[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210414102443.000071a7@Huawei.com>
Date: Wed, 14 Apr 2021 10:24:43 +0100
From: Jonathan Cameron <Jonathan.Cameron@...wei.com>
To: Ben Widawsky <ben.widawsky@...el.com>
CC: <linux-cxl@...r.kernel.org>, <linux-pci@...r.kernel.org>,
<linux-acpi@...r.kernel.org>, <ira.weiny@...el.com>,
<vishal.l.verma@...el.com>, <alison.schofield@...el.com>,
<dan.j.williams@...el.com>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 4/7] cxl/mem: Get rid of @cxlm.base
On Tue, 13 Apr 2021 09:17:26 -0700
Ben Widawsky <ben.widawsky@...el.com> wrote:
> On 21-04-08 18:26:35, Jonathan Cameron wrote:
> > On Wed, 7 Apr 2021 15:26:22 -0700
> > Ben Widawsky <ben.widawsky@...el.com> wrote:
> >
> > > @cxlm.base only existed to support holding the base found in the
> > > register block mapping code, and pass it along to the register setup
> > > code. Now that the register setup function has all logic around managing
> > > the registers, from DVSEC to iomapping up to populating our CXL specific
> > > information, it is easy to turn the @base values into local variables
> > > and remove them from our device driver state.
> > >
> > > Signed-off-by: Ben Widawsky <ben.widawsky@...el.com>
> >
> > Patch is basically fine, but I do wonder if you could avoid the
> > nasty casting in and out of __iomem in the error paths.
> >
> > It's a common enough idiom though so I'm not htat fussed.
> >
> > Acked-by: Jonathan Cameron <Jonathan.Cameron@...wei.com>
> >
> > > ---
> > > drivers/cxl/mem.c | 24 +++++++++++-------------
> > > drivers/cxl/mem.h | 2 --
> > > 2 files changed, 11 insertions(+), 15 deletions(-)
> > >
> > > diff --git a/drivers/cxl/mem.c b/drivers/cxl/mem.c
> > > index 04b4f7445083..60b95c524c3e 100644
> > > --- a/drivers/cxl/mem.c
> > > +++ b/drivers/cxl/mem.c
> > > @@ -922,11 +922,10 @@ static struct cxl_mem *cxl_mem_create(struct pci_dev *pdev)
> > > return cxlm;
> > > }
> > >
> > > -static int cxl_mem_map_regblock(struct cxl_mem *cxlm, u32 reg_lo, u32 reg_hi)
> > > +static void __iomem *cxl_mem_map_regblock(struct cxl_mem *cxlm, u32 reg_lo, u32 reg_hi)
> > > {
> > > struct pci_dev *pdev = cxlm->pdev;
> > > struct device *dev = &pdev->dev;
> > > - void __iomem *regs;
> > > u64 offset;
> > > u8 bar;
> > > int rc;
> > > @@ -938,20 +937,18 @@ static int cxl_mem_map_regblock(struct cxl_mem *cxlm, u32 reg_lo, u32 reg_hi)
> > > if (pci_resource_len(pdev, bar) < offset) {
> > > dev_err(dev, "BAR%d: %pr: too small (offset: %#llx)\n", bar,
> > > &pdev->resource[bar], (unsigned long long)offset);
> > > - return -ENXIO;
> > > + return (void __iomem *)ERR_PTR(-ENXIO);
> > > }
> > >
> > > rc = pcim_iomap_regions(pdev, BIT(bar), pci_name(pdev));
> > > if (rc) {
> > > dev_err(dev, "failed to map registers\n");
> > > - return rc;
> > > + return (void __iomem *)ERR_PTR(rc);
> >
> > The casting is fairly horrible, perhaps just pass in
> > a void __iomem ** and pass base back through that?
> >
>
> TIL: IOMEM_ERR_PTR. Would that suffice?
Definitely. Didn't know about that!
Jonathan
Powered by blists - more mailing lists