From mboxrd@z Thu Jan 1 00:00:00 1970 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=-14.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 6239DC47076 for ; Fri, 21 May 2021 16:41:22 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 D2BD4613E9 for ; Fri, 21 May 2021 16:41:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D2BD4613E9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=dFfGCvut/3EUIOTP52am8kJsAnKzvVDyTei4jfhLxsM=; b=KyJS00xQlooteXS5cg5oImCX0X mPRqEfJArcTl+zVV8iHCOvj02/8PfGbJw3bNNx+6TbOgmEgiu8fKMEB/rKir6KRxRLMMBLHqP/E+h oqvnVSv2IF6oNLiEyMZ9Td+SReN4qOXd9pH1YcNXl4DITe4YLTzNXWPJKudBtWh3klKVYzNaTE0OY /8Vdr+AgdAgQqsE4tvpiDqMFPuJfVMOx69ThSc5waUUygOtQIiU5VZ5SdWDBnvb3IvNteWfLibUDb qtWpZXpzqoI1qfPNn1kBJykRGf8ukIG6XDfuTVPVJBrvjXtiI3locF3/0DifGq0g8goomeUVcF0Z6 cgbX6CQA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lk8BZ-000IT8-K8; Fri, 21 May 2021 16:39:41 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lk8BX-000ISu-4y for linux-arm-kernel@desiato.infradead.org; Fri, 21 May 2021 16:39:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Type:Cc:To:Subject:Message-ID :Date:From:In-Reply-To:References:MIME-Version:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=5L/RoK6wup09rAoEsvKy77fTqf/Hy3G7bB4uSc9Jrfo=; b=GChGH7ob+cUG5b0BXUJOaqnxzS qS79JTUyZe4O6BCumTEmf4ZIu2Ah0PqzPiR1Cu7RhzAo9joq0O4MncQC9/RdzVXqBj1X+tkTAhB3B 6UDEE8vWXjOQrzDRPzKfzBDwcAYV8ZyNDtCoNMR+u3UxnODqZsO195Jha0XzuNA6kGahXW7byKQ0h +V+zrzepIGU60ofm+HIIakdVfmm/IUSbW3SRNjTY5Bh3Z9rlgrDpXeqqKqL+PoM0wZ7cFBRS5BTaj tIBqcilcxG47WsiI59xUgn5VCfqx16U8rVOlALDZJrbbdIGSO4gH+WqlRx9iLbbgiyDYirG2Prg4S NDz6YjeQ==; Received: from mail-oi1-f180.google.com ([209.85.167.180]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lk8BU-00HHfD-9b for linux-arm-kernel@lists.infradead.org; Fri, 21 May 2021 16:39:37 +0000 Received: by mail-oi1-f180.google.com with SMTP id h9so20229931oih.4 for ; Fri, 21 May 2021 09:39:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=5L/RoK6wup09rAoEsvKy77fTqf/Hy3G7bB4uSc9Jrfo=; b=alshsRfC7HTzXoCCb/N3be2kfaXret01b20Kbp/FyRY/VMvipAwfXLqFUWhXAcY9W3 J8ctn74y2kMnuxpbJEopq5MyIN8l9m9Br4bllZbg8FxNl4mt8JrCr2I45Eb6RTT1BIyu FYGPxBQ5su8UvI6BigEfGYbhK4D46+NM/PBUd04g1xUqlfdaropq8jUYqaRdP33hwJHs vsVIen43/g2pSv3gFaNwAHX4HV0GtER47RHQd+8sRYaHlKaarLXjZAYnuCXbnbYnbWyS vYbEPLSQNaIJIS2OZZ83kJZVRRQ203XYOnUKcVyFvbKMsRm1vhx3+L4DMuXGcBzVy5LU rYlQ== X-Gm-Message-State: AOAM5318zHLKr92c5lm+PTKYd0sKV0mfJjq2Z1Zn6q4bpIakv1LpuwZj 7XCjbwLRfcD5nZVnCN7ILbh139DfExnRMzwq7i8= X-Google-Smtp-Source: ABdhPJybUpZcko8bDzbsYB0EWlv5wAQPE40mmkviuVqrnlJf1vsIP3osFfCJr1yxVSlO/8tJbLKE8TlBsZTeC8zPyhw= X-Received: by 2002:aca:4758:: with SMTP id u85mr2840877oia.71.1621615175113; Fri, 21 May 2021 09:39:35 -0700 (PDT) MIME-Version: 1.0 References: <20210423113836.3974972-1-jean-philippe@linaro.org> <20210423113836.3974972-4-jean-philippe@linaro.org> In-Reply-To: <20210423113836.3974972-4-jean-philippe@linaro.org> From: "Rafael J. Wysocki" Date: Fri, 21 May 2021 18:39:24 +0200 Message-ID: Subject: Re: [PATCH v2 3/6] ACPI: Add driver for the VIOT table To: Jean-Philippe Brucker Cc: "Rafael J. Wysocki" , Len Brown , Joerg Roedel , "Michael S. Tsirkin" , Will Deacon , Catalin Marinas , Lu Baolu , David Woodhouse , ACPI Devel Maling List , "open list:AMD IOMMU (AMD-VI)" , virtualization@lists.linux-foundation.org, Linux ARM , Eric Auger , sebastien.boeuf@intel.com, Robin Murphy , kevin.tian@intel.com, Lorenzo Pieralisi , Hanjun Guo , Sudeep Holla X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210521_093936_383690_A0496FD6 X-CRM114-Status: GOOD ( 30.08 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Apr 23, 2021 at 1:57 PM Jean-Philippe Brucker wrote: > > The ACPI Virtual I/O Translation Table describes topology of > para-virtual platforms, similarly to vendor tables DMAR, IVRS and IORT. > For now it describes the relation between virtio-iommu and the endpoints > it manages. > > Three steps are needed to configure DMA of endpoints: > > (1) acpi_viot_init(): parse the VIOT table, find or create the fwnode > associated to each vIOMMU device. > > (2) When probing the vIOMMU device, the driver registers its IOMMU ops > within the IOMMU subsystem. This step doesn't require any > intervention from the VIOT driver. > > (3) viot_iommu_configure(): before binding the endpoint to a driver, > find the associated IOMMU ops. Register them, along with the > endpoint ID, into the device's iommu_fwspec. > > If step (3) happens before step (2), it is deferred until the IOMMU is > initialized, then retried. > > Signed-off-by: Jean-Philippe Brucker > --- > drivers/acpi/Kconfig | 3 + > drivers/iommu/Kconfig | 1 + > drivers/acpi/Makefile | 2 + > include/linux/acpi_viot.h | 19 +++ > drivers/acpi/bus.c | 2 + > drivers/acpi/scan.c | 3 + > drivers/acpi/viot.c | 350 ++++++++++++++++++++++++++++++++++++++ > MAINTAINERS | 8 + > 8 files changed, 388 insertions(+) > create mode 100644 include/linux/acpi_viot.h > create mode 100644 drivers/acpi/viot.c > > diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig > index eedec61e3476..3758c6940ed7 100644 > --- a/drivers/acpi/Kconfig > +++ b/drivers/acpi/Kconfig > @@ -526,6 +526,9 @@ endif > > source "drivers/acpi/pmic/Kconfig" > > +config ACPI_VIOT > + bool > + > endif # ACPI > > config X86_PM_TIMER > diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig > index 1f111b399bca..aff8a4830dd1 100644 > --- a/drivers/iommu/Kconfig > +++ b/drivers/iommu/Kconfig > @@ -403,6 +403,7 @@ config VIRTIO_IOMMU > depends on ARM64 > select IOMMU_API > select INTERVAL_TREE > + select ACPI_VIOT if ACPI > help > Para-virtualised IOMMU driver with virtio. > > diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile > index 700b41adf2db..a6e644c48987 100644 > --- a/drivers/acpi/Makefile > +++ b/drivers/acpi/Makefile > @@ -118,3 +118,5 @@ video-objs += acpi_video.o video_detect.o > obj-y += dptf/ > > obj-$(CONFIG_ARM64) += arm64/ > + > +obj-$(CONFIG_ACPI_VIOT) += viot.o > diff --git a/include/linux/acpi_viot.h b/include/linux/acpi_viot.h > new file mode 100644 > index 000000000000..1eb8ee5b0e5f > --- /dev/null > +++ b/include/linux/acpi_viot.h > @@ -0,0 +1,19 @@ > +/* SPDX-License-Identifier: GPL-2.0-only */ > + > +#ifndef __ACPI_VIOT_H__ > +#define __ACPI_VIOT_H__ > + > +#include > + > +#ifdef CONFIG_ACPI_VIOT > +void __init acpi_viot_init(void); > +int viot_iommu_configure(struct device *dev); > +#else > +static inline void acpi_viot_init(void) {} > +static inline int viot_iommu_configure(struct device *dev) > +{ > + return -ENODEV; > +} > +#endif > + > +#endif /* __ACPI_VIOT_H__ */ > diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c > index be7da23fad76..b835ca702ff0 100644 > --- a/drivers/acpi/bus.c > +++ b/drivers/acpi/bus.c > @@ -27,6 +27,7 @@ > #include > #endif > #include > +#include > #include > #include > #include > @@ -1339,6 +1340,7 @@ static int __init acpi_init(void) > pci_mmcfg_late_init(); > acpi_iort_init(); > acpi_scan_init(); > + acpi_viot_init(); > acpi_ec_init(); > acpi_debugfs_init(); > acpi_sleep_proc_init(); > diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c > index 5924421075f6..4db43c822ee7 100644 > --- a/drivers/acpi/scan.c > +++ b/drivers/acpi/scan.c > @@ -9,6 +9,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -1554,6 +1555,8 @@ static const struct iommu_ops *acpi_iommu_configure_id(struct device *dev, > return ops; > > err = iort_iommu_configure_id(dev, id_in); > + if (err && err != -EPROBE_DEFER) > + err = viot_iommu_configure(dev); > > /* > * If we have reason to believe the IOMMU driver missed the initial > diff --git a/drivers/acpi/viot.c b/drivers/acpi/viot.c > new file mode 100644 > index 000000000000..710e5a5eac70 > --- /dev/null > +++ b/drivers/acpi/viot.c > @@ -0,0 +1,350 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * Virtual I/O topology In the first place, more information on what this is all about, please. What it does and how it is used. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel