Received: by 10.213.65.68 with SMTP id h4csp1662209imn; Mon, 19 Mar 2018 09:58:29 -0700 (PDT) X-Google-Smtp-Source: AG47ELvAbV9cpaJMyvV47d1T/OJcyUxvxe6SAsZ7pKcHAxDtQYAIAA/L5TshzzJISBnz1g+hLGIN X-Received: by 10.101.65.134 with SMTP id a6mr9570922pgq.331.1521478709026; Mon, 19 Mar 2018 09:58:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521478708; cv=none; d=google.com; s=arc-20160816; b=C8Q7xsft+/+eQTd5DLNY2hCsS2gwKlrXJdh4RLHW7GMLjlR86qNF+phowmf/E8b1vw XO3d1Rs55ud/yecDsZGXqA+td+NmSWpat5UPFJxqFm8Bfoxn0O3o/+R52VJ7YW8Lz+B/ d82XxpLhFEZXIup506C655NCRYmteyz/4fdAF1t/K29WUeN9m8PvoGfz6UCnmqj/C13Z fNKu7fE99AY3qA3V99zsp6/jRPGgsAshWs5zpNUSHVZQifB3Jt5Ksr3LTQGVRQkgVwYo mi4GvqYZOAAR8J/MK88lTgeYA8F1JIbvUUR7WV+sqUvFuE2lInEvMDGJ+TWqTHADF8Ju Hsug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=jSIvbt/0CJH+EQL3JckLhcV3xRF3RUDafsi/M7UhFQ4=; b=qx/OvXa/pjrqoodP9iOMwclzT9wVJvcdIVntUkMWibEfyQvufsLOdpXU21DLnU/PYV E5/3YGPBcIhJD43egw77MO8yUQRBfIPoRoLglQm1uKFKBVg44D3jzVLaIbvJ45dIJrgB DkHyCUKHywIQ+fLcKJdYyip7yrK3rMtRlIVpccML/LBrdS3X2JKs1eXfljtgvUWv9dml oS8nFni+z+plvuow9m8eu0okhEL4YY7hihi6whZM/s5iCaFsv61rVcsNVM/5s/iTOBC0 596qi4YhNZGaxgwDoyLs5pqabsA+N8WTvgHTYUhRkQd2xgCuIpjl6YXMP9S55ss8oy6n oxNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=dbAYWAUq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i12-v6si288578plk.508.2018.03.19.09.58.14; Mon, 19 Mar 2018 09:58:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=dbAYWAUq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967661AbeCSQ4e (ORCPT + 99 others); Mon, 19 Mar 2018 12:56:34 -0400 Received: from mail-dm3nam03on0111.outbound.protection.outlook.com ([104.47.41.111]:6417 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S966752AbeCSQL3 (ORCPT ); Mon, 19 Mar 2018 12:11:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=jSIvbt/0CJH+EQL3JckLhcV3xRF3RUDafsi/M7UhFQ4=; b=dbAYWAUqObtT9bnQT/F5Iw+emtCDD3dRW6Nz1KY5W1M6n8mWstSZgQHPwIH0HZ/NIqSC2Iil2rL5iz8GcIFmn+nAB8z7RZbA6rkg2wt8Z5dpVfs9Nj2S1gcFZhKoeQmALHUXoZb+QLo5vb46BXJIRs8nRn+YgGTran5os4cu+Ao= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0805.namprd21.prod.outlook.com (10.167.105.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.631.2; Mon, 19 Mar 2018 16:11:27 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::3d9b:79e7:94eb:5d62]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::3d9b:79e7:94eb:5d62%5]) with mapi id 15.20.0631.004; Mon, 19 Mar 2018 16:11:27 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: David Lechner , Stephen Boyd , Sasha Levin Subject: [PATCH AUTOSEL for 4.4 163/167] clk: fix reentrancy of clk_enable() on UP systems Thread-Topic: [PATCH AUTOSEL for 4.4 163/167] clk: fix reentrancy of clk_enable() on UP systems Thread-Index: AQHTv5yQ+Ey0MovVY0+Ieju5xrvkPA== Date: Mon, 19 Mar 2018 16:08:47 +0000 Message-ID: <20180319160513.16384-163-alexander.levin@microsoft.com> References: <20180319160513.16384-1-alexander.levin@microsoft.com> In-Reply-To: <20180319160513.16384-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB0805;7:qq2Nz3rTqWrv+3hDRWW8R2b3T9ItSy/xDKPiV3gX4qWm45K7Tsd+wqSIqEcPArVpOEN5mjDsLGHwROrf8DyfhedcndjRSwQ7lSAMzyyBK2/rAAcQyQeAQsFFew++lxFkyNeA6IPH649rwhN+jWuXFC1nXdTIYG24Ien0xsIIBUa2r5QBCERPuv0LBHXuC1a4mm2NKgynU1a6EcRzGqacIMmkjzi0V41jj5L4pN9mll330ac+sCmfRy8yj49SFuOL;20:pXpzvl43ZwgLESvkrjHy7Il0a96VCTe3PJOcDOQwmHqMb0B5Z4NNdFrBmWwuuXkG5riVEskOcugC1rF/YUeoasI09SPED3qI4ggHzB5QG+xw1XyNXyyNg1q6fmYNxFeLgPxCwv9udWllMibnUxJPKZp95MEp7cLLArTIGYtiX8U= x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: d6ba3f88-11dd-41b2-a240-08d58db411ae x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0805; x-ms-traffictypediagnostic: DM5PR2101MB0805: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(3231221)(944501300)(52105095)(3002001)(6055026)(61426038)(61427038)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(20161123558120)(20161123560045)(6072148)(201708071742011);SRVR:DM5PR2101MB0805;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0805; x-forefront-prvs: 06167FAD59 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39380400002)(376002)(346002)(366004)(396003)(39860400002)(199004)(189003)(575784001)(2950100002)(305945005)(186003)(86362001)(6506007)(3660700001)(6666003)(5660300001)(6116002)(8936002)(3846002)(1076002)(26005)(7736002)(6486002)(2900100001)(6436002)(2906002)(86612001)(68736007)(81166006)(81156014)(10090500001)(102836004)(59450400001)(8676002)(14454004)(105586002)(107886003)(25786009)(478600001)(2501003)(5250100002)(53936002)(3280700002)(316002)(54906003)(4326008)(6512007)(72206003)(66066001)(22452003)(10290500003)(99286004)(76176011)(36756003)(97736004)(106356001)(110136005)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0805;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: gPQr7R4JS00GmLQC5JzL06hyMJSncNpnuhq2eUmrTaOuuTHO2VwfLJadDEIvAfolG/JNM34UDu1KCfGm7yTsuCJKdAzKLoQ4v1uaDyNYStP+xcDdVilvgbfnUOc0WVAUGr8raOjFqfZPUHWyEJAIOVqjbLlp9BQTffguh+SstFTX1qMThuRk1YyhoIXTBwGPetUq7fInBOSWGiWqNPuYHrD2S2IoNJtYkSZltH/jjJwCT5By+nKyrbFgB2X6Pw+jQsslbERpjOGHlo5kmb6vsTpFMti7RiXdaVrsOEbXc+2dVLumdT6zGvicNc9Jy6ul5sDj3M4BetsgMqwk76ZV/A== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: d6ba3f88-11dd-41b2-a240-08d58db411ae X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Mar 2018 16:08:47.9831 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0805 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: David Lechner [ Upstream commit a12aa8a68dfef5de181f2e555aa950a0ab05411f ] Reentrant calls to clk_enable() are not working on UP systems. This is caused by the fact spin_trylock_irqsave() always returns true when CONFIG_SMP=3Dn (and CONFIG_DEBUG_SPINLOCK=3Dn) which causes the reference counting to not work correctly when clk_enable_lock() is called twice before clk_enable_unlock() is called (this happens when clk_enable() is called from within another clk_enable()). This fixes the problem by skipping the call to spin_trylock_irqsave() on UP systems and relying solely on reference counting. We also make sure to set flags in this case so that we are not returning an uninitialized value. Suggested-by: Stephen Boyd Signed-off-by: David Lechner Signed-off-by: Stephen Boyd Signed-off-by: Sasha Levin --- drivers/clk/clk.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index f13c3f4228d4..a20538c4c2fa 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -119,10 +119,18 @@ static unsigned long clk_enable_lock(void) { unsigned long flags; =20 - if (!spin_trylock_irqsave(&enable_lock, flags)) { + /* + * On UP systems, spin_trylock_irqsave() always returns true, even if + * we already hold the lock. So, in that case, we rely only on + * reference counting. + */ + if (!IS_ENABLED(CONFIG_SMP) || + !spin_trylock_irqsave(&enable_lock, flags)) { if (enable_owner =3D=3D current) { enable_refcnt++; __acquire(enable_lock); + if (!IS_ENABLED(CONFIG_SMP)) + local_save_flags(flags); return flags; } spin_lock_irqsave(&enable_lock, flags); --=20 2.14.1