From: Maxim Levitsky <maximlevitsky@gmail.com>
To: linux-kernel <linux-kernel@vger.kernel.org>
Cc: Alex Dubov <oakad@yahoo.com>
Subject: [QUESTION] Need some explanations in regard to memory alignment of requests that a block device receives
Date: Fri, 13 Aug 2010 16:27:51 +0300 [thread overview]
Message-ID: <1281706071.4160.18.camel@maxim-laptop> (raw)
Hi,
I currently am writing a block driver for Legacy Memory sticks.
I have few questions about that type of data my ->request will receive
from kernel.
First of all I think that by default, driver receives requests that
contains just one sector and it isn't in high memory.
However I am opting in to allow to receive requests that have many
sectors span several memory regions, and be in highmem).
The request is converted to scatterlist upon which I operate.
(Untill this point I did the same think Alex does in mspro_blk.c)
For simplicity lets assume 512 byte hardware sector size.
However is there a guarantee that incoming memory segments will be
aligned on 512 byte boundary?
If this isn't true I run into 2 problems:
1. Sector can span 2 pages. Therefore if I decide to do pio, and I use
kmap_atomic (because of highmem), I need first map 1st page, read/write
it, unmap it, and then then do the same with 2nd page.
2. Sectors can span 2 memory regions.
This is even worse. For DMA I would need to bounce the sector.
Also it becames very difficult to handle input on sector by sector basis
(short of bouncing everything...)
If the above is true (I hope), then I have different problem.
The problem is that I will have small buffer that will contain few
hardware sectors.
I currently allocate it using kmalloc.
However I want to send that buffer to same functions that deal with IO,
therefore I need it to be aligned on 512 byte boundary.
Is there a way to allocate aligned memory (short of allocating more and
aligning pointer manually which I hate to do)
Maybe I should just use __get_free_pages?
(I will need a buffer of page or two (once per driver load) I think).
Best regards,
Maxim Levitsky
next reply other threads:[~2010-08-13 13:28 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-13 13:27 Maxim Levitsky [this message]
2010-08-14 7:08 ` Alex Dubov
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=1281706071.4160.18.camel@maxim-laptop \
--to=maximlevitsky@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=oakad@yahoo.com \
/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
Powered by JetHome