linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* PCI: endpoint: Usage of atomic notifier chain
@ 2022-02-25 18:23 Manivannan Sadhasivam
  2022-02-25 18:26 ` Dmitry Baryshkov
  0 siblings, 1 reply; 2+ messages in thread
From: Manivannan Sadhasivam @ 2022-02-25 18:23 UTC (permalink / raw)
  To: kishon, lorenzo.pieralisi
  Cc: omp, vidyas, linux-pci, linux-kernel, bjorn.andersson, dmitry.baryshkov

Hi,

While working with the PCI endpoint subsystem, I stumbled upon the sleeping
in atomic context bug during CORE_INIT phase. The issue seems to be due to the
usage of "epc lock" (mutex) in functions such as set_msi, set_msix,
write_header, etc...

These functions are supposed to be used in the atomic notifier chain by the
CORE_INIT notifier. While using the lock is necessary in these functions as
pci_epc_create() would've been called, I see two possible workarounds:

1. Using non-atomic notifier chains such as blocking or raw.
2. Modifying the EPF drivers to use workqueue in CORE_INIT notifier chain. But
this has the implication of missing the workqueue execution before hitting other
PCI events as there might be a delay in scheduling the work item.

I prefer 1st option but I'd like to hear other ideas also.

Thanks,
Mani

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: PCI: endpoint: Usage of atomic notifier chain
  2022-02-25 18:23 PCI: endpoint: Usage of atomic notifier chain Manivannan Sadhasivam
@ 2022-02-25 18:26 ` Dmitry Baryshkov
  0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Baryshkov @ 2022-02-25 18:26 UTC (permalink / raw)
  To: Manivannan Sadhasivam
  Cc: kishon, lorenzo.pieralisi, omp, vidyas, linux-pci, linux-kernel,
	bjorn.andersson

On Fri, 25 Feb 2022 at 21:23, Manivannan Sadhasivam
<manivannan.sadhasivam@linaro.org> wrote:
>
> Hi,
>
> While working with the PCI endpoint subsystem, I stumbled upon the sleeping
> in atomic context bug during CORE_INIT phase. The issue seems to be due to the
> usage of "epc lock" (mutex) in functions such as set_msi, set_msix,
> write_header, etc...
>
> These functions are supposed to be used in the atomic notifier chain by the
> CORE_INIT notifier. While using the lock is necessary in these functions as
> pci_epc_create() would've been called, I see two possible workarounds:
>
> 1. Using non-atomic notifier chains such as blocking or raw.
> 2. Modifying the EPF drivers to use workqueue in CORE_INIT notifier chain. But
> this has the implication of missing the workqueue execution before hitting other
> PCI events as there might be a delay in scheduling the work item.

Just a note: using workqueue wouldn't help if one has to process link
down events.
The driver would expect that after dispatching the link down event it
can disable the hardware, thus making worker access disabled hw
instance.



-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-02-25 18:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-25 18:23 PCI: endpoint: Usage of atomic notifier chain Manivannan Sadhasivam
2022-02-25 18:26 ` Dmitry Baryshkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).