From patchwork Sun Apr 15 18:39:02 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 152695 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 E3664B6FEA for ; Mon, 16 Apr 2012 05:29:08 +1000 (EST) Received: from localhost ([::1]:46525 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SJUNI-0002Rk-BE for incoming@patchwork.ozlabs.org; Sun, 15 Apr 2012 14:40:36 -0400 Received: from eggs.gnu.org ([208.118.235.92]:37771) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SJUMT-0000eA-PN for qemu-devel@nongnu.org; Sun, 15 Apr 2012 14:39:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SJUMO-00030n-VF for qemu-devel@nongnu.org; Sun, 15 Apr 2012 14:39:45 -0400 Received: from cantor2.suse.de ([195.135.220.15]:35671 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SJUMO-0002zS-MN; Sun, 15 Apr 2012 14:39:40 -0400 Received: from relay2.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id 4F1318FD0F; Sun, 15 Apr 2012 20:39:39 +0200 (CEST) From: =?UTF-8?q?Andreas=20F=C3=A4rber?= To: qemu-devel@nongnu.org Date: Sun, 15 Apr 2012 20:39:02 +0200 Message-Id: <1334515144-26485-19-git-send-email-afaerber@suse.de> X-Mailer: git-send-email 1.7.7 In-Reply-To: <1334515144-26485-1-git-send-email-afaerber@suse.de> References: <1334515144-26485-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-Received-From: 195.135.220.15 Cc: Michael Ellerman , Anthony Liguori , agraf@suse.de, blauwirbel@gmail.com, qemu-ppc@nongnu.org, Paolo Bonzini , =?UTF-8?q?Andreas=20F=C3=A4rber?= , David Gibson Subject: [Qemu-devel] [PATCH 18/20] pseries: Correctly use the device model reset hooks 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: David Gibson Recently we added code to properly clean away VIO CRQs on reset However, this directly uses qemu_register, rather than the existing device model reset callbacks. This patch cleans this up by adding proper use of the reset hook to the VIO bus model. The existing CRQ reset code is converted to the new method. Signed-off-by: David Gibson Signed-off-by: Andreas Färber --- hw/spapr_vio.c | 12 ++++++++---- hw/spapr_vio.h | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/hw/spapr_vio.c b/hw/spapr_vio.c index 0bf2c31..fccf48b 100644 --- a/hw/spapr_vio.c +++ b/hw/spapr_vio.c @@ -648,13 +648,18 @@ static int spapr_vio_check_reg(VIOsPAPRDevice *sdev) return 0; } -static void spapr_vio_busdev_reset(void *opaque) +static void spapr_vio_busdev_reset(DeviceState *qdev) { - VIOsPAPRDevice *dev = (VIOsPAPRDevice *)opaque; + VIOsPAPRDevice *dev = DO_UPCAST(VIOsPAPRDevice, qdev, qdev); + VIOsPAPRDeviceClass *pc = VIO_SPAPR_DEVICE_GET_CLASS(dev); if (dev->crq.qsize) { free_crq(dev); } + + if (pc->reset) { + pc->reset(dev); + } } static int spapr_vio_busdev_init(DeviceState *qdev) @@ -685,8 +690,6 @@ static int spapr_vio_busdev_init(DeviceState *qdev) rtce_init(dev); - qemu_register_reset(spapr_vio_busdev_reset, dev); - return pc->init(dev); } @@ -776,6 +779,7 @@ static void vio_spapr_device_class_init(ObjectClass *klass, void *data) { DeviceClass *k = DEVICE_CLASS(klass); k->init = spapr_vio_busdev_init; + k->reset = spapr_vio_busdev_reset; k->bus_info = &spapr_vio_bus_info; } diff --git a/hw/spapr_vio.h b/hw/spapr_vio.h index 626d04f..10ab359 100644 --- a/hw/spapr_vio.h +++ b/hw/spapr_vio.h @@ -64,6 +64,7 @@ typedef struct VIOsPAPRDeviceClass { const char *dt_name, *dt_type, *dt_compatible; target_ulong signal_mask; int (*init)(VIOsPAPRDevice *dev); + void (*reset)(VIOsPAPRDevice *dev); int (*devnode)(VIOsPAPRDevice *dev, void *fdt, int node_off); } VIOsPAPRDeviceClass;