[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 13/19] libqos/ahci: add ahci command size setter
Re: [Qemu-devel] [PATCH 13/19] libqos/ahci: add ahci command size setters
Mon, 02 Feb 2015 16:09:54 -0500
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0
On 02/02/2015 05:35 AM, Paolo Bonzini wrote:
On 30/01/2015 19:42, John Snow wrote:
+void ahci_command_set_sizes(AHCICommand *cmd, uint64_t xbytes,
+ unsigned prd_size)
+ /* Each PRD can describe up to 4MiB, and must not be odd. */
+ g_assert_cmphex(prd_size, <=, 4096 * 1024);
+ g_assert_cmphex(prd_size & 0x01, ==, 0x00);
+ cmd->prd_size = prd_size;
+ cmd->xbytes = xbytes;
+ cmd->fis.count = cpu_to_le16(cmd->xbytes / AHCI_SECTOR_SIZE);
Why do you need cpu_to_le16 here, instead of having it in the function
that writes the command to guest memory?
+ cmd->header.prdtl = size_to_prdtl(cmd->xbytes, cmd->prd_size);
In this case, only the command header had a utility written for it to
flip the bits for me. This is part of the FIS, instead, which has no
explicit flip-on-write mechanism inside of commit.
So, it's correct, but not terribly consistent.
I can write a fis write helper to make this more internally consistent
about when we handle it for the user and when we don't.