Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp1137513lqb; Thu, 30 May 2024 00:59:05 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXUEqMzA2k03IHMTYpzbSnVOCbqOufrSO/zQ/xyzDm/MntNcDQfxYEN67WCBw7QdLNzapycO+1MMXSpdZ0nUXh0bY9naurpBVn8UVMOow== X-Google-Smtp-Source: AGHT+IES/YDch3lwAwYkt/xEy0q+arr6pZJUk8Di0lAzqe9onmIF87OAYgbPb1pVSZBF1oZmUW+I X-Received: by 2002:a05:622a:14c8:b0:43d:f99a:3f91 with SMTP id d75a77b69052e-43fe9325464mr16442651cf.65.1717055945149; Thu, 30 May 2024 00:59:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717055945; cv=pass; d=google.com; s=arc-20160816; b=ysgREWRs522x5189Vqz3lA8AB9uQjVmoWiFkgD7Mef0YZtP2hctnyD6Ojs2u37roxW 2uPVa2WOK5vU7tQ2ApAE2n/poAVp7azpawwrjaXD03KWmYSQheO8dgxKSB2STCuRxV6D 0f55TKncs1dFfIecL9oU36/3ejufJ6a4FyYtgPB/qeAJu5X2fi2hV9M0msAMMgzig5pg UASDTomYXs12YSVPMh6QKcUkzqB99xsNb0Qsh1jzpgN55lep9s7NRKVN1CnlMA1ocKVc bmB8+hcq1/Dzf1pfpeS6/NL+gQGSX2L/B7DsmzfutxbPFJ2Oa1ZbL6d3lWI0ymoXvTds Wb1g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=B+oJ9AQU1WwAFE3BTuASvQX6ynujHPOOLDvZ4IBH4iY=; fh=488myhmPSHjFTHY8sru3D7GWsQeY/pwNy91OdOGOh2U=; b=KrZXoxx29Mj4iUf+DbFRpYVOZiBOAEwrnkpl+4FJNWmnmThNMbYUfilTWTS+oIYfzQ wxsDTQQsefrUFfbDW1noVllrsc1RbM4tJStUg/cw0fNL46r4r0pfPQIiMTZzRoKi52ua 8dudpDrOIA2/mYDOnlJ+D1yxSIix+Mg8jkTsVNPKLfpJ/gGbxaRAFl4uyyl1d+GmymVh LboyyJt7qFqJEJZyWvi5gHKGhm2I8E9ovl0ruDzyzlBBbx+ZWG066/eTID/ol3EfZye4 TYzcVWf+/Hwp073YZIUBh9qLquJFtOMlux0Ql25GelxULzcQkRiPeZSuDpdoaavc6OPq KPoQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OYcpfuHv; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-195030-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-195030-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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-43fb5bb2c50si143745081cf.277.2024.05.30.00.59.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 00:59:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-195030-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=@linaro.org header.s=google header.b=OYcpfuHv; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-195030-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-195030-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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 CBF601C20B82 for ; Thu, 30 May 2024 07:59:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 77352143725; Thu, 30 May 2024 07:58:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="OYcpfuHv" Received: from mail-yb1-f175.google.com (mail-yb1-f175.google.com [209.85.219.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E80BA143745 for ; Thu, 30 May 2024 07:58:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717055937; cv=none; b=X34Op5RB0tgo+waxGeh3p/93qIlndQ3atOEeGu0TiUkpZTj28DTcxPFl1khXiVe1oiabKRsKZrGEfc6L7OwwhSoAs22RdaY0S2AQlrJrPwimm9bq1/0SnGCmOFAZohMinrR/1B/kiETiL2BKMKxftEBqKfhUusWIbWKMQXNwjQM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717055937; c=relaxed/simple; bh=lmnS+uhE1B+Xtb3Jn2lTEbYhgqdcwEtClUTNalj/uSg=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=b2l+L9GHzbCN00YSR53D4CfCmB7chF99fKigGOBZkoI5T3XgzsFHt/6JZwyYxrK7H/EHEDna9/Oz6CPBp+wJvxYoTVCjZPwr7qJon+i8eb4yrk6iJ52AwvDtRqHOeC6DNiy/kfN33LfZWRYIDEaQg6lURbsYMNOZeGhjFrcewFY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=OYcpfuHv; arc=none smtp.client-ip=209.85.219.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-yb1-f175.google.com with SMTP id 3f1490d57ef6-dfa4ad7f6dfso509800276.1 for ; Thu, 30 May 2024 00:58:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1717055934; x=1717660734; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=B+oJ9AQU1WwAFE3BTuASvQX6ynujHPOOLDvZ4IBH4iY=; b=OYcpfuHvJsLG9NS5r6X/psJlgl3kfnafKJ0whTUUKQZ0sHiQBy58S7nqpXG2AnmPZw ylfWbVNxeDJT6bW/ycY9P/f/gyG+/GswhHvyYpgpudop+17tkiaa4bvKK44zwyMh1wJp S+jEAquaum+7hglpejr5aEUDXAJau42VULLimhpTTOpelRBop2bLsldst6B/M2XRON4r W5EFVW9aZlRPPYqrPCgb8Tw4QTOX0p3qEIY/K+RHPn0nErIVt+cC82ky+dsJUrWC5mLd QZc1XkWwFGf5WhIYAPfd9Je9mHZD5n8zOvQn7Z0Z6hnAgTkFIWnYufFjzufuARqiNn5R LG5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717055934; x=1717660734; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=B+oJ9AQU1WwAFE3BTuASvQX6ynujHPOOLDvZ4IBH4iY=; b=tEUHspDgt4+ZTcJvpVQrQdheLtta9n4dtXN1EM26yA7Ck6Qq5fb3hVEz9WN+0XYJJ5 OBQW5qtAFQqN1Si8pZDZPdznfpoPM1QKGNDNCIvNpeUuzTQqDK2Vj3YYyth9uFp16z6L MH/ahMiMz6aN883A9f/elVz0Zh4no0iDfLIS50awcMdn6/RsIKd4RKjCe51UUNiOJ/2a vDSJ0tH35sQm5vRTIzezWhegb71wG3C5kAhduPm72EuJue/bekgcSeJ1i40gSbMvQQoz CNV8+f2XdYSkc2PSF63fbKwrqa5QD0tSf1rmYuJxupten5k3pciearoxUgh82RjOaMJl 9/7A== X-Forwarded-Encrypted: i=1; AJvYcCUnKq83PjxEfqcxROOinjnJ1VQa6PBdT6KC44Pyz/FCxG0XKNRSKMho/YkYEI3+umg1EpVVyHqQN3Gj3wNf+N2zLz6yN/5YmYIun6Y7 X-Gm-Message-State: AOJu0Yx2EME/k3c43wQW3xdxkpep3sx51vqdZTsc4la4qL0QMIATCAMy csfRAV6YVnxBHEKP/eWc+3z82A/bOypVJ847s0YczdYVRuiD5k5ODDASJtSQ9u0vUy0II0ikhgI 2INOJQOhPv0JbFwNgiE46i4ahjhaHXxnYpjeg1Q== X-Received: by 2002:a25:2e07:0:b0:de5:558c:e9b9 with SMTP id 3f1490d57ef6-dfa5a5bb588mr1579742276.11.1717055933851; Thu, 30 May 2024 00:58:53 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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> In-Reply-To: <960bfc23-22b3-48d1-baa6-2707767875c5@linux.intel.com> From: Dmitry Baryshkov Date: Thu, 30 May 2024 10:58:42 +0300 Message-ID: Subject: Re: [PATCH 06/20] drm/msm: Use iommu_paging_domain_alloc() To: Baolu Lu Cc: 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 Content-Type: text/plain; charset="UTF-8" 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; -- With best wishes Dmitry