Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3622062pxb; Mon, 24 Jan 2022 13:43:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJzbBmkB6Yrm1oaw5EA+k0tZFD+YTPlrDL16eHTLJONKpHPPq8QHjo1JL/B9vbQaRVo7Px1v X-Received: by 2002:a05:6a00:1817:b0:4c9:f264:1aa7 with SMTP id y23-20020a056a00181700b004c9f2641aa7mr3281217pfa.13.1643060618251; Mon, 24 Jan 2022 13:43:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643060618; cv=none; d=google.com; s=arc-20160816; b=Jq+aaGgHAFLC/I6DURqFnmao3NcM20fXG6EDELGdseUni15pigJwnDqxIJwP27rh6y TrbqrxAHVPKT8RK3/q7USIB5dljogtt30oZe6J8Hq14eOWcrNgdX+m0Ewmmqv14TdIBW 8jRctLbK8j/AuyjO5ICxqNXNVPpj2sw3+jycHQMDBf8XC5ES19KgvaGs8IJ8NhKAsbl+ ulg4Am2NrPo5SmpH0AUkbzGZkjsvHaNG3KTXd1bIy8qjTGmdtSXG8/AUTczX65i3iQAK gKsX1auR23WBuQRMK+ldotNTdX+H4Hek7+TyCUmIGW4mPFQyWTr4ymJtkNSHf//1PObb I/fg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=+ZzILSWIAdd9AwGl2m611LKcI65L/PMJ4B61oMN0Ej8=; b=Mx+NxGDfKybhyVJLn5DBMMbPYr25N9Rxyru5uDGNRg8jeG3zVa9xY3HQ3Jt7cLyg8L w+p497tAx/rw43CdbU4qmRv7FSUisn0wm7k/ibD64SkYXXJT+RC39BZt1c40+k9iU74N f5206r53VSmDOG7AAr0LuRCjMTiCPS649CuIjuh8cdngvfeBj2lle/6P9C5DhLBMjRs2 Rv7sfcu94ixYc9bB8OnfcqpliqaBsbxU3t0agen7VFqWreAosuO8gQcuiare4H3jfyeo Ztc7uPO2W/i12S6bxeJ+X7AQmFJGd8yLRtD5tSsazK6KcH1vkNDgYUf5tggmVXOtlh5U 4Ntg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sROAMMly; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c18si10789150plh.243.2022.01.24.13.43.21; Mon, 24 Jan 2022 13:43:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sROAMMly; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1451734AbiAXVXa (ORCPT + 99 others); Mon, 24 Jan 2022 16:23:30 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:49266 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1443005AbiAXU4C (ORCPT ); Mon, 24 Jan 2022 15:56:02 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A6CE760B28; Mon, 24 Jan 2022 20:56:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7A97BC340E5; Mon, 24 Jan 2022 20:56:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643057761; bh=RHR1IXkcIgk2HJtIz0MhPowxjEOro65WsiGHJqwdpCQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sROAMMlyhGV786XFkR6DsGBgROVq5paJADlhM8cvnddSV1BWcswERofXqfbvg5q8o eB0R6ZLKjlf90aJRmxa7ag0nLCo9UuR7gUQAdnd6ZdxuiQSqkRabyc0H7rNYwo2apf JtZWYnc5/3RzrF8NLxuvzkJBbPC7uu58sX8QkjdY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dmitry Osipenko , Thierry Reding Subject: [PATCH 5.16 0070/1039] drm/tegra: Add back arm_iommu_detach_device() Date: Mon, 24 Jan 2022 19:30:59 +0100 Message-Id: <20220124184127.526859872@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dmitry Osipenko commit d210919dbdc8a82c676cc3e3c370b1802be63124 upstream. DMA buffers of 2D/3D engines aren't mapped properly when CONFIG_ARM_DMA_USE_IOMMU=y. The memory management code of Tegra DRM driver has a longstanding overhaul overdue and it's not obvious where the problem is in this case. Hence let's add back the old workaround which we already had sometime before. It explicitly detaches DRM devices from the offending implicit IOMMU domain. This fixes a completely broken 2d/3d drivers in case of ARM32 multiplatform kernel config. Cc: stable@vger.kernel.org Fixes: fa6661b7aa0b ("drm/tegra: Optionally attach clients to the IOMMU") Signed-off-by: Dmitry Osipenko Signed-off-by: Thierry Reding Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/tegra/drm.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) --- a/drivers/gpu/drm/tegra/drm.c +++ b/drivers/gpu/drm/tegra/drm.c @@ -21,6 +21,10 @@ #include #include +#if IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU) +#include +#endif + #include "dc.h" #include "drm.h" #include "gem.h" @@ -936,6 +940,17 @@ int host1x_client_iommu_attach(struct ho struct iommu_group *group = NULL; int err; +#if IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU) + if (client->dev->archdata.mapping) { + struct dma_iommu_mapping *mapping = + to_dma_iommu_mapping(client->dev); + arm_iommu_detach_device(client->dev); + arm_iommu_release_mapping(mapping); + + domain = iommu_get_domain_for_dev(client->dev); + } +#endif + /* * If the host1x client is already attached to an IOMMU domain that is * not the shared IOMMU domain, don't try to attach it to a different