Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751064AbcL0F1A convert rfc822-to-8bit (ORCPT ); Tue, 27 Dec 2016 00:27:00 -0500 Received: from mga09.intel.com ([134.134.136.24]:11707 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750807AbcL0F0s (ORCPT ); Tue, 27 Dec 2016 00:26:48 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,414,1477983600"; d="scan'208";a="916385327" From: "Kweh, Hock Leong" To: David Miller CC: "Joao.Pinto@synopsys.com" , "peppe.cavallaro@st.com" , "seraphin.bonnaffe@st.com" , "alexandre.torgue@gmail.com" , "manabian@gmail.com" , "niklas.cassel@axis.com" , "johan@kernel.org" , "pavel@ucw.cz" , "Ong, Boon Leong" , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "Voon, Weifeng" , "lars.persson@axis.com" Subject: RE: [PATCH] net: stmmac: synchronize stmmac_open and stmmac_dvr_probe Thread-Topic: [PATCH] net: stmmac: synchronize stmmac_open and stmmac_dvr_probe Thread-Index: AQHSX/L/pUyP0LH4jkKd47+Y4NZurKEatKIAgACO8aA= Date: Tue, 27 Dec 2016 05:26:43 +0000 Message-ID: References: <1482839100-20612-1-git-send-email-hock.leong.kweh@intel.com> <20161226.235436.131087168899382517.davem@davemloft.net> In-Reply-To: <20161226.235436.131087168899382517.davem@davemloft.net> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.30.20.206] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1467 Lines: 36 > -----Original Message----- > From: David Miller [mailto:davem@davemloft.net] > Sent: Tuesday, December 27, 2016 12:55 PM > To: Kweh, Hock Leong > Cc: Joao.Pinto@synopsys.com; peppe.cavallaro@st.com; > seraphin.bonnaffe@st.com; alexandre.torgue@gmail.com; > manabian@gmail.com; niklas.cassel@axis.com; johan@kernel.org; > pavel@ucw.cz; Ong, Boon Leong ; > netdev@vger.kernel.org; linux-kernel@vger.kernel.org; Voon, Weifeng > ; lars.persson@axis.com > Subject: Re: [PATCH] net: stmmac: synchronize stmmac_open and > stmmac_dvr_probe > > From: "Kweh, Hock Leong" > Date: Tue, 27 Dec 2016 19:44:59 +0800 > > > From: "Kweh, Hock Leong" > > > > If kernel module stmmac driver being loaded after OS booted, there is a > > race condition between stmmac_open() and stmmac_mdio_register(), which is > > invoked inside stmmac_dvr_probe(), and the error is showed in dmesg log as > > PHY not found and stmmac_open() failed: > ... > > The resolution used wait_for_completion_interruptible() to synchronize > > stmmac_open() and stmmac_dvr_probe() to prevent the race condition > > happening. > > > > Signed-off-by: Kweh, Hock Leong > > The proper thing to do is to make sure register_netdevice() is not > invoked until it is %100 safe to call stmmac_open(). Noted & thanks. Will look into it. Regards, Wilson