From patchwork Mon Aug 14 01:17:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolu Lu X-Patchwork-Id: 13576 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp2466555vqi; Sun, 13 Aug 2023 19:01:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGw0XWbSP4XOYTqABNGWrN45/PgQoXbdP/evMIY/gIVdGeJ3+A3rCt1Euwdn3UnvTST7SHM X-Received: by 2002:a17:906:314c:b0:99b:64d0:f6c8 with SMTP id e12-20020a170906314c00b0099b64d0f6c8mr6325169eje.50.1691978506928; Sun, 13 Aug 2023 19:01:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691978506; cv=none; d=google.com; s=arc-20160816; b=qpr6WszBqcIDwSlMqy9nBAYSI6DUmykyjK24rqCS72N8HoTEuumAkIOQRKpfvOqdmp fv5mKvNI0Rb6+m2ArY0afaLvcdI8zai1/nIcKX3IUky0dZNpUEdwqFVFmwr3z3Ap4yw6 eYaYcpajYkuXkxondChEfl8YHQki4L53dJw3AWLivThLfNryEG+Vo2IYCnmyFKK1dOoL N+sImp627zaQBvhDQnKIiPvglD1WU9NM07ULTedZ40kvUTq0HglhkH0aK+mRxwQi538R 6L4uHymkqJ4X3HtCPEILMXvIOhDKhQHyk5gTeMCMuTSdmMHgY2K68mOVUekOGQ6QBg4h KwAg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=JJSvFFZGJNyOBq32LdNjm1W77J3zwRD8N8YWlDgarIw=; fh=5v0QJkujOnxKSzhmeWiMX/0q9X35NwMz+SRMkKa4moc=; b=GiErHdMS7v30KTZ1ZLl+3sMbuU3meO38TDcwn+IzPYuwlbpRnfLW2Woth3bq1ySscJ 0RjmMUgG/+SPZIR2jdYwPfMshSQpP4SRDvVJ7a+4XXcabHT048XcuVPnMpGQvvbotlNW ap3ofeCK0IdU5Mg7GwIuYroQ0Aoi3NNfPLMT33QFtG2H/Yz/eFZK7f0jwqNS4lh/pIyE UrQdKIaUi6yBBDCOgPI/icxwz0Gwt4bsfSy+SUC617fcOEADHGP1Kd2EhQOEStnq6by4 HKRI4mZEFctGD6Y4+qviFKMjs+p4CkP12eMMJLNO6MylCUX5Q+12Y43AzkqvY/2rA10R SplA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="AmYB/mjL"; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ss13-20020a170907038d00b009930d4e327dsi7359591ejb.880.2023.08.13.19.01.23; Sun, 13 Aug 2023 19:01:46 -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="AmYB/mjL"; 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 S231730AbjHNBVB (ORCPT + 99 others); Sun, 13 Aug 2023 21:21:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231704AbjHNBUa (ORCPT ); Sun, 13 Aug 2023 21:20:30 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66FF71BD; Sun, 13 Aug 2023 18:20:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1691976029; x=1723512029; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=oe335Nlu8sc5VS5G7ofG+VOn5WK1MFpLS3mlAGuCpFo=; b=AmYB/mjLC5wgRSySM/rffrDcf5e+ITBfHXj28s9lrfuvIj0z52aZKMaA Ps5zEFr+Dx4o58D1CYXui18MRMfkVHSRYBasyEQueWuAffbZfMmFWW3VB RCf6nmC1zRu2lppk3DaB0TpkASusexmkSBwQ5EavBnJPQcbyQ+IbRKU6E qffxK+006HeR1aNTD8alhBGZwvKiWSZ8SPK6jOj2pIeRdsCVoUCMqrDUl RO+cq/UhXACCMp4FqzTm4nLwimq5Iv0af/P7xKqo7/IP/epNNJt8GAHbG CPDMfRdXeslE6ijCXti9hRQeaFfHXwOYhWiND77DISroTIt5mgp5Cc528 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10801"; a="375645291" X-IronPort-AV: E=Sophos;i="6.01,171,1684825200"; d="scan'208";a="375645291" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Aug 2023 18:20:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10801"; a="726842289" X-IronPort-AV: E=Sophos;i="6.01,171,1684825200"; d="scan'208";a="726842289" Received: from allen-box.sh.intel.com ([10.239.159.127]) by orsmga007.jf.intel.com with ESMTP; 13 Aug 2023 18:20:25 -0700 From: Lu Baolu To: Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian , Jean-Philippe Brucker , Nicolin Chen Cc: Yi Liu , Jacob Pan , iommu@lists.linux.dev, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH v2 0/3] iommu: Make pasid array per device Date: Mon, 14 Aug 2023 09:17:56 +0800 Message-Id: <20230814011759.102089-1-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1774168055119607929 X-GMAIL-MSGID: 1774168055119607929 The PCI PASID enabling interface guarantees that the address space used by each PASID is unique. This is achieved by checking that the PCI ACS path is enabled for the device. If the path is not enabled, then the PASID feature cannot be used. if (!pci_acs_path_enabled(pdev, NULL, PCI_ACS_RR | PCI_ACS_UF)) return -EINVAL; The PASID array is not an attribute of the IOMMU group. It is more natural to store the PASID array in the per-device IOMMU data. This makes the code clearer and easier to understand. Please help review and suggest. Change log: v2: - Add an explict check for single-device group in the domain attaching device pasid interface. (Jason) - Make assert_pasid_dma_ownership() returns true or false. Refactor the code in a way that does not change its exsiting behavior. (Kevin) v1: https://lore.kernel.org/linux-iommu/20230801063125.34995-1-baolu.lu@linux.intel.com/ Lu Baolu (3): iommu: Make single-device group for PASID explicit iommu: Consolidate pasid dma ownership check iommu: Move pasid array from group to device include/linux/iommu.h | 2 + drivers/iommu/iommu.c | 102 +++++++++++++++++++----------------------- 2 files changed, 49 insertions(+), 55 deletions(-)