Re: [PATCH v3 10/11] spi: Ensure the io_mutex is held until spi_finalize_current_message()

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

 



On Tue, Jun 21, 2022 at 8:16 AM David Jander <david@xxxxxxxxxxx> wrote:
>
> This patch introduces a completion that is completed in
> spi_finalize_current_message() and waited for in
> __spi_pump_transfer_message(). This way all manipulation of ctlr->cur_msg
> is done with the io_mutex held and strictly ordered:
> __spi_pump_transfer_message() will not return until
> spi_finalize_current_message() is done using ctlr->cur_msg, and its
> calling context is only touching ctlr->cur_msg after returning.
> Due to this, we can safely drop the spin-locks around ctlr->cur_msg.

...

> +       reinit_completion(&ctlr->cur_msg_completion);
>         ret = ctlr->transfer_one_message(ctlr, msg);
>         if (ret) {
>                 dev_err(&ctlr->dev,
>                         "failed to transfer one message from queue\n");
>                 return ret;
> +       } else {

Redundant.

if (ret) {
 ...
 return ...;
}

...do other stuff...

> +               wait_for_completion(&ctlr->cur_msg_completion);
>         }

...

>         ret = __spi_pump_transfer_message(ctlr, msg, was_busy);
> +

No need to add a blank line here.

> +       if (!ret)
> +               kthread_queue_work(ctlr->kworker, &ctlr->pump_messages);

> +       ctlr->cur_msg = NULL;
> +       ctlr->fallback = false;

Does ->pump_messages() use any of these two?

>         mutex_unlock(&ctlr->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