mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Philipp Stanner <phasta@mailbox.org>
To: "Philipp Stanner" <phasta@kernel.org>,
	schalla@marvell.com, vattunuru@marvell.com,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Jason Wang" <jasowang@redhat.com>,
	"Xuan Zhuo" <xuanzhuo@linux.alibaba.com>,
	"Eugenio Pérez" <eperezma@redhat.com>,
	"Shijith Thotton" <sthotton@marvell.com>,
	"Dan Carpenter" <dan.carpenter@linaro.org>,
	"Satha Rao" <skoteshwar@marvell.com>
Cc: virtualization@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] vdpa/octeon_ep: Control PCI dev enabling manually
Date: Wed, 23 Apr 2025 14:09:34 +0200	[thread overview]
Message-ID: <f7c67d6cb24e94b9fd053b144f616d71354f114e.camel@mailbox.org> (raw)
In-Reply-To: <20250423103909.59063-2-phasta@kernel.org>

On Wed, 2025-04-23 at 12:39 +0200, Philipp Stanner wrote:
> PCI region request functions such as pci_request_region() currently
> have
> the problem of becoming sometimes managed functions, if
> pcim_enable_device() instead of pci_enable_device() was called. The
> PCI
> subsystem wants to remove this deprecated behavior from its
> interfaces.
> 
> octeopn_ep enables its device with pcim_enable_device(), but does so
> only to get automatic disablement. The driver wants to manage its PCI
> resources manually, without devres.
> 
> The easiest way not to use automatic resource management at all is by
> also handling device enable- and disablement manually.
> 
> Replace pcim_enable_device() with pci_enable_device(). Add the
> necessary
> calls to pci_disable_device().	struct
> list_head		pending_list;
> 
> Signed-off-by: Philipp Stanner <phasta@kernel.org>
> ---
> Was formerly called "Use non-hybrid PCI devres API"
> 
> Changes in v2:
>   - Don't replace the request functions. Enable / disable manually
>     instead. (Vamsi)
> ---
>  drivers/vdpa/octeon_ep/octep_vdpa_main.c | 16 +++++++++++-----
>  1 file changed, 11 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/vdpa/octeon_ep/octep_vdpa_main.c
> b/drivers/vdpa/octeon_ep/octep_vdpa_main.c
> index f3d4dda4e04c..0a282f9186f4 100644
> --- a/drivers/vdpa/octeon_ep/octep_vdpa_main.c
> +++ b/drivers/vdpa/octeon_ep/octep_vdpa_main.c
> @@ -492,6 +492,8 @@ static void octep_vdpa_remove(struct pci_dev
> *pdev)
>  		octep_vdpa_remove_vf(pdev);
>  	else
>  		octep_vdpa_remove_pf(pdev);
> +
> +	pci_disable_device(pdev);

Taking a second glance, we probably want to do this only for PF, don't
we?

So VF would use pcim_enable_device(), but none of the request
functions, and PF would replace its pcim_enable_device(), and to
compensate for that only the PF remove / deactivate path would actively
call pci_disable_device. Right?

P.

>  }
>  
>  static int octep_vdpa_dev_add(struct vdpa_mgmt_dev *mdev, const char
> *name,
> @@ -825,7 +827,7 @@ static int octep_vdpa_probe_pf(struct pci_dev
> *pdev)
>  	struct octep_pf *octpf;
>  	int ret;
>  
> -	ret = pcim_enable_device(pdev);
> +	ret = pci_enable_device(pdev);
>  	if (ret) {
>  		dev_err(dev, "Failed to enable device\n");
>  		return ret;
> @@ -834,15 +836,17 @@ static int octep_vdpa_probe_pf(struct pci_dev
> *pdev)
>  	ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64));
>  	if (ret) {
>  		dev_err(dev, "No usable DMA configuration\n");
> -		return ret;
> +		goto disable_pci;
>  	}
>  	octpf = devm_kzalloc(dev, sizeof(*octpf), GFP_KERNEL);
> -	if (!octpf)
> -		return -ENOMEM;
> +	if (!octpf) {
> +		ret = -ENOMEM;
> +		goto disable_pci;
> +	}
>  
>  	ret = octep_iomap_region(pdev, octpf->base,
> OCTEP_HW_MBOX_BAR);
>  	if (ret)
> -		return ret;
> +		goto disable_pci;
>  
>  	pci_set_master(pdev);
>  	pci_set_drvdata(pdev, octpf);
> @@ -856,6 +860,8 @@ static int octep_vdpa_probe_pf(struct pci_dev
> *pdev)
>  
>  unmap_region:
>  	octep_iounmap_region(pdev, octpf->base, OCTEP_HW_MBOX_BAR);
> +disable_pci:
> +	pci_disable_device(pdev);
>  	return ret;
>  }
>  


      reply	other threads:[~2025-04-23 12:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-23 10:39 Philipp Stanner
2025-04-23 12:09 ` Philipp Stanner [this message]

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=f7c67d6cb24e94b9fd053b144f616d71354f114e.camel@mailbox.org \
    --to=phasta@mailbox.org \
    --cc=dan.carpenter@linaro.org \
    --cc=eperezma@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=phasta@kernel.org \
    --cc=schalla@marvell.com \
    --cc=skoteshwar@marvell.com \
    --cc=sthotton@marvell.com \
    --cc=vattunuru@marvell.com \
    --cc=virtualization@lists.linux.dev \
    --cc=xuanzhuo@linux.alibaba.com \
    /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®