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=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no 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 A82FEC388F9 for ; Wed, 11 Nov 2020 13:58:12 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0535C20756 for ; Wed, 11 Nov 2020 13:58:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="PX5YSlcx" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0535C20756 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 654956B007B; Wed, 11 Nov 2020 08:58:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 62B8B6B007D; Wed, 11 Nov 2020 08:58:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4CC0F6B007E; Wed, 11 Nov 2020 08:58:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0143.hostedemail.com [216.40.44.143]) by kanga.kvack.org (Postfix) with ESMTP id 1D23D6B007B for ; Wed, 11 Nov 2020 08:58:11 -0500 (EST) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id B961E8249980 for ; Wed, 11 Nov 2020 13:58:10 +0000 (UTC) X-FDA: 77472291540.10.scent81_370caad272fe Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin10.hostedemail.com (Postfix) with ESMTP id 9866116A06B for ; Wed, 11 Nov 2020 13:58:10 +0000 (UTC) X-HE-Tag: scent81_370caad272fe X-Filterd-Recvd-Size: 5945 Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by imf44.hostedemail.com (Postfix) with ESMTP for ; Wed, 11 Nov 2020 13:58:10 +0000 (UTC) Received: by mail-wr1-f67.google.com with SMTP id r17so2649725wrw.1 for ; Wed, 11 Nov 2020 05:58:10 -0800 (PST) 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=Bg58Nuvlkki+FL9k9rnhWH9yWYXQkDaY8dFISymQNf4=; b=PX5YSlcxcGmSZg8r/sp2D0I5JTHOJyKFcuVZxLO1fiouCfjYWFBADilQDWAd0Zg9Sd HIfJ/J4cOjkRzfvjnj1WMh/LKncrPEtfWeva76W8jYJ5GBV9QsvF6eKzhO5TLf58/h3Y 9SHRXS3ggYLKFZJgaiWZUr0gnAEq+xCsESwyC2lrlYNo+T1yDCho+DSiFZax7SLWk8Kc qS+/kEN2EY8zDLbcFnyYa3Hzli6iLHqYJh3b8/FneQUgK84gqG6h1k7T94Ji4UfDLetv p3Xs14pIjTNueMnPgMl2lVXzAS9+JjhDnXFy1NouXt6C7VZY0sEXk+8MnG75YWkKX/C+ MxRQ== 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=Bg58Nuvlkki+FL9k9rnhWH9yWYXQkDaY8dFISymQNf4=; b=RQhZ064HA/owGi4Yl9a+Sxn4Vw6XklXn0EaWYSOaIgH+U7GH1e+zrExMXHhyZm9rKX T7uR2s/L0nTMSHcjdp3BnOElabhIvyf1Dw21m4i2jw8hWvBGIQ/jAsgep4R3tPoeDY8y p3OxCEnsUaRskFdW/YWrpuOHkaWIT2RSQRFzPpwJ0IkyV4IpKSUFAHCaXRktNv2TUmE8 kHMAl38nciRgqIj742gYOUlesHNmt5cIM9G+73C/8Rql6boOgoE0uoyILHom7M/3uXsd RvKwZUMfDEpLEwcGd/ap8VPwsoyKt+ww7wNkxcY995eolJCboVTwg0Vs7WU2n0Jt0Uf6 9M4Q== X-Gm-Message-State: AOAM53330x+mqDFkZFxI/jG/RPiN+Ne/x6kxd+iRxc6dSIRBrG2W2iGH /p3SXi2hnJPXkEHteWy/R90D4A== X-Google-Smtp-Source: ABdhPJw6IjBDWuhoEyhqDsHpEgNzVVOxVUrrMBm3b8SRWwCRsVl0IlzCByu/s34c5pnWmTrWJJOQPA== X-Received: by 2002:adf:f9cb:: with SMTP id w11mr26381611wrr.1.1605103089202; Wed, 11 Nov 2020 05:58:09 -0800 (PST) Received: from myrica ([2001:1715:4e26:a7e0:116c:c27a:3e7f:5eaf]) by smtp.gmail.com with ESMTPSA id b8sm2551407wmj.9.2020.11.11.05.58.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Nov 2020 05:58:08 -0800 (PST) Date: Wed, 11 Nov 2020 14:57:50 +0100 From: Jean-Philippe Brucker To: Xiang Zheng 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, fenghua.yu@intel.com, kevin.tian@intel.com, jacob.jun.pan@linux.intel.com, jgg@ziepe.ca, catalin.marinas@arm.com, joro@8bytes.org, robin.murphy@arm.com, hch@infradead.org, zhangfei.gao@linaro.org, Jonathan.Cameron@huawei.com, felix.kuehling@amd.com, xuzaibo@huawei.com, will@kernel.org, christian.koenig@amd.com, baolu.lu@linux.intel.com, Wang Haibin Subject: Re: [PATCH v7 04/24] iommu: Add a page fault handler Message-ID: <20201111135750.GA2617489@myrica> References: <20200519175502.2504091-1-jean-philippe@linaro.org> <20200519175502.2504091-5-jean-philippe@linaro.org> <422e84da-9ccb-5452-8cbf-f472d2ad16b5@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <422e84da-9ccb-5452-8cbf-f472d2ad16b5@huawei.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: Hi Xiang, Thank you for reviewing this. I forgot to send a reply, sorry for the delay. On Fri, May 29, 2020 at 05:18:27PM +0800, Xiang Zheng wrote: > Hi, > > On 2020/5/20 1:54, Jean-Philippe Brucker wrote: > > Some systems allow devices to handle I/O Page Faults in the core mm. For > > example systems implementing the PCIe PRI extension or Arm SMMU stall > > model. Infrastructure for reporting these recoverable page faults was > > added to the IOMMU core by commit 0c830e6b3282 ("iommu: Introduce device > > fault report API"). Add a page fault handler for host SVA. > > > > IOMMU driver can now instantiate several fault workqueues and link them > > to IOPF-capable devices. Drivers can choose between a single global > > workqueue, one per IOMMU device, one per low-level fault queue, one per > > domain, etc. > > > > When it receives a fault event, supposedly in an IRQ handler, the IOMMU > > driver reports the fault using iommu_report_device_fault(), which calls > > the registered handler. The page fault handler then calls the mm fault > > handler, and reports either success or failure with iommu_page_response(). > > When the handler succeeded, the IOMMU retries the access. > > > > The iopf_param pointer could be embedded into iommu_fault_param. But > > putting iopf_param into the iommu_param structure allows us not to care > > about ordering between calls to iopf_queue_add_device() and > > iommu_register_device_fault_handler(). > > > > Signed-off-by: Jean-Philippe Brucker [...] > > +/** > > + * iopf_queue_free - Free IOPF queue > > + * @queue: queue to free > > + * > > + * Counterpart to iopf_queue_alloc(). The driver must not be queuing faults or > > + * adding/removing devices on this queue anymore. > > + */ > > +void iopf_queue_free(struct iopf_queue *queue) > > +{ > > + struct iopf_device_param *iopf_param, *next; > > + > > + if (!queue) > > + return; > > + > > + list_for_each_entry_safe(iopf_param, next, &queue->devices, queue_list) > > + iopf_queue_remove_device(queue, iopf_param->dev); > > + > > + destroy_workqueue(queue->wq); > > Do we need to free iopf_group(s) here in case the work queue of the group(s) are not > scheduled yet? If that occurs, we might leak memory here. Partial groups are freed by iopf_queue_remove_device(), and all other groups are freed when destroy_workqueue() executes the remaining work. Thanks, Jean