ipr SATA problems in 2.6.20
I'm currently debugging some problems with SATA on ipr and figured I would give a heads up. The problems include overlength errors and data corruption. Basically SATA on ipr is completely broken in its current state.
Quoted 1 line
From what I have found so far, it looks like due to some libata changes
made recently, qc->nbytes is no longer getting setup for ATAPI devices all the time.
Jeff - should qc->nbytes be used a libata user? If not, what is the proper way to determine the total command length in bytes? Summing all the sg entries? I was using nbytes + pad_len.
The other oddity I've been seeing is that I am getting zero length commands, such as TEST_UNIT_READY with a dma_dir of DMA_FROM_DEVICE. Shouldn't this be DMA_NONE? I'm still tracking this down.
Brian
Signature · 3 lines
Brian King eServer Storage I/O IBM Linux Technology Center
Quoted 3 lines
The other oddity I've been seeing is that I am getting zero length commands, such as
TEST_UNIT_READYwith adma_dirofDMA_FROM_DEVICE. Shouldn't this beDMA_NONE? I'm still tracking this down.
I was looking at a PATA trace that was looking the same 2 days ago and couldn't figure what was going on.
Alan
Quoted 6 lines · Alan
Quoted 3 lines
The other oddity I've been seeing is that I am getting zero length commands, such as
TEST_UNIT_READYwith adma_dirofDMA_FROM_DEVICE. Shouldn't this beDMA_NONE? I'm still tracking this down.I was looking at a PATA trace that was looking the same 2 days ago and couldn't figure what was going on.
Tejun recently updated the CDB length areas of the code. I bet it's either a bug somewhere in there, or the SCSI layer isn't passing us proper command lengths in a case or two.
Additional traces (starting with SCSI command, before it hits libata) would be helpful.
Jeff
Quoted 6 lines · Jeff Garzik
Tejun recently updated the CDB length areas of the code. I bet it's either a bug somewhere in there, or the SCSI layer isn't passing us proper command lengths in a case or two.
Additional traces (starting with SCSI command, before it hits libata) would be helpful.
Actually, this looks like a potential bug in atapi_xlat(): it doesn't set qc->dma_dir. Shouldn't it be setting it from qc->scsicmd->sc_data_direction like ata_scsi_translate() does?
James
Quoted 11 lines · James Bottomley
Quoted 6 lines · Jeff Garzik
Tejun recently updated the CDB length areas of the code. I bet it's either a bug somewhere in there, or the SCSI layer isn't passing us proper command lengths in a case or two.
Additional traces (starting with SCSI command, before it hits libata) would be helpful.
Actually, this looks like a potential bug in
atapi_xlat(): it doesn't setqc->dma_dir. Shouldn't it be setting it fromqc->scsicmd->sc_data_directionlikeata_scsi_translate()does?
I think we are OK here since atapi_xlate is only ever called by ata_scsi_translate.
Brian
Signature · 3 lines
Brian King eServer Storage I/O IBM Linux Technology Center
Quoted 2 lines · Brian King
I think we are OK here since
atapi_xlateis only ever called byata_scsi_translate.
True. But can you tell me where it gets set in ata_scsi_translate if sc_data_direction is DMA_NONE ...
James
Quoted 6 lines · Brian King
Quoted 5 lines · James Bottomley
Quoted 4 lines · Jeff Garzik
Tejun recently updated the CDB length areas of the code. I bet it's either a bug somewhere in there, or the SCSI layer isn't passing us proper command lengths in a case or two.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Additional traces (starting with SCSI command, before it hits libata) would be helpful.
Actually, this looks like a potential bug in
atapi_xlat(): it doesn't setqc->dma_dir. Shouldn't it be setting it fromqc->scsicmd->sc_data_directionlikeata_scsi_translate()does?I think we are OK here since
atapi_xlateis only ever called byata_scsi_translate.
I spoke too soon... ata_scsi_translate only sets up dma_dir if its a read or write, which means it never gets initialized if the direction is DMA_NONE.
Brian
Signature · 3 lines
Brian King eServer Storage I/O IBM Linux Technology Center
PATCH 1/1 libata: initialize qc->dma_dir to DMA_NONE
libata didn't used to init qc->dma_dir to any specific value on qc initialization and command translation path didn't set qc->dma_dir if the command doesn't need data transfer. This made non-data commands to have random qc->dma_dir.
This usually doesn't cause problem because LLDs usually check qc->protocol first and look at qc->dma_dir iff the command needs data transfer but this doesn't hold for all LLDs.
It might be worthwhile to rename qc->dma_dir to qc->data_dir as we use the field to tag data direction for both PIO and DMA protocols.
This problem has been spotted by James Bottomley.
include/linux/libata.h +1 -0
@@ -1139,6 +1139,7 @@ static inline void ata_tf_init(struct ata_device *dev, struct ata_taskfile *tf)static inline void ata_qc_reinit (struct ata_queued_cmd *qc) { + qc->dma_dir =DMA_NONE ; qc->__sg =NULL ; qc->flags =0 ; qc->cursect = qc->cursg = qc->cursg_ofs =0 ;
Re: [PATCH] libata: initialize qc->dma_dir to DMA_NONE
ACK
Quoted 33 lines · Tejun Heo
libata didn't used to init
qc->dma_dirto any specific value on qc initialization and command translation path didn't setqc->dma_dirif the command doesn't need data transfer. This made non-data commands to have randomqc->dma_dir.This usually doesn't cause problem because LLDs usually check
qc->protocolfirst and look atqc->dma_diriff the command needs data transfer but this doesn't hold for all LLDs.It might be worthwhile to rename
qc->dma_dirtoqc->data_diras we use the field to tag data direction for both PIO and DMA protocols.This problem has been spotted by James Bottomley.
Signed-off-by Tejun Heo <[email protected]>Cc James Bottomley <[email protected]>include/linux/libata.h +1
-1@@ -1139,6 +1139,7 @@ static inline void ata_tf_init(struct ata_device *dev, struct ata_taskfile *tf)static inline void ata_qc_reinit (struct ata_queued_cmd *qc) { + qc->dma_dir =DMA_NONE ; qc->__sg =NULL ; qc->flags =0 ; qc->cursect = qc->cursg = qc->cursg_ofs =0 ; -To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 3 lines
Brian King eServer Storage I/O IBM Linux Technology Center
Re: [PATCH] libata: initialize qc->dma_dir to DMA_NONE
Quoted 1 line · Brian King
ACK
Does this response mean that you've tested it, and successfully verified your problem is gone?
Jeff
Re: [PATCH] libata: initialize qc->dma_dir to DMA_NONE
Quoted 5 lines · Jeff Garzik
Quoted 1 line · Brian King
ACK
Does this response mean that you've tested it, and successfully verified your problem is gone?
Yes, I have tested it, but all my problems are not gone with this one patch. This fixes the problem I was seeing where the data direction was set incorrectly, but I still have some other issues I am working through. I'll be sending out additional patches shortly.
Brian
Signature · 3 lines
Brian King eServer Storage I/O IBM Linux Technology Center
Re: [PATCH] libata: initialize qc->dma_dir to DMA_NONE
Quoted 10 lines · Brian King
Quoted 4 lines · Jeff Garzik
Quoted 1 line · Brian King
ACK
Does this response mean that you've tested it, and successfully verified your problem is gone?
Yes, I have tested it, but all my problems are not gone with this one patch. This fixes the problem I was seeing where the data direction was set incorrectly, but I still have some other issues I am working through. I'll be sending out additional patches shortly.
I just sent three small libata patches to linux-ide which fix the problems I was seeing. I am still running additional tests to make sure there are not any other issues, but everything looks pretty good so far.
Thanks,
Brian
Signature · 3 lines
Brian King eServer Storage I/O IBM Linux Technology Center
Re: [PATCH] libata: initialize qc->dma_dir to DMA_NONE
In reply to Tejun HeoQuoted 9 lines · Tejun Heo
libata didn't used to init
qc->dma_dirto any specific value on qc initialization and command translation path didn't setqc->dma_dirif the command doesn't need data transfer. This made non-data commands to have randomqc->dma_dir.This usually doesn't cause problem because LLDs usually check
qc->protocolfirst and look atqc->dma_diriff the command needs data transfer but this doesn't hold for all LLDs.
Quoted 7 lines
It might be worthwhile to rename
qc->dma_dirtoqc->data_diras we use the field to tag data direction for both PIO and DMA protocols.This problem has been spotted by James Bottomley.
Signed-off-by Tejun Heo <[email protected]>Cc James Bottomley <[email protected]>
This looks perfectly fine as a possible solution. Is there any reason not to initialise qc->dma_dir unconditionally from the SCSI command? The only potential problem is DMA_BIDIRECTIONAL, which we don't use (yet) ... but if it ever did come down libata will do the wrong thing anyway.
James
Re: [PATCH] libata: initialize qc->dma_dir to DMA_NONE
Quoted 2 lines · James Bottomley
This looks perfectly fine as a possible solution. Is there any reason not to initialise
qc->dma_dirunconditionally from the SCSI command?
That should work too. I did what I did because it was more in line with what the current code assumed and initializing the field on qc alloc seemed like a good idea with or without unconditional qc->dma_dir = scmd->sc_data_direction because not all commands are translated from scsi command.
Quoted 3 lines
The only potential problem is
DMA_BIDIRECTIONAL, which we don't use (yet) ... but if it ever did come down libata will do the wrong thing anyway.
If that ever happens, libata probably should emulate it using multiple commands, I guess.
Thanks.
Signature · 1 line
tejun
Re: [PATCH] libata: initialize qc->dma_dir to DMA_NONE
Quoted 9 lines · Tejun Heo
Quoted 2 lines · James Bottomley
This looks perfectly fine as a possible solution. Is there any reason not to initialise
qc->dma_dirunconditionally from the SCSI command?That should work too. I did what I did because it was more in line with what the current code assumed and initializing the field on qc alloc seemed like a good idea with or without unconditional
qc->dma_dir=scmd->sc_data_directionbecause not all commands are translated from scsi command.
Sure, I agree with the initialisation (although it should perhaps be initialised to an error value we can detect just in case there are other paths where it would leak through uninitialised ... we'll still get cockups if a command with data ever goes through as DMA_NONE.
Quoted 6 lines
Quoted 3 lines
The only potential problem is
DMA_BIDIRECTIONAL, which we don't use (yet) ... but if it ever did come down libata will do the wrong thing anyway.If that ever happens, libata probably should emulate it using multiple commands, I guess.
This really depends on where SATA is going. Current SCSI bidirectional commands are the preserve of the complex command sets I don't believe even a SATA device would ever emulate. On the other hand, we're planning to use bidirectional in SGv4 for frame in/frame out type packets that are used to control expanders.
So the interesting question is whether SATA would ever want to drive expanders? For the low end, given the lack of success of the port multipliers which are effectively a poor man's expander, I guess not ... but, since most SAS/SATA cages seem to be coming with built in expanders, I can see that changing.
James
Jeff Garzik
AppliedRe: [PATCH] libata: initialize qc->dma_dir to DMA_NONE
In reply to Tejun HeoQuoted 9 lines · Tejun Heo
libata didn't used to init
qc->dma_dirto any specific value on qc initialization and command translation path didn't setqc->dma_dirif the command doesn't need data transfer. This made non-data commands to have randomqc->dma_dir.This usually doesn't cause problem because LLDs usually check
qc->protocolfirst and look atqc->dma_diriff the command needs data transfer but this doesn't hold for all LLDs.
Quoted 7 lines
It might be worthwhile to rename
qc->dma_dirtoqc->data_diras we use the field to tag data direction for both PIO and DMA protocols.This problem has been spotted by James Bottomley.
Signed-off-by Tejun Heo <[email protected]>Cc James Bottomley <[email protected]>
applied to #upstream-fixes
Quoted 11 lines · On Tue, 16 Jan 2007 17:45:56 -0500 Jeff Garzik <[email protected]> wrote:
Quoted 6 lines · Alan
Quoted 3 lines
The other oddity I've been seeing is that I am getting zero length commands, such as
TEST_UNIT_READYwith adma_dirofDMA_FROM_DEVICE. Shouldn't this beDMA_NONE? I'm still tracking this down.I was looking at a PATA trace that was looking the same 2 days ago and couldn't figure what was going on.
Tejun recently updated the CDB length areas of the code. I bet it's either a bug somewhere in there, or the SCSI layer isn't passing us proper command lengths in a case or two.
That might explain a few things - the qemu PIIX3 emulation bug possibly and also perhaps the recent NVidia iommu fun.
Alan