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]
Message-ID: <CAMhs-H_Ne4W79Awbmo6w_68X+h0-ybjvzNsbh=XuHMPJJ8-hDQ@mail.gmail.com>
Date:   Fri, 2 Jul 2021 11:40:20 +0200
From:   Sergio Paracuellos <sergio.paracuellos@...il.com>
To:     Andy Shevchenko <andy.shevchenko@...il.com>
Cc:     "open list:GPIO SUBSYSTEM" <linux-gpio@...r.kernel.org>,
        Bartosz Golaszewski <bgolaszewski@...libre.com>,
        Matthias Brugger <matthias.bgg@...il.com>,
        Linus Walleij <linus.walleij@...aro.org>,
        John Thomson <git@...nthomson.fastmail.com.au>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        NeilBrown <neil@...wn.name>,
        René van Dorst <opensource@...rst.com>,
        Nicholas Mc Guire <hofrat@...dl.org>
Subject: Re: [PATCH v2] gpio: mt7621: support gpio-line-names property

Hi Andy,

On Fri, Jul 2, 2021 at 11:27 AM Andy Shevchenko
<andy.shevchenko@...il.com> wrote:
>
> On Sun, Jun 27, 2021 at 4:13 PM Sergio Paracuellos
> <sergio.paracuellos@...il.com> wrote:
> > On Sun, Jun 27, 2021 at 3:01 PM Andy Shevchenko
> > <andy.shevchenko@...il.com> wrote:
> > > On Sun, Jun 27, 2021 at 1:56 PM Sergio Paracuellos
> > > <sergio.paracuellos@...il.com> wrote:
> > > > On Sun, Jun 27, 2021 at 12:51 PM Andy Shevchenko
> > > > <andy.shevchenko@...il.com> wrote:
> > > > > On Sun, Jun 27, 2021 at 12:47 PM Sergio Paracuellos
> > > > > <sergio.paracuellos@...il.com> wrote:
> > > > > > On Sun, Jun 27, 2021 at 11:33 AM Andy Shevchenko
> > > > > > <andy.shevchenko@...il.com> wrote:
> > > > > > > On Sat, Jun 26, 2021 at 7:18 PM Sergio Paracuellos
> > > > > > > <sergio.paracuellos@...il.com> wrote:
> > > > > > > >
> > > > > > > > The default handling of the gpio-line-names property by the
> > > > > > > > gpiolib-of implementation does not work with the multiple
> > > > > > > > gpiochip banks per device structure used by the gpio-mt7621
> > > > > > > > driver.
> > > > > > > >
> > > > > > > > This commit adds driver level support for the device tree
> > > > > > > > property so that GPIO lines can be assigned friendly names.
> > > > >
> > > > > > > > This driver has three gpiochips with 32 gpios each. Core implementation
> > > > > > >
> > > > > > > implementation
> > > > > > >
> > > > > > >
> > > > > > > > got gpio's repeated along each gpio chip if chip.names is not assigned.
> > > > > > > > To avoid this behaviour driver will set this names as empty or
> > > > > > >
> > > > > > > the driver
> > > > > > > these names
> > > > > > >
> > > > > > > > with desired friendly line names. Consider the following sample with
> > > > > > > > minimal entries for the first chip with this patch changes applied:
> > > > > > >
> > > > > > > The same comment as per v1:
> > > > > > >
> > > > > > > Any idea why it's not a duplicate of
> > > > > > > https://elixir.bootlin.com/linux/v5.13-rc7/C/ident/devprop_gpiochip_set_names,
> > > > > > > and why the latter is not called in your case?
> > > > > >
> > > > > > The core properly calls this function but not in the way expected.
> > > > > > This driver implements three banks of 32 gpios each internally using
> > > > > > one gpiochip per bank, all of them in the same device. So the core
> > > > > > code you are pointing out here duplicates the same names along the
> > > > > > three gpiochips which is not the expected behaviour. So implementing
> > > > > > in this way and setting names at least reserved avoids the core code
> > > > > > to be run and also avoids the duplication getting expected behaviour
> > > > > > for all the banks and each line friendly name.
> > > > >
> > > > > Isn't it the problem of how we supply fwnode in that case?
> > > > > Another possibility is to fix DT (although I'm not sure it's now possible).
> > > >
> > > > Since the fwnode is the same for all banks of the same device, each bank
> > > > repeats the first MTK_BANK_WIDTH label names in each bank.
> > >
> > > Can you point out the DT in question?
> >
> > https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git/tree/drivers/staging/mt7621-dts/mt7621.dtsi?h=staging-next
> >
> > Gpio node:
> >
> >  gpio: gpio@600 {
> >               #gpio-cells = <2>;
> >               #interrupt-cells = <2>;
> >               compatible = "mediatek,mt7621-gpio";
> >               gpio-controller;
> >               gpio-ranges = <&pinctrl 0 0 95>;
> >               interrupt-controller;
> >               reg = <0x600 0x100>;
> >               interrupt-parent = <&gic>;
> >               interrupts = <GIC_SHARED 12 IRQ_TYPE_LEVEL_HIGH>;
> >    };
> >
> > My overlay:
> >
> > &gpio {
> >     gpio-line-names = "", "", "", "",
> >                       "", "", "SFP LOS", "extcon port5 PoE compat",
> >                       "SFP module def0", "LED blue SFP", "SFP tx disable", "",
> >                       "switch USB power", "mode", "", "buzzer",
> >                       "LED blue pwr", "switch port5 PoE out", "reset";
> > };
> >
> >
> >
> > >
> > > > This commit populates the gc.names member of each bank from the
> > > > device-tree node within the driver. This overrides the default behavior
> > > > since devprop_gpiochip_set_names() will only be called if names is NULL.
> > >
> > > I believe this commit is not needed in the proposed (i.e. duplication) shape.
> > > The fwnode supports primary and secondary ones. Thus, we may create a
> > > pair of fwnodes when they will unify properties per device with
> > > properties per child together (child is primary and device, i.e.
> > > parent, is secondary).
> >
> > There are no child nodes, all the stuff is in the same parent node
> > and, as I said, belongs to the same device but internally uses three
> > gpiochips.
>
> And it can't be split into three children in the overlay?

Original code before this being mainlined was using three children and
I was told in the review that three children were not allowed:

See https://patchwork.ozlabs.org/project/linux-gpio/patch/1527924610-13135-3-git-send-email-sergio.paracuellos@gmail.com/#1932827

> Let's assume it can't, then the GPIO library function should be
> refactored in a way that it takes parameters like base index for the
> names and tries to satisfy the caller.

Bartosz, Linus, any thoughts on this?

>
> > This case is pretty much the same as the following already
> > added commit for gpio-brcmstb:
> >
> > https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git/commit/drivers/gpio/gpio-brcmstb.c?id=5eefcaed501dd9e3933dbff58720244bd75ed90f
>
> This should be fixed accordingly.

Obviously, the treatment should be the same, yes :)

Best regards,
    Sergio Paracuellos
>
> --
> With Best Regards,
> Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ