[Skiboot] [PATCH 2/4] npu/pau: endian fixes
Nicholas Piggin
npiggin at gmail.com
Sun Nov 10 23:56:35 AEDT 2024
Add endian annotations to NPU OPAL APIs, and fix warnings and bugs
reported by sparse.
Signed-off-by: Nicholas Piggin <npiggin at gmail.com>
---
hw/npu-opal.c | 4 ++--
hw/npu2-opencapi.c | 2 +-
hw/pau.c | 19 ++++++++++---------
include/npu2.h | 2 +-
include/pau.h | 2 +-
5 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/hw/npu-opal.c b/hw/npu-opal.c
index 1b66857f4..943ac608c 100644
--- a/hw/npu-opal.c
+++ b/hw/npu-opal.c
@@ -241,7 +241,7 @@ static int64_t opal_npu_tl_set(uint64_t phb_id, uint32_t bdfn,
opal_call(OPAL_NPU_TL_SET, opal_npu_tl_set, 5);
static int64_t opal_npu_mem_alloc(uint64_t phb_id, uint32_t bdfn,
- uint64_t size, uint64_t *bar)
+ uint64_t size, __be64 *bar)
{
struct phb *phb = pci_get_phb(phb_id);
@@ -260,7 +260,7 @@ opal_call(OPAL_NPU_MEM_ALLOC, opal_npu_mem_alloc, 4);
static int64_t opal_npu_mem_release(uint64_t phb_id, uint32_t bdfn)
{
- struct phb *phb = pci_get_phb(phb_id);;
+ struct phb *phb = pci_get_phb(phb_id);
if (!phb)
return OPAL_PARAMETER;
diff --git a/hw/npu2-opencapi.c b/hw/npu2-opencapi.c
index 8e7bcca93..8004d85b9 100644
--- a/hw/npu2-opencapi.c
+++ b/hw/npu2-opencapi.c
@@ -2296,7 +2296,7 @@ out:
}
int64_t npu2_opencapi_mem_alloc(struct phb *phb, uint32_t __unused bdfn,
- uint64_t size, uint64_t *__bar)
+ uint64_t size, __be64 *__bar)
{
struct npu2_dev *dev;
uint64_t bar;
diff --git a/hw/pau.c b/hw/pau.c
index 1a3fbfaf7..144e58456 100644
--- a/hw/pau.c
+++ b/hw/pau.c
@@ -444,7 +444,7 @@ int64_t pau_opencapi_tl_set(struct phb *phb, uint32_t __unused bdfn,
static int64_t pau_opencapi_afu_memory_bars(struct pau_dev *dev,
uint64_t size,
- uint64_t *bar)
+ __be64 *bar)
{
struct pau *pau = dev->pau;
uint64_t addr, psize;
@@ -492,12 +492,13 @@ static int64_t pau_opencapi_afu_memory_bars(struct pau_dev *dev,
reg = PAU_XSL_GPU_MEM_BAR(dev->index);
pau_write(pau, reg, val);
- *bar = addr;
+ *bar = cpu_to_be64(addr);
+
return OPAL_SUCCESS;
}
int64_t pau_opencapi_mem_alloc(struct phb *phb, uint32_t __unused bdfn,
- uint64_t size, uint64_t *bar)
+ uint64_t size, __be64 *bar)
{
struct pau_dev *dev = pau_phb_to_opencapi_dev(phb);
int64_t rc;
@@ -1302,7 +1303,7 @@ static int64_t pau_opencapi_pcicfg_read(struct phb *phb, uint32_t bdfn,
cfg_addr = SETFIELD(PAU_CTL_MISC_CFG_ADDR_REGISTER_NBR,
cfg_addr, offset & ~3u);
- out_be64((uint64_t *)genid_base, cfg_addr);
+ out_be64((__be64 *)genid_base, cfg_addr);
sync();
switch (size) {
@@ -1312,10 +1313,10 @@ static int64_t pau_opencapi_pcicfg_read(struct phb *phb, uint32_t bdfn,
break;
case 2:
*((uint16_t *)data) =
- in_le16((uint16_t *)(genid_base + 128 + (offset & 2)));
+ in_le16((__le16 *)(genid_base + 128 + (offset & 2)));
break;
case 4:
- *((uint32_t *)data) = in_le32((uint32_t *)(genid_base + 128));
+ *((uint32_t *)data) = in_le32((__le32 *)(genid_base + 128));
break;
default:
return OPAL_PARAMETER;
@@ -1358,7 +1359,7 @@ static int64_t pau_opencapi_pcicfg_write(struct phb *phb, uint32_t bdfn,
cfg_addr = SETFIELD(PAU_CTL_MISC_CFG_ADDR_REGISTER_NBR,
cfg_addr, offset & ~3u);
- out_be64((uint64_t *)genid_base, cfg_addr);
+ out_be64((__be64 *)genid_base, cfg_addr);
sync();
switch (size) {
@@ -1366,10 +1367,10 @@ static int64_t pau_opencapi_pcicfg_write(struct phb *phb, uint32_t bdfn,
out_8((uint8_t *)(genid_base + 128 + (offset & 3)), data);
break;
case 2:
- out_le16((uint16_t *)(genid_base + 128 + (offset & 2)), data);
+ out_le16((__le16 *)(genid_base + 128 + (offset & 2)), data);
break;
case 4:
- out_le32((uint32_t *)(genid_base + 128), data);
+ out_le32((__le32 *)(genid_base + 128), data);
break;
default:
return OPAL_PARAMETER;
diff --git a/include/npu2.h b/include/npu2.h
index b302108b9..bc1a74ea1 100644
--- a/include/npu2.h
+++ b/include/npu2.h
@@ -278,7 +278,7 @@ int64_t npu2_opencapi_spa_clear_cache(struct phb *phb, uint32_t __unused bdfn,
int64_t npu2_opencapi_tl_set(struct phb *phb, uint32_t __unused bdfn,
long capabilities, char *rate);
int64_t npu2_opencapi_mem_alloc(struct phb *phb, uint32_t __unused bdfn,
- uint64_t size, uint64_t *bar);
+ uint64_t size, __be64 *bar);
int64_t npu2_opencapi_mem_release(struct phb *phb, uint32_t __unused bdfn);
#endif /* __NPU2_H */
diff --git a/include/pau.h b/include/pau.h
index 4a6087cbf..8d5e32071 100644
--- a/include/pau.h
+++ b/include/pau.h
@@ -211,7 +211,7 @@ int64_t pau_opencapi_spa_clear_cache(struct phb *phb,
int64_t pau_opencapi_tl_set(struct phb *phb, uint32_t __unused bdfn,
long capabilities, char *rate_buf);
int64_t pau_opencapi_mem_alloc(struct phb *phb, uint32_t __unused bdfn,
- uint64_t size, uint64_t *bar);
+ uint64_t size, __be64 *bar);
int64_t pau_opencapi_mem_release(struct phb *phb, uint32_t __unused bdfn);
/* PHY */
--
2.45.2
More information about the Skiboot
mailing list