Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp425062lqb; Tue, 28 May 2024 22:37:05 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWw7d1soruqIhc8uzhSCfQrDufl41b9TUs/cg/FtUTgVms6l4pY+2RValzHmzj2rgOV5S7qzlhRPAwGVGrqddPuHHRetEsz9FaPqPVxXA== X-Google-Smtp-Source: AGHT+IHSFiN8/imCHMrR/5uQHeUPzlrE7mHPahEIoUrl7lkG3ud0IEFBe/9MthyQmHVWNn93tMrT X-Received: by 2002:a25:ab02:0:b0:deb:d7b5:5c27 with SMTP id 3f1490d57ef6-df772382acdmr14020063276.53.1716961024857; Tue, 28 May 2024 22:37:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716961024; cv=pass; d=google.com; s=arc-20160816; b=RrW2CeuRAsbAstBrn3zWCNU5Sr737gpJkvOn47zfjQ2HBPVBg/mA5kr2BjYKA0hyP4 IlCNb96pn19MXZETG/g2lxCEGeIjGFUUFduwwzT9/inqwg/TalDw2xE76YpEReK3+Oox bPYvGXyrOEkHEI6K32xNNrouIxGSWs2WL2mDM+R7IEqThscZ/aoABstSOPONoCiVJNTA uQU5PU4pFcpmCBlfgmQvooLBGScEZ5KsrxvuCSOOCwVOgLDbLF4EgkPa6jJ3zqzyHCQb cdFOBP0/O4qlHaGvES3PZnILJGQCWPX6OnZu4OzzbeszEjf5o9HSbhOyS5vHaC8Ett4P t0Xw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=08GxDhgZl21klUWbBBAMWjhvz2+zKHMg6SIuF8SKdNk=; fh=u7VIfotmvhCnFPKh0R845OAh004BwcT1TGiZ1dQEGzo=; b=wyJK53CB20H8Bxj+ibzhV5MLYqjch5SjWLWLpmnW/fD0Q987uYPhBfA/yS3TOMEVTp reYVXZjauZzEf1W+KsmUmqwwyn8qKbazTr65XN+LFmpXspEaPk/rNLtWpSKKBxbBeQ/P utDspBhKXDFvPmSPEr5Y1nz9MEo5TjfHV1FirrHrVEObqwbNb16g6mK1tdjDuJUzFGFx 9ahP7MH5xnWb1d9KMkZ7CoLZHK6TUwqdkpbHX9yfnl3yfgU68srLzPmjZ04N7TU/k0ra UMxC7vYQmzxTZJXvLETeV6fD4JxA+b8F/dS4jedumiavXewlB4TH1BduBPsg44b72oj+ fAWg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=TFUfN7yV; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-193450-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193450-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d75a77b69052e-43fdd7a428bsi22539501cf.532.2024.05.28.22.37.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 22:37:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-193450-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=TFUfN7yV; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-193450-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193450-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 81C091C20F83 for ; Wed, 29 May 2024 05:37:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1298215FCF2; Wed, 29 May 2024 05:36:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="TFUfN7yV" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (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 1D87315DBC0 for ; Wed, 29 May 2024 05:36:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716960974; cv=none; b=K0ae3cX32CKwyIfWJlv8fwIR3rGqgI3FkH/Mhys2HG9Cc44zPDFOdlT7QBT1Bv+SY7iqQerHjnD+TwjPbiLLA7/SwHE5xALk7EsP4lT2YrMCYCkc5IKyY1R5L0Ese/WULAcj4wxDK8JYims3W4vbComjOimXAM5AEbBX8dqRshQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716960974; c=relaxed/simple; bh=jeXpPTPjJIlOE9JrMGFrdmPdU1WHNyP76S68yxLZIYk=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=kW83Yyc2Umyo3jVWa0D+g41xv565qpTwm7Jvf+YYaCaOk6zO9xU7YODYzCbJQ/wrfVCWw50Fwd8wo14S0RADuUnPfS4mzPlMerM3T+pmzODPhGJXXSlEbRZoGDaWDpnf/t+VDnUzO7QYgOgwJTcqoQhvHYsfJb/5ezHtULEQqFc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=TFUfN7yV; arc=none smtp.client-ip=192.198.163.14 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716960971; x=1748496971; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=jeXpPTPjJIlOE9JrMGFrdmPdU1WHNyP76S68yxLZIYk=; b=TFUfN7yVG1bwnqYmHQKOxKfxEqRMRg5egyF7l6KfmtPRHs55CclNZ5s+ SrccswOAUMcYZ0UjhmtfjMoTGM1R04TPdGlzzl+TLUdWwiptPY1UUDlf5 bfymRIMG48LDcr5NElJhi03g129yUbqliq5nZpJoNJxNEtsqwD1+Z2QgV ech6+tNu7cHlHM4ITIujmhsUiP+2yGfK34ArLTcATVs4sPAHU4Swbsisi OKxzo0nQWmvWmL2dWmi9HfP+OXgY3aS1rMfbHYUgHUqzMJpZJpU+4OHve eFs33WN4ArkNCZUqq3YY8/fK2JHYqYsuq1okPpJYnulvDQmK5xufwlEBi Q==; X-CSE-ConnectionGUID: M2TgG0t5Qp2mKzy8r39v9A== X-CSE-MsgGUID: NEAtBJBjQJOanRgAoRMLiw== X-IronPort-AV: E=McAfee;i="6600,9927,11085"; a="13568734" X-IronPort-AV: E=Sophos;i="6.08,197,1712646000"; d="scan'208";a="13568734" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2024 22:35:02 -0700 X-CSE-ConnectionGUID: COa8Vg/1TJ+DOYohn2WZPQ== X-CSE-MsgGUID: kjXbaTeoRi+UtA/joP+AHQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,197,1712646000"; d="scan'208";a="35257413" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by fmviesa007.fm.intel.com with ESMTP; 28 May 2024 22:34:56 -0700 From: Lu Baolu To: Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian Cc: Yi Liu , David Airlie , Daniel Vetter , Kalle Valo , Bjorn Andersson , Mathieu Poirier , Alex Williamson , mst@redhat.com, Jason Wang , Thierry Reding , Jonathan Hunter , Mikko Perttunen , iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH 00/20] iommu: Refactoring domain allocation interface Date: Wed, 29 May 2024 13:32:30 +0800 Message-Id: <20240529053250.91284-1-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The IOMMU subsystem has undergone some changes, including the removal of iommu_ops from the bus structure. Consequently, the existing domain allocation interface, which relies on a bus type argument, is no longer relevant: struct iommu_domain *iommu_domain_alloc(struct bus_type *bus) This series is designed to refactor the use of this interface. It proposes two new interfaces to replace iommu_domain_alloc(): - iommu_user_domain_alloc(): This interface is intended for allocating iommu domains managed by userspace for device passthrough scenarios, such as those used by iommufd, vfio, and vdpa. It clearly indicates that the domain is for user-managed device DMA. If an IOMMU driver does not implement iommu_ops->domain_alloc_user, this interface will rollback to the generic paging domain allocation. - iommu_paging_domain_alloc(): This interface is for allocating iommu domains managed by kernel drivers for kernel DMA purposes. It takes a device pointer as a parameter, which better reflects the current design of the IOMMU subsystem. The majority of device drivers currently using iommu_domain_alloc() do so to allocate a domain for a specific device and then attach that domain to the device. These cases can be straightforwardly migrated to the new interfaces. However, there are some drivers with more complex use cases that do not fit neatly into this new scheme. For example: $ git grep "= iommu_domain_alloc" arch/arm/mm/dma-mapping.c: mapping->domain = iommu_domain_alloc(bus); drivers/gpu/drm/rockchip/rockchip_drm_drv.c: private->domain = iommu_domain_alloc(private->iommu_dev->bus); drivers/gpu/drm/tegra/drm.c: tegra->domain = iommu_domain_alloc(&platform_bus_type); drivers/infiniband/hw/usnic/usnic_uiom.c: pd->domain = domain = iommu_domain_alloc(dev->bus); This series leave those cases unchanged and keep iommu_domain_alloc() for their usage. But new drivers should not use it anymore. The whole series is also available on GitHub: https://github.com/LuBaolu/intel-iommu/commits/iommu-domain-allocation-refactor-v1 Lu Baolu (20): iommu: Add iommu_user_domain_alloc() interface iommufd: Use iommu_user_domain_alloc() vfio/type1: Use iommu_paging_domain_alloc() vhost-vdpa: Use iommu_user_domain_alloc() iommu: Add iommu_paging_domain_alloc() interface drm/msm: Use iommu_paging_domain_alloc() drm/nouveau/tegra: Use iommu_paging_domain_alloc() gpu: host1x: Use iommu_paging_domain_alloc() media: nvidia: tegra: Use iommu_paging_domain_alloc() media: venus: firmware: Use iommu_paging_domain_alloc() ath10k: Use iommu_paging_domain_alloc() wifi: ath11k: Use iommu_paging_domain_alloc() remoteproc: Use iommu_paging_domain_alloc() soc/fsl/qbman: Use iommu_paging_domain_alloc() iommu/vt-d: Add helper to allocate paging domain iommu/vt-d: Add domain_alloc_paging support iommu/vt-d: Simplify compatibility check for identity domain iommu/vt-d: Enhance compatibility check for paging domain attach iommu/vt-d: Remove domain_update_iommu_cap() iommu/vt-d: Remove domain_update_iommu_superpage() include/linux/iommu.h | 12 + drivers/gpu/drm/msm/msm_iommu.c | 8 +- .../drm/nouveau/nvkm/engine/device/tegra.c | 4 +- drivers/gpu/host1x/dev.c | 6 +- drivers/iommu/intel/iommu.c | 319 ++++++++---------- drivers/iommu/intel/pasid.c | 28 +- drivers/iommu/iommu.c | 62 ++++ drivers/iommu/iommufd/hw_pagetable.c | 20 +- .../media/platform/nvidia/tegra-vde/iommu.c | 6 +- drivers/media/platform/qcom/venus/firmware.c | 6 +- drivers/net/wireless/ath/ath10k/snoc.c | 6 +- drivers/net/wireless/ath/ath11k/ahb.c | 6 +- drivers/remoteproc/remoteproc_core.c | 6 +- drivers/soc/fsl/qbman/qman_portal.c | 4 +- drivers/vfio/vfio_iommu_type1.c | 7 +- drivers/vhost/vdpa.c | 11 +- 16 files changed, 253 insertions(+), 258 deletions(-) -- 2.34.1