From patchwork Fri Jan 6 16:05:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Schultz X-Patchwork-Id: 40185 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp899848wrt; Fri, 6 Jan 2023 08:08:15 -0800 (PST) X-Google-Smtp-Source: AMrXdXvjEGbQZvVTIEpNekF6RVmitXYk0Sk8mF/Xr15VH/N4AFp8ihpnoI7eaOctMhcyEI0kQUDL X-Received: by 2002:a17:907:80ca:b0:7c1:540c:e214 with SMTP id io10-20020a17090780ca00b007c1540ce214mr50761321ejc.47.1673021295385; Fri, 06 Jan 2023 08:08:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673021295; cv=none; d=google.com; s=arc-20160816; b=v3hdtoii+MCJcv0bfCBofj07B+/zvb9DL605K6iWCbfNpvWas5+K+gHMBhP+Ybqoo1 IR2gy7AP5noWKAPfMGGrWL2Tmx3GcM2zS0mLIX23+K4UOzNEx+uIj29CXnk7XL8919Z/ 3Rj5rEBgz9S8YSOv+CNZIte6I98GgGRdHb0naUaVsMoA5z/VUIU527Ji288GfKeFP8eI rzn9i8SsDSibqhYtKWZTJn9hyKjl01Is4ajK0hvx1W0jOuvXHibMaJd05vOpLIHbRAEk a5eIpngHpKMKDIqcg8S70SwdAA0cvz1uTvdSQ35Cn6MMoSiuCPkWcb75yHZrKyhVuGKU q1xg== 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=7CryQf9HLIOEeLRqQvlM1zUjpW9BXv0A1TyOI0cP+LY=; b=DSqwDHl47iKzgRHQDz1t1qf9MtwU1960WLuDRsaqIuK1lq1OGi3Fd+L4HiFkf5lywi MFg3qm8rqP9lG3chyfmBSZKboxwMrxeM0DocnfKv6gz60iB2FVw2Xg6fVGUJLbOZEfR2 RrrKrVbbs5HNxjecq4pi91m5kAUVBr5KLfhWv3nY2OSHDvfrhZdNDXYPILpmrwF7D/nL mkfUcmo6qBtSxqEIiajtPdEpsWDvFfnQWAX39w3VI8zmwes/foEmW77cwXobsTZifGSY oMq5cAQuWgPy7DFlej63Pe2d4NBd57PoYMhey3FSIUo5w9XAGYQzedAZTgkOX4Xl34rz SNJQ== 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 wu1-20020a170906eec100b007a1d4f0e7fcsi1720075ejb.655.2023.01.06.08.07.50; Fri, 06 Jan 2023 08:08:15 -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 S232411AbjAFQHU (ORCPT + 99 others); Fri, 6 Jan 2023 11:07:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231286AbjAFQHR (ORCPT ); Fri, 6 Jan 2023 11:07:17 -0500 Received: from mailout-taastrup.gigahost.dk (mailout-taastrup.gigahost.dk [46.183.139.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45C4739B; Fri, 6 Jan 2023 08:07:14 -0800 (PST) Received: from mailout.gigahost.dk (mailout.gigahost.dk [89.186.169.112]) by mailout-taastrup.gigahost.dk (Postfix) with ESMTP id DFE57188467F; Fri, 6 Jan 2023 16:07:11 +0000 (UTC) Received: from smtp.gigahost.dk (smtp.gigahost.dk [89.186.169.109]) by mailout.gigahost.dk (Postfix) with ESMTP id D5E072503B65; Fri, 6 Jan 2023 16:07:11 +0000 (UTC) Received: by smtp.gigahost.dk (Postfix, from userid 1000) id C54D29EC000D; Fri, 6 Jan 2023 16:07:11 +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 7721691201E3; Fri, 6 Jan 2023 16:07:11 +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 v3 net-next 2/3] net: dsa: mv88e6xxx: shorten the locked section in mv88e6xxx_g1_atu_prob_irq_thread_fn() Date: Fri, 6 Jan 2023 17:05:28 +0100 Message-Id: <20230106160529.1668452-3-netdev@kapio-technology.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230106160529.1668452-1-netdev@kapio-technology.com> References: <20230106160529.1668452-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?1754289977937335632?= X-GMAIL-MSGID: =?utf-8?q?1754289977937335632?= As only the hardware access functions up til and including mv88e6xxx_g1_atu_mac_read() called under the interrupt handler need to take the chip lock, we release the chip lock after this call. The follow up code that handles the violations can run without the chip lock held. In further patches, the violation handler function will even be incompatible with having the chip lock held. This due to an AB/BA ordering inversion with rtnl_lock(). Signed-off-by: Hans J. Schultz --- drivers/net/dsa/mv88e6xxx/global1_atu.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/net/dsa/mv88e6xxx/global1_atu.c b/drivers/net/dsa/mv88e6xxx/global1_atu.c index 61ae2d61e25c..557428cee457 100644 --- a/drivers/net/dsa/mv88e6xxx/global1_atu.c +++ b/drivers/net/dsa/mv88e6xxx/global1_atu.c @@ -409,23 +409,25 @@ 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) - goto out; + goto out_unlock; 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;