Re: [RFC PATCH] spi: Take the SPI IO-mutex in the spi_setup() method

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Nov 17, 2020 at 11:45 AM Serge Semin
<Sergey.Semin@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> I've discovered that due to the recent commit 49d7d695ca4b ("spi: dw:
> Explicitly de-assert CS on SPI transfer completion") a concurrent usage of
> the spidev devices with different chip-selects causes the "SPI transfer
> timed out" error.

I'll read this later...

> +       mutex_lock(&spi->controller->io_mutex);
> +
>         if (spi->controller->setup)
>                 status = spi->controller->setup(spi);
>
>         if (spi->controller->auto_runtime_pm && spi->controller->set_cs) {
>                 status = pm_runtime_get_sync(spi->controller->dev.parent);

I didn't check what this lock is protecting, but have you checked all
PM runtime callbacks if they are not taking the lock. When you call PM
runtime functions with 'sync' it may include a lot of work, some of
which may sleep (not a problem for mutex) and may take arbitrary locks
(might be a deadlock in case of trying the same lock).

>                 if (status < 0) {
> +                       mutex_unlock(&spi->controller->io_mutex);
>                         pm_runtime_put_noidle(spi->controller->dev.parent);
>                         dev_err(&spi->controller->dev, "Failed to power device: %d\n",
>                                 status);
> @@ -3354,6 +3357,8 @@ int spi_setup(struct spi_device *spi)
>                 spi_set_cs(spi, false);
>         }
>
> +       mutex_unlock(&spi->controller->io_mutex);
> +


-- 
With Best Regards,
Andy Shevchenko



[Index of Archives]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux