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 C702DC6379F for ; Mon, 20 Feb 2023 19:44:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232355AbjBTToB (ORCPT ); Mon, 20 Feb 2023 14:44:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231921AbjBTTn7 (ORCPT ); Mon, 20 Feb 2023 14:43:59 -0500 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B322CA10; Mon, 20 Feb 2023 11:43:57 -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=9HbrxqQTQpnPyk90Ibmi+L1eYlZ8P8y6XH2D3rbiNws=; b=UfFwuH6iH/M1sgUS3t+DNVm34J hyEwZY+mOKUDtI34qcK4zuS9bReY+5FrBE4PLLAmm814GqdqowfY41TFnRqrrbVUc5RrDT85KHAcM VM+FSvlsXppxYfq8qVwOLeTlxKqSOoKd6Fm20bWRMREnfV8VdMOsU4EVCfy35cme8usA=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1pUC4e-005XE4-Td; Mon, 20 Feb 2023 20:43:44 +0100 Date: Mon, 20 Feb 2023 20:43:44 +0100 From: Andrew Lunn To: "Russell King (Oracle)" Cc: Marc Zyngier , Thomas Gleixner , LKML , x86@kernel.org, Joerg Roedel , Will Deacon , linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , Greg Kroah-Hartman , Jason Gunthorpe , Dave Jiang , Alex Williamson , Kevin Tian , Dan Williams , Logan Gunthorpe , Ashok Raj , Jon Mason , Allen Hubbe Subject: Re: [REGRESSION] Re: [patch V3 09/33] genirq/msi: Add range checking to msi_insert_desc() Message-ID: References: <20221124230505.073418677@linutronix.de> <20221124232325.798556374@linutronix.de> <86fsb0xkaa.wl-maz@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 20, 2023 at 07:17:11PM +0000, Russell King (Oracle) wrote: > On Mon, Feb 20, 2023 at 06:29:33PM +0000, Marc Zyngier wrote: > > Lockdep also reports[1] a possible circular locking dependency between > > phy_attach_direct() and rtnetlink_rcv_msg(), which looks interesting. > > > > [1] https://paste.debian.net/1271454/ > > Adding Andrew, but really this should be in a separate thread, since > this has nothing to do with MSI. > > It looks like the open path takes the RTNL lock followed by the phydev > lock, whereas the PHY probe path takes the phydev lock, and then if > there's a SFP attached to the PHY, we end up taking the RTNL lock. > That's going to be utterly horrid to try and solve, and isn't going > to be quick to fix. What are we actually trying to protect in phy_probe() when we take the lock and call phydev->drv->probe(phydev) ? The main purpose of the lock is to protect members of phydev, such as link, speed, duplex, which can be inconsistent when the lock is not held. But the PHY is not attached to a MAC yet, so a MAC cannot be using it, and those members of phydev are not valid yet anyway. The lock also prevents parallel operation on the device by phylib, but i cannot think of how that could happen at this early stage in the life of the PHY. So maybe we can move the mutex_lock() after the call to phydev->drv->probe()? Andrew