From patchwork Mon Feb 10 23:02:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 24431 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f70.google.com (mail-vb0-f70.google.com [209.85.212.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C14D3202B2 for ; Mon, 10 Feb 2014 23:06:05 +0000 (UTC) Received: by mail-vb0-f70.google.com with SMTP id w17sf15876774vbj.5 for ; Mon, 10 Feb 2014 15:06:04 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:cc:subject:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:errors-to:sender :x-original-sender:x-original-authentication-results:mailing-list; bh=V+b3ql+iOc0asMkpF/G93F1qrTREl650MwklFvpwYCA=; b=BVOCQlhga6JZovaIJKoGgiCoQ3S3a8sNQEUjPbGe6Hule/9onQeXvvwtBnMmW1ZqF+ WsCwZCqHluTpQ0vd6tgRJ2CrVkrLP+rc0J4amxRkwgXCadydU9gQ1ckcqhMVLr3um0P+ tzLtbG9dYr1DHZiZxtke9o+wDHmjSR5ZNcAgD2TJ1xQauubnVTP+E5XG8s5yyiYQQHkK oXNg8BQeIRqiwEtyTpj8yjM+VUo8AHzljffnpapsRRDMp/siqul6emaUMb5Ps/Lv9rmG DL7jpicZ5Rm8ZyXmo2/OldN45RWgpGqA4raA1WfPgRN6Y5WKIzPSsMMlFFAqlCITyw8i UOwg== X-Gm-Message-State: ALoCoQkCUwDAV67jLr0+7rBZ4GvMs3O1q62dO8vUYeG/XDev4i+bMODH7VMJCTIqpCOEF9xN4dIo X-Received: by 10.236.96.138 with SMTP id r10mr10621523yhf.12.1392073564645; Mon, 10 Feb 2014 15:06:04 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.28.162 with SMTP id 31ls360351qgz.50.gmail; Mon, 10 Feb 2014 15:06:04 -0800 (PST) X-Received: by 10.58.168.142 with SMTP id zw14mr59468veb.33.1392073564489; Mon, 10 Feb 2014 15:06:04 -0800 (PST) Received: from mail-vc0-x22e.google.com (mail-vc0-x22e.google.com [2607:f8b0:400c:c03::22e]) by mx.google.com with ESMTPS id v7si5245327vet.66.2014.02.10.15.06.04 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 10 Feb 2014 15:06:04 -0800 (PST) Received-SPF: neutral (google.com: 2607:f8b0:400c:c03::22e is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c03::22e; Received: by mail-vc0-f174.google.com with SMTP id im17so5361298vcb.33 for ; Mon, 10 Feb 2014 15:06:04 -0800 (PST) X-Received: by 10.221.29.196 with SMTP id rz4mr25846167vcb.8.1392073564406; Mon, 10 Feb 2014 15:06:04 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.174.196 with SMTP id u4csp203964vcz; Mon, 10 Feb 2014 15:06:04 -0800 (PST) X-Received: by 10.140.107.138 with SMTP id h10mr48558169qgf.30.1392073563779; Mon, 10 Feb 2014 15:06:03 -0800 (PST) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id k45si11143596qgd.142.2014.02.10.15.06.03 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 10 Feb 2014 15:06:03 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:58562 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WCzvP-0000U1-8u for patch@linaro.org; Mon, 10 Feb 2014 18:06:03 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39149) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WCzur-00007f-7h for qemu-devel@nongnu.org; Mon, 10 Feb 2014 18:05:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WCzul-0000qi-Sc for qemu-devel@nongnu.org; Mon, 10 Feb 2014 18:05:29 -0500 Received: from mail-ob0-x232.google.com ([2607:f8b0:4003:c01::232]:50652) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WCzul-0000qW-NF for qemu-devel@nongnu.org; Mon, 10 Feb 2014 18:05:23 -0500 Received: by mail-ob0-f178.google.com with SMTP id wn1so7971554obc.23 for ; Mon, 10 Feb 2014 15:05:23 -0800 (PST) X-Received: by 10.60.51.6 with SMTP id g6mr29379779oeo.5.1392073523129; Mon, 10 Feb 2014 15:05:23 -0800 (PST) Received: from localhost.localdomain (65-36-73-129.dyn.grandenetworks.net. [65.36.73.129]) by mx.google.com with ESMTPSA id fn10sm39191635obb.12.2014.02.10.15.05.22 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 10 Feb 2014 15:05:22 -0800 (PST) From: Rob Herring To: qemu-devel@nongnu.org Date: Mon, 10 Feb 2014 17:02:53 -0600 Message-Id: <1392073373-3295-1-git-send-email-robherring2@gmail.com> X-Mailer: git-send-email 1.8.3.2 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4003:c01::232 Cc: Rob Herring Subject: [Qemu-devel] [PATCH] ahci: fix sysbus support 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Original-Sender: robherring2@gmail.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c03::22e is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=fail header.i=@gmail.com; dmarc=fail (p=NONE dis=NONE) header.from=gmail.com Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Rob Herring Non-PCI AHCI support is broken due to assertion failures when trying to convert AHCIState to a PCIDevice pointer as AHCIState can have different container structs. Fix this by using the non-asserting object cast and checking the returned pointer is not NULL. The AddressSpace pointer is also being initialized to NULL and causing dma_memory_map call to fail. Fix this by initializing to address_space_memory for sysbus instances. Also correct AHCI_VMSTATE to use the correct container SysbusAHCIState for sysbus instances. Signed-off-by: Rob Herring Reviewed-by: Peter Maydell --- hw/ide/ahci.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index fbea9e8..55f984e 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -118,11 +118,11 @@ static uint32_t ahci_port_read(AHCIState *s, int port, int offset) static void ahci_irq_raise(AHCIState *s, AHCIDevice *dev) { AHCIPCIState *d = container_of(s, AHCIPCIState, ahci); - PCIDevice *pci_dev = PCI_DEVICE(d); + PCIDevice *pci_dev = (PCIDevice *)object_dynamic_cast(OBJECT(d), TYPE_PCI_DEVICE); DPRINTF(0, "raise irq\n"); - if (msi_enabled(pci_dev)) { + if (pci_dev && msi_enabled(pci_dev)) { msi_notify(pci_dev, 0); } else { qemu_irq_raise(s->irq); @@ -132,10 +132,11 @@ static void ahci_irq_raise(AHCIState *s, AHCIDevice *dev) static void ahci_irq_lower(AHCIState *s, AHCIDevice *dev) { AHCIPCIState *d = container_of(s, AHCIPCIState, ahci); + PCIDevice *pci_dev = (PCIDevice *)object_dynamic_cast(OBJECT(d), TYPE_PCI_DEVICE); DPRINTF(0, "lower irq\n"); - if (!msi_enabled(PCI_DEVICE(d))) { + if (!pci_dev || !msi_enabled(pci_dev)) { qemu_irq_lower(s->irq); } } @@ -1311,7 +1312,7 @@ static const VMStateDescription vmstate_sysbus_ahci = { .name = "sysbus-ahci", .unmigratable = 1, /* Still buggy under I/O load */ .fields = (VMStateField []) { - VMSTATE_AHCI(ahci, AHCIPCIState), + VMSTATE_AHCI(ahci, SysbusAHCIState), VMSTATE_END_OF_LIST() }, }; @@ -1328,7 +1329,7 @@ static void sysbus_ahci_realize(DeviceState *dev, Error **errp) SysBusDevice *sbd = SYS_BUS_DEVICE(dev); SysbusAHCIState *s = SYSBUS_AHCI(dev); - ahci_init(&s->ahci, dev, NULL, s->num_ports); + ahci_init(&s->ahci, dev, &address_space_memory, s->num_ports); sysbus_init_mmio(sbd, &s->ahci.mem); sysbus_init_irq(sbd, &s->ahci.irq);