From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52939) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btdXZ-0000KB-HO for qemu-devel@nongnu.org; Mon, 10 Oct 2016 12:35:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1btdXY-0005YN-D7 for qemu-devel@nongnu.org; Mon, 10 Oct 2016 12:35:01 -0400 References: <1476031419-6805-1-git-send-email-mark.cave-ayland@ilande.co.uk> <1476031419-6805-2-git-send-email-mark.cave-ayland@ilande.co.uk> From: Eric Blake Message-ID: <97da94bb-e32c-8d9f-7309-ca4bef4bbe7c@redhat.com> Date: Mon, 10 Oct 2016 11:34:51 -0500 MIME-Version: 1.0 In-Reply-To: <1476031419-6805-2-git-send-email-mark.cave-ayland@ilande.co.uk> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="j9lbT3tTvan2JeQwf3a7qXqD0vQwiPQMQ" Subject: Re: [Qemu-devel] [PATCH 1/2] dma-helpers: explicitly pass alignment into dma-helpers List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Mark Cave-Ayland , keith.busch@intel.com, kwolf@redhat.com, mreitz@redhat.com, jsnow@redhat.com, pbonzini@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --j9lbT3tTvan2JeQwf3a7qXqD0vQwiPQMQ From: Eric Blake To: Mark Cave-Ayland , keith.busch@intel.com, kwolf@redhat.com, mreitz@redhat.com, jsnow@redhat.com, pbonzini@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org Message-ID: <97da94bb-e32c-8d9f-7309-ca4bef4bbe7c@redhat.com> Subject: Re: [Qemu-devel] [PATCH 1/2] dma-helpers: explicitly pass alignment into dma-helpers References: <1476031419-6805-1-git-send-email-mark.cave-ayland@ilande.co.uk> <1476031419-6805-2-git-send-email-mark.cave-ayland@ilande.co.uk> In-Reply-To: <1476031419-6805-2-git-send-email-mark.cave-ayland@ilande.co.uk> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 10/09/2016 11:43 AM, Mark Cave-Ayland wrote: > The hard-coded default alignment is BDRV_SECTOR_SIZE, however this is n= ot > necessarily the case for all platforms. Use this as the default alignme= nt for > all current callers. >=20 > Signed-off-by: Mark Cave-Ayland > --- > @@ -160,8 +161,8 @@ static void dma_blk_cb(void *opaque, int ret) > return; > } > =20 > - if (dbs->iov.size & ~BDRV_SECTOR_MASK) { > - qemu_iovec_discard_back(&dbs->iov, dbs->iov.size & ~BDRV_SECTO= R_MASK); > + if (dbs->iov.size & (dbs->align - 1)) { > + qemu_iovec_discard_back(&dbs->iov, dbs->iov.size & (dbs->align= - 1)); Would it be any smarter to use osdep.h's QEMU_IS_ALIGNED(dbs->iov.size, dbs->align) and QEMU_ALIGN_DOWN(dbs->iov.size, dbs->align)? Semantically it is the same, but the macros make it obvious what the bit-twiddling is doing. Unless you think that needs a tweak, Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --j9lbT3tTvan2JeQwf3a7qXqD0vQwiPQMQ Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJX+8MrAAoJEKeha0olJ0Nq95AIAKrliKqeg+A9kE9E4VVRjVqy Fl/Mm3aLzjfCK610GJV5cm4kFyZuYHAo9pCPjB0+XO83SNFb4nMNBXyFhDX9Zj7P tHViiKvNI9Bj5hfXu9hiRHR7N5iOzLruljnwISRG9lD3Jr0yQLskGq5EOSPDtvKr ijjaq1Rq/eSTLYcatHfX47DdfwouSgXRCKhpJ8T7kmxkqPtgvjBUz2StuuXXsnVv lSuPf4VdarI+HTYIfXtQgjuY02SSACPPzl3LdpDrvVKf/YHibrlaBC5jHPLA01A9 6/Roq3xowTzGJLhb1s23VmHXDPuQhY1dkZm0uajjcsIA5nvL7TT4O87nujQbe44= =AYTx -----END PGP SIGNATURE----- --j9lbT3tTvan2JeQwf3a7qXqD0vQwiPQMQ--