Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp997720pxb; Thu, 19 Nov 2020 20:55:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJw9DaEV8BiJEPyz3mrGtz2ktW7/KBB7fOIOp2M8Z0kv2jbK4pK3LmBa8DmPaCwY9TgwUQWD X-Received: by 2002:a05:6402:150b:: with SMTP id f11mr14014403edw.332.1605848130646; Thu, 19 Nov 2020 20:55:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605848130; cv=none; d=google.com; s=arc-20160816; b=E57A16xeE0YzUuTY8H0HT2aCEy02rM0vCFd47C4jugxFzAxUacmys6NvM7yJI2/dct /Fi9/n0CyrEDCsT8P0YLZecABKg31D+vxBkD0MI6eNkCRX+D47LiuKXDJtEPf1daiCRA f9z4qO9mO2fF5FZy8q0SsMqyb5vDOBPgiEWOThat+RZzyPR13Jadpyjy/dsx1VsbVIXC 7hqbpILz0aJJNgrlH7Y8dkGyBn88R2owT8TciwgD4txnu1UqOB1lVSWey6SEEibPJItQ dj1K+/nh4pemrBhRC0Cfx8gYwOtsmO1CfvuQUbH76vqHObY2gCF9a7mwAVWQtDS5KMqp jVoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:subject:from:message-id:cc:to; bh=0lpphAqu85QXLvmxquAKmglsxwzWTGj+DKY+tJZDVyU=; b=Dr0aW8GaliIdmTEHg5y7WraYeugzC7e0rqa6A1DPm/rBPk/alTqG60uqtTma4MM7mg HX1i2RV1zSgBi6rqktZUP9YgJo2CMV/Il5GAVlze6t3qMSJLA0iiEtfPv+urp+6H8W+1 WnsMajCIQSkJRj5afTeZsWZSpk3k9pQk1pWiTFODs3m3vQ+GopIeHnDlMFqcFsIOy6Z4 xFOAR6Zcph+eck33Ej5PK1zCPNB9mYSmOSqEU1h8gbYP6GMfC+8NWTmQmd/PiBJ5mfEN Qa2hE5Lr5P7FQYrO+oTvhAs0WCjQk6hnNtj2TV4Rkj0T19sll5pauTl9L248dS3frvAi /N+w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y25si1048169ejd.556.2020.11.19.20.54.51; Thu, 19 Nov 2020 20:55:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726354AbgKTEvk (ORCPT + 99 others); Thu, 19 Nov 2020 23:51:40 -0500 Received: from kvm5.telegraphics.com.au ([98.124.60.144]:52650 "EHLO kvm5.telegraphics.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726172AbgKTEvg (ORCPT ); Thu, 19 Nov 2020 23:51:36 -0500 Received: by kvm5.telegraphics.com.au (Postfix, from userid 502) id A38082A451; Thu, 19 Nov 2020 23:51:35 -0500 (EST) To: Michael Schmitz , "James E.J. Bottomley" , "Martin K. Petersen" Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Message-Id: From: Finn Thain Subject: [PATCH] scsi/atari_scsi: Fix race condition between .queuecommand and EH Date: Fri, 20 Nov 2020 15:39:56 +1100 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It is possible that bus_reset_cleanup() or .eh_abort_handler could be invoked during NCR5380_queuecommand(). If that takes place before the new command is enqueued and after the ST-DMA "lock" has been acquired, the ST-DMA "lock" will be released again. This will result in a lost DMA interrupt and a command timeout. Fix this by excluding EH and interrupt handlers while the new command is enqueued. Signed-off-by: Finn Thain --- Michael, would you please send your Acked-by or Reviewed-and-tested-by? These two patches taken together should be equivalent to the one you tested recently. I've split it into two as that seemed to make more sense. --- drivers/scsi/NCR5380.c | 9 ++++++--- drivers/scsi/atari_scsi.c | 10 +++------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c index d654a6cc4162..ea4b5749e7da 100644 --- a/drivers/scsi/NCR5380.c +++ b/drivers/scsi/NCR5380.c @@ -580,11 +580,14 @@ static int NCR5380_queue_command(struct Scsi_Host *instance, cmd->result = 0; - if (!NCR5380_acquire_dma_irq(instance)) - return SCSI_MLQUEUE_HOST_BUSY; - spin_lock_irqsave(&hostdata->lock, flags); + if (!NCR5380_acquire_dma_irq(instance)) { + spin_unlock_irqrestore(&hostdata->lock, flags); + + return SCSI_MLQUEUE_HOST_BUSY; + } + /* * Insert the cmd into the issue queue. Note that REQUEST SENSE * commands are added to the head of the queue since any command will diff --git a/drivers/scsi/atari_scsi.c b/drivers/scsi/atari_scsi.c index a82b63a66635..95d7a3586083 100644 --- a/drivers/scsi/atari_scsi.c +++ b/drivers/scsi/atari_scsi.c @@ -376,15 +376,11 @@ static int falcon_get_lock(struct Scsi_Host *instance) if (IS_A_TT()) return 1; - if (stdma_is_locked_by(scsi_falcon_intr) && - instance->hostt->can_queue > 1) + if (stdma_is_locked_by(scsi_falcon_intr)) return 1; - if (in_interrupt()) - return stdma_try_lock(scsi_falcon_intr, instance); - - stdma_lock(scsi_falcon_intr, instance); - return 1; + /* stdma_lock() may sleep which means it can't be used here */ + return stdma_try_lock(scsi_falcon_intr, instance); } #ifndef MODULE -- 2.26.2