From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AA1F3C3A5A9 for ; Mon, 4 May 2020 16:25:54 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5F15B20707 for ; Mon, 4 May 2020 16:25:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="NPOSWeTN" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5F15B20707 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id EC99A8E005E; Mon, 4 May 2020 12:25:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E52768E0058; Mon, 4 May 2020 12:25:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D1AFC8E005E; Mon, 4 May 2020 12:25:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0154.hostedemail.com [216.40.44.154]) by kanga.kvack.org (Postfix) with ESMTP id B6DFE8E0058 for ; Mon, 4 May 2020 12:25:53 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 82CD940EE for ; Mon, 4 May 2020 16:25:53 +0000 (UTC) X-FDA: 76779562986.28.bread23_507ef4647b20a X-HE-Tag: bread23_507ef4647b20a X-Filterd-Recvd-Size: 6176 Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by imf40.hostedemail.com (Postfix) with ESMTP for ; Mon, 4 May 2020 16:25:52 +0000 (UTC) Received: by mail-wr1-f68.google.com with SMTP id s8so11403204wrt.9 for ; Mon, 04 May 2020 09:25:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=GL2JHfWb2mPYeSgeIH5WeIgVbATF3Ra0zLGdb9HxWZQ=; b=NPOSWeTNC3Un3eskvozXKMxNnsJ6r9fc/sgBE1d6gnYLdALaK8wjIX/j58IvqfxFmC cJ7U5u96OPGUoehpQYLz0ggsicjiGrgSLC1dqZkfAjTE0uE8MD2K1WFx/8y4Pzbpbd5R z1XLioC0bjQNb3+Z6msYsAptNDoFZ4CqIP/741UwHR5xz+ADrwIsStOoAMCNc23vCn0O CkGZuVDFZP0sdQAJ3dIDW/VXYBbjPmqlBAyRLYt21m9Bo4iyUVDnyUPUU+K5e2tYxPpF W5ts90uOmnfyFrIy99D6BSUc9rUBir+ZREIxahMT07HpDKv5DXmykWAMqamGEhd1zCAa cW9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=GL2JHfWb2mPYeSgeIH5WeIgVbATF3Ra0zLGdb9HxWZQ=; b=jPPeyHasjMC3AG1ZrnmWICI1AJof/XqIEA+ZHeSgsnkYSIAScgXqOg5WV8oSVyJDFy W9pwidyUDU6JcvNLlPB80BVD9RQstY4MVDLk9X3EGD8BGSlIMXYY//k8kuxH0hnFwTMg YGX4qae26PfHeedEpF4jCD5e1uMLxM66pFUXXTNR3fpTAr4OBk0sTPAtaLGyKtoX8Q06 QwMrunHhEcVgBWKZfDTFflssZluonesMGrRlFjfEwHP3AZdrx4GKILHuByvM9vhxbK3a jV3CDjH1U6m3warWXie4NysOLSbM6PDmCtwHX0T1+SCYabuR6HljfdoKRkgTxc8q2Yba BhSg== X-Gm-Message-State: AGi0PuYu2gGw/Jrcr9OlJssELRe1PbCAnuxZi94XRCaaLRAdKZwfNU3Y ZLxhsVhHfEJ7BbKFsTKUbKRy8g== X-Google-Smtp-Source: APiQypJewC2A5eJu+LlIEsZxNgowtLfUPSFwzAN1NtAObzTj2fsi/+uiw7oQbS2F9/ABw1GE+6Cvxw== X-Received: by 2002:adf:f606:: with SMTP id t6mr7882808wrp.321.1588609551965; Mon, 04 May 2020 09:25:51 -0700 (PDT) Received: from myrica ([2001:171b:226e:c200:c43b:ef78:d083:b355]) by smtp.gmail.com with ESMTPSA id r15sm6980383wrq.93.2020.05.04.09.25.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 May 2020 09:25:51 -0700 (PDT) Date: Mon, 4 May 2020 18:25:41 +0200 From: Jean-Philippe Brucker To: Lu Baolu Cc: iommu@lists.linux-foundation.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, linux-mm@kvack.org, joro@8bytes.org, catalin.marinas@arm.com, will@kernel.org, robin.murphy@arm.com, kevin.tian@intel.com, Jonathan.Cameron@huawei.com, jacob.jun.pan@linux.intel.com, christian.koenig@amd.com, felix.kuehling@amd.com, zhangfei.gao@linaro.org, jgg@ziepe.ca, xuzaibo@huawei.com, fenghua.yu@intel.com, hch@infradead.org Subject: Re: [PATCH v6 05/25] iommu/iopf: Handle mm faults Message-ID: <20200504162541.GG170104@myrica> References: <20200430143424.2787566-1-jean-philippe@linaro.org> <20200430143424.2787566-6-jean-philippe@linaro.org> <9fc0e4cc-1242-bf96-5328-cc9039dcc9b6@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9fc0e4cc-1242-bf96-5328-cc9039dcc9b6@linux.intel.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Sun, May 03, 2020 at 01:54:36PM +0800, Lu Baolu wrote: > On 2020/4/30 22:34, Jean-Philippe Brucker wrote: > > When a recoverable page fault is handled by the fault workqueue, find the > > associated mm and call handle_mm_fault. > > > > Signed-off-by: Jean-Philippe Brucker > > --- > > v5->v6: select CONFIG_IOMMU_SVA > > --- > > drivers/iommu/Kconfig | 1 + > > drivers/iommu/io-pgfault.c | 79 +++++++++++++++++++++++++++++++++++++- > > 2 files changed, 78 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig > > index 4f33e489f0726..1e64ee6592e16 100644 > > --- a/drivers/iommu/Kconfig > > +++ b/drivers/iommu/Kconfig > > @@ -109,6 +109,7 @@ config IOMMU_SVA > > config IOMMU_PAGE_FAULT > > bool > > + select IOMMU_SVA > > It would be better to move this to the previous patch. > [...] > > @@ -104,6 +156,29 @@ static void iopf_handle_group(struct work_struct *work) > > * > > * Add a fault to the device workqueue, to be handled by mm. > > * > > + * This module doesn't handle PCI PASID Stop Marker; IOMMU drivers must discard > > + * them before reporting faults. A PASID Stop Marker (LRW = 0b100) doesn't > > + * expect a response. It may be generated when disabling a PASID (issuing a > > + * PASID stop request) by some PCI devices. > > + * > > + * The PASID stop request is issued by the device driver before unbind(). Once > > + * it completes, no page request is generated for this PASID anymore and > > + * outstanding ones have been pushed to the IOMMU (as per PCIe 4.0r1.0 - 6.20.1 > > + * and 10.4.1.2 - Managing PASID TLP Prefix Usage). Some PCI devices will wait > > + * for all outstanding page requests to come back with a response before > > + * completing the PASID stop request. Others do not wait for page responses, and > > + * instead issue this Stop Marker that tells us when the PASID can be > > + * reallocated. > > + * > > + * It is safe to discard the Stop Marker because it is an optimization. > > + * a. Page requests, which are posted requests, have been flushed to the IOMMU > > + * when the stop request completes. > > + * b. We flush all fault queues on unbind() before freeing the PASID. > > + * > > + * So even though the Stop Marker might be issued by the device *after* the stop > > + * request completes, outstanding faults will have been dealt with by the time > > + * we free the PASID. > > + * > > * Return: 0 on success and <0 on error. > > */ > > int iommu_queue_iopf(struct iommu_fault *fault, void *cookie) > > > > The same for the comments. I think I'll squash both patches, probably doesn't make it harder to review. Thanks, Jean