[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YshC+Jaua01dPQak@iweiny-desk3>
Date: Fri, 8 Jul 2022 07:45:12 -0700
From: Ira Weiny <ira.weiny@...el.com>
To: Bjorn Helgaas <helgaas@...nel.org>
CC: Dan Williams <dan.j.williams@...el.com>,
Matthew Wilcox <willy@...radead.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
"Rafael J. Wysocki" <rafael@...nel.org>,
Alison Schofield <alison.schofield@...el.com>,
Vishal Verma <vishal.l.verma@...el.com>,
<linux-kernel@...r.kernel.org>, <linux-cxl@...r.kernel.org>,
<linux-pci@...r.kernel.org>, <linux-fsdevel@...r.kernel.org>
Subject: Re: [RFC PATCH 2/3] pci/doe: Use devm_xa_init()
On Thu, Jul 07, 2022 at 11:06:46AM -0500, Bjorn Helgaas wrote:
> On Tue, Jul 05, 2022 at 04:21:58PM -0700, ira.weiny@...el.com wrote:
> > From: Ira Weiny <ira.weiny@...el.com>
> >
> > The XArray being used to store the protocols does not even store
> > allocated objects.
>
> I guess the point is that the doe_mb->prots XArray doesn't reference
> any other objects that would need to be freed when destroying
> doe_mb->prots?
Yes.
> A few more words here would make the commit log more
> useful to non-XArray experts.
I'll update this to be more clear in a V1 if it goes that far. But to clarify
here; the protocol information is a u16 vendor id and u8 protocol number. So
we are able to store that in the unsigned long value that would normally be a
pointer to something in the XArray.
>
> s|pci/doe|PCI/DOE| in subject to match the drivers/pci convention.
Yes. Sorry,
Thanks for the review,
Ira
>
> > Use devm_xa_init() to automatically destroy the XArray when the PCI
> > device goes away.
> >
> > Signed-off-by: Ira Weiny <ira.weiny@...el.com>
> > ---
> > drivers/pci/doe.c | 14 ++------------
> > 1 file changed, 2 insertions(+), 12 deletions(-)
> >
> > diff --git a/drivers/pci/doe.c b/drivers/pci/doe.c
> > index 0b02f33ef994..aa36f459d375 100644
> > --- a/drivers/pci/doe.c
> > +++ b/drivers/pci/doe.c
> > @@ -386,13 +386,6 @@ static int pci_doe_cache_protocols(struct pci_doe_mb *doe_mb)
> > return 0;
> > }
> >
> > -static void pci_doe_xa_destroy(void *mb)
> > -{
> > - struct pci_doe_mb *doe_mb = mb;
> > -
> > - xa_destroy(&doe_mb->prots);
> > -}
> > -
> > static void pci_doe_destroy_workqueue(void *mb)
> > {
> > struct pci_doe_mb *doe_mb = mb;
> > @@ -440,11 +433,8 @@ struct pci_doe_mb *pcim_doe_create_mb(struct pci_dev *pdev, u16 cap_offset)
> > doe_mb->pdev = pdev;
> > doe_mb->cap_offset = cap_offset;
> > init_waitqueue_head(&doe_mb->wq);
> > -
> > - xa_init(&doe_mb->prots);
> > - rc = devm_add_action(dev, pci_doe_xa_destroy, doe_mb);
> > - if (rc)
> > - return ERR_PTR(rc);
> > + if (devm_xa_init(dev, &doe_mb->prots))
> > + return ERR_PTR(-ENOMEM);
> >
> > doe_mb->work_queue = alloc_ordered_workqueue("DOE: [%x]", 0,
> > doe_mb->cap_offset);
> > --
> > 2.35.3
> >
Powered by blists - more mailing lists