From patchwork Fri Nov 22 10:49:51 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: 180035 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp66721ilf; Fri, 22 Nov 2019 03:16:14 -0800 (PST) X-Google-Smtp-Source: APXvYqzm12+Ik8bGU6GtIlZjeGVNvK27WXGroJ3h8kSCXtSpwlIrBrlmN6L/f8Zf25AQO+MOP4ZZ X-Received: by 2002:aa7:c39a:: with SMTP id k26mr368096edq.128.1574421374727; Fri, 22 Nov 2019 03:16:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574421374; cv=none; d=google.com; s=arc-20160816; b=czj2qRRvDlR6C2ZaitWP3FZegPQBwnDu7NxTXOnEG4MCAW3fICMmni9Fs6vgR2dfnk hiLTaig0fx1fNFKq5uE2naKrqE10EmOS7sCtqzjV4SiSz6GWYD7DOr8nVq3O5tmbpRVA /nf8ypWFkhji/+55LKDUoadj4fuyNycyo7Q5RbotFM+X/2EAhQCVyfm8DNVassR3uXCI DTXYtLXSvxKVlWQKxjIXJqXA8sWZcQ+38lvs66bbS7rJfOz8wQHd0/aNxYLQdv7J3DhB 6ZRSbZJcNroruEtxKP9pE7IyNBBm29guYa4uouD3OAgF5RbYCEeBPFdV2Jg85GPMpp2s Mzsg== 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=MfTtXiG/W/rObmsyirkEQ0i6+kv30tKWKHAFlzXsK50=; b=IHpZVg5H3VI30k7f4raiyl+Oir8Z35KEuEemdlfpPLyR3ek0023iEnR9vvR46cyKSy WFkMJcahcFGnj0TY4gOcXku5Mw0+c0g2I8/ANp3ba0vuD+cjQBHN9FqPZKX6YUTba0o6 DUtzU/Sgk9ikk5F9ti4mOXxjSqwgnVOzSRXX8MrEsm6v7Y4x/fxQqB6uSsT1bilRm3vo n7XSZlafajqQijgkSZPuP+yggnVA33zejJplYC6RBKMxdPuGSYFWhSy1l6hhltT4P44Z LHfNXZDbjNREZ4nhmxxn5nNKhL2lyQcF33kv1vIybLG+AKVixPGxcapOfy8H7jKC/5sC QhXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KGaaTyS3; 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.14; Fri, 22 Nov 2019 03:16:14 -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=KGaaTyS3; 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 S1729263AbfKVKu7 (ORCPT + 7 others); Fri, 22 Nov 2019 05:50:59 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:46954 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729041AbfKVKu6 (ORCPT ); Fri, 22 Nov 2019 05:50:58 -0500 Received: by mail-wr1-f66.google.com with SMTP id z7so4622346wrl.13 for ; Fri, 22 Nov 2019 02:50:57 -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=MfTtXiG/W/rObmsyirkEQ0i6+kv30tKWKHAFlzXsK50=; b=KGaaTyS3Lc/ef+t1SZuZlTE1UsU+JnOw0CHre56ANUeiS1fG2WU5O/YFQcBx5DFQ+g C3eEzhT3EtsVVDaPXc0JJnwFtgO1xkFqrrE6GycrJ2S4YEKOcx4s42s4o+D2QSUmsenY giJa7ayJtTWwW60SOcSL7s5TyIuTMeag5BlKYTNd2Vpv5b3Ku4VoOfgVTWmpiuNgZfga 0U9jEO3Ob60MHJopefjx77FsOCYeO+1ZpoKfR2ZI8XHgbGZFlpcgyTQN/mBvo0haJZcQ 4WN5cxwZz8VzF5n+E1gDTt+EyPoR0GPG3uAOf5O3TZXJzM8psHGvEWv0Dabay2iZKY72 vmuQ== 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=MfTtXiG/W/rObmsyirkEQ0i6+kv30tKWKHAFlzXsK50=; b=aNtVIs1LNFAsZ7HuFXBGjUp1xPeMzhNBYf31torDpYNYggsMCtW8subqrAkupw0xvn iu9Nl5cmWGDNdO82txF8UowVcbUCHVK3x0QQs4NFSo3FYsh+NSiHDp3A+PSXsfd5WI+T qAFN6tvj90jIAakZnDq/oTh6Y6mxgrFxsOT+qn9OnSNSZ1I8/9yo35VQnAWYlQgJhCo6 47hdx9VSFUzBpWFUxjTH/CbZ8JWC7pX5BBUZv71VebFHdkFB9oy8X4q9no4+XIdbK7Ae t6/eu3zqpMyzgcNq7ESCjyX+S3vz/TCgf44XMAYUmkg442sgmTbMmEUxjeZmHkMp0u38 HHpA== X-Gm-Message-State: APjAAAVPNuVYWyCwxtrheOw/ir2+2QTcbhsqZtigREDD3wdGIGlwmQCY IU3BPY7FSjDaCJdvbdEF4RwfnINU+vY= X-Received: by 2002:adf:e885:: with SMTP id d5mr17167901wrm.117.1574419856320; Fri, 22 Nov 2019 02:50:56 -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.50.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Nov 2019 02:50:55 -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 04/13] ACPI/IORT: Add node categories Date: Fri, 22 Nov 2019 11:49:51 +0100 Message-Id: <20191122105000.800410-5-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 The current node filtering won't work when introducing node types greater than 63 (such as the virtio-iommu nodes). Add node_type_matches() to filter nodes by category. Signed-off-by: Jean-Philippe Brucker --- drivers/acpi/iort.c | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) -- 2.24.0 diff --git a/drivers/acpi/iort.c b/drivers/acpi/iort.c index 9c6c91e06f8f..1d43fbc0001f 100644 --- a/drivers/acpi/iort.c +++ b/drivers/acpi/iort.c @@ -18,10 +18,10 @@ #include #include -#define IORT_TYPE_MASK(type) (1 << (type)) -#define IORT_MSI_TYPE (1 << ACPI_IORT_NODE_ITS_GROUP) -#define IORT_IOMMU_TYPE ((1 << ACPI_IORT_NODE_SMMU) | \ - (1 << ACPI_IORT_NODE_SMMU_V3)) +enum iort_node_category { + IORT_MSI_TYPE, + IORT_IOMMU_TYPE, +}; struct iort_its_msi_chip { struct list_head list; @@ -38,6 +38,20 @@ struct iort_fwnode { static LIST_HEAD(iort_fwnode_list); static DEFINE_SPINLOCK(iort_fwnode_lock); +static bool iort_type_matches(u8 type, enum iort_node_category category) +{ + switch (category) { + case IORT_IOMMU_TYPE: + return type == ACPI_IORT_NODE_SMMU || + type == ACPI_IORT_NODE_SMMU_V3; + case IORT_MSI_TYPE: + return type == ACPI_IORT_NODE_ITS_GROUP; + default: + WARN_ON(1); + return false; + } +} + /** * iort_set_fwnode() - Create iort_fwnode and use it to register * iommu data in the iort_fwnode_list @@ -397,7 +411,7 @@ static int iort_get_id_mapping_index(struct acpi_iort_node *node) static struct acpi_iort_node *iort_node_map_id(struct acpi_iort_node *node, u32 id_in, u32 *id_out, - u8 type_mask) + enum iort_node_category category) { u32 id = id_in; @@ -406,7 +420,7 @@ static struct acpi_iort_node *iort_node_map_id(struct acpi_iort_node *node, struct acpi_iort_id_mapping *map; int i, index; - if (IORT_TYPE_MASK(node->type) & type_mask) { + if (iort_type_matches(node->type, category)) { if (id_out) *id_out = id; return node; @@ -458,8 +472,8 @@ static struct acpi_iort_node *iort_node_map_id(struct acpi_iort_node *node, } static struct acpi_iort_node *iort_node_map_platform_id( - struct acpi_iort_node *node, u32 *id_out, u8 type_mask, - int index) + struct acpi_iort_node *node, u32 *id_out, + enum iort_node_category category, int index) { struct acpi_iort_node *parent; u32 id; @@ -475,8 +489,8 @@ static struct acpi_iort_node *iort_node_map_platform_id( * as NC (named component) -> SMMU -> ITS. If the type is matched, * return the initial dev id and its parent pointer directly. */ - if (!(IORT_TYPE_MASK(parent->type) & type_mask)) - parent = iort_node_map_id(parent, id, id_out, type_mask); + if (!iort_type_matches(parent->type, category)) + parent = iort_node_map_id(parent, id, id_out, category); else if (id_out) *id_out = id;