ATA: Replace deprecated PCI functions
Subsystems (2)
cover ATA: Replace deprecated PCI functions
Hi,
many of you probably know that I'm trying to remove pcim_iomap_regions() from the kernel. One of the more difficult users is ATA, because it's the only subsystem I've seen so far that accesses that table pcim_iomap_table() administrates.
This series only builds as a whole because of patch 1. That's why I submit it as an RFC.
I want to know whether you agree with the basic idea, and whether your subsystem wants this series to be squashed into a single commit that builds.
Another solution would be to provide a struct ata_host.iomap2 or something like that, phase out the pcim_iomap_regions() users, and then remove iomap2 again.
Please tell me your preferred way.
(This is the revived version of an old series from August. In case someone is wondering)
Thx,
P.
Philipp Stanner (3):
ata: Allocate PCI iomap table statically
ata: Replace deprecated PCI functions
libata-sff: Simplify request of PCI resources
drivers/ata/ata_piix.c | 7 +- drivers/ata/libata-sff.c | 130 +++++++++++++++++++++++------------- drivers/ata/pata_atp867x.c | 13 ++-- drivers/ata/pata_hpt3x3.c | 10 +-- drivers/ata/pata_ninja32.c | 11 +-- drivers/ata/pata_pdc2027x.c | 11 ++- drivers/ata/pata_sil680.c | 12 ++-- drivers/ata/pdc_adma.c | 9 ++- drivers/ata/sata_inic162x.c | 10 ++- drivers/ata/sata_mv.c | 9 +-- drivers/ata/sata_nv.c | 8 +-- drivers/ata/sata_promise.c | 8 ++- drivers/ata/sata_qstor.c | 7 +- drivers/ata/sata_sil.c | 8 ++- drivers/ata/sata_sil24.c | 20 +++--- drivers/ata/sata_sis.c | 8 +-- drivers/ata/sata_svw.c | 10 +-- drivers/ata/sata_sx4.c | 19 +++++- drivers/ata/sata_via.c | 31 +++++---- drivers/ata/sata_vsc.c | 8 ++- include/linux/libata.h | 7 +- 21 files changed, 216 insertions(+), 140 deletions(-)
Signature · 1 line
2.47.0
RFC PATCH 1/3 ata: Allocate PCI iomap table statically
struct ata_host.iomap has been created and administrated so far by pcim_iomap_table(), a problematic function that has been deprecated in commit e354bb84a4c1c ("PCI: Deprecate pcim_iomap_table(), pcim_iomap_regions_request_all()")
Ideally, drivers should not need a global table at all and should store ioremaped BARs in their respective structs separately. For ATA, however, it's far easier to deprecate pcim_iomap_table() by allocating struct ata_host.iomap statically as an array of iomem pointers. Since PCI_STD_NUM_BARS is currently defined to be 6, the memory overhead is irrelevant.
Make struct ata_host.iomap a static iomem pointer table.
--- include/linux/libata.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
include/linux/libata.h +6 -1
@@ -23,6 +23,9 @@#include <linux/cdrom.h> #include <linux/sched.h> #include <linux/async.h> +#ifdef CONFIG_PCI +#include <linux/pci_regs.h> /* for PCI_STD_NUM_BARS */ +#endif /* CONFIG_PCI */ /* * Define if arch has non-standard setup. This is a _PCI_ standard
@@ -615,7 +618,9 @@ struct ata_ioports {struct ata_host {spinlock_t lock;struct device *dev; -void __iomem *const *iomap; +#ifdef CONFIG_PCI +void __iomem *iomap[PCI_STD_NUM_BARS ]; +#endif /* CONFIG_PCI */ unsigned int n_ports;unsigned int n_tags;/* nr of NCQ tags */ void *private_data;
Signature · 1 line
2.47.0
kernel test robot
build botRe: [RFC PATCH 1/3] ata: Allocate PCI iomap table statically
kernel test robot noticed the following build errors:
Hi Philipp,
[This is a private test report for your RFC patch.] kernel test robot noticed the following build errors:
[auto build test ERROR on linus/master]
[also build test ERROR on v6.13-rc1 next-20241205]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Philipp-Stanner/ata-Allocate-PCI-iomap-table-statically/20241205-014059 base: linus/master patch link: https://lore.kernel.org/r/20241204171033.86804-3-pstanner%40redhat.com patch subject: [RFC PATCH 1/3] ata: Allocate PCI iomap table statically config: powerpc-allmodconfig (https://download.01.org/0day-ci/archive/20241206/[email protected]/config) compiler: powerpc64-linux-gcc (GCC) 14.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241206/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
drivers/ata/pata_macio.c: In function 'pata_macio_common_init':
>> drivers/ata/pata_macio.c:1089:27: error: assignment to expression with array type
1089 | priv->host->iomap = &priv->tfregs;
| ^vim +1089 drivers/ata/pata_macio.c
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1048
0ec24914675c482 Greg Kroah-Hartman 2012-12-21 1049 static int pata_macio_common_init(struct pata_macio_priv *priv,
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1050 resource_size_t tfregs,
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1051 resource_size_t dmaregs,
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1052 resource_size_t fcregs,
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1053 unsigned long irq)
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1054 {
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1055 struct ata_port_info pinfo;
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1056 const struct ata_port_info *ppi[] = { &pinfo, NULL };
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1057 void __iomem *dma_regs = NULL;
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1058
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1059 /* Fill up privates with various invariants collected from the
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1060 * device-tree
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1061 */
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1062 pata_macio_invariants(priv);
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1063
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1064 /* Make sure we have sane initial timings in the cache */
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1065 pata_macio_default_timings(priv);
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1066
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1067 /* Allocate libata host for 1 port */
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1068 memset(&pinfo, 0, sizeof(struct ata_port_info));
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1069 pmac_macio_calc_timing_masks(priv, &pinfo);
9cbe056f6c467e7 Sergei Shtylyov 2011-02-04 1070 pinfo.flags = ATA_FLAG_SLAVE_POSS;
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1071 pinfo.port_ops = &pata_macio_ops;
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1072 pinfo.private_data = priv;
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1073
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1074 priv->host = ata_host_alloc_pinfo(priv->dev, ppi, 1);
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1075 if (priv->host == NULL) {
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1076 dev_err(priv->dev, "Failed to allocate ATA port structure\n");
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1077 return -ENOMEM;
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1078 }
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1079
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1080 /* Setup the private data in host too */
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1081 priv->host->private_data = priv;
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1082
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1083 /* Map base registers */
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1084 priv->tfregs = devm_ioremap(priv->dev, tfregs, 0x100);
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1085 if (priv->tfregs == NULL) {
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1086 dev_err(priv->dev, "Failed to map ATA ports\n");
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1087 return -ENOMEM;
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1088 }
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 @1089 priv->host->iomap = &priv->tfregs;
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1090
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1091 /* Map DMA regs */
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1092 if (dmaregs != 0) {
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1093 dma_regs = devm_ioremap(priv->dev, dmaregs,
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1094 sizeof(struct dbdma_regs));
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1095 if (dma_regs == NULL)
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1096 dev_warn(priv->dev, "Failed to map ATA DMA registers\n");
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1097 }
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1098
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1099 /* If chip has local feature control, map those regs too */
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1100 if (fcregs != 0) {
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1101 priv->kauai_fcr = devm_ioremap(priv->dev, fcregs, 4);
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1102 if (priv->kauai_fcr == NULL) {
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1103 dev_err(priv->dev, "Failed to map ATA FCR register\n");
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1104 return -ENOMEM;
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1105 }
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1106 }
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1107
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1108 /* Setup port data structure */
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1109 pata_macio_setup_ios(&priv->host->ports[0]->ioaddr,
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1110 priv->tfregs, dma_regs);
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1111 priv->host->ports[0]->private_data = priv;
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1112
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1113 /* hard-reset the controller */
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1114 pata_macio_reset_hw(priv, 0);
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1115 pata_macio_apply_timings(priv->host->ports[0], 0);
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1116
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1117 /* Enable bus master if necessary */
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1118 if (priv->pdev && dma_regs)
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1119 pci_set_master(priv->pdev);
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1120
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1121 dev_info(priv->dev, "Activating pata-macio chipset %s, Apple bus ID %d\n",
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1122 macio_ata_names[priv->kind], priv->aapl_bus_id);
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1123
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1124 /* Start it up */
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1125 priv->irq = irq;
c3b2889424c26f3 Tejun Heo 2010-05-19 1126 return ata_host_activate(priv->host, irq, ata_bmdma_interrupt, 0,
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1127 &pata_macio_sht);
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1128 }
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1129 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [RFC PATCH 1/3] ata: Allocate PCI iomap table statically
In reply to Philipp Stannerkernel test robot noticed the following build errors:
Hi Philipp,
[This is a private test report for your RFC patch.] kernel test robot noticed the following build errors:
[auto build test ERROR on linus/master]
[also build test ERROR on v6.13-rc1 next-20241205]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Philipp-Stanner/ata-Allocate-PCI-iomap-table-statically/20241205-014059 base: linus/master patch link: https://lore.kernel.org/r/20241204171033.86804-3-pstanner%40redhat.com patch subject: [RFC PATCH 1/3] ata: Allocate PCI iomap table statically config: powerpc-allyesconfig (https://download.01.org/0day-ci/archive/20241206/[email protected]/config) compiler: clang version 20.0.0git (https://github.com/llvm/llvm-project 592c0fe55f6d9a811028b5f3507be91458ab2713) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241206/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
In file included from drivers/ata/pata_macio.c:18:
In file included from include/linux/blkdev.h:9:
In file included from include/linux/blk_types.h:10:
In file included from include/linux/bvec.h:10:
In file included from include/linux/highmem.h:8:
In file included from include/linux/cacheflush.h:5:
In file included from arch/powerpc/include/asm/cacheflush.h:7:
In file included from include/linux/mm.h:2223:
include/linux/vmstat.h:504:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
504 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
505 | item];
| ~~~~
include/linux/vmstat.h:511:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
511 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
512 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
include/linux/vmstat.h:518:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
518 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
| ~~~~~~~~~~~ ^ ~~~
include/linux/vmstat.h:524:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
524 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
525 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
>> drivers/ata/pata_macio.c:1089:20: error: array type 'void *[6]' is not assignable
1089 | priv->host->iomap = &priv->tfregs;
| ~~~~~~~~~~~~~~~~~ ^4 warnings and 1 error generated.
vim +1089 drivers/ata/pata_macio.c
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1048
0ec24914675c482 Greg Kroah-Hartman 2012-12-21 1049 static int pata_macio_common_init(struct pata_macio_priv *priv,
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1050 resource_size_t tfregs,
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1051 resource_size_t dmaregs,
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1052 resource_size_t fcregs,
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1053 unsigned long irq)
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1054 {
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1055 struct ata_port_info pinfo;
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1056 const struct ata_port_info *ppi[] = { &pinfo, NULL };
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1057 void __iomem *dma_regs = NULL;
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1058
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1059 /* Fill up privates with various invariants collected from the
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1060 * device-tree
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1061 */
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1062 pata_macio_invariants(priv);
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1063
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1064 /* Make sure we have sane initial timings in the cache */
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1065 pata_macio_default_timings(priv);
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1066
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1067 /* Allocate libata host for 1 port */
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1068 memset(&pinfo, 0, sizeof(struct ata_port_info));
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1069 pmac_macio_calc_timing_masks(priv, &pinfo);
9cbe056f6c467e7 Sergei Shtylyov 2011-02-04 1070 pinfo.flags = ATA_FLAG_SLAVE_POSS;
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1071 pinfo.port_ops = &pata_macio_ops;
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1072 pinfo.private_data = priv;
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1073
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1074 priv->host = ata_host_alloc_pinfo(priv->dev, ppi, 1);
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1075 if (priv->host == NULL) {
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1076 dev_err(priv->dev, "Failed to allocate ATA port structure\n");
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1077 return -ENOMEM;
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1078 }
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1079
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1080 /* Setup the private data in host too */
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1081 priv->host->private_data = priv;
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1082
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1083 /* Map base registers */
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1084 priv->tfregs = devm_ioremap(priv->dev, tfregs, 0x100);
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1085 if (priv->tfregs == NULL) {
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1086 dev_err(priv->dev, "Failed to map ATA ports\n");
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1087 return -ENOMEM;
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1088 }
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 @1089 priv->host->iomap = &priv->tfregs;
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1090
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1091 /* Map DMA regs */
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1092 if (dmaregs != 0) {
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1093 dma_regs = devm_ioremap(priv->dev, dmaregs,
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1094 sizeof(struct dbdma_regs));
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1095 if (dma_regs == NULL)
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1096 dev_warn(priv->dev, "Failed to map ATA DMA registers\n");
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1097 }
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1098
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1099 /* If chip has local feature control, map those regs too */
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1100 if (fcregs != 0) {
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1101 priv->kauai_fcr = devm_ioremap(priv->dev, fcregs, 4);
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1102 if (priv->kauai_fcr == NULL) {
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1103 dev_err(priv->dev, "Failed to map ATA FCR register\n");
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1104 return -ENOMEM;
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1105 }
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1106 }
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1107
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1108 /* Setup port data structure */
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1109 pata_macio_setup_ios(&priv->host->ports[0]->ioaddr,
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1110 priv->tfregs, dma_regs);
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1111 priv->host->ports[0]->private_data = priv;
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1112
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1113 /* hard-reset the controller */
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1114 pata_macio_reset_hw(priv, 0);
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1115 pata_macio_apply_timings(priv->host->ports[0], 0);
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1116
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1117 /* Enable bus master if necessary */
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1118 if (priv->pdev && dma_regs)
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1119 pci_set_master(priv->pdev);
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1120
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1121 dev_info(priv->dev, "Activating pata-macio chipset %s, Apple bus ID %d\n",
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1122 macio_ata_names[priv->kind], priv->aapl_bus_id);
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1123
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1124 /* Start it up */
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1125 priv->irq = irq;
c3b2889424c26f3 Tejun Heo 2010-05-19 1126 return ata_host_activate(priv->host, irq, ata_bmdma_interrupt, 0,
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1127 &pata_macio_sht);
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1128 }
88358ab08944da7 Benjamin Herrenschmidt 2009-12-01 1129 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
RFC PATCH 2/3 ata: Replace deprecated PCI functions
In reply to Philipp StannerThe ata subsystem uses the deprecated PCI devres functions pcim_iomap_table() and pcim_request_regions().
These functions internally already use their successors, notably pcim_request_region(), so they are quite trivial to replace.
Replace all calls to pcim_request_regions() with ones to pcim_request_region().
Remove all calls to pcim_iomap_table().
The last remaining user, libata-sff.c, is very complicated to port and left for future work.
--- drivers/ata/ata_piix.c | 7 +++---- drivers/ata/pata_atp867x.c | 13 ++++++++----- drivers/ata/pata_hpt3x3.c | 10 ++++++---- drivers/ata/pata_ninja32.c | 11 ++++++----- drivers/ata/pata_pdc2027x.c | 11 +++++------ drivers/ata/pata_sil680.c | 12 +++++++----- drivers/ata/pdc_adma.c | 9 ++++----- drivers/ata/sata_inic162x.c | 10 ++++------ drivers/ata/sata_mv.c | 9 +++++---- drivers/ata/sata_nv.c | 8 ++++---- drivers/ata/sata_promise.c | 8 +++++--- drivers/ata/sata_qstor.c | 7 +++---- drivers/ata/sata_sil.c | 8 +++++--- drivers/ata/sata_sil24.c | 20 +++++++++++--------- drivers/ata/sata_sis.c | 8 ++++---- drivers/ata/sata_svw.c | 10 ++++++---- drivers/ata/sata_sx4.c | 19 ++++++++++++++++--- drivers/ata/sata_via.c | 31 +++++++++++++++++++------------ drivers/ata/sata_vsc.c | 8 +++++--- 19 files changed, 126 insertions(+), 93 deletions(-)
drivers/ata/ata_piix.c +3 -4
@@ -1456,10 +1456,9 @@ static int piix_init_sidpr(struct ata_host *host) pci_resource_len(pdev, PIIX_SIDPR_BAR) != PIIX_SIDPR_LEN)return 0 ; -if (pcim_iomap_regions (pdev,1 <<PIIX_SIDPR_BAR ,DRV_NAME )) -return 0 ; - - hpriv->sidpr =pcim_iomap_table (pdev)[PIIX_SIDPR_BAR ]; + hpriv->sidpr =pcim_iomap_region (pdev,PIIX_SIDPR_BAR ,DRV_NAME ); +if (IS_ERR (hpriv->sidpr)) +return PTR_ERR (hpriv->sidpr);/* SCR access via SIDPR doesn't work on some configurations. * Give it a test drive by inhibiting power save modes which
drivers/ata/pata_atp867x.c +8 -5
@@ -405,17 +405,20 @@ static int atp867x_ata_pci_sff_init_host(struct ata_host *host)struct device *gdev = host->dev;struct pci_dev *pdev =to_pci_dev (gdev);unsigned int mask =0 ; +void __iomem *iomem;int i, rc;/* * do not map rombase */ - rc =pcim_iomap_regions (pdev,1 <<ATP867X_BAR_IOBASE ,DRV_NAME ); -if (rc == -EBUSY ) -pcim_pin_device (pdev); -if (rc) + iomem =pcim_iomap_region (pdev,ATP867X_BAR_IOBASE ,DRV_NAME ); +if (IS_ERR (iomem)) { + rc =PTR_ERR (iomem); +if (rc == -EBUSY ) +pcim_pin_device (pdev);return rc; - host->iomap =pcim_iomap_table (pdev); + } + host->iomap[ATP867X_BAR_IOBASE ] = iomem;atp867x_check_res (pdev);
drivers/ata/pata_hpt3x3.c +6 -4
@@ -199,7 +199,7 @@ static int hpt3x3_init_one(struct pci_dev *pdev, const struct pci_device_id *id)static const u8 offset_ctl[2 ] = {0x36 ,0x3E };const struct ata_port_info *ppi[] = { &info,NULL };struct ata_host *host; -int i, rc; +int i, rc =0 ;void __iomem *base;hpt3x3_init_chipset (pdev);
@@ -215,17 +215,19 @@ static int hpt3x3_init_one(struct pci_dev *pdev, const struct pci_device_id *id)return rc;/* Everything is relative to BAR4 if we set up this way */ - rc =pcim_iomap_regions (pdev,1 <<4 ,DRV_NAME ); + base =pcim_iomap_region (pdev,4 ,DRV_NAME ); +if (IS_ERR (base)) + rc =PTR_ERR (base);if (rc == -EBUSY )pcim_pin_device (pdev);if (rc)return rc; - host->iomap =pcim_iomap_table (pdev); + rc =dma_set_mask_and_coherent (&pdev->dev,ATA_DMA_MASK );if (rc)return rc; - base = host->iomap[4 ];/* Bus mastering base */ + host->iomap[4 ] = base;/* Bus mastering base */ for (i =0 ; i < host->n_ports; i++) {struct ata_port *ap = host->ports[i];
drivers/ata/pata_ninja32.c +6 -5
@@ -116,13 +116,16 @@ static int ninja32_init_one(struct pci_dev *dev, const struct pci_device_id *id) rc =pcim_enable_device (dev);if (rc)return rc; - rc =pcim_iomap_regions (dev,1 <<0 ,DRV_NAME ); + + rc =0 ; + base =pcim_iomap_region (dev,0 ,DRV_NAME ); +if (IS_ERR (base)) + rc =PTR_ERR (base);if (rc == -EBUSY )pcim_pin_device (dev);if (rc)return rc; - host->iomap =pcim_iomap_table (dev); rc =dma_set_mask_and_coherent (&dev->dev,ATA_DMA_MASK );if (rc)return rc;
@@ -130,9 +133,7 @@ static int ninja32_init_one(struct pci_dev *dev, const struct pci_device_id *id)/* Set up the register mappings. We use the I/O mapping as only the older chips also have MMIO on BAR 1 */ - base = host->iomap[0 ]; -if (!base) -return -ENOMEM ; + host->iomap[0 ] = base; ap->ops = &ninja32_port_ops; ap->pio_mask =ATA_PIO4 ; ap->flags |=ATA_FLAG_SLAVE_POSS ;
drivers/ata/pata_pdc2027x.c +5 -6
@@ -702,17 +702,16 @@ static int pdc2027x_init_one(struct pci_dev *pdev,if (rc)return rc; - rc =pcim_iomap_regions (pdev,1 <<PDC_MMIO_BAR ,DRV_NAME ); -if (rc) -return rc; - host->iomap =pcim_iomap_table (pdev); + mmio_base =pcim_iomap_region (pdev,PDC_MMIO_BAR ,DRV_NAME ); +if (IS_ERR (mmio_base)) +return PTR_ERR (mmio_base); + + host->iomap[PDC_MMIO_BAR ] = mmio_base; rc =dma_set_mask_and_coherent (&pdev->dev,ATA_DMA_MASK );if (rc)return rc; - mmio_base = host->iomap[PDC_MMIO_BAR ]; -for (i =0 ; i <2 ; i++) {struct ata_port *ap = host->ports[i];
drivers/ata/pata_sil680.c +7 -5
@@ -360,15 +360,17 @@ static int sil680_init_one(struct pci_dev *pdev, const struct pci_device_id *id)/* Try to acquire MMIO resources and fallback to PIO if * that fails */ - rc =pcim_iomap_regions (pdev,1 <<SIL680_MMIO_BAR ,DRV_NAME ); -if (rc) + rc =0 ; + mmio_base =pcim_iomap_region (pdev,SIL680_MMIO_BAR ,DRV_NAME ); +if (IS_ERR (mmio_base)) { + rc =PTR_ERR (mmio_base); goto use_ioports; + }/* Allocate host and set it up */ host =ata_host_alloc_pinfo (&pdev->dev, ppi,2 );if (!host)return -ENOMEM ; - host->iomap =pcim_iomap_table (pdev);/* Setup DMA masks */ rc =dma_set_mask_and_coherent (&pdev->dev,ATA_DMA_MASK );
@@ -376,8 +378,8 @@ static int sil680_init_one(struct pci_dev *pdev, const struct pci_device_id *id)return rc;pci_set_master (pdev); -/* Get MMIO base and initialize port addresses */ - mmio_base = host->iomap[SIL680_MMIO_BAR ]; +/* Set MMIO base in table and initialize port addresses */ + host->iomap[SIL680_MMIO_BAR ] = mmio_base; host->ports[0 ]->ioaddr.bmdma_addr = mmio_base +0x00 ; host->ports[0 ]->ioaddr.cmd_addr = mmio_base +0x80 ; host->ports[0 ]->ioaddr.ctl_addr = mmio_base +0x8a ;
drivers/ata/pdc_adma.c +4 -5
@@ -568,11 +568,10 @@ static int adma_ata_init_one(struct pci_dev *pdev,if ((pci_resource_flags (pdev,4 ) &IORESOURCE_MEM ) ==0 )return -ENODEV ; - rc =pcim_iomap_regions (pdev,1 <<ADMA_MMIO_BAR ,DRV_NAME ); -if (rc) -return rc; - host->iomap =pcim_iomap_table (pdev); - mmio_base = host->iomap[ADMA_MMIO_BAR ]; + mmio_base =pcim_iomap_region (pdev,ADMA_MMIO_BAR ,DRV_NAME ); +if (IS_ERR (mmio_base)) +return PTR_ERR (mmio_base); + host->iomap[ADMA_MMIO_BAR ] = mmio_base; rc =dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (32 ));if (rc) {
drivers/ata/sata_inic162x.c +4 -6
@@ -817,7 +817,6 @@ static int inic_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)const struct ata_port_info *ppi[] = { &inic_port_info,NULL };struct ata_host *host;struct inic_host_priv *hpriv; -void __iomem *const *iomap;int mmio_bar;int i, rc;
@@ -845,11 +844,10 @@ static int inic_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)else mmio_bar =MMIO_BAR_CARDBUS ; - rc =pcim_iomap_regions (pdev,1 << mmio_bar,DRV_NAME ); -if (rc) -return rc; - host->iomap = iomap =pcim_iomap_table (pdev); - hpriv->mmio_base = iomap[mmio_bar]; + hpriv->mmio_base =pcim_iomap_region (pdev, mmio_bar,DRV_NAME ); +if (IS_ERR (hpriv->mmio_base)) +return PTR_ERR (hpriv->mmio_base); + host->iomap[mmio_bar] = hpriv->mmio_base; hpriv->cached_hctl =readw (hpriv->mmio_base +HOST_CTL );for (i =0 ; i <NR_PORTS ; i++) {
drivers/ata/sata_mv.c +5 -4
@@ -4083,7 +4083,6 @@ static int mv_platform_probe(struct platform_device *pdev) host->private_data = hpriv; hpriv->board_idx = chip_soc; - host->iomap =NULL ; hpriv->base =devm_ioremap (&pdev->dev, res->start,resource_size (res));if (!hpriv->base)
@@ -4392,13 +4391,15 @@ static int mv_pci_init_one(struct pci_dev *pdev,if (rc)return rc; - rc =pcim_iomap_regions (pdev,1 <<MV_PRIMARY_BAR ,DRV_NAME ); + rc =0 ; + hpriv->base =pcim_iomap_region (pdev,MV_PRIMARY_BAR ,DRV_NAME ); +if (IS_ERR (hpriv->base)) + rc =PTR_ERR (hpriv->base);if (rc == -EBUSY )pcim_pin_device (pdev);if (rc)return rc; - host->iomap =pcim_iomap_table (pdev); - hpriv->base = host->iomap[MV_PRIMARY_BAR ]; + host->iomap[MV_PRIMARY_BAR ] = hpriv->base; rc =dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (64 ));if (rc) {
drivers/ata/sata_nv.c +4 -4
@@ -2353,12 +2353,12 @@ static int nv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) host->private_data = hpriv;/* request and iomap NV_MMIO_BAR */ - rc =pcim_iomap_regions (pdev,1 <<NV_MMIO_BAR ,DRV_NAME ); -if (rc) -return rc; + base =pcim_iomap_region (pdev,NV_MMIO_BAR ,DRV_NAME ); +if (IS_ERR (base)) +return PTR_ERR (base);/* configure SCR access */ - base = host->iomap[NV_MMIO_BAR ]; + host->iomap[NV_MMIO_BAR ] = base; host->ports[0 ]->ioaddr.scr_addr = base +NV_PORT0_SCR_REG_OFFSET ; host->ports[1 ]->ioaddr.scr_addr = base +NV_PORT1_SCR_REG_OFFSET ;
drivers/ata/sata_promise.c +5 -3
@@ -1163,12 +1163,14 @@ static int pdc_ata_init_one(struct pci_dev *pdev,if (rc)return rc; - rc =pcim_iomap_regions (pdev,1 <<PDC_MMIO_BAR ,DRV_NAME ); + rc =0 ; + host_mmio =pcim_iomap_region (pdev,PDC_MMIO_BAR ,DRV_NAME ); +if (IS_ERR (host_mmio)) + rc =PTR_ERR (host_mmio);if (rc == -EBUSY )pcim_pin_device (pdev);if (rc)return rc; - host_mmio =pcim_iomap_table (pdev)[PDC_MMIO_BAR ];/* determine port configuration and setup host */ n_ports =2 ;
@@ -1193,7 +1195,7 @@ static int pdc_ata_init_one(struct pci_dev *pdev,return -ENOMEM ;spin_lock_init (&hpriv->hard_reset_lock); host->private_data = hpriv; - host->iomap =pcim_iomap_table (pdev); + host->iomap[PDC_MMIO_BAR ] = host_mmio; is_sataii_tx4 =pdc_is_sataii_tx4 (pi->flags);for (i =0 ; i < host->n_ports; i++) {
drivers/ata/sata_qstor.c +3 -4
@@ -560,10 +560,9 @@ static int qs_ata_init_one(struct pci_dev *pdev,if ((pci_resource_flags (pdev,QS_MMIO_BAR ) &IORESOURCE_MEM ) ==0 )return -ENODEV ; - rc =pcim_iomap_regions (pdev,1 <<QS_MMIO_BAR ,DRV_NAME ); -if (rc) -return rc; - host->iomap =pcim_iomap_table (pdev); + host->iomap[QS_MMIO_BAR ] =pcim_iomap_region (pdev,QS_MMIO_BAR ,DRV_NAME ); +if (IS_ERR (host->iomap[QS_MMIO_BAR ])) +return PTR_ERR (host->iomap[QS_MMIO_BAR ]); rc =qs_set_dma_masks (pdev, host->iomap[QS_MMIO_BAR ]);if (rc)
drivers/ata/sata_sil.c +5 -3
@@ -751,18 +751,20 @@ static int sil_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)if (rc)return rc; - rc =pcim_iomap_regions (pdev,1 <<SIL_MMIO_BAR ,DRV_NAME ); + rc =0 ; + mmio_base =pcim_iomap_region (pdev,SIL_MMIO_BAR ,DRV_NAME ); +if (IS_ERR (mmio_base)) + rc =PTR_ERR (mmio_base);if (rc == -EBUSY )pcim_pin_device (pdev);if (rc)return rc; - host->iomap =pcim_iomap_table (pdev); rc =dma_set_mask_and_coherent (&pdev->dev,ATA_DMA_MASK );if (rc)return rc; - mmio_base = host->iomap[SIL_MMIO_BAR ]; + host->iomap[SIL_MMIO_BAR ] = mmio_base;for (i =0 ; i < host->n_ports; i++) {struct ata_port *ap = host->ports[i];
drivers/ata/sata_sil24.c +11 -9
@@ -1261,7 +1261,7 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)extern int __MARKER__sil24_cmd_block_is_sized_wrongly;struct ata_port_info pi = sil24_port_info[ent->driver_data];const struct ata_port_info *ppi[] = { &pi,NULL }; -void __iomem *const *iomap; +void __iomem *host_iomem, *port_iomem;struct ata_host *host;int rc;u32 tmp;
@@ -1277,16 +1277,17 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)if (rc)return rc; - rc =pcim_iomap_regions (pdev, - (1 <<SIL24_HOST_BAR ) | (1 <<SIL24_PORT_BAR ), -DRV_NAME ); -if (rc) -return rc; - iomap =pcim_iomap_table (pdev); + host_iomem =pcim_iomap_region (pdev,SIL24_HOST_BAR ,DRV_NAME ); +if (IS_ERR (host_iomem)) +return PTR_ERR (host_iomem); + + port_iomem =pcim_iomap_region (pdev,SIL24_PORT_BAR ,DRV_NAME ); +if (IS_ERR (port_iomem)) +return PTR_ERR (port_iomem);/* apply workaround for completion IRQ loss on PCI-X errata */ if (pi.flags &SIL24_FLAG_PCIX_IRQ_WOC ) { - tmp =readl (iomap[SIL24_HOST_BAR ] +HOST_CTRL ); + tmp =readl (host_iomem +HOST_CTRL );if (tmp & (HOST_CTRL_TRDY |HOST_CTRL_STOP |HOST_CTRL_DEVSEL ))dev_info (&pdev->dev,"Applying completion IRQ loss on PCI-X errata fix\n" );
@@ -1299,7 +1300,8 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) SIL24_FLAG2NPORTS(ppi[0]->flags));if (!host)return -ENOMEM ; - host->iomap = iomap; + host->iomap[SIL24_HOST_BAR ] = host_iomem; + host->iomap[SIL24_PORT_BAR ] = port_iomem;/* configure and activate the device */ rc =dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (64 ));
drivers/ata/sata_sis.c +4 -4
@@ -280,10 +280,10 @@ static int sis_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)if (!(pi.flags &SIS_FLAG_CFGSCR )) {void __iomem *mmio; - rc =pcim_iomap_regions (pdev,1 <<SIS_SCR_PCI_BAR ,DRV_NAME ); -if (rc) -return rc; - mmio = host->iomap[SIS_SCR_PCI_BAR ]; + mmio =pcim_iomap_region (pdev,SIS_SCR_PCI_BAR ,DRV_NAME ); +if (IS_ERR (mmio)) +return PTR_ERR (mmio); + host->iomap[SIS_SCR_PCI_BAR ] = mmio; host->ports[0 ]->ioaddr.scr_addr = mmio; host->ports[1 ]->ioaddr.scr_addr = mmio + port2_start;
drivers/ata/sata_svw.c +6 -4
@@ -451,14 +451,16 @@ static int k2_sata_init_one(struct pci_dev *pdev, const struct pci_device_id *enreturn -ENODEV ; } -/* Request and iomap PCI regions */ - rc =pcim_iomap_regions (pdev,1 << bar_pos,DRV_NAME ); +/* Request and iomap PCI region */ + rc =0 ; + mmio_base =pcim_iomap_region (pdev, bar_pos,DRV_NAME ); +if (IS_ERR (mmio_base)) + rc =PTR_ERR (mmio_base);if (rc == -EBUSY )pcim_pin_device (pdev);if (rc)return rc; - host->iomap =pcim_iomap_table (pdev); - mmio_base = host->iomap[bar_pos]; + host->iomap[bar_pos] = mmio_base;/* different controllers have different number of ports - currently 4 or 8 */ /* All ports are on the same function. Multi-function device is no
drivers/ata/sata_sx4.c +16 -3
@@ -1390,6 +1390,7 @@ static int pdc_sata_init_one(struct pci_dev *pdev,struct ata_host *host;struct pdc_host_priv *hpriv;int i, rc; +void __iomem *io_tmp;ata_print_version_once (&pdev->dev,DRV_VERSION );
@@ -1406,13 +1407,25 @@ static int pdc_sata_init_one(struct pci_dev *pdev,if (rc)return rc; - rc =pcim_iomap_regions (pdev, (1 <<PDC_MMIO_BAR ) | (1 <<PDC_DIMM_BAR ), -DRV_NAME ); + rc =0 ; + io_tmp =pcim_iomap_region (pdev,PDC_MMIO_BAR ,DRV_NAME ); +if (IS_ERR (io_tmp)) + rc =PTR_ERR (io_tmp);if (rc == -EBUSY )pcim_pin_device (pdev);if (rc)return rc; - host->iomap =pcim_iomap_table (pdev); + host->iomap[PDC_MMIO_BAR ] = io_tmp; + + rc =0 ; + io_tmp =pcim_iomap_region (pdev,PDC_DIMM_BAR ,DRV_NAME ); +if (IS_ERR (io_tmp)) + rc =PTR_ERR (io_tmp); +if (rc == -EBUSY ) +pcim_pin_device (pdev); +if (rc) +return rc; + host->iomap[PDC_DIMM_BAR ] = io_tmp;for (i =0 ; i <4 ; i++) {struct ata_port *ap = host->ports[i];
drivers/ata/sata_via.c +19 -12
@@ -457,6 +457,7 @@ static int vt6420_prepare_host(struct pci_dev *pdev, struct ata_host **r_host) {const struct ata_port_info *ppi[] = { &vt6420_port_info,NULL };struct ata_host *host; +void __iomem *iomem;int rc;if (vt6420_hotplug) {
@@ -469,11 +470,12 @@ static int vt6420_prepare_host(struct pci_dev *pdev, struct ata_host **r_host)return rc; *r_host = host; - rc =pcim_iomap_regions (pdev,1 <<5 ,DRV_NAME ); -if (rc) { + iomem =pcim_iomap_region (pdev,5 ,DRV_NAME ); +if (IS_ERR (iomem)) {dev_err (&pdev->dev,"failed to iomap PCI BAR 5\n" ); -return rc; +return PTR_ERR (iomem); } + host->iomap[5 ] = iomem; host->ports[0 ]->ioaddr.scr_addr =svia_scr_addr (host->iomap[5 ],0 ); host->ports[1 ]->ioaddr.scr_addr =svia_scr_addr (host->iomap[5 ],1 );
@@ -486,6 +488,7 @@ static int vt6421_prepare_host(struct pci_dev *pdev, struct ata_host **r_host)const struct ata_port_info *ppi[] = { &vt6421_sport_info, &vt6421_sport_info, &vt6421_pport_info };struct ata_host *host; +void __iomem *iomem;int i, rc; *r_host = host =ata_host_alloc_pinfo (&pdev->dev, ppi,ARRAY_SIZE (ppi));
@@ -494,13 +497,17 @@ static int vt6421_prepare_host(struct pci_dev *pdev, struct ata_host **r_host)return -ENOMEM ; } - rc =pcim_iomap_regions (pdev,0x3f ,DRV_NAME ); -if (rc) { -dev_err (&pdev->dev,"failed to request/iomap PCI BARs (errno=%d)\n" , - rc); -return rc; +/* Request and ioremap _all_ PCI BARs. */ +for (i =0 ; i <PCI_STD_NUM_BARS ; i++) { + iomem =pcim_iomap_region (pdev, i,DRV_NAME ); +if (IS_ERR (iomem)) { + rc =PTR_ERR (iomem); +dev_err (&pdev->dev,"failed to request/iomap PCI BARs (errno=%d)\n" , + rc); +return rc; + } + host->iomap[i] = iomem; } - host->iomap =pcim_iomap_table (pdev);for (i =0 ; i < host->n_ports; i++)vt6421_init_addrs (host->ports[i]);
@@ -519,10 +526,10 @@ static int vt8251_prepare_host(struct pci_dev *pdev, struct ata_host **r_host)return rc; *r_host = host; - rc =pcim_iomap_regions (pdev,1 <<5 ,DRV_NAME ); -if (rc) { + host->iomap[5 ] =pcim_iomap_region (pdev,5 ,DRV_NAME ); +if (IS_ERR (host->iomap[5 ])) {dev_err (&pdev->dev,"failed to iomap PCI BAR 5\n" ); -return rc; +return PTR_ERR (host->iomap[5 ]); }/* 8251 hosts four sata ports as M/S of the two channels */
drivers/ata/sata_vsc.c +5 -3
@@ -349,14 +349,16 @@ static int vsc_sata_init_one(struct pci_dev *pdev,return -ENODEV ;/* map IO regions and initialize host accordingly */ - rc =pcim_iomap_regions (pdev,1 <<VSC_MMIO_BAR ,DRV_NAME ); + rc =0 ; + mmio_base =pcim_iomap_region (pdev,VSC_MMIO_BAR ,DRV_NAME ); +if (IS_ERR (mmio_base)) + rc =PTR_ERR (mmio_base);if (rc == -EBUSY )pcim_pin_device (pdev);if (rc)return rc; - host->iomap =pcim_iomap_table (pdev); - mmio_base = host->iomap[VSC_MMIO_BAR ]; + host->iomap[VSC_MMIO_BAR ] = mmio_base;for (i =0 ; i < host->n_ports; i++) {struct ata_port *ap = host->ports[i];
Signature · 1 line
2.47.0
Re: [RFC PATCH 2/3] ata: Replace deprecated PCI functions
Quoted 15 lines · Philipp Stanner
The ata subsystem uses the deprecated PCI devres functions
pcim_iomap_table()andpcim_request_regions().These functions internally already use their successors, notably
pcim_request_region(), so they are quite trivial to replace.Replace all calls to
pcim_request_regions()with ones topcim_request_region().Remove all calls to
pcim_iomap_table().The last remaining user,
libata-sff.c, is very complicated to port and left for future work.Signed-off-by Philipp Stanner <[email protected]>
[...]
drivers/ata/pata_sil680.c static int sil680_init_one(struct pci_dev *pdev, const struct pci_device_id *id) · line 363
Quoted 11 lines
drivers/ata/pata_sil680.c +1
-2@@ -360,15 +360,17 @@ static int sil680_init_one(struct pci_dev *pdev, const struct pci_device_id *id)/* Try to acquire MMIO resources and fallback to PIO if * that fails */ - rc =pcim_iomap_regions (pdev,1 <<SIL680_MMIO_BAR ,DRV_NAME ); -if (rc) + rc =0 ;
Doesn't seem necessary...
Quoted 14 lines
drivers/ata/pata_sil680.c +4
-1+ mmio_base =pcim_iomap_region (pdev,SIL680_MMIO_BAR ,DRV_NAME ); +if (IS_ERR (mmio_base)) { + rc =PTR_ERR (mmio_base); goto use_ioports; + }/* Allocate host and set it up */ host =ata_host_alloc_pinfo (&pdev->dev, ppi,2 );if (!host)return -ENOMEM ; - host->iomap =pcim_iomap_table (pdev);/* Setup DMA masks */ rc =dma_set_mask_and_coherent (&pdev->dev,ATA_DMA_MASK );
[...]
drivers/ata/sata_sx4.c static int pdc_sata_init_one(struct pci_dev *pdev, · line 1393
Quoted 9 lines
drivers/ata/sata_sx4.c +1
-0@@ -1390,6 +1390,7 @@ static int pdc_sata_init_one(struct pci_dev *pdev,struct ata_host *host;struct pdc_host_priv *hpriv;int i, rc; +void __iomem *io_tmp;
I'd suggest a better name, like iomem here...
[...]
Quoted 4 lines
drivers/ata/sata_via.c +0
-0
[...]
Quoted 6 lines
drivers/ata/sata_via.c +0
-2@@ -494,13 +497,17 @@ static int vt6421_prepare_host(struct pci_dev *pdev, struct ata_host **r_host)return -ENOMEM ; } - rc =pcim_iomap_regions (pdev,0x3f ,DRV_NAME ); -if (rc) {
drivers/ata/sata_via.c static int vt6421_prepare_host(struct pci_dev *pdev, struct ata_host **r_host) · line 506
Quoted 10 lines
drivers/ata/sata_via.c +7
-3-dev_err (&pdev->dev,"failed to request/iomap PCI BARs (errno=%d)\n" , - rc); -return rc; +/* Request and ioremap _all_ PCI BARs. */ +for (i =0 ; i <PCI_STD_NUM_BARS ; i++) { + iomem =pcim_iomap_region (pdev, i,DRV_NAME ); +if (IS_ERR (iomem)) { + rc =PTR_ERR (iomem); +dev_err (&pdev->dev,"failed to request/iomap PCI BARs (errno=%d)\n" , + rc);
You have a limit of 100 columns now. :-)
[...]
MBR, Sergey
RFC PATCH 3/3 libata-sff: Simplify request of PCI resources
In reply to Philipp Stannerpcim_iomap_regions() has been deprecated by the PCI subsystem.
Unfortunately, libata-sff uses quite complicated bit mask magic to obtain its PCI resources.
Restructure and simplify the PCI resource request code.
Replace pcim_iomap_regions() with pcim_iomap_region().
--- drivers/ata/libata-sff.c | 130 +++++++++++++++++++++++++-------------- 1 file changed, 84 insertions(+), 46 deletions(-)
drivers/ata/libata-sff.c +84 -46
@@ -2127,6 +2127,73 @@ static bool ata_resources_present(struct pci_dev *pdev, int port)return true; } +static void ata_pci_sff_set_ap_data (struct ata_port *ap,struct ata_host *host, +struct pci_dev *pdev,unsigned short base) +{ +void __iomem *ctl_addr; + + ctl_addr = host->iomap[base +1 ]; + ctl_addr = (void __iomem *)((unsigned long )ctl_addr |ATA_PCI_CTL_OFS ); + + ap->ioaddr.cmd_addr = host->iomap[base]; + ap->ioaddr.altstatus_addr = ctl_addr; + ap->ioaddr.ctl_addr = ctl_addr; + +ata_sff_std_ports (&ap->ioaddr); + +ata_port_desc (ap,"cmd 0x%llx ctl 0x%llx" , + (unsigned long long )pci_resource_start (pdev, base), + (unsigned long long )pci_resource_start (pdev, base +1 )); +} + +/* +* ata_pci_sff_obtain_bars - obtain the PCI BARs associated with an ATA port +* @pdev: the PCI device +* @host: the ATA host +* @ap: the ATA port +* @port: @ap's port index in @host +* +* Returns: Number of successfully ioremaped BARs, a negative code on failure +*/ +static int ata_pci_sff_obtain_bars (struct pci_dev *pdev,struct ata_host *host, +struct ata_port *ap,unsigned short port) +{ +int ret =0 , bars_mapped =0 ; +unsigned short i, base; +void __iomem *io_tmp; +const char *name =dev_driver_string (&pdev->dev); + +/* +* Port can be 0 or 1. +* Port 0 corresponds to PCI BARs 0 and 1, port 1 to BARs 2 and 3. +*/ + base = port *2 ; + +/* +* Discard disabled ports. Some controllers show their unused channels +* this way. Disabled ports are made dummy. +*/ +if (!ata_resources_present (pdev, port)) + goto try_next; + +for (i =0 ; i <2 ; i++) { + io_tmp =pcim_iomap_region (pdev, base + i, name); + ret =PTR_ERR_OR_ZERO (io_tmp); +if (ret !=0 ) + goto try_next; + + bars_mapped++; + } + +ata_pci_sff_set_ap_data (ap, host, pdev, base); + +return bars_mapped; + +try_next: + ap->ops = &ata_dummy_port_ops; +return ret; +} +/** * ata_pci_sff_init_host - acquire native PCI ATA resources and init host * @host: target ATA host
@@ -2148,59 +2215,31 @@ static bool ata_resources_present(struct pci_dev *pdev, int port)*/ int ata_pci_sff_init_host (struct ata_host *host) { -struct device *gdev = host->dev; -struct pci_dev *pdev =to_pci_dev (gdev); -unsigned int mask =0 ; -int i, rc; - -/* request, iomap BARs and init port addresses accordingly */ -for (i =0 ; i <2 ; i++) { -struct ata_port *ap = host->ports[i]; -int base = i *2 ; -void __iomem *const *iomap; +int ret; +unsigned short port_nr, operational_ports =0 ; +struct device *dev = host->dev; +struct pci_dev *pdev =to_pci_dev (dev); +struct ata_port *ap; +for (port_nr =0 ; port_nr <2 ; port_nr++) { + ap = host->ports[port_nr];if (ata_port_is_dummy (ap))continue ; -/* Discard disabled ports. Some controllers show -* their unused channels this way. Disabled ports are -* made dummy. -*/ -if (!ata_resources_present (pdev, i)) { - ap->ops = &ata_dummy_port_ops; -continue ; - } - - rc =pcim_iomap_regions (pdev,0x3 << base, -dev_driver_string (gdev)); -if (rc) { -dev_warn (gdev, + ret =ata_pci_sff_obtain_bars (pdev, host, ap, port_nr); +if (ret >0 ) { + operational_ports += ret; + }else if (ret <0 ) { +dev_warn (dev,"failed to request/iomap BARs for port %d (errno=%d)\n" , - i, rc); -if (rc == -EBUSY ) + port_nr, ret); +if (ret == -EBUSY )pcim_pin_device (pdev); - ap->ops = &ata_dummy_port_ops; -continue ; } - host->iomap = iomap =pcim_iomap_table (pdev); - - ap->ioaddr.cmd_addr = iomap[base]; - ap->ioaddr.altstatus_addr = - ap->ioaddr.ctl_addr = (void __iomem *) - ((unsigned long )iomap[base +1 ] |ATA_PCI_CTL_OFS ); -ata_sff_std_ports (&ap->ioaddr); - -ata_port_desc (ap,"cmd 0x%llx ctl 0x%llx" , - (unsigned long long )pci_resource_start (pdev, base), - (unsigned long long )pci_resource_start (pdev, base +1 )); - - mask |=1 << i; } -if (!mask) { -dev_err (gdev,"no available native port\n" ); +if (operational_ports ==0 )return -ENODEV ; - }return 0 ; }
@@ -3094,12 +3133,11 @@ void ata_pci_bmdma_init(struct ata_host *host)ata_bmdma_nodma (host,"failed to set dma mask" );/* request and iomap DMA region */ - rc =pcim_iomap_regions (pdev,1 <<4 ,dev_driver_string (gdev)); -if (rc) { + host->iomap[4 ] =pcim_iomap_region (pdev,4 ,dev_driver_string (gdev)); +if (IS_ERR (host->iomap[4 ])) {ata_bmdma_nodma (host,"failed to request/iomap BAR4" );return ; } - host->iomap =pcim_iomap_table (pdev);for (i =0 ; i <2 ; i++) {struct ata_port *ap = host->ports[i];
Signature · 1 line
2.47.0
Re: [RFC PATCH 3/3] libata-sff: Simplify request of PCI resources
Quoted 10 lines · Philipp Stanner
pcim_iomap_regions()has been deprecated by the PCI subsystem.Unfortunately, libata-sff uses quite complicated bit mask magic to obtain its PCI resources.
Restructure and simplify the PCI resource request code.
Replace
pcim_iomap_regions()withpcim_iomap_region().Signed-off-by Philipp Stanner <[email protected]>
[...]
drivers/ata/libata-sff.c static bool ata_resources_present(struct pci_dev *pdev, int port) · line 2130
Quoted 9 lines
drivers/ata/libata-sff.c +1
-0@@ -2127,6 +2127,73 @@ static bool ata_resources_present(struct pci_dev *pdev, int port)return true; } +static void ata_pci_sff_set_ap_data(struct ata_port *ap, struct ata_host *host,
Maybe ata_pci_sff_set_port_data()?
drivers/ata/libata-sff.c static bool ata_resources_present(struct pci_dev *pdev, int port) · line 2131
Quoted 1 line
drivers/ata/libata-sff.c +1
-0+ struct pci_dev *pdev, unsigned short base)
Using just 2 tabs here seems to go against the coding style used in libata-sff.c
but no biggie... :-)
Quoted 8 lines
drivers/ata/libata-sff.c +8
-0+{ +void __iomem *ctl_addr; + + ctl_addr = host->iomap[base +1 ]; + ctl_addr = (void __iomem *)((unsigned long )ctl_addr |ATA_PCI_CTL_OFS ); + + ap->ioaddr.cmd_addr = host->iomap[base]; + ap->ioaddr.altstatus_addr = ctl_addr;
drivers/ata/libata-sff.c static bool ata_resources_present(struct pci_dev *pdev, int port) · line 2149
Quoted 10 lines
drivers/ata/libata-sff.c +10
-0+ ap->ioaddr.ctl_addr = ctl_addr; + +ata_sff_std_ports (&ap->ioaddr); + +ata_port_desc (ap,"cmd 0x%llx ctl 0x%llx" , + (unsigned long long )pci_resource_start (pdev, base), + (unsigned long long )pci_resource_start (pdev, base +1 )); +} + +/*
Please use /** here -- the comment seems to otherwise match the kernel-doc
format...
Quoted 4 lines
drivers/ata/libata-sff.c +4
-0+* ata_pci_sff_obtain_bars - obtain the PCI BARs associated with an ATA port +* @pdev: the PCI device +* @host: the ATA host +* @ap: the ATA port
drivers/ata/libata-sff.c static bool ata_resources_present(struct pci_dev *pdev, int port) · line 2163
Quoted 10 lines
drivers/ata/libata-sff.c +10
-0+* @port: @ap's port index in @host +* +* Returns: Number of successfully ioremaped BARs, a negative code on failure +*/ +static int ata_pci_sff_obtain_bars (struct pci_dev *pdev,struct ata_host *host, +struct ata_port *ap,unsigned short port) +{ +int ret =0 , bars_mapped =0 ; +unsigned short i, base; +void __iomem *io_tmp;
Maybe call it iomem instead?
drivers/ata/libata-sff.c static bool ata_resources_present(struct pci_dev *pdev, int port) · line 2172
Quoted 9 lines
drivers/ata/libata-sff.c +9
-0+const char *name =dev_driver_string (&pdev->dev); + +/* +* Port can be 0 or 1. +* Port 0 corresponds to PCI BARs 0 and 1, port 1 to BARs 2 and 3. +*/ + base = port *2 ; + +/*
Don't indent with spaces please.
drivers/ata/libata-sff.c static bool ata_resources_present(struct pci_dev *pdev, int port) · line 2175
Quoted 3 lines
drivers/ata/libata-sff.c +3
-0+* Discard disabled ports. Some controllers show their unused channels +* this way. Disabled ports are made dummy. +*/
These 3 lines lack a space before *.
[...]
drivers/ata/libata-sff.c static bool ata_resources_present(struct pci_dev *pdev, int port) · line 2182
Quoted 4 lines
drivers/ata/libata-sff.c +4
-0+for (i =0 ; i <2 ; i++) { + io_tmp =pcim_iomap_region (pdev, base + i, name); + ret =PTR_ERR_OR_ZERO (io_tmp); +if (ret !=0 )
!= 0 unnecessary.
[...]
drivers/ata/libata-sff.c static bool ata_resources_present(struct pci_dev *pdev, int port)
Quoted 1 line
drivers/ata/libata-sff.c +0
-0@@ -2148,59 +2215,31 @@ static bool ata_resources_present(struct pci_dev *pdev, int port)
[...]> - if (!mask) {
drivers/ata/libata-sff.c static bool ata_resources_present(struct pci_dev *pdev, int port) · line 2241
Quoted 2 lines
drivers/ata/libata-sff.c +1
-1-dev_err (gdev,"no available native port\n" ); +if (operational_ports ==0 )
Perhaps:
if (!operational_ports)
[...]
MBR, Sergey
Damien Le Moal
maintainerQuoted 7 lines · Philipp Stanner
Hi,
many of you probably know that I'm trying to remove
pcim_iomap_regions()from the kernel. One of the more difficult users is ATA, because it's the only subsystem I've seen so far that accesses that tablepcim_iomap_table()administrates.
Quoted 6 lines
This series only builds as a whole because of patch 1. That's why I submit it as an RFC.
I want to know whether you agree with the basic idea, and whether your subsystem wants this series to be squashed into a single commit that builds.
Overall, looks OK to me. But I think that at least patches 1 and 2 need to be squashed together. For patch 3, if you can have a minimal "make it compile" change in patch 2, you can keep the cleanup separate. Otherwise, squashing all patches together seems fine too.
Quoted 3 lines
Another solution would be to provide a struct ata_host.iomap2 or something like that, phase out the
pcim_iomap_regions()users, and then remove iomap2 again.
That seems unnecessary.
Quoted 37 lines
Please tell me your preferred way.
(This is the revived version of an old series from August. In case someone is wondering)
Thx,
P.Philipp Stanner (3):
ata: Allocate PCI iomap table statically
ata: Replace deprecated PCI functions
libata-sff: Simplify request of PCI resourcesdrivers/ata/ata_piix.c | 7 +- drivers/ata/libata-sff.c | 130 +++++++++++++++++++++++------------- drivers/ata/pata_atp867x.c | 13 ++-- drivers/ata/pata_hpt3x3.c | 10 +-- drivers/ata/pata_ninja32.c | 11 +-- drivers/ata/pata_pdc2027x.c | 11 ++- drivers/ata/pata_sil680.c | 12 ++-- drivers/ata/pdc_adma.c | 9 ++- drivers/ata/sata_inic162x.c | 10 ++- drivers/ata/sata_mv.c | 9 +-- drivers/ata/sata_nv.c | 8 +-- drivers/ata/sata_promise.c | 8 ++- drivers/ata/sata_qstor.c | 7 +- drivers/ata/sata_sil.c | 8 ++- drivers/ata/sata_sil24.c | 20 +++--- drivers/ata/sata_sis.c | 8 +-- drivers/ata/sata_svw.c | 10 +-- drivers/ata/sata_sx4.c | 19 +++++- drivers/ata/sata_via.c | 31 +++++---- drivers/ata/sata_vsc.c | 8 ++- include/linux/libata.h | 7 +- 21 files changed, 216 insertions(+), 140 deletions(-)
Signature · 2 lines
Damien Le Moal Western Digital Research