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:   Wed, 12 May 2021 11:16:43 +0800
From:   Xin Hao <xhao@...ux.alibaba.com>
To:     Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
        Mark Brown <broonie@...nel.org>, linux-spi@...r.kernel.org,
        linux-kernel@...r.kernel.org
Cc:     Liguang Zhang <zhangliguang@...ux.alibaba.com>,
        Jay Fang <f.fangjian@...wei.com>,
        Sven Van Asbroeck <thesven73@...il.com>
Subject: Re: [PATCH v2 1/1] spi: Assume GPIO CS active high in ACPI case


在 2021/5/11 下午10:09, Andy Shevchenko 写道:
> Currently GPIO CS handling, when descriptors are in use, doesn't
> take into consideration that in ACPI case the default polarity
> is Active High and can't be altered. Instead we have to use the
> per-chip definition provided by SPISerialBus() resource.
>
> Fixes: 766c6b63aa04 ("spi: fix client driver breakages when using GPIO descriptors")
> Cc: Liguang Zhang <zhangliguang@...ux.alibaba.com>
> Cc: Jay Fang <f.fangjian@...wei.com>
> Cc: Sven Van Asbroeck <thesven73@...il.com>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
> Tested-by: Xin Hao <xhao@...ux.alibaba.com>
> ---
> v2: refactor to avoid ternary (Mark, Sven), dropped comment changes (Mark)
>   drivers/spi/spi.c | 22 ++++++++++++++++++----
>   1 file changed, 18 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
> index cd40421b8f55..36ee33514b40 100644
> --- a/drivers/spi/spi.c
> +++ b/drivers/spi/spi.c
> @@ -820,15 +820,29 @@ static void spi_set_cs(struct spi_device *spi, bool enable, bool force)
>   
>   	if (spi->cs_gpiod || gpio_is_valid(spi->cs_gpio)) {
>   		if (!(spi->mode & SPI_NO_CS)) {
> -			if (spi->cs_gpiod)
> -				/* polarity handled by gpiolib */
> -				gpiod_set_value_cansleep(spi->cs_gpiod, activate);
> -			else
> +			if (spi->cs_gpiod) {
> +				/*
> +				 * Historically ACPI has no means of the GPIO polarity and
> +				 * thus the SPISerialBus() resource defines it on the per-chip
> +				 * basis. In order to avoid a chain of negations, the GPIO
> +				 * polarity is considered being Active High. Even for the cases
> +				 * when _DSD() is involved (in the updated versions of ACPI)
> +				 * the GPIO CS polarity must be defined Active High to avoid
> +				 * ambiguity. That's why we use enable, that takes SPI_CS_HIGH
> +				 * into account.
> +				 */
> +				if (has_acpi_companion(&spi->dev))
> +					gpiod_set_value_cansleep(spi->cs_gpiod, !enable);

it worked and code changed minimally,  before ACPI & OF keeps no same 
rules,  this patch is ok!

> +				else
> +					/* Polarity handled by GPIO library */
> +					gpiod_set_value_cansleep(spi->cs_gpiod, activate);
> +			} else {
>   				/*
>   				 * invert the enable line, as active low is
>   				 * default for SPI.
>   				 */
>   				gpio_set_value_cansleep(spi->cs_gpio, !enable);
> +			}
>   		}
>   		/* Some SPI masters need both GPIO CS & slave_select */
>   		if ((spi->controller->flags & SPI_MASTER_GPIO_SS) &&

-- 
Best Regards!
Xin Hao

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ