From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B47EDC4332F for ; Sat, 3 Dec 2022 20:48:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229755AbiLCUsD (ORCPT ); Sat, 3 Dec 2022 15:48:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbiLCUsB (ORCPT ); Sat, 3 Dec 2022 15:48:01 -0500 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C457564E3; Sat, 3 Dec 2022 12:48:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=nrIUiqu0rhHfNsiWFPaaq3UEuLRQT2XtfSlEcQWCe80=; b=AofCRjqnSYXZ8feR+kEmJkOUC2 MZqTyRCe/KBWz+8IvZVZ6dP9aoc32d9xigxVoFXBUvYAM5W/tqxdMQ/Wg7ysLy9nBa63WByVgYLZn BtjSVsFqoOMwaBUNqIAEf14fT/gtqQn9eua1PyIk//lpbk6Hc0JuppW6HfrnwQMPNGLk=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1p1ZQE-004HrO-Th; Sat, 03 Dec 2022 21:47:42 +0100 Date: Sat, 3 Dec 2022 21:47:42 +0100 From: Andrew Lunn To: "Russell King (Oracle)" Cc: Frank , Peter Geis , Heiner Kallweit , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , yinghong.zhang@motor-comm.com, fei.zhang@motor-comm.com, hua.sun@motor-comm.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net-next v2] net: phy: Add driver for Motorcomm yt8531 gigabit ethernet phy Message-ID: References: <20221202073648.3182-1-Frank.Sae@motor-comm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Fri, Dec 02, 2022 at 01:34:16PM +0000, Russell King (Oracle) wrote: > On Fri, Dec 02, 2022 at 02:27:43PM +0100, Andrew Lunn wrote: > > > +static bool mdio_is_locked(struct phy_device *phydev) > > > +{ > > > + return mutex_is_locked(&phydev->mdio.bus->mdio_lock); > > > +} > > > + > > > +#define ASSERT_MDIO(phydev) \ > > > + WARN_ONCE(!mdio_is_locked(phydev), \ > > > + "MDIO: assertion failed at %s (%d)\n", __FILE__, __LINE__) > > > + > > > > Hi Frank > > > > You are not the only one who gets locking wrong. This could be used in > > other drivers. Please add it to include/linux/phy.h, > > That placement doesn't make much sense. > > As I already said, we have lockdep checks in drivers/net/phy/mdio_bus.c, > and if we want to increase their effectiveness, then that's the place > that it should be done. I was following the ASSERT_RTNL model, but that is used in quite deep and complex call stacks, and it is useful to scatter the macro in lots of places. PHY drivers are however very shallow, so yes, putting them in mdio_bus.c makes a lot of sense. > I don't see any point in using __FILE__ and __LINE__ in the above > macro either. Firstly, WARN_ONCE() already includes the file and line, > and secondly, the backtrace is more useful than the file and line where > the assertion occurs especially if it's placed in mdio_bus.c And PHY driver functions are simpler, there is a lot less inlining going on, so the function name is probably all you need to know to find where you messed up the locking. So i agree, they can be removed. Andrew