Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp916367pxp; Wed, 16 Mar 2022 21:12:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwu+RsIDM7dHUQH7p69pgZV3xa/pRJfXaIvWsxo4yWFaPUMp3tFlJ/42gjqb7ZX6xubYi7Z X-Received: by 2002:a17:90a:7f04:b0:1bf:9e71:9d35 with SMTP id k4-20020a17090a7f0400b001bf9e719d35mr13738707pjl.203.1647490337816; Wed, 16 Mar 2022 21:12:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647490337; cv=none; d=google.com; s=arc-20160816; b=n/lG2UHMkdbwpkmoWlW4M+SZN/MzzCm4d/nCZ7QfJEE1tVMT+YK+pnf3cBUzT7pgmH 1As5MTsyL7BwsWlDtNdqeoO3YwJ7zT/4fxYnskL9Fbnwm9jVcW1DmcHm41wuaiAHaTM1 yqKvxjjGttWnGj73g3QgkAzTuKqtktdJJUL1slCjxjhF/xGHFIcvw4q0TsHv90CfIYjX X6J7BHN5WUWXOCuNGslTRwItd1TwmBEnTuN6yjAGdz4TyutFa6hgNnILaNFjLbU/nZ9q N5WVkeoA/GmAYX+zkEg/H2LfPFJhDDL20j0J46X9l6CC4hIhBr3Z4bgREXKCmg3B3J5x xiaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Xsy+hdBDmUEEW9oGx4D4eHqInkltCSE2p0AuseWmMgg=; b=T0XDpd4t3kBm9wPfOVJ50zOkDqLeqf2Uu3eTSpm6PLyLIeMh8Y2dPa/9pwGrbljyMP GlUFTJ7WKonyyQWlRJAQWAvYWgZ7Sft33lff8MI+SHGe92ZS2U1cuuODvpRonsyqVKJB UvmFfgDHVvrQwSHKoJQ3QVGrvEwvbhmBXRx5nM2GCgPqlxzoDY5IYlhSpE8TOmPhSwwM bAvcbxXeaB9KTjEgre1hkmvfOZqVUpQnULbDqWBbr1PYq8VW0Lj+H66bBNqsmhoghTXC 1wC/JRj0VwLdm2MMB2BQnFnPWaWCM7MAdDvRBAeoygZuv+67bxmsTaSunR9zxpgobr2+ mqWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NN5nqsh5; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id s207-20020a6277d8000000b004f787292402si3730049pfc.58.2022.03.16.21.12.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Mar 2022 21:12:17 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NN5nqsh5; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EDE407A99A; Wed, 16 Mar 2022 20:50:57 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346495AbiCOL2k (ORCPT + 99 others); Tue, 15 Mar 2022 07:28:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229821AbiCOL2i (ORCPT ); Tue, 15 Mar 2022 07:28:38 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E280F4F9F9 for ; Tue, 15 Mar 2022 04:27:26 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id r6so28040382wrr.2 for ; Tue, 15 Mar 2022 04:27:26 -0700 (PDT) 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=Xsy+hdBDmUEEW9oGx4D4eHqInkltCSE2p0AuseWmMgg=; b=NN5nqsh5i2xYRMZXD4nVNF44ylsoZUN1zOSa8Vzd4saL/27OcGoHbKQSfiEqQbnx7+ Eft7dWXkDfTrx7LuODBh7+p3+qJQDwsy5n5Jp8eoWvlZWGulbQqK27lYw4cgD2fxDdGK jlgVl5VVl0GV/w8Mw7cV7mLIU8CG4phu5pwPOm0orA8CQFVFWTDgZC8MoGspUSQ46AKx lkGZ/fpYCyerOUjUbrFm5lyOmIoRNE2Aqa5mU92mx3ZjtED1k8eFhJaIldK6mkV34T30 afZlNazQE9o5zyTKePlKUNCHT73/Fm3P+amBqUwUPPUjeSkCHyCfbDz2fHFIqQEgW+/p NYPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Xsy+hdBDmUEEW9oGx4D4eHqInkltCSE2p0AuseWmMgg=; b=IMhspA3iT8B/caNKgB0J6xeJ9OoHXJ3PzdNe16qP+nTMqCz3Y0L/bSn3QN28AH+BjJ sQ8pPMiKthTyux2jVMrfvd/OasFfZKJ0CDwhBXCoynZkvhJjT1PMuWt+qkh9FK5PEDVN LUrvFInK53O+xLOYhx9f+zRN/KjotswU5eiwu+aRv8th7O7M1WOj/VpohBoBZAy/z/qr mLXJCt7En8Y1ZpqMZ+8tDfkuOYMn2QMtTIQGOJbEzoOb4pAWeGTFUF3rNfnpHXr5olvh +BIDMz//KeVCa7AkcCWKCCuts2nL2943REE/s7ROTYm3ugixb3bqiWuKcJwkQr4WaIhu PSug== X-Gm-Message-State: AOAM533BNGPkM5p8hR5Lnxau7vxJAWn2pEijnrSJR1FHLQobVV9+ZL6/ MzIJQUPyDcHDdElc3ABrxFipBA== X-Received: by 2002:adf:cd8f:0:b0:1ed:af02:2295 with SMTP id q15-20020adfcd8f000000b001edaf022295mr19238184wrj.226.1647343645473; Tue, 15 Mar 2022 04:27:25 -0700 (PDT) Received: from myrica (cpc92880-cmbg19-2-0-cust679.5-4.cable.virginm.net. [82.27.106.168]) by smtp.gmail.com with ESMTPSA id n8-20020a5d5988000000b00203d5f1f3e4sm1348294wri.105.2022.03.15.04.27.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Mar 2022 04:27:25 -0700 (PDT) Date: Tue, 15 Mar 2022 11:26:59 +0000 From: Jean-Philippe Brucker To: Jacob Pan Cc: iommu@lists.linux-foundation.org, LKML , Joerg Roedel , Jason Gunthorpe , Christoph Hellwig , Lu Baolu , Jean-Philippe Brucker , Jacob Pan , Raj Ashok , "Kumar, Sanjay K" , Dave Jiang , Tony Luck , "Zanussi, Tom" , Dan Williams , "Tian, Kevin" , Yi Liu Subject: Re: [PATCH v2 2/8] iommu: Add attach/detach_dev_pasid domain ops Message-ID: References: <20220315050713.2000518-1-jacob.jun.pan@linux.intel.com> <20220315050713.2000518-3-jacob.jun.pan@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220315050713.2000518-3-jacob.jun.pan@linux.intel.com> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Mon, Mar 14, 2022 at 10:07:06PM -0700, Jacob Pan wrote: > From: Lu Baolu > > An IOMMU domain represents an address space which can be attached by > devices that perform DMA within a domain. However, for platforms with > PASID capability the domain attachment needs be handled at device+PASID > level. There can be multiple PASIDs within a device and multiple devices > attached to a given domain. > This patch introduces a new IOMMU op which support device, PASID, and > IOMMU domain attachment. The immediate use case is for PASID capable > devices to perform DMA under DMA APIs. > > Signed-off-by: Lu Baolu > Signed-off-by: Jacob Pan > --- > include/linux/iommu.h | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/include/linux/iommu.h b/include/linux/iommu.h > index 369f05c2a4e2..fde5b933dbe3 100644 > --- a/include/linux/iommu.h > +++ b/include/linux/iommu.h > @@ -227,6 +227,8 @@ struct iommu_iotlb_gather { > * @aux_get_pasid: get the pasid given an aux-domain > * @sva_bind: Bind process address space to device > * @sva_unbind: Unbind process address space from device > + * @attach_dev_pasid: attach an iommu domain to a pasid of device > + * @detach_dev_pasid: detach an iommu domain from a pasid of device Isn't that operation "assign a PASID to a domain" instead? In patch 5, the domain is already attached to the device, so set_domain_pasid() might be clearer and to the point. If the IOMMU driver did the allocation we could also avoid patch 1. If I understand correctly this series is not about a generic PASID API that allows drivers to manage multiple DMA address spaces, because there still doesn't seem to be any interest in that. It's about the specific IDXD use-case, so let's focus on that. We can introduce a specialized call such as (iommu|dma)_set_device_pasid(), which will be easy to consolidate later into a more generic "dma_enable_pasid()" API if that ever seems useful. Thanks, Jean > * @sva_get_pasid: Get PASID associated to a SVA handle > * @page_response: handle page request response > * @cache_invalidate: invalidate translation caches > @@ -296,6 +298,10 @@ struct iommu_ops { > struct iommu_sva *(*sva_bind)(struct device *dev, struct mm_struct *mm, > void *drvdata); > void (*sva_unbind)(struct iommu_sva *handle); > + int (*attach_dev_pasid)(struct iommu_domain *domain, > + struct device *dev, ioasid_t id); > + void (*detach_dev_pasid)(struct iommu_domain *domain, > + struct device *dev, ioasid_t id); > u32 (*sva_get_pasid)(struct iommu_sva *handle); > > int (*page_response)(struct device *dev, > -- > 2.25.1 >