Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp4358289pxp; Tue, 15 Mar 2022 19:27:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwYg7+JDSv8UgIjipd48zHVuSuC/NGVU3eHKoo4AChZxpiPHlc0BDd/30Td4oqRd1M5Gmae X-Received: by 2002:a17:902:e94f:b0:14f:1636:c8a8 with SMTP id b15-20020a170902e94f00b0014f1636c8a8mr31231045pll.130.1647397674753; Tue, 15 Mar 2022 19:27:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647397674; cv=none; d=google.com; s=arc-20160816; b=qQZmzJQjunM9Qts6ZTqgrWOVK+pm00kaMQAjymvUkIb+4d/sALnNNCw/5jiQEl85/F GqoVdAhpFVj5g8Goujao6EqASQMMQ0hHxDbXkf2NtxkTujqeZ5xb/veBN9lMNy2RrG37 UnghzM6EO4MD0ayImumz6vXxga9WYO09jB71y5/q6htlG/IupaTUHGhfaIV8sSCJJpAS 1oMwMtJ5HFgpNkfRZEJX8Ge9B8RUWk4M1SFvz/G39bP8Y2AK1XmBpvqynCWZ32FPgmIL SjM1vpe7+khwFkdcL0uThG9E6fWlYKPBvNe54CnpMMuBSumASvO+ztPgF891R/VfY5gm yOrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=lppOY30CJiako9ek4pC+ooEE+kTUhnE5jMzcvRJdiYg=; b=MNmyPgD6uHkgHu+JiZU2Yo8idBnDj7BmOFlB+hYnJGjiVGKHSbsuNz6S8051SWjrWm +o/xO4XUVM5a54lAZ5o5W5q1svi1cadjVSVy3g7242UeOPK9p6+7dgg28knA8FMeutu8 X2P7ouZSAV48BBPYKcUuNHkBWbShIPV3+25ICgwqI5iNUA67o14w+6js5MuTtzTLU19L uWqftOhzSczS6IZG7hGvtHiYiUoCOkrDTCaWMpkI6KUcsvkzE9nclqlB1CZFlvLgjwbP 14fKZ0QLjb2oeuan6tmuqDFQY4etjcSrk7Pwddfh2TzXIzmgEYUa0l4Ab1ToRQKQAUHk ZRTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=R7klZzYO; 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 q15-20020a056a00150f00b004f7948d14e2si853280pfu.253.2022.03.15.19.27.41; Tue, 15 Mar 2022 19:27:54 -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=R7klZzYO; 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 S1344885AbiCOFMc (ORCPT + 99 others); Tue, 15 Mar 2022 01:12:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344842AbiCOFMT (ORCPT ); Tue, 15 Mar 2022 01:12:19 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9188A49250 for ; Mon, 14 Mar 2022 22:11:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1647321067; x=1678857067; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Ol0nXzisKyEPOLK+60+mhBiQ8qX4SQP0mQu06nsUuvU=; b=R7klZzYOg5Hmtx0aGtul9HX0RNXHOYSHxpQ25zf/RbQ5xKO5JPTLcrdB 3qWWJWbJKv4950gn/8SC9nSNtC8CppQkMZwOaFg3zYB1anlT6DoDG1EjK 2RRk8lKrBF9UDmwhpkemIKFvGtwVxWLANUL7f81e2MDK1JPeNpTUjNIZZ 6qWx8FiDAxrstu/c3BljOY34/kJhzZtKNJhmJ3SUQ1fIw06y5YsnJrVws go+0I7ayxK+4eXVajnsuxJvNSjeNOaRK63KLZDeqcORDQ4bUUQCtoyZgp T95C71dNDBip9Cs38RYDS96gSiQnXwpfCc4LeYXEkPYPHqjaJzkRWFZdG Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10286"; a="236159100" X-IronPort-AV: E=Sophos;i="5.90,182,1643702400"; d="scan'208";a="236159100" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Mar 2022 22:03:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,182,1643702400"; d="scan'208";a="580383571" Received: from otc-wp-03.jf.intel.com (HELO jacob-builder.jf.intel.com) ([10.54.39.79]) by orsmga001.jf.intel.com with ESMTP; 14 Mar 2022 22:03:58 -0700 From: Jacob Pan To: iommu@lists.linux-foundation.org, LKML , Joerg Roedel , Jason Gunthorpe , "Christoph Hellwig" , "Lu Baolu" , Jean-Philippe Brucker Cc: Jacob Pan , Raj Ashok , "Kumar, Sanjay K" , Dave Jiang , Tony Luck , "Zanussi, Tom" , Dan Williams , "Tian, Kevin" , Yi Liu Subject: [PATCH v2 2/8] iommu: Add attach/detach_dev_pasid domain ops Date: Mon, 14 Mar 2022 22:07:06 -0700 Message-Id: <20220315050713.2000518-3-jacob.jun.pan@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220315050713.2000518-1-jacob.jun.pan@linux.intel.com> References: <20220315050713.2000518-1-jacob.jun.pan@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_PASS, 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 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 * @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