linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* ipr SATA problems in 2.6.20
@ 2007-01-16 22:24 Brian King
  2007-01-16 22:41 ` Alan
  0 siblings, 1 reply; 17+ messages in thread
From: Brian King @ 2007-01-16 22:24 UTC (permalink / raw)
  To: linux-scsi; +Cc: James Bottomley, Jeff Garzik, linux-ide@vger.kernel.org

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.
>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

-- 
Brian King
eServer Storage I/O
IBM Linux Technology Center

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

* Re: ipr SATA problems in 2.6.20
  2007-01-16 22:24 ipr SATA problems in 2.6.20 Brian King
@ 2007-01-16 22:41 ` Alan
  2007-01-16 22:45   ` Jeff Garzik
  0 siblings, 1 reply; 17+ messages in thread
From: Alan @ 2007-01-16 22:41 UTC (permalink / raw)
  To: brking; +Cc: linux-scsi, James Bottomley, Jeff Garzik,
	linux-ide@vger.kernel.org

> 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.

I was looking at a PATA trace that was looking the same 2 days ago and
couldn't figure what was going on. 

Alan

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

* Re: ipr SATA problems in 2.6.20
  2007-01-16 22:41 ` Alan
@ 2007-01-16 22:45   ` Jeff Garzik
  2007-01-16 23:11     ` James Bottomley
  2007-01-16 23:28     ` ipr SATA problems in 2.6.20 Alan
  0 siblings, 2 replies; 17+ messages in thread
From: Jeff Garzik @ 2007-01-16 22:45 UTC (permalink / raw)
  To: Alan
  Cc: brking, linux-scsi, James Bottomley, linux-ide@vger.kernel.org,
	Tejun Heo

Alan wrote:
>> 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.
> 
> 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



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

* Re: ipr SATA problems in 2.6.20
  2007-01-16 22:45   ` Jeff Garzik
@ 2007-01-16 23:11     ` James Bottomley
  2007-01-16 23:17       ` Brian King
  2007-01-16 23:28     ` ipr SATA problems in 2.6.20 Alan
  1 sibling, 1 reply; 17+ messages in thread
From: James Bottomley @ 2007-01-16 23:11 UTC (permalink / raw)
  To: Jeff Garzik
  Cc: Alan, brking, linux-scsi, linux-ide@vger.kernel.org, Tejun Heo

On Tue, 2007-01-16 at 17:45 -0500, Jeff Garzik wrote:
> 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



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

* Re: ipr SATA problems in 2.6.20
  2007-01-16 23:11     ` James Bottomley
@ 2007-01-16 23:17       ` Brian King
  2007-01-16 23:30         ` James Bottomley
  2007-01-16 23:33         ` Brian King
  0 siblings, 2 replies; 17+ messages in thread
From: Brian King @ 2007-01-16 23:17 UTC (permalink / raw)
  To: James Bottomley
  Cc: Jeff Garzik, Alan, linux-scsi, linux-ide@vger.kernel.org,
	Tejun Heo

James Bottomley wrote:
> On Tue, 2007-01-16 at 17:45 -0500, Jeff Garzik wrote:
>> 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?

I think we are OK here since atapi_xlate is only ever called by
ata_scsi_translate.

Brian

-- 
Brian King
eServer Storage I/O
IBM Linux Technology Center

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

* Re: ipr SATA problems in 2.6.20
  2007-01-16 22:45   ` Jeff Garzik
  2007-01-16 23:11     ` James Bottomley
@ 2007-01-16 23:28     ` Alan
  1 sibling, 0 replies; 17+ messages in thread
From: Alan @ 2007-01-16 23:28 UTC (permalink / raw)
  To: Jeff Garzik
  Cc: brking, linux-scsi, James Bottomley, linux-ide@vger.kernel.org,
	Tejun Heo

On Tue, 16 Jan 2007 17:45:56 -0500
Jeff Garzik <jgarzik@pobox.com> wrote:

> Alan wrote:
> >> 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.
> > 
> > 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

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

* Re: ipr SATA problems in 2.6.20
  2007-01-16 23:17       ` Brian King
@ 2007-01-16 23:30         ` James Bottomley
  2007-01-16 23:33         ` Brian King
  1 sibling, 0 replies; 17+ messages in thread
From: James Bottomley @ 2007-01-16 23:30 UTC (permalink / raw)
  To: brking; +Cc: Jeff Garzik, Alan, linux-scsi, linux-ide@vger.kernel.org,
	Tejun Heo

On Tue, 2007-01-16 at 17:17 -0600, Brian King wrote:
> I think we are OK here since atapi_xlate is only ever called by
> ata_scsi_translate.

True.  But can you tell me where it gets set in ata_scsi_translate if
sc_data_direction is DMA_NONE ...

James



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

* Re: ipr SATA problems in 2.6.20
  2007-01-16 23:17       ` Brian King
  2007-01-16 23:30         ` James Bottomley
@ 2007-01-16 23:33         ` Brian King
  2007-01-17  2:34           ` [PATCH] libata: initialize qc->dma_dir to DMA_NONE Tejun Heo
  1 sibling, 1 reply; 17+ messages in thread
From: Brian King @ 2007-01-16 23:33 UTC (permalink / raw)
  To: brking
  Cc: James Bottomley, Jeff Garzik, Alan, linux-scsi,
	linux-ide@vger.kernel.org, Tejun Heo

Brian King wrote:
> James Bottomley wrote:
>> On Tue, 2007-01-16 at 17:45 -0500, Jeff Garzik wrote:
>>> 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?
> 
> I think we are OK here since atapi_xlate is only ever called by
> ata_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

-- 
Brian King
eServer Storage I/O
IBM Linux Technology Center

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

* [PATCH] libata: initialize qc->dma_dir to DMA_NONE
  2007-01-16 23:33         ` Brian King
@ 2007-01-17  2:34           ` Tejun Heo
  2007-01-17  3:43             ` Brian King
                               ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: Tejun Heo @ 2007-01-17  2:34 UTC (permalink / raw)
  To: Brian King
  Cc: Jeff Garzik, James Bottomley, Alan, linux-scsi,
	linux-ide@vger.kernel.org

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.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Cc: James Bottomley <James.Bottomley@SteelEye.com>

diff --git a/include/linux/libata.h b/include/linux/libata.h
index 7cfc18f..925ad7f 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -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;

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

* Re: [PATCH] libata: initialize qc->dma_dir to DMA_NONE
  2007-01-17  2:34           ` [PATCH] libata: initialize qc->dma_dir to DMA_NONE Tejun Heo
@ 2007-01-17  3:43             ` Brian King
  2007-01-17  3:59               ` Jeff Garzik
  2007-01-17 15:19             ` James Bottomley
  2007-01-20  0:19             ` Jeff Garzik
  2 siblings, 1 reply; 17+ messages in thread
From: Brian King @ 2007-01-17  3:43 UTC (permalink / raw)
  To: Tejun Heo
  Cc: Brian King, Jeff Garzik, James Bottomley, Alan, linux-scsi,
	linux-ide@vger.kernel.org

ACK

Tejun Heo wrote:
> 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.
> 
> Signed-off-by: Tejun Heo <htejun@gmail.com>
> Cc: James Bottomley <James.Bottomley@SteelEye.com>
> 
> diff --git a/include/linux/libata.h b/include/linux/libata.h
> index 7cfc18f..925ad7f 100644
> --- a/include/linux/libata.h
> +++ b/include/linux/libata.h
> @@ -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 majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


-- 
Brian King
eServer Storage I/O
IBM Linux Technology Center

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

* Re: [PATCH] libata: initialize qc->dma_dir to DMA_NONE
  2007-01-17  3:43             ` Brian King
@ 2007-01-17  3:59               ` Jeff Garzik
  2007-01-17 14:37                 ` Brian King
  0 siblings, 1 reply; 17+ messages in thread
From: Jeff Garzik @ 2007-01-17  3:59 UTC (permalink / raw)
  To: Brian King
  Cc: Tejun Heo, Brian King, James Bottomley, Alan, linux-scsi,
	linux-ide@vger.kernel.org

Brian King wrote:
> ACK

Does this response mean that you've tested it, and successfully verified 
your problem is gone?

	Jeff




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

* Re: [PATCH] libata: initialize qc->dma_dir to DMA_NONE
  2007-01-17  3:59               ` Jeff Garzik
@ 2007-01-17 14:37                 ` Brian King
  2007-01-17 18:35                   ` Brian King
  0 siblings, 1 reply; 17+ messages in thread
From: Brian King @ 2007-01-17 14:37 UTC (permalink / raw)
  To: Jeff Garzik
  Cc: Brian King, Tejun Heo, James Bottomley, Alan, linux-scsi,
	linux-ide@vger.kernel.org

Jeff Garzik wrote:
> Brian King wrote:
>> 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


-- 
Brian King
eServer Storage I/O
IBM Linux Technology Center

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

* Re: [PATCH] libata: initialize qc->dma_dir to DMA_NONE
  2007-01-17  2:34           ` [PATCH] libata: initialize qc->dma_dir to DMA_NONE Tejun Heo
  2007-01-17  3:43             ` Brian King
@ 2007-01-17 15:19             ` James Bottomley
  2007-01-17 15:49               ` Tejun Heo
  2007-01-20  0:19             ` Jeff Garzik
  2 siblings, 1 reply; 17+ messages in thread
From: James Bottomley @ 2007-01-17 15:19 UTC (permalink / raw)
  To: Tejun Heo
  Cc: Brian King, Jeff Garzik, Alan, linux-scsi,
	linux-ide@vger.kernel.org

On Wed, 2007-01-17 at 11:34 +0900, Tejun Heo wrote:
> 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.
> 
> Signed-off-by: Tejun Heo <htejun@gmail.com>
> Cc: James Bottomley <James.Bottomley@SteelEye.com>

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



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

* Re: [PATCH] libata: initialize qc->dma_dir to DMA_NONE
  2007-01-17 15:19             ` James Bottomley
@ 2007-01-17 15:49               ` Tejun Heo
  2007-01-17 16:07                 ` James Bottomley
  0 siblings, 1 reply; 17+ messages in thread
From: Tejun Heo @ 2007-01-17 15:49 UTC (permalink / raw)
  To: James Bottomley
  Cc: Brian King, Jeff Garzik, Alan, linux-scsi,
	linux-ide@vger.kernel.org

James Bottomley wrote:
> This looks perfectly fine as a possible solution.  Is there any reason
> not to initialise qc->dma_dir unconditionally 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.

> 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.

-- 
tejun

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

* Re: [PATCH] libata: initialize qc->dma_dir to DMA_NONE
  2007-01-17 15:49               ` Tejun Heo
@ 2007-01-17 16:07                 ` James Bottomley
  0 siblings, 0 replies; 17+ messages in thread
From: James Bottomley @ 2007-01-17 16:07 UTC (permalink / raw)
  To: Tejun Heo
  Cc: Brian King, Jeff Garzik, Alan, linux-scsi,
	linux-ide@vger.kernel.org

On Thu, 2007-01-18 at 00:49 +0900, Tejun Heo wrote:
> James Bottomley wrote:
> > This looks perfectly fine as a possible solution.  Is there any reason
> > not to initialise qc->dma_dir unconditionally 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.

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.

> > 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



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

* Re: [PATCH] libata: initialize qc->dma_dir to DMA_NONE
  2007-01-17 14:37                 ` Brian King
@ 2007-01-17 18:35                   ` Brian King
  0 siblings, 0 replies; 17+ messages in thread
From: Brian King @ 2007-01-17 18:35 UTC (permalink / raw)
  To: brking
  Cc: Jeff Garzik, Brian King, Tejun Heo, James Bottomley, Alan,
	linux-scsi, linux-ide@vger.kernel.org

Brian King wrote:
> Jeff Garzik wrote:
>> Brian King wrote:
>>> 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


-- 
Brian King
eServer Storage I/O
IBM Linux Technology Center

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

* Re: [PATCH] libata: initialize qc->dma_dir to DMA_NONE
  2007-01-17  2:34           ` [PATCH] libata: initialize qc->dma_dir to DMA_NONE Tejun Heo
  2007-01-17  3:43             ` Brian King
  2007-01-17 15:19             ` James Bottomley
@ 2007-01-20  0:19             ` Jeff Garzik
  2 siblings, 0 replies; 17+ messages in thread
From: Jeff Garzik @ 2007-01-20  0:19 UTC (permalink / raw)
  To: Tejun Heo
  Cc: Brian King, James Bottomley, Alan, linux-scsi,
	linux-ide@vger.kernel.org

Tejun Heo wrote:
> 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.
> 
> Signed-off-by: Tejun Heo <htejun@gmail.com>
> Cc: James Bottomley <James.Bottomley@SteelEye.com>

applied to #upstream-fixes



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

end of thread, other threads:[~2007-01-20  0:19 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-01-16 22:24 ipr SATA problems in 2.6.20 Brian King
2007-01-16 22:41 ` Alan
2007-01-16 22:45   ` Jeff Garzik
2007-01-16 23:11     ` James Bottomley
2007-01-16 23:17       ` Brian King
2007-01-16 23:30         ` James Bottomley
2007-01-16 23:33         ` Brian King
2007-01-17  2:34           ` [PATCH] libata: initialize qc->dma_dir to DMA_NONE Tejun Heo
2007-01-17  3:43             ` Brian King
2007-01-17  3:59               ` Jeff Garzik
2007-01-17 14:37                 ` Brian King
2007-01-17 18:35                   ` Brian King
2007-01-17 15:19             ` James Bottomley
2007-01-17 15:49               ` Tejun Heo
2007-01-17 16:07                 ` James Bottomley
2007-01-20  0:19             ` Jeff Garzik
2007-01-16 23:28     ` ipr SATA problems in 2.6.20 Alan

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).