mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Finn Thain <fthain@telegraphics.com.au>
To: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Michael Schmitz <schmitzmic@gmail.com>,
	Ondrej Zary <linux@rainbow-software.org>,
	<linux-scsi@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: [PATCH 03/12] scsi/atari_scsi: Make device register accessors re-enterant
Date: Tue,  4 Oct 2016 01:40:50 -0400 (EDT)	[thread overview]
Message-ID: <b83c2a3699efc5ea5d8b11d68b897d3ac66bb050.1475559357.git.fthain@telegraphics.com.au> (raw)
In-Reply-To: <cover.1475559357.git.fthain@telegraphics.com.au>

This patch fixes an old bug: accesses to device registers from the
interrupt handler (after reselection, DMA completion etc.) could mess
up a device register access elsewhere, if the latter takes place outside
of an irq lock (during selection etc.).

Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
---
 drivers/scsi/atari_scsi.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/atari_scsi.c b/drivers/scsi/atari_scsi.c
index a59ad94..862f30c 100644
--- a/drivers/scsi/atari_scsi.c
+++ b/drivers/scsi/atari_scsi.c
@@ -670,14 +670,26 @@ static void atari_scsi_tt_reg_write(unsigned char reg, unsigned char value)
 
 static unsigned char atari_scsi_falcon_reg_read(unsigned char reg)
 {
-	dma_wd.dma_mode_status= (u_short)(0x88 + reg);
-	return (u_char)dma_wd.fdc_acces_seccount;
+	unsigned long flags;
+	unsigned char result;
+
+	reg += 0x88;
+	local_irq_save(flags);
+	dma_wd.dma_mode_status = (u_short)reg;
+	result = (u_char)dma_wd.fdc_acces_seccount;
+	local_irq_restore(flags);
+	return result;
 }
 
 static void atari_scsi_falcon_reg_write(unsigned char reg, unsigned char value)
 {
-	dma_wd.dma_mode_status = (u_short)(0x88 + reg);
+	unsigned long flags;
+
+	reg += 0x88;
+	local_irq_save(flags);
+	dma_wd.dma_mode_status = (u_short)reg;
 	dma_wd.fdc_acces_seccount = (u_short)value;
+	local_irq_restore(flags);
 }
 
 
-- 
2.7.3

  reply	other threads:[~2016-10-04  5:41 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-04  5:40 [PATCH 00/12] Fixes, cleanup and g_NCR5380_mmio/g_NCR5380 merger Finn Thain
2016-10-04  5:40 ` Finn Thain [this message]
2016-10-04  5:40 ` [PATCH 02/12] scsi/cumana_1: Remove unused cumanascsi_setup() function Finn Thain
2016-10-04  5:40 ` [PATCH 09/12] scsi/ncr5380: Pass hostdata pointer to register polling routines Finn Thain
2016-10-04  5:40 ` [PATCH 05/12] scsi/ncr5380: Increase register polling limit Finn Thain
2016-10-04  5:40 ` [PATCH 10/12] scsi/ncr5380: Expedite register polling Finn Thain
2016-10-04  5:40 ` [PATCH 11/12] scsi/ncr5380: Use correct types for DMA routines Finn Thain
2016-10-04  5:40 ` [PATCH 08/12] scsi/ncr5380: Use correct types for device register accessors Finn Thain
2016-10-04  5:40 ` [PATCH 06/12] scsi/ncr5380: Improve hostdata struct member alignment and cache-ability Finn Thain
2016-10-04  5:40 ` [PATCH 04/12] scsi/ncr5380: Simplify register polling limit Finn Thain
2016-10-04  5:40 ` [PATCH 01/12] scsi/g_NCR5380: Merge g_NCR5380 and g_NCR5380_mmio drivers Finn Thain
2016-10-04  5:40 ` [PATCH 07/12] scsi/ncr5380: Store IO ports and addresses in host private data Finn Thain
2016-10-04  5:40 ` [PATCH 12/12] scsi/ncr5380: Suppress unhelpful "interrupt without IRQ bit" message Finn Thain
2016-10-04  8:23 ` [PATCH 00/12] Fixes, cleanup and g_NCR5380_mmio/g_NCR5380 merger Hannes Reinecke
2016-10-05 19:57 ` Ondrej Zary

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b83c2a3699efc5ea5d8b11d68b897d3ac66bb050.1475559357.git.fthain@telegraphics.com.au \
    --to=fthain@telegraphics.com.au \
    --cc=jejb@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=linux@rainbow-software.org \
    --cc=martin.petersen@oracle.com \
    --cc=schmitzmic@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®