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] [day] [month] [year] [list]
Date:   Tue, 14 Sep 2021 22:41:47 -0700
From:   Saravana Kannan <saravanak@...gle.com>
To:     Geert Uytterhoeven <geert@...ux-m68k.org>
Cc:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        "Rafael J. Wysocki" <rafael@...nel.org>,
        John Stultz <john.stultz@...aro.org>,
        Marek Szyprowski <m.szyprowski@...sung.com>,
        Rob Herring <robh+dt@...nel.org>, Andrew Lunn <andrew@...n.ch>,
        Vladimir Oltean <olteanv@...il.com>,
        Android Kernel Team <kernel-team@...roid.com>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v1 2/5] driver core: Set deferred probe reason when
 deferred by driver core

On Tue, Sep 14, 2021 at 12:58 AM Saravana Kannan <saravanak@...gle.com> wrote:
>
> On Tue, Sep 14, 2021 at 12:01 AM Geert Uytterhoeven
> <geert@...ux-m68k.org> wrote:
> >
> > Hi Saravana,
> >
> > On Tue, Sep 14, 2021 at 6:39 AM Saravana Kannan <saravanak@...gle.com> wrote:
> > > When the driver core defers the probe of a device, set the deferred
> > > probe reason so that it's easier to debug. The deferred probe reason is
> > > available in debugfs under devices_deferred.
> > >
> > > Signed-off-by: Saravana Kannan <saravanak@...gle.com>
> >
> > Thanks for your patch!
>
> Thanks for the reviews!
>
> >
> > > --- a/drivers/base/core.c
> > > +++ b/drivers/base/core.c
> > > @@ -955,6 +955,29 @@ static void device_links_missing_supplier(struct device *dev)
> > >         }
> > >  }
> > >
> > > +/**
> > > + * dev_set_def_probe_reason - Set the deferred probe reason for a device
> > > + * @dev: the pointer to the struct device
> > > + * @fmt: printf-style format string
> > > + * @...: arguments as specified in the format string
> > > + *
> > > + * This is a more caller-friendly version of device_set_deferred_probe_reason()
> > > + * that takes variable argument inputs similar to dev_info().
> > > + */
> > > +static void dev_set_def_probe_reason(const struct device *dev, const char *fmt, ...)
> >
> > So this is indeed similar to device_set_deferred_probe_reason(),
> > but the function's name is completely different, unlike e.g.
> > (v)printf()?
>
> Yes.
>
> >
> > > +{
> > > +       struct va_format vaf;
> > > +       va_list args;
> > > +
> > > +       va_start(args, fmt);
> > > +       vaf.fmt = fmt;
> > > +       vaf.va = &args;
> > > +
> > > +       device_set_deferred_probe_reason(dev, &vaf);
> > > +
> > > +       va_end(args);
> > > +}
> >
> > I think you can just make this a macro wrapper calling
> > dev_err_probe(dev, -EPROBE_DEFER, fmt, ...).
> > Or open-code that below.
>
> Good point. I think I can make it be a wrapper macro.
>
> >
> > > +
> > >  /**
> > >   * device_links_check_suppliers - Check presence of supplier drivers.
> > >   * @dev: Consumer device.
> > > @@ -975,6 +998,7 @@ int device_links_check_suppliers(struct device *dev)
> > >  {
> > >         struct device_link *link;
> > >         int ret = 0;
> > > +       struct fwnode_handle *sup_fw;
> > >
> > >         /*
> > >          * Device waiting for supplier to become available is not allowed to
> > > @@ -983,10 +1007,13 @@ int device_links_check_suppliers(struct device *dev)
> > >         mutex_lock(&fwnode_link_lock);
> > >         if (dev->fwnode && !list_empty(&dev->fwnode->suppliers) &&
> > >             !fw_devlink_is_permissive()) {
> > > +               sup_fw = list_first_entry(&dev->fwnode->suppliers,
> > > +                                         struct fwnode_link,
> > > +                                         c_hook)->supplier;
> > >                 dev_dbg(dev, "probe deferral - wait for supplier %pfwP\n",
> > > -                       list_first_entry(&dev->fwnode->suppliers,
> > > -                       struct fwnode_link,
> > > -                       c_hook)->supplier);
> > > +                       sup_fw);
> > > +               dev_set_def_probe_reason(dev,
> > > +                       "wait for supplier %pfwP\n", sup_fw);
> >
> > dev_err_probe() would replace both the dev_dbg() and the
> > dev_set_def_probe_reason().
>
> I intentionally didn't use dev_err_probe() because:
>
> 1. I wanted the messages to be a bit different -- not have the "probe
> deferral" in the deferred_devices file but have it in the dmesg logs
> so that the log is clearer.

Nevermind, I see that dev_err_probe() prints the log with
-EPROBE_DEFER but sets the reason without that string. Which is kinda
similar to what I'm trying to do here. So I'll go with that
suggestion.

> 2. And more importantly, I'm working on a patch (could take a few
> weeks) that'll make this place return -EPROBE_DEFER vs -ENODEV (or
> whatever) for different situations. And using dev_err_probe() with
> -ENODEV would cause it to print the error (when I don't want it to).
> And always doing dev_err_probe(dev, -EPROBE_DEFER,...) while returning
> -ENODEV would be confusing.

I'll deal with this when I send out that patch.

Thanks for the review.

-Saravana

>
> >
> > >                 mutex_unlock(&fwnode_link_lock);
> > >                 return -EPROBE_DEFER;
> > >         }
> > > @@ -1003,6 +1030,9 @@ int device_links_check_suppliers(struct device *dev)
> > >                         device_links_missing_supplier(dev);
> > >                         dev_dbg(dev, "probe deferral - supplier %s not ready\n",
> > >                                 dev_name(link->supplier));
> > > +                       dev_set_def_probe_reason(dev,
> > > +                               "supplier %s not ready\n",
> > > +                               dev_name(link->supplier));
> >
> > Likewise.
>
> Same reason as above.
>
> I mainly added you for comments on 5/5. Hopefully you'll have some
> comments on that too by the time I'm up tomorrow :)
>
> -Saravana
>
> >
> > >                         ret = -EPROBE_DEFER;
> > >                         break;
> > >                 }
> >
> > Gr{oetje,eeting}s,
> >
> >                         Geert
> >
> > --
> > Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-m68k.org
> >
> > In personal conversations with technical people, I call myself a hacker. But
> > when I'm talking to journalists I just say "programmer" or something like that.
> >                                 -- Linus Torvalds

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ