From mboxrd@z Thu Jan 1 00:00:00 1970 From: Vladimir Murzin Subject: Re: [PATCH v3 05/10] serial: mps2-uart: add support for early console Date: Tue, 16 Feb 2016 13:38:09 +0000 Message-ID: <56C32641.4020201@arm.com> References: <1455617295-23736-1-git-send-email-vladimir.murzin@arm.com> <1455617295-23736-6-git-send-email-vladimir.murzin@arm.com> <56C31F9F.10000@arm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Return-path: In-Reply-To: Sender: linux-api-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Andy Shevchenko Cc: Arnd Bergmann , Russell King , Greg Kroah-Hartman , Daniel Lezcano , Thomas Gleixner , =?UTF-8?B?VXdlIEtsZWluZS1Lw7ZuaWc=?= , Mark Rutland , Pawel Moll , ijc+devicetree , Kumar Gala , Jiri Slaby , Rob Herring , devicetree , "linux-serial-u79uwXL29TY76Z2rM5mHXA@public.gmane.org" , "linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org" , linux-arm Mailing List , "linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org" List-Id: linux-api@vger.kernel.org On 16/02/16 13:13, Andy Shevchenko wrote: > On Tue, Feb 16, 2016 at 3:09 PM, Vladimir Murzin > wrote: >> On 16/02/16 10:36, Andy Shevchenko wrote: >>> On Tue, Feb 16, 2016 at 12:08 PM, Vladimir Murzin >>> wrote: >>>> This adds support early console for MPS2 UART which can be enabled= via >>>> earlycon=3Dmps2,0x40004000 >=20 >>>> +static void mps2_early_putchar(struct uart_port *port, int ch) >>>> +{ >>>> + >>>> + while (readb(port->membase + UARTn_STATE) & UARTn_STATE_TX= _FULL) >>>> + cpu_relax(); >>> >>> Infinite busy loop? >> >> In case of broken hw, yes, but I'm quite unsure how we can help to f= ix >> it. Do you have something in mind? >=20 > Set sane amount of loops like >=20 > int count =3D 100; > =E2=80=A6 > while (=E2=80=A6 && --count) >=20 > Though I have no idea what to do if count =3D=3D 0. Perhaps it's a TX= overrun state. I thought about counter too, like some of drivers do, but had no idea what to do next after counter reaches zero. In case of TX overrun we could get it either because of broken hw or because we entered Linux with that state already set. In both cases, it looks handy to me to attach a debugger and see that we are spinning in this putchar loop. If you do insist to have a counter I'll add one, but if you are not strong about it I'd prefer to leave it as is. >=20 > You may try to recover by flushing TX queue in HW (fifo and / or Tx > shift register) if HW supports it. >=20 I'm afraid this is not supported. Thanks Vladimir From mboxrd@z Thu Jan 1 00:00:00 1970 From: vladimir.murzin@arm.com (Vladimir Murzin) Date: Tue, 16 Feb 2016 13:38:09 +0000 Subject: [PATCH v3 05/10] serial: mps2-uart: add support for early console In-Reply-To: References: <1455617295-23736-1-git-send-email-vladimir.murzin@arm.com> <1455617295-23736-6-git-send-email-vladimir.murzin@arm.com> <56C31F9F.10000@arm.com> Message-ID: <56C32641.4020201@arm.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On 16/02/16 13:13, Andy Shevchenko wrote: > On Tue, Feb 16, 2016 at 3:09 PM, Vladimir Murzin > wrote: >> On 16/02/16 10:36, Andy Shevchenko wrote: >>> On Tue, Feb 16, 2016 at 12:08 PM, Vladimir Murzin >>> wrote: >>>> This adds support early console for MPS2 UART which can be enabled via >>>> earlycon=mps2,0x40004000 > >>>> +static void mps2_early_putchar(struct uart_port *port, int ch) >>>> +{ >>>> + >>>> + while (readb(port->membase + UARTn_STATE) & UARTn_STATE_TX_FULL) >>>> + cpu_relax(); >>> >>> Infinite busy loop? >> >> In case of broken hw, yes, but I'm quite unsure how we can help to fix >> it. Do you have something in mind? > > Set sane amount of loops like > > int count = 100; > ? > while (? && --count) > > Though I have no idea what to do if count == 0. Perhaps it's a TX overrun state. I thought about counter too, like some of drivers do, but had no idea what to do next after counter reaches zero. In case of TX overrun we could get it either because of broken hw or because we entered Linux with that state already set. In both cases, it looks handy to me to attach a debugger and see that we are spinning in this putchar loop. If you do insist to have a counter I'll add one, but if you are not strong about it I'd prefer to leave it as is. > > You may try to recover by flushing TX queue in HW (fifo and / or Tx > shift register) if HW supports it. > I'm afraid this is not supported. Thanks Vladimir From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932432AbcBPNiQ (ORCPT ); Tue, 16 Feb 2016 08:38:16 -0500 Received: from foss.arm.com ([217.140.101.70]:52976 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932109AbcBPNiO (ORCPT ); Tue, 16 Feb 2016 08:38:14 -0500 Message-ID: <56C32641.4020201@arm.com> Date: Tue, 16 Feb 2016 13:38:09 +0000 From: Vladimir Murzin User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: Andy Shevchenko CC: Arnd Bergmann , Russell King , Greg Kroah-Hartman , Daniel Lezcano , Thomas Gleixner , =?UTF-8?B?VXdlIEtsZWluZS1Lw7ZuaWc=?= , Mark Rutland , Pawel Moll , ijc+devicetree , Kumar Gala , Jiri Slaby , Rob Herring , devicetree , "linux-serial@vger.kernel.org" , "linux-api@vger.kernel.org" , linux-arm Mailing List , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v3 05/10] serial: mps2-uart: add support for early console References: <1455617295-23736-1-git-send-email-vladimir.murzin@arm.com> <1455617295-23736-6-git-send-email-vladimir.murzin@arm.com> <56C31F9F.10000@arm.com> In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 16/02/16 13:13, Andy Shevchenko wrote: > On Tue, Feb 16, 2016 at 3:09 PM, Vladimir Murzin > wrote: >> On 16/02/16 10:36, Andy Shevchenko wrote: >>> On Tue, Feb 16, 2016 at 12:08 PM, Vladimir Murzin >>> wrote: >>>> This adds support early console for MPS2 UART which can be enabled via >>>> earlycon=mps2,0x40004000 > >>>> +static void mps2_early_putchar(struct uart_port *port, int ch) >>>> +{ >>>> + >>>> + while (readb(port->membase + UARTn_STATE) & UARTn_STATE_TX_FULL) >>>> + cpu_relax(); >>> >>> Infinite busy loop? >> >> In case of broken hw, yes, but I'm quite unsure how we can help to fix >> it. Do you have something in mind? > > Set sane amount of loops like > > int count = 100; > … > while (… && --count) > > Though I have no idea what to do if count == 0. Perhaps it's a TX overrun state. I thought about counter too, like some of drivers do, but had no idea what to do next after counter reaches zero. In case of TX overrun we could get it either because of broken hw or because we entered Linux with that state already set. In both cases, it looks handy to me to attach a debugger and see that we are spinning in this putchar loop. If you do insist to have a counter I'll add one, but if you are not strong about it I'd prefer to leave it as is. > > You may try to recover by flushing TX queue in HW (fifo and / or Tx > shift register) if HW supports it. > I'm afraid this is not supported. Thanks Vladimir