2007-10-30 04:16:44

by Robert Hancock

[permalink] [raw]
Subject: sata_nv and dynamically changing DMA mask?

In the sata_nv driver, when running in ADMA mode, we can do 64-bit DMA.
However, when an ATAPI device like a DVD drive is connected, we can't
use ADMA mode, and so we have to abide by the restrictions of a normal
SFF ATA controller and can only do 32-bit DMA. We detect this and try to
set the blk_queue_bounce_limit, blk_queue_segment_boundary and
blk_queue_max_hw_segments to the values corresponding to a normal SFF
controller.

However, we have this bug report:

https://bugzilla.redhat.com/show_bug.cgi?id=351451

that their DVD drive doesn't work properly on a computer with 4GB of RAM
unless they either disable ADMA (thus resulting in the DMA parameters
being initialized to the SFF ones from the start) or pass mem=3000M to
the kernel to keep the memory above the 4GB mark from being used. Thus I
suspect that what we're trying to do with the DMA parameters is not taking.

Question is: is setting blk_queue_bounce_limit enough to prevent
addresses outside that mask from showing up, or does the device DMA mask
also need to be updated? Is there anything wrong with just changing the
DMA mask at runtime? Keep in mind, ATAPI and non-ATAPI devices can
potentially be switched out on the port, so the mask might need to be
updated at runtime..

--
Robert Hancock Saskatoon, SK, Canada
To email, remove "nospam" from [email protected]
Home Page: http://www.roberthancock.com/


2007-10-30 10:04:00

by Alan

[permalink] [raw]
Subject: Re: sata_nv and dynamically changing DMA mask?

On Mon, 29 Oct 2007 22:17:40 -0600
Robert Hancock <[email protected]> wrote:

> In the sata_nv driver, when running in ADMA mode, we can do 64-bit DMA.
> However, when an ATAPI device like a DVD drive is connected, we can't
> use ADMA mode, and so we have to abide by the restrictions of a normal
> SFF ATA controller and can only do 32-bit DMA. We detect this and try to
> set the blk_queue_bounce_limit, blk_queue_segment_boundary and
> blk_queue_max_hw_segments to the values corresponding to a normal SFF
> controller.

What about the DMA padding buffer from nv_adma_port_start and internal
buffers for commands like request sense that don't come via the request
queue directly.

Also it seems nv_adma_use_reg_mode() can decide to send other commands
via the non ADMA interface even for ATA devices. Are we 100% certain it
never decides to let through a command with DMA via the register
interface in this case - what do you see if you instrument the function ?

Alan

2007-10-30 23:58:05

by Robert Hancock

[permalink] [raw]
Subject: Re: sata_nv and dynamically changing DMA mask?

Alan Cox wrote:
> On Mon, 29 Oct 2007 22:17:40 -0600
> Robert Hancock <[email protected]> wrote:
>
>> In the sata_nv driver, when running in ADMA mode, we can do 64-bit DMA.
>> However, when an ATAPI device like a DVD drive is connected, we can't
>> use ADMA mode, and so we have to abide by the restrictions of a normal
>> SFF ATA controller and can only do 32-bit DMA. We detect this and try to
>> set the blk_queue_bounce_limit, blk_queue_segment_boundary and
>> blk_queue_max_hw_segments to the values corresponding to a normal SFF
>> controller.
>
> What about the DMA padding buffer from nv_adma_port_start and internal
> buffers for commands like request sense that don't come via the request
> queue directly.

Indeed we do call ata_port_start from nv_adma_port_start, which calls
dmam_alloc_coherent to allocate the SFF PRD table. Since the DMA mask is
64-bit, this could indeed be allocated above 4GB which would be bad.

I suppose what we could do is just not call ata_port_start there, but
move it into nv_adma_slave_config and call it when going into non-ADMA
mode. We'd have to drop the DMA mask down to 32-bit first as well as
setting blk_queue_bounce_limit though, which is one of my questions, is
this OK to do?

> Also it seems nv_adma_use_reg_mode() can decide to send other commands
> via the non ADMA interface even for ATA devices. Are we 100% certain it
> never decides to let through a command with DMA via the register
> interface in this case - what do you see if you instrument the function ?

The only cases where that could happen are for polling DMA commands
(which I presume we never do) or where result taskfile is requested. The
latter could be a problem for ATA passthrough commands using DMA, I
suppose.. Question is what we can do about it.. We have to switch out of
ADMA mode to read a result taskfile. I guess that's not really a problem
unless somebody starts issuing NCQ commands via ATA pass-through. Do we
allow that?