From patchwork Mon Sep 2 01:46:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolu Lu X-Patchwork-Id: 824819 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) (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 3C3FB20B0F; Mon, 2 Sep 2024 01:51:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.8 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725241870; cv=none; b=VfyCJ+pwpKN6Fgw0XL3aJSnnRZpJ7dADbIQfdzi0y+VSCz692xWMH6WII8vnmVq4dycRf1AwMt6jAinIOwM6admv5NkxV3n+5hDK2OBD+9VRAOVdxSxtQn4rPyANGYPxME1mFm8HI/dMI++ZiQ6J7TtxSPemWKDAJS9073B5kXc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725241870; c=relaxed/simple; bh=GbpYXxZBS+r4Y0EiK3BFmXVZKaFfLeJ2IAlI0t0Upno=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=PpeJvWZUdvtJoFbW1qRot+L5mnF53m/d+tY9gas29eQAz1l8cTrqIJGyBfMypt8Nv4fawTeW0dbnXlTQV90mvijnb+vL0j0EUuA7IuKhzBeYWKIEPC6P7y1KBnUvWYf77NBmwL6a4q2+q/MyvhyBpKIBBaZTLHgF3F7BPCXJzIM= 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=hf2Qp0ic; arc=none smtp.client-ip=192.198.163.8 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="hf2Qp0ic" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1725241868; x=1756777868; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GbpYXxZBS+r4Y0EiK3BFmXVZKaFfLeJ2IAlI0t0Upno=; b=hf2Qp0ichCOfBGXIdRA6b50c934tMWiBcJzp0/le5HlfxQGVbw/mS2Gc 267fb3n374cvunbd3uUrryv5oB5OOJfRnwpZMCvIhgcpqk8rX0xVmLH4F xbyNzgkbwQgm0Q7wx+fA1H8LTnOY0VuiPbDZOS0+A/jEyP4SvCN5Gd2m5 M1u0VN+M/X7+aQU70aIsDAciH4e2ojXC99ft9MvBwQtoGswvrwy9+a7/s JmNp1lkNLK88lcbxQBznoPtX6fML9iy4EKDbxeTm9OblCKxv40+dw+APL PNbIfYrWq7fv1t1nPXnLWd+Y8sTW2z77NRI6yIoo56RHhzuhx0tmfPYaZ w==; X-CSE-ConnectionGUID: ugvfHC2qQAGe3Vc4HgaVkw== X-CSE-MsgGUID: z2F8aLdkRHeb3+uiAA7KDA== X-IronPort-AV: E=McAfee;i="6700,10204,11182"; a="41307666" X-IronPort-AV: E=Sophos;i="6.10,194,1719903600"; d="scan'208";a="41307666" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Sep 2024 18:51:08 -0700 X-CSE-ConnectionGUID: ZzqqnVAJSDev//9APFczuA== X-CSE-MsgGUID: afJR3rigT1S94bedyrPJ5g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,194,1719903600"; d="scan'208";a="64817644" Received: from allen-box.sh.intel.com ([10.239.159.127]) by orviesa006.jf.intel.com with ESMTP; 01 Sep 2024 18:51:01 -0700 From: Lu Baolu To: Karol Herbst , Lyude Paul , Danilo Krummrich , David Airlie , Daniel Vetter , Thierry Reding , Jonathan Hunter , Sandy Huang , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Mikko Perttunen , Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian Cc: dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, linux-tegra@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-media@vger.kernel.org, iommu@lists.linux.dev, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH v2 1/3] drm/nouveau/tegra: Use iommu_paging_domain_alloc() Date: Mon, 2 Sep 2024 09:46:58 +0800 Message-Id: <20240902014700.66095-2-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240902014700.66095-1-baolu.lu@linux.intel.com> References: <20240902014700.66095-1-baolu.lu@linux.intel.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In nvkm_device_tegra_probe_iommu(), a paging domain is allocated for @dev and attached to it on success. Use iommu_paging_domain_alloc() to make it explicit. Signed-off-by: Lu Baolu Reviewed-by: Lyude Paul --- drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c b/drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c index 87caa4a72921..763c4c2925f9 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c @@ -120,8 +120,8 @@ nvkm_device_tegra_probe_iommu(struct nvkm_device_tegra *tdev) mutex_init(&tdev->iommu.mutex); if (device_iommu_mapped(dev)) { - tdev->iommu.domain = iommu_domain_alloc(&platform_bus_type); - if (!tdev->iommu.domain) + tdev->iommu.domain = iommu_paging_domain_alloc(dev); + if (IS_ERR(tdev->iommu.domain)) goto error; /* From patchwork Mon Sep 2 01:46:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolu Lu X-Patchwork-Id: 825182 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) (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 B35033A8CB; Mon, 2 Sep 2024 01:51:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.8 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725241876; cv=none; b=cSRcJjEqe36nNb9m6Jh22HjIv37d9X0eLhYfC/big/oZz6jOW6/XMypV88p9z0HMpfg1nVT0SkvsOMKaqCFg2JUp3hwPbc2wyP54yoc17M+2EFSmQf/zuE0lA1jUXxeg7oHLYbs7wAL3wSqxULj7hS8uSCpkKJ1er4jVMk2csOQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725241876; c=relaxed/simple; bh=HTJQcN0FE2N5DQLr1jAt6JXd6rKNx9aVQY3dPFxGnc4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ItN4zKFjYWVRitR+Bwaxzrhba5BOU/fb6HCDE/GEKDyW963t7SRf9YAVXbLvA58Nsre7hFpaFl84QayGXeigL+sXekRvQ4NEHxS0noIN7VXOyQI9WqClno+UB9e971BASCmtiam1NTE5RV2iAwDFVB77FXjB0IjZSAXAmsOQAtY= 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=SAxBmPoS; arc=none smtp.client-ip=192.198.163.8 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="SAxBmPoS" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1725241875; x=1756777875; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HTJQcN0FE2N5DQLr1jAt6JXd6rKNx9aVQY3dPFxGnc4=; b=SAxBmPoSlc4y7/SGHP24I4hG78Pi+Ky53dVDzmpHKSTpMHd9Mccl+0qY UCJBQpV5WIOj/mSVkAiSh5ydbD8FlTyAsXaA0JYbhn6GmcN0rMUZXMadu C7a7ctsMOo2RBkIL9M61OCWmlUt7ixQp0R+rLmOALdw7WmrT3iaRk4lad aTivY5cGhYv++I0wz2hroc3zhNJLGBFWrRPpQ0jBzTwRml4e65Fabtywh Q/02c1J+/X9GPMGLglJxo/8oeEFYqJLNtd11xKo7OvQ2b6t9WPMRqShOB JkEauqt1gL3pv98jqqaYY6uwdutMAlfmCem9p2QiuB2vL/wmBbYL7oXD6 w==; X-CSE-ConnectionGUID: 9WAz+8hlS42G+4CvTde5vg== X-CSE-MsgGUID: Nu7l90SSSNuWPd0eoIIeyg== X-IronPort-AV: E=McAfee;i="6700,10204,11182"; a="41307688" X-IronPort-AV: E=Sophos;i="6.10,194,1719903600"; d="scan'208";a="41307688" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Sep 2024 18:51:14 -0700 X-CSE-ConnectionGUID: Nl7Pj8i9TO6XqEwIgHlq0Q== X-CSE-MsgGUID: +vkijvTkTzO3htP32F9nBw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,194,1719903600"; d="scan'208";a="64817664" Received: from allen-box.sh.intel.com ([10.239.159.127]) by orviesa006.jf.intel.com with ESMTP; 01 Sep 2024 18:51:08 -0700 From: Lu Baolu To: Karol Herbst , Lyude Paul , Danilo Krummrich , David Airlie , Daniel Vetter , Thierry Reding , Jonathan Hunter , Sandy Huang , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Mikko Perttunen , Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian Cc: dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, linux-tegra@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-media@vger.kernel.org, iommu@lists.linux.dev, linux-kernel@vger.kernel.org, Lu Baolu , Jason Gunthorpe , Andy Yan Subject: [PATCH v2 2/3] drm/rockchip: Use iommu_paging_domain_alloc() Date: Mon, 2 Sep 2024 09:46:59 +0800 Message-Id: <20240902014700.66095-3-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240902014700.66095-1-baolu.lu@linux.intel.com> References: <20240902014700.66095-1-baolu.lu@linux.intel.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Commit <421be3ee36a4> ("drm/rockchip: Refactor IOMMU initialisation") has refactored rockchip_drm_init_iommu() to pass a device that the domain is allocated for. Replace iommu_domain_alloc() with iommu_paging_domain_alloc() to retire the former. Signed-off-by: Lu Baolu Reviewed-by: Jason Gunthorpe Acked-by: Andy Yan --- drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c index 44d769d9234d..11e5d10de4d7 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c @@ -103,13 +103,17 @@ static int rockchip_drm_init_iommu(struct drm_device *drm_dev) struct rockchip_drm_private *private = drm_dev->dev_private; struct iommu_domain_geometry *geometry; u64 start, end; + int ret; if (IS_ERR_OR_NULL(private->iommu_dev)) return 0; - private->domain = iommu_domain_alloc(private->iommu_dev->bus); - if (!private->domain) - return -ENOMEM; + private->domain = iommu_paging_domain_alloc(private->iommu_dev); + if (IS_ERR(private->domain)) { + ret = PTR_ERR(private->domain); + private->domain = NULL; + return ret; + } geometry = &private->domain->geometry; start = geometry->aperture_start; From patchwork Mon Sep 2 01:47:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolu Lu X-Patchwork-Id: 824818 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) (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 E539843155; Mon, 2 Sep 2024 01:51:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.8 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725241883; cv=none; b=gxEln8fOPQZzJXGWg8MtYnSkCXZPoC1THPgYsUqxgGJjF1uKuFq3+RWRXvFVzVkT/SvpAqor23JYqy19K9Cmw3eb+w4nYhRXtpql4kq3uEJkVd2Ruu4QTI3A28ty4kHqjg4tQygpW6JkV9OCyg+0rIPSfSdF7Xy5V3WuI7sGXd4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725241883; c=relaxed/simple; bh=eNOviPAyOZhMOAzv2QCrEMyisdMbFcDCq2iEBrdz3QQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gaFxIkaG7V/C5qbcDxpyWn/8WwTmYAzgkMuJZMcdVj04S9YqnID+TQks7JI6v+vOWbiTQnSZcT9VTplmaprMqbKGYX61tX10h5FSbQMjgJSTPSOJAAEhFdv03WcQbBCODpaVHJUSKbBhQKY0OcNZTSoCPIb8P+Kaf+orhAbynrs= 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=AyLh5Ijb; arc=none smtp.client-ip=192.198.163.8 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="AyLh5Ijb" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1725241882; x=1756777882; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=eNOviPAyOZhMOAzv2QCrEMyisdMbFcDCq2iEBrdz3QQ=; b=AyLh5Ijb7GkRHzQ86SsD9TT/XumemhyIz3aEjEiZrVjhA0SQiC7IvJxY 7XE/RAAeEQeJu/0POss1L6zUTh9hG+IPGLLgObU47j+t73wNhmZSA3l8b xirMS5jf6+Tqyj4GemKhQtwLEved+80mdCqmO5hJT/BRNqsw7v01eEIVl U3l+1oQt3kJKh3/kMG/uDIHGdjk9kvqFgxkxdUsP9RobJItoeNAJB6jSj 2Fm2J5uHpfWi3VXh+0MkmE7OBD8G0SEWucSpOEtmeB8oAnJUrPjT4NFkn a6DZ4fwYbYmhUXU7SbzIzfOyCEw0F4cj9IasZfHzMO8B8qMqvPhLHT4Qd w==; X-CSE-ConnectionGUID: uq+0KWoaR3GltarrjmqOLA== X-CSE-MsgGUID: pKd8mdcDSNeW6OGTHjx9uQ== X-IronPort-AV: E=McAfee;i="6700,10204,11182"; a="41307710" X-IronPort-AV: E=Sophos;i="6.10,194,1719903600"; d="scan'208";a="41307710" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Sep 2024 18:51:21 -0700 X-CSE-ConnectionGUID: 29OEIk5/RfmpO23cXnBNZA== X-CSE-MsgGUID: ON9C07fzS3iCg+btlHUEUA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,194,1719903600"; d="scan'208";a="64817693" Received: from allen-box.sh.intel.com ([10.239.159.127]) by orviesa006.jf.intel.com with ESMTP; 01 Sep 2024 18:51:15 -0700 From: Lu Baolu To: Karol Herbst , Lyude Paul , Danilo Krummrich , David Airlie , Daniel Vetter , Thierry Reding , Jonathan Hunter , Sandy Huang , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Mikko Perttunen , Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian Cc: dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, linux-tegra@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-media@vger.kernel.org, iommu@lists.linux.dev, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH v2 3/3] drm/tegra: Use iommu_paging_domain_alloc() Date: Mon, 2 Sep 2024 09:47:00 +0800 Message-Id: <20240902014700.66095-4-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240902014700.66095-1-baolu.lu@linux.intel.com> References: <20240902014700.66095-1-baolu.lu@linux.intel.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Commit <17de3f5fdd35> ("iommu: Retire bus ops") removes iommu ops from the bus structure. The iommu subsystem no longer relies on bus for operations. So iommu_domain_alloc() interface is no longer relevant. Replace iommu_domain_alloc() with iommu_paging_domain_alloc() which takes the physical device from which the host1x_device virtual device was instantiated. This physical device is a common parent to all physical devices that are part of the virtual device. Suggested-by: Thierry Reding Signed-off-by: Lu Baolu --- drivers/gpu/drm/tegra/drm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c index 03d1c76aec2d..d79c76a287f2 100644 --- a/drivers/gpu/drm/tegra/drm.c +++ b/drivers/gpu/drm/tegra/drm.c @@ -1135,6 +1135,7 @@ static bool host1x_drm_wants_iommu(struct host1x_device *dev) static int host1x_drm_probe(struct host1x_device *dev) { + struct device *dma_dev = dev->dev.parent; struct tegra_drm *tegra; struct drm_device *drm; int err; @@ -1149,8 +1150,8 @@ static int host1x_drm_probe(struct host1x_device *dev) goto put; } - if (host1x_drm_wants_iommu(dev) && iommu_present(&platform_bus_type)) { - tegra->domain = iommu_domain_alloc(&platform_bus_type); + if (host1x_drm_wants_iommu(dev) && device_iommu_mapped(dma_dev)) { + tegra->domain = iommu_paging_domain_alloc(dma_dev); if (!tegra->domain) { err = -ENOMEM; goto free;