Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp3844470iog; Tue, 28 Jun 2022 04:06:05 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uN0ffyCSy/5R7FTH0XzYjv3CGKI1uA9S1Ki2h3KeerkAVqoAvwbSr1xGu4gSsj+prQuTq0 X-Received: by 2002:a50:fe0c:0:b0:435:510a:9f1f with SMTP id f12-20020a50fe0c000000b00435510a9f1fmr23068360edt.297.1656414365456; Tue, 28 Jun 2022 04:06:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656414365; cv=none; d=google.com; s=arc-20160816; b=LB61BoLM1I0eyg8bRv9d5Y8rXY8W/DP/GitWqwRcMgYHvIdQCQbGKJ+E8keawu89PN Wm3aCHNpHG9zEfFgvPlb3DGVxNoftlB2BLcS2rjZyiTjoHU1uNEI1aqPy4QIMZHjWGRe rksSa9PL8b7yfGX1FfXaYjOVmqnKayH29W74gilhIJ04Cz/87OnvsRyAtJQML7wEse2+ xE+QEBVzlawFacNypK6HEUGy1F6SRN0Hvgj6C2Q58/KpznNy4Z9hbEtNDVNe/MokmWkx nr/tnZDda3sTwgmr5+tLiJvE+2Yx7Ndl0osbC9HFTAMYCb9HJThuGjh0bc5syKDfXjqz d6rA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:to:content-language:subject:cc:user-agent:mime-version :date:message-id:dkim-signature; bh=OwYDNqJtj2Q3ep/ZM7ZX0NLnwuBo9SAv298jvJS+RpY=; b=vA3tMWIsD6zSAAB1bDAL7ESRSvAXUHWe8L7aICPge6+RFIxE0avmCaznoMQWBGyCQS O3TrjRwzHqpNBr4vTvl83nF50IGk2Nw/tJV0K9kj0KYWWJ+3F3+QnCpNrLyL2lsG9B8o Qcjq5uRsMKiVfqq3kFgv0TlMa+VGPsr9GF1IYWonnVOcryRGo0KRuBVwD1AwnEf7G+OF YzGboNLOasS46StylNwPSE1LoY8rK7Oyzw8iyhLoJJW4tm9k32gbJ3VK5AI23knmtuD9 IUCYSjC122u3X/JO4Gz3uYXw/bTUAsG3N/7LmeQ2opRKQkfCgMzUWu1iqg14yudP0oWU xiRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=jzsXHfGH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jg27-20020a170907971b00b0072632426373si16312644ejc.865.2022.06.28.04.05.39; Tue, 28 Jun 2022 04:06:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=jzsXHfGH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344032AbiF1LDH (ORCPT + 99 others); Tue, 28 Jun 2022 07:03:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344917AbiF1LCb (ORCPT ); Tue, 28 Jun 2022 07:02:31 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2528724F26 for ; Tue, 28 Jun 2022 04:02:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1656414151; x=1687950151; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=5uCybmEbGP1MC9vWgObj6veTZsOluHrJf+cNJQ0Uaw8=; b=jzsXHfGHPRAa4KLzGxT2YbK4lHU0JBFXaus1hPJSDruN2jYhEOnJr0Kh zaE8t7zp0rRFOF8tqyoFtxkvnS1Xj+j5oLH/4QPWBBWjO37CDljPoreuT YJSZJHCWJJR7zIm2w7BWzebBU/zH+W67otn8sT5Gy2tBS90kvJPjyqgb+ m+P9SrX0ej7L8ovgmOXNm1EtqF7BCxnC8taZYxfZ14yfHLW+VzvvU8A/o NXMlfxuS0jmCX8W2pFPhb8igI7Vk0sUHU74nyvm1vOFOEcMyLCzyHJqQf +GxLbod0pfnTDf0RqnNwrZAP/fgMvDhFgPQNcolNMTtL/NMVqmen9OAyr A==; X-IronPort-AV: E=McAfee;i="6400,9594,10391"; a="368022627" X-IronPort-AV: E=Sophos;i="5.92,227,1650956400"; d="scan'208";a="368022627" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2022 04:02:30 -0700 X-IronPort-AV: E=Sophos;i="5.92,227,1650956400"; d="scan'208";a="646867528" Received: from ltang11-mobl1.ccr.corp.intel.com (HELO [10.249.169.64]) ([10.249.169.64]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2022 04:02:27 -0700 Message-ID: <85993f97-fd8c-07b7-9843-20d1b831f2eb@linux.intel.com> Date: Tue, 28 Jun 2022 19:02:25 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Cc: baolu.lu@linux.intel.com, Eric Auger , "Liu, Yi L" , "Pan, Jacob jun" , "iommu@lists.linux-foundation.org" , "iommu@lists.linux.dev" , "linux-kernel@vger.kernel.org" , Jean-Philippe Brucker Subject: Re: [PATCH v9 10/11] iommu: Per-domain I/O page fault handling Content-Language: en-US To: "Tian, Kevin" , Joerg Roedel , Jason Gunthorpe , Christoph Hellwig , "Raj, Ashok" , Will Deacon , Robin Murphy , Jean-Philippe Brucker , "Jiang, Dave" , Vinod Koul References: <20220621144353.17547-1-baolu.lu@linux.intel.com> <20220621144353.17547-11-baolu.lu@linux.intel.com> From: Baolu Lu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022/6/28 16:39, Tian, Kevin wrote: >> static void iopf_handle_group(struct work_struct *work) >> { >> struct iopf_group *group; >> + struct iommu_domain *domain; >> struct iopf_fault *iopf, *next; >> enum iommu_page_response_code status = >> IOMMU_PAGE_RESP_SUCCESS; >> >> group = container_of(work, struct iopf_group, work); >> + domain = iommu_get_domain_for_dev_pasid(group->dev, >> + group->last_fault.fault.prm.pasid); >> + if (!domain || !domain->iopf_handler) >> + status = IOMMU_PAGE_RESP_INVALID; > Miss a comment on why no refcnt is required on domain as explained > in the commit msg. I had some comments around iommu_queue_iopf() in the previous patch. The iommu_queue_iopf() is the generic page fault handler exposed by iommu core, hence that's the right place to document this. Post it below as well: diff --git a/drivers/iommu/io-pgfault.c b/drivers/iommu/io-pgfault.c index 1df8c1dcae77..aee9e033012f 100644 --- a/drivers/iommu/io-pgfault.c +++ b/drivers/iommu/io-pgfault.c @@ -181,6 +181,13 @@ static void iopf_handle_group(struct work_struct *work) * request completes, outstanding faults will have been dealt with by the time * the PASID is freed. * + * Any valid page fault will be eventually routed to an iommu domain and the + * page fault handler installed there will get called. The users of this + * handling framework should guarantee that the iommu domain could only be + * freed after the device has stopped generating page faults (or the iommu + * hardware has been set to block the page faults) and the pending page faults + * have been flushed. + * * Return: 0 on success and <0 on error. */ int iommu_queue_iopf(struct iommu_fault *fault, void *cookie) Best regards, baolu