public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: Alistair Francis <alistair23@gmail.com>
Cc: <bhelgaas@google.com>, <linux-pci@vger.kernel.org>,
	<lukas@wunner.de>, <alex.williamson@redhat.com>,
	<christian.koenig@amd.com>, <kch@nvidia.com>,
	<gregkh@linuxfoundation.org>, <logang@deltatee.com>,
	<linux-kernel@vger.kernel.org>, <chaitanyak@nvidia.com>,
	<rdunlap@infradead.org>,
	Alistair Francis <alistair.francis@wdc.com>
Subject: Re: [PATCH v11 3/4] PCI/DOE: Expose the DOE features via sysfs
Date: Fri, 14 Jun 2024 09:59:24 +0100	[thread overview]
Message-ID: <20240614095924.00004eb5@Huawei.com> (raw)
In-Reply-To: <20240614001244.925401-3-alistair.francis@wdc.com>

On Fri, 14 Jun 2024 10:12:43 +1000
Alistair Francis <alistair23@gmail.com> wrote:

> The PCIe 6 specification added support for the Data Object
> Exchange (DOE).
> When DOE is supported the DOE Discovery Feature must be implemented per
> PCIe r6.1 sec 6.30.1.1. The protocol allows a requester to obtain
> information about the other DOE features supported by the device.
> 
> The kernel is already querying the DOE features supported and cacheing
> the values. Expose the values in sysfs to allow user space to
> determine which DOE features are supported by the PCIe device.
> 
> By exposing the information to userspace tools like lspci can relay the
> information to users. By listing all of the supported features we can
> allow userspace to parse the list, which might include
> vendor specific features as well as yet to be supported features.
> 
> As the DOE Discovery feature must always be supported we treat it as a
> special named attribute case. This allows the usual PCI attribute_group
> handling to correctly create the doe_features directory when registering
> pci_doe_sysfs_group (otherwise it doesn't and sysfs_add_file_to_group()
> will seg fault).
> 
> After this patch is supported you can see something like this when
> attaching a DOE device
> 
> $ ls /sys/devices/pci0000:00/0000:00:02.0//doe*
> 0001:01        0001:02        doe_discovery
> 
> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Hi Alistair,

One question inline.  Feels like I'm either missing something or
the code has evolved in a fashion that left us with a pointless check
on attr visibility.

Jonathan

> diff --git a/drivers/pci/doe.c b/drivers/pci/doe.c
> index defc4be81bd4..9858b709c020 100644
> --- a/drivers/pci/doe.c
> +++ b/drivers/pci/doe.c

> +static umode_t pci_doe_features_sysfs_attr_visible(struct kobject *kobj,
> +						   struct attribute *a, int n)
> +{
> +	struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj));
> +	struct pci_doe_mb *doe_mb;
> +	unsigned long index, j;
> +	unsigned long vid, type;
> +	void *entry;
> +
> +	xa_for_each(&pdev->doe_mbs, index, doe_mb) {
> +		xa_for_each(&doe_mb->feats, j, entry) {

I'm confused.  What is the intent here?

Given every DOE should have the discovery entry any call of this function
that actually finds a DOE should return a->mode, so why search the
actual entries? 

Given absence of the files anyway (due to the directory visible checks)
if there are no DOEs, why not drop this function completely?

> +			vid = xa_to_value(entry) >> 8;
> +			type = xa_to_value(entry) & 0xFF;
> +
> +			if (vid == 0x01 && type == 0x00) {
> +				/*
> +				 * This is the DOE discovery protocol
> +				 * Every DOE instance must support this, so we
> +				 * give it a useful name.
> +				 */
> +				return a->mode;
> +			}
> +		}
> +	}
> +
> +	return 0;
> +}




  reply	other threads:[~2024-06-14  8:59 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-14  0:12 [PATCH v11 1/4] PCI/DOE: Rename DOE protocol to feature Alistair Francis
2024-06-14  0:12 ` [PATCH v11 2/4] PCI/DOE: Rename Discovery Response Data Object Contents to type Alistair Francis
2024-06-14  8:47   ` Jonathan Cameron
2024-06-14  0:12 ` [PATCH v11 3/4] PCI/DOE: Expose the DOE features via sysfs Alistair Francis
2024-06-14  8:59   ` Jonathan Cameron [this message]
2024-06-26  3:59     ` Alistair Francis
2024-06-14 16:28   ` Lukas Wunner
2024-06-15 13:05   ` Lukas Wunner
2024-08-06  6:36     ` Alistair Francis
2024-06-14  0:12 ` [PATCH v11 4/4] PCI/DOE: Allow enabling DOE without CXL Alistair Francis

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=20240614095924.00004eb5@Huawei.com \
    --to=jonathan.cameron@huawei.com \
    --cc=alex.williamson@redhat.com \
    --cc=alistair.francis@wdc.com \
    --cc=alistair23@gmail.com \
    --cc=bhelgaas@google.com \
    --cc=chaitanyak@nvidia.com \
    --cc=christian.koenig@amd.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kch@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=logang@deltatee.com \
    --cc=lukas@wunner.de \
    --cc=rdunlap@infradead.org \
    /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