Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1292640

Re: [PATCH LINUX v4 06/13] tty: xuartps: Move request_irq to after setting up the HW

Path csiph.com!eternal-september.org!feeder.eternal-september.org!aioe.org!bofh.it!news.nic.it!robomod
From Peter Hurley <peter@hurleysoftware.com>
Newsgroups linux.kernel
Subject Re: [PATCH LINUX v4 06/13] tty: xuartps: Move request_irq to after setting up the HW
Date Wed, 16 Dec 2015 00:30:02 +0100
Message-ID <qG7cC-2o7-15@gated-at.bofh.it> (permalink)
References <qCzqN-2b5-3@gated-at.bofh.it> <qCzqO-2b5-21@gated-at.bofh.it> <qEhg6-3j4-17@gated-at.bofh.it> <qG01t-68o-49@gated-at.bofh.it>
X-Original-To Sören Brinkmann <soren.brinkmann@xilinx.com>
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=hurleysoftware-com.20150623.gappssmtp.com; s=20150623; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-type:content-transfer-encoding; bh=abABLJ1lnoKauy6B6i/TQ+SzCu5oElFVmlzGG85mj9s=; b=Ef3cyHe+mfp83AipBfH0jrLu1Y75fnbyZ13+G71Yv63RrdlQAjR37tcFis6OYNJyqh hhxMG1MfDL4xkAXpD35Kh6zuRN9qeFx2xYP9W6tgqYaJOLudM1aeQcALjw+ZCLCDrAo2 oBHNVT7eV4Vt+5VewiYI94QpD54SPhTA4exvOwz1pCVFzMBkTt7C6GHgFBZt0Av0TRf+ oDaTZ7P32wzETsdS3xBvo2yX913XR5uG4jMoRW4A/8i0vYEJvNixhhSZFYj79YhoGoOU 0Miow9Dh4KaIYPZbcMI8sA10TtuIUUFJ1klnhamKrcsHsC7jxyo0E+ReyNeXUgtC9kOo n0Kw==
X-Google-Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-type :content-transfer-encoding; bh=abABLJ1lnoKauy6B6i/TQ+SzCu5oElFVmlzGG85mj9s=; b=MNhp6/IHhWPBH6i20+Ksb7PQcHIn6qtG7Z0Akdy3zIqJpU4mVWpxz9Gt7dRCXL6G43 st48YrnhEphNCW6Onq69CZSy5/b76P6MXHAdXSWEj1O2ZA3CkvmYU0kzrWFp0qdH7ZZ+ TWfEqLNrBpoqMBR27sOdsIayBWNNHwO6OUs+Rtjhjv/2N5S8dqUV2upcNW0feh6Bq6GE pPv/sFYvBQ5j5UrH1Q4M2LRoBVycN8P/w6T81y01j32/mrVEYq+lIw5Iy43HSJn0ITBo ku7mshsL3Q+avVbOFTlAvNStDHcH27+GMvFMWZxNMI2lvvhnpbOZLGz7DNUB0mrIEVOK +Xig==
X-Gm-Message-State ALoCoQmOd8QbLqX8FtgzfOqm6xPDSxC5wbziSJnbKtvyyI1ofTHJjkRwkrrJATMHfnKuh9HlW3y3P6zxYDkK+PVxiJ+DoCSqZg==
X-Received by 10.98.71.20 with SMTP id u20mr840450pfa.16.1450222008366; Tue, 15 Dec 2015 15:26:48 -0800 (PST)
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0
MIME-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 8bit
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 100
Organization linux.* mail to news gateway
X-Original-Cc Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Jiri Slaby <jslaby@suse.com>, Michal Simek <michal.simek@xilinx.com>, linux-serial@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Moritz Fischer <moritz.fischer@ettus.com>
X-Original-Date Tue, 15 Dec 2015 15:26:46 -0800
X-Original-Message-ID <5670A1B6.6050708@hurleysoftware.com>
X-Original-References <1449376769-13369-1-git-send-email-soren.brinkmann@xilinx.com> <1449376769-13369-7-git-send-email-soren.brinkmann@xilinx.com> <5669F172.6020503@hurleysoftware.com> <20151215154136.GU3358@xsjsorenbubuntu>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1292640

Show key headers only | View raw


On 12/15/2015 07:41 AM, Sören Brinkmann wrote:
> On Thu, 2015-12-10 at 01:41PM -0800, Peter Hurley wrote:
>> On 12/05/2015 08:39 PM, Soren Brinkmann wrote:
>>> Request_irq() should be _after_ h/w programming, otherwise an
>>> interrupt could be triggered and in-progress before the h/w has been
>>> setup.
>>
>> Slight misunderstanding. My fault; I should have been more explicit.
>>
>> 1. Any setup necessary for the isr not to be confused and misdirect spurious
>>    interrupts (or hang) should be before installing the isr with request_irq()
>>    None of this code should trigger an interrupt.
>> 2. Clear pending interrupts
>> 3. Install the isr with request_irq()
>> 4. Enable interrupts
> 
> Isn't that what the startup function is doing now - more or less. I
> think 3 and 4 are swapped to release the lock and then do the
> request_irq, but I believe that should be OK.
> The startup function configures the HW. Clears the ISR. Enables the
> intended IRQs and then does the request_irq call.

If the driver enables interrupts before installing the isr with request_irq()
and an interrupt occurs there will the no handler to catch it and EOI the
device.


>> For extra safety, first disable interrupts before starting h/w programming.
> 
> It's done within spin_lock_irqsave, which gives us at least locally
> disabled IRQs. I guess we could add a disabling all IRQs in the UART
> core, but it should not really be necessary.

Similar issue.

What I mean is to mask interrupts from this device so that h/w programming
doesn't accidentally trigger an interrupt for which no isr is installed.

It's a bit overkill; that's why I said "extra safety".

Regards,
Peter Hurley


>> I would do the v5 series in the same order as the v3 series only up to
>> what I reviewed. Then do another series with the remainder plus new changes, ok?
> 
> Sure.
> 
> 	Sören
> 
>>
>> Regards,
>> Peter Hurley
>>
>>> Reported-by: Peter Hurley <peter@hurleysoftware.com>
>>> Signed-off-by: Soren Brinkmann <soren.brinkmann@xilinx.com>
>>> ---
>>> v4:
>>>  - this patch has been added. Thanks to Peter for pointing it out and providing
>>>    commit message
>>> ---
>>>  drivers/tty/serial/xilinx_uartps.c | 9 ++-------
>>>  1 file changed, 2 insertions(+), 7 deletions(-)
>>>
>>> diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c
>>> index 6ffd3bbe3e18..1e9053656610 100644
>>> --- a/drivers/tty/serial/xilinx_uartps.c
>>> +++ b/drivers/tty/serial/xilinx_uartps.c
>>> @@ -759,12 +759,7 @@ static void cdns_uart_set_termios(struct uart_port *port,
>>>  static int cdns_uart_startup(struct uart_port *port)
>>>  {
>>>  	unsigned long flags;
>>> -	unsigned int retval = 0, status = 0;
>>> -
>>> -	retval = request_irq(port->irq, cdns_uart_isr, 0, CDNS_UART_NAME,
>>> -								(void *)port);
>>> -	if (retval)
>>> -		return retval;
>>> +	unsigned int status = 0;
>>>  
>>>  	spin_lock_irqsave(&port->lock, flags);
>>>  
>>> @@ -818,7 +813,7 @@ static int cdns_uart_startup(struct uart_port *port)
>>>  
>>>  	spin_unlock_irqrestore(&port->lock, flags);
>>>  
>>> -	return retval;
>>> +	return request_irq(port->irq, cdns_uart_isr, 0, CDNS_UART_NAME, port);
>>>  }
>>>  
>>>  /**
>>>
>>

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [PATCH LINUX v4 06/13] tty: xuartps: Move request_irq to after  setting up the HW Sören Brinkmann <soren.brinkmann@xilinx.com> - 2015-12-15 16:50 +0100
  Re: [PATCH LINUX v4 06/13] tty: xuartps: Move request_irq to after  setting up the HW Peter Hurley <peter@hurleysoftware.com> - 2015-12-16 00:30 +0100
    Re: [PATCH LINUX v4 06/13] tty: xuartps: Move request_irq to after  setting up the HW Sören Brinkmann <soren.brinkmann@xilinx.com> - 2015-12-16 10:10 +0100
      Re: [PATCH LINUX v4 06/13] tty: xuartps: Move request_irq to after  setting up the HW Peter Hurley <peter@hurleysoftware.com> - 2015-12-16 15:40 +0100
        Re: [PATCH LINUX v4 06/13] tty: xuartps: Move request_irq to after  setting up the HW Sören Brinkmann <soren.brinkmann@xilinx.com> - 2015-12-17 11:10 +0100

csiph-web