All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lukas Wunner <lukas@wunner.de>
To: "Pali Rohár" <pali@kernel.org>
Cc: linux-pci@vger.kernel.org
Subject: Re: PCI service interrupt handlers & access to PCI config space
Date: Sat, 10 Apr 2021 16:25:24 +0200	[thread overview]
Message-ID: <20210410142524.GA31187@wunner.de> (raw)
In-Reply-To: <20210410122845.nhenihbygmcjlegn@pali>

On Sat, Apr 10, 2021 at 02:28:45PM +0200, Pali Rohár wrote:
> I see that more PCI service drivers in their interrupt handlers are
> accessing PCI config space.
> 
> E.g. in PCIe Hot Plug interrupt handler pciehp_isr handler is called
> pcie_capability_read_word() function.
> 
> It is correct? Because these capability functions are protected by
> pci_lock_config() / pci_unlock_config() calls.

Looks fine to me.  That's a raw_spin_lock, which is allowed to be taken
in interrupt context.

> And what would happen when during execution of reading or writing to
> PCIe config space (e.g. via pcie_capability_read_word()) is triggered
> PCIe HP interrupt? Would not enter interrupt handler function in
> deadlock (waiting for unlocking config space)?

The interrupt handler would spin until the lock is released.
raw_spin_locks are not supposed to be held for a prolonged
period of time.

The interrupt is masked when it triggers and until it's been handled,
so the interrupt handler never runs multiple times concurrently.
See e.g. handle_level_irq() in kernel/irq/chip.c.

Thanks,

Lukas

  reply	other threads:[~2021-04-10 14:25 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-10 12:28 PCI service interrupt handlers & access to PCI config space Pali Rohár
2021-04-10 14:25 ` Lukas Wunner [this message]
2021-04-10 15:17   ` Pali Rohár
2021-04-10 16:26     ` Lukas Wunner
2021-04-12  2:25       ` Keith Busch
2021-04-12 14:04         ` Pali Rohár
2021-04-12 15:09           ` Keith Busch
2021-04-13  9:33             ` Pali Rohár
2021-04-13  9:35       ` Pali Rohár

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210410142524.GA31187@wunner.de \
    --to=lukas@wunner.de \
    --cc=linux-pci@vger.kernel.org \
    --cc=pali@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.