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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,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 E2A80C5517A for ; Wed, 11 Nov 2020 13:58:41 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 67E2F207BB for ; Wed, 11 Nov 2020 13:58:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="C/FAUwdX"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="PX5YSlcx" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 67E2F207BB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=+vb8O9USnY/Q071tRN0monSpIOSzFcTuwXWDcfSEd18=; b=C/FAUwdXF4UG78oKCEbwJmwcE g2esuqVnywMHRES+ZFekczyvzVdGT4xqsJqwIZes+myoI297qRYQUFoPbfmdCv4MupvmVdK6KDJ6Q cSzbp7ht2USc7Wm75FNi5hlJPpUYYKrvUC7BJXHdmHj2FzCK5DhGi2B7f9I3wG/4KfU3KRjkfle8e 8KyVO4VJn1XDridTTq+x8uH9+mv3KbJa2IBpE+52P02oqprgqCqvLS3Y+d0N6CaXXbPCfpCct8Lxe WWyAwOG7Ad8xrYDA2iMLLbsfeqkqogYQbW/GRiO+fgwmGu1eW/7UnEmzGjE0upzl/XxaCc2ceqQPE UdtKG5TZQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kcqdc-00020T-0y; Wed, 11 Nov 2020 13:58:16 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kcqdW-0001y9-Ax for linux-arm-kernel@lists.infradead.org; Wed, 11 Nov 2020 13:58:11 +0000 Received: by mail-wr1-x442.google.com with SMTP id k2so2637837wrx.2 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=RO2JbP3i3oc0ff+/3Wd03k2cuqTJsMXk1rJeoZVMLSxvmXDekxw1gPDlp1nG+lpw25 zdXpYQXAURcF4dkqvhkfAdSi0IF+Ug1mb9H6GibXbvEk3FE8KIlOfoCQFzjxbKgEkcFC Iv/s8/P+dxMMllm+HZKL9kYEq4Ga9JXvxQ2uhHVtaPcCTmmCL/HKzKlbfu0ZZMLMlrIs jLMadhDcm/zYludeklfID38GMKp3to8eiD7HrQsl2XFCDUECIQw7vbQsfkma/g7ez/Av +daOCU5TebFo2cdCKXGFuzicDf8QHEQ9tVvVKqT8gQyvZtfzmYgK36py1nzC7oYGGAG2 z/qg== X-Gm-Message-State: AOAM531NkOD2n/7WPCWgDouDTWdR0aHvZda1W9YpwBQvnsy8ld+BWpIr h7xrDNuG2dRZFQDa5ShNPSSDjQ== 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 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-Disposition: inline In-Reply-To: <422e84da-9ccb-5452-8cbf-f472d2ad16b5@huawei.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201111_085810_466959_716E093B X-CRM114-Status: GOOD ( 22.34 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, kevin.tian@intel.com, jacob.jun.pan@linux.intel.com, will@kernel.org, fenghua.yu@intel.com, jgg@ziepe.ca, linux-pci@vger.kernel.org, joro@8bytes.org, Jonathan.Cameron@huawei.com, christian.koenig@amd.com, hch@infradead.org, linux-mm@kvack.org, iommu@lists.linux-foundation.org, Wang Haibin , catalin.marinas@arm.com, zhangfei.gao@linaro.org, xuzaibo@huawei.com, robin.murphy@arm.com, felix.kuehling@amd.com, linux-arm-kernel@lists.infradead.org, baolu.lu@linux.intel.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel