Received: by 2002:ac2:464d:0:0:0:0:0 with SMTP id s13csp159907lfo; Wed, 25 May 2022 18:43:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxbAVJxcrBGvrQMEEneJ2r8GT0XuY8NklaXM18DQ+5pz8QOjJ9S42iWdKDE/2x3lH27IzJ X-Received: by 2002:a17:907:1c1c:b0:6fe:cedb:d089 with SMTP id nc28-20020a1709071c1c00b006fecedbd089mr18657256ejc.323.1653529385394; Wed, 25 May 2022 18:43:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653529385; cv=none; d=google.com; s=arc-20160816; b=sLhwnm5mRLmC4Iva3zYFq5MT/ckTlXs/BrpXyLLmxn6Q40FmS+Sl3Ul7CavQtW+D5o yqNQy1SRWT8lJgY3jRT0Uh2qY0qZRnPHO93OZ8YcagfZTbDZ0S8DRmq7hlcwC5gz1t+l zkJiyFoZbmLGkijcjFxSGmWp38267IUv09T6AnkuM2TzxIkDL4OKATmYWo3QP7ux9OGr cEqsW0tC31sv45QJo5AqrP2mGx9ll/GvlqiXE8F86k/kC7gebOyv4w2f8rAYqb5XLTAG 1r1ALWCOEW1nvuROXNqnvTXsA+DJPD73OLAnk+Yr7CaIQZwg/kq/hZ177S8KG5soXnrL 7MyA== 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=D0FZsZMHA0bpX7WySnCDhoH4rylw2uFdPB+9tsThfMI=; b=Qad2BuikD57HgvaMcy4lU8o+fnjeH0WXr9ngddUWqkg+JaT/+ur9jAPVtg2su9tP5x MN8uSOJMMr8/IQUc8LmbngFO/BUjvvXnIqnWRiwP9N0KwjS6Hwp1ruMQh8sftXvKY3+i tZPSUjRVzy7SY4u/AbOq+T4Oe4oIwb/OVqGVexi37cY+ji6pqFlK8uXF2ouP1FelBvDV dp9YyMoU2j0Qmc/lAAiR2UQHOhYdJsEBRA+iCJYbJnm4h65KmX6EkbDb+07ODewM4kVS oQsY3j63Mj63hkkkiWoyfppnQp+SVkUu6RQ62FVgEjRLeSrKJzJg/0TDmMb53uSXAUwN zU/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=P+9eIJ0i; 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 o8-20020a170906974800b006ff1e01c729si176952ejy.1009.2022.05.25.18.42.21; Wed, 25 May 2022 18:43: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=P+9eIJ0i; 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 S244004AbiEYFd5 (ORCPT + 99 others); Wed, 25 May 2022 01:33:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243999AbiEYFd4 (ORCPT ); Wed, 25 May 2022 01:33:56 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47F1D5E74D for ; Tue, 24 May 2022 22:33:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1653456835; x=1684992835; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=tC5kXzJ2AZTXt2qxLz/QlNtc9RLvHWTtlK4ZRvR3278=; b=P+9eIJ0iqKBOt5fl8p6Khy5jOuGihRyGHIvIdVx2ejCb2/qJYTwf2qUC T1ueCF66F9iZ8BVGLaWhfkntKaDQvpAr+qAWGQufchHjBdTIcY0qu4LtH rzNvYPACceB/tLyND3XWLE+VdIItMabADHQMlAkBA4OnWl+WFWcPNYo47 9yK9p9D0cCXpleBkCStIiT3HkeSEkTStgOX+IF5cA9GmWJgvB/TQyRQ4B /c10JKQPadBJYbJnxJRX1Jb/P8KZ1H3G/1N4BGSOiFcy+vgjS/w9NGdty p3pa5jUCpKCEA6norC8BHZiqoWRodq1+jPF/MfD5orO1cs1qT48WUNd71 A==; X-IronPort-AV: E=McAfee;i="6400,9594,10357"; a="336775076" X-IronPort-AV: E=Sophos;i="5.91,250,1647327600"; d="scan'208";a="336775076" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2022 22:33:54 -0700 X-IronPort-AV: E=Sophos;i="5.91,250,1647327600"; d="scan'208";a="601666278" Received: from jwang96-mobl.ccr.corp.intel.com (HELO [10.255.29.139]) ([10.255.29.139]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2022 22:33:50 -0700 Message-ID: <11743cbe-c354-8442-d758-764cc59ce01a@linux.intel.com> Date: Wed, 25 May 2022 13:33:48 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Cc: baolu.lu@linux.intel.com, Joerg Roedel , Christoph Hellwig , Kevin Tian , Ashok Raj , Will Deacon , Robin Murphy , Jean-Philippe Brucker , Dave Jiang , Vinod Koul , Eric Auger , Liu Yi L , Jacob jun Pan , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Jean-Philippe Brucker Subject: Re: [PATCH v7 03/10] iommu/sva: Add iommu_sva_domain support Content-Language: en-US To: Jason Gunthorpe References: <20220519072047.2996983-1-baolu.lu@linux.intel.com> <20220519072047.2996983-4-baolu.lu@linux.intel.com> <20220524134440.GT1343366@nvidia.com> From: Baolu Lu In-Reply-To: <20220524134440.GT1343366@nvidia.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-8.3 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/5/24 21:44, Jason Gunthorpe wrote: >> +{ >> + struct iommu_sva_domain *sva_domain; >> + struct iommu_domain *domain; >> + >> + if (!bus->iommu_ops || !bus->iommu_ops->sva_domain_ops) >> + return ERR_PTR(-ENODEV); >> + >> + sva_domain = kzalloc(sizeof(*sva_domain), GFP_KERNEL); >> + if (!sva_domain) >> + return ERR_PTR(-ENOMEM); >> + >> + mmgrab(mm); >> + sva_domain->mm = mm; >> + >> + domain = &sva_domain->domain; >> + domain->type = IOMMU_DOMAIN_SVA; >> + domain->ops = bus->iommu_ops->sva_domain_ops; >> + >> + return domain; >> +} >> + >> +void iommu_sva_free_domain(struct iommu_domain *domain) >> +{ >> + struct iommu_sva_domain *sva_domain = to_sva_domain(domain); >> + >> + mmdrop(sva_domain->mm); >> + kfree(sva_domain); >> +} > No callback to the driver? Should do this in the next version. This version added an sva-specific iommu_domain_ops pointer in iommu_ops. This is not the right way to go. > >> +int iommu_sva_set_domain(struct iommu_domain *domain, struct device *dev, >> + ioasid_t pasid) >> +{ > Why does this function exist? Just call iommu_set_device_pasid() Yes, agreed. > >> +int iommu_set_device_pasid(struct iommu_domain *domain, struct device *dev, >> + ioasid_t pasid) >> +{ > Here you can continue to use attach/detach language as at this API > level we expect strict pairing.. Sure. > > >> +void iommu_block_device_pasid(struct iommu_domain *domain, struct device *dev, >> + ioasid_t pasid) >> +{ >> + struct iommu_group *group = iommu_group_get(dev); >> + >> + mutex_lock(&group->mutex); >> + domain->ops->block_dev_pasid(domain, dev, pasid); >> + xa_erase(&group->pasid_array, pasid); >> + mutex_unlock(&group->mutex); > Should be the blocking domain. As we discussed, we should change above to blocking domain when the blocking domain is supported on at least Intel and arm-smmu-v3 drivers. I have started the work for Intel driver support. Best regards, baolu