From patchwork Wed Jul 11 10:32:01 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasilis Liaskovitis X-Patchwork-Id: 170455 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 5A6592C0088 for ; Wed, 11 Jul 2012 22:15:39 +1000 (EST) Received: from localhost ([::1]:42087 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SouEw-0005Le-Gk for incoming@patchwork.ozlabs.org; Wed, 11 Jul 2012 06:33:50 -0400 Received: from eggs.gnu.org ([208.118.235.92]:44339) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SouDc-0003Yo-Lx for qemu-devel@nongnu.org; Wed, 11 Jul 2012 06:32:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SouDX-0005su-FH for qemu-devel@nongnu.org; Wed, 11 Jul 2012 06:32:28 -0400 Received: from mail-bk0-f45.google.com ([209.85.214.45]:52569) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SouDX-0005nz-9a for qemu-devel@nongnu.org; Wed, 11 Jul 2012 06:32:23 -0400 Received: by mail-bk0-f45.google.com with SMTP id ji1so712845bkc.4 for ; Wed, 11 Jul 2012 03:32:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=QCX9YiBA064Np9cdWR/lsuYnSZzU5jcICa84PbAKA3c=; b=H6EZZ2rBhFxG+pKZABSSzKqfmd7DVdYbqctW07FvBpzE4eNJmCRe0fxOZqPnGf6kkS YEgn4Vhh2Y668YaMrJFqocfJKC9wMXzETeBPQmHx/CVU6U2sJGNzLqU1DORGcyjPZoNm XFcIfnFWnu8LHPA+pDaZjdqFIj4g83nWZbySkCVNml/0NQ4yQCIhKyf0dOSH629nZJQS DmtZ2YwcjgphsiRQ1zo2Y60cOMtPUTJcV0NGuDuwK2BEUy9VxjAX86m461WxqYrGpNrU eYCn18Av0pSHaBPYkYv55Bm2YbzVC+lJApSsm89a5e9UPN7oA9/n2J03YxL3k7f8axXC M4dw== Received: by 10.204.157.7 with SMTP id z7mr16814918bkw.14.1342002742205; Wed, 11 Jul 2012 03:32:22 -0700 (PDT) Received: from dhcp-192-168-178-175.ri.profitbricks.localdomain ([62.217.45.26]) by mx.google.com with ESMTPS id e20sm794740bkv.10.2012.07.11.03.32.21 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 11 Jul 2012 03:32:22 -0700 (PDT) From: Vasilis Liaskovitis To: qemu-devel@nongnu.org, kvm@vger.kernel.org, seabios@seabios.org Date: Wed, 11 Jul 2012 12:32:01 +0200 Message-Id: <1342002726-18258-17-git-send-email-vasilis.liaskovitis@profitbricks.com> X-Mailer: git-send-email 1.7.9 In-Reply-To: <1342002726-18258-1-git-send-email-vasilis.liaskovitis@profitbricks.com> References: <1342002726-18258-1-git-send-email-vasilis.liaskovitis@profitbricks.com> X-Gm-Message-State: ALoCoQkm9c6BtPxZjqARd08L6c9zX2cuvnmUigLRpzeIzXir7QiZgb4R/ENR1y/ycBrKqCvfwIya X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.214.45 Cc: gleb@redhat.com, Vasilis Liaskovitis , kevin@koconnor.net, avi@redhat.com, anthony@codemonkey.ws, imammedo@redhat.com Subject: [Qemu-devel] [RFC PATCH v2 16/21] acpi_piix4: Update dimm state on VM reboot 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 in case of hot-remove or hot-add failure, the dimm bitmaps in qemu and Seabios are inconsistent with the true state of the DIMM devices. The "populated" field of the DimmState reflects the true state of the device. This inconsistency means that a failed operation cannot be retried. Ths patch updates the bit array to the true state of the dimms on VM reboot. This allows retry of failed hot-add or hot-remove operations after a reboot. Retrying a failed hot operation is not yet possible before reboot (the following patch removes this limitation for guests with _OST acpi support) Signed-off-by: Vasilis Liaskovitis --- hw/acpi_piix4.c | 25 +++++++++++++++++++++++++ 1 files changed, 25 insertions(+), 0 deletions(-) diff --git a/hw/acpi_piix4.c b/hw/acpi_piix4.c index d8e2c22..ebc5de7 100644 --- a/hw/acpi_piix4.c +++ b/hw/acpi_piix4.c @@ -91,6 +91,7 @@ typedef struct PIIX4PMState { } PIIX4PMState; static void piix4_acpi_system_hot_add_init(PCIBus *bus, PIIX4PMState *s); +static void piix4_dimm_state_sync(PIIX4PMState *s); #define ACPI_ENABLE 0xf1 #define ACPI_DISABLE 0xf0 @@ -369,6 +370,7 @@ static void piix4_reset(void *opaque) /* Mark SMM as already inited (until KVM supports SMM). */ pci_conf[0x5B] = 0x02; } + piix4_dimm_state_sync(s); piix4_update_hotplug(s); } @@ -671,6 +673,29 @@ static int piix4_dimm_hotplug(DeviceState *qdev, SysBusDevice *dev, int return 0; } +void piix4_dimm_state_sync(PIIX4PMState *s) +{ + struct gpe_regs *g = &s->gperegs; + DimmState *slot = NULL; + uint32_t i, temp = 1; + + for(i = 0; i < MAX_DIMMS; i++) { + slot = dimm_find_from_idx(i); + if (!slot) + break; + if (i % 8 == 0) { + temp = 1; + g->mems_sts[i / 8] = 0; + } + else + temp = temp << 1; + if (slot->populated) { + g->mems_sts[i / 8] |= temp; + } + slot->pending = false; + } +} + static int piix4_device_hotplug(DeviceState *qdev, PCIDevice *dev, PCIHotplugState state) {