From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 216F427B327 for ; Wed, 17 Sep 2025 10:02:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758103369; cv=none; b=u0utWuL65Nc/6FK6MA2nt+8YcydQJQMV9019QV/qnEJm7gQRhQyTRD5dq4mSkjdf5Uli7XUQ889BdiKx9cUlFsPM6tHV/9SOAxqYk60XDGJrS8iKHoFlS96QJwjID1tLnQV4++6p4nYus7jqLuY44K5mUoHwi3+8NV8ptlgufVc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758103369; c=relaxed/simple; bh=eitIgTv7GwxROzOoX6w5BE9GZOWDF3FR13hWKajvlBU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=BXgaVdh/QZ4goYoLlTe3SuO8aBIkFXcgcugDz58K3A7zF2/XCrcBeFuiNCc+T5ATBsaqU0U9szHCvJdz3AaODEEKWoYOs7bQ/0uMZdV07yf2kXrPR/2rE8PGeKKYO4NFN8mZTOc9IH+1f4hqe+LKRk2cWpXHjrEq2pOTYLn1P6E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=NSyPXowB; arc=none smtp.client-ip=209.85.128.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NSyPXowB" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-45de1532995so3977075e9.1 for ; Wed, 17 Sep 2025 03:02:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1758103366; x=1758708166; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=HmvDAXhB3YF18ndychtadEGtlpqabkSgHGl2UaFJHtM=; b=NSyPXowBoZ0FgSPzWVjI+7EUvCqYTCgNNkXk2gJwZggEwoZUypkpevPgaS9FxiUFXv ypIcBwEFGy2n9iDVEuOegRlkIOlcDnwp50E7lv+f1KKgbCAiKYX+KvwazKGG6BagtIhh RS8nGLg/p78Y8dazHWapUO7tgJlP+M/dWz7BLCM7ELsbZMm6k6kKPXV0g+cxbPkf7n8S YeEwWyHhZ5Llx5uHX+4uJnK/kZTKf/yNQyU/egTeODR5rseBSouJon3UrjZeREjhe9Ng fOFFXTPSSPvXqG7B1LfyOxPfZc2M5iRvMfGbQcnhVKyJTBpHl8RVo5HdsEVbZpcne7eF VHog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758103366; x=1758708166; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=HmvDAXhB3YF18ndychtadEGtlpqabkSgHGl2UaFJHtM=; b=qAPHubdOKG7BmgRlzFb/YSK2fWI4GoXM7Mv1z5AioT78cZepOyxaTcp7Z88a7Xt8xZ ZN82qGY5uYkk+Tw8tm//XjuDfkUz9i5Cr8LxkvxTzmTW6uleJd2X/Oumt9Sny1yyCgOx E1+FwTvDRNQU+aSTF9OAjVGwGu/XGFCv/bN0yG1HZdhefCc7HOGggbY96qku2JqiB+zZ AkWRz0XDHmmAGePU21bDBIThKzW919caTBiu/2piEJVgw6eJtOm82oYRoNaznS78fjJO lIar7IxdC8lxlksiWLrXZyjNrW5Zi6r3Ynag8InMBgdxSZq81fQc6dz3dCm2wEBe8RS3 mggg== X-Forwarded-Encrypted: i=1; AJvYcCVekQCXVq0ql/lGgf/ULTZa+OarivgwXMPorUFtU/42I5QXpgKKkzagZNDb1lUjW2vNCw+b9/00xxnQd5Q=@vger.kernel.org X-Gm-Message-State: AOJu0YwwpZZCHdUzkf/CjkmH7bv5+CtinteHUeva0jCnjYs/H/tErUWT HTpwq1vT0qsI5DUiuVoYBeDjmEgaPf8VTvO2kfcGhsPnLv0iLlnoahkIZCvrdioF X-Gm-Gg: ASbGncv7OUaD8d4TFnmtkvTVSgtlH3fp9CBc15Hl0eE9UO+Ulsc6nzuvcPAkINXNEKO /eEBIZffo3rNVIpV+ZCWvoOaY7dm69UIqBWyuYirVegbV5mFTb4qRyXamoInlncK2a8453L6/Sb ISeBoxsQtmkOWiRdiXMNWt3PO327tg4yDZqqCnUbDpnpC2qqgHMpyeEx194LwKWnUHKbfhQ41xW sXUiM/QA1zGLLRJx/feyi/W6QqaNk+qDqLQWL/9NN8SLCV17RMzwRVxvbFVl/sBSzGYeV1dyU/y gxYFyvV6jS3Vx2zX2CA0w9ETv5uDTBoT3jT5e1OuYdTaDsFA3ilc2mXByNRjLvge003IsGXnU9n SrRrav+anW7JUETM= X-Google-Smtp-Source: AGHT+IEJSD+XRqxq7Nyy97GWdJgdPxBloPmolF7AIID/h3YZTxRJteo3lDDYW9w4cvIOkM3qFATA5Q== X-Received: by 2002:a05:600c:3555:b0:45d:d401:2777 with SMTP id 5b1f17b1804b1-462024532c8mr7748625e9.2.1758103366267; Wed, 17 Sep 2025 03:02:46 -0700 (PDT) Received: from skbuf ([2a02:2f04:d005:3b00:8bcc:b603:fee7:a273]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3e80da7f335sm18935412f8f.8.2025.09.17.03.02.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Sep 2025 03:02:45 -0700 (PDT) Date: Wed, 17 Sep 2025 13:02:43 +0300 From: Vladimir Oltean To: Andrew Lunn Cc: David Yang , netdev@vger.kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Simon Horman , Russell King , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net-next v9 3/3] net: dsa: yt921x: Add support for Motorcomm YT921x Message-ID: <20250917100243.s55irruj4bzg343v@skbuf> References: <20250913044404.63641-1-mmyangfl@gmail.com> <20250913044404.63641-4-mmyangfl@gmail.com> <20250916231714.7cg5zgpnxj6qmg3d@skbuf> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Wed, Sep 17, 2025 at 02:08:31AM +0200, Andrew Lunn wrote: > > > +static int yt921x_reg_mdio_read(void *context, u32 reg, u32 *valp) > > > +{ > > > + struct yt921x_reg_mdio *mdio = context; > > > + struct mii_bus *bus = mdio->bus; > > > + int addr = mdio->addr; > > > + u32 reg_addr; > > > + u32 reg_data; > > > + u32 val; > > > + int res; > > > + > > > + /* Hold the mdio bus lock to avoid (un)locking for 4 times */ > > > + mutex_lock_nested(&bus->mdio_lock, MDIO_MUTEX_NESTED); > > > > Andrew, are you satisfied with this lock? > > This is O.K. You snipped too much context. As the comment says, the > code is about to do 4 MDIO bus transactions. Each will take and > release the lock. By taking it now, and then using the unlocked > version for read/write, it will make it a tiny bit faster. The time to > do the bus transaction will however dominate. > > > Perhaps I missed some part of > > the conversation, but didn't you say "leave the mdio lock alone"? > > Yes, i did, but then the mdio lock was being abused as a DSA driver > lock. The DSA driver now has its own lock. So what we see above is > purely an optimisation, not a locking scheme. > > Andrew Ok, I misunderstood the reason for your comment to leave the MDIO lock alone. Acquiring &bus->mdio_lock I can agree with, regardless of whether the "driver lock" exists. I'm currently reviewing drivers/mfd/airoha-an8855.c and it handles this the same way. I'm not sure that a "driver lock" is something that drivers need. In this case it creates a lot of red tape. Function yt921x_dsa_X() takes the driver lock and calls function yt921x_X() which does the work. IMO that's part of what gives "vendor crap" drivers their name, when there's no reason behind it.