From patchwork Thu Mar 8 04:56:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 130933 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp6026963lja; Wed, 7 Mar 2018 20:56:15 -0800 (PST) X-Google-Smtp-Source: AG47ELtR66oXI6Crl2Fpb2HXHe0lNLF77f/BEpdFuHgcjyU4CNd0RuUmp78JLvmXBiD3avwyFOWR X-Received: by 2002:a17:902:66e6:: with SMTP id e93-v6mr22848873plk.312.1520484975235; Wed, 07 Mar 2018 20:56:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520484975; cv=none; d=google.com; s=arc-20160816; b=rH9Btfk3K2Oa5vEGHNjxSOppnpGwNPjiApoF3oSd2aWGlRrhaf0my0ej8amPZLAsoo NgCBetwwA5pdp6SCU6l8YqAy7BIzn4BQaAnul9qFv/wwezKa1Hncf/wvKJAe3ptc/1E3 cQbTQFsrkd8hQT7oaNAKip94g5VpAA0CUu0th8Nv6mEqo0FePwJmX1RKXt2ajMpQcPpH lUJx7ITA8jW8+KYkbSz5myxUs29opC1DOb8l645PVF3vSQYi2r3F6sYmImVrE6V58uWa cvk2dbNJ/ooZMOkAB1XoYJ/XCIrmlsnaZ3EQnhoLIy+cX9Cg16HIbm+XpOAnwinO3Fln SnQw== 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=/1GXPH5nmS0CMQNJxf7FGYSpOEHTE3q8ZMHXbucL+3w=; b=mcOxKoHzKonsb0AZqpWpA1l+jYFBIrMqTHA/YM62z2BKtm2Yh+0XNvcswNVWpfjevv ySPybhkm0n3f6BQLHWKvXzFARP7VVkplzx9Wvj8ouRPfUp4WpSVeyTOhKsK/bBaWH1XR 7d3R4VZ+Ty6tNzlsHnLs/6gkMaC90RmDe+R70WQ9QjFV2c7v4ye4PoL5vE32cEemUX+u N9PNsveldRt4DsVRzw1xvp8PmGx1RXWjtMbZx62zDSq8t7rkMq6uJPpfb6FJmk6yfrGR 1ZoBkPuVFmruM3jgVpOJ4r2wOsoAHSudLJ3zyaoFsPJQAwdDs7iTHGCSXV9xh2vbstJ5 oBJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=XURpB+Qg; 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 1-v6si14214196pla.496.2018.03.07.20.56.14; Wed, 07 Mar 2018 20:56:15 -0800 (PST) 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=XURpB+Qg; 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 S1755081AbeCHE4J (ORCPT + 28 others); Wed, 7 Mar 2018 23:56:09 -0500 Received: from mail-by2nam03on0095.outbound.protection.outlook.com ([104.47.42.95]:43489 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754997AbeCHE4F (ORCPT ); Wed, 7 Mar 2018 23:56:05 -0500 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=/1GXPH5nmS0CMQNJxf7FGYSpOEHTE3q8ZMHXbucL+3w=; b=XURpB+QgdBQtPZ3Ip8xnRnC4M4Jw95YJsSV1BWBrBpUlXq5T46Pj+6kpZOj+SHpQEkpQHEoeEBwJbqdgM+po4q1QqwyjHkzBI2JnMYbGsT6Akt8XUzFB5RWF1REOr23rX1k7o1YQn25+CMjnxRQWp5iRpfHJQou4y4clokZxpSA= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0902.namprd21.prod.outlook.com (52.132.132.159) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.588.3; Thu, 8 Mar 2018 04:56:02 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8063:c68a:b210:7446]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8063:c68a:b210:7446%2]) with mapi id 15.20.0588.008; Thu, 8 Mar 2018 04:56:02 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Loic Poulain , Marcel Holtmann , Sasha Levin Subject: [PATCH AUTOSEL for 4.15 04/78] Bluetooth: btqcomsmd: Fix skb double free corruption Thread-Topic: [PATCH AUTOSEL for 4.15 04/78] Bluetooth: btqcomsmd: Fix skb double free corruption Thread-Index: AQHTtpnBg/Lz5y61L0awhM+uj730kQ== Date: Thu, 8 Mar 2018 04:56:02 +0000 Message-ID: <20180308045525.7662-4-alexander.levin@microsoft.com> References: <20180308045525.7662-1-alexander.levin@microsoft.com> In-Reply-To: <20180308045525.7662-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; DM5PR2101MB0902; 20:D+Hn7hRlMB1LS8F70bE7x2i/GaZJ0xNs+8v7fFgCtaKEa/wb70LBfodEA5qJTjpRR+3g7ayTmShHN+NgSYst9RkrEqln/D2xR+JLMncTTgSfHmzV2Bb9e0Zq/rQ1OGrE2hieP/KN/b8gynmrMrEsxeYq8jSp174OV1kifA/0DA0= x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 212ed212-170c-4c68-4f44-08d584b0e46a x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020); SRVR:DM5PR2101MB0902; x-ms-traffictypediagnostic: DM5PR2101MB0902: 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)(6040501)(2401047)(5005006)(8121501046)(10201501046)(3002001)(3231220)(944501244)(52105095)(93006095)(93001095)(6055026)(61426038)(61427038)(6041288)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123564045)(20161123558120)(6072148)(201708071742011); SRVR:DM5PR2101MB0902; BCL:0; PCL:0; RULEID:; SRVR:DM5PR2101MB0902; x-forefront-prvs: 060503E79B x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(346002)(39860400002)(39380400002)(376002)(366004)(396003)(189003)(199004)(8936002)(81156014)(81166006)(7736002)(5250100002)(8676002)(99286004)(26005)(107886003)(186003)(2950100002)(106356001)(10090500001)(575784001)(305945005)(66066001)(97736004)(2501003)(86362001)(3846002)(3660700001)(72206003)(6436002)(1076002)(6486002)(5660300001)(54906003)(110136005)(68736007)(53936002)(14454004)(36756003)(25786009)(478600001)(10290500003)(6506007)(59450400001)(2900100001)(102836004)(76176011)(6512007)(22452003)(6116002)(316002)(4326008)(105586002)(86612001)(2906002)(3280700002)(22906009)(217873001); DIR:OUT; SFP:1102; SCL:1; SRVR:DM5PR2101MB0902; H:DM5PR2101MB1032.namprd21.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: CsOHPNZbDKzdLZckCtPfImBGPUejEiUNS63PqpB7wnk8Wh+KHmYFC/tYUvjFRQQkjhKOKPDiwueOj/E5SWN3TBVZduHRABxGwUgLJG/db/kdaTcz5BAbkyd3YvtIz0I0s5pgWAz/AEvBdZANhiQ8fW/R4vohbtK5Y0nyOS+OkQ75GeE9BnVbcyNkKvTkNFU9UZw1jXlZtp3UwxPClGTSv9H7/TGm3NitTjetsQfhxWvF9jwF0ptt410y6ofuZ98ap5PBrgQ3yC5IeuJMZz0E4URh9ew/pmpYEFL4KVd6B/Q59q5OoLonzGzg9gc7CntIctYnc4NWD3vBI1KLVvhHqA== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 212ed212-170c-4c68-4f44-08d584b0e46a X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Mar 2018 04:56:02.2725 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0902 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Loic Poulain [ Upstream commit 67b8fbead4685b36d290a0ef91c6ddffc4920ec9 ] In case of hci send frame failure, skb is still owned by the caller (hci_core) and then should not be freed. This fixes crash on dragonboard-410c when sending SCO packet. skb is freed by both btqcomsmd and hci_core. Fixes: 1511cc750c3d ("Bluetooth: Introduce Qualcomm WCNSS SMD based HCI driver") Signed-off-by: Loic Poulain Signed-off-by: Marcel Holtmann Signed-off-by: Sasha Levin --- drivers/bluetooth/btqcomsmd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.14.1 diff --git a/drivers/bluetooth/btqcomsmd.c b/drivers/bluetooth/btqcomsmd.c index 663bed63b871..2c9a5fc9137d 100644 --- a/drivers/bluetooth/btqcomsmd.c +++ b/drivers/bluetooth/btqcomsmd.c @@ -88,7 +88,8 @@ static int btqcomsmd_send(struct hci_dev *hdev, struct sk_buff *skb) break; } - kfree_skb(skb); + if (!ret) + kfree_skb(skb); return ret; } From patchwork Thu Mar 8 04:56:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 130962 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp6125718lja; Wed, 7 Mar 2018 23:02:30 -0800 (PST) X-Google-Smtp-Source: AG47ELtp0Zklde51Q5Ad8C/P0IbeAu+PRMKDV+bEd3hEhq1fhPcOXoeWR07438KTMkWVaBXDEEEJ X-Received: by 2002:a17:902:3183:: with SMTP id x3-v6mr22925351plb.383.1520492549858; Wed, 07 Mar 2018 23:02:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520492549; cv=none; d=google.com; s=arc-20160816; b=bVA0bW2TD/nepkynDuR5YM0ZA6DwR3Cf4hYOF8ogU0aYjnipJ7ItuwHqkf0RWBlB7X JYj30yxxg2eMMq/p48nhG5ch9nNA398BGUCSrTWDq1uh2VqdjZkXeEQ7VSTe+PIPF0Zn BoGchOtFR6y9+W14dIFLSFdlqQLR3LrSln3YeHpzAjAczBwxTA65c7AzkTOw+Uoi8Z9H bkEz/k/YQGf0MjJlmRU2cEsHkwe0JepasrDjjbbvBEMIYrb/3JzqvhuwYXRBpC8lM1ac txaRe7HU2Pbc7T2EarJ7UWD6pUK21CRAtoWRFOBd+B4bMhOpTDc46DjBOUyt2LJUEntj VUCA== 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=NbwClYHcGl2iVLBaur5Np7VVD3WQVd/3TT4LvjP/DLQ=; b=W2UgM0mOpumGJ4vhLSUBuv/+vkCxKUkxXpbr+dw9zGPY3v5N/Bx6uPfMJCumYAk/mV ee9x8xq9wvkDv02LgIcTFWKA7JOScC6wkJYO1l/4qe7JQqkCUOE2WnBls2thqZ9apFIb qr0jAbY65LQHIuavK+pRpmdHTdLZqwDdivF7bOtCB9eYVFjo7W3fTyDDLEYM8uuC0ADR X/GThK/QJcq8JfcCvw6G003XERXyfLf2PtSnzE2gXe9Nbdp21pcx5cm4bII+muLaNmQe VdlL1OokEH67yZ/TSKk6qOAoFaMxWu9tqJdAJwJj7dnlLC3l5IQc4zq1RFMiVruR6LAH Pcdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=ZHu7J3na; 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 v4si12466527pgt.83.2018.03.07.23.02.29; Wed, 07 Mar 2018 23:02:29 -0800 (PST) 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=ZHu7J3na; 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 S934873AbeCHE5M (ORCPT + 28 others); Wed, 7 Mar 2018 23:57:12 -0500 Received: from mail-bn3nam01on0102.outbound.protection.outlook.com ([104.47.33.102]:13054 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755212AbeCHE5I (ORCPT ); Wed, 7 Mar 2018 23:57:08 -0500 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=NbwClYHcGl2iVLBaur5Np7VVD3WQVd/3TT4LvjP/DLQ=; b=ZHu7J3najXAYEWNjxKpZEmVwnWVq4A2IasoQ+k9snf8etI5E2gY/PQNTP8G5YbRKpP/P8w0Ym1aMc2OdR/mFZznjSUdjxhR+aq0UljVYd90k/W0020loTzyPLOtRlei7AvWwOgn0alOvaf9+vgQI0957G1Nq7o4M7ikr6S4kl6E= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1079.namprd21.prod.outlook.com (52.132.130.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.588.3; Thu, 8 Mar 2018 04:57:04 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8063:c68a:b210:7446]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8063:c68a:b210:7446%2]) with mapi id 15.20.0588.008; Thu, 8 Mar 2018 04:57:04 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Jerome Brunet , "David S . Miller" , Sasha Levin Subject: [PATCH AUTOSEL for 4.15 36/78] net: phy: meson-gxl: check phy_write return value Thread-Topic: [PATCH AUTOSEL for 4.15 36/78] net: phy: meson-gxl: check phy_write return value Thread-Index: AQHTtpnKj1bzUDm9ckao0zJwpMWJ8A== Date: Thu, 8 Mar 2018 04:56:17 +0000 Message-ID: <20180308045525.7662-36-alexander.levin@microsoft.com> References: <20180308045525.7662-1-alexander.levin@microsoft.com> In-Reply-To: <20180308045525.7662-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; DM5PR2101MB1079; 7:LDmgMeLCNkdCeIxdXzUEhFU9B0JiKQGeKgzFS2WdqjdZXOE/mGqCpjz+Ca0/MNOI6fQZAR2j8F7mJDrjo7IxBT6HqB6Y7/3OUnjICUCXtFWjbZfmmzUXl5H6L44oxXG/qjBzdfCbmi/ljn/2LVw4+BkLiwFcfOBtuHuxmsJfVO2vlVU4O5sVrqG1F4QPRgr3+0aqQoFjgYVGycEotgqGO4nv8metKAn84y2oXGWDVgsUY+2wXkjZ6mVoG92+p2Cf; 20:Crwx0ZDTHXaF1XSbIs4HGyBeMzSJ1Da26mE1FCyQbPjg04xzy/PY1LIKN0cELWq8XWCzNlb9nDzdW3qohEp2FDs3SsNRApQwHIFERwQXeyhOPymFg/4LYw94X86FZJQ1zPc+zB343SOalb4HDojOR1qkOCzatbSXi9aHBaEPc6I= x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: f39dd92f-7ccd-45a8-3ab8-08d584b1094f x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020); SRVR:DM5PR2101MB1079; x-ms-traffictypediagnostic: DM5PR2101MB1079: 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)(6040501)(2401047)(8121501046)(5005006)(3231220)(944501244)(52105095)(93006095)(93001095)(10201501046)(3002001)(6055026)(61426038)(61427038)(6041288)(20161123564045)(20161123560045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(6072148)(201708071742011); SRVR:DM5PR2101MB1079; BCL:0; PCL:0; RULEID:; SRVR:DM5PR2101MB1079; x-forefront-prvs: 060503E79B x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(376002)(39860400002)(39380400002)(396003)(346002)(366004)(189003)(199004)(36756003)(107886003)(4326008)(97736004)(2906002)(2950100002)(1076002)(6666003)(105586002)(7736002)(186003)(3660700001)(5660300001)(106356001)(305945005)(6512007)(3280700002)(25786009)(14454004)(575784001)(86362001)(86612001)(81156014)(10090500001)(76176011)(26005)(99286004)(66066001)(102836004)(110136005)(81166006)(72206003)(54906003)(5250100002)(478600001)(59450400001)(10290500003)(6116002)(2501003)(8936002)(68736007)(53936002)(6506007)(6486002)(8676002)(6436002)(3846002)(22452003)(316002)(2900100001)(22906009)(217873001); DIR:OUT; SFP:1102; SCL:1; SRVR:DM5PR2101MB1079; H:DM5PR2101MB1032.namprd21.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: trZsldvG004wsoXW1HQmlt9JxJLkm4aABWXE6eV5T/Ew7GUb9jfomcEBS+s74eVy+XVRDZZJgj4z6SRday5+mnNEfcVFFd40hma/b5WvbaaLPS2i6Wy/Zga5A2dWxYZ3UefSPv6PHSJ1K85yGexje+HGKhvUPGM/fKT41lGdGdQxXPoO9D2Wvqwr6k5DjlqQh6lGmxaY/QUY+MAiyLvoNNeqQ0cZqaqx9BbaSBNAMD7XoJjQ/fM4zgzqfzmJ6yPgX32sYy4KZfopjKbmc30WMUaGzgwi2kuQtHcBcLA5UaJqotnzUZ6hqkMHSSNh6L64emK63HSrY7d2AR0YW+8E0A== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: f39dd92f-7ccd-45a8-3ab8-08d584b1094f X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Mar 2018 04:56:17.3480 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1079 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jerome Brunet [ Upstream commit 9042b46eda33ef5db3cdfc9e12b3c8cabb196141 ] Always check phy_write return values. Better to be safe than sorry Reviewed-by: Andrew Lunn Signed-off-by: Jerome Brunet Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/phy/meson-gxl.c | 50 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 38 insertions(+), 12 deletions(-) -- 2.14.1 diff --git a/drivers/net/phy/meson-gxl.c b/drivers/net/phy/meson-gxl.c index 842eb871a6e3..f431c83ba0b5 100644 --- a/drivers/net/phy/meson-gxl.c +++ b/drivers/net/phy/meson-gxl.c @@ -26,27 +26,53 @@ static int meson_gxl_config_init(struct phy_device *phydev) { + int ret; + /* Enable Analog and DSP register Bank access by */ - phy_write(phydev, 0x14, 0x0000); - phy_write(phydev, 0x14, 0x0400); - phy_write(phydev, 0x14, 0x0000); - phy_write(phydev, 0x14, 0x0400); + ret = phy_write(phydev, 0x14, 0x0000); + if (ret) + return ret; + ret = phy_write(phydev, 0x14, 0x0400); + if (ret) + return ret; + ret = phy_write(phydev, 0x14, 0x0000); + if (ret) + return ret; + ret = phy_write(phydev, 0x14, 0x0400); + if (ret) + return ret; /* Write Analog register 23 */ - phy_write(phydev, 0x17, 0x8E0D); - phy_write(phydev, 0x14, 0x4417); + ret = phy_write(phydev, 0x17, 0x8E0D); + if (ret) + return ret; + ret = phy_write(phydev, 0x14, 0x4417); + if (ret) + return ret; /* Enable fractional PLL */ - phy_write(phydev, 0x17, 0x0005); - phy_write(phydev, 0x14, 0x5C1B); + ret = phy_write(phydev, 0x17, 0x0005); + if (ret) + return ret; + ret = phy_write(phydev, 0x14, 0x5C1B); + if (ret) + return ret; /* Program fraction FR_PLL_DIV1 */ - phy_write(phydev, 0x17, 0x029A); - phy_write(phydev, 0x14, 0x5C1D); + ret = phy_write(phydev, 0x17, 0x029A); + if (ret) + return ret; + ret = phy_write(phydev, 0x14, 0x5C1D); + if (ret) + return ret; /* Program fraction FR_PLL_DIV1 */ - phy_write(phydev, 0x17, 0xAAAA); - phy_write(phydev, 0x14, 0x5C1C); + ret = phy_write(phydev, 0x17, 0xAAAA); + if (ret) + return ret; + ret = phy_write(phydev, 0x14, 0x5C1C); + if (ret) + return ret; return 0; } From patchwork Thu Mar 8 04:56:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 130960 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp6122306lja; Wed, 7 Mar 2018 22:59:07 -0800 (PST) X-Google-Smtp-Source: AG47ELv/k3PTZ/PT/cz0aZ8D9kMT7h/VjeX0fNOXudkvOufxxEnpnDP+qUXJVRAt9aL5pcPGmTit X-Received: by 10.99.116.28 with SMTP id p28mr20455645pgc.306.1520492347350; Wed, 07 Mar 2018 22:59:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520492347; cv=none; d=google.com; s=arc-20160816; b=YnByApbMjPopdytx1NMYrSaAntushjFuyfFxtC82ovd6yXUvqo35WCv5DSy2S/N/Ej l9IAvgO5iclU8osmA7DncESw/c+CpAgiBTaTsTb4gFdSOayYfl74zICqDM/qO10H6hgj PKZ/9NA89PlGIB33+jeNxBU7UsPpwQCp68UEY1H38WCrD3CBVFWNQfgIXTi1859EamgO YiBVmOOJeIEkBOYu1gETU4wMGvNdTscGhwpQrSJkaZTfg20PsBlJNRO26Iv64nm7kzTB q390RE70Vv/85PBVSZRqbi9xtYtBU2BkL50UeGroUF4XWMF0HWrtoqmUdTfLIXRWozzT iIFQ== 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=Wf2jXcVZOT2Z9mBzrfGCRvJb5+7RE+3B4jxCzN4Z4G8=; b=ENxQnFVjquaPqICICeChZjCgzAkgkdMcCpywCdLJ27Iq1j5S/3qpBVrHYivETw6vJl Ru6nKBX1ymqkqE/9ictru0y8xxbPcQ9U8fqRKAaCqGwCJ4iMQK7n0SA45PCV3fzWfMof mqTEMk4RqGtKelzQew3o7Gv0NLMnUyy1/SjvZQgaeHaABeEr7Bz8I6ZF/4TUAEz70VTT EvgLjUx9RJRKpN1XvVedwJGUbMOZZsnLrj5bFXqL6WHJxuFFfVTHOOE2VABcBuYARic7 c1bCRZBSE8VQNRZrhYmmIRZmPRoEo0N3lDYTd+ONFZRDat4C1Ilz14TTNTsmvwODGGuX 7v3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=hIB0rYy+; 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 q6-v6si14814061pli.790.2018.03.07.22.59.07; Wed, 07 Mar 2018 22:59:07 -0800 (PST) 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=hIB0rYy+; 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 S935047AbeCHE5Y (ORCPT + 28 others); Wed, 7 Mar 2018 23:57:24 -0500 Received: from mail-sn1nam02on0127.outbound.protection.outlook.com ([104.47.36.127]:4352 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934948AbeCHE5R (ORCPT ); Wed, 7 Mar 2018 23:57:17 -0500 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=Wf2jXcVZOT2Z9mBzrfGCRvJb5+7RE+3B4jxCzN4Z4G8=; b=hIB0rYy+Uu6UYs4IzXgBUGE5gVRpXIXcrkUrYlaMo68uzfRdZD+2fWByS4gix7S1j8kpQK0dgg8ErWmswFxN7dwh8WMpQjjTsLhzQyBH9UAADt+2Ul5jMOR65eYhBlCIWfLdXxNnsfpCOsPbpcE+XfSoX4drlcueKYyWJ7HEHbQ= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.588.3; Thu, 8 Mar 2018 04:57:14 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8063:c68a:b210:7446]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8063:c68a:b210:7446%2]) with mapi id 15.20.0588.008; Thu, 8 Mar 2018 04:57:14 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Kishon Vijay Abraham I , Lorenzo Pieralisi , Sasha Levin Subject: [PATCH AUTOSEL for 4.15 53/78] PCI: designware-ep: Fix ->get_msi() to check MSI_EN bit Thread-Topic: [PATCH AUTOSEL for 4.15 53/78] PCI: designware-ep: Fix ->get_msi() to check MSI_EN bit Thread-Index: AQHTtpnPLeG+NGMoa0Okfott0VH1Zg== Date: Thu, 8 Mar 2018 04:56:24 +0000 Message-ID: <20180308045525.7662-53-alexander.levin@microsoft.com> References: <20180308045525.7662-1-alexander.levin@microsoft.com> In-Reply-To: <20180308045525.7662-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; DM5PR2101MB1032; 7:S6Zk066UBoxq5aQ/HqGqAP99BsCWuDc44SVaz4F5xPpAHsXNwqnO8Gk3hGow8U8DDA0r+JKROTOU7IBkj4VgEYyYk/38Qkk5HwdE5C/cSXcSrk5vDwTHMrtsUyUKJnHUjcza5dP6CvIny9HLJ8XnXiCGJCwbLffQuPpkGOodPo1jkXzpAOX1KR+SzwbMK7ncaTJPl/zSY4RQ18SixwcUY7S2tHPOV34FiA770iAJN0YDnKxxHYkPgXRY5sQLTV1+; 20:ihB0P04HExDiRBtdFWOm8Igg93y/aZDV5lED33wU8362CXyLR2A5PiQg0yA3kv9P43Excm6J63MBA6BEmwsKArJeRS9c38P1AFDdgBf5YOSFyvBCNd2tTEW21naWMHytOwUGhu4g0F509kXYL79QFqHbrPJzUFzdG61Cv/xvOgk= x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: bf22de95-8d8c-4d6e-2a63-08d584b10f3d x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020); SRVR:DM5PR2101MB1032; x-ms-traffictypediagnostic: DM5PR2101MB1032: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(180628864354917)(31051911155226)(89211679590171); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(61425038)(6040501)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231220)(944501244)(52105095)(10201501046)(3002001)(6055026)(61426038)(61427038)(6041288)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(6072148)(201708071742011); SRVR:DM5PR2101MB1032; BCL:0; PCL:0; RULEID:; SRVR:DM5PR2101MB1032; x-forefront-prvs: 060503E79B x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(346002)(376002)(39860400002)(39380400002)(366004)(396003)(199004)(189003)(97736004)(36756003)(8936002)(105586002)(2950100002)(2501003)(6666003)(186003)(8676002)(5250100002)(86362001)(2900100001)(3846002)(5660300001)(6116002)(10090500001)(2906002)(7736002)(22452003)(81156014)(26005)(6506007)(1076002)(102836004)(575784001)(81166006)(305945005)(3280700002)(72206003)(110136005)(86612001)(54906003)(99286004)(10290500003)(316002)(107886003)(4326008)(25786009)(68736007)(6486002)(6436002)(6512007)(53936002)(76176011)(66066001)(3660700001)(478600001)(14454004)(106356001)(22906009)(217873001); DIR:OUT; SFP:1102; SCL:1; SRVR:DM5PR2101MB1032; H:DM5PR2101MB1032.namprd21.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: mYyH37HsU38UNZZwyUSVl9y1ULZkOpybQiGYt/99rScrSMEOyPBVEvSpq1ZSbqWexv/Jt+MkjfCSle3x+AblIKqOzqPk3+P1WdHgMfju1qWvDvlG3NYiNRrgZI+0KG6LX0auiSR/AlOGJg/ixLPn3u6tmRqFBu5SYRaG3qRCJw3EYUP0YIzhVq+ZqxuS32e82z4Sgqdd9M6OECTmWyA3Vgp+MYMU1egr8rQo2zqLymFMQlIEFIT10enThS5Hsg30PChWQzzKNwvFY+YNuIbJAM/EHD407U+74WIQxpOHMJtv9XkWH3hzFhTIlf/AnvvkW5ySMOJ+hGOta56kVHNZgQ== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: bf22de95-8d8c-4d6e-2a63-08d584b10f3d X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Mar 2018 04:56:24.7622 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1032 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kishon Vijay Abraham I [ Upstream commit a134a457ed985dca8cce7ac4ea66129ea70eba73 ] ->get_msi() now checks MSI_EN bit in the MSI CAPABILITY register to find whether the host supports MSI instead of using the MSI ADDRESS in the MSI CAPABILITY register. This fixes the issue with the following sequence 'modprobe pci_endpoint_test' enables MSI 'rmmod pci_endpoint_test' disables MSI but MSI address (in EP's capability register) has a valid value 'modprobe pci_endpoint_test no_msi=1' - Since MSI address (in EP's capability register) has a valid value (set during the previous insertion of the module), EP thinks host supports MSI. Fixes: f8aed6ec624f ("PCI: dwc: designware: Add EP mode support") Signed-off-by: Kishon Vijay Abraham I Signed-off-by: Lorenzo Pieralisi Signed-off-by: Sasha Levin --- drivers/pci/dwc/pcie-designware-ep.c | 12 +++--------- drivers/pci/dwc/pcie-designware.h | 1 + 2 files changed, 4 insertions(+), 9 deletions(-) -- 2.14.1 diff --git a/drivers/pci/dwc/pcie-designware-ep.c b/drivers/pci/dwc/pcie-designware-ep.c index d53d5f168363..7c621877a939 100644 --- a/drivers/pci/dwc/pcie-designware-ep.c +++ b/drivers/pci/dwc/pcie-designware-ep.c @@ -197,20 +197,14 @@ static int dw_pcie_ep_map_addr(struct pci_epc *epc, phys_addr_t addr, static int dw_pcie_ep_get_msi(struct pci_epc *epc) { int val; - u32 lower_addr; - u32 upper_addr; struct dw_pcie_ep *ep = epc_get_drvdata(epc); struct dw_pcie *pci = to_dw_pcie_from_ep(ep); - val = dw_pcie_readb_dbi(pci, MSI_MESSAGE_CONTROL); - val = (val & MSI_CAP_MME_MASK) >> MSI_CAP_MME_SHIFT; - - lower_addr = dw_pcie_readl_dbi(pci, MSI_MESSAGE_ADDR_L32); - upper_addr = dw_pcie_readl_dbi(pci, MSI_MESSAGE_ADDR_U32); - - if (!(lower_addr || upper_addr)) + val = dw_pcie_readw_dbi(pci, MSI_MESSAGE_CONTROL); + if (!(val & MSI_CAP_MSI_EN_MASK)) return -EINVAL; + val = (val & MSI_CAP_MME_MASK) >> MSI_CAP_MME_SHIFT; return val; } diff --git a/drivers/pci/dwc/pcie-designware.h b/drivers/pci/dwc/pcie-designware.h index e5d9d77b778e..cb493bcae8b4 100644 --- a/drivers/pci/dwc/pcie-designware.h +++ b/drivers/pci/dwc/pcie-designware.h @@ -101,6 +101,7 @@ #define MSI_MESSAGE_CONTROL 0x52 #define MSI_CAP_MMC_SHIFT 1 #define MSI_CAP_MME_SHIFT 4 +#define MSI_CAP_MSI_EN_MASK 0x1 #define MSI_CAP_MME_MASK (7 << MSI_CAP_MME_SHIFT) #define MSI_MESSAGE_ADDR_L32 0x54 #define MSI_MESSAGE_ADDR_U32 0x58 From patchwork Thu Mar 8 04:56:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 130959 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp6121456lja; Wed, 7 Mar 2018 22:58:06 -0800 (PST) X-Google-Smtp-Source: AG47ELuqm2dfT11k4DISBgVmtTP1mv3SZfg69YSIybqI3HgAT6Wgu6vm4MXo6g25BoXqfDHE4zcZ X-Received: by 2002:a17:902:4827:: with SMTP id s36-v6mr22897363pld.269.1520492285846; Wed, 07 Mar 2018 22:58:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520492285; cv=none; d=google.com; s=arc-20160816; b=LOfu4TWx7kbzqfq9maC/sgz/kHAWXGVDzZ3CL7rgifq6veI8cFjr49NlNwYoKidZ9a 0rgiURkLFBoJ8DNzLy8pdP/OVy8DIWaR2wURkxLxOVRXw8Wah6dCfJ6kzTFH/6xYY6c9 4KZvIotfFI68xyOvUkX1PfV+zuiw3CCkFSJ/fyDo3JFPj0eHzZXOsVpDsVLG+Pcuj033 BWovb2MDSRcDM9L4kxN0BkHsgdENH4Y1LHegLrfRZflejXqjbHXgQV6qxphf6xpNrqt0 xCN0Cn1+Achscz2r2oKYYySyRjCIoT9AzUfdUinU0/JBNNbFOWsSfK0XrVygRuE2oacz vJUw== 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=uN5TA/SyZJwMUSQ49Vvyvk5AnrCWSOXaKlbuFaHdkH0=; b=Vew6uzXsjT2feE8yeVN9GcfNziULc19DpXpfLJuOWBNJjuvkMYT+gcwhkKv54DXM2q xExr/xUIiKggZrdnfUAVOENabuC8a+mD4wCijWKejyHanXD+naRjj7i4Eq60EzUTRBqd xasHO4aZPjdtYe0GJ587hhkWNrDxXrytDddceGY0EwU2bUbMFeb6Lax9YqzwrVmt2Lxa lvNxiAvqUXVpEyl1UQY+9GICTboU8esYpgbXbgS1XV5WKMwxctiOlXs6gm942+GCjuo3 flnKtvcRxL5vLP7CVNbv+Eb2I367WAmSuCuRYxRapX/Be/+fbVHUQgYO5NZXu3javR1N W4mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=l/ls2EkH; 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 i70si12641077pgc.264.2018.03.07.22.58.05; Wed, 07 Mar 2018 22:58:05 -0800 (PST) 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=l/ls2EkH; 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 S965194AbeCHG6D (ORCPT + 28 others); Thu, 8 Mar 2018 01:58:03 -0500 Received: from mail-sn1nam02on0119.outbound.protection.outlook.com ([104.47.36.119]:9666 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S935053AbeCHE50 (ORCPT ); Wed, 7 Mar 2018 23:57:26 -0500 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=uN5TA/SyZJwMUSQ49Vvyvk5AnrCWSOXaKlbuFaHdkH0=; b=l/ls2EkH90WlbR47tSv8cAWduDwWQ5vcoo3Hv4F/lzZWRCkO9Rusc1yUai2xvTmbJacL7h8XSh+OSLGhgA/MxXg37UB1FumsbpTQ/D/qsUC7CAGhBoSOWtzOSO/rbhZiu9OlpxTs/3WzVKLkpAGiGXOkW25lx51szwfEuIsXDpI= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.588.3; Thu, 8 Mar 2018 04:57:16 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8063:c68a:b210:7446]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8063:c68a:b210:7446%2]) with mapi id 15.20.0588.008; Thu, 8 Mar 2018 04:57:16 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Jerome Brunet , Michael Turquette , Sasha Levin Subject: [PATCH AUTOSEL for 4.15 59/78] clk: use round rate to bail out early in set_rate Thread-Topic: [PATCH AUTOSEL for 4.15 59/78] clk: use round rate to bail out early in set_rate Thread-Index: AQHTtpnQSzrgscDpe0KxX935nC77iA== Date: Thu, 8 Mar 2018 04:56:27 +0000 Message-ID: <20180308045525.7662-59-alexander.levin@microsoft.com> References: <20180308045525.7662-1-alexander.levin@microsoft.com> In-Reply-To: <20180308045525.7662-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; DM5PR2101MB1032; 7:q/VXbi1zbX5tce0mdXdciqeGYOjcrEhHXOTfV5NZkeWtQcVpzYnut/9B9hlciRJuGZjpeWvsQkUsYqO9un+rDXHQ/OTLSF6R47MZkoEXbClh3GazUxH73q+1lSOyGR08WfNVIRTb1AUMVexMeTEvJxfRbrbt8EFEWdLQNoibb2JrPjBIxYCnlaI9NrExbOiLsBocHdGURuGSIO6tLXOYIQZsefH1vPYP/T1kxiVQV3yNdy8btT1wEjpXkNRofcWc; 20:wmUJWK/w0pgIcH6tLw653nwdKXWKjZkPMgXTZoxRq2hEflouHvIVg/YQ/XLmqLQsvU8pmwRF9yqmp23Tf5zyMhdjPP7FNOR5sNDSVz3/nRyOL1F6dw8dPqhn7a4vJd1zUTjfXEruIJYZMNjzWJwikSc2tzuV1fQ3n14zjv8jQWA= x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 89281b8e-1632-442b-2d65-08d584b110bf x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020); SRVR:DM5PR2101MB1032; x-ms-traffictypediagnostic: DM5PR2101MB1032: 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)(58145275503218)(42068640409301); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(61425038)(6040501)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231220)(944501244)(52105095)(10201501046)(3002001)(6055026)(61426038)(61427038)(6041288)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(6072148)(201708071742011); SRVR:DM5PR2101MB1032; BCL:0; PCL:0; RULEID:; SRVR:DM5PR2101MB1032; x-forefront-prvs: 060503E79B x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(346002)(376002)(39860400002)(39380400002)(366004)(396003)(199004)(189003)(97736004)(36756003)(8936002)(105586002)(2950100002)(2501003)(6666003)(186003)(8676002)(5250100002)(86362001)(2900100001)(3846002)(5660300001)(6116002)(10090500001)(2906002)(7736002)(22452003)(81156014)(26005)(6506007)(1076002)(102836004)(59450400001)(81166006)(305945005)(3280700002)(72206003)(110136005)(86612001)(54906003)(99286004)(10290500003)(316002)(107886003)(4326008)(25786009)(68736007)(6486002)(6436002)(6512007)(53936002)(76176011)(66066001)(3660700001)(478600001)(14454004)(106356001)(22906009)(217873001); DIR:OUT; SFP:1102; SCL:1; SRVR:DM5PR2101MB1032; H:DM5PR2101MB1032.namprd21.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: 582KmFuuUnTbWQ+c5v3ZQLQu1QL6xXHkjLWX2W1nf0jCWYfE7DQl4O/LwUSTsMNebDf2cbw3SU+kmFB8VpmeqNkjTVJJbOowIt48MQI9ctMZw9Qhn4me7V2Tsk3vkcAq0x1J1XJskYr6GiR2JVDKcS0jVTTuRX4m2Opb7rQoTx/exLJoyec/ASzTs6r+VQIBh4XPrFEDzVF9L6pvZqcPlFXmNKacQ0sYo0e5FqMDwBXBR24AfXN//8dypSNM4seiWmKrWSBFkPmWqm7RI1QUtplKPbIH/g6aDpAVIGnDbqQZXEhAiktpg9XPXdO3ZuMOecXze6fr4YPoaKXn0akRhA== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 89281b8e-1632-442b-2d65-08d584b110bf X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Mar 2018 04:56:27.2459 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1032 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jerome Brunet [ Upstream commit ca5e089a32c5ffba6c5101fdabdd6dea18041c34 ] The current implementation of clk_core_set_rate_nolock() bails out early if the requested rate is exactly the same as the one set. It should bail out if the request would not result in a rate a change. This is important when the rate is not exactly what is requested, which is fairly common with PLLs. Ex: provider able to give any rate with steps of 100Hz - 1st consumer request 48000Hz and gets it. - 2nd consumer request 48010Hz as well. If we were to perform the usual mechanism, we would get 48000Hz as well. The clock would not change so there is no point performing any checks to make sure the clock can change, we know it won't. This is important to prepare the addition of the clock protection mechanism Acked-by: Linus Walleij Tested-by: Quentin Schulz Tested-by: Maxime Ripard Acked-by: Michael Turquette Signed-off-by: Jerome Brunet Signed-off-by: Michael Turquette Link: lkml.kernel.org/r/20171201215200.23523-6-jbrunet@baylibre.com Signed-off-by: Sasha Levin --- drivers/clk/clk.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) -- 2.14.1 diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 12180049a42a..0cca063f70e7 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -1642,16 +1642,37 @@ static void clk_change_rate(struct clk_core *core) clk_pm_runtime_put(core); } +static unsigned long clk_core_req_round_rate_nolock(struct clk_core *core, + unsigned long req_rate) +{ + int ret; + struct clk_rate_request req; + + lockdep_assert_held(&prepare_lock); + + if (!core) + return 0; + + clk_core_get_boundaries(core, &req.min_rate, &req.max_rate); + req.rate = req_rate; + + ret = clk_core_round_rate_nolock(core, &req); + + return ret ? 0 : req.rate; +} + static int clk_core_set_rate_nolock(struct clk_core *core, unsigned long req_rate) { struct clk_core *top, *fail_clk; - unsigned long rate = req_rate; + unsigned long rate; int ret = 0; if (!core) return 0; + rate = clk_core_req_round_rate_nolock(core, req_rate); + /* bail early if nothing to do */ if (rate == clk_core_get_rate_nolock(core)) return 0; @@ -1660,7 +1681,7 @@ static int clk_core_set_rate_nolock(struct clk_core *core, return -EBUSY; /* calculate new rates and get the topmost changed clock */ - top = clk_calc_new_rates(core, rate); + top = clk_calc_new_rates(core, req_rate); if (!top) return -EINVAL;