Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5045565rdb; Tue, 12 Dec 2023 18:09:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IEw33FqzGR76yqnvdvFPTs+DYOLfFeYeVExkmWD3nPl7NZtfka0XU4isuuukMQfm+55y9g4 X-Received: by 2002:a17:902:da8b:b0:1d0:6ffd:e2b6 with SMTP id j11-20020a170902da8b00b001d06ffde2b6mr7611207plx.80.1702433392706; Tue, 12 Dec 2023 18:09:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702433392; cv=none; d=google.com; s=arc-20160816; b=cIL/zvVLPT202NqmvykYxXQomzADIh8AQkgIZ0VZwyDlqW8NCRa+PDt+mHEkFAHBJp xU/ji/STgfeKO2F4ImLMhTgDCKxqcb+8VsY3/gbXw6zwlAKkB/GZ+3GKl/FlhXESlYxQ gv8irHfxPufFODXW3m1eoXSW79g8JVVVxDecth030qxNBy9ZimAArtwGmN0JtbZdDv7/ 3vfA6SdSUwuw/aeIf3tbFaedpSlYYjn2P4Lc6XswDIQkLdjgkxsWLDyUrIJiv2SMzkdE 2J+3eHFqDU4Pd3lT+sGNure6oeTCge4V57FEZ/7XshGbgjx72eiUFWmNrMmgR+IBwSS8 Qf1Q== 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=RXAOqmANxhZFc79Isye/+qlA5QEAoCxdBQzxvXfhBZs=; fh=Ty013/s3USjgaq0vt1KcS0o922FZrcN+/Crpr5TAzGM=; b=nUeOHhaZseDNznT5qXPBSrgiwFPT7dvCv+6Sb/FZG6MNzN30XyTQQ2QwpiZ7+hqimJ gbeogYmMfGxSvnAtWH+s2NI45PaNCOKm5N/m4seZcdOqg45iZwB2GzqtsyCO73GeTmoK Sx8c7VOPeu5dq/iEsyo2ToRl1eukOrlgZAV04BM2sNPpiXXk9Wehjc+E65qq1lWDNQ3B f2ldLYo3Lh33R+ETNXUH/G7DQ4dZurqxw8isTWuq0razXNau63JZ6zpPdHIMcXmrHQfd YWY8qoZWyWBYbTBbIZZlSrcbp+slRzICrm/GIhjIf31lotIL5z5K8FXWlRFhIem9dtB6 dD0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=gwm6+En1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id ei20-20020a17090ae55400b0028ada09a765si750157pjb.161.2023.12.12.18.09.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 18:09:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=gwm6+En1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id E17E480B1339; Tue, 12 Dec 2023 18:09:49 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378226AbjLMCJ2 (ORCPT + 99 others); Tue, 12 Dec 2023 21:09:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232721AbjLMCJ1 (ORCPT ); Tue, 12 Dec 2023 21:09:27 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7179AA; Tue, 12 Dec 2023 18:09:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1702433373; x=1733969373; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=MNAA322q9vhdRNtkpV3N3RglXmc+rKBeo/qJoA/OlJw=; b=gwm6+En17XvjuXVfFjRkrYbSBNOcYT6xFYUMRpxwqpXF8gRFh+B1cjmc Qs4ksM2Pw+ji66HNoKGc/Tsi1KhkkRU5cXjHMLCMwMeyteuqe/3rXGtV1 InAth1EVw3M+oLx/0PJom1s6YCMpUmsfu+qJlBF293KIKQoThzIwbw7Z9 DHpDNmgF0PDyGOmvr3Zg5bBc8ZSxgp2ErDo3VEu9xxX0KSYKm3Shn0Tic OXqfAXWX075EUejGKoxU0WLcbpEB7hSBsEhq62jxu/0Ixm2MVnXYkK7yV 0DBeQK28gVqerRycOurhw+YhPdLkkxCXV1tEBsdWCt9PoXZs+OAqDCegx Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10922"; a="392078357" X-IronPort-AV: E=Sophos;i="6.04,271,1695711600"; d="scan'208";a="392078357" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Dec 2023 18:09:33 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.04,271,1695711600"; d="scan'208";a="21756369" Received: from allen-box.sh.intel.com (HELO [10.239.159.127]) ([10.239.159.127]) by orviesa001.jf.intel.com with ESMTP; 12 Dec 2023 18:09:29 -0800 Message-ID: <276597d0-9947-44f1-a6b9-16d245394b22@linux.intel.com> Date: Wed, 13 Dec 2023 10:04:49 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Cc: baolu.lu@linux.intel.com, Kevin Tian , Joerg Roedel , Will Deacon , Robin Murphy , Jean-Philippe Brucker , Nicolin Chen , Yi Liu , Jacob Pan , iommu@lists.linux.dev, linux-kselftest@vger.kernel.org, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 3/6] iommufd: Initializing and releasing IO page fault data Content-Language: en-US To: Jason Gunthorpe , Joel Granados References: <20231026024930.382898-1-baolu.lu@linux.intel.com> <20231026024930.382898-4-baolu.lu@linux.intel.com> <20231212131008.k6s5xwjgolp6geps@localhost> <20231212141208.GA3013885@ziepe.ca> From: Baolu Lu In-Reply-To: <20231212141208.GA3013885@ziepe.ca> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 12 Dec 2023 18:09:50 -0800 (PST) On 12/12/23 10:12 PM, Jason Gunthorpe wrote: > On Tue, Dec 12, 2023 at 02:10:08PM +0100, Joel Granados wrote: > >>> diff --git a/drivers/iommu/iommufd/device.c b/drivers/iommu/iommufd/device.c >>> index 645ab5d290fe..0a8e03d5e7c5 100644 >>> --- a/drivers/iommu/iommufd/device.c >>> +++ b/drivers/iommu/iommufd/device.c >>> @@ -456,6 +456,16 @@ int iommufd_hw_pagetable_attach(struct iommufd_hw_pagetable *hwpt, >>> if (rc) >>> goto err_unlock; >>> >>> + if (hwpt->fault) { >>> + void *curr; >>> + >>> + curr = iopf_pasid_cookie_set(idev->dev, IOMMU_NO_PASID, idev); >> I'm hitting an error here when I try to attach to a hwpt that I created >> previously with the `IOMMU_HWPT_ALLOC_IOPF_CAPABLE` flag. >> >> I get an -ENODEV from iopf_pasid_cookie_set which is triggered by >> dev->iommu->fault_param being 0x0. >> >> I looked around and I see that the fault param gets set in >> iopf_queue_add_device which is called from iommu_dev_enable_feature >> only. Furthermore iommu_dev_enable_feature is only called in idxd and >> uacce drivers. >> >> Questions: >> 1. Should iopf_queue_add_device get called from the >> IOMMU_HWPT_ALLOC_IOPF_CAPABLE ioctl call? This make sense to me as >> this is where the device and the IOPF are related from user space. > It probably needs to call the set feature thing in the short term. > > In the medium term I would like the drivers to manage the iopf based > on domain attachment not explicit feature asks Yes, it's the same as my plan. > >> 2. This is not intended to work only with idxd and uacce. right? > It should work everywhere, I suspect Intel Team didn't hit this > because they are testing IDXD SIOV? Yes. > Can you guys also test it as a PF > assignment? For PF assignment, probably the driver (vfio-pci) needs to enable iopf. Best regards, baolu