Linux PCI subsystem development
 help / color / mirror / Atom feed
From: Sathyanarayanan Kuppuswamy  <sathyanarayanan.kuppuswamy@linux.intel.com>
To: Bjorn Helgaas <helgaas@kernel.org>
Cc: Mika Westerberg <mika.westerberg@linux.intel.com>,
	Bjorn Helgaas <bhelgaas@google.com>,
	linux-pci@vger.kernel.org
Subject: Re: [PATCH v2] PCI/portdrv: Do not require an interrupt for all AER capable ports
Date: Fri, 9 Dec 2022 14:13:53 -0800	[thread overview]
Message-ID: <c96da230-bd9d-a9db-2b89-a48314b6d056@linux.intel.com> (raw)
In-Reply-To: <20221209214835.GA1734545@bhelgaas>



On 12/9/22 1:48 PM, Bjorn Helgaas wrote:
> On Fri, Dec 09, 2022 at 01:04:22PM -0800, Sathyanarayanan Kuppuswamy wrote:
>> On 12/9/22 9:07 AM, Bjorn Helgaas wrote:
>>> On Wed, Dec 07, 2022 at 10:41:05AM +0200, Mika Westerberg wrote:
>>>> Only Root Ports and Event Collectors use MSI for AER. PCIe Switch ports
>>>> or endpoints on the other hand only send messages (that get collected by
>>>> the former). For this reason do not require PCIe switch ports and
>>>> endpoints to use interrupt if they support AER.
>>>>
>>>> This allows portdrv to attach PCIe switch ports of Intel DG1 and DG2
>>>> discrete graphics cards. These do not declare MSI or legacy interrupts.
>>>>
>>>> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
>>>
>>> Thanks for the additional info!  This seems like something we should
>>> definitely do.
>>>
>>> I'm wondering whether we should check for this in
>>> get_port_device_capability().  It already has similar checks for
>>> device type for other services.  This would skip pci_set_master() for
>>> these non-RP, non-RCEC devices, which is probably harmless, since I
>>> assume we only need that to make sure MSI works.
>>
>> Currently, we only have high level (cap or enable/disable) checks in 
>> get_port_device_capability(). Why bring in more AER specific checks
>> there and make it complicated? Is there any benefit in doing this?
> 
> Thanks a lot for taking a look!
> 
> I agree, I hate how complicated the expressions in
> get_port_device_capability() are, but I don't think my idea is
> significantly worse than what's already there.
> 
> Here's some existing code from get_port_device_capability():
> 
>         /* Root Ports and Root Complex Event Collectors may generate PMEs */
>         if ((pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT ||
>              pci_pcie_type(dev) == PCI_EXP_TYPE_RC_EC) &&
>             (pcie_ports_native || host->native_pme)) {
>                 services |= PCIE_PORT_SERVICE_PME;
> 
> And here's what the corresponding AER code would look like:
> 
>         if ((pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT ||
>              pci_pcie_type(dev) == PCI_EXP_TYPE_RC_EC) &&
>             dev->aer_cap && pci_aer_available() &&
>             (pcie_ports_native || host->native_aer))
>                 services |= PCIE_PORT_SERVICE_AER;
> 
> I do have some ideas about simplifying these, see below.
> 
> The benefits would be to make similar checks in the same place, avoid
> setting Bus Master when we don't need it, and remove the AER child
> service for non-RP/RCECs (it wouldn't appear in sysfs and they
> wouldn't be eligible for PCIE_PORT_SERVICE_AER registration).

I did not notice the PME part. But if possible, we should simplify
these conditions in the future.

I have no objections about this change.

> 
>>> It would also prevent allocation of the AER service for non-RP,
>>> non-RCEC devices.  That's also probably harmless, since aer_probe()
>>> ignores those devices anyway.
>>>
>>> What do you think of something like this?  (This is based on my
>>> pci/portdrv branch which squashed everything into portdrv.c:
>>> https://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git/log/?h=pci/portdrv)
>>>
>>> diff --git a/drivers/pci/pcie/portdrv.c b/drivers/pci/pcie/portdrv.c
>>> index a6c4225505d5..8b16e96ec15c 100644
>>> --- a/drivers/pci/pcie/portdrv.c
>>> +++ b/drivers/pci/pcie/portdrv.c
>>> @@ -232,7 +232,9 @@ static int get_port_device_capability(struct pci_dev *dev)
>>>  	}
>>>  
>>>  #ifdef CONFIG_PCIEAER
>>> -	if (dev->aer_cap && pci_aer_available() &&
>>> +	if ((pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT ||
>>> +             pci_pcie_type(dev) == PCI_EXP_TYPE_RC_EC) &&
>>> +	    dev->aer_cap && pci_aer_available() &&
>>>  	    (pcie_ports_native || host->native_aer))
>>>  		services |= PCIE_PORT_SERVICE_AER;
>>>  #endif
>>
>> If you want to do it, will you remove the relevant check in AER driver
>> probe?
> 
> That would be a good idea, although I was hoping to squeeze this into
> v6.2, and I would probably postpone the rest until the next cycle.
> 
> I think aer_probe() could also be simplified by dropping the
> set_downstream_devices_error_reporting() stuff.  pci_aer_init()
> already takes care of that, IIUC, and that's a more natural place for
> it since it handles the hot-add case.

Agree. Since pci_ear_init() already configures the AER bits for all
devices, repeating it in aer_probe() is redundant. 

> 
> There may also be opportunity to simplify some of these ugly checks of
> pci_aer_available(), pcie_ports_native, and host->native_aer that are
> littered all over the place by doing them in pci_aer_init() and
> setting dev->aer_cap only if they are satisfied.
> 
> Bjorn

-- 
Sathyanarayanan Kuppuswamy
Linux Kernel Developer

      reply	other threads:[~2022-12-09 22:14 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-07  8:41 [PATCH v2] PCI/portdrv: Do not require an interrupt for all AER capable ports Mika Westerberg
2022-12-07 14:31 ` Sathyanarayanan Kuppuswamy
2022-12-07 22:35 ` Bjorn Helgaas
2022-12-08  5:58   ` Mika Westerberg
2022-12-08 12:23     ` Bjorn Helgaas
2022-12-08 13:58       ` Mika Westerberg
2022-12-08 14:12         ` Mika Westerberg
2022-12-09 17:07 ` Bjorn Helgaas
2022-12-09 21:04   ` Sathyanarayanan Kuppuswamy
2022-12-09 21:48     ` Bjorn Helgaas
2022-12-09 22:13       ` Sathyanarayanan Kuppuswamy [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=c96da230-bd9d-a9db-2b89-a48314b6d056@linux.intel.com \
    --to=sathyanarayanan.kuppuswamy@linux.intel.com \
    --cc=bhelgaas@google.com \
    --cc=helgaas@kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=mika.westerberg@linux.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