From patchwork Fri Jan 8 14:52:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Philippe Brucker X-Patchwork-Id: 358984 Delivered-To: patch@linaro.org Received: by 2002:a17:906:4755:0:0:0:0 with SMTP id j21csp396441ejs; Fri, 8 Jan 2021 07:04:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJyd/jCtgYKBhHgLQxKtIj3EgTrgwosiRnRCQOz9eV2IEnkFFMVqwKBzGvk4rzJE5CnuTlRE X-Received: by 2002:a17:906:2612:: with SMTP id h18mr2923398ejc.469.1610118271582; Fri, 08 Jan 2021 07:04:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610118271; cv=none; d=google.com; s=arc-20160816; b=vkRwxPG+ala5kBqpKcDT3zxVaZmNJLLP9tE2O5XgLuTMDY8V4UOukIIvLptH689dFJ thSlIiFRiNFcyt/oB6ZBhDIc6veXSRyk9JBWEjHfIethx/lluRteysvcvuQMqKlk6/qc YqP8B4J12xiOhfg1+/N4aRGUqht/3hS/NN0yL9NT0HL/7+ebSKFAJdP0ah2I1rWJjwWX 1dzMY9ty6DWY1sU63XRGsdab4MpRchSo5st18ANqU9vJHMs5SZ6Obvrbn6fgUDxyOZZa ikPoXwyfIBt/SQY2kkckA80mg3yczUQoUBOnARInjViDFDBVg1B2PJHMa7B67FvKDpgo nK7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8RN8kwidJOzPyA7Qpg3RtqPE4flzC/x9Wg3rMV7wees=; b=o5IFdhe//fbw0uxcGpAiF0G9RZXIUZeV4/EQJkIJI866eDzalCekC7P6mFEwMShG0f O0czFU5WgQaamRSUK82BQZnlc59RRisoDuaCoQfzqdpAybbpIKmQGsDgiJRDoX30kXkS +KmchAm9QBz6apJPj7LhSoMiJZOm3ymaVk4t98ySKcslX/nkOQjgNXZolaygKtkgE5KW qf/HISL5RK6IMLsSngIpZy7W6Pqw/z8KXzoPWlTpbcJPBeGuLbOxedFu6PFDZu+wiMFR 7zbA3+zijS7zxNHzw1Mi5O/dolQocyzi7gZx3eT1Wh8bvr2BsVM9eHE9G0x6yP8rtb+Q caxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Fak3o+zy; spf=pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id cy28si3658900edb.535.2021.01.08.07.04.31; Fri, 08 Jan 2021 07:04:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Fak3o+zy; spf=pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 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 S1727475AbhAHPEa (ORCPT + 5 others); Fri, 8 Jan 2021 10:04:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727449AbhAHPEa (ORCPT ); Fri, 8 Jan 2021 10:04:30 -0500 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59123C0612B1 for ; Fri, 8 Jan 2021 07:02:47 -0800 (PST) Received: by mail-wr1-x42d.google.com with SMTP id t16so9331010wra.3 for ; Fri, 08 Jan 2021 07:02:47 -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=8RN8kwidJOzPyA7Qpg3RtqPE4flzC/x9Wg3rMV7wees=; b=Fak3o+zy1duaz7jSvXKzMTPcG81rNMh00UGR6hiDG1yuhxLSQ0h3vd3WpSV7arh3RV qJe6332Hy8nYJaxBYNayIHQD5Xkd1eCzyPT4ZxRBMRVpXG3kj2rAb7VRFuzCuNVwD5bD cXoaGCab5mUM9vZfl6eJvNpd+XcMEU7m/GaWL7uRAx5jG2eTnBEVtYCjOnifCBfK8kY1 77Tq+/+ndHgQ2WC8bjQk1SxdJe+kBe4xMcJHNbXFOaNsS2cWnI6xlGWAGtZXcYtKnW2D Wl0BJiddYbKSNl5cZ5IQpZuuSAZzPnrI0FEXytcHQScVZeC6b+prft5hhEZyOvBJ0e+t no7A== 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=8RN8kwidJOzPyA7Qpg3RtqPE4flzC/x9Wg3rMV7wees=; b=ranIwHqtqE0rfqaHDFwDLnbwTDu089IK28iS10l7SFxHnbeyikbGzJRq/6iCiwbqGz Wtx3ggfnSsKotg34Sfx2u7qYA8xk+xRTXGiyZ2RSwPB2FHvjWawClKtgcCmdHPMz2jsU neljnoki7vaJ7Yt5subtke0Ivn4FwON6QpKh6IfJMe/9rv0p3BJP2/Kx7VZfnWGrZs8s bU5iRvp/lEeJfEaLWawcNCD6M2CA+S9X8PCgbnGOGOf6Orz5R9XtcXgWJLoY/eHZfHFD mxSvExbj7zaZMmQLVVOJ3Qz4myYDBqMieURczcC+glLLqNYGN+J7EBKS2B4lJEMZ7njy 5uXA== X-Gm-Message-State: AOAM532Jbrfb+YsPA1KoRLz6IdJoY9fJvEMu5l6pX74HiduGuM5roKs/ ES9PZq6P3Yf4TXOvJXQ+rOd4FA== X-Received: by 2002:a5d:690d:: with SMTP id t13mr4077051wru.410.1610118153487; Fri, 08 Jan 2021 07:02:33 -0800 (PST) Received: from localhost.localdomain ([2001:1715:4e26:a7e0:116c:c27a:3e7f:5eaf]) by smtp.gmail.com with ESMTPSA id s13sm14258464wra.53.2021.01.08.07.02.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jan 2021 07:02:32 -0800 (PST) From: Jean-Philippe Brucker To: joro@8bytes.org, will@kernel.org Cc: lorenzo.pieralisi@arm.com, robh+dt@kernel.org, guohanjun@huawei.com, sudeep.holla@arm.com, rjw@rjwysocki.net, lenb@kernel.org, robin.murphy@arm.com, Jonathan.Cameron@huawei.com, eric.auger@redhat.com, iommu@lists.linux-foundation.org, devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-accelerators@lists.ozlabs.org, baolu.lu@linux.intel.com, vdumpa@nvidia.com, zhangfei.gao@linaro.org, shameerali.kolothum.thodi@huawei.com, vivek.gautam@arm.com, Jean-Philippe Brucker , David Woodhouse Subject: [PATCH v9 04/10] iommu/vt-d: Support IOMMU_DEV_FEAT_IOPF Date: Fri, 8 Jan 2021 15:52:12 +0100 Message-Id: <20210108145217.2254447-5-jean-philippe@linaro.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210108145217.2254447-1-jean-philippe@linaro.org> References: <20210108145217.2254447-1-jean-philippe@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Allow drivers to query and enable IOMMU_DEV_FEAT_IOPF, which amounts to checking whether PRI is enabled. Signed-off-by: Jean-Philippe Brucker --- Cc: David Woodhouse Cc: Lu Baolu --- drivers/iommu/intel/iommu.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) -- 2.29.2 diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 788119c5b021..630639c753f9 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -5263,6 +5263,8 @@ static int siov_find_pci_dvsec(struct pci_dev *pdev) static bool intel_iommu_dev_has_feat(struct device *dev, enum iommu_dev_features feat) { + struct device_domain_info *info = get_domain_info(dev); + if (feat == IOMMU_DEV_FEAT_AUX) { int ret; @@ -5277,13 +5279,13 @@ intel_iommu_dev_has_feat(struct device *dev, enum iommu_dev_features feat) return !!siov_find_pci_dvsec(to_pci_dev(dev)); } - if (feat == IOMMU_DEV_FEAT_SVA) { - struct device_domain_info *info = get_domain_info(dev); + if (feat == IOMMU_DEV_FEAT_IOPF) + return info && info->pri_supported; + if (feat == IOMMU_DEV_FEAT_SVA) return info && (info->iommu->flags & VTD_FLAG_SVM_CAPABLE) && info->pasid_supported && info->pri_supported && info->ats_supported; - } return false; } @@ -5294,6 +5296,9 @@ intel_iommu_dev_enable_feat(struct device *dev, enum iommu_dev_features feat) if (feat == IOMMU_DEV_FEAT_AUX) return intel_iommu_enable_auxd(dev); + if (feat == IOMMU_DEV_FEAT_IOPF) + return intel_iommu_dev_has_feat(dev, feat) ? 0 : -ENODEV; + if (feat == IOMMU_DEV_FEAT_SVA) { struct device_domain_info *info = get_domain_info(dev);