All of lore.kernel.org
 help / color / mirror / Atom feed
From: Doug Anderson <dianders@chromium.org>
To: Olliver Schinagl <oliver@schinagl.nl>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jiri Slaby <jslaby@suse.com>,
	Kefeng Wang <wangkefeng.wang@huawei.com>,
	Andy Shevchenko <andy.shevchenko@gmail.com>,
	Heikki Krogerus <heikki.krogerus@linux.intel.com>,
	Jason Uy <jason.uy@broadcom.com>,
	Heiko Stuebner <heiko@sntech.de>, Ed Blake <ed.blake@imgtec.com>,
	linux-serial@vger.kernel.org,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	dev@linux-sunxi.org
Subject: Re: [PATCH] serial: 8250_dw: Minor code cleanup
Date: Wed, 29 Mar 2017 08:50:34 -0700	[thread overview]
Message-ID: <CAD=FV=XZFuZ-Zqv75wF7wj6AY35o9n4-zrbsVjNcFZ+DxS=fbQ@mail.gmail.com> (raw)
In-Reply-To: <20170329100424.7439-1-oliver@schinagl.nl>

Hi,

On Wed, Mar 29, 2017 at 3:04 AM, Olliver Schinagl <oliver@schinagl.nl> wrote:
> Commit 424d79183af0 ("serial: 8250_dw: Avoid "too much work" from bogus rx timeout interrupt")
> added a bit check with quite a wide mask. To be concise with the other
> similar calls in this driver, change it to mask against the flag we want to
> check only. This thus removes a magic value/mask.

How certain are you that your patch is correct?  You are now basically
checking to see if the bits "0xc" are set in the IIR.  Previously the
patch ensured that the bits 0x33 were clear.

Have you tried looking through the kernel for other places where
UART_IIR_RX_TIMEOUT is referenced?  In 8250_omap.c and 8250_port.c I
believe you'll find it masking against 0x3f.  In omap-serial.c you'll
see a mask against 0x3e.

Looking at the TRM for rk3399, I see that bits 4 and 5 (bitmask 0x30)
as "reserved".  I see the following definitions for bits 3:0:

0000 = modem status
0001 = no interrupt pending
0010 = THR empty
0100 = received data available
0110 = receiver line status
0111 = busy detect
1100 = character timeout

...so while your patch will probably function OK, it would also
function equally well to simply test bit 3 (0x80) and ignore
everything else.  ...but IMHO it is more correct to at least mask the
IIR with 0x0F and confirm that bits 2 and 3 are set and bits 0 and 1
are zero.  ...and since the main 8250 code uses 0x3f, that seems even
better to me (despite the fact that it seems to be relying on the fact
that the "reserved" bits come back as 0).


If you want to make a fix, I'd suggest adding a #define for 0x3f and
using it in various places.


> Some very minor code cleanups, such as including the bitops header for
> DW_UART_MCR_SIRE, use the BIT() macro as suggested by checkpatc and
> removed a whitespace to match other invocations.

Maybe it's just me, but it seems like a bad idea to combine these
cleanups in the same patch with a functional change..

WARNING: multiple messages have this Message-ID (diff)
From: Doug Anderson <dianders-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
To: Olliver Schinagl <oliver-dxLnbx3+1qmEVqv0pETR8A@public.gmane.org>
Cc: Greg Kroah-Hartman
	<gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>,
	Jiri Slaby <jslaby-IBi9RG/b67k@public.gmane.org>,
	Kefeng Wang
	<wangkefeng.wang-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>,
	Andy Shevchenko
	<andy.shevchenko-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Heikki Krogerus
	<heikki.krogerus-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>,
	Jason Uy <jason.uy-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>,
	Heiko Stuebner <heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>,
	Ed Blake <ed.blake-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org>,
	linux-serial-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	"linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	dev-3kdeTeqwOZ9EV1b7eY7vFQ@public.gmane.org
Subject: Re: [PATCH] serial: 8250_dw: Minor code cleanup
Date: Wed, 29 Mar 2017 08:50:34 -0700	[thread overview]
Message-ID: <CAD=FV=XZFuZ-Zqv75wF7wj6AY35o9n4-zrbsVjNcFZ+DxS=fbQ@mail.gmail.com> (raw)
In-Reply-To: <20170329100424.7439-1-oliver-dxLnbx3+1qmEVqv0pETR8A@public.gmane.org>

Hi,

On Wed, Mar 29, 2017 at 3:04 AM, Olliver Schinagl <oliver-dxLnbx3+1qmEVqv0pETR8A@public.gmane.org> wrote:
> Commit 424d79183af0 ("serial: 8250_dw: Avoid "too much work" from bogus rx timeout interrupt")
> added a bit check with quite a wide mask. To be concise with the other
> similar calls in this driver, change it to mask against the flag we want to
> check only. This thus removes a magic value/mask.

How certain are you that your patch is correct?  You are now basically
checking to see if the bits "0xc" are set in the IIR.  Previously the
patch ensured that the bits 0x33 were clear.

Have you tried looking through the kernel for other places where
UART_IIR_RX_TIMEOUT is referenced?  In 8250_omap.c and 8250_port.c I
believe you'll find it masking against 0x3f.  In omap-serial.c you'll
see a mask against 0x3e.

Looking at the TRM for rk3399, I see that bits 4 and 5 (bitmask 0x30)
as "reserved".  I see the following definitions for bits 3:0:

0000 = modem status
0001 = no interrupt pending
0010 = THR empty
0100 = received data available
0110 = receiver line status
0111 = busy detect
1100 = character timeout

...so while your patch will probably function OK, it would also
function equally well to simply test bit 3 (0x80) and ignore
everything else.  ...but IMHO it is more correct to at least mask the
IIR with 0x0F and confirm that bits 2 and 3 are set and bits 0 and 1
are zero.  ...and since the main 8250 code uses 0x3f, that seems even
better to me (despite the fact that it seems to be relying on the fact
that the "reserved" bits come back as 0).


If you want to make a fix, I'd suggest adding a #define for 0x3f and
using it in various places.


> Some very minor code cleanups, such as including the bitops header for
> DW_UART_MCR_SIRE, use the BIT() macro as suggested by checkpatc and
> removed a whitespace to match other invocations.

Maybe it's just me, but it seems like a bad idea to combine these
cleanups in the same patch with a functional change..

  reply	other threads:[~2017-03-29 15:50 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-29 10:04 [PATCH] serial: 8250_dw: Minor code cleanup Olliver Schinagl
2017-03-29 10:04 ` Olliver Schinagl
2017-03-29 15:50 ` Doug Anderson [this message]
2017-03-29 15:50   ` Doug Anderson
2017-03-29 17:10   ` Olliver Schinagl
2017-03-29 17:10     ` Olliver Schinagl
2017-03-29 17:20     ` Olliver Schinagl
2017-03-29 17:20       ` Olliver Schinagl
2017-03-29 18:38     ` Doug Anderson
2017-03-29 18:38       ` Doug Anderson

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='CAD=FV=XZFuZ-Zqv75wF7wj6AY35o9n4-zrbsVjNcFZ+DxS=fbQ@mail.gmail.com' \
    --to=dianders@chromium.org \
    --cc=andy.shevchenko@gmail.com \
    --cc=dev@linux-sunxi.org \
    --cc=ed.blake@imgtec.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=heiko@sntech.de \
    --cc=jason.uy@broadcom.com \
    --cc=jslaby@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=oliver@schinagl.nl \
    --cc=wangkefeng.wang@huawei.com \
    /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.