linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andi Kleen <andi@firstfloor.org>
To: James.Bottomley@HansenPartnership.com,
	linux-scsi@vger.kernel.org, axboe@kernel.dk
Subject: [PATCH] [5/20] Remove unchecked_isa_dma in eata.c
Date: Fri,  7 Mar 2008 18:54:04 +0100 (CET)	[thread overview]
Message-ID: <20080307175404.CC5201B41AE@basil.firstfloor.org> (raw)
In-Reply-To: <20080307653.720459648@firstfloor.org>


- Allocate hostdata with DMA separately in the driver
- Audited ->cmnd uses and it only ever copies them
- Enable sense_buffer bouncing using new sense_buffer_isa flag
- Enable block layer bouncing explicitely
- Remove unchecked_isa_dma

Untested due to lack of hardware

Signed-off-by: Andi Kleen <ak@suse.de>

---
 drivers/scsi/eata.c |   54 +++++++++++++++++++++++++++++++++++++---------------
 1 file changed, 39 insertions(+), 15 deletions(-)

Index: linux/drivers/scsi/eata.c
===================================================================
--- linux.orig/drivers/scsi/eata.c
+++ linux/drivers/scsi/eata.c
@@ -512,6 +512,13 @@ static int eata2x_bios_param(struct scsi
 			     sector_t, int *);
 static int eata2x_slave_configure(struct scsi_device *);
 
+static int eata_adjust_queue(struct scsi_device *device)
+{
+	if (device->host->sense_buffer_isa)
+		blk_queue_bounce_limit(device->request_queue, BLK_BOUNCE_ISA);
+	return 0;
+}
+
 static struct scsi_host_template driver_template = {
 	.name = "EATA/DMA 2.0x rev. 8.10.00 ",
 	.detect = eata2x_detect,
@@ -522,8 +529,8 @@ static struct scsi_host_template driver_
 	.bios_param = eata2x_bios_param,
 	.slave_configure = eata2x_slave_configure,
 	.this_id = 7,
-	.unchecked_isa_dma = 1,
 	.use_clustering = ENABLE_CLUSTERING,
+	.slave_alloc = eata_adjust_queue,
 };
 
 #if !defined(__BIG_ENDIAN_BITFIELD) && !defined(__LITTLE_ENDIAN_BITFIELD)
@@ -834,6 +841,16 @@ struct hostdata {
 	struct mssp sp;		/* Local copy of sp buffer */
 };
 
+struct hostdata_ptr {
+	struct hostdata *host;
+	dma_addr_t dma;
+};
+
+#define eata_shost_priv(shost) \
+	(((struct hostdata_ptr *)shost_priv(shost))->host)
+#define eata_shost_dma(shost) \
+	(((struct hostdata_ptr *)shost_priv(shost))->dma)
+
 static struct Scsi_Host *sh[MAX_BOARDS];
 static const char *driver_name = "EATA";
 static char sha[MAX_BOARDS];
@@ -1266,14 +1283,23 @@ static int port_detect(unsigned long por
 #endif
 
 	spin_unlock_irq(&driver_lock);
-	sh[j] = shost = scsi_register(tpnt, sizeof(struct hostdata));
+	sh[j] = shost = scsi_register(tpnt, sizeof(struct hostdata_ptr));
+	ha = dma_alloc_coherent(pdev ? &pdev->dev : NULL,
+				sizeof(struct hostdata),
+				&eata_shost_dma(shost), GFP_KERNEL);
 	spin_lock_irq(&driver_lock);
 
-	if (shost == NULL) {
+	if (shost == NULL || ha == NULL) {
+		if (ha)
+			dma_free_coherent(pdev ? &pdev->dev : NULL,
+					  sizeof(struct hostdata),
+					  ha, eata_shost_dma(shost));
 		printk("%s: unable to register host, detaching.\n", name);
 		goto freedma;
 	}
 
+	eata_shost_priv(shost) = ha;
+
 	shost->io_port = port_base;
 	shost->unique_id = port_base;
 	shost->n_io_port = REGION_SIZE;
@@ -1283,8 +1309,6 @@ static int port_detect(unsigned long por
 	shost->this_id = (ushort) info.host_addr[3];
 	shost->can_queue = (ushort) info.queue_size;
 	shost->cmd_per_lun = MAX_CMD_PER_LUN;
-
-	ha = (struct hostdata *)shost->hostdata;
 	
 	memset(ha, 0, sizeof(struct hostdata));
 	ha->subversion = subversion;
@@ -1293,11 +1317,9 @@ static int port_detect(unsigned long por
 	ha->pdev = pdev;
 	ha->board_number = j;
 
-	if (ha->subversion == ESA)
-		shost->unchecked_isa_dma = 0;
-	else {
+	if (ha->subversion != ESA) {
 		unsigned long flags;
-		shost->unchecked_isa_dma = 1;
+		shost->sense_buffer_isa = 1;
 
 		flags = claim_dma_lock();
 		disable_dma(dma_channel);
@@ -1355,7 +1377,7 @@ static int port_detect(unsigned long por
 
 	for (i = 0; i < shost->can_queue; i++) {
 		size_t sz = shost->sg_tablesize *sizeof(struct sg_list);
-		gfp_t gfp_mask = (shost->unchecked_isa_dma ? GFP_DMA : 0) | GFP_ATOMIC;
+		gfp_t gfp_mask = (shost->sense_buffer_isa ? GFP_DMA : 0) | GFP_ATOMIC;
 		ha->cp[i].sglist = kmalloc(sz, gfp_mask);
 		if (!ha->cp[i].sglist) {
 			printk
@@ -1752,7 +1774,7 @@ static int eata2x_queuecommand(struct sc
 			       void (*done) (struct scsi_cmnd *))
 {
 	struct Scsi_Host *shost = SCpnt->device->host;
-	struct hostdata *ha = (struct hostdata *)shost->hostdata;
+	struct hostdata *ha = eata_shost_priv(shost);
 	unsigned int i, k;
 	struct mscp *cpp;
 
@@ -1836,7 +1858,7 @@ static int eata2x_queuecommand(struct sc
 static int eata2x_eh_abort(struct scsi_cmnd *SCarg)
 {
 	struct Scsi_Host *shost = SCarg->device->host;
-	struct hostdata *ha = (struct hostdata *)shost->hostdata;
+	struct hostdata *ha = eata_shost_priv(shost);
 	unsigned int i;
 
 	if (SCarg->host_scribble == NULL) {
@@ -1906,7 +1928,7 @@ static int eata2x_eh_host_reset(struct s
 	int arg_done = 0;
 	struct scsi_cmnd *SCpnt;
 	struct Scsi_Host *shost = SCarg->device->host;
-	struct hostdata *ha = (struct hostdata *)shost->hostdata;
+	struct hostdata *ha = eata_shost_priv(shost);
 
 	scmd_printk(KERN_INFO, SCarg,
 		"reset, enter, pid %ld.\n", SCarg->serial_number);
@@ -2292,7 +2314,7 @@ static irqreturn_t ihdlr(int irq, struct
 	unsigned int i, k, c, status, tstatus, reg;
 	struct mssp *spp;
 	struct mscp *cpp;
-	struct hostdata *ha = (struct hostdata *)shost->hostdata;
+	struct hostdata *ha = eata_shost_priv(shost);
 
 	if (shost->irq != irq)
 		panic("%s: ihdlr, irq %d, shost->irq %d.\n", ha->board_name, irq,
@@ -2555,7 +2577,7 @@ static irqreturn_t do_interrupt_handler(
 
 static int eata2x_release(struct Scsi_Host *shost)
 {
-	struct hostdata *ha = (struct hostdata *)shost->hostdata;
+	struct hostdata *ha = eata_shost_priv(shost);
 	unsigned int i;
 
 	for (i = 0; i < shost->can_queue; i++)
@@ -2575,6 +2597,8 @@ static int eata2x_release(struct Scsi_Ho
 		free_dma(shost->dma_channel);
 
 	release_region(shost->io_port, shost->n_io_port);
+	dma_free_coherent(ha->pdev ? &ha->pdev->dev : NULL,
+			  sizeof(*ha), ha, eata_shost_dma(shost));
 	scsi_unregister(shost);
 	return 0;
 }

  parent reply	other threads:[~2008-03-07 17:54 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-07 17:53 [PATCH] [0/20] Remove isa_unchecked_dma and some more GFP_DMAs in the mid layer v3 Andi Kleen
2008-03-07 17:54 ` [PATCH] [1/20] Add sense_buffer_isa to host template Andi Kleen
2008-03-07 17:54 ` [PATCH] [2/20] Remove unchecked_isa in BusLogic Andi Kleen
2008-03-07 17:54 ` [PATCH] [3/20] Remove unchecked_isa_dma in advansys.c Andi Kleen
2008-03-07 17:54 ` [PATCH] [4/20] Remove unchecked_isa_dma in gdth Andi Kleen
2008-03-07 17:54 ` Andi Kleen [this message]
2008-03-07 17:54 ` [PATCH] [6/20] Remove unchecked_isa_dma in aha1542 Andi Kleen
2008-03-07 17:54 ` [PATCH] [7/20] Remove unchecked_isa_dma in aha152x/wd7000/sym53c416/u14-34f/NCR53c406a Andi Kleen
2008-03-07 17:54 ` [PATCH] [8/20] Remove random noop unchecked_isa_dma users Andi Kleen
2008-03-07 17:54 ` [PATCH] [9/20] Add blk_kmalloc/blk_alloc_pages Andi Kleen
2008-03-13 22:06   ` James Bottomley
2008-03-14 13:48     ` Jens Axboe
2008-03-14 13:59       ` Andi Kleen
2008-03-17  8:27         ` Jens Axboe
2008-03-17  8:36           ` Andi Kleen
2008-03-17  8:38             ` Jens Axboe
2008-03-17  8:53               ` Andi Kleen
2008-03-17  9:18                 ` Boaz Harrosh
2008-03-17 10:03                   ` Andi Kleen
2008-03-17 20:29                 ` Jens Axboe
2008-03-17 20:45                   ` Andi Kleen
2008-03-17 20:46                     ` Jens Axboe
2008-03-17 21:34                       ` Andi Kleen
2008-03-18  7:26                         ` Jens Axboe
2008-04-02  3:37                         ` FUJITA Tomonori
2008-04-02  8:43                           ` Boaz Harrosh
2008-04-02 11:08                             ` FUJITA Tomonori
2008-04-02 11:32                               ` Boaz Harrosh
2008-03-17 13:59           ` James Bottomley
2008-03-07 17:54 ` [PATCH] [11/20] Remove unchecked_isa_dma support for hostdata Andi Kleen
2008-03-07 17:54 ` [PATCH] [12/20] Remove unchecked_isa_dma checks in sg.c Andi Kleen
2008-03-07 17:54 ` [PATCH] [13/20] Use blk_kmalloc in scsi_scan Andi Kleen
2008-03-07 17:54 ` [PATCH] [14/20] Don't disable direct_io for unchecked_isa_dma in st.c Andi Kleen
2008-03-14 13:51   ` Jens Axboe
2008-03-14 14:24     ` Christoph Hellwig
2008-03-16 12:39       ` Boaz Harrosh
2008-03-16 12:44         ` Andi Kleen
2008-03-17  8:28           ` Jens Axboe
2008-03-27 17:26         ` Mike Christie
2008-03-17  8:27       ` Jens Axboe
2008-03-17 10:55       ` FUJITA Tomonori
2008-03-17 12:21         ` Boaz Harrosh
2008-03-07 17:54 ` [PATCH] [15/20] Remove automatic block layer bouncing for unchecked_isa_dma Andi Kleen
2008-03-07 17:54 ` [PATCH] [16/20] Convert sr driver over the blk_kmalloc Andi Kleen
2008-03-07 17:54 ` [PATCH] [17/20] Remove unchecked_isa_dma from sysfs Andi Kleen
2008-03-07 17:54 ` [PATCH] [18/20] Switch to a single SCSI command pool Andi Kleen
2008-03-07 17:54 ` [PATCH] [19/20] Finally kill unchecked_isa_dma Andi Kleen
2008-03-07 17:54 ` [PATCH] [20/20] Convert DMA buffers in ch.c to allocate via the block layer Andi Kleen
2008-03-11 17:55 ` [PATCH] [0/20] Remove isa_unchecked_dma and some more GFP_DMAs in the mid layer v3 Boaz Harrosh
2008-03-12  0:56   ` Andi Kleen

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=20080307175404.CC5201B41AE@basil.firstfloor.org \
    --to=andi@firstfloor.org \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=axboe@kernel.dk \
    --cc=linux-scsi@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).