From patchwork Wed Nov 20 09:55:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 292717 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 54E022C00C1 for ; Wed, 20 Nov 2013 21:00:26 +1100 (EST) Received: from localhost ([::1]:53734 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vj4a0-0007tj-Mt for incoming@patchwork.ozlabs.org; Wed, 20 Nov 2013 05:00:16 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34530) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vj4VT-0000n5-DH for qemu-devel@nongnu.org; Wed, 20 Nov 2013 04:55:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vj4VK-0002A0-VI for qemu-devel@nongnu.org; Wed, 20 Nov 2013 04:55:35 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37343) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vj4VK-00029b-My for qemu-devel@nongnu.org; Wed, 20 Nov 2013 04:55:26 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rAK9tQI1018089 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 20 Nov 2013 04:55:26 -0500 Received: from blackfin.pond.sub.org (ovpn-116-62.ams2.redhat.com [10.36.116.62]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id rAK9tN7M000887 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 20 Nov 2013 04:55:25 -0500 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 561D8200CE; Wed, 20 Nov 2013 10:55:21 +0100 (CET) From: armbru@redhat.com To: qemu-devel@nongnu.org Date: Wed, 20 Nov 2013 10:55:20 +0100 Message-Id: <1384941320-30987-10-git-send-email-armbru@redhat.com> In-Reply-To: <1384941320-30987-1-git-send-email-armbru@redhat.com> References: <1384941320-30987-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, afaerber@suse.de Subject: [Qemu-devel] [PATCH v2 9/9] ide: Drop redundant IDEState member wwn X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Markus Armbruster It's a copy of dev->wwn. The copy was needed for non-qdevified controllers, which lacked dev. Note that pci_piix3_xen_ide_unplug() did not clear the copy (it only cleared the copy of bs). Begs the question whether stale data could have been used after unplug. As far as I can tell, the copy was used only when the copy of bs was non-null, thus no bug there. Signed-off-by: Markus Armbruster --- hw/ide/core.c | 18 ++++++++---------- hw/ide/internal.h | 4 +--- hw/ide/qdev.c | 3 +-- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/hw/ide/core.c b/hw/ide/core.c index be5be61..008d9bc 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -142,7 +142,7 @@ static void ide_identify(IDEState *s) /* 13=flush_cache_ext,12=flush_cache,10=lba48 */ put_le16(p + 83, (1 << 14) | (1 << 13) | (1 <<12) | (1 << 10)); /* 14=set to 1, 8=has WWN, 1=SMART self test, 0=SMART error logging */ - if (s->wwn) { + if (s->dev->wwn) { put_le16(p + 84, (1 << 14) | (1 << 8) | 0); } else { put_le16(p + 84, (1 << 14) | 0); @@ -156,7 +156,7 @@ static void ide_identify(IDEState *s) /* 13=flush_cache_ext,12=flush_cache,10=lba48 */ put_le16(p + 86, (1 << 13) | (1 <<12) | (1 << 10)); /* 14=set to 1, 8=has WWN, 1=SMART self test, 0=SMART error logging */ - if (s->wwn) { + if (s->dev->wwn) { put_le16(p + 87, (1 << 14) | (1 << 8) | 0); } else { put_le16(p + 87, (1 << 14) | 0); @@ -170,12 +170,12 @@ static void ide_identify(IDEState *s) if (dev && dev->conf.physical_block_size) put_le16(p + 106, 0x6000 | get_physical_block_exp(&dev->conf)); - if (s->wwn) { + if (s->dev->wwn) { /* LE 16-bit words 111-108 contain 64-bit World Wide Name */ - put_le16(p + 108, s->wwn >> 48); - put_le16(p + 109, s->wwn >> 32); - put_le16(p + 110, s->wwn >> 16); - put_le16(p + 111, s->wwn); + put_le16(p + 108, s->dev->wwn >> 48); + put_le16(p + 109, s->dev->wwn >> 32); + put_le16(p + 110, s->dev->wwn >> 16); + put_le16(p + 111, s->dev->wwn); } if (dev && dev->conf.discard_granularity) { put_le16(p + 169, 1); /* TRIM support */ @@ -2088,8 +2088,7 @@ static const BlockDevOps ide_cd_block_ops = { .is_medium_locked = ide_cd_is_medium_locked, }; -int ide_init_drive(IDEState *s, IDEDriveKind kind, - uint64_t wwn) +int ide_init_drive(IDEState *s, IDEDriveKind kind) { BlockDriverState *bs = s->dev->conf.bs; uint64_t nb_sectors; @@ -2098,7 +2097,6 @@ int ide_init_drive(IDEState *s, IDEDriveKind kind, bdrv_get_geometry(bs, &nb_sectors); s->nb_sectors = nb_sectors; - s->wwn = wwn; /* The SMART values should be preserved across power cycles but they aren't. */ s->smart_enabled = 1; diff --git a/hw/ide/internal.h b/hw/ide/internal.h index c4a5773..95ea75c 100644 --- a/hw/ide/internal.h +++ b/hw/ide/internal.h @@ -350,7 +350,6 @@ struct IDEState { int identify_set; uint8_t identify_data[512]; int drive_serial; - uint64_t wwn; /* ide regs */ uint8_t feature; uint8_t error; @@ -541,8 +540,7 @@ uint32_t ide_data_readw(void *opaque, uint32_t addr); void ide_data_writel(void *opaque, uint32_t addr, uint32_t val); uint32_t ide_data_readl(void *opaque, uint32_t addr); -int ide_init_drive(IDEState *s, IDEDriveKind kind, - uint64_t wwn); +int ide_init_drive(IDEState *s, IDEDriveKind kind); void ide_init2(IDEBus *bus, qemu_irq irq); void ide_init_ioport(IDEBus *bus, ISADevice *isa, int iobase, int iobase2); diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c index 915bc27..17404b8 100644 --- a/hw/ide/qdev.c +++ b/hw/ide/qdev.c @@ -182,8 +182,7 @@ static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind) } } - if (ide_init_drive(s, kind, - dev->wwn) < 0) { + if (ide_init_drive(s, kind) < 0) { return -1; }