From: Lukas Wunner <lukas@wunner.de>
To: Alistair Francis <alistair23@gmail.com>
Cc: bhelgaas@google.com, linux-pci@vger.kernel.org,
Jonathan.Cameron@huawei.com, 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 18:28:12 +0200 [thread overview]
Message-ID: <ZmxvnLDBhkWPrXGK@wunner.de> (raw)
In-Reply-To: <20240614001244.925401-3-alistair.francis@wdc.com>
On Fri, Jun 14, 2024 at 10:12:43AM +1000, Alistair Francis wrote:
> --- a/drivers/pci/pci-sysfs.c
> +++ b/drivers/pci/pci-sysfs.c
> @@ -16,6 +16,7 @@
> #include <linux/kernel.h>
> #include <linux/sched.h>
> #include <linux/pci.h>
> +#include <linux/pci-doe.h>
> #include <linux/stat.h>
> #include <linux/export.h>
> #include <linux/topology.h>
I'm not seeing any symbols used here which are defined in pci-doe.h.
Am I missing something?
If not this additional #include can be dropped.
> @@ -1143,6 +1144,9 @@ static void pci_remove_resource_files(struct pci_dev *pdev)
> {
> int i;
>
> + if (IS_ENABLED(CONFIG_PCI_DOE))
> + pci_doe_sysfs_teardown(pdev);
> +
No need to constrain to "if (IS_ENABLED(CONFIG_PCI_DOE))" as you're
defining an empty static inline in the header file.
> @@ -1227,6 +1231,12 @@ static int pci_create_resource_files(struct pci_dev *pdev)
> int i;
> int retval;
>
> + if (IS_ENABLED(CONFIG_PCI_DOE)) {
> + retval = pci_doe_sysfs_init(pdev);
> + if (retval)
> + return retval;
> + }
> +
Same here.
Note that pci_{create,remove}_resource_files() is not the right place
to dynamically add sysfs attributes. These functions are called very
late to postpone exposure of ROM resources until they're enumerated.
You want to add your sysfs attributes right after device_add() has been
called and you want to remove them right before device_del() is called.
See here for an example how it's done correctly:
https://lore.kernel.org/all/20240528131940.16924-3-mariusz.tkaczyk@linux.intel.com/
(Search for the call to pci_npem_create() in pci_device_add() and
pci_npem_remove() in pci_destroy_dev().)
> --- a/drivers/pci/pci.h
> +++ b/drivers/pci/pci.h
> @@ -189,6 +189,7 @@ extern const struct attribute_group *pci_dev_groups[];
> extern const struct attribute_group *pci_dev_attr_groups[];
> extern const struct attribute_group *pcibus_groups[];
> extern const struct attribute_group *pci_bus_groups[];
> +extern const struct attribute_group pci_doe_sysfs_group;
> #else
> static inline int pci_create_sysfs_dev_files(struct pci_dev *pdev) { return 0; }
> static inline void pci_remove_sysfs_dev_files(struct pci_dev *pdev) { }
> @@ -196,6 +197,7 @@ static inline void pci_remove_sysfs_dev_files(struct pci_dev *pdev) { }
> #define pci_dev_attr_groups NULL
> #define pcibus_groups NULL
> #define pci_bus_groups NULL
> +#define pci_doe_sysfs_group NULL
> #endif
You only need the "extern const struct ..." definition, not the
NULL definition. The reason we have these NULL definitions is
because we're referencing the attribute groups in files which
are compiled even if CONFIG_SYSFS=n. But I believe that's not
the case here.
Thanks,
Lukas
next prev parent reply other threads:[~2024-06-14 16:28 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
2024-06-26 3:59 ` Alistair Francis
2024-06-14 16:28 ` Lukas Wunner [this message]
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=ZmxvnLDBhkWPrXGK@wunner.de \
--to=lukas@wunner.de \
--cc=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=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