All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
To: BALATON Zoltan <balaton@eik.bme.hu>
Cc: qemu-ppc@nongnu.org, Alexander Graf <agraf@suse.de>,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [Qemu-ppc] macio ide question/bug report
Date: Fri, 16 May 2014 12:22:26 +0100	[thread overview]
Message-ID: <5375F4F2.9030804@ilande.co.uk> (raw)
In-Reply-To: <alpine.LMD.2.02.1405152227040.991@jedlik.phy.bme.hu>

[-- Attachment #1: Type: text/plain, Size: 1283 bytes --]

On 15/05/14 21:28, BALATON Zoltan wrote:

> On Thu, 15 May 2014, BALATON Zoltan wrote:
>> On Thu, 15 May 2014, BALATON Zoltan wrote:
>>> confusing.) Do you think that replacing io->len in your patch with
>>> s->io_buffer_size would be the correct thing to do?

That looks reasonable, as the MIN() will help prevent excessive memory 
clobber.

>> Probably that's not enough. I've tried it and then it gets to here:
>
> I should've also included these lines too to make it more clear what did
> I change:

Yes, this is definitely helpful. It appears that cmd_read_toc_pma_atip() 
returns 0x20 bytes of data (can you confirm this?), while the DMA engine 
is configured to transfer 0x324 bytes of data - perhaps this is the 
maximum possible size of a TOC?. So the existing code determines there 
are still 0x324 - 0x20 = 0x304 bytes remaining for the DMA request and 
falls into the unaligned code which is definitely not what we want.

Perhaps we need to assume for a non-IO DMA request that the result will 
only be a single ATAPI reply packet? Attached is another version of the 
patch for you to experiment with which makes your s->io_buffer_size 
change but also moves the logic into pmac_ide_transfer() so that we 
don't inadvertently drop into the unaligned code.


ATB,

Mark.


[-- Attachment #2: qemu-macio-atapi-v2.patch --]
[-- Type: text/x-diff, Size: 1115 bytes --]

diff --git a/hw/ide/macio.c b/hw/ide/macio.c
index da94580..0f68124 100644
--- a/hw/ide/macio.c
+++ b/hw/ide/macio.c
@@ -337,6 +337,24 @@ static void pmac_ide_transfer(DBDMA_io *io)
 
     s->io_buffer_size = 0;
     if (s->drive_kind == IDE_CD) {
+        
+        /* Handle non-IO DMA ATAPI transfers */
+        if (s->lba == -1) {
+            s->io_buffer_size = MIN(io->len, s->packet_transfer_size);
+            bdrv_acct_start(s->bs, &s->acct, s->io_buffer_size, BDRV_ACCT_READ);
+            MACIO_DPRINTF("non-IO ATAPI DMA transfer size: %d\n", s->io_buffer_size);
+
+            /* Copy ATAPI buffer directly to RAM and finish */
+            cpu_physical_memory_write(io->addr, s->io_buffer, s->io_buffer_size);
+            ide_atapi_cmd_ok(s);
+            m->dma_active = false;
+            
+            MACIO_DPRINTF("end of non-IO ATAPI DMA transfer\n");
+            bdrv_acct_done(s->bs, &s->acct);
+            io->dma_end(io);
+            return;
+        }
+
         bdrv_acct_start(s->bs, &s->acct, io->len, BDRV_ACCT_READ);
         pmac_ide_atapi_transfer_cb(io, 0);
         return;

  reply	other threads:[~2014-05-16 11:25 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <alpine.LMD.2.02.1405040120250.2612@jedlik.phy.bme.hu>
     [not found] ` <5366CA94.3030803@ilande.co.uk>
     [not found]   ` <alpine.LMD.2.02.1405071132470.25770@jedlik.phy.bme.hu>
     [not found]     ` <536A328F.6070100@ilande.co.uk>
     [not found]       ` <alpine.LMD.2.02.1405071854390.26524@jedlik.phy.bme.hu>
     [not found]         ` <536A6F3C.1030708@ilande.co.uk>
2014-05-10 12:30           ` [Qemu-devel] [Qemu-ppc] macio ide question/bug report BALATON Zoltan
2014-05-12 16:26             ` Mark Cave-Ayland
2014-05-12 19:32               ` BALATON Zoltan
2014-05-12 20:34                 ` Mark Cave-Ayland
2014-05-13 23:02                   ` BALATON Zoltan
2014-05-14  4:55                     ` Mark Cave-Ayland
2014-05-14 11:10                       ` BALATON Zoltan
2014-05-14 20:09                         ` Mark Cave-Ayland
2014-05-14 23:21                           ` BALATON Zoltan
2014-05-15  9:30                             ` Mark Cave-Ayland
2014-05-15 17:28                               ` BALATON Zoltan
2014-05-15 19:22                                 ` Mark Cave-Ayland
2014-05-15 20:14                                   ` BALATON Zoltan
2014-05-15 20:26                                     ` BALATON Zoltan
2014-05-15 20:28                                       ` BALATON Zoltan
2014-05-16 11:22                                         ` Mark Cave-Ayland [this message]
2014-05-16 20:31                                           ` BALATON Zoltan

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=5375F4F2.9030804@ilande.co.uk \
    --to=mark.cave-ayland@ilande.co.uk \
    --cc=agraf@suse.de \
    --cc=balaton@eik.bme.hu \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.