Skip to contentSkip to conversation

duplicate test 'SCpnt->sc_data_direction == DMA_FROM_DEVICE'

PATCH In review Roel Kluin 3 participants 5 messages Feb 4, 2008 – Feb 6, 2008 SCSI

lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

PATCH 1/1 duplicate test 'SCpnt->sc_data_direction == DMA_FROM_DEVICE'

It should be like this I guess? this patch was not yet tested, please confirm.
--
Note the duplicate test 'SCpnt->sc_data_direction == DMA_FROM_DEVICE'

from Documentation/DMA-API.txt:
DMA_TO_DEVICE = PCI_DMA_TODEVICE data is going from the
memory to the device
DMA_FROM_DEVICE = PCI_DMA_FROMDEVICE data is coming from
the device to the

---

drivers/scsi/u14-34f.c +1 -1
index 662c004..1e704f9 100644
@@ -1208,15 +1208,15 @@ static void scsi_to_dev_dir(unsigned int i, unsigned int j) {
       };
 
    struct mscp *cpp;
    struct scsi_cmnd *SCpnt;
 
    cpp = &HD(j)->cp[i]; SCpnt = cpp->SCpnt;
 
-   if (SCpnt->sc_data_direction == DMA_FROM_DEVICE) {
+   if (SCpnt->sc_data_direction == DMA_TO_DEVICE) {
       cpp->xdir = DTD_IN;
       return;
       }
    else if (SCpnt->sc_data_direction == DMA_FROM_DEVICE) {
       cpp->xdir = DTD_OUT;
       return;
       }
#1 lore raw

Good to know that somebody still uses the Ultrastor 14f board :).....
Yes, this typo was introduced by somebody doing massive editing to all scsi drivers long ago.
Cheers,
--db

-----Original Message-----
From: Roel Kluin [mailto:[email protected]]
Sent: Monday, February 04, 2008 11:37 PM
To: Ballabio, Dario
Cc: [email protected]; lkml
Subject: [PATCH][drivers/scsi/u14-34f.c] duplicate test 'SCpnt->sc_data_direction == DMA_FROM_DEVICE'

It should be like this I guess? this patch was not yet tested, please confirm.
--
Note the duplicate test 'SCpnt->sc_data_direction == DMA_FROM_DEVICE'

from Documentation/DMA-API.txt:
DMA_TO_DEVICE = PCI_DMA_TODEVICE data is going from the
memory to the device
DMA_FROM_DEVICE = PCI_DMA_FROMDEVICE data is coming from
the device to the

---

drivers/scsi/u14-34f.c +0 -0
index 662c004..1e704f9 100644
@@ -1208,15 +1208,15 @@ static void scsi_to_dev_dir(unsigned int i,
unsigned int j) {
       };
 
    struct mscp *cpp;
    struct scsi_cmnd *SCpnt;
 
    cpp = &HD(j)->cp[i]; SCpnt = cpp->SCpnt;

- if (SCpnt->sc_data_direction == DMA_FROM_DEVICE) {

+   if (SCpnt->sc_data_direction == DMA_TO_DEVICE) {
       cpp->xdir = DTD_IN;
       return;
       }
    else if (SCpnt->sc_data_direction == DMA_FROM_DEVICE) {
       cpp->xdir = DTD_OUT;
       return;
       }
author
#2 lore raw
Quoted 5 lines · [email protected] wrote:

Good to know that somebody still uses the Ultrastor 14f board :).....
Yes, this typo was introduced by somebody doing massive editing to all scsi drivers long ago.
Cheers,
--db

Actually, I do not own a Ultrastor 14f board. I found this by searching for if (test)
...
else if (exactly same test)
...
Thanks,
Roel

maintainer
#3 lore raw
In reply to Roel Kluin
Quoted 24 lines · Roel Kluin

It should be like this I guess? this patch was not yet tested, please confirm.
--
Note the duplicate test 'SCpnt->sc_data_direction == DMA_FROM_DEVICE'

from Documentation/DMA-API.txt:
DMA_TO_DEVICE = PCI_DMA_TODEVICE data is going from the
memory to the device
DMA_FROM_DEVICE = PCI_DMA_FROMDEVICE data is coming from
the device to the

---

drivers/scsi/u14-34f.c +0 -0
index 662c004..1e704f9 100644
@@ -1208,15 +1208,15 @@ static void scsi_to_dev_dir(unsigned int i, unsigned int j) {
       };
 
    struct mscp *cpp;
    struct scsi_cmnd *SCpnt;
 
    cpp = &HD(j)->cp[i]; SCpnt = cpp->SCpnt;

drivers/scsi/u14-34f.c static void scsi_to_dev_dir(unsigned int i, unsigned int j) { · line 1222

Quoted 10 lines
drivers/scsi/u14-34f.c +1 -1
 
-   if (SCpnt->sc_data_direction == DMA_FROM_DEVICE) {
+   if (SCpnt->sc_data_direction == DMA_TO_DEVICE) {
       cpp->xdir = DTD_IN;
       return;
       }
    else if (SCpnt->sc_data_direction == DMA_FROM_DEVICE) {
       cpp->xdir = DTD_OUT;
       return;
       }

Well spotted, this is definitely a huge bug in the driver.

However, I think on closer examination that DTD_IN actually means transfer from device to host, so DMA_FROM_DEVICE is correct for that case. It should be DMA_TO_DEVICE in the else if() piece.

Could you correct and resend the patch and I'll apply it.

Thanks,

James

author
#4 lore raw
Quoted 12 lines · James Bottomley

Review

Quoted 8 lines · Roel Kluin

Note the duplicate test 'SCpnt->sc_data_direction == DMA_FROM_DEVICE'

(quoted diff) +1 -1
-   if (SCpnt->sc_data_direction == DMA_FROM_DEVICE) {
+   if (SCpnt->sc_data_direction == DMA_TO_DEVICE) {
       cpp->xdir = DTD_IN;
       return;
       }
    else if (SCpnt->sc_data_direction == DMA_FROM_DEVICE) {
Quoted 7 lines

Well spotted, this is definitely a huge bug in the driver.

However, I think on closer examination that DTD_IN actually means transfer from device to host, so DMA_FROM_DEVICE is correct for that case. It should be DMA_TO_DEVICE in the else if() piece.

Could you correct and resend the patch and I'll apply it.

Thanks for your review.
---
Direction of data transfer 'DMA_FROM_DEVICE' was tested twice. DTD_OUT means transfer from host to device. This should occur when the direction of data transfer (sc_data_direction) is 'DMA_TO_DEVICE'.

---

drivers/scsi/u14-34f.c +1 -1
index 662c004..58d7eee 100644
@@ -1215,9 +1215,9 @@ static void scsi_to_dev_dir(unsigned int i, unsigned int j) {
    if (SCpnt->sc_data_direction == DMA_FROM_DEVICE) {
       cpp->xdir = DTD_IN;
       return;
       }
-   else if (SCpnt->sc_data_direction == DMA_FROM_DEVICE) {
+   else if (SCpnt->sc_data_direction == DMA_TO_DEVICE) {
       cpp->xdir = DTD_OUT;
       return;
       }
    else if (SCpnt->sc_data_direction == DMA_NONE) {