Re: [PATCH] dmaengine: amd: Replace deprecated PCI functions

From: Philipp Stanner

Date: Tue Feb 03 2026 - 07:45:05 EST


On Tue, 2026-02-03 at 13:32 +0100, Philipp Stanner wrote:
> ae4dma and ptdma make use of pcim_iomap_table(), a deprecated,
> problematic PCI function.
>
> Both drivers currently request all IORESOURCE_MEM BARs, and ioremap only
> a single bar.
>
> Replace the deprecated function while keeping the aforementioned
> behavior identical.
>
> Signed-off-by: Philipp Stanner <phasta@xxxxxxxxxx>
> ---
> If it's deemed unnecessary to do the region requests, we could further
> simplify the code.
>
> Compiled, not tested.
>
> P.
> ---
>  drivers/dma/amd/ae4dma/ae4dma-pci.c | 17 +++++++++++------
>  drivers/dma/amd/ptdma/ptdma-pci.c   | 27 ++++++++++++---------------
>  2 files changed, 23 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/dma/amd/ae4dma/ae4dma-pci.c b/drivers/dma/amd/ae4dma/ae4dma-pci.c
> index 2c63907db228..872011d4dd37 100644
> --- a/drivers/dma/amd/ae4dma/ae4dma-pci.c
> +++ b/drivers/dma/amd/ae4dma/ae4dma-pci.c
> @@ -10,6 +10,8 @@
>  
>  #include "ae4dma.h"
>  
> +#define DRIVER_NAME "ae4dma"
> +
>  static int ae4_get_irqs(struct ae4_device *ae4)
>  {
>   struct ae4_msix *ae4_msix = ae4->ae4_msix;
> @@ -75,9 +77,10 @@ static int ae4_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
>  {
>   struct device *dev = &pdev->dev;
>   struct ae4_device *ae4;
> + unsigned long bar_mask
>   struct pt_device *pt;
> - int bar_mask;
>   int ret = 0;
> + int bar;
>  
>   ae4 = devm_kzalloc(dev, sizeof(*ae4), GFP_KERNEL);
>   if (!ae4)
> @@ -92,15 +95,17 @@ static int ae4_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
>   goto ae4_error;
>  
>   bar_mask = pci_select_bars(pdev, IORESOURCE_MEM);
> - ret = pcim_iomap_regions(pdev, bar_mask, "ae4dma");
> - if (ret)
> - goto ae4_error;
> + for_each_set_bit(bar, &bar_mask, sizeof(bar_mask)) {
> + ret = pcim_request_region(pdev, bar, DRIVER_NAME);
> + if (ret)
> + goto ae4_error;
> + }
>  
>   pt = &ae4->pt;
>   pt->dev = dev;
>   pt->ver = AE4_DMA_VERSION;
>  
> - pt->io_regs = pcim_iomap_table(pdev)[0];
> + pt->io_regs = pcim_iomap(pdev, 0, 0);
>   if (!pt->io_regs) {
>   ret = -ENOMEM;
>   goto ae4_error;
> @@ -144,7 +149,7 @@ static const struct pci_device_id ae4_pci_table[] = {
>  MODULE_DEVICE_TABLE(pci, ae4_pci_table);
>  
>  static struct pci_driver ae4_pci_driver = {
> - .name = "ae4dma",
> + .name = DRIVER_NAME,
>   .id_table = ae4_pci_table,
>   .probe = ae4_pci_probe,
>   .remove = ae4_pci_remove,
> diff --git a/drivers/dma/amd/ptdma/ptdma-pci.c b/drivers/dma/amd/ptdma/ptdma-pci.c
> index 22739ff0c3c5..d1c1c14b9292 100644
> --- a/drivers/dma/amd/ptdma/ptdma-pci.c
> +++ b/drivers/dma/amd/ptdma/ptdma-pci.c
> @@ -23,6 +23,8 @@
>  
>  #include "ptdma.h"
>  
> +#define DRIVER_NAME ptdma

Oh, please ignore that patch – I hadn't checked the fix for this in
accidentally. Will provide v2…


Sorry,
P.

> +
>  struct pt_msix {
>   int msix_count;
>   struct msix_entry msix_entry;
> @@ -123,9 +125,9 @@ static int pt_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
>   struct pt_device *pt;
>   struct pt_msix *pt_msix;
>   struct device *dev = &pdev->dev;
> - void __iomem * const *iomap_table;
> - int bar_mask;
> + unsigned long bar_mask;
>   int ret = -ENOMEM;
> + int bar;
>  
>   pt = pt_alloc_struct(dev);
>   if (!pt)
> @@ -150,20 +152,15 @@ static int pt_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
>   }
>  
>   bar_mask = pci_select_bars(pdev, IORESOURCE_MEM);
> - ret = pcim_iomap_regions(pdev, bar_mask, "ptdma");
> - if (ret) {
> - dev_err(dev, "pcim_iomap_regions failed (%d)\n", ret);
> - goto e_err;
> + for_each_set_bit(bar, &bar_mask, sizeof(bar_mask)) {
> + ret = pcim_request_region(pdev, bar, DRIVER_NAME);
> + if (ret) {
> + dev_err(dev, "pcim_iomap_regions failed (%d)\n", ret);
> + goto e_err;
> + }
>   }
>  
> - iomap_table = pcim_iomap_table(pdev);
> - if (!iomap_table) {
> - dev_err(dev, "pcim_iomap_table failed\n");
> - ret = -ENOMEM;
> - goto e_err;
> - }
> -
> - pt->io_regs = iomap_table[pt->dev_vdata->bar];
> + pt->io_regs = pcim_iomap(pdev, pt->dev_vdata->bar, 0);
>   if (!pt->io_regs) {
>   dev_err(dev, "ioremap failed\n");
>   ret = -ENOMEM;
> @@ -230,7 +227,7 @@ static const struct pci_device_id pt_pci_table[] = {
>  MODULE_DEVICE_TABLE(pci, pt_pci_table);
>  
>  static struct pci_driver pt_pci_driver = {
> - .name = "ptdma",
> + .name = DRIVER_NAME,
>   .id_table = pt_pci_table,
>   .probe = pt_pci_probe,
>   .remove = pt_pci_remove,