Received: by 2002:a05:6500:2018:b0:1fb:9675:f89d with SMTP id t24csp227416lqh; Thu, 30 May 2024 22:06:56 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW26sXVeK6g9RDGAsxe7RgC08A3IudgVOrGNecyYCdFDGi3GeZ8oWzvAj5C1buV9JIwuYkAZ0EjYwOi9KTaugQnRtLf/rRff6ZvjQ7Gkw== X-Google-Smtp-Source: AGHT+IFiEqJ2hfU/XDbC/WBxoKouAg0/Aerd5o5vANGWp43nYeA+x+12JutW9lNbXGRSlzZsYUiz X-Received: by 2002:a05:6358:27a3:b0:199:47ab:d067 with SMTP id e5c5f4694b2df-19b490c4d10mr126580755d.27.1717132016220; Thu, 30 May 2024 22:06:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717132016; cv=pass; d=google.com; s=arc-20160816; b=De3obVl3j2h84S8fwsrJ+2yN1yLTOx0/l5CWeTpvAl3k996qLBgyV69Z3jK5MHxLVq XbqzdXMZpT8R+zzs7sNkHCmU5PcIIeTqVBpIuT61lkqC6+vu+FehF8TZl4yLrHglYeK+ Zl1i1uNvYL3I8rndvvqd8jbE6O4TCAlBg/GLWlAlpp6LVEmtJ1fY2TivuuTmpDjtmxde cPB+qOnZEQgBm/RAAmleE8Rfzj0fCtWKWrO5bSVKMbJn5UP5rPKXeFmF5NwSoO4LWMNa QBnl1d8vPpgmukRg6Cpi/2w+RlI0PtKpg1rhY9DAVByj1R1905k5B2zNO/u3VoawEuNZ zs3w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:cc:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=YMP+MSS+cJVbEI6DDRAbZraP4pswMIha1Xfrl9Idncw=; fh=ja0RdY/59LAVcCMp0MzX6U24NRg4kgA09n+XC1RbAas=; b=BIpNMYR5oFeSks4/85qnsDe6bWTWb6h9veR0L1oenik3q90hJ1XTBqd/lx0Hk3DacO u3fIURUhk9MwqhHCnimkKVYKZ6OAzWFRjGxAvv6R2Nqe4obWSU3RDxDQJvrCT4VS5rzw 8JyB9K8ftuZK9uWrCO3XdaHSwPZpdVyh80Nps4TT8mUhPDe+JePM1fOnHJLlXuMscB3d FTLpkw/1Apeh6GO5z9VR7c3yy4k1Euyzsa+HQGun4Ahbzh0bX4CkuCglwqDTL1vXr8ku Rc+jUtiZuSvdHNcRtszCR9nUSE1Q83fZfcNYFXooM8Dnir1dr3m4I7Ynn0ZCsn9t+cq9 Gpyw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=kmZL7lZl; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-196175-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-196175-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6c35c552770si907491a12.705.2024.05.30.22.06.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 22:06:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-196175-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=kmZL7lZl; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-196175-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-196175-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 1337FB24932 for ; Fri, 31 May 2024 02:00:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4669659164; Fri, 31 May 2024 02:00:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="kmZL7lZl" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.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 E36E357CA6 for ; Fri, 31 May 2024 02:00:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.14 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717120809; cv=none; b=rm/EQpgpv1t9EiFlD+lnFKUrTiKyv3IHvXXE0dXbaDGBHJdJNk7ikxtzhu/yFlZePx9IL0EGogupKAs9MkdU4vHv45ZT7D31seaQQeemu2BCJ2aB0rpwNUIUjGeD7MVMNzrTkIUG/DPxWpQpz+vvlBQ1rPwo4ZlD0IL2OBcrYbs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717120809; c=relaxed/simple; bh=2fUiLAe0vLP2hoMqQ1N3E6uckKGVMNj5dHoJ19Y+sN0=; h=Message-ID:Date:MIME-Version:Cc:Subject:To:References:From: In-Reply-To:Content-Type; b=rCPpCq0kYp+GpCzCUu/bG/FYRLjHmlWs9laS6LtHLgi4RhDBw1LRaA6MAMzjrYMrPlAe55beC2p7dsdOkfINIWEgN+uCoeA9OSa9z/Qn68N5/8TJfBVfvrac2eSeBjZo5+IeX+zqr2KLA6IF5WaXlBdE5ZHlCH6X3Et4Kt5dQ+M= 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=kmZL7lZl; arc=none smtp.client-ip=198.175.65.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=1717120808; x=1748656808; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=2fUiLAe0vLP2hoMqQ1N3E6uckKGVMNj5dHoJ19Y+sN0=; b=kmZL7lZlV2Gm4OBXmcDU1jfoCGjPPJjDYBbJnj+twYdE3LjtyzXcurWQ aS+eZdITfwQXSqRd4BUqxuNNnEBIMyNQaeJ8UqeVWhxYPsIgkwdECDUZi +NMHcYyrZTueDTRlKayHBg44k2V3OJxSoTPkDsyG0CyOn7WPQp2egMDFq TII16fFCDJovpqysA9RT4E7iKMlNpuL12rV9QjWr81FSln8waBARt1lIv u0UyzEQ7EMZB2YFIhGKKu45/0+ZsavHBSqc0/rg817pRtq+rHBDLkfFDR uNX/XGudOGdyF7wakhwTq3SttGgV3blkPEiQaKB6N5azXOT08a70AdLLT A==; X-CSE-ConnectionGUID: CvxAf+ESQWCf4AZBXJ7/XA== X-CSE-MsgGUID: qecW2XQzSHa6cbHmyA0BpQ== X-IronPort-AV: E=McAfee;i="6600,9927,11088"; a="17479951" X-IronPort-AV: E=Sophos;i="6.08,202,1712646000"; d="scan'208";a="17479951" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2024 19:00:08 -0700 X-CSE-ConnectionGUID: U2f5FXHqTNiG/j8alR7vOg== X-CSE-MsgGUID: +b1UL6wJRJyLg9EzJxqHvw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,202,1712646000"; d="scan'208";a="40936569" Received: from unknown (HELO [10.239.159.127]) ([10.239.159.127]) by orviesa005.jf.intel.com with ESMTP; 30 May 2024 19:00:02 -0700 Message-ID: Date: Fri, 31 May 2024 09:57:54 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Cc: baolu.lu@linux.intel.com, Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian , 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 Subject: Re: [PATCH 06/20] drm/msm: Use iommu_paging_domain_alloc() To: Dmitry Baryshkov References: <20240529053250.91284-1-baolu.lu@linux.intel.com> <20240529053250.91284-7-baolu.lu@linux.intel.com> <960bfc23-22b3-48d1-baa6-2707767875c5@linux.intel.com> Content-Language: en-US From: Baolu Lu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 5/30/24 3:58 PM, Dmitry Baryshkov wrote: > On Thu, 30 May 2024 at 04:59, Baolu Lu wrote: >> On 5/29/24 4:21 PM, Dmitry Baryshkov wrote: >>> On Wed, May 29, 2024 at 01:32:36PM +0800, Lu Baolu wrote: >>>> The domain allocated in msm_iommu_new() is for the @dev. Replace >>>> iommu_domain_alloc() with iommu_paging_domain_alloc() to make it explicit. >>>> >>>> Update msm_iommu_new() to always return ERR_PTR in failure cases instead >>>> of NULL. >>> Please don't mix unrelated changes, because ... >>> >>>> Signed-off-by: Lu Baolu >>>> --- >>>> drivers/gpu/drm/msm/msm_iommu.c | 8 ++++---- >>>> 1 file changed, 4 insertions(+), 4 deletions(-) >>>> >>>> diff --git a/drivers/gpu/drm/msm/msm_iommu.c b/drivers/gpu/drm/msm/msm_iommu.c >>>> index d5512037c38b..f7e28d4b5f62 100644 >>>> --- a/drivers/gpu/drm/msm/msm_iommu.c >>>> +++ b/drivers/gpu/drm/msm/msm_iommu.c >>>> @@ -407,9 +407,9 @@ struct msm_mmu *msm_iommu_new(struct device *dev, unsigned long quirks) >>>> struct msm_iommu *iommu; >>>> int ret; >>>> >>>> - domain = iommu_domain_alloc(dev->bus); >>>> - if (!domain) >>>> - return NULL; >>>> + domain = iommu_paging_domain_alloc(dev); >>>> + if (IS_ERR(domain)) >>>> + return ERR_CAST(domain); >>>> >>>> iommu_set_pgtable_quirks(domain, quirks); >>>> >>>> @@ -441,7 +441,7 @@ struct msm_mmu *msm_iommu_gpu_new(struct device *dev, struct msm_gpu *gpu, unsig >>>> struct msm_mmu *mmu; >>>> >>>> mmu = msm_iommu_new(dev, quirks); >>>> - if (IS_ERR_OR_NULL(mmu)) >>>> + if (IS_ERR(mmu)) >>>> return mmu; >>> NAK, not having an IOMMU is a poor but legit usecase for some of devices >>> which don't have IOMMU support yet (for example because of the buggy >>> implementation for which we were not able to get all the hooks in). >>> >>> Please don't break compatibility for existing platforms. >> Sure. I will remove this line of change. Though I have no idea in which >> case msm_iommu_new() could return NULL after this patch. > So, even without this chunk you are going to break the no-IOMMU case. > Please don't. This will result in a regression report and a revert. > > Instead please provide a way for the existing drivers to continue > working. For example, something like: > > if (IS_ERR(mmu) && ERR_PTR(mmu) == -ENODEV)) > return NULL; Oh I see. msm_iommu_new() returning NULL indicates a no-IOMMU case, right? So perhaps we can make it explicit like below? if (!device_iommu_mapped(dev)) return NULL; domain = iommu_paging_domain_alloc(dev); if (IS_ERR(domain)) return ERR_CAST(domain); Best regards, baolu