Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3285277ybb; Tue, 31 Mar 2020 02:06:04 -0700 (PDT) X-Google-Smtp-Source: ADFU+vux+ESfsnsUDIbMUmmjOpkpVKCALZWZ5eO3WNuiPa31Ylu50Gvebz5jAUdhk0O7SfGT5E/+ X-Received: by 2002:aca:c28b:: with SMTP id s133mr1452820oif.36.1585645564697; Tue, 31 Mar 2020 02:06:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585645564; cv=none; d=google.com; s=arc-20160816; b=vbx7600ZTxB3ALZoZxwsJLFGMbTv20GdOqJLfPb/gT+C34JFyzWCa5aNShENAIIqVV 6aHGfUJMFPf/LMDzY36Uqy5hH2glhBFC2A/ewFH9AmPys2dh+WWKFr951UispSD2DmXi osRsP9Ntipa3YpBlW7G3VhaE0ctO1rzFrUd0QrPLplu4kSt1K9IiR8OK/7ld/6CZCiq5 Idvo0q+QkbSd/jyMlTm0EReia63MroEPjE8R7LOmwZYfbtkCaku/cP7vpTrOy3yBPm65 yvuBtwNxMLmCmd1UqUQfI9lyypZxwoumQN8gqEYAgoPedpYBEYP8YNFc+K6Xfb4XoVl2 cFFQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=HWfaW9jvKOlrMQwCWvQndQg39tQVRKRvJZodkKSq9Iw=; b=YoPK2YRikMOIvN20PmOneGZU5BtTBeEujzgLQt9FjVHKrtErDSUhrHYbVB/4QhZKBW tQLhz42AHv2I+xoKOwJvrWJvKHOZYt7eFvxTJY3kw9mTgq1Li76RmEeuehxDZ+i7zPpt aVfI5OcwwnRMy/R2kqsMWa7HRMOmYOYiAVKFzMZxNF7kaBJ9yQKqE7D9XzPCktIFjtvu gDomRmEbmDbVPRk1C3Hg5c592nDOBLF1NPSXh3AtokhM8KTs6HG7BdxKGeF2WdAfghr9 vvVyRqewMvVVVo5RJAn9YC3QeMov8vR+F1YdoWWegyUyn6yrcpStBlMpDcoqvj1ly8jR P0MQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kTTb6BUl; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d21si7311332oof.2.2020.03.31.02.05.52; Tue, 31 Mar 2020 02:06:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=@kernel.org header.s=default header.b=kTTb6BUl; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730882AbgCaJFZ (ORCPT + 99 others); Tue, 31 Mar 2020 05:05:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:46414 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730799AbgCaJFY (ORCPT ); Tue, 31 Mar 2020 05:05:24 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DB93B20787; Tue, 31 Mar 2020 09:05:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585645524; bh=TXg//bs+/ZskiFsmA2fT4UWOVj10ZmFUdDtwwCgJwgg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kTTb6BUlXAqm5kAkyE/fyIy2vHyw+glFDi5t7FZv8Ih73nLvqR9U4rAjVOl5pwkP3 RrZzoxhbnKj7RSBpTceeKwMa+5QsSZwgBnfdz7vyimSc+cLjoe2t1JYyA6CatqLy9L efhXIZxTyV7aYdWglvD0kGYgvEhyagN57w5hZG0E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Megha Dey , Lu Baolu , Joerg Roedel , Sasha Levin Subject: [PATCH 5.5 080/170] iommu/vt-d: Populate debugfs if IOMMUs are detected Date: Tue, 31 Mar 2020 10:58:14 +0200 Message-Id: <20200331085432.821179266@linuxfoundation.org> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200331085423.990189598@linuxfoundation.org> References: <20200331085423.990189598@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Megha Dey [ Upstream commit 1da8347d8505c137fb07ff06bbcd3f2bf37409bc ] Currently, the intel iommu debugfs directory(/sys/kernel/debug/iommu/intel) gets populated only when DMA remapping is enabled (dmar_disabled = 0) irrespective of whether interrupt remapping is enabled or not. Instead, populate the intel iommu debugfs directory if any IOMMUs are detected. Cc: Dan Carpenter Fixes: ee2636b8670b1 ("iommu/vt-d: Enable base Intel IOMMU debugfs support") Signed-off-by: Megha Dey Signed-off-by: Lu Baolu Signed-off-by: Joerg Roedel Signed-off-by: Sasha Levin --- drivers/iommu/intel-iommu-debugfs.c | 11 ++++++++++- drivers/iommu/intel-iommu.c | 4 +++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/intel-iommu-debugfs.c b/drivers/iommu/intel-iommu-debugfs.c index 80378c10dd77a..bdf095e9dbe03 100644 --- a/drivers/iommu/intel-iommu-debugfs.c +++ b/drivers/iommu/intel-iommu-debugfs.c @@ -281,9 +281,16 @@ static int dmar_translation_struct_show(struct seq_file *m, void *unused) { struct dmar_drhd_unit *drhd; struct intel_iommu *iommu; + u32 sts; rcu_read_lock(); for_each_active_iommu(iommu, drhd) { + sts = dmar_readl(iommu->reg + DMAR_GSTS_REG); + if (!(sts & DMA_GSTS_TES)) { + seq_printf(m, "DMA Remapping is not enabled on %s\n", + iommu->name); + continue; + } root_tbl_walk(m, iommu); seq_putc(m, '\n'); } @@ -353,6 +360,7 @@ static int ir_translation_struct_show(struct seq_file *m, void *unused) struct dmar_drhd_unit *drhd; struct intel_iommu *iommu; u64 irta; + u32 sts; rcu_read_lock(); for_each_active_iommu(iommu, drhd) { @@ -362,7 +370,8 @@ static int ir_translation_struct_show(struct seq_file *m, void *unused) seq_printf(m, "Remapped Interrupt supported on IOMMU: %s\n", iommu->name); - if (iommu->ir_table) { + sts = dmar_readl(iommu->reg + DMAR_GSTS_REG); + if (iommu->ir_table && (sts & DMA_GSTS_IRES)) { irta = virt_to_phys(iommu->ir_table->base); seq_printf(m, " IR table address:%llx\n", irta); ir_tbl_remap_entry_show(m, iommu); diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index 10176d8ea3e65..7f31775e9b554 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c @@ -5005,6 +5005,9 @@ int __init intel_iommu_init(void) down_write(&dmar_global_lock); + if (!no_iommu) + intel_iommu_debugfs_init(); + if (no_iommu || dmar_disabled) { /* * We exit the function here to ensure IOMMU's remapping and @@ -5100,7 +5103,6 @@ int __init intel_iommu_init(void) pr_info("Intel(R) Virtualization Technology for Directed I/O\n"); intel_iommu_enabled = 1; - intel_iommu_debugfs_init(); return 0; -- 2.20.1