From patchwork Wed Mar 29 15:59:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 76698 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp530246vqo; Wed, 29 Mar 2023 09:16:42 -0700 (PDT) X-Google-Smtp-Source: AKy350avPcts71k232dg99b3m0JHVHd7PX0162Pp97NzJRHMHyISFggVTxiNCcIJrBwlLKvGPSTi X-Received: by 2002:aa7:c6d1:0:b0:501:d6d4:ef33 with SMTP id b17-20020aa7c6d1000000b00501d6d4ef33mr18572307eds.40.1680106602296; Wed, 29 Mar 2023 09:16:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680106602; cv=none; d=google.com; s=arc-20160816; b=yYSnr0miw/Hwt5grmW5o85ysks9lQrYJ2gjdsmfTSyYJPhRz4LRXE/bPSpO+eJoZfV dhFsiU5fIkCBNmldGDSixDKSTEA5ehsGS328KucHl8LfuQ8l3MDDsXfDhlbuJp1GOLIQ dXxktViJXqm0q9IpCJeJc2UtNZjg4VQLE7EoEEz9RwF7bsJRJkj+wLbFLXPPGUb1YB9t +dM846MR+NMrQOoDp8LY98dcUw2CbvJ3vlRo5WOeK0BUs0H5AmE03LFpL6Y5urCrM37Z 8TVvpYySDs52XQlCXk3fOhreAPQfnvpg+0XZghsCK7lbm8GVYiYkQJrqTrA/sL19CgsY fhXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=MKuUSgy1LKC1fzavlY6dVE3HFo8hotnsiWf2bQBe4YI=; b=ZgNC7KAvH+gQyP99SO5v9w5waeyQsfQDW54EhOFK60AgXJSiWyLVstgT8Gzve4gekG Suzsr/S6UFEpeyr+aHm142Xw4Urn5hX2pkM/H+Vr+YWG6vfVx1L/iGTcdYA5JryZyQf7 fdF8zllChyB6Q3rG3PsHjwCZuaiNL6aURE6JqOXPnUzhFS9XxZBRpgf0jF2mD7xGwy03 cEWXXBjpkxGKSxnuwCWDDNSebiLsta/QkCHmiD6OSAgMVkPC5oelG4byjajCf+r4jDPi FioA0gX4ICPd/CUxOMjDQvkCZMApjPWJbGUdVkL/dbchTGMiSX2VoPQ5kjnYTUq8sXPH jE8A== 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 r9-20020aa7cfc9000000b004fd26753791si13379321edy.649.2023.03.29.09.16.05; Wed, 29 Mar 2023 09:16:42 -0700 (PDT) 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 S231222AbjC2QBv (ORCPT + 99 others); Wed, 29 Mar 2023 12:01:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230282AbjC2QAy (ORCPT ); Wed, 29 Mar 2023 12:00:54 -0400 Received: from fudo.makrotopia.org (fudo.makrotopia.org [IPv6:2a07:2ec0:3002::71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C58B64C2C; Wed, 29 Mar 2023 08:59:56 -0700 (PDT) Received: from local by fudo.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.96) (envelope-from ) id 1phYDH-0003RC-1w; Wed, 29 Mar 2023 17:59:51 +0200 Date: Wed, 29 Mar 2023 16:59:47 +0100 From: Daniel Golle To: netdev@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , Sean Wang , Landen Chao , DENG Qingfang , Philipp Zabel Cc: Sam Shih , Lorenzo Bianconi , John Crispin , Felix Fietkau Subject: [RFC PATCH net-next v3 11/15] net: dsa: mt7530: skip locking if MDIO bus isn't present Message-ID: <4e6d1cbba2ff16cad5b9ac48ccdf4407f45c7857.1680105013.git.daniel@makrotopia.org> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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?1761719460342214253?= X-GMAIL-MSGID: =?utf-8?q?1761719460342214253?= As MT7530 and MT7531 internally use 32-bit wide registers, each access to any register of the switch requires several operations on the MDIO bus. Hence if there is congruent access, e.g. due to PCS or PHY polling, this can mess up and interfere with another ongoing register access sequence. However, the MDIO bus mutex is only relevant for MDIO-connected switches. Prepare switches which have there registers directly mapped into the SoCs register space via MMIO which do not require such locking. There we can simply use regmap's default locking mechanism. Hence guard mutex operations to only be performed in case of MDIO connected switches. Signed-off-by: Daniel Golle Reviewed-by: Andrew Lunn --- drivers/net/dsa/mt7530.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index ce2665abaaf57..c6fad2d156160 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -145,13 +145,15 @@ core_write_mmd_indirect(struct mt7530_priv *priv, int prtad, static void mt7530_mutex_lock(struct mt7530_priv *priv) { - mutex_lock_nested(&priv->bus->mdio_lock, MDIO_MUTEX_NESTED); + if (priv->bus) + mutex_lock_nested(&priv->bus->mdio_lock, MDIO_MUTEX_NESTED); } static void mt7530_mutex_unlock(struct mt7530_priv *priv) { - mutex_unlock(&priv->bus->mdio_lock); + if (priv->bus) + mutex_unlock(&priv->bus->mdio_lock); } static void