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]
Message-ID: <92d95675-5d4a-4bc1-b2a2-8f2f1668a640@broadcom.com>
Date: Wed, 2 Apr 2025 09:04:14 -0700
From: Florian Fainelli <florian.fainelli@...adcom.com>
To: Bartosz Golaszewski <brgl@...ev.pl>
Cc: linux-kernel@...r.kernel.org, Mark Brown <broonie@...nel.org>,
 Ray Jui <rjui@...adcom.com>, Scott Branden <sbranden@...adcom.com>,
 Broadcom internal kernel review list
 <bcm-kernel-feedback-list@...adcom.com>,
 Linus Walleij <linus.walleij@...aro.org>,
 Bartosz Golaszewski <bartosz.golaszewski@...aro.org>,
 "open list:SPI SUBSYSTEM" <linux-spi@...r.kernel.org>,
 "moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE"
 <linux-rpi-kernel@...ts.infradead.org>,
 "moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE"
 <linux-arm-kernel@...ts.infradead.org>
Subject: Re: [PATCH] spi: bcm2835: Restore native CS probing when
 pinctrl-bcm2835 is absent

On 4/2/25 04:44, Bartosz Golaszewski wrote:
> On Wed, Apr 2, 2025 at 1:37 AM Florian Fainelli
> <florian.fainelli@...adcom.com> wrote:
>>
>> The lookup table forces the use of the "pinctrl-bcm2835" GPIO chip
>> provider and essentially assumes that there is going to be such a
>> provider, and if not, we will fail to set-up the SPI device.
>>
> 
> Yeah, the consumer driver itself is an unfortunate place to define the
> provider data. This could potentially be moved to gpiolib-of.c quirks.
> 
>> While this is true on Raspberry Pi based systems (2835/36/37, 2711,
>> 2712), this is not true on 7712/77122 Broadcom STB systems which use the
>> SPI driver, but not the GPIO driver.
>>
>> There used to be an early check:
>>
>>         chip = gpiochip_find("pinctrl-bcm2835", chip_match_name);
>>         if (!chip)
>>                 return 0;
>>
>> which would accomplish that nicely, bring something similar back by
>> checking for the compatible strings matched by the pinctrl-bcm2835.c
>> driver, if there is no Device Tree node matching those compatible
>> strings, then we won't find any GPIO provider registered by the
>> "pinctrl-bcm2835" driver.
>>
>> Fixes: 21f252cd29f0 ("spi: bcm2835: reduce the abuse of the GPIO API")
>> Signed-off-by: Florian Fainelli <florian.fainelli@...adcom.com>
>> ---
>>   drivers/spi/spi-bcm2835.c | 15 ++++++++++++++-
>>   1 file changed, 14 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/spi/spi-bcm2835.c b/drivers/spi/spi-bcm2835.c
>> index a5d621b94d5e..5926e004d9a6 100644
>> --- a/drivers/spi/spi-bcm2835.c
>> +++ b/drivers/spi/spi-bcm2835.c
>> @@ -1226,7 +1226,12 @@ static int bcm2835_spi_setup(struct spi_device *spi)
>>          struct bcm2835_spi *bs = spi_controller_get_devdata(ctlr);
>>          struct bcm2835_spidev *target = spi_get_ctldata(spi);
>>          struct gpiod_lookup_table *lookup __free(kfree) = NULL;
>> -       int ret;
>> +       const char *pinctrl_compats[] = {
>> +               "brcm,bcm2835-gpio",
>> +               "brcm,bcm2711-gpio",
>> +               "brcm,bcm7211-gpio",
>> +       };
>> +       int ret, i;
>>          u32 cs;
>>
>>          if (!target) {
>> @@ -1291,6 +1296,14 @@ static int bcm2835_spi_setup(struct spi_device *spi)
>>                  goto err_cleanup;
>>          }
>>
>> +       for (i = 0; i < ARRAY_SIZE(pinctrl_compats); i++) {
>> +               if (of_find_compatible_node(NULL, NULL, pinctrl_compats[i]))
>> +                       break;
>> +       }
>> +
>> +       if (i == ARRAY_SIZE(pinctrl_compats))
>> +               return 0;
>> +
>>          /*
>>           * TODO: The code below is a slightly better alternative to the utter
>>           * abuse of the GPIO API that I found here before. It creates a
>> --
>> 2.34.1
>>
>>
> 
> The fix is good for now but I'd still try to move this out of the
> driver at some point.
> 
> Acked-by: Bartosz Golaszewski <bartosz.golaszewski@...aro.org>

Thanks, I will see what I can do on that front, but if you don't hear 
from me in the next few weeks, don't hesitate to ask again :)
-- 
Florian

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ