From: Philipp Stanner <pstanner@redhat.com>
To: Przemek Kitszel <przemyslaw.kitszel@intel.com>,
intel-wired-lan@lists.osuosl.org,
Tony Nguyen <anthony.l.nguyen@intel.com>
Cc: himasekharx.reddy.pucha@intel.com,
Larysa Zaremba <larysa.zaremba@intel.com>
Subject: Re: [Intel-wired-lan] [PATCH iwl-net] ice: stop calling pci_disable_device() as we use pcim
Date: Thu, 29 Aug 2024 09:11:40 +0200 [thread overview]
Message-ID: <839bc942bb6d8a3fc0cf9081b3f7d91fcbec790f.camel@redhat.com> (raw)
In-Reply-To: <20240828130403.14145-2-przemyslaw.kitszel@intel.com>
Hi,
On Wed, 2024-08-28 at 15:03 +0200, Przemek Kitszel wrote:
> Our driver uses devres to manage resources, in particular we call
> pcim_enable_device(), which recently has registered
> pcim_disable_device()
> as device remove action
That's not the exact cause, actually.
The ultimate call to pci_disable_device() (not pcim_) through callbacks
set up by pcim_enable_device() has always been there. It's not me
adding that which caused the warning. What caused it is that I removed
the enabled-check from pcim_disable_device():
f748a07a0b64:
-static void pcim_release(struct device *gendev, void *res)
+static void pcim_disable_device(void *pdev_raw)
{
- struct pci_dev *dev = to_pci_dev(gendev);
-
- if (pci_is_enabled(dev) && !dev->pinned)
- pci_disable_device(dev);
-}
-
-static struct pci_devres *get_pci_dr(struct pci_dev *pdev)
-{
- struct pci_devres *dr, *new_dr;
-
- dr = devres_find(&pdev->dev, pcim_release, NULL, NULL);
- if (dr)
- return dr;
+ struct pci_dev *pdev = pdev_raw;
- new_dr = devres_alloc(pcim_release, sizeof(*new_dr),
GFP_KERNEL);
- if (!new_dr)
- return NULL;
- return devres_get(&pdev->dev, new_dr, NULL, NULL);
+ if (!pdev->pinned)
+ pci_disable_device(pdev);
}
Theoretically, we could add
if (pci_is_enabled(...
back, but I think the far cleaner solution is to clean up the drivers
as you do here if that warning occurs. Faults should not be caused by
this, just warnings, if I read the code correctly. Please correct me if
not.
> (see cited "Fixes" commit). Since that, unloading
> the driver yields following warn+splat:
>
> [70633.628490] ice 0000:af:00.7: disabling already-disabled device
> [70633.628512] WARNING: CPU: 52 PID: 33890 at drivers/pci/pci.c:2250
> pci_disable_device+0xf4/0x100
> ...
> [70633.628744] ? pci_disable_device+0xf4/0x100
> [70633.628752] release_nodes+0x4a/0x70
> [70633.628759] devres_release_all+0x8b/0xc0
> [70633.628768] device_unbind_cleanup+0xe/0x70
> [70633.628774] device_release_driver_internal+0x208/0x250
> [70633.628781] driver_detach+0x47/0x90
> [70633.628786] bus_remove_driver+0x80/0x100
> [70633.628791] pci_unregister_driver+0x2a/0xb0
> [70633.628799] ice_module_exit+0x11/0x3a [ice]
>
> Note that this is the only Intel ethernet driver that needs such fix.
>
> CC: Philipp Stanner <pstanner@redhat.com>
> Fixes: f748a07a0b64 ("PCI: Remove legacy pcim_release()")
> Reviewed-by: Larysa Zaremba <larysa.zaremba@intel.com>
> Signed-off-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Reviewed-by: Philipp Stanner <pstanner@redhat.com>
with or without the above suggestion for the commit message.
Thanks for solving this!
Regards,
P.
> ---
> drivers/net/ethernet/intel/ice/ice_main.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/intel/ice/ice_main.c
> b/drivers/net/ethernet/intel/ice/ice_main.c
> index 6f97ed471fe9..18e4950316f1 100644
> --- a/drivers/net/ethernet/intel/ice/ice_main.c
> +++ b/drivers/net/ethernet/intel/ice/ice_main.c
> @@ -5350,7 +5350,6 @@ ice_probe(struct pci_dev *pdev, const struct
> pci_device_id __always_unused *ent)
> ice_deinit(pf);
> err_init:
> ice_adapter_put(pdev);
> - pci_disable_device(pdev);
> return err;
> }
>
> @@ -5457,7 +5456,6 @@ static void ice_remove(struct pci_dev *pdev)
> ice_set_wake(pf);
>
> ice_adapter_put(pdev);
> - pci_disable_device(pdev);
> }
>
> /**
>
> base-commit: 4186c8d9e6af57bab0687b299df10ebd47534a0a
next prev parent reply other threads:[~2024-08-29 15:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-28 13:03 [Intel-wired-lan] [PATCH iwl-net] ice: stop calling pci_disable_device() as we use pcim Przemek Kitszel
2024-08-29 7:11 ` Philipp Stanner [this message]
2024-08-30 6:16 ` Przemek Kitszel
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=839bc942bb6d8a3fc0cf9081b3f7d91fcbec790f.camel@redhat.com \
--to=pstanner@redhat.com \
--cc=anthony.l.nguyen@intel.com \
--cc=himasekharx.reddy.pucha@intel.com \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=larysa.zaremba@intel.com \
--cc=przemyslaw.kitszel@intel.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