From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 116C7ECE for ; Wed, 13 Dec 2023 02:09:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="nnzS61T/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1702433374; x=1733969374; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=MNAA322q9vhdRNtkpV3N3RglXmc+rKBeo/qJoA/OlJw=; b=nnzS61T/r7093TxomjsVKn37FPv/hEa8Ltj5PnAmK/YKxX9GSSC3rVut vZJ8iwg7HGfPybJwEB5E/OO4G4JECPkgilLltKORxowXy31u4HCDdGUpP tgWlwOHbC6Ow7tcM8kS7MQS8thKdSYo7hjV/w47iHz7GQUWT3kjEellj7 iCwxy1uxLidsZeS8NCxODq1EtQx7RLwUHW0RY8XOJTh/8oPCH5pNjQf8v VEOXHY7jr5esgtAOG9XY7JYcioPFHpAtP+zzHRbF6dyjosFlDIT+Dytjo SaDUl5XzdCssFK3fr9/MILiXNp9m7XeMr/YHk9MyikZOxu0LVzv3YN5B8 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10922"; a="392078358" X-IronPort-AV: E=Sophos;i="6.04,271,1695711600"; d="scan'208";a="392078358" 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 Precedence: bulk X-Mailing-List: iommu@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: 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 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