From patchwork Thu Mar 30 15:23:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 77249 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1238815vqo; Thu, 30 Mar 2023 09:08:20 -0700 (PDT) X-Google-Smtp-Source: AKy350an3xNvq4NOYLNJc5zWVvV4agRKN6FDAp9aO38DHOqnG3inwjRpPA1Y0Jq22/x1y2hveqz4 X-Received: by 2002:a17:90b:3846:b0:237:24a8:c5e2 with SMTP id nl6-20020a17090b384600b0023724a8c5e2mr25718162pjb.40.1680192500035; Thu, 30 Mar 2023 09:08:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680192500; cv=none; d=google.com; s=arc-20160816; b=OZSq84f0BmX8GG0kNPWPDzjTkytneIUqDtyqMOP9Ew7TDvrIoSfO5n/lyVd/XBXl6t 0Y/kMH5CrTrT2UoYNci6ZbOS6h8olLX4O9PxUXBBfTYayj8HwyMdULxQG6URW2TaYw/6 9h463itm/Bzz/9y6PR84YxkYkdw021etUrWCDIE/7pVB8uP4rGPf0MeDBAi7E8ZwzGDe ZU8ymphG97hfnD5r7sICmD49W3gaMpoyTgEAXuLOi9dsDviFacUPhPnCEpbtnRTnm63C rOUhbuqIBsql3Ie2RYsERNeR6FRokjneHAnrA99cxomWUFleqXMFkmvIKFaT0MowNhi+ hKmg== 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=KgDRz6AtND+m4DB5W+DNaw4z/ta0YSzw7PR+WZ/DrKI=; b=cjvpeVOj0ZWDPc1o0vrpiuwmWkMGhnDcvpsNN8SpoO9C+hUEpUegES0KDAZIeDjm4M u9ZSKxUTg2RsUsKx20/2AhSsBI7Yl2dXOOalgIMzPP/qTW7BCh5JN9fRwvgW7CgIJEWv Kucb2HOdnt7reIW1VmiVqho0yO5HjC9pa2LCO3AAgKYDvgAUqpQc6AIzT0u5RLaijYyg BSIHaoFPrevwxGirw7Dxk3S04CbALnU/zAtHTO3d0ayH7wLsSuUl1bjQWNWRHEGD86n5 vwHR7EKq4uhgCnyGTQgvU1SjRTj/ymMBwgOzZESydyfDrNY8j/3Mc5hlba8ZegxUbxf0 5hrw== 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 t11-20020a17090abc4b00b0023d2e945af7si4250368pjv.95.2023.03.30.09.07.48; Thu, 30 Mar 2023 09:08:20 -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 S233093AbjC3PYu (ORCPT + 99 others); Thu, 30 Mar 2023 11:24:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233064AbjC3PY1 (ORCPT ); Thu, 30 Mar 2023 11:24:27 -0400 Received: from fudo.makrotopia.org (fudo.makrotopia.org [IPv6:2a07:2ec0:3002::71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D2EECC2F; Thu, 30 Mar 2023 08:23:58 -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 1phu7Q-0006kH-1P; Thu, 30 Mar 2023 17:23:16 +0200 Date: Thu, 30 Mar 2023 16:23:13 +0100 From: Daniel Golle To: netdev@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux@armlinux.org.uk, linux-kernel@vger.kernel.org, Andrew Lunn , =?utf-8?b?QXI=?= =?utf-8?b?xLFuw6cgw5xuYWw=?= , 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: [PATCH net-next 12/15] net: dsa: mt7530: skip locking if MDIO bus isn't present Message-ID: <10cf68a82095fc136c1bb1af3f48bb3fef21e71b.1680180959.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?1761809530917947818?= X-GMAIL-MSGID: =?utf-8?q?1761809530917947818?= 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. Reviewed-by: Andrew Lunn 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 ea8d8e669aacc..3a4682e71e746 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