From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33143) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZAf6x-0002ry-3G for qemu-devel@nongnu.org; Thu, 02 Jul 2015 10:05:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZAf6v-0007Ue-Uj for qemu-devel@nongnu.org; Thu, 02 Jul 2015 10:05:07 -0400 Date: Thu, 2 Jul 2015 15:04:55 +0100 From: Stefan Hajnoczi Message-ID: <20150702140455.GL21214@stefanha-thinkpad.home> References: <1435767578-32743-1-git-send-email-jsnow@redhat.com> <1435767578-32743-2-git-send-email-jsnow@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="AGBBLMjITsWHeOTZ" Content-Disposition: inline In-Reply-To: <1435767578-32743-2-git-send-email-jsnow@redhat.com> Subject: Re: [Qemu-devel] [PATCH v2 01/15] ide: add limit to .prepare_buf() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: John Snow Cc: kwolf@redhat.com, pbonzini@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org --AGBBLMjITsWHeOTZ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jul 01, 2015 at 12:19:24PM -0400, John Snow wrote: > prepare_buf should not always grab as many descriptors > as it can, sometimes it should self-limit. >=20 > For example, an NCQ transfer of 1 sector with a PRDT that > describes 4GiB of data should not copy 4GiB of data, it > should just transfer that first 512 bytes. >=20 > PIO is not affected, because the dma_buf_rw dma helpers > already have a byte limit built-in to them, but DMA/NCQ > will exhaust the entire list regardless of requested size. >=20 > AHCI 1.3 specifies in section 6.1.6 Command List Underflow that > NCQ is not required to detect underflow conditions. Non-NCQ > pathways signal underflow by writing to the PRDBC field, which > will already occur by writing the actual transferred byte count > to the PRDBC, signaling the underflow. >=20 > Our NCQ pathways aren't required to detect underflow, but since our DMA > backend uses the size of the PRDT to determine the size of the transer, > if our PRDT is bigger than the transaction (the underflow condition) it > doesn't cost us anything to detect it and truncate the PRDT. >=20 > This is a recoverable error and is not signaled to the guest, in either > NCQ or normal DMA cases. >=20 > For BMDMA, the existing pathways should see no guest-visible difference, > but any bytes described in the overage will no longer be transferred > before indicating to the guest that there was an underflow. >=20 > Signed-off-by: John Snow > --- > hw/ide/ahci.c | 27 ++++++++++++++------------- > hw/ide/core.c | 8 ++++---- > hw/ide/internal.h | 2 +- > hw/ide/macio.c | 2 +- > hw/ide/pci.c | 21 ++++++++++++++++----- > 5 files changed, 36 insertions(+), 24 deletions(-) Reviewed-by: Stefan Hajnoczi --AGBBLMjITsWHeOTZ Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJVlUUHAAoJEJykq7OBq3PI+p4H/iXKab48BxDVlak4OWfgf1pW 9yxjUyUPasETjIFGlUz24Mvev3T6KDCoRZn3knPcc0JGyg5GUNT3LswVrztHpMRm a6w0WcpvOOXXOE+JOavdS4bPBgUTH21GHBwcDFoGIgt4KzM6XoZiPvLEQHQ3qzSe ilPZQDlS7rr+OFC5I0v0/2+NtAESQYvRgqQJ6mRjmosW44DFGpa+i6pxp4E8w6o2 /Ee1OhKe07i/1uog7q+8f93JoxOVZZCooAuTwJPtoEWHxs452ApHHYBE2MiCobR9 JD0ZQWO03R58b46Z971fm97E+0PeIICAa4cXto6paG2aC3Nm4bA8Keh5NFNnRMs= =N7jP -----END PGP SIGNATURE----- --AGBBLMjITsWHeOTZ--