public inbox for linux-pci@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Jiang <dave.jiang@intel.com>
To: Lukas Wunner <lukas@wunner.de>
Cc: linux-cxl@vger.kernel.org, linux-pci@vger.kernel.org,
	dan.j.williams@intel.com, ira.weiny@intel.com,
	vishal.l.verma@intel.com, alison.schofield@intel.com,
	Jonathan.Cameron@huawei.com, dave@stgolabs.net,
	bhelgaas@google.com
Subject: Re: [PATCH 1/3] PCI: Add check for CXL Secondary Bus Reset
Date: Tue, 12 Mar 2024 14:35:28 -0700	[thread overview]
Message-ID: <c50492a9-0fcc-47be-bce2-f5543587a5f2@intel.com> (raw)
In-Reply-To: <ZfAEncKttj9qFQHw@wunner.de>



On 3/12/24 12:30 AM, Lukas Wunner wrote:
> On Mon, Mar 11, 2024 at 01:39:53PM -0700, Dave Jiang wrote:
>> +static bool is_cxl_device(struct pci_dev *dev)
>> +{
>> +	return pci_find_dvsec_capability(dev, PCI_DVSEC_VENDOR_ID_CXL,
>> +					 CXL_DVSEC_PCIE_DEVICE);
>> +}
> 
> If this was my bikeshed, I'd call it pci_is_cxl() to match pci_is_pcie().

Ok will change.
> 
> 
>> +static bool is_cxl_port_sbr_masked(struct pci_dev *dev)
>> +{
>> +	int dvsec;
>> +	int rc;
>> +	u16 reg;
> 
> Nit: Inverse Christmas tree?

Will change.
> 
> 
>>  static int pci_reset_bus_function(struct pci_dev *dev, bool probe)
>>  {
>>  	int rc;
>>  
>> +	/* If it's a CXL port and the SBR control is masked, fail the SBR */
>> +	if (is_cxl_device(dev) && dev->bus->self &&
>> +	    is_cxl_port_sbr_masked(dev->bus->self)) {
>> +		if (probe)
>> +			return 0;
>> +
>> +		return -EPERM;
>> +	}
>> +
> 
> Is this also necessary if CONFIG_CXL_PCI=n?

Yes. As the kernel only loads type3 mem class CXL device driver. This is attempt to cover all CXL devices and not dependent on a loaded driver.

> 
> Return code on non-availability of a reset method is generally -ENOTTY.

Ok I can change it to that.

> Or is the choice deliberate to expose this reset method despite the bit
> being set and thus allow user space to unmask it in the first place?

Yes the idea is if user intentionally unmasks the bit via a user tool then reset can go through.

> 
> Also, we mostly use pci_upstream_bridge(dev) in lieu of dev->bus->self.
> Is the choice to use the latter deliberate because maybe is_virtfn is
> never set and the device can never be on the root bus?  (What about
> RCiEP CXL devices?)

I'll change to pci_upstream_bridge() call. I didn't realize that existed.

> 
> Thanks,
> 
> Lukas

  reply	other threads:[~2024-03-12 21:35 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-11 20:39 [PATCH 0/3] PCI: Add Secondary Bus Reset (SBR) support for CXL Dave Jiang
2024-03-11 20:39 ` [PATCH 1/3] PCI: Add check for CXL Secondary Bus Reset Dave Jiang
2024-03-12  7:30   ` Lukas Wunner
2024-03-12 21:35     ` Dave Jiang [this message]
2024-03-11 20:39 ` [PATCH 2/3] PCI: Create new reset method to force SBR for CXL Dave Jiang
2024-03-12  7:50   ` Lukas Wunner
2024-03-11 20:39 ` [PATCH 3/3] cxl: Add post reset warning if reset is detected as Secondary Bus Reset (SBR) Dave Jiang
2024-03-12  7:46 ` [PATCH 0/3] PCI: Add Secondary Bus Reset (SBR) support for CXL Lukas Wunner
2024-03-12 21:31   ` Dave Jiang

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=c50492a9-0fcc-47be-bce2-f5543587a5f2@intel.com \
    --to=dave.jiang@intel.com \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=alison.schofield@intel.com \
    --cc=bhelgaas@google.com \
    --cc=dan.j.williams@intel.com \
    --cc=dave@stgolabs.net \
    --cc=ira.weiny@intel.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lukas@wunner.de \
    --cc=vishal.l.verma@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