From patchwork Fri Nov 22 10:49:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Philippe Brucker X-Patchwork-Id: 180031 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp66596ilf; Fri, 22 Nov 2019 03:16:09 -0800 (PST) X-Google-Smtp-Source: APXvYqwMng8SUTxWJSfmxqfbZiErzy05nt9UV5/qipfSuMMz0wa+g5zAazWlXbDyBwT+PdJskiz/ X-Received: by 2002:aa7:ce96:: with SMTP id y22mr384500edv.100.1574421369148; Fri, 22 Nov 2019 03:16:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574421369; cv=none; d=google.com; s=arc-20160816; b=EK7PQFtD7thnM6+9tLNC3bLckbY9zzGgzFmNA7F7POP7wILJEj0qqH81lysns2tE32 bD4Evtg0Y3MwWe75lHWzp5ymdzII/zJ8B9iHIGQpBRWmPyVbby9Ix7/nVk240mxFf/68 dfgyahKWpb1MExY+r/YlDi/AfmThoSgtRz5JauUlhcQOF1F7jyaCEtBVhfAoUkIxU6lU bzet8aNuw6NRGoetLKtrw7dbs8Ms8Kqph1shquQyu6x7RDdMruIlZSPemPzChJdb6PBe 3teBPJ1QMKVk21iP2ypcc0Q7OtEqpJI+7n7ShjBtqlkiNujXEkeqLMopcc4s7DiYw0S/ WpuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=X6qGp2c7p8L2l1s7Du/UosUTRGtm9jAQFCi+oOptldg=; b=psxf5gtQXnLyzHukjxmpQn7QbhaNoWW1x+8UX33dj79ZQpU547m4wtsx3D0aIlTxWF l0f1MvK/KOJtMoV9BeFjKOy4xNUJTHvW9OL3wCytOWNkDiwNJq5d7bDleHLSkxd+UhyN ixF3JPXkSccSiCGN/HLr2B8ecnycTmFLi+U+Y9QmV3zYGH604BhmZEANGfMPEU9m4oEq sduKjc0GlrjqEv5KTVLn3cmca63MNUmelfqjf7XqOfqcfT5JCRKyz+oxnh/BMBEW4LT4 2YPnimbSYpgH7ggNjooMgPkOGxBOUSdNZ8CAul/K0LtM9mdOgSkMLCOk05xhvo4BJcUI HvGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SOMWRl5M; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j6si3801343ejb.419.2019.11.22.03.16.08; Fri, 22 Nov 2019 03:16:09 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SOMWRl5M; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727762AbfKVLQH (ORCPT + 7 others); Fri, 22 Nov 2019 06:16:07 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:54099 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729325AbfKVKvI (ORCPT ); Fri, 22 Nov 2019 05:51:08 -0500 Received: by mail-wm1-f68.google.com with SMTP id u18so6931668wmc.3 for ; Fri, 22 Nov 2019 02:51:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=X6qGp2c7p8L2l1s7Du/UosUTRGtm9jAQFCi+oOptldg=; b=SOMWRl5MASeOm4GNtX9OArMbaILwLPRIzg8o5jQFJjlDJs7o7+6TRqRDRJJlcZKv1S C2wRUga0S929l8ZmubuZMrj4IpG5Fa2Nqe1Nopf/OfaG7JXzleQDTj1N8JFM+wM4dxkw a0IPZK9nsydiR7+ZaHFq8+zB4Kl+q/5r1Xtc5efWJGgpcICIwIevEVheIsqYwHeQbybW cC1h0KeLL/1CSa0gL5NCQZiIo97Dk5CcMapCj8Pt35ahMGhjHVVuLINva1JbNz3+Gk7f HvHGhikrvzqw3GWpjHonq28nTbE1JPkhrHfsEMIPgU0/NbAlKrRBh/66q3xFCw04rAqj UPvA== 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=X6qGp2c7p8L2l1s7Du/UosUTRGtm9jAQFCi+oOptldg=; b=m551qOahUO+Qcycml6n7OiPQ4WCGh/2IayHEKiBmTGKlyhWpQa2xmkQ9yfqnTm8KQf YWRCWjSgeht1jvkhuLnoLxUDhoALqJYrZX8c33Vz8j8kULzp3UOA4+CuzhKTWWG0mnFF vgwDPP2EwGyX+CC1VORXVFZQkFyo9L3VWYZ1sj9uQzJ0N2qDIV2Qv5lizix1vbhNAJue xChM4+IODcFudJ3JnE6xgW7XWy0H+lOCJj1XjeGOS1xys0kAXmp3pothGBnIgx95Fi24 THdSZ/jaeBXBJ1IRRDy0q4uWHFvoSmACtnLqBhvmt8rinWm27dhuFE2fADAR9n2oVdoI rmBw== X-Gm-Message-State: APjAAAX4jB8PRQ0MCmM1Ez5Pr+KvtbKb8T34Td9+l/M8aypdPqEE5JRj rhp0kE3aqYywkQ2GgMxhtAp5An9FOQw= X-Received: by 2002:a1c:2d49:: with SMTP id t70mr15677618wmt.131.1574419865443; Fri, 22 Nov 2019 02:51:05 -0800 (PST) Received: from localhost.localdomain (xdsl-188-155-204-106.adslplus.ch. [188.155.204.106]) by smtp.gmail.com with ESMTPSA id o133sm2088197wmb.4.2019.11.22.02.51.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Nov 2019 02:51:05 -0800 (PST) From: Jean-Philippe Brucker To: linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, iommu@lists.linux-foundation.org, virtualization@lists.linux-foundation.org, linux-pci@vger.kernel.org, virtio-dev@lists.oasis-open.org Cc: rjw@rjwysocki.net, lenb@kernel.org, lorenzo.pieralisi@arm.com, guohanjun@huawei.com, sudeep.holla@arm.com, gregkh@linuxfoundation.org, joro@8bytes.org, bhelgaas@google.com, mst@redhat.com, jasowang@redhat.com, jacob.jun.pan@intel.com, eric.auger@redhat.com, sebastien.boeuf@intel.com, kevin.tian@intel.com Subject: [RFC 11/13] ACPI: Add VIOT table Date: Fri, 22 Nov 2019 11:49:58 +0100 Message-Id: <20191122105000.800410-12-jean-philippe@linaro.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191122105000.800410-1-jean-philippe@linaro.org> References: <20191122105000.800410-1-jean-philippe@linaro.org> MIME-Version: 1.0 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Add support for a new ACPI table that embeds other tables describing a platform's IOMMU topology. Currently the only supported base table is IORT. The VIOT contains an IORT with additional node types, that describe a virtio-iommu. Signed-off-by: Jean-Philippe Brucker --- drivers/acpi/Kconfig | 4 ++++ drivers/acpi/Makefile | 1 + drivers/acpi/bus.c | 2 ++ drivers/acpi/tables.c | 2 +- drivers/acpi/viot.c | 44 +++++++++++++++++++++++++++++++++++++++ drivers/iommu/Kconfig | 1 + include/linux/acpi_viot.h | 20 ++++++++++++++++++ 7 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 drivers/acpi/viot.c create mode 100644 include/linux/acpi_viot.h -- 2.24.0 diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 548976c8b2b0..513a5e4d3526 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -579,6 +579,10 @@ config TPS68470_PMIC_OPREGION config ACPI_IORT bool +config ACPI_VIOT + bool + select ACPI_IORT + endif # ACPI config X86_PM_TIMER diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index 9d1792165713..6abdc6cc32c7 100644 --- a/drivers/acpi/Makefile +++ b/drivers/acpi/Makefile @@ -124,3 +124,4 @@ obj-y += dptf/ obj-$(CONFIG_ARM64) += arm64/ obj-$(CONFIG_ACPI_IORT) += iort.o +obj-$(CONFIG_ACPI_VIOT) += viot.o diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index 48bc96d45bab..6f364e0c9240 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -25,6 +25,7 @@ #include #endif #include +#include #include #include #include @@ -1246,6 +1247,7 @@ static int __init acpi_init(void) pci_mmcfg_late_init(); acpi_iort_init(); + acpi_viot_init(); acpi_scan_init(); acpi_ec_init(); acpi_debugfs_init(); diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c index 180ac4329763..9662ea5e1064 100644 --- a/drivers/acpi/tables.c +++ b/drivers/acpi/tables.c @@ -501,7 +501,7 @@ static const char * const table_sigs[] = { ACPI_SIG_WDDT, ACPI_SIG_WDRT, ACPI_SIG_DSDT, ACPI_SIG_FADT, ACPI_SIG_PSDT, ACPI_SIG_RSDT, ACPI_SIG_XSDT, ACPI_SIG_SSDT, ACPI_SIG_IORT, ACPI_SIG_NFIT, ACPI_SIG_HMAT, ACPI_SIG_PPTT, - NULL }; + ACPI_SIG_VIOT, NULL }; #define ACPI_HEADER_SIZE sizeof(struct acpi_table_header) diff --git a/drivers/acpi/viot.c b/drivers/acpi/viot.c new file mode 100644 index 000000000000..ab9a6e43ad9b --- /dev/null +++ b/drivers/acpi/viot.c @@ -0,0 +1,44 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2019 Linaro + * + * Virtual IOMMU table + */ +#define pr_fmt(fmt) "ACPI: VIOT: " fmt + +#include +#include +#include + +int __init acpi_viot_init(void) +{ + struct acpi_table_viot *viot; + struct acpi_table_header *acpi_header; + acpi_status status; + + status = acpi_get_table(ACPI_SIG_VIOT, 0, &acpi_header); + if (ACPI_FAILURE(status)) { + if (status != AE_NOT_FOUND) { + const char *msg = acpi_format_exception(status); + + pr_err("Failed to get table, %s\n", msg); + return -EINVAL; + } + + return 0; + } + + if (acpi_header->length < sizeof(*viot)) { + pr_err("VIOT table overflow, bad table!\n"); + return -EINVAL; + } + + viot = (struct acpi_table_viot *)acpi_header; + if (ACPI_COMPARE_NAMESEG(viot->base_table.signature, ACPI_SIG_IORT)) { + acpi_iort_register_table(&viot->base_table, IORT_SOURCE_VIOT); + return 0; + } + + pr_err("Unknown base table header\n"); + return -EINVAL; +} diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig index e3842eabcfdd..e6eb4f238d1a 100644 --- a/drivers/iommu/Kconfig +++ b/drivers/iommu/Kconfig @@ -480,6 +480,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/include/linux/acpi_viot.h b/include/linux/acpi_viot.h new file mode 100644 index 000000000000..6c282d5eb793 --- /dev/null +++ b/include/linux/acpi_viot.h @@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (C) 2019 Linaro + */ + +#ifndef __ACPI_VIOT_H__ +#define __ACPI_VIOT_H__ + +#ifdef CONFIG_ACPI_VIOT + +int acpi_viot_init(void); + +#else /* !CONFIG_ACPI_VIOT */ + +static inline int acpi_viot_init(void) +{} + +#endif /* !CONFIG_ACPI_VIOT */ + +#endif /* __ACPI_VIOT_H__ */