lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 23 Nov 2020 11:20:29 -0800
From:   Ben Widawsky <ben.widawsky@...el.com>
To:     Bjorn Helgaas <helgaas@...nel.org>
Cc:     Dan Williams <dan.j.williams@...el.com>, linux-cxl@...r.kernel.org,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        Linux PCI <linux-pci@...r.kernel.org>,
        Linux ACPI <linux-acpi@...r.kernel.org>,
        Ira Weiny <ira.weiny@...el.com>,
        Vishal Verma <vishal.l.verma@...el.com>,
        "Kelley, Sean V" <sean.v.kelley@...el.com>,
        Bjorn Helgaas <bhelgaas@...gle.com>,
        "Rafael J . Wysocki" <rafael.j.wysocki@...el.com>
Subject: Re: [RFC PATCH 4/9] cxl/mem: Map memory device registers

On 20-11-16 18:23:21, Bjorn Helgaas wrote:
> On Mon, Nov 16, 2020 at 03:19:41PM -0800, Dan Williams wrote:
> > On Fri, Nov 13, 2020 at 5:12 PM Ben Widawsky <ben.widawsky@...el.com> wrote:
> > > On 20-11-13 12:17:32, Bjorn Helgaas wrote:
> > > > On Tue, Nov 10, 2020 at 09:43:51PM -0800, Ben Widawsky wrote:
> 
> > > > >  static int cxl_mem_probe(struct pci_dev *pdev, const struct pci_device_id *id)
> > > > >  {
> > > > > +   struct cxl_mem *cxlm = ERR_PTR(-ENXIO);
> > > > >     struct device *dev = &pdev->dev;
> > > > > -   struct cxl_mem *cxlm;
> > > >
> > > > The order was better before ("dev", then "clxm").  Oh, I suppose this
> > > > is a "reverse Christmas tree" thing.
> > > >
> > >
> > > I don't actually care either way as long as it's consistent. I tend to do
> > > reverse Christmas tree for no particular reason.
> > 
> > Yeah, reverse Christmas tree for no particular reason.
> 
> FWIW, the usual drivers/pci style is to order the decls in the order
> the variables are used in the code.  But this isn't drivers/pci, so
> it's up to you.  I only noticed because changing the order made the
> diff bigger than it needed to be.
> 
> > > > I think this would be easier to read if cxl_mem_create() returned NULL
> > > > on failure (it prints error messages and we throw away
> > > > -ENXIO/-ENOMEM distinction here anyway) so you could do:
> > > >
> > > >   struct cxl_mem *cxlm = NULL;
> > > >
> > > >   for (...) {
> > > >     if (...) {
> > > >       cxlm = cxl_mem_create(pdev, reg_lo, reg_hi);
> > > >       break;
> > > >     }
> > > >   }
> > > >
> > > >   if (!cxlm)
> > > >     return -ENXIO;  /* -ENODEV might be more natural? */
> > > >
> > >
> > > I agree on both counts. Both of these came from Dan, so I will let him explain.
> > 
> > I'm not attached to differentiating -ENOMEM from -ENXIO and am ok to
> > drop the ERR_PTR() return. I do tend to use -ENXIO for failure to
> > perform an initialization action vs failure to even find the device,
> > but if -ENODEV seems more idiomatic to Bjorn, I won't argue.
> 
> -ENXIO is fine with me.  I just don't see it as often so I don't
> really know what it is.
> 
> Bjorn

Dan, Bjorn, I did a fairly randomized look at various probe functions and ENODEV
seems to be more common. My sort of historical use has been
- ENODEV: General, couldn't establish device presence
- ENXIO: Device was there but something is totally misconfigured
- E*: A matching errno for exactly what went wrong

My question though is, would it be useful to propagate the error up through
probe?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ