Skip to contentSkip to conversation

video: bochs: fix IOMEM usage

PATCH Applied Denis Orlov 3 participants 3 messages May 11, 2023 – May 12, 2023 Framebuffer layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 video: bochs: fix IOMEM usage

For the PCI version of the driver, we end up calling IOMEM() twice on both the fb_map and mmio pointers. This happens because we first use pci_iomap() on PCI resources in the bochs_pci_probe() and then explicitly call IOMEM() in the bochs_hw_probe(). However, judging from the parameters of the latter function having __iomem attributes, we should not be remapping them. So, remove those IOMEM calls and instead do explicit remapping in bochs_isa_detect(), which was missing it.

Also fix bochs_hw_probe() declaration missing one __iomem.

---
 drivers/video/bochs/bochs_hw.c  | 4 ++--
 drivers/video/bochs/bochs_hw.h  | 2 +-
 drivers/video/bochs/bochs_isa.c | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)
drivers/video/bochs/bochs_hw.c +2 -2
index f31020acd4..48de5ea0bd 100644
@@ -158,8 +158,8 @@ int bochs_hw_probe(struct device *dev, void __iomem *fb_map,
 
 	bochs = xzalloc(sizeof(*bochs));
 
-	bochs->fb_map	= IOMEM(fb_map);
-	bochs->mmio	= IOMEM(mmio);
+	bochs->fb_map	= fb_map;
+	bochs->mmio	= mmio;
 
 	ret = bochs_hw_read_version(bochs);
 	if (ret < 0) {
drivers/video/bochs/bochs_hw.h +1 -1
index e01ef13d47..c721113656 100644
@@ -10,6 +10,6 @@
 
 struct device;
 
-int bochs_hw_probe(struct device *dev, void *fb_map, void __iomem *mmio);
+int bochs_hw_probe(struct device *dev, void __iomem *fb_map, void __iomem *mmio);
 
 #endif
drivers/video/bochs/bochs_isa.c +1 -1
index 3cedb5c345..50fdecd9c8 100644
@@ -26,6 +26,6 @@ static int bochs_isa_detect(void)
 	if (ret)
 		return ret;
 
-	return bochs_hw_probe(dev, (void *)0xe0000000, NULL);
+	return bochs_hw_probe(dev, IOMEM(0xe0000000), NULL);
 }
 device_initcall(bochs_isa_detect);
Signature · 1 line
2.30.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Denis Orlov

For the PCI version of the driver, we end up calling IOMEM() twice on both the fb_map and mmio pointers. This happens because we first use pci_iomap() on PCI resources in the bochs_pci_probe() and then explicitly call IOMEM() in the bochs_hw_probe(). However, judging from the parameters of the latter function having __iomem attributes, we should not be remapping them. So, remove those IOMEM calls and instead do explicit remapping in bochs_isa_detect(), which was missing it.

Also fix bochs_hw_probe() declaration missing one __iomem.

Thanks!
Ahmad

Quoted 45 lines
---
 drivers/video/bochs/bochs_hw.c  | 4 ++--
 drivers/video/bochs/bochs_hw.h  | 2 +-
 drivers/video/bochs/bochs_isa.c | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)
drivers/video/bochs/bochs_hw.c +2 -2
index f31020acd4..48de5ea0bd 100644
@@ -158,8 +158,8 @@ int bochs_hw_probe(struct device *dev, void __iomem *fb_map,
 
 	bochs = xzalloc(sizeof(*bochs));
 
-	bochs->fb_map	= IOMEM(fb_map);
-	bochs->mmio	= IOMEM(mmio);
+	bochs->fb_map	= fb_map;
+	bochs->mmio	= mmio;
 
 	ret = bochs_hw_read_version(bochs);
 	if (ret < 0) {
drivers/video/bochs/bochs_hw.h +1 -1
index e01ef13d47..c721113656 100644
@@ -10,6 +10,6 @@
 
 struct device;
 
-int bochs_hw_probe(struct device *dev, void *fb_map, void __iomem *mmio);
+int bochs_hw_probe(struct device *dev, void __iomem *fb_map, void __iomem *mmio);
 
 #endif
drivers/video/bochs/bochs_isa.c +1 -1
index 3cedb5c345..50fdecd9c8 100644
@@ -26,6 +26,6 @@ static int bochs_isa_detect(void)
 	if (ret)
 		return ret;
 
-	return bochs_hw_probe(dev, (void *)0xe0000000, NULL);
+	return bochs_hw_probe(dev, IOMEM(0xe0000000), NULL);
 }
 device_initcall(bochs_isa_detect);
Signature · 4 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
Applied
#2 lore raw
In reply to Denis Orlov
Quoted 8 lines · Denis Orlov

For the PCI version of the driver, we end up calling IOMEM() twice on both the fb_map and mmio pointers. This happens because we first use pci_iomap() on PCI resources in the bochs_pci_probe() and then explicitly call IOMEM() in the bochs_hw_probe(). However, judging from the parameters of the latter function having __iomem attributes, we should not be remapping them. So, remove those IOMEM calls and instead do explicit remapping in bochs_isa_detect(), which was missing it.

Quoted 8 lines

Also fix bochs_hw_probe() declaration missing one __iomem.

---
 drivers/video/bochs/bochs_hw.c  | 4 ++--
 drivers/video/bochs/bochs_hw.h  | 2 +-
 drivers/video/bochs/bochs_isa.c | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

Applied, thanks

Sascha

Quoted 44 lines
drivers/video/bochs/bochs_hw.c +2 -2
index f31020acd4..48de5ea0bd 100644
@@ -158,8 +158,8 @@ int bochs_hw_probe(struct device *dev, void __iomem *fb_map,
 
 	bochs = xzalloc(sizeof(*bochs));
 
-	bochs->fb_map	= IOMEM(fb_map);
-	bochs->mmio	= IOMEM(mmio);
+	bochs->fb_map	= fb_map;
+	bochs->mmio	= mmio;
 
 	ret = bochs_hw_read_version(bochs);
 	if (ret < 0) {
drivers/video/bochs/bochs_hw.h +1 -1
index e01ef13d47..c721113656 100644
@@ -10,6 +10,6 @@
 
 struct device;
 
-int bochs_hw_probe(struct device *dev, void *fb_map, void __iomem *mmio);
+int bochs_hw_probe(struct device *dev, void __iomem *fb_map, void __iomem *mmio);
 
 #endif
drivers/video/bochs/bochs_isa.c +1 -1
index 3cedb5c345..50fdecd9c8 100644
@@ -26,6 +26,6 @@ static int bochs_isa_detect(void)
 	if (ret)
 		return ret;
 
-	return bochs_hw_probe(dev, (void *)0xe0000000, NULL);
+	return bochs_hw_probe(dev, IOMEM(0xe0000000), NULL);
 }
 device_initcall(bochs_isa_detect);
Signature · 1 line
2.30.2
Signature · 4 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |