From: Ira Weiny <ira.weiny@intel.com>
To: Dan Williams <dan.j.williams@intel.com>,
Ira Weiny <ira.weiny@intel.com>,
Jonathan Cameron <jonathan.cameron@huawei.com>,
Smita Koralahalli <Smita.KoralahalliChannabasappa@amd.com>,
Shiju Jose <shiju.jose@huawei.com>
Cc: Yazen Ghannam <yazen.ghannam@amd.com>,
Davidlohr Bueso <dave@stgolabs.net>,
Dave Jiang <dave.jiang@intel.com>,
Alison Schofield <alison.schofield@intel.com>,
Vishal Verma <vishal.l.verma@intel.com>,
"Ard Biesheuvel" <ardb@kernel.org>, <linux-efi@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <linux-cxl@vger.kernel.org>,
Ira Weiny <ira.weiny@intel.com>
Subject: Re: [PATCH v2 7/7] cxl/memdev: Register for and process CPER events
Date: Tue, 12 Dec 2023 16:17:00 -0800 [thread overview]
Message-ID: <6578f7fc4e04a_22539529429@iweiny-mobl.notmuch> (raw)
In-Reply-To: <657897453dda8_269bd29492@dwillia2-mobl3.amr.corp.intel.com.notmuch>
Dan Williams wrote:
> Ira Weiny wrote:
[snip]
> > diff --git a/drivers/cxl/cxlmem.h b/drivers/cxl/cxlmem.h
> > index e5d770e26e02..7a891b4641cc 100644
> > --- a/drivers/cxl/cxlmem.h
> > +++ b/drivers/cxl/cxlmem.h
> > @@ -481,6 +481,8 @@ struct cxl_memdev_state {
> > struct cxl_security_state security;
> > struct cxl_fw_state fw;
> >
> > + struct notifier_block cxl_cper_nb;
delete this...
[snip]
> >
> > +#define CXL_EVENT_HDR_FLAGS_REC_SEVERITY GENMASK(1, 0)
> > +static void cxl_cper_event_call(struct cxl_cper_event_data *ev_data)
> > +{
> > + struct cper_cxl_event_devid *device_id = &ev_data->rec->hdr.device_id;
> > + struct cxl_dev_state *cxlds = NULL;
> > + enum cxl_event_log_type log_type;
> > + struct pci_dev *pdev;
> > + unsigned int devfn;
> > + u32 hdr_flags;
> > +
> > + devfn = PCI_DEVFN(device_id->device_num, device_id->func_num);
> > + pdev = pci_get_domain_bus_and_slot(device_id->segment_num,
> > + device_id->bus_num, devfn);
>
> What if pci_get_domain_bus_and_slot() returned NULL?
:-/ yep.
>
> > +
> > + guard(mutex)(&pdev->dev.mutex);
>
> Lets not open code this since device_lock() is so prevalent it deserves
> its own guard() type:
>
> DEFINE_GUARD(device, struct device *, device_lock(_T), device_unlock(_T))
Good idea.
>
> > + if (pdev->driver == &cxl_pci_driver)
> > + cxlds = pci_get_drvdata(pdev);
> > + if (!cxlds)
> > + goto out;
>
> Lets not mix usage of cleanup.h helpers with usage of goto. The helpers
> are there to eliminate goto errors. Just add a new helper:
>
> DEFINE_FREE(pci_dev_put, struct pci_dev *, if (_T) pci_dev_put(_T))
>
> ...and declare @pdev as:
>
> struct pci_dev *pdev __free(pci_dev_put) = NULL;
>
Even better idea. Done.
Thanks,
Ira
prev parent reply other threads:[~2023-12-13 0:17 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-11 22:57 [PATCH v2 0/7] efi/cxl-cper: Report CPER CXL component events through trace events Ira Weiny
2023-12-11 22:57 ` [PATCH v2 1/7] cxl/trace: Pass uuid explicitly to event traces Ira Weiny
2023-12-11 22:57 ` [PATCH v2 2/7] cxl/events: Promote CXL event structures to a core header Ira Weiny
2023-12-11 22:57 ` [PATCH v2 3/7] cxl/events: Create common event UUID defines Ira Weiny
2023-12-11 22:57 ` [PATCH v2 4/7] cxl/events: Separate UUID from event structures Ira Weiny
2023-12-11 22:57 ` [PATCH v2 5/7] cxl/events: Create a CXL event union Ira Weiny
2023-12-11 22:57 ` [PATCH v2 6/7] firmware/efi: Process CXL Component Events Ira Weiny
2023-12-12 9:52 ` Ard Biesheuvel
2023-12-12 17:00 ` Dan Williams
2023-12-12 20:50 ` Ira Weiny
2023-12-11 22:57 ` [PATCH v2 7/7] cxl/memdev: Register for and process CPER events Ira Weiny
2023-12-12 17:24 ` Dan Williams
2023-12-13 0:17 ` Ira Weiny [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=6578f7fc4e04a_22539529429@iweiny-mobl.notmuch \
--to=ira.weiny@intel.com \
--cc=Smita.KoralahalliChannabasappa@amd.com \
--cc=alison.schofield@intel.com \
--cc=ardb@kernel.org \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=dave@stgolabs.net \
--cc=jonathan.cameron@huawei.com \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-efi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=shiju.jose@huawei.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).