Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp834550rwl; Wed, 29 Mar 2023 09:03:54 -0700 (PDT) X-Google-Smtp-Source: AKy350ZQwBbH5txms32mse0qEHZ+VL+BcsN+DPRod1+8LEX3EFj/+D9YJBwiWJsbsdqrjLN9TCnr X-Received: by 2002:a17:90a:5105:b0:234:a88e:d67e with SMTP id t5-20020a17090a510500b00234a88ed67emr21895473pjh.34.1680105834521; Wed, 29 Mar 2023 09:03:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680105834; cv=none; d=google.com; s=arc-20160816; b=Ne2YVJmqqVUiToVg9Ix2JSE6LJnawYCvTvP4aoJ4+6sTcp9NBEn+/dSJvhO6WyC0A9 BswVaICQnKy4XenwvhCMRGSVSbUiMG+maLR4BtimVoWLmHZ3QlZSiUYl1N37cZN+oMtO L3SghV76c6er3azoR/rJifZliPgiOxdMarmOdXHcPYt2PS3lolX0ywAzAD5cNOmWVJx2 VblbCV0lnumDTVUDYbebPsejtbaf3wk6UbIqRT40kxZpXxvGEHcSFpY1bPf/tCTdaR/9 TvATnKv2Ss12MyCZEWFTqgu4zAqlyogj4kyPMMDuJeFixQbArj+DoNybKBRfkd4uhtzt UvTg== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id np11-20020a17090b4c4b00b0023f5452b573si1733728pjb.141.2023.03.29.09.03.40; Wed, 29 Mar 2023 09:03:54 -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 S229871AbjC2QBv (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-Type: text/plain; charset=us-ascii 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 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 --- 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 -- 2.39.2