Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753037AbcCVRcb (ORCPT ); Tue, 22 Mar 2016 13:32:31 -0400 Received: from mail-pf0-f171.google.com ([209.85.192.171]:35255 "EHLO mail-pf0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751365AbcCVRc1 (ORCPT ); Tue, 22 Mar 2016 13:32:27 -0400 Subject: Re: [PATCH v5 3/6] ACPI: parse SPCR and enable matching console To: Yury Norov References: <1458643595-14719-1-git-send-email-aleksey.makarov@linaro.org> <1458643595-14719-4-git-send-email-aleksey.makarov@linaro.org> <20160322122650.GA10616@yury-N73SV> <56F15D40.9020401@hurleysoftware.com> <20160322165122.GB10616@yury-N73SV> Cc: Aleksey Makarov , Greg Kroah-Hartman , "Rafael J . Wysocki" , Len Brown , linux-serial@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Russell King , Leif Lindholm , Graeme Gregory , Al Stone , Christopher Covington , "Zheng, Lv" , Jiri Slaby From: Peter Hurley Message-ID: <56F181A6.3070502@hurleysoftware.com> Date: Tue, 22 Mar 2016 10:32:22 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <20160322165122.GB10616@yury-N73SV> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1784 Lines: 64 On 03/22/2016 09:51 AM, Yury Norov wrote: > On Tue, Mar 22, 2016 at 07:57:04AM -0700, Peter Hurley wrote: > > [...] > >>>> +static bool init_earlycon; >>>> + >>>> +void __init init_spcr_earlycon(void) >>>> +{ >>>> + init_earlycon = true; >>>> +} >>>> + >>> >>> 1. I see you keep in mind multiple access. >> >> Concurrent access is not a concern here: only the boot cpu is running >> and intrs are off. >> >> The "init_earlycon" flag is used because parsing the "earlycon" early param >> is earlier than parsing ACPI tables. >> > > OK got it. My concern is that it's generic code, and parse_spcr() is public > function. I think corresponding comment is needed at least. The other option is > to make it race-safe and forget. I prefer second one, moreover it's 2 simple > changes. Earlycon is generic only in the sense of platform independence, not in the sense of temporal independence. There is no serialization in earlycon, anywhere. Adding serialization will unnecessarily confuse casual observers into believing it is necessary. An argument could be made that earlycon needs some standalone documentation, but I don't think this patch needs to be that. >> Then you'd worry about race >>> conditions as well. In this case, I'd consider atomic access to >>> variable. >>> 2. It seems you need is_init() helper too. >>> >>>> +int __init parse_spcr(void) >>>> +{ >>>> + static char opts[64]; >>>> + struct acpi_table_spcr *table; >>>> + acpi_size table_size; >>>> + acpi_status status; >>>> + char *uart; >>>> + char *iotype; >>>> + int baud_rate; >>>> + int err = 0; >>> >>> You can do not initialize 'err'. >> >> Why? >> > > Because there's no path here that doesn't init err with some value. > So this initialization is useless waste of cycles. Ok. Regards, Peter Hurley