From: Krzysztof Halasa <khc@pm.waw.pl>
To: James Bottomley <James.Bottomley@steeleye.com>
Cc: Linux Kernel <linux-kernel@vger.kernel.org>,
SCSI Mailing List <linux-scsi@vger.kernel.org>
Subject: Re: Proposal for new generic device API: dma_get_required_mask()
Date: Fri, 18 Jun 2004 02:46:46 +0200 [thread overview]
Message-ID: <m33c4tsnex.fsf@defiant.pm.waw.pl> (raw)
In-Reply-To: <1087481331.2210.27.camel@mulgrave> (James Bottomley's message of "17 Jun 2004 09:08:51 -0500")
James Bottomley <James.Bottomley@steeleye.com> writes:
> If the driver decides to use the mask, it would do another
> dma_set_mask() to confirm it (this gives the platform the opportunity if
> it so chooses to return a mask that doesn't quite cover memory, but
> would be more optimal...say for platforms that have all memory under 4GB
> bar one small chunk at 64GB or something).
What I think drivers such as AIC7xxx should do is:
#define OUR_COST_32 = 4
#define OUR_COST_39 = 8
#define OUR_COST_64 = 10
int cost32 = check_dma_mask(32 bits);
int cost39 = check_dma_mask(39 bits);
int cost64 = check_dma_mask(64 bits);
if (!cost32 && !cost39 && !cost64)
printk(KERN_ERR "64 bits aren't enough for RAM addressing?\n")
else
use_mode_with_minimal_cost(cost32 * OUR_COST_32,
cost39 * OUR_COST_39,
cost64 * OUR_COST_64);
This check_dma_mask() should be renamed + extended to cover different
RAM access types:
- coherent vs non-coherent memory
- preallocated/initialized memory (such as skb->data passed to
hard_start_xmit()) vs uninitialized memory (such as returned by
kmalloc()).
The "cost" is needed for cases where both the host and the device can
support many addressing modes, such as with AIC7xxx, > 4GB of RAM
and (costly) IO MMU or bounce buffers.
Currently, set_dma_mask(less than 32 bits) can return success but then
the mapping functions can return addresses which don't fit in the
requested number of bits. In fact set_dma_mask() has any meaning
only to *alloc functions. The statement "pci_set_consistent_dma_mask()
will always be able to set the same or a smaller mask as
pci_set_dma_mask()" doesn't make IMHO sense.
If we fix the API we should IMHO also remove set_dma_mask() and add
the number of address bits to the arguments of actual mapping
functions. It would make it possible to use different masks for
different tasks, I'm told there is hardware which can benefit from it.
Done correctly it wouldn't have any runtime overhead.
I would also change the "u64 mask" into plain number of bits.
It would be easier for people, cpp, gcc and CPU.
--
Krzysztof Halasa, B*FH
next prev parent reply other threads:[~2004-06-18 1:00 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-06-17 14:08 Proposal for new generic device API: dma_get_required_mask() James Bottomley
2004-06-17 14:51 ` Meelis Roos
2004-06-17 15:28 ` Matthew Wilcox
2004-06-17 20:12 ` James Bottomley
2004-06-18 0:46 ` Krzysztof Halasa [this message]
2004-06-18 1:45 ` James Bottomley
2004-06-18 23:07 ` Krzysztof Halasa
2004-06-19 15:00 ` James Bottomley
2004-06-19 23:39 ` Krzysztof Halasa
2004-06-20 16:56 ` James Bottomley
2004-06-18 9:21 ` Russell King
2004-06-18 23:10 ` Krzysztof Halasa
2004-06-19 20:22 ` Russell King
2004-06-20 0:00 ` Krzysztof Halasa
2004-06-20 19:47 ` Russell King
2004-06-23 19:32 ` Krzysztof Halasa
2004-06-18 5:59 ` Jeremy Higdon
2004-06-18 14:19 ` James Bottomley
-- strict thread matches above, loose matches on Subject: below --
2004-06-17 14:52 Salyzyn, Mark
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m33c4tsnex.fsf@defiant.pm.waw.pl \
--to=khc@pm.waw.pl \
--cc=James.Bottomley@steeleye.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox