public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [SCSI] sg.c: SG_DXFER_TO_FROM_DEV mean DMA_BIDIRECTIONAL
@ 2006-11-04 19:58 Luben Tuikov
  2006-11-05  3:56 ` Jeff Garzik
  2006-11-05 14:34 ` Douglas Gilbert
  0 siblings, 2 replies; 4+ messages in thread
From: Luben Tuikov @ 2006-11-04 19:58 UTC (permalink / raw)
  To: linux-scsi; +Cc: Douglas Gilbert

[-- Attachment #1: Type: text/plain, Size: 248 bytes --]

SG_DXFER_TO_FROM_DEV means DMA_BIDIRECTIONAL, not
DMA_FROM_DEVICE.

Signed-off-by: Luben Tuikov <ltuikov@yahoo.com>
---
 drivers/scsi/sg.c |   11 +++++------
 1 files changed, 5 insertions(+), 6 deletions(-)

This patch is 8 months old.

     Luben

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 2098548068-sg2.txt --]
[-- Type: text/inline; name="sg2.txt", Size: 1272 bytes --]

diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 5a0a193..3f81477 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -608,12 +608,11 @@ sg_write(struct file *filp, const char _
 	if (hp->dxfer_direction == SG_DXFER_TO_FROM_DEV)
 		if (printk_ratelimit())
 			printk(KERN_WARNING
-			       "sg_write: data in/out %d/%d bytes for SCSI command 0x%x--"
-			       "guessing data in;\n" KERN_WARNING "   "
-			       "program %s not setting count and/or reply_len properly\n",
+			       "sg_write: program %s: data in/out %d/%d bytes for SCSI command 0x%x--"
+			       "bidirectional;\n",
+			       current->comm,
 			       old_hdr.reply_len - (int)SZ_SG_HEADER,
-			       input_size, (unsigned int) cmnd[0],
-			       current->comm);
+			       input_size, (unsigned int) cmnd[0]);
 	k = sg_common_write(sfp, srp, cmnd, sfp->timeout, blocking);
 	return (k < 0) ? k : count;
 }
@@ -724,13 +723,13 @@ sg_common_write(Sg_fd * sfp, Sg_request
 	}
 
 	switch (hp->dxfer_direction) {
-	case SG_DXFER_TO_FROM_DEV:
 	case SG_DXFER_FROM_DEV:
 		data_dir = DMA_FROM_DEVICE;
 		break;
 	case SG_DXFER_TO_DEV:
 		data_dir = DMA_TO_DEVICE;
 		break;
+	case SG_DXFER_TO_FROM_DEV:
 	case SG_DXFER_UNKNOWN:
 		data_dir = DMA_BIDIRECTIONAL;
 		break;
-- 
1.4.3.3.g8478


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

* Re: [PATCH] [SCSI] sg.c: SG_DXFER_TO_FROM_DEV mean DMA_BIDIRECTIONAL
  2006-11-04 19:58 [PATCH] [SCSI] sg.c: SG_DXFER_TO_FROM_DEV mean DMA_BIDIRECTIONAL Luben Tuikov
@ 2006-11-05  3:56 ` Jeff Garzik
  2006-11-05 14:34 ` Douglas Gilbert
  1 sibling, 0 replies; 4+ messages in thread
From: Jeff Garzik @ 2006-11-05  3:56 UTC (permalink / raw)
  To: ltuikov; +Cc: linux-scsi, Douglas Gilbert

Luben Tuikov wrote:
> SG_DXFER_TO_FROM_DEV means DMA_BIDIRECTIONAL, not
> DMA_FROM_DEVICE.
> 
> Signed-off-by: Luben Tuikov <ltuikov@yahoo.com>

ACK



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

* Re: [PATCH] [SCSI] sg.c: SG_DXFER_TO_FROM_DEV mean DMA_BIDIRECTIONAL
  2006-11-04 19:58 [PATCH] [SCSI] sg.c: SG_DXFER_TO_FROM_DEV mean DMA_BIDIRECTIONAL Luben Tuikov
  2006-11-05  3:56 ` Jeff Garzik
@ 2006-11-05 14:34 ` Douglas Gilbert
  2006-11-05 22:54   ` James Bottomley
  1 sibling, 1 reply; 4+ messages in thread
From: Douglas Gilbert @ 2006-11-05 14:34 UTC (permalink / raw)
  To: ltuikov; +Cc: linux-scsi

Luben Tuikov wrote:
> SG_DXFER_TO_FROM_DEV means DMA_BIDIRECTIONAL, not
> DMA_FROM_DEVICE.
> 
> Signed-off-by: Luben Tuikov <ltuikov@yahoo.com>
> ---
>  drivers/scsi/sg.c |   11 +++++------
>  1 files changed, 5 insertions(+), 6 deletions(-)
> 
> This patch is 8 months old.

While this patch is sensible, it breaks a very arcane
usage that I inherited with the sg driver in 1998.
At that time there was no resid, so application clients
(e.g. cdrecord) had no way of knowing if the amount of
data they requested to be read, was actually read.
So, as indirect IO was the only game in town, the
hack used was to prefill the kernel buffer prior to
a read, and then check if it had been overwritten
after the read operation.
Hence SG_DXFER_TO_FROM_DEV was actually a read from
the device.

Some LLDs still do not implement resid (properly).

I'm happy to accept the change as long as people are
prepared to wear the breakage.

Doug Gilbert

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

* Re: [PATCH] [SCSI] sg.c: SG_DXFER_TO_FROM_DEV mean DMA_BIDIRECTIONAL
  2006-11-05 14:34 ` Douglas Gilbert
@ 2006-11-05 22:54   ` James Bottomley
  0 siblings, 0 replies; 4+ messages in thread
From: James Bottomley @ 2006-11-05 22:54 UTC (permalink / raw)
  To: dougg; +Cc: ltuikov, linux-scsi

On Sun, 2006-11-05 at 09:34 -0500, Douglas Gilbert wrote:
> I'm happy to accept the change as long as people are
> prepared to wear the breakage.

You're the maintainer ... is that an ACK or a NACK?

James



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

end of thread, other threads:[~2006-11-05 22:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-04 19:58 [PATCH] [SCSI] sg.c: SG_DXFER_TO_FROM_DEV mean DMA_BIDIRECTIONAL Luben Tuikov
2006-11-05  3:56 ` Jeff Garzik
2006-11-05 14:34 ` Douglas Gilbert
2006-11-05 22:54   ` James Bottomley

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