linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Russell King - ARM Linux <linux@arm.linux.org.uk>
To: Andre Przywara <andre.przywara@arm.com>
Cc: Lorenzo Pieralisi <Lorenzo.Pieralisi@arm.com>,
	"graeme.gregory@linaro.org" <graeme.gregory@linaro.org>,
	Arnd Bergmann <arnd@arndb.de>, Jakub Kicinski <moorray3@wp.pl>,
	GregKH <gregkh@linuxfoundation.org>,
	Timur Tabi <timur@codeaurora.org>,
	Naresh Bhat <nareshgbhat@gmail.com>,
	"mlangsdo@redhat.com" <mlangsdo@redhat.com>,
	"linux-serial@vger.kernel.org" <linux-serial@vger.kernel.org>,
	Jiri Slaby <jslaby@suse.cz>, Dave P Martin <Dave.Martin@arm.com>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH v5 02/11] drivers: PL011: refactor pl011_startup()
Date: Fri, 25 Sep 2015 16:30:35 +0100	[thread overview]
Message-ID: <20150925153035.GP21513@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <5605668C.5020407@arm.com>

On Fri, Sep 25, 2015 at 04:21:48PM +0100, Andre Przywara wrote:
> Hi Timur,
> 
> On 25/09/15 00:11, Timur Tabi wrote:
> > On Thu, May 21, 2015 at 11:26 AM, Andre Przywara <andre.przywara@arm.com> wrote:
> >> +static void pl011_enable_interrupts(struct uart_amba_port *uap)
> >> +{
> >> +       spin_lock_irq(&uap->port.lock);
> >> +
> >> +       /* Clear out any spuriously appearing RX interrupts */
> >> +       writew(UART011_RTIS | UART011_RXIS,
> >> +              uap->port.membase + UART011_ICR);
> >> +       uap->im = UART011_RTIM;
> >> +       if (!pl011_dma_rx_running(uap))
> >> +               uap->im |= UART011_RXIM;
> >> +       writew(uap->im, uap->port.membase + UART011_IMSC);
> >> +       spin_unlock_irq(&uap->port.lock);
> >> +}
> > 
> > Shouldn't this function be using spin_lock_irqsave() and
> > spin_unlock_irqrestore()?  If interrupts are generally disabled before
> > calling this function, then they will be enabled by the
> > spin_unlock_irq() call, and I don't think we want that.  This function
> > is only supposed to enable pl011 interrupts, not all interrupts.
> 
> Are you seeing an actual issue with this? Does changing it fix anything?
> Looking at the history I see that these locks predate git history.
> If I get this correctly, going from spin_{un,}lock_irq to the _irqsave
> variants should always be safe, but I'd like to hear more opinions on this.

If code is only called from process sleepable context, then using the
_irq variants is a sane thing to do, and avoids the extra work to
read and store the interrupt state prior to the protected code.
Currently that's true in mainline.

I'd encourage people not to jump on the "you're using _irq variants,
the code must be bad!" wagon, and instead spend time reading the code
and checking whether it's safe.

If the code path is suitable for a mutex, it's suitable for _irq()
variants too: you're not allowed to sleep with IRQs disabled.

If you want to have some runtime validation, add WARN_ON(!irqs_disabled());
before it, but I'd recommend against littering mainline with that.
Arguably, it's something that the _irq() variants should do, and I
think it's been proposed in the past, but rejected.  I forget why.

-- 
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

  reply	other threads:[~2015-09-25 15:30 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-21 16:26 [PATCH v5 00/11] drivers: PL011: add ARM SBSA Generic UART support Andre Przywara
2015-05-21 16:26 ` [PATCH v5 01/11] drivers: PL011: avoid potential unregister_driver call Andre Przywara
2015-05-21 16:26 ` [PATCH v5 02/11] drivers: PL011: refactor pl011_startup() Andre Przywara
2015-09-24 23:11   ` Timur Tabi
2015-09-25 15:21     ` Andre Przywara
2015-09-25 15:30       ` Russell King - ARM Linux [this message]
2015-05-21 16:26 ` [PATCH v5 03/11] drivers: PL011: refactor pl011_shutdown() Andre Przywara
2015-05-21 16:26 ` [PATCH v5 04/11] drivers: PL011: refactor pl011_set_termios() Andre Przywara
2015-05-21 16:26 ` [PATCH v5 05/11] drivers: PL011: refactor pl011_probe() Andre Przywara
2015-08-09  0:59   ` Timur Tabi
2015-09-03 16:54     ` Andre Przywara
2015-09-03 18:09       ` Timur Tabi
2015-05-21 16:26 ` [PATCH v5 06/11] drivers: PL011: replace UART_MIS reading with _RIS & _IMSC Andre Przywara
2015-05-21 16:26 ` [PATCH v5 07/11] drivers: PL011: move cts_event workaround into separate function Andre Przywara
2015-05-21 16:26 ` [PATCH v5 08/11] drivers: PL011: allow avoiding UART enabling/disabling Andre Przywara
2015-05-21 16:26 ` [PATCH v5 09/11] drivers: PL011: allow to supply fixed option string Andre Przywara
2015-05-21 16:26 ` [PATCH v5 10/11] drivers: PL011: add support for the ARM SBSA generic UART Andre Przywara
2015-05-21 16:26 ` [PATCH v5 11/11] drivers: PL011: add ACPI probing for SBSA UART Andre Przywara
2015-05-21 17:19 ` [PATCH v5 00/11] drivers: PL011: add ARM SBSA Generic UART support Mark Langsdorf
2015-05-21 17:45   ` Graeme Gregory
2015-05-22 13:14 ` Naresh Bhat

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=20150925153035.GP21513@n2100.arm.linux.org.uk \
    --to=linux@arm.linux.org.uk \
    --cc=Dave.Martin@arm.com \
    --cc=Lorenzo.Pieralisi@arm.com \
    --cc=andre.przywara@arm.com \
    --cc=arnd@arndb.de \
    --cc=graeme.gregory@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jslaby@suse.cz \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=mlangsdo@redhat.com \
    --cc=moorray3@wp.pl \
    --cc=nareshgbhat@gmail.com \
    --cc=timur@codeaurora.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 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).