From patchwork Sun Sep 12 21:44:00 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 64566 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id D508AB70A3 for ; Mon, 13 Sep 2010 07:48:23 +1000 (EST) Received: from localhost ([127.0.0.1]:49087 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OuuPF-0000It-Uo for incoming@patchwork.ozlabs.org; Sun, 12 Sep 2010 17:48:13 -0400 Received: from [140.186.70.92] (port=48601 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OuuLD-0006NN-9i for qemu-devel@nongnu.org; Sun, 12 Sep 2010 17:44:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OuuLB-0003UR-UT for qemu-devel@nongnu.org; Sun, 12 Sep 2010 17:44:03 -0400 Received: from verein.lst.de ([213.95.11.210]:33471) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OuuLB-0003UI-Je for qemu-devel@nongnu.org; Sun, 12 Sep 2010 17:44:01 -0400 Received: from verein.lst.de (localhost [127.0.0.1]) by verein.lst.de (8.12.3/8.12.3/Debian-7.1) with ESMTP id o8CLi0WY004942 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Sun, 12 Sep 2010 23:44:00 +0200 Received: (from hch@localhost) by verein.lst.de (8.12.3/8.12.3/Debian-7.2) id o8CLi0Jg004941 for qemu-devel@nongnu.org; Sun, 12 Sep 2010 23:44:00 +0200 Date: Sun, 12 Sep 2010 23:44:00 +0200 From: Christoph Hellwig To: qemu-devel@nongnu.org Message-ID: <20100912214400.GD4893@lst.de> References: <20100912214256.GA4854@lst.de> Mime-Version: 1.0 Content-Disposition: inline In-Reply-To: <20100912214256.GA4854@lst.de> User-Agent: Mutt/1.3.28i X-Scanned-By: MIMEDefang 2.39 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [Qemu-devel] [PATCH 5/5] ide: propagate the required alignment X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org IDE is a bit ugly in this respect. For one it doesn't really keep track of a sector size - most of the protocol is in units of 512 bytes, and we assume 2048 bytes for CDROMs which is correct most of the time. Second IDE allocates an I/O buffer long before we know if we're dealing with a CDROM or not, so increase the alignment for the io_buffer unconditionally. Signed-off-by: Christoph Hellwig Index: qemu/hw/ide/core.c =================================================================== --- qemu.orig/hw/ide/core.c 2010-09-12 18:30:06.000000000 -0300 +++ qemu/hw/ide/core.c 2010-09-12 18:32:29.133759395 -0300 @@ -2645,6 +2645,7 @@ int ide_init_drive(IDEState *s, BlockDri if (bdrv_get_type_hint(bs) == BDRV_TYPE_CDROM) { s->drive_kind = IDE_CD; bdrv_set_change_cb(bs, cdrom_change_cb, s); + bs->buffer_alignment = 2048; } else { if (!bdrv_is_inserted(s->bs)) { error_report("Device needs media, but drive is empty"); @@ -2679,7 +2680,8 @@ static void ide_init1(IDEBus *bus, int u s->bus = bus; s->unit = unit; s->drive_serial = drive_serial++; - s->io_buffer = qemu_blockalign(s->bs, IDE_DMA_BUF_SECTORS*512 + 4); + /* we need at least 2k alignment for accessing CDROMs using O_DIRECT */ + s->io_buffer = qemu_memalign(2048, IDE_DMA_BUF_SECTORS*512 + 4); s->io_buffer_total_len = IDE_DMA_BUF_SECTORS*512 + 4; s->smart_selftest_data = qemu_blockalign(s->bs, 512); s->sector_write_timer = qemu_new_timer(vm_clock,