Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752425AbdFGSi4 (ORCPT ); Wed, 7 Jun 2017 14:38:56 -0400 Received: from shards.monkeyblade.net ([184.105.139.130]:33498 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752316AbdFGSix (ORCPT ); Wed, 7 Jun 2017 14:38:53 -0400 Date: Wed, 07 Jun 2017 14:38:44 -0400 (EDT) Message-Id: <20170607.143844.682492319776197931.davem@davemloft.net> To: liu.xiang6@zte.com.cn Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, liuxiang1999@gmail.com Subject: Re: [PATCH v2] net: davicom: dm9000: Avoid spinlock recursion during dm9000_timeout routine From: David Miller In-Reply-To: <1496758626-2726-1-git-send-email-liu.xiang6@zte.com.cn> References: <1496758626-2726-1-git-send-email-liu.xiang6@zte.com.cn> X-Mailer: Mew version 6.7 on Emacs 24.5 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Wed, 07 Jun 2017 10:57:09 -0700 (PDT) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 925 Lines: 28 From: Liu Xiang Date: Tue, 6 Jun 2017 22:17:06 +0800 > On the DM9000B, dm9000_phy_write() is called after the main spinlock > is held, during the dm9000_timeout() routine. Spinlock recursion > occurs because the main spinlock is requested again in > dm9000_phy_write(). So spinlock should be avoided in phy operation > during the dm9000_timeout() routine. > > --- > v2: > dm9000_phy_write_reg is extracted from dm9000_phy_write, with no lock, > do the real phy operation. I told you during your first submission that this is racy. Conditional locking in multithreaded driver almost never works properly. Once we enter the timeout, another asynchronous thread of control (an interrupt, timer, whatever) can try to do a PHY operation and skip the locking because the timeout boolean is set. That's not right. You will need to find a more correct solution to this locking problem. Thanks.