From: Lukas Wunner <lukas@wunner.de>
To: Feng Tang <feng.tang@linux.alibaba.com>
Cc: rafael@kernel.org, Bjorn Helgaas <bhelgaas@google.com>,
Sathyanarayanan Kuppuswamy
<sathyanarayanan.kuppuswamy@linux.intel.com>,
Liguang Zhang <zhangliguang@linux.alibaba.com>,
Guanghui Feng <guanghuifeng@linux.alibaba.com>,
Markus Elfring <Markus.Elfring@web.de>,
lkp@intel.com, Jonathan Cameron <Jonathan.Cameron@huawei.com>,
ilpo.jarvinen@linux.intel.com, linux-pci@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 2/4] PCI/portdrv: Add necessary wait for disabling hotplug events
Date: Tue, 25 Feb 2025 05:01:43 +0100 [thread overview]
Message-ID: <Z71Ap7kpV4rfhFDU@wunner.de> (raw)
In-Reply-To: <Z70zyhZe6OrxNNT3@U-2FWC9VHC-2323.local>
On Tue, Feb 25, 2025 at 11:06:50AM +0800, Feng Tang wrote:
> On Mon, Feb 24, 2025 at 07:12:11PM +0100, Lukas Wunner wrote:
> > On Mon, Feb 24, 2025 at 11:44:58AM +0800, Feng Tang wrote:
> > > @@ -255,8 +271,7 @@ static int get_port_device_capability(struct pci_dev *dev)
> > > * Disable hot-plug interrupts in case they have been enabled
> > > * by the BIOS and the hot-plug service driver is not loaded.
> > > */
> > > - pcie_capability_clear_word(dev, PCI_EXP_SLTCTL,
> > > - PCI_EXP_SLTCTL_CCIE | PCI_EXP_SLTCTL_HPIE);
> > > + pcie_disable_hp_interrupts_early(dev);
> > > }
> >
> > Moving the Slot Control code from pciehp to portdrv (as is done in
> > patch 1 of this series) is hackish. It should be avoided if at all
> > possible.
>
> I tried to remove the code duplication of 2 waiting function, according
> to Bjorn's comment in https://lore.kernel.org/lkml/20250218223354.GA196886@bhelgaas/.
> Maybe I didn't git it right. Any suggestion?
My point is just that you may not need to move the code from pciehp to
portdrv at all if you follow my suggestion.
> There might be some misunderstaning here :), I responded in
> https://lore.kernel.org/lkml/Z6LRAozZm1UfgjqT@U-2FWC9VHC-2323.local/
> that your suggestion could solve our issue.
Well, could you test it please?
A small change like the one I proposed is definitely preferable to
moving dozens of lines of code around.
> And the reason I didn't take it is I was afraid that it might hurt
> the problem what commit 2bd50dd800b5 ("PCI: PCIe: Disable PCIe port
> services during port initialization") tried to solve.
>
> As you mentioned, the comment for 2bd50dd800b5 is "a bit confusing",
> and I tried to guess in my previous reply:
> "
> I'm not sure what problem this piece of code try to avoid, maybe
> something simliar to the irq storm isseu as mentioned in the 2/2 patch?
> The code comments could be about the small time window between this
> point and the loading of pciehp driver, which will request_irq and
> enable hotplug interrupt again.
> "
>
> The code comment from 2bd50dd800b5 is:
>
> /*
> * Disable hot-plug interrupts in case they have been
> * enabled by the BIOS and the hot-plug service driver
> * is not loaded.
> */
>
> The "is not loaded" has 2 possible meanings:
> 1. the pciehp driver is not loaded yet at this point inside
> get_port_device_capability(), and will be loaded later
> 2. the pciehp will never be loaded, i.e. CONFIG_HOTPLUG_PCI_PCIE=n
>
> If it's case 2, your suggestion can solve it nicely, but for case 1,
> we may have to keep the interrupt disabling.
The pciehp driver cannot be bound to the PCIe port when
get_port_device_capability() is running. Because at that point,
portdrv is still figuring out which capabilities the port has and
it will subsequently instantiate the port service devices to which
the drivers (such as pciehp) will bind.
So in that sense, case 1 cannot be what the code comment is
referring to.
My point is that if CONFIG_HOTPLUG_PCI_PCIE=y, there may indeed be
another write to the Slot Control register before the command written
by portdrv has been completed. Because pciehp will write to the
register on probe. But in this case, there shouldn't be a need for
portdrv to quiesce the interrupt because pciehp will do that anyway
shortly afterwards.
And in the CONFIG_HOTPLUG_PCI_PCIE=n case, pciehp will not quiesce
the interrupt, so portdrv has to do that. I believe that's what
the code comment is referring to. It should be safe to just write
to the Slot Control register without waiting for the command to
complete because there shouldn't be another Slot Control write
afterwards (not by pciehp anyway).
If making the Slot Control write in portdrv conditional on
CONFIG_HOTPLUG_PCI_PCIE=n does unexpectedly *not* solve the issue,
please try to find out where the second Slot Control write is
coming from. E.g. you could amend pcie_capability_write_word()
with something like:
if (pos == PCI_EXP_SLTCTL) {
pci_info(dev, "Writing %04hx SltCtl\n", val);
dump_stack();
}
Thanks,
Lukas
next prev parent reply other threads:[~2025-02-25 4:01 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-24 3:44 [PATCH v3 0/4] PCIe hotplug interrupt related fixes Feng Tang
2025-02-24 3:44 ` [PATCH v3 1/4] PCI: portdrv: pciehp: Move PCIe hotplug command waiting logic to port driver Feng Tang
2025-02-24 15:06 ` Ilpo Järvinen
2025-02-25 8:18 ` Feng Tang
2025-02-24 3:44 ` [PATCH v3 2/4] PCI/portdrv: Add necessary wait for disabling hotplug events Feng Tang
2025-02-24 9:42 ` Markus Elfring
2025-02-24 15:00 ` Ilpo Järvinen
2025-02-25 5:51 ` Feng Tang
2025-02-24 18:12 ` Lukas Wunner
2025-02-25 3:06 ` Feng Tang
2025-02-25 4:01 ` Lukas Wunner [this message]
2025-02-25 4:42 ` Feng Tang
2025-02-28 6:29 ` Feng Tang
2025-02-28 7:14 ` Lukas Wunner
2025-02-28 9:33 ` Feng Tang
2025-02-28 10:01 ` Feng Tang
2025-02-24 3:44 ` [PATCH v3 3/4] PCI/portdrv: Loose the condition check for disabling hotplug interrupts Feng Tang
2025-02-24 9:47 ` Markus Elfring
2025-02-25 4:09 ` Lukas Wunner
2025-02-26 2:54 ` Feng Tang
2025-02-24 3:45 ` [PATCH v3 4/4] PCI: Disable PCIe hotplug interrupts early when msi is disabled Feng Tang
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=Z71Ap7kpV4rfhFDU@wunner.de \
--to=lukas@wunner.de \
--cc=Jonathan.Cameron@huawei.com \
--cc=Markus.Elfring@web.de \
--cc=bhelgaas@google.com \
--cc=feng.tang@linux.alibaba.com \
--cc=guanghuifeng@linux.alibaba.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lkp@intel.com \
--cc=rafael@kernel.org \
--cc=sathyanarayanan.kuppuswamy@linux.intel.com \
--cc=zhangliguang@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