From patchwork Thu Aug 26 20:07:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12460651 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C2C6C43214 for ; Thu, 26 Aug 2021 20:08:49 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D097D60FE6 for ; Thu, 26 Aug 2021 20:08:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D097D60FE6 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:35062 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJLg7-0000Bz-T6 for qemu-devel@archiver.kernel.org; Thu, 26 Aug 2021 16:08:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52086) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJLex-0005sh-CK for qemu-devel@nongnu.org; Thu, 26 Aug 2021 16:07:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:40840) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJLet-0005dM-Mr for qemu-devel@nongnu.org; Thu, 26 Aug 2021 16:07:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630008449; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iFdJgmZSFDi0T3tz5j4VdZ4mFoLbPu805prh7+ofjFQ=; b=Rmb6K2BGPnhajjnEW1/GQPBsSBshhPMvB55eyMqTkyw2P9tmMPbUghl4YMZYfwT32eCvDs h+UpLWoffYhU77CbD/NMzV/mZuP+7/ZOsEai3VuI/OvLHXcMj5Vzg3ZhcKvrJPEyep+03p YrXGKlCGvg39DAJf2MblvwpQo69F+cE= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-365-kch9r3bBPu6b5wEqBhDVFw-1; Thu, 26 Aug 2021 16:07:28 -0400 X-MC-Unique: kch9r3bBPu6b5wEqBhDVFw-1 Received: by mail-wm1-f70.google.com with SMTP id a201-20020a1c7fd2000000b002e748bf0544so4800725wmd.2 for ; Thu, 26 Aug 2021 13:07:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=iFdJgmZSFDi0T3tz5j4VdZ4mFoLbPu805prh7+ofjFQ=; b=pdcYX4GClK2dej4h0o0SiC7EDIawi38eV+4F1uu3uWxcT/mbg12Topua0qK1LQLTQ4 6C3ClT0AHiVA5piF3T4+q1u6mPB6i3IAsKMiaR+/WyVXkANYMouzNKsHjPMzphI7Plr2 Y9XnCenL12vUf5rjgQgFy86Lkq5QTEzOkU28Y38hsE6cHmYIE6SK3kB8Tl+GHPzgMbVc pLmngWZdmsJoQhhJTKukWaKQEx4ysQXh16V/14eywgBOkRd7S2t/dSH+k7bN0IsOkbRF srfl1ReEtr0E3c5ril9wut4bQBHxmXBVa3eMxSL2GIkjqM3l+B0rpbUol25BAdvelkn+ RJYQ== X-Gm-Message-State: AOAM533Fvut+u/PQVM5ilR79PEFpWEF8DniGz4JCamdywgTvKuOtwOzM PsohLFdptw34KaTU9OK/Py/eAQch0jUkRek/Rl8LdVAUdy/M5nwsws35/uU8/a6Fe7CQgpiaZCd BTsIR9njHFcKuBdIuYcEegRLVxA3mvAvsVkWvYaK8fs6xHd0V8R0gEsI5Nl79Bj1g X-Received: by 2002:a5d:4568:: with SMTP id a8mr6402661wrc.200.1630008447158; Thu, 26 Aug 2021 13:07:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyXM+8NhwWeRegRd1V7F+CEHGpzg5FArWoj0MLdwiQWtLa7KFb1eNKTHJ8Gtl/e3VLSkMXnxw== X-Received: by 2002:a5d:4568:: with SMTP id a8mr6402629wrc.200.1630008446951; Thu, 26 Aug 2021 13:07:26 -0700 (PDT) Received: from x1w.. (163.red-83-52-55.dynamicip.rima-tde.net. [83.52.55.163]) by smtp.gmail.com with ESMTPSA id u26sm2085844wrd.32.2021.08.26.13.07.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Aug 2021 13:07:26 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v3 1/3] hw/pci: Introduce pci_dma_memory_region() helper Date: Thu, 26 Aug 2021 22:07:18 +0200 Message-Id: <20210826200720.2196827-2-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210826200720.2196827-1-philmd@redhat.com> References: <20210826200720.2196827-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.742, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Sergio Lopez , "Michael S. Tsirkin" , Richard Henderson , Gerd Hoffmann , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" pci_get_address_space() returns an AddressSpace. In some cases we want a MemoryRegion. Add the pci_dma_memory_region() equivalent helper. Signed-off-by: Philippe Mathieu-Daudé --- include/hw/pci/pci.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index d0f4266e372..5860f42e400 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -786,6 +786,11 @@ static inline AddressSpace *pci_get_address_space(PCIDevice *dev) return &dev->bus_master_as; } +static inline MemoryRegion *pci_dma_memory_region(PCIDevice *dev) +{ + return &dev->bus_master_container_region; +} + /** * pci_dma_rw: Read from or write to an address space from PCI device. * From patchwork Thu Aug 26 20:07:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12460649 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E1B73C432BE for ; Thu, 26 Aug 2021 20:08:47 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7733F60F45 for ; Thu, 26 Aug 2021 20:08:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 7733F60F45 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:34962 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJLg6-00007W-HH for qemu-devel@archiver.kernel.org; Thu, 26 Aug 2021 16:08:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52114) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJLey-0005xv-Q8 for qemu-devel@nongnu.org; Thu, 26 Aug 2021 16:07:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:31502) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJLew-0005gV-T6 for qemu-devel@nongnu.org; Thu, 26 Aug 2021 16:07:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630008454; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8ZLosj281VIPcnVVY5MWZocWOZi5mT78NAOIuJQf3M8=; b=PiHdk1IU4lg1cBiCRgt2BZhKoPUcmYTAvus2Jm/SOvNJatWSujXRWEmdq67aZKLLgGrM8a uz+Uyk6fjHy7c6jYgbbGE8IhDBEYY1rQ86t5HhreM8JDvwYoJQWnVveKwn6tfYmJ7v0sKr uI6rYaUDtrfHcOFvcnZqweWMAqXfzoQ= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-488-aD0tW992NFOuzZVhkQAYqw-1; Thu, 26 Aug 2021 16:07:33 -0400 X-MC-Unique: aD0tW992NFOuzZVhkQAYqw-1 Received: by mail-wm1-f72.google.com with SMTP id j135-20020a1c238d000000b002e87aa95b5aso3984902wmj.4 for ; Thu, 26 Aug 2021 13:07:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8ZLosj281VIPcnVVY5MWZocWOZi5mT78NAOIuJQf3M8=; b=qkUiOTbT+xR26hdgsbFnGZjyJPWKma8ARL+y3/uFGL9kqdxLz6KWhruzCNppJfxJWU 2WC8VQqlh4gqLicEYotOQ0qvjznwJ/xCuPyE9mWyVHQVNnw3bA63sxNHyhPxfTVN/dwK IqZ6G2oT50pugB2u0+41LPkn38iRCWXZLJ3kFs2P+WUDNj+fUoOoLUy/TFI7BJIzFYOU YMLxKMcG2zeZYg9dywRXofMOyiIZTQIHgqSsfAyEb93jvNk9n5Ht2OAxHRPYL8AFXbkt BCFN1J8HzTEV/pCEj+8QCbavUeVuKyXw31XH8g0tGrhodXajvZcotxvuU6WmRN/0C3Q9 x4vg== X-Gm-Message-State: AOAM5324F5dawzr6YHyuUI6qwtyIDVBB9s8AhSaJS0A9OSKCemOGRL2T 1u7U2YKQTq2Y8TU3WSK7Tfh7in+3rjie5rXQdAYSCzYTn6qbxWU4u5UaV8ACZNGBWGjdLT2RquU SpV7yxzkbfRuzSUzRlKRLPNpq+1q6AR8gcIy8Hw6QL6BCSgP5IY9BFqNQav1jjriB X-Received: by 2002:a1c:a5c2:: with SMTP id o185mr16068553wme.34.1630008451522; Thu, 26 Aug 2021 13:07:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyMCstQ65sK3jZMXwP0SFbsn0H2tQqwl2KgBLEA5lchtjsw/WTWmqZcZYq3kpEdDr2fs9ONKQ== X-Received: by 2002:a1c:a5c2:: with SMTP id o185mr16068529wme.34.1630008451304; Thu, 26 Aug 2021 13:07:31 -0700 (PDT) Received: from x1w.. (163.red-83-52-55.dynamicip.rima-tde.net. [83.52.55.163]) by smtp.gmail.com with ESMTPSA id y1sm3837057wmq.43.2021.08.26.13.07.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Aug 2021 13:07:30 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v3 2/3] hw/usb/hcd-xhci-pci: Abort if setting link property failed Date: Thu, 26 Aug 2021 22:07:19 +0200 Message-Id: <20210826200720.2196827-3-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210826200720.2196827-1-philmd@redhat.com> References: <20210826200720.2196827-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.742, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Sergio Lopez , "Michael S. Tsirkin" , Richard Henderson , Gerd Hoffmann , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Do not ignore eventual error if we failed at setting the 'host' property of the TYPE_XHCI model. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Mark Cave-Ayland --- hw/usb/hcd-xhci-pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/usb/hcd-xhci-pci.c b/hw/usb/hcd-xhci-pci.c index e934b1a5b1f..24c528d210f 100644 --- a/hw/usb/hcd-xhci-pci.c +++ b/hw/usb/hcd-xhci-pci.c @@ -115,7 +115,7 @@ static void usb_xhci_pci_realize(struct PCIDevice *dev, Error **errp) dev->config[PCI_CACHE_LINE_SIZE] = 0x10; dev->config[0x60] = 0x30; /* release number */ - object_property_set_link(OBJECT(&s->xhci), "host", OBJECT(s), NULL); + object_property_set_link(OBJECT(&s->xhci), "host", OBJECT(s), &error_abort); s->xhci.intr_update = xhci_pci_intr_update; s->xhci.intr_raise = xhci_pci_intr_raise; if (!qdev_realize(DEVICE(&s->xhci), NULL, errp)) { From patchwork Thu Aug 26 20:07:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12460655 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19A57C432BE for ; Thu, 26 Aug 2021 20:08:55 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9BCA060FE6 for ; Thu, 26 Aug 2021 20:08:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9BCA060FE6 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:35702 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJLgD-0000d5-NU for qemu-devel@archiver.kernel.org; Thu, 26 Aug 2021 16:08:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52136) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJLf4-0006G1-ST for qemu-devel@nongnu.org; Thu, 26 Aug 2021 16:07:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:27291) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJLf2-0005kv-QR for qemu-devel@nongnu.org; Thu, 26 Aug 2021 16:07:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630008460; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UeL3Yz7d1ZnWXoMN7sC9fU3j5GyHb4O1fAS4ToJkz0k=; b=C6Bta0hw9T0se7ZxB9uXtIqasvaPeRPJBkh/K9VUBalxEFUzyVZyF8fLJiLBSLzQyj2xgS bpypd+mD4cTkMARZAr+GbaA616Suio36XwfdLErd6nEzYZ4DvA2QI1t1HGEINEkZF6Q9gl hBeN+tdGRHYzh6cS1EQOQZ5HoG2DP2w= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-530-Gy0ljGqcN4CZDhFwveNw4A-1; Thu, 26 Aug 2021 16:07:37 -0400 X-MC-Unique: Gy0ljGqcN4CZDhFwveNw4A-1 Received: by mail-wm1-f72.google.com with SMTP id g3-20020a1c2003000000b002e751c4f439so4785713wmg.7 for ; Thu, 26 Aug 2021 13:07:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UeL3Yz7d1ZnWXoMN7sC9fU3j5GyHb4O1fAS4ToJkz0k=; b=HxU2+vjfTd6IQw/fXWzjHRpBf1lMy1i8nrt9PCHIEJiPGCjsmzTuJwabfvLdkhlahI lP/2MXPPacgGGMrREMVkbO9f/ttcws3BAtI+dde7Yg1M6DKsG4yMbBIrZBER/74VssR4 82BvhBiufxMicEVkNJLHuUpdqVTCEvIJFTUSRIc38aLVncwSQc5N39cG/CO4PVNSveB0 XEAn94A7ZBSG9NLo8PZMr0YWwU6oAztA2UHu70dJPtlQCIIRWwM7tHlYaUv7C6VKdh3f 3QKqvM1Ywp0m+r0NJwSByJixqMtP8QtS3GN+wSELTZkrXeAQfujPAHdl6UGrIIgfhogx /HZg== X-Gm-Message-State: AOAM530H7eX4nhVdoKA7/Cqlale8E6+FMX59rE5f6xop0anwlccWli+d r+DMJ7yQEsjBWV8c9eIt8mRwsFh2JZP67D8B+/I3qIAu49WaExFKbt28zZgb2VyQPP2r5rUHlk4 lDgoGe+FR88aTfaAqUXgImJOwc22XeEgRp4qaYv0nrYNvODoSn+PmgClBNJ6Do9J2 X-Received: by 2002:adf:90d0:: with SMTP id i74mr5940250wri.185.1630008456218; Thu, 26 Aug 2021 13:07:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyzzwGSEySuwUOYsPFZjviyVMv4xJ0gCe32nTG9XYL+82hMU1fxFo19TDjPYqtPlSzC19TZEw== X-Received: by 2002:adf:90d0:: with SMTP id i74mr5940210wri.185.1630008455869; Thu, 26 Aug 2021 13:07:35 -0700 (PDT) Received: from x1w.. (163.red-83-52-55.dynamicip.rima-tde.net. [83.52.55.163]) by smtp.gmail.com with ESMTPSA id f17sm4786090wrt.63.2021.08.26.13.07.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Aug 2021 13:07:35 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v3 3/3] hw/usb/xhci: Always expect 'dma' link property to be set Date: Thu, 26 Aug 2021 22:07:20 +0200 Message-Id: <20210826200720.2196827-4-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210826200720.2196827-1-philmd@redhat.com> References: <20210826200720.2196827-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.742, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Sergio Lopez , "Michael S. Tsirkin" , Richard Henderson , Gerd Hoffmann , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Simplify by always passing a MemoryRegion property to the device. Doing so we can move the AddressSpace field to the device struct, removing need for heap allocation. Update the MicroVM machine to pass the default system memory instead of a NULL value. We don't need to change the Versal machine, as the link property is initialize as "versal.dwc3_alias" MemoryRegion alias. Suggested-by: Peter Maydell Signed-off-by: Philippe Mathieu-Daudé --- Versal untested --- hw/usb/hcd-xhci.h | 2 +- hw/i386/microvm.c | 2 ++ hw/usb/hcd-xhci-pci.c | 3 ++- hw/usb/hcd-xhci-sysbus.c | 13 ++++++------- hw/usb/hcd-xhci.c | 20 ++++++++++---------- 5 files changed, 21 insertions(+), 19 deletions(-) diff --git a/hw/usb/hcd-xhci.h b/hw/usb/hcd-xhci.h index 98f598382ad..ea76ec4f277 100644 --- a/hw/usb/hcd-xhci.h +++ b/hw/usb/hcd-xhci.h @@ -180,7 +180,7 @@ typedef struct XHCIState { USBBus bus; MemoryRegion mem; MemoryRegion *dma_mr; - AddressSpace *as; + AddressSpace as; MemoryRegion mem_cap; MemoryRegion mem_oper; MemoryRegion mem_runtime; diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c index aba0c832190..2d55114a676 100644 --- a/hw/i386/microvm.c +++ b/hw/i386/microvm.c @@ -219,6 +219,8 @@ static void microvm_devices_init(MicrovmMachineState *mms) qdev_prop_set_uint32(dev, "slots", XHCI_MAXSLOTS); qdev_prop_set_uint32(dev, "p2", 8); qdev_prop_set_uint32(dev, "p3", 8); + object_property_set_link(OBJECT(dev), "dma", + OBJECT(get_system_memory()), &error_abort); sysbus_realize(SYS_BUS_DEVICE(dev), &error_fatal); sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, MICROVM_XHCI_BASE); sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, diff --git a/hw/usb/hcd-xhci-pci.c b/hw/usb/hcd-xhci-pci.c index 24c528d210f..10f5cc374fe 100644 --- a/hw/usb/hcd-xhci-pci.c +++ b/hw/usb/hcd-xhci-pci.c @@ -116,6 +116,8 @@ static void usb_xhci_pci_realize(struct PCIDevice *dev, Error **errp) dev->config[0x60] = 0x30; /* release number */ object_property_set_link(OBJECT(&s->xhci), "host", OBJECT(s), &error_abort); + object_property_set_link(OBJECT(dev), "dma", + OBJECT(pci_dma_memory_region(dev)), &error_abort); s->xhci.intr_update = xhci_pci_intr_update; s->xhci.intr_raise = xhci_pci_intr_raise; if (!qdev_realize(DEVICE(&s->xhci), NULL, errp)) { @@ -161,7 +163,6 @@ static void usb_xhci_pci_realize(struct PCIDevice *dev, Error **errp) &s->xhci.mem, 0, OFF_MSIX_PBA, 0x90, NULL); } - s->xhci.as = pci_get_address_space(dev); } static void usb_xhci_pci_exit(PCIDevice *dev) diff --git a/hw/usb/hcd-xhci-sysbus.c b/hw/usb/hcd-xhci-sysbus.c index a14e4381960..f212ce785bd 100644 --- a/hw/usb/hcd-xhci-sysbus.c +++ b/hw/usb/hcd-xhci-sysbus.c @@ -36,6 +36,11 @@ static void xhci_sysbus_realize(DeviceState *dev, Error **errp) { XHCISysbusState *s = XHCI_SYSBUS(dev); + if (!s->xhci.dma_mr) { + error_setg(errp, TYPE_XHCI_SYSBUS " 'dma' link not set"); + return; + } + object_property_set_link(OBJECT(&s->xhci), "host", OBJECT(s), NULL); if (!qdev_realize(DEVICE(&s->xhci), NULL, errp)) { return; @@ -43,13 +48,7 @@ static void xhci_sysbus_realize(DeviceState *dev, Error **errp) s->irq = g_new0(qemu_irq, s->xhci.numintrs); qdev_init_gpio_out_named(dev, s->irq, SYSBUS_DEVICE_GPIO_IRQ, s->xhci.numintrs); - if (s->xhci.dma_mr) { - s->xhci.as = g_malloc0(sizeof(AddressSpace)); - address_space_init(s->xhci.as, s->xhci.dma_mr, NULL); - } else { - s->xhci.as = &address_space_memory; - } - + address_space_init(&s->xhci.as, s->xhci.dma_mr, "usb-xhci-dma"); sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->xhci.mem); } diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c index e01700039b1..011f1233ef3 100644 --- a/hw/usb/hcd-xhci.c +++ b/hw/usb/hcd-xhci.c @@ -487,7 +487,7 @@ static inline void xhci_dma_read_u32s(XHCIState *xhci, dma_addr_t addr, assert((len % sizeof(uint32_t)) == 0); - dma_memory_read(xhci->as, addr, buf, len); + dma_memory_read(&xhci->as, addr, buf, len); for (i = 0; i < (len / sizeof(uint32_t)); i++) { buf[i] = le32_to_cpu(buf[i]); @@ -507,7 +507,7 @@ static inline void xhci_dma_write_u32s(XHCIState *xhci, dma_addr_t addr, for (i = 0; i < n; i++) { tmp[i] = cpu_to_le32(buf[i]); } - dma_memory_write(xhci->as, addr, tmp, len); + dma_memory_write(&xhci->as, addr, tmp, len); } static XHCIPort *xhci_lookup_port(XHCIState *xhci, struct USBPort *uport) @@ -618,7 +618,7 @@ static void xhci_write_event(XHCIState *xhci, XHCIEvent *event, int v) ev_trb.status, ev_trb.control); addr = intr->er_start + TRB_SIZE*intr->er_ep_idx; - dma_memory_write(xhci->as, addr, &ev_trb, TRB_SIZE); + dma_memory_write(&xhci->as, addr, &ev_trb, TRB_SIZE); intr->er_ep_idx++; if (intr->er_ep_idx >= intr->er_size) { @@ -679,7 +679,7 @@ static TRBType xhci_ring_fetch(XHCIState *xhci, XHCIRing *ring, XHCITRB *trb, while (1) { TRBType type; - dma_memory_read(xhci->as, ring->dequeue, trb, TRB_SIZE); + dma_memory_read(&xhci->as, ring->dequeue, trb, TRB_SIZE); trb->addr = ring->dequeue; trb->ccs = ring->ccs; le64_to_cpus(&trb->parameter); @@ -726,7 +726,7 @@ static int xhci_ring_chain_length(XHCIState *xhci, const XHCIRing *ring) while (1) { TRBType type; - dma_memory_read(xhci->as, dequeue, &trb, TRB_SIZE); + dma_memory_read(&xhci->as, dequeue, &trb, TRB_SIZE); le64_to_cpus(&trb.parameter); le32_to_cpus(&trb.status); le32_to_cpus(&trb.control); @@ -781,7 +781,7 @@ static void xhci_er_reset(XHCIState *xhci, int v) xhci_die(xhci); return; } - dma_memory_read(xhci->as, erstba, &seg, sizeof(seg)); + dma_memory_read(&xhci->as, erstba, &seg, sizeof(seg)); le32_to_cpus(&seg.addr_low); le32_to_cpus(&seg.addr_high); le32_to_cpus(&seg.size); @@ -1393,7 +1393,7 @@ static int xhci_xfer_create_sgl(XHCITransfer *xfer, int in_xfer) int i; xfer->int_req = false; - qemu_sglist_init(&xfer->sgl, DEVICE(xhci), xfer->trb_count, xhci->as); + qemu_sglist_init(&xfer->sgl, DEVICE(xhci), xfer->trb_count, &xhci->as); for (i = 0; i < xfer->trb_count; i++) { XHCITRB *trb = &xfer->trbs[i]; dma_addr_t addr; @@ -2059,7 +2059,7 @@ static TRBCCode xhci_address_slot(XHCIState *xhci, unsigned int slotid, assert(slotid >= 1 && slotid <= xhci->numslots); dcbaap = xhci_addr64(xhci->dcbaap_low, xhci->dcbaap_high); - poctx = ldq_le_dma(xhci->as, dcbaap + 8 * slotid); + poctx = ldq_le_dma(&xhci->as, dcbaap + 8 * slotid); ictx = xhci_mask64(pictx); octx = xhci_mask64(poctx); @@ -2397,7 +2397,7 @@ static TRBCCode xhci_get_port_bandwidth(XHCIState *xhci, uint64_t pctx) /* TODO: actually implement real values here */ bw_ctx[0] = 0; memset(&bw_ctx[1], 80, xhci->numports); /* 80% */ - dma_memory_write(xhci->as, ctx, bw_ctx, sizeof(bw_ctx)); + dma_memory_write(&xhci->as, ctx, bw_ctx, sizeof(bw_ctx)); return CC_SUCCESS; } @@ -3434,7 +3434,7 @@ static int usb_xhci_post_load(void *opaque, int version_id) continue; } slot->ctx = - xhci_mask64(ldq_le_dma(xhci->as, dcbaap + 8 * slotid)); + xhci_mask64(ldq_le_dma(&xhci->as, dcbaap + 8 * slotid)); xhci_dma_read_u32s(xhci, slot->ctx, slot_ctx, sizeof(slot_ctx)); slot->uport = xhci_lookup_uport(xhci, slot_ctx); if (!slot->uport) {