Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755463AbcCVQv5 (ORCPT ); Tue, 22 Mar 2016 12:51:57 -0400 Received: from mail-by2on0092.outbound.protection.outlook.com ([207.46.100.92]:32513 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752696AbcCVQvp (ORCPT ); Tue, 22 Mar 2016 12:51:45 -0400 Authentication-Results: hurleysoftware.com; dkim=none (message not signed) header.d=none;hurleysoftware.com; dmarc=none action=none header.from=caviumnetworks.com; Date: Tue, 22 Mar 2016 19:51:22 +0300 From: Yury Norov To: Peter Hurley CC: Aleksey Makarov , Greg Kroah-Hartman , "Rafael J . Wysocki" , Len Brown , , , , , Russell King , Leif Lindholm , Graeme Gregory , Al Stone , Christopher Covington , "Zheng, Lv" , Jiri Slaby Subject: Re: [PATCH v5 3/6] ACPI: parse SPCR and enable matching console Message-ID: <20160322165122.GB10616@yury-N73SV> 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> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <56F15D40.9020401@hurleysoftware.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-Originating-IP: [95.143.213.121] X-ClientProxiedBy: VI1PR06CA0009.eurprd06.prod.outlook.com (25.162.116.147) To CO2PR07MB617.namprd07.prod.outlook.com (10.141.228.143) X-MS-Office365-Filtering-Correlation-Id: 774c65f9-8316-43e9-7480-08d352723eec X-Microsoft-Exchange-Diagnostics: 1;CO2PR07MB617;2:JbyPD66QnLsFeQHaMboCAtFhpC88GQ236EPoi6J5l9idKuQMcHx0mtVEEoG5Oj5fbhtEd6Uv0KnHlaDS5NOFVMn1iYpPAan1hJpH9NMObrMnupa3GJFa78+gFUDfvFs6MqHECXEQrizlVE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oxuedkbKZWt2tVrS7XClpFHVoKgFU3Bc0mId7iQD6/fREk9UDhvMR/YiDssXvDw5xfhVyesi75aZqK5QylOLHYl2RDyg9FxPP85e/oMQMoqrUbmgJ1dWw2P/vj1bRbWR3QP5KHC2MHPOTyfOZnKXmzDvkEodyREj2nB4ykElbij0ByGwp9aI1D84q1V/b9z8fGKUTm45j/1c/nPbizpKcpASbUgMIfV51rcSyxFCQorWkQy0Le491uoNzBm5o0+6U9b0kNAmOfQX65JZwhlKPiVYTED3d8bp6bxI/etYb+mUGwQGk4X7NWhJ0qoYy7KApe63LTVNBxtn8x8rs8X9hDYLaBd0LC3Ki44UsxmpAajAZ8/eQc= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046);SRVR:CO2PR07MB617;BCL:0;PCL:0;RULEID:;SRVR:CO2PR07MB617; X-Microsoft-Exchange-Diagnostics: 1;CO2PR07MB617;4:yPDS+YR9nDwVvoa/y+vu4jEH5/Bw8OMHqZVUhdN5of05CsmvP/Y9EoQKHl8MvHlh5+R0Fys3un/NhhbvWQ2n2P/sCXjAEDwD/pana17QogWFi1iKcL20FlzI3rnsxdZA2w/CtNKKrFNHrXwAMJUWZnYw3COMjFPBBUqoBekE7jL+Xmw8YUfaj3sgUCyEAglyn4ta+62eD4GW0CjjudVfftLOnjRqYG+bdkrxB76bJiC/tGQZHhYjSow4w0/Ee7DMe+w+6MsCbdGMIOOqYXBi8+11NYPTw4NblGdkUCECHRwD1lW/swrpTBhenQrtl/HidybZQsXyzOg6EPHAmXp9F/84VbENEl7ljcru1HxXXP97JMWeVRP7PmZf2AWXE/V+ X-Forefront-PRVS: 08897B549D X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(24454002)(76176999)(4326007)(33716001)(586003)(92566002)(50986999)(110136002)(77096005)(4001350100001)(2950100001)(93886004)(33656002)(42186005)(83506001)(6116002)(3846002)(5004730100002)(50466002)(1076002)(189998001)(76506005)(54356999)(1096002)(66066001)(2906002)(97756001)(81166005)(23726003)(47776003)(5008740100001)(46406003);DIR:OUT;SFP:1101;SCL:1;SRVR:CO2PR07MB617;H:localhost;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;CO2PR07MB617;23:oE31QQT77G03tZKAmecLYVoBjV9/Mb64q5rVtWtu2iTqyu9Q905ADLO3p2km6nnqe7Js8IeWluSNzDNmN6fybGMzZbjkEYPtk1v5rsQhMCp5dAB43pq6paBuDbtWNR7mFFZ0m44nCRGVRYokbHReBK/Wjkgyks/mghwVLJY78DhuxXVX4j37KwSkAFB0lW3ujNMcmf/GRLzWpJlMBRFSRwUQDz+wt86U5EJorEm8LwnsSfmZi6iVXwvgkmUV7X/CE+f6k1MBJOSpdJlxD4IPXDGvLL0FFV4Fcn6vOEwN4AUAb9iMoLvvhy2599JPhXc/7a2jUtZobi38MWH1coEx57Gl8MLz/aEYnqHkXFO03MwIzdku2JcputmSbsj2epSsRIkEqT2PcWw1W9q5M1io1qH3J7fAXgzfzzZ/+u3skEqa0VcOpbU73wyqdjjGVSs6KXob0ABBYZpXTwHZlpZS/cVVmxhi1yIbaLkVmuK06OvT+aqcOn/4MRBmLnOUjlgZHqsjug6r+lzFpBxfCUQZsuI4kgVV4gx+3WSBt9FRZDv2YVmGUCfz0E0V8xTucrtcMRVNxC59IZriMIT75XQULJufZp8pl9s2BmKlFPUJgC8Us4PXUkDnqczs7McCmtl/hYqu0O5CT5uUSpBU0ZwMu/ececD4FF6o9t7nWK9cUbPwWqHKSUTXa+nrNJsi1y00wGdg1f75gbumb0gfosiON+cWBXLN2SK2whQDyQcP9/Z/Rc2BlGCgSNkoVcxtwQCC8falGPCg4qM4x4eq4FTcm/zB0ToyohFh1qbu6rv8wcHQmVEoFRfm5dVKAL0czebLSlYHPQjsyb2Dec6xk4GhtxCnXQEOFhCJgqNQFfqxx742pZFPVU6Pza2w0rdLkOU8uGF9Vf2qPIgfZ5m4zw4dEUeury4nBNW02eq0Pfb1wYo= X-Microsoft-Exchange-Diagnostics: 1;CO2PR07MB617;5:xlyT+6C/noSo5GVNrW867E0LD/kseLnLQtXCB/igHOmGGU3+0VsXh565DXIik0TLQ8If64ZZ8+Wmlt6rPszoUY9eZYvoOK3lrFeVDaYNsZm50elv9gDSIb5pQaC1WiZQxY+oR9vEY083Kq8C6oypJQ==;24:EyfNFfNMqnXIHX8WL3rGO6PZgR7J4ySnp3Zgtara6xWMyEJ5kTyt7syWg9X6CP7n/GG3gFf2TKsGWlg9lvsXqBqbq1GHqUK/j6gflNrVhvA= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Mar 2016 16:51:41.9804 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO2PR07MB617 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1317 Lines: 52 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. > > 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. [...]