mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: 殺人熊 <killman.bear@msa.hinet.net>
To: linux-kernel@vger.kernel.org
Subject: IDE DMA sglist handle probelem
Date: Tue, 23 Sep 2008 17:53:06 +0800	[thread overview]
Message-ID: <e5931ce10809230253m7d821c3ev48676884bb382eaf@mail.gmail.com> (raw)

Hi,

I want to test a private cache for IDE R/W in 2.6.26.
Before develop the private cache, I need to do something with the IDE
read/write buffer.
If service a read command, I replace the DMA buffer address of sglist
by my buffer before transfer, and memcpy the received data(in my
buffer) to original DMA buffer of sglist.
If service a write command, I replace the DMA buffer address by my
buffer, and memcpy the write data from sglist to my buffer, then
transfer it.
I implement it on  linux-2.6.26/drivers/ata/libata-core.c.

I replace each DMA address of sglist as follow:
-----------------------------------------------------------------------------
       for_each_sg(qc->sg, sg, qc->n_elem, si) {
       u32 addr, len;
               addr = sg_dma_address(sg);
               len = sg_dma_len(sg);

               //if write command, copy data from DMA address to my buf
               if (qc->tf.command == ATA_CMD_WRITE || qc->tf.command ==
ATA_CMD_WRITE_EXT) {
                       memcpy(myBuf[si], bus_to_virt(addr), len);
               }

               //save orignal DAM address
               savedAddr[si] = (unsigned char *)addr;

               //replace DMA address by my buf
               sg_dma_address(sg) = myBuf[si];
       }
-----------------------------------------------------------------------------
The book Linux Device Driver say that driver can not access DMA sg
between dma_map_sg and dma_unmap_sg, so I implement them before
dma_map_sg and after dma_unmap_sg.
I use a burn-in tool to test the fixed functions, and found the data
verify success for 80 hours, buf if I try to extract three big
packages in the disk at the same time, the kernel panic:

BUG: unable to handle kernel paging request a ff450fd7
IP:[<c05f5ba4>] iret_exc+0x68c/0x8d2
*pde = 00008067 *pte = 00000000
Oop : 0002 [#1] SMP

I do not know what is wrong.
How to access the sglist DMA buffer correctly?

                 reply	other threads:[~2008-09-23  9:53 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=e5931ce10809230253m7d821c3ev48676884bb382eaf@mail.gmail.com \
    --to=killman.bear@msa.hinet.net \
    --cc=linux-kernel@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

all inboxes | Powered by JetHome®