Skip to content

Commit 92b19ff

Browse files
committed
cleanup IORESOURCE_CACHEABLE vs ioremap()
Quoting Arnd: I was thinking the opposite approach and basically removing all uses of IORESOURCE_CACHEABLE from the kernel. There are only a handful of them.and we can probably replace them all with hardcoded ioremap_cached() calls in the cases they are actually useful. All existing usages of IORESOURCE_CACHEABLE call ioremap() instead of ioremap_nocache() if the resource is cacheable, however ioremap() is uncached by default. Clearly none of the existing usages care about the cacheability. Particularly devm_ioremap_resource() never worked as advertised since it always fell back to plain ioremap(). Clean this up as the new direction we want is to convert ioremap_<type>() usages to memremap(..., flags). Suggested-by: Arnd Bergmann <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Dan Williams <[email protected]>
1 parent 2584cf8 commit 92b19ff

File tree

11 files changed

+16
-44
lines changed

11 files changed

+16
-44
lines changed

arch/arm/mach-clps711x/board-cdb89712.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ static struct physmap_flash_data cdb89712_bootrom_pdata __initdata = {
9595

9696
static struct resource cdb89712_bootrom_resources[] __initdata = {
9797
DEFINE_RES_NAMED(CS7_PHYS_BASE, SZ_128, "BOOTROM", IORESOURCE_MEM |
98-
IORESOURCE_CACHEABLE | IORESOURCE_READONLY),
98+
IORESOURCE_READONLY),
9999
};
100100

101101
static struct platform_device cdb89712_bootrom_pdev __initdata = {

arch/powerpc/kernel/pci_of_scan.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ static void of_pci_parse_addrs(struct device_node *node, struct pci_dev *dev)
102102
res = &dev->resource[(i - PCI_BASE_ADDRESS_0) >> 2];
103103
} else if (i == dev->rom_base_reg) {
104104
res = &dev->resource[PCI_ROM_RESOURCE];
105-
flags |= IORESOURCE_READONLY | IORESOURCE_CACHEABLE;
105+
flags |= IORESOURCE_READONLY;
106106
} else {
107107
printk(KERN_ERR "PCI: bad cfg reg num 0x%x\n", i);
108108
continue;

arch/sparc/kernel/pci.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,7 @@ static void pci_parse_of_addrs(struct platform_device *op,
231231
res = &dev->resource[(i - PCI_BASE_ADDRESS_0) >> 2];
232232
} else if (i == dev->rom_base_reg) {
233233
res = &dev->resource[PCI_ROM_RESOURCE];
234-
flags |= IORESOURCE_READONLY | IORESOURCE_CACHEABLE
235-
| IORESOURCE_SIZEALIGN;
234+
flags |= IORESOURCE_READONLY | IORESOURCE_SIZEALIGN;
236235
} else {
237236
printk(KERN_ERR "PCI: bad cfg reg num 0x%x\n", i);
238237
continue;

drivers/pci/probe.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,7 @@ static void pci_read_bases(struct pci_dev *dev, unsigned int howmany, int rom)
326326
struct resource *res = &dev->resource[PCI_ROM_RESOURCE];
327327
dev->rom_base_reg = rom;
328328
res->flags = IORESOURCE_MEM | IORESOURCE_PREFETCH |
329-
IORESOURCE_READONLY | IORESOURCE_CACHEABLE |
330-
IORESOURCE_SIZEALIGN;
329+
IORESOURCE_READONLY | IORESOURCE_SIZEALIGN;
331330
__pci_read_base(dev, pci_bar_mem32, res, rom);
332331
}
333332
}

drivers/pnp/manager.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,6 @@ static int pnp_assign_mem(struct pnp_dev *dev, struct pnp_mem *rule, int idx)
9797
/* ??? rule->flags restricted to 8 bits, all tests bogus ??? */
9898
if (!(rule->flags & IORESOURCE_MEM_WRITEABLE))
9999
res->flags |= IORESOURCE_READONLY;
100-
if (rule->flags & IORESOURCE_MEM_CACHEABLE)
101-
res->flags |= IORESOURCE_CACHEABLE;
102100
if (rule->flags & IORESOURCE_MEM_RANGELENGTH)
103101
res->flags |= IORESOURCE_RANGELENGTH;
104102
if (rule->flags & IORESOURCE_MEM_SHADOWABLE)

drivers/scsi/aic94xx/aic94xx_init.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,7 @@ static int asd_map_memio(struct asd_ha_struct *asd_ha)
100100
pci_name(asd_ha->pcidev));
101101
goto Err;
102102
}
103-
if (io_handle->flags & IORESOURCE_CACHEABLE)
104-
io_handle->addr = ioremap(io_handle->start,
105-
io_handle->len);
106-
else
107-
io_handle->addr = ioremap_nocache(io_handle->start,
108-
io_handle->len);
103+
io_handle->addr = ioremap(io_handle->start, io_handle->len);
109104
if (!io_handle->addr) {
110105
asd_printk("couldn't map MBAR%d of %s\n", i==0?0:1,
111106
pci_name(asd_ha->pcidev));

drivers/scsi/arcmsr/arcmsr_hba.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,7 @@ static bool arcmsr_remap_pciregion(struct AdapterControlBlock *acb)
259259
addr = (unsigned long)pci_resource_start(pdev, 0);
260260
range = pci_resource_len(pdev, 0);
261261
flags = pci_resource_flags(pdev, 0);
262-
if (flags & IORESOURCE_CACHEABLE)
263-
mem_base0 = ioremap(addr, range);
264-
else
265-
mem_base0 = ioremap_nocache(addr, range);
262+
mem_base0 = ioremap(addr, range);
266263
if (!mem_base0) {
267264
pr_notice("arcmsr%d: memory mapping region fail\n",
268265
acb->host->host_no);

drivers/scsi/mvsas/mv_init.c

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -324,13 +324,9 @@ int mvs_ioremap(struct mvs_info *mvi, int bar, int bar_ex)
324324
goto err_out;
325325

326326
res_flag_ex = pci_resource_flags(pdev, bar_ex);
327-
if (res_flag_ex & IORESOURCE_MEM) {
328-
if (res_flag_ex & IORESOURCE_CACHEABLE)
329-
mvi->regs_ex = ioremap(res_start, res_len);
330-
else
331-
mvi->regs_ex = ioremap_nocache(res_start,
332-
res_len);
333-
} else
327+
if (res_flag_ex & IORESOURCE_MEM)
328+
mvi->regs_ex = ioremap(res_start, res_len);
329+
else
334330
mvi->regs_ex = (void *)res_start;
335331
if (!mvi->regs_ex)
336332
goto err_out;
@@ -342,10 +338,7 @@ int mvs_ioremap(struct mvs_info *mvi, int bar, int bar_ex)
342338
goto err_out;
343339

344340
res_flag = pci_resource_flags(pdev, bar);
345-
if (res_flag & IORESOURCE_CACHEABLE)
346-
mvi->regs = ioremap(res_start, res_len);
347-
else
348-
mvi->regs = ioremap_nocache(res_start, res_len);
341+
mvi->regs = ioremap(res_start, res_len);
349342

350343
if (!mvi->regs) {
351344
if (mvi->regs_ex && (res_flag_ex & IORESOURCE_MEM))

drivers/video/fbdev/ocfb.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,6 @@ static int ocfb_probe(struct platform_device *pdev)
325325
dev_err(&pdev->dev, "I/O resource request failed\n");
326326
return -ENXIO;
327327
}
328-
res->flags &= ~IORESOURCE_CACHEABLE;
329328
fbdev->regs = devm_ioremap_resource(&pdev->dev, res);
330329
if (IS_ERR(fbdev->regs))
331330
return PTR_ERR(fbdev->regs);

lib/devres.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,9 @@ EXPORT_SYMBOL(devm_iounmap);
119119
* @dev: generic device to handle the resource for
120120
* @res: resource to be handled
121121
*
122-
* Checks that a resource is a valid memory region, requests the memory region
123-
* and ioremaps it either as cacheable or as non-cacheable memory depending on
124-
* the resource's flags. All operations are managed and will be undone on
125-
* driver detach.
122+
* Checks that a resource is a valid memory region, requests the memory
123+
* region and ioremaps it. All operations are managed and will be undone
124+
* on driver detach.
126125
*
127126
* Returns a pointer to the remapped memory or an ERR_PTR() encoded error code
128127
* on failure. Usage example:
@@ -153,11 +152,7 @@ void __iomem *devm_ioremap_resource(struct device *dev, struct resource *res)
153152
return IOMEM_ERR_PTR(-EBUSY);
154153
}
155154

156-
if (res->flags & IORESOURCE_CACHEABLE)
157-
dest_ptr = devm_ioremap(dev, res->start, size);
158-
else
159-
dest_ptr = devm_ioremap_nocache(dev, res->start, size);
160-
155+
dest_ptr = devm_ioremap(dev, res->start, size);
161156
if (!dest_ptr) {
162157
dev_err(dev, "ioremap failed for resource %pR\n", res);
163158
devm_release_mem_region(dev, res->start, size);

0 commit comments

Comments
 (0)