From patchwork Wed Jan 4 13:06:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Schultz X-Patchwork-Id: 38914 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp5135947wrt; Wed, 4 Jan 2023 05:13:11 -0800 (PST) X-Google-Smtp-Source: AMrXdXtBm9zfO03CDOxrugUL4NzRpQ6ZnA3vBW3BLBaaa7Lmk4w9gkUoHTNVb+n5AJ86NxMIH73v X-Received: by 2002:a05:6402:3894:b0:48f:68b1:db4e with SMTP id fd20-20020a056402389400b0048f68b1db4emr1246906edb.27.1672837991056; Wed, 04 Jan 2023 05:13:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672837991; cv=none; d=google.com; s=arc-20160816; b=N4i+PrEJU+h7gneQILQ5joX2cR0NVVO4+ceVfZYLq/TQ3tKIAXhdS0UVmZJzADNX5V k/eVNqcjNk9RKzHFIT+gKHIXJEFf8raHiPhcWS5GDNuYU7sPcAOATyb6QwFDSKwFHDXF cvLC72MAEgjUsOEjW7kbzz7lci5nOsHrQ7keoo8DGKfjkk8a54IkvkURAEUoTuDdWObw GvFF1X+lwsOoVFaOMHYzDit2JAKNhgcLWVhQwXQGL5Rq3qaiY9+a/mT2U3/ub6ubU/UN VUoAGm66hkBT3Zmj9RQFpjcKDY+Zuj5q52sig4bpU5OTaONat1cwikzaArzhJirQXqVt +ruA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:organization :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=h51pJH6cHzodeoqh2MviDY7bEHKSym5zwv8IArnirvs=; b=BAeJQIq7XZBv3ziu/CCyIT1d1vw4SMGxODOkvQWHNvWw6u7zEBi4auyY7hPMFQzj/w jeOYotP6clKUH5a4NGcjEyZdWr/Q7mIgiNP2rFCBvq66sQTBv0LkV68bcB3beLdEncBg g/d2hIUWvkWLZfEdCjVmWgOU7I0OaYR5PhyGs1e4prCT3h8IST3+OiV6/cE1B+OekfBe 6avoBsMS1BysfDV06LzrhS9qM24jPf9SUMDApc1b68gK07PWFkhAgHsib/FFlwERm/WS 9Yy2d/u4jb7E857a2ps2ktev5R9kYmLaaksXuSZYlFptdSwlSfXRrtP7Mi33LuYNlbMh 4XoA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w13-20020a50fa8d000000b0046b1c4b8199si28561608edr.82.2023.01.04.05.12.47; Wed, 04 Jan 2023 05:13:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239372AbjADNJ1 (ORCPT + 99 others); Wed, 4 Jan 2023 08:09:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239398AbjADNIn (ORCPT ); Wed, 4 Jan 2023 08:08:43 -0500 Received: from mailout-taastrup.gigahost.dk (mailout-taastrup.gigahost.dk [46.183.139.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1371D1EC47; Wed, 4 Jan 2023 05:07:40 -0800 (PST) Received: from mailout.gigahost.dk (mailout.gigahost.dk [89.186.169.112]) by mailout-taastrup.gigahost.dk (Postfix) with ESMTP id 35AD31884546; Wed, 4 Jan 2023 13:07:38 +0000 (UTC) Received: from smtp.gigahost.dk (smtp.gigahost.dk [89.186.169.109]) by mailout.gigahost.dk (Postfix) with ESMTP id 14CB7250007B; Wed, 4 Jan 2023 13:07:38 +0000 (UTC) Received: by smtp.gigahost.dk (Postfix, from userid 1000) id 024879EC000E; Wed, 4 Jan 2023 13:07:37 +0000 (UTC) X-Screener-Id: 413d8c6ce5bf6eab4824d0abaab02863e8e3f662 Received: from fujitsu.vestervang (2-104-116-184-cable.dk.customer.tdc.net [2.104.116.184]) by smtp.gigahost.dk (Postfix) with ESMTPSA id A8A8491201E4; Wed, 4 Jan 2023 13:07:37 +0000 (UTC) From: "Hans J. Schultz" To: davem@davemloft.net, kuba@kernel.org Cc: netdev@vger.kernel.org, "Hans J. Schultz" , Andrew Lunn , Florian Fainelli , Vladimir Oltean , Eric Dumazet , Paolo Abeni , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 net-next 2/3] net: dsa: mv88e6xxx: disable hold of chip lock for handling Date: Wed, 4 Jan 2023 14:06:02 +0100 Message-Id: <20230104130603.1624945-3-netdev@kapio-technology.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230104130603.1624945-1-netdev@kapio-technology.com> References: <20230104130603.1624945-1-netdev@kapio-technology.com> MIME-Version: 1.0 Organization: Westermo Network Technologies AB X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754097769489915254?= X-GMAIL-MSGID: =?utf-8?q?1754097769489915254?= As functions called under the interrupt handler will need to take the netlink lock, we need to release the chip lock before calling those functions as otherwise double lock deadlocks will occur as userspace calls towards the driver often take the netlink lock and then the chip lock. The deadlock would look like: Interrupt handler: chip lock taken, but cannot take netlink lock as userspace config call has netlink lock. Userspace config: netlink lock taken, but cannot take chip lock as the interrupt handler has the chip lock. Signed-off-by: Hans J. Schultz --- drivers/net/dsa/mv88e6xxx/global1_atu.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/net/dsa/mv88e6xxx/global1_atu.c b/drivers/net/dsa/mv88e6xxx/global1_atu.c index 61ae2d61e25c..34203e112eef 100644 --- a/drivers/net/dsa/mv88e6xxx/global1_atu.c +++ b/drivers/net/dsa/mv88e6xxx/global1_atu.c @@ -409,11 +409,11 @@ static irqreturn_t mv88e6xxx_g1_atu_prob_irq_thread_fn(int irq, void *dev_id) err = mv88e6xxx_g1_read_atu_violation(chip); if (err) - goto out; + goto out_unlock; err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_ATU_OP, &val); if (err) - goto out; + goto out_unlock; err = mv88e6xxx_g1_atu_fid_read(chip, &fid); if (err) @@ -421,11 +421,13 @@ static irqreturn_t mv88e6xxx_g1_atu_prob_irq_thread_fn(int irq, void *dev_id) err = mv88e6xxx_g1_atu_data_read(chip, &entry); if (err) - goto out; + goto out_unlock; err = mv88e6xxx_g1_atu_mac_read(chip, &entry); if (err) - goto out; + goto out_unlock; + + mv88e6xxx_reg_unlock(chip); spid = entry.state; @@ -449,13 +451,13 @@ static irqreturn_t mv88e6xxx_g1_atu_prob_irq_thread_fn(int irq, void *dev_id) fid); chip->ports[spid].atu_full_violation++; } - mv88e6xxx_reg_unlock(chip); return IRQ_HANDLED; -out: +out_unlock: mv88e6xxx_reg_unlock(chip); +out: dev_err(chip->dev, "ATU problem: error %d while handling interrupt\n", err); return IRQ_HANDLED;