* [PATCH v3 0/2] drm/ofdrm: Fix sparse warnings
@ 2022-11-03 10:16 Thomas Zimmermann
2022-11-03 10:16 ` [PATCH v3 1/2] drm/ofdrm: Convert PCI IDs to CPU endianness for comparing Thomas Zimmermann
2022-11-03 10:16 ` [PATCH v3 2/2] drm/ofdrm: Cast error pointers to void __iomem * Thomas Zimmermann
0 siblings, 2 replies; 3+ messages in thread
From: Thomas Zimmermann @ 2022-11-03 10:16 UTC (permalink / raw)
To: alexander.stein, javierm, airlied, daniel; +Cc: Thomas Zimmermann, dri-devel
Fix two types of sparse warnings in ofdrm. Reported by the LKP bot.
v3:
* use IOMEM_ERR_PTR() (Javier)
v2:
* convert PCI ID endianness (Alex)
Thomas Zimmermann (2):
drm/ofdrm: Convert PCI IDs to CPU endianness for comparing
drm/ofdrm: Cast error pointers to void __iomem *
drivers/gpu/drm/tiny/ofdrm.c | 27 ++++++++++++++++-----------
1 file changed, 16 insertions(+), 11 deletions(-)
base-commit: f5a9fb2d688dfc6efa1fd779a2d225048bfb10f9
--
2.38.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v3 1/2] drm/ofdrm: Convert PCI IDs to CPU endianness for comparing
2022-11-03 10:16 [PATCH v3 0/2] drm/ofdrm: Fix sparse warnings Thomas Zimmermann
@ 2022-11-03 10:16 ` Thomas Zimmermann
2022-11-03 10:16 ` [PATCH v3 2/2] drm/ofdrm: Cast error pointers to void __iomem * Thomas Zimmermann
1 sibling, 0 replies; 3+ messages in thread
From: Thomas Zimmermann @ 2022-11-03 10:16 UTC (permalink / raw)
To: alexander.stein, javierm, airlied, daniel
Cc: Thomas Zimmermann, dri-devel, kernel test robot
Properties of 32-bit integers are returned from the OF device tree
as type __be32. Convert PCI vendor and device IDs from __be32 to host
endianness before comparing them to constants. All relevant machines
are old, big-endian Macintosh systems; hence the bug never happened
in practice.
Fixes sparse warnings shown below.
drivers/gpu/drm/tiny/ofdrm.c:237:17: warning: restricted __be32 degrades to integer
drivers/gpu/drm/tiny/ofdrm.c:238:18: warning: restricted __be32 degrades to integer
drivers/gpu/drm/tiny/ofdrm.c:238:54: warning: restricted __be32 degrades to integer
See [1] for the bug report.
v2:
* convert endianness (Alex)
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Link: https://lore.kernel.org/dri-devel/202210192208.D888I6X7-lkp@intel.com/ # [1]
---
drivers/gpu/drm/tiny/ofdrm.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/tiny/ofdrm.c b/drivers/gpu/drm/tiny/ofdrm.c
index 0e1cc2369afcc..44f13a2b372be 100644
--- a/drivers/gpu/drm/tiny/ofdrm.c
+++ b/drivers/gpu/drm/tiny/ofdrm.c
@@ -231,7 +231,7 @@ static u64 display_get_address_of(struct drm_device *dev, struct device_node *of
return address;
}
-static bool is_avivo(__be32 vendor, __be32 device)
+static bool is_avivo(u32 vendor, u32 device)
{
/* This will match most R5xx */
return (vendor == PCI_VENDOR_ID_ATI) &&
@@ -265,8 +265,13 @@ static enum ofdrm_model display_get_model_of(struct drm_device *dev, struct devi
of_parent = of_get_parent(of_node);
vendor_p = of_get_property(of_parent, "vendor-id", NULL);
device_p = of_get_property(of_parent, "device-id", NULL);
- if (vendor_p && device_p && is_avivo(*vendor_p, *device_p))
- model = OFDRM_MODEL_AVIVO;
+ if (vendor_p && device_p) {
+ u32 vendor = be32_to_cpup(vendor_p);
+ u32 device = be32_to_cpup(device_p);
+
+ if (is_avivo(vendor, device))
+ model = OFDRM_MODEL_AVIVO;
+ }
of_node_put(of_parent);
} else if (of_device_is_compatible(of_node, "qemu,std-vga")) {
model = OFDRM_MODEL_QEMU;
--
2.38.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v3 2/2] drm/ofdrm: Cast error pointers to void __iomem *
2022-11-03 10:16 [PATCH v3 0/2] drm/ofdrm: Fix sparse warnings Thomas Zimmermann
2022-11-03 10:16 ` [PATCH v3 1/2] drm/ofdrm: Convert PCI IDs to CPU endianness for comparing Thomas Zimmermann
@ 2022-11-03 10:16 ` Thomas Zimmermann
1 sibling, 0 replies; 3+ messages in thread
From: Thomas Zimmermann @ 2022-11-03 10:16 UTC (permalink / raw)
To: alexander.stein, javierm, airlied, daniel
Cc: Thomas Zimmermann, dri-devel, kernel test robot
Cast error pointers when returning them as void __iomem *. Fixes
a number of Sparse warnings, such as the ones shown below.
../drivers/gpu/drm/tiny/ofdrm.c:439:31: warning: incorrect type in return expression (different address spaces)
../drivers/gpu/drm/tiny/ofdrm.c:439:31: expected void [noderef] __iomem *
../drivers/gpu/drm/tiny/ofdrm.c:439:31: got void *
../drivers/gpu/drm/tiny/ofdrm.c:442:31: warning: incorrect type in return expression (different address spaces)
../drivers/gpu/drm/tiny/ofdrm.c:442:31: expected void [noderef] __iomem *
../drivers/gpu/drm/tiny/ofdrm.c:442:31: got void *
See [1] for the bug report.
v3:
* use IOMEM_ERR_PTR() (Javier)
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Link: https://lore.kernel.org/dri-devel/202210200016.yiQzPIy0-lkp@intel.com/ # [1]
---
drivers/gpu/drm/tiny/ofdrm.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/gpu/drm/tiny/ofdrm.c b/drivers/gpu/drm/tiny/ofdrm.c
index 44f13a2b372be..d7f98dcf23300 100644
--- a/drivers/gpu/drm/tiny/ofdrm.c
+++ b/drivers/gpu/drm/tiny/ofdrm.c
@@ -438,21 +438,21 @@ static void __iomem *get_cmap_address_of(struct ofdrm_device *odev, struct devic
if (!addr_p)
addr_p = of_get_address(of_node, bar_no, &max_size, &flags);
if (!addr_p)
- return ERR_PTR(-ENODEV);
+ return IOMEM_ERR_PTR(-ENODEV);
if ((flags & (IORESOURCE_IO | IORESOURCE_MEM)) == 0)
- return ERR_PTR(-ENODEV);
+ return IOMEM_ERR_PTR(-ENODEV);
if ((offset + size) >= max_size)
- return ERR_PTR(-ENODEV);
+ return IOMEM_ERR_PTR(-ENODEV);
address = of_translate_address(of_node, addr_p);
if (address == OF_BAD_ADDR)
- return ERR_PTR(-ENODEV);
+ return IOMEM_ERR_PTR(-ENODEV);
mem = devm_ioremap(dev->dev, address + offset, size);
if (!mem)
- return ERR_PTR(-ENOMEM);
+ return IOMEM_ERR_PTR(-ENOMEM);
return mem;
}
@@ -470,7 +470,7 @@ static void __iomem *ofdrm_mach64_cmap_ioremap(struct ofdrm_device *odev,
cmap_base = devm_ioremap(dev->dev, address, 0x1000);
if (!cmap_base)
- return ERR_PTR(-ENOMEM);
+ return IOMEM_ERR_PTR(-ENOMEM);
return cmap_base;
}
@@ -629,11 +629,11 @@ static void __iomem *ofdrm_qemu_cmap_ioremap(struct ofdrm_device *odev,
address = of_translate_address(of_node, io_of_addr);
if (address == OF_BAD_ADDR)
- return ERR_PTR(-ENODEV);
+ return IOMEM_ERR_PTR(-ENODEV);
cmap_base = devm_ioremap(dev->dev, address + 0x3c8, 2);
if (!cmap_base)
- return ERR_PTR(-ENOMEM);
+ return IOMEM_ERR_PTR(-ENOMEM);
return cmap_base;
}
--
2.38.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-11-03 10:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-03 10:16 [PATCH v3 0/2] drm/ofdrm: Fix sparse warnings Thomas Zimmermann
2022-11-03 10:16 ` [PATCH v3 1/2] drm/ofdrm: Convert PCI IDs to CPU endianness for comparing Thomas Zimmermann
2022-11-03 10:16 ` [PATCH v3 2/2] drm/ofdrm: Cast error pointers to void __iomem * Thomas Zimmermann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).