Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2227188ybi; Sun, 9 Jun 2019 06:45:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqyYuhaGSVzbVARpvDcGDhjdBoFb0B/OqfKWNDT2vY+SaP5x9a9VU3dCIOiOKVJWd0iVDwOK X-Received: by 2002:a17:90a:214e:: with SMTP id a72mr16723077pje.0.1560087938062; Sun, 09 Jun 2019 06:45:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560087938; cv=none; d=google.com; s=arc-20160816; b=zjKXZoINfYSpjQk6Vl3VqmsYQxkdeqW5AVft5+d5IUnQYk/u+T2WBxfgvn+5NINxUL rZZh+X3U5ZQsjD1o3zMGBFLu0uxvIo8kGZrxh+j9kqNwQrS69Pzjvbk2Mcp+roqK1Z62 P7DNp6Cp6xGW5XG/BJpz+liT++DmnJ+oJIDq/FthGb40u943LekWB7kKixHvVwp/1fSW /Kl6wYCIrqT9jJHYI5mjZDoP1rIl91dEpdoYr+XkmA59SZDLU6ifYKO3e8WBSXTeMeRt un86I2hJwaQZ+gutJgU4eeCmd345dHlhwGh3/jZiXNAgd9Fy2E5/az0FuO8ZUnC8KsBi JW+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=TIOJ3dGO5vGMfgVnhznAL1gHTdsMqX/GvRfPp+QXpUA=; b=rANWBJ37k2b22IHm3CeBvNt3cYtu43xVpaT8WSXWYn4UYMEC3tX7kLA2TrdCm592gS gY42TfR+2nQnKVAY2PaeETwY838XrF11GAqIlidzyv7010U3guQ5j4jrs7tGyvkXH+k9 Hs0A5EPL6pOVibEcs7FG+hxDAmE4DEFZQdlNF8/PCOPZyzW1A8MZbH3wV4yzGKjbJhAI ctYuY3OKc6yzH+8tA0sX+3g9rFPmIo0iLQJCUuDFtViR8tw8uUXhbQhqcaYF36+QL/tX J+EwxE+TkhjuH8GzDgQ8CSskXPxJjPAk+21A8U5S+o4XN2GuvZ5m6V3V2i116CqFmkQd V+pg== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e39si7526216plg.103.2019.06.09.06.45.22; Sun, 09 Jun 2019 06:45:38 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728905AbfFINlS (ORCPT + 99 others); Sun, 9 Jun 2019 09:41:18 -0400 Received: from mga11.intel.com ([192.55.52.93]:32101 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727587AbfFINlR (ORCPT ); Sun, 9 Jun 2019 09:41:17 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Jun 2019 06:41:16 -0700 X-ExtLoop1: 1 Received: from jacob-builder.jf.intel.com ([10.7.199.155]) by orsmga003.jf.intel.com with ESMTP; 09 Jun 2019 06:41:16 -0700 From: Jacob Pan To: iommu@lists.linux-foundation.org, LKML , Joerg Roedel , David Woodhouse , Eric Auger , Alex Williamson , Jean-Philippe Brucker Cc: "Yi Liu" , "Tian, Kevin" , Raj Ashok , "Christoph Hellwig" , "Lu Baolu" , Andriy Shevchenko , Jacob Pan Subject: [PATCH v4 05/22] iommu: Add a timeout parameter for PRQ response Date: Sun, 9 Jun 2019 06:44:05 -0700 Message-Id: <1560087862-57608-6-git-send-email-jacob.jun.pan@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1560087862-57608-1-git-send-email-jacob.jun.pan@linux.intel.com> References: <1560087862-57608-1-git-send-email-jacob.jun.pan@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When an IO page request is processed outside IOMMU subsystem, response can be delayed or lost. Add a tunable setup parameter such that user can choose the timeout for IOMMU to track pending page requests. This timeout mechanism is a basic safety net which can be implemented in conjunction with credit based or device level page response exception handling. Signed-off-by: Jacob Pan --- Documentation/admin-guide/kernel-parameters.txt | 8 +++++++ drivers/iommu/iommu.c | 29 +++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 138f666..b43f089 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -1813,6 +1813,14 @@ 1 - Bypass the IOMMU for DMA. unset - Use value of CONFIG_IOMMU_DEFAULT_PASSTHROUGH. + iommu.prq_timeout= + Timeout in seconds to wait for page response + of a pending page request. + Format: + Default: 10 + 0 - no timeout tracking + 1 to 100 - allowed range + io7= [HW] IO7 for Marvel based alpha systems See comment before marvel_specify_io7 in arch/alpha/kernel/core_marvel.c. diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 13b301c..64e87d5 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -45,6 +45,19 @@ static unsigned int iommu_def_domain_type = IOMMU_DOMAIN_DMA; #endif static bool iommu_dma_strict __read_mostly = true; +/* + * Timeout to wait for page response of a pending page request. This is + * intended as a basic safty net in case a pending page request is not + * responded for an exceptionally long time. Device may also implement + * its own protection mechanism against this exception. + * Units are in jiffies with a range between 1 - 100 seconds equivalent. + * Default to 10 seconds. + * Setting 0 means no timeout tracking. + */ +#define IOMMU_PAGE_RESPONSE_MAX_TIMEOUT (HZ * 100) +#define IOMMU_PAGE_RESPONSE_DEF_TIMEOUT (HZ * 10) +static unsigned long prq_timeout = IOMMU_PAGE_RESPONSE_DEF_TIMEOUT; + struct iommu_group { struct kobject kobj; struct kobject *devices_kobj; @@ -157,6 +170,22 @@ static int __init iommu_dma_setup(char *str) } early_param("iommu.strict", iommu_dma_setup); +static int __init iommu_set_prq_timeout(char *str) +{ + unsigned long timeout; + + if (!str) + return -EINVAL; + timeout = simple_strtoul(str, NULL, 0); + timeout = timeout * HZ; + if (timeout > IOMMU_PAGE_RESPONSE_MAX_TIMEOUT) + return -EINVAL; + prq_timeout = timeout; + + return 0; +} +early_param("iommu.prq_timeout", iommu_set_prq_timeout); + static ssize_t iommu_group_attr_show(struct kobject *kobj, struct attribute *__attr, char *buf) { -- 2.7.4