From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753252AbdC2Puu (ORCPT ); Wed, 29 Mar 2017 11:50:50 -0400 Received: from mail-lf0-f52.google.com ([209.85.215.52]:34834 "EHLO mail-lf0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752872AbdC2Pur (ORCPT ); Wed, 29 Mar 2017 11:50:47 -0400 MIME-Version: 1.0 In-Reply-To: <20170329100424.7439-1-oliver@schinagl.nl> References: <20170329100424.7439-1-oliver@schinagl.nl> From: Doug Anderson Date: Wed, 29 Mar 2017 08:50:34 -0700 X-Google-Sender-Auth: hBwZAqebOlvQ-SPTGG3TZLAVfv8 Message-ID: Subject: Re: [PATCH] serial: 8250_dw: Minor code cleanup To: Olliver Schinagl Cc: Greg Kroah-Hartman , Jiri Slaby , Kefeng Wang , Andy Shevchenko , Heikki Krogerus , Jason Uy , Heiko Stuebner , Ed Blake , linux-serial@vger.kernel.org, "linux-kernel@vger.kernel.org" , dev@linux-sunxi.org Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Wed, Mar 29, 2017 at 3:04 AM, Olliver Schinagl 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.. From mboxrd@z Thu Jan 1 00:00:00 1970 From: Doug Anderson Subject: Re: [PATCH] serial: 8250_dw: Minor code cleanup Date: Wed, 29 Mar 2017 08:50:34 -0700 Message-ID: References: <20170329100424.7439-1-oliver@schinagl.nl> Reply-To: dianders-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Return-path: Sender: dianders-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org In-Reply-To: <20170329100424.7439-1-oliver-dxLnbx3+1qmEVqv0pETR8A@public.gmane.org> List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , To: Olliver Schinagl Cc: Greg Kroah-Hartman , Jiri Slaby , Kefeng Wang , Andy Shevchenko , Heikki Krogerus , Jason Uy , Heiko Stuebner , Ed Blake , linux-serial-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, "linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org" , dev-3kdeTeqwOZ9EV1b7eY7vFQ@public.gmane.org List-Id: linux-serial@vger.kernel.org Hi, On Wed, Mar 29, 2017 at 3:04 AM, Olliver Schinagl 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..