Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp8755387rwb; Tue, 13 Dec 2022 10:01:51 -0800 (PST) X-Google-Smtp-Source: AA0mqf7PMnaHmm5lqpr0XGXnXvLdhg15SbxQ+q1VCMqiZFgR2JZmOEgdejvnd6SjDH5c64Tdtdg4 X-Received: by 2002:a17:906:cd04:b0:7c0:efb4:71fb with SMTP id oz4-20020a170906cd0400b007c0efb471fbmr15545891ejb.28.1670954511197; Tue, 13 Dec 2022 10:01:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670954511; cv=none; d=google.com; s=arc-20160816; b=qqm7sjZsC0Tu9jYCf9Rkhhe5CklcmU/S4Z5p8wmIJ8ulBefi0oQfIrag32w0u2Ri4M eN2FmDTS+aFvaIPdUzOscbFlZcKqEyVCHFW/B6EKLo/TitZbJcBffVkkA5GbIqZemq0N ZxyLhdJ7Ikuc3IArZ9SlIQo4tZP1VU3qZUBR9QilvkUrS+EYbYXH2N0LFLSpTuh9rAv1 SzaK3iY3mxKUAsthwLFEABCpGdu8Iuiu7eCqtj5IDixSnZbLT9/ytcAAYeBt4gwr9rIw RX/G1XbfzrvEeqB8RokUAOoxfk9hbgi74VHx6qi6nNqOnMVaMBPlxFHxG6ImAtu8X4Tm 70rQ== 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=RfkEDVA27NF3OJricJCO3eum3+iTVzq/mQIKoLnlDX23Ug4YKqfyTAHn7QwjCf75S3 3eI69Zsw+CG+v4yStLST0E9/aSpL1zQ0pjJaMCxUYohORH8TXNFgGp4xlALNtkDNcqG/ Y/0G98Lgad8yKfrc9DRjZKuZFhatC8GRJoyh6JWsY4Ja3vy4U+nMDz+h0P9GAVrim9wt tJTOVZ5Fjk+5s+ib8v0JAJ/ek8ERdywH/ydHo/n64kp1DSmNZbuAG6KErT3Mf2SPbP6E 6qOdUHJuZa8elm9Hp6c8ZDxtF6qS9/W6SJkI6wAIZ1nTqrBF2o8nRk9c7ZKgPe39FyLn pW4Q== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cs16-20020a170906dc9000b0078261fd56efsi9920662ejc.571.2022.12.13.10.01.33; Tue, 13 Dec 2022 10:01:51 -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 S236378AbiLMRsP (ORCPT + 72 others); Tue, 13 Dec 2022 12:48:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236366AbiLMRsL (ORCPT ); Tue, 13 Dec 2022 12:48:11 -0500 Received: from mailout-taastrup.gigahost.dk (mailout-taastrup.gigahost.dk [46.183.139.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1705F11A0F; Tue, 13 Dec 2022 09:48:08 -0800 (PST) Received: from mailout.gigahost.dk (mailout.gigahost.dk [89.186.169.112]) by mailout-taastrup.gigahost.dk (Postfix) with ESMTP id E6C3F18839C0; Tue, 13 Dec 2022 17:48:06 +0000 (UTC) Received: from smtp.gigahost.dk (smtp.gigahost.dk [89.186.169.109]) by mailout.gigahost.dk (Postfix) with ESMTP id D6BA72500015; Tue, 13 Dec 2022 17:48:06 +0000 (UTC) Received: by smtp.gigahost.dk (Postfix, from userid 1000) id CAB329EC0027; Tue, 13 Dec 2022 17:48:06 +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 7E8F891201E3; Tue, 13 Dec 2022 17:48:06 +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: Tue, 13 Dec 2022 18:46:49 +0100 Message-Id: <20221213174650.670767-3-netdev@kapio-technology.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221213174650.670767-1-netdev@kapio-technology.com> References: <20221213174650.670767-1-netdev@kapio-technology.com> MIME-Version: 1.0 Organization: Westermo Network Technologies AB Content-Transfer-Encoding: 8bit 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 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; -- 2.34.1