From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43619) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YIOFu-0007S4-U6 for qemu-devel@nongnu.org; Mon, 02 Feb 2015 16:10:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YIOFp-0001rA-Oi for qemu-devel@nongnu.org; Mon, 02 Feb 2015 16:10:02 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60472) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YIOFp-0001qG-He for qemu-devel@nongnu.org; Mon, 02 Feb 2015 16:09:57 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t12L9t9O006086 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Mon, 2 Feb 2015 16:09:55 -0500 Message-ID: <54CFE7A2.2090304@redhat.com> Date: Mon, 02 Feb 2015 16:09:54 -0500 From: John Snow MIME-Version: 1.0 References: <1422643333-27926-1-git-send-email-jsnow@redhat.com> <1422643333-27926-14-git-send-email-jsnow@redhat.com> <54CF52EF.7090805@redhat.com> In-Reply-To: <54CF52EF.7090805@redhat.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 13/19] libqos/ahci: add ahci command size setters List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: "pbon >> Paolo Bonzini" 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? > > Paolo > >> + 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.