public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Make ide-scsi compile in 2.5
@ 2002-01-27  1:46 Andi Kleen
  2002-01-27 10:49 ` Jens Axboe
  2002-01-27 15:51 ` Skip Ford
  0 siblings, 2 replies; 3+ messages in thread
From: Andi Kleen @ 2002-01-27  1:46 UTC (permalink / raw)
  To: linux-kernel


ide-scsi doesn't compile currently in 2.5.x. This patch fixes it in a 
rather hackish way by adding some kmap_atomic()s.  It would be 
probably better to kmap earlier in process context in the request 
function instead, but I leave this to the people who know more 
about IDE/block layer than me (but apparently not compile ide-scsi..)
I'm also not totally convinced that it is deadlock free here to use
KM_BOUNCE_READ here, it may be safer to add a new bounce type. 
You have been warned. 

I have only tested it without highmem and it works for me. 

Hopefully there will be eventually a better fix, but for now it 
allows to burn (and mount if you use /dev/scd* for ide) CDs under 2.5 again. 


-Andi



Index: drivers/scsi/ide-scsi.c
===================================================================
RCS file: /cvs/linux/drivers/scsi/ide-scsi.c,v
retrieving revision 1.45
diff -u -u -r1.45 ide-scsi.c
--- drivers/scsi/ide-scsi.c	2002/01/16 20:58:39	1.45
+++ drivers/scsi/ide-scsi.c	2002/01/27 01:40:26
@@ -52,7 +52,7 @@
 #include "sd.h"
 #include <scsi/sg.h>
 
-#define IDESCSI_DEBUG_LOG		0
+/* #define IDESCSI_DEBUG_LOG		0 */
 
 typedef struct idescsi_pc_s {
 	u8 c[12];				/* Actual packet bytes */
@@ -132,13 +132,20 @@
 	int count;
 
 	while (bcount) {
+		void *addr; 
 		if (pc->sg - (struct scatterlist *) pc->scsi_cmd->request_buffer > pc->scsi_cmd->use_sg) {
 			printk (KERN_ERR "ide-scsi: scatter gather table too small, discarding data\n");
 			idescsi_discard_data (drive, bcount);
 			return;
 		}
 		count = IDE_MIN (pc->sg->length - pc->b_count, bcount);
-		atapi_input_bytes (drive, pc->sg->address + pc->b_count, count);
+		/* This kmap should be moved earlier into process context
+		   and use kmap instead of kmap_atomic. Not now. 
+		   It also should use an own KMAP_ type to avoid deadlocks, 
+		   butter better do the first should. b_count is hopefully <= PAGE_SIZE */  
+		addr = kmap_atomic(pc->sg->page, KM_BOUNCE_READ);  
+		atapi_input_bytes (drive, addr + pc->sg->offset + pc->b_count, count);
+		kunmap_atomic(addr, KM_BOUNCE_READ); 
 		bcount -= count; pc->b_count += count;
 		if (pc->b_count == pc->sg->length) {
 			pc->sg++;
@@ -152,13 +159,16 @@
 	int count;
 
 	while (bcount) {
+		void *addr;
 		if (pc->sg - (struct scatterlist *) pc->scsi_cmd->request_buffer > pc->scsi_cmd->use_sg) {
 			printk (KERN_ERR "ide-scsi: scatter gather table too small, padding with zeros\n");
 			idescsi_output_zeros (drive, bcount);
 			return;
 		}
 		count = IDE_MIN (pc->sg->length - pc->b_count, bcount);
-		atapi_output_bytes (drive, pc->sg->address + pc->b_count, count);
+		addr = kmap_atomic(pc->sg->page, KM_BOUNCE_READ); 
+		atapi_output_bytes (drive, addr + pc->sg->offset + pc->b_count, count);
+		kunmap_atomic(addr, KM_BOUNCE_READ); 
 		bcount -= count; pc->b_count += count;
 		if (pc->b_count == pc->sg->length) {
 			pc->sg++;
@@ -753,22 +763,21 @@
 			struct page *page = sg->page;
 			int offset = sg->offset;
 
+#if 0
 			if (!page) {
 				BUG_ON(!sg->address);
 				page = virt_to_page(sg->address);
 				offset = (unsigned long) sg->address & ~PAGE_MASK;
 			}
+#endif			
 				
 			bh->bi_io_vec[0].bv_page = page;
 			bh->bi_io_vec[0].bv_len = sg->length;
 			bh->bi_io_vec[0].bv_offset = offset;
 			bh->bi_size = sg->length;
 			bh = bh->bi_next;
-			/*
-			 * just until scsi_merge is fixed up...
-			 */
-			BUG_ON(PageHighMem(page));
-			sg->address = page_address(page) + offset;
+			sg->page =  page; 
+			sg->offset = offset; 
 			sg++;
 		}
 	} else {


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Make ide-scsi compile in 2.5
  2002-01-27  1:46 [PATCH] Make ide-scsi compile in 2.5 Andi Kleen
@ 2002-01-27 10:49 ` Jens Axboe
  2002-01-27 15:51 ` Skip Ford
  1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2002-01-27 10:49 UTC (permalink / raw)
  To: Andi Kleen; +Cc: linux-kernel

On Sun, Jan 27 2002, Andi Kleen wrote:
> 
> ide-scsi doesn't compile currently in 2.5.x. This patch fixes it in a 
> rather hackish way by adding some kmap_atomic()s.  It would be 
> probably better to kmap earlier in process context in the request 
> function instead, but I leave this to the people who know more 
> about IDE/block layer than me (but apparently not compile ide-scsi..)

axboe@burns:~/src/linux> make drivers/scsi/ide-scsi.o
gcc -D__KERNEL__ -I/home/axboe/src/linux/include -Wall
-Wstrict-prototypes -Wno-trigraphs -O2 -fomit-frame-pointer
-fno-strict-aliasing -fno-common -pipe -mpreferred-stack-boundary=2
-march=i686   -c -o drivers/scsi/ide-scsi.o drivers/scsi/ide-scsi.c
axboe@burns:~/src/linux>

Works for me, what didn't compile?

Are you sure that you aren't hitting the sg address change? AFAICS,
there should not be a need for highmem mapping here. Requests coming out
of the block layer for /dev/scd* should be bounced for you, and sg
doesn't pass on highmem pages iirc.

Puzzled...

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Make ide-scsi compile in 2.5
  2002-01-27  1:46 [PATCH] Make ide-scsi compile in 2.5 Andi Kleen
  2002-01-27 10:49 ` Jens Axboe
@ 2002-01-27 15:51 ` Skip Ford
  1 sibling, 0 replies; 3+ messages in thread
From: Skip Ford @ 2002-01-27 15:51 UTC (permalink / raw)
  To: linux-kernel

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Andi Kleen wrote:
> 
> ide-scsi doesn't compile currently in 2.5.x. This patch fixes it in a 
> rather hackish way by adding some kmap_atomic()s.  It would be 
> probably better to kmap earlier in process context in the request 
> function instead, but I leave this to the people who know more 
> about IDE/block layer than me (but apparently not compile ide-scsi..)
> I'm also not totally convinced that it is deadlock free here to use
> KM_BOUNCE_READ here, it may be safer to add a new bounce type. 
> You have been warned. 
> 
> I have only tested it without highmem and it works for me. 
> 
> Hopefully there will be eventually a better fix, but for now it 
> allows to burn (and mount if you use /dev/scd* for ide) CDs under 2.5 again. 

There was a brief period when 2.5 was released and changes went in that
it didn't compile.  Then that was fixed, but it couldn't mount or burn,
but that was also fixed.

I burned a CD a few days ago and it worked fine.  Maybe you have a
partial patch hanging around or something.

- -- 
Skip  ID: 0x7EDDDB0A
-----BEGIN PGP SIGNATURE-----

iEYEARECAAYFAjxUIewACgkQBMKxVH7d2wrDwACgrG0Nidkkl1uw6pSu33+NKxFR
9lwAnREktZYiYo2sKTSL4kpWLSnRK4BY
=43xD
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-01-27 15:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-01-27  1:46 [PATCH] Make ide-scsi compile in 2.5 Andi Kleen
2002-01-27 10:49 ` Jens Axboe
2002-01-27 15:51 ` Skip Ford

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox