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 513D5C71144 for ; Fri, 18 Aug 2023 13:08:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377013AbjHRNI0 (ORCPT ); Fri, 18 Aug 2023 09:08:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376985AbjHRNIA (ORCPT ); Fri, 18 Aug 2023 09:08:00 -0400 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C013E3A9A; Fri, 18 Aug 2023 06:07:59 -0700 (PDT) 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=H7VtEsZofYId/aG305o0Ub13+3fvF0NwF4OODNLCumA=; b=jN18pognnRJGsiK2TBBQh836Ey NtS2ADPP1juZxm9y+X0RR5bPJSoix/ltu8+PlgO9oXmwIZx6DF44AJCOP0E06L7iCatpCXjyn/1nO ZSyDx4jdvjXIk6QT9jpsF/O4Bhnq5JoC18XoWO+ehwwPvuFxLWssqcxbHuoC20UVOgng=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1qWzCf-004Uj3-I9; Fri, 18 Aug 2023 15:07:49 +0200 Date: Fri, 18 Aug 2023 15:07:49 +0200 From: Andrew Lunn To: Serge Semin Cc: Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Francesco Dolcini , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net] net: phy: Fix deadlocking in phy_error() invocation Message-ID: <6e52f88e-73ad-4e2a-90ca-ada471f30b9d@lunn.ch> References: <20230818125449.32061-1-fancer.lancer@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230818125449.32061-1-fancer.lancer@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 18, 2023 at 03:54:45PM +0300, Serge Semin wrote: > static void phy_process_error(struct phy_device *phydev) > { > - mutex_lock(&phydev->lock); > + /* phydev->lock must be held for the state change to be safe */ > + if (!mutex_is_locked(&phydev->lock)) > + phydev_err(phydev, "PHY-device data unsafe context\n"); > + > phydev->state = PHY_ERROR; > - mutex_unlock(&phydev->lock); > > phy_trigger_machine(phydev); > } Thanks for the patch Serge. It looks like a good implementation of what i suggested. But thinking about it further, if the error ever appears in somebodies kernel log, there is probably not enough information to actually fix it. There is no call path. So i think it should actually use WARN_ON_ONCE() so we get a stack trace. Sorry for changing my mind. Andrew --- pw-bot: cr