mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Philipp Stanner <phasta@mailbox.org>
To: Philipp Stanner <phasta@kernel.org>,
	Basavaraj Natikar <Basavaraj.Natikar@amd.com>,
	Vinod Koul <vkoul@kernel.org>
Cc: dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] dmaengine: amd: Replace deprecated PCI functions
Date: Tue, 03 Feb 2026 13:41:04 +0100	[thread overview]
Message-ID: <431b8803109624e05901d44c55772402f811cf02.camel@mailbox.org> (raw)
In-Reply-To: <20260203123238.88598-2-phasta@kernel.org>

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@kernel.org>
> ---
> 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,


  reply	other threads:[~2026-02-03 12:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-03 12:32 Philipp Stanner
2026-02-03 12:41 ` Philipp Stanner [this message]
2026-02-03 19:08 ` kernel test robot
2026-02-03 20:16 ` kernel test robot
2026-02-03 20:16 ` kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=431b8803109624e05901d44c55772402f811cf02.camel@mailbox.org \
    --to=phasta@mailbox.org \
    --cc=Basavaraj.Natikar@amd.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=phasta@kernel.org \
    --cc=vkoul@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®