From: Ira Weiny <ira.weiny@intel.com>
To: Smita Koralahalli <Smita.KoralahalliChannabasappa@amd.com>,
<linux-efi@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-cxl@vger.kernel.org>
Cc: Ard Biesheuvel <ardb@kernel.org>,
Alison Schofield <alison.schofield@intel.com>,
Vishal Verma <vishal.l.verma@intel.com>,
"Ira Weiny" <ira.weiny@intel.com>,
Dan Williams <dan.j.williams@intel.com>,
Jonathan Cameron <Jonathan.Cameron@huawei.com>,
Yazen Ghannam <yazen.ghannam@amd.com>,
Bowman Terry <terry.bowman@amd.com>
Subject: Re: [PATCH v2 2/4] cxl/pci: Define a common function get_cxl_devstate()
Date: Tue, 1 Oct 2024 10:06:25 -0500 [thread overview]
Message-ID: <66fc0ff16eecf_b5d94294b7@iweiny-mobl.notmuch> (raw)
In-Reply-To: <20241001005234.61409-3-Smita.KoralahalliChannabasappa@amd.com>
Smita Koralahalli wrote:
> Refactor computation of cxlds to a common function get_cxl_devstate().
>
> The above function could then be reused in both FW-First Component and
> Protocol error reporting and handling.
>
> Signed-off-by: Smita Koralahalli <Smita.KoralahalliChannabasappa@amd.com>
> ---
> v2:
> Refactor before adding trace support.
> get_cxl_dev() -> get_cxl_devstate().
> Cleaned up get_cxl_devstate().
> ---
> drivers/cxl/pci.c | 32 +++++++++++++++++++-------------
> 1 file changed, 19 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c
> index 37164174b5fb..915102f5113f 100644
> --- a/drivers/cxl/pci.c
> +++ b/drivers/cxl/pci.c
> @@ -1021,32 +1021,38 @@ static struct pci_driver cxl_pci_driver = {
> },
> };
>
> +static struct cxl_dev_state *get_cxl_devstate(u16 segment, u8 bus,
> + u8 device, u8 function)
> +{
> + unsigned int devfn = PCI_DEVFN(device, function);
> + struct pci_dev *pdev __free(pci_dev_put) =
> + pci_get_domain_bus_and_slot(segment, bus, devfn);
This is a good cleanup. The previous code should not have declared pdev
NULL. However...
> +
> + if (!pdev)
> + return NULL;
> +
> + guard(device)(&pdev->dev);
> + if (pdev->driver != &cxl_pci_driver)
> + return NULL;
> +
> + return pci_get_drvdata(pdev);
The device lock is now dropped before the tracing is completed. For this
simple code I'm not keen on having the lock be taken in the helper and
released later. It seems best to just open code this in each caller.
Ira
next prev parent reply other threads:[~2024-10-01 15:06 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-01 0:52 [PATCH v2 0/4] acpi/ghes, cper, cxl: Trace FW-First CXL Protocol Errors Smita Koralahalli
2024-10-01 0:52 ` [PATCH v2 1/4] efi/cper, cxl: Make definitions and structures global Smita Koralahalli
2024-10-02 23:02 ` Dan Williams
2024-10-03 8:51 ` Ard Biesheuvel
2024-10-01 0:52 ` [PATCH v2 2/4] cxl/pci: Define a common function get_cxl_devstate() Smita Koralahalli
2024-10-01 15:06 ` Ira Weiny [this message]
2024-10-02 23:04 ` Dan Williams
2024-10-03 18:44 ` Smita Koralahalli
2024-10-01 0:52 ` [PATCH v2 3/4] acpi/ghes, efi/cper: Recognize and process CXL Protocol Errors Smita Koralahalli
2024-10-01 15:47 ` Ira Weiny
2024-10-01 17:41 ` Fan Ni
2024-10-03 19:19 ` Smita Koralahalli
2024-10-02 23:47 ` Dan Williams
2024-10-03 19:15 ` Smita Koralahalli
2024-10-03 23:21 ` Dan Williams
2024-10-01 0:52 ` [PATCH v2 4/4] acpi/ghes, cxl/pci: Trace FW-First " Smita Koralahalli
2024-10-01 15:52 ` Ira Weiny
2024-10-03 19:31 ` Smita Koralahalli
2024-10-03 0:16 ` Dan Williams
2024-10-03 20:03 ` Smita Koralahalli
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=66fc0ff16eecf_b5d94294b7@iweiny-mobl.notmuch \
--to=ira.weiny@intel.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=Smita.KoralahalliChannabasappa@amd.com \
--cc=alison.schofield@intel.com \
--cc=ardb@kernel.org \
--cc=dan.j.williams@intel.com \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-efi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=terry.bowman@amd.com \
--cc=vishal.l.verma@intel.com \
--cc=yazen.ghannam@amd.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