From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53532) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axFwU-0002ZD-QD for qemu-devel@nongnu.org; Mon, 02 May 2016 11:39:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1axFw7-00027E-1N for qemu-devel@nongnu.org; Mon, 02 May 2016 11:39:21 -0400 Date: Mon, 2 May 2016 17:35:11 +0200 From: Kevin Wolf Message-ID: <20160502153511.GC4882@noname.redhat.com> References: <1461960516-4717-1-git-send-email-eblake@redhat.com> <1461960516-4717-4-git-send-email-eblake@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1461960516-4717-4-git-send-email-eblake@redhat.com> Subject: Re: [Qemu-devel] [PATCH v4 03/14] nand: Switch to byte-based block access List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: qemu-devel@nongnu.org, "open list:Block layer core" , Max Reitz Am 29.04.2016 um 22:08 hat Eric Blake geschrieben: > Sector-based blk_write() should die; switch to byte-based > blk_pwrite() instead. Likewise for blk_read(). > > This file is doing some complex computations to map various > flash page sizes (256, 512, and 2048) atop generic uses of > 512-byte sector operations. Perhaps someone will want to tidy > up the file for fewer gymnastics in managing addresses and > offsets, and less wasteful visits of 256-byte pages, but it > was out of scope for this series, where I just went with the > mechanical conversion. > > Signed-off-by: Eric Blake > --- > hw/block/nand.c | 36 +++++++++++++++++++++++------------- > 1 file changed, 23 insertions(+), 13 deletions(-) > > diff --git a/hw/block/nand.c b/hw/block/nand.c > index 29c6596..2703ff4 100644 > --- a/hw/block/nand.c > +++ b/hw/block/nand.c > @@ -663,7 +663,8 @@ static void glue(nand_blk_write_, PAGE_SIZE)(NANDFlashState *s) > sector = SECTOR(s->addr); > off = (s->addr & PAGE_MASK) + s->offset; > soff = SECTOR_OFFSET(s->addr); > - if (blk_read(s->blk, sector, iobuf, PAGE_SECTORS) < 0) { > + if (blk_pread(s->blk, sector << BDRV_SECTOR_BITS, iobuf, > + PAGE_SECTORS << BDRV_SECTOR_BITS) < 0) { > printf("%s: read error in sector %" PRIu64 "\n", __func__, sector); > return; > } > @@ -675,21 +676,24 @@ static void glue(nand_blk_write_, PAGE_SIZE)(NANDFlashState *s) > MIN(OOB_SIZE, off + s->iolen - PAGE_SIZE)); > } > > - if (blk_write(s->blk, sector, iobuf, PAGE_SECTORS) < 0) { > + if (blk_pwrite(s->blk, sector << BDRV_SECTOR_BITS, iobuf, > + PAGE_SECTORS << BDRV_SECTOR_BITS, 0) < 0) { > printf("%s: write error in sector %" PRIu64 "\n", __func__, sector); > } > } else { > off = PAGE_START(s->addr) + (s->addr & PAGE_MASK) + s->offset; > sector = off >> 9; > soff = off & 0x1ff; > - if (blk_read(s->blk, sector, iobuf, PAGE_SECTORS + 2) < 0) { > + if (blk_pread(s->blk, sector << BDRV_SECTOR_BITS, iobuf, > + (PAGE_SECTORS + 2) << BDRV_SECTOR_BITS) < 0) { > printf("%s: read error in sector %" PRIu64 "\n", __func__, sector); > return; > } > > mem_and(iobuf + soff, s->io, s->iolen); > > - if (blk_write(s->blk, sector, iobuf, PAGE_SECTORS + 2) < 0) { > + if (blk_write(s->blk, sector << BDRV_SECTOR_BITS, iobuf, > + (PAGE_SECTORS + 2) << BDRV_SECTOR_BITS, 0) < 0) { You forgot to actually change which function is called here. Kevin