Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp3917336rwl; Sun, 2 Apr 2023 18:44:53 -0700 (PDT) X-Google-Smtp-Source: AKy350Zgdy+Q4VbZ5WGacetJ/n2sbVWNg4H0EudS8zPlbYO9kZ+tz1BVhznYbrsdzedXjyJbkryG X-Received: by 2002:a17:906:c453:b0:90b:53f6:fd8a with SMTP id ck19-20020a170906c45300b0090b53f6fd8amr36044762ejb.10.1680486293434; Sun, 02 Apr 2023 18:44:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680486293; cv=none; d=google.com; s=arc-20160816; b=t29F+LNw8FQHLgiWaak+kV6I42R5gc/30pSJ7E+hhW1uwPtgYxvxzGyXHbT867bRmx 8POpUOBpCDVf9+eKHnCKEEJygmleenf636q9SQZK4BkpRXva3K+zZ99zxZnIH9rEYE2O Ox5Re7tXU4WIOtCr6YyfEW7Pqtu+qpIn/F3R2yukkjTrHsRnCAg7VrEI9KYw1EZH2Oqr K5EUEkmyhg0//NVuCWz9HBtGCI4E5I1OWdnp2oI/7I9s9XrDDosqOTJPxaJZ6fposJv1 jUtHzVFVRuvdo0mxo5H3yP5GGhtEZSi5XXn+TP1gMVnOuXROpcV87VyLjLFgQa4is33t p7dw== 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=CTGyR7LCQoy96a9ILhwN+Ycbc1fuDFmtWGjFfBaYhbs=; b=e5IRQ1g4Ssmxx2d/iTUfQ+skIw8xuBh5/dbwjNPFZnN9W8h8vZMsU2lIt2rtdo/+3C nw46wW6CpRN2a7OAuLVEONTGnPv3vtphhQ/aZKlRkKUZ9LfBcFgrI42KSXEO0eoDmfgy Rb8p9f/C+a6MwRLBBdsC8MotpzdOD2Z1tdOI0K2aVp/UjP7P1PMB/Zfn5SMKvLUj4fFG 4NI1UdHx+8qAmUMWR4GW/2shjh8K938EnDDQ7JUc0BUgQ9T/98hyUX9TVf+xv0rVgbdq ACaM2CRAqiY3YFtHrNkxERGietJpo2WxKft/3S7UFtvk7yWGwXLB+MZQBY3oPHlaTVZ5 /UsA== 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 v19-20020a170906181300b00944010e04fasi7397749eje.712.2023.04.02.18.44.27; Sun, 02 Apr 2023 18:44:53 -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 S231415AbjDCBUM (ORCPT + 99 others); Sun, 2 Apr 2023 21:20:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231282AbjDCBTy (ORCPT ); Sun, 2 Apr 2023 21:19:54 -0400 Received: from fudo.makrotopia.org (fudo.makrotopia.org [IPv6:2a07:2ec0:3002::71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A983C5FFF; Sun, 2 Apr 2023 18:19:34 -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 1pj8r6-0004nc-1Z; Mon, 03 Apr 2023 03:19:32 +0200 Date: Mon, 3 Apr 2023 02:19:28 +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 , Russell King , =?utf-8?B?QXLEsW7DpyDDnG5hbA==?= Cc: Sam Shih , Lorenzo Bianconi , John Crispin , Felix Fietkau Subject: [PATCH net-next v2 12/14] net: dsa: mt7530: skip locking if MDIO bus isn't present Message-ID: <82f84ef9850bddf5a855f568594c403270a08249.1680483896.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 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 ac485ee83ed07..394fada7ddf13 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -144,13 +144,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.40.0