From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754649AbcHSGBD (ORCPT ); Fri, 19 Aug 2016 02:01:03 -0400 Received: from shards.monkeyblade.net ([184.105.139.130]:42281 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754165AbcHSGBC (ORCPT ); Fri, 19 Aug 2016 02:01:02 -0400 Date: Thu, 18 Aug 2016 23:00:55 -0700 (PDT) Message-Id: <20160818.230055.1587442048794416891.davem@davemloft.net> To: vaishali.thakkar@oracle.com Cc: andrianov@ispras.ru, mugunthanvnm@ti.com, a@unstable.cc, felipe.balbi@linux.intel.com, fw@strlen.de, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org Subject: Re: [PATCH] smc91c92_cs : add a spinlock to avoid race condition From: David Miller In-Reply-To: <57B68DFC.4070204@oracle.com> References: <1471354746-27110-1-git-send-email-andrianov@ispras.ru> <20160818.210734.1003452853595787957.davem@davemloft.net> <57B68DFC.4070204@oracle.com> 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]); Thu, 18 Aug 2016 23:00:58 -0700 (PDT) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vaishali Thakkar Date: Fri, 19 Aug 2016 10:11:32 +0530 > > > On Friday 19 August 2016 09:37 AM, David Miller wrote: >> From: Pavel Andrianov >> Date: Tue, 16 Aug 2016 16:39:06 +0300 >> >>> smc_reset may be executed in parallel with timer function media_check. >>> To avoid data race in smc_set_xcvr a spinlock was added. >>> >>> Found by Linux Driver Verification project (linuxtesting.org). >>> >>> Signed-off-by: Pavel Andrianov >> >> This is not sufficient. >> >> You have to block basically the entire function, because both >> smc_reset and media_check program the bank selection so could >> corrupt eachother's register accesses. > > Hmm, but then there is a use of udelay as well. Would it be still > fine to acquire a spinlock on whole function? I don't know, but what I'm telling you is that you have to execute register programming these two functions do atomically so that the bank selection doesn't check get changed midstream.