From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50583) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZLH3V-0005W6-AP for qemu-devel@nongnu.org; Fri, 31 Jul 2015 16:37:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZLH3R-00019j-5B for qemu-devel@nongnu.org; Fri, 31 Jul 2015 16:37:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47413) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZLH3R-00019J-07 for qemu-devel@nongnu.org; Fri, 31 Jul 2015 16:37:21 -0400 Message-ID: <55BBDC7D.9050100@redhat.com> Date: Fri, 31 Jul 2015 16:37:17 -0400 From: John Snow MIME-Version: 1.0 References: <1438198068-32428-1-git-send-email-aurelien@aurel32.net> In-Reply-To: <1438198068-32428-1-git-send-email-aurelien@aurel32.net> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH for-2.4] macio: re-add TRIM support List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Aurelien Jarno , qemu-devel@nongnu.org Cc: Mark Cave-Ayland On 07/29/2015 03:27 PM, Aurelien Jarno wrote: > Commit bd4214fc dropped TRIM support by mistake. Given it is still > advertised to the host when using a drive with discard=3Don, this cause > the IDE bus to hang when the host issues a TRIM command. >=20 > This patch fixes that by re-adding the TRIM code, ported to the new > new DMA implementation. >=20 > Cc: Mark Cave-Ayland > Cc: John Snow > Signed-off-by: Aurelien Jarno > --- > hw/ide/macio.c | 28 ++++++++++++++++++++++++++++ > 1 file changed, 28 insertions(+) >=20 > diff --git a/hw/ide/macio.c b/hw/ide/macio.c > index a55a479..66ac2ba 100644 > --- a/hw/ide/macio.c > +++ b/hw/ide/macio.c > @@ -208,6 +208,33 @@ static void pmac_dma_write(BlockBackend *blk, > cb, io); > } > =20 > +static void pmac_dma_trim(BlockBackend *blk, > + int64_t offset, int bytes, > + void (*cb)(void *opaque, int ret), void *opaqu= e) > +{ > + DBDMA_io *io =3D opaque; > + MACIOIDEState *m =3D io->opaque; > + IDEState *s =3D idebus_active_if(&m->bus); > + dma_addr_t dma_addr, dma_len; > + void *mem; > + > + qemu_iovec_destroy(&io->iov); > + qemu_iovec_init(&io->iov, io->len / MACIO_PAGE_SIZE + 1); > + > + dma_addr =3D io->addr; > + dma_len =3D io->len; > + mem =3D dma_memory_map(&address_space_memory, dma_addr, &dma_len, > + DMA_DIRECTION_TO_DEVICE); > + > + qemu_iovec_add(&io->iov, mem, io->len); > + s->io_buffer_size -=3D io->len; > + s->io_buffer_index +=3D io->len; > + io->len =3D 0; > + > + m->aiocb =3D ide_issue_trim(blk, (offset >> 9), &io->iov, (bytes >= > 9), > + cb, io); > +} > + > static void pmac_ide_atapi_transfer_cb(void *opaque, int ret) > { > DBDMA_io *io =3D opaque; > @@ -313,6 +340,7 @@ static void pmac_ide_transfer_cb(void *opaque, int = ret) > pmac_dma_write(s->blk, offset, io->len, pmac_ide_transfer_cb, = io); > break; > case IDE_DMA_TRIM: > + pmac_dma_trim(s->blk, offset, io->len, pmac_ide_transfer_cb, i= o); > break; > } > =20 >=20 Looks sane, and tested myself. Not that this is a problem you introduced, but we don't *unmap* this memory anywhere, something else I overlooked for the initial patch. Reviewed-by: John Snow