Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3635483pxb; Mon, 24 Jan 2022 14:04:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJyWFOhqtIegMblFcgJkDkVG5kvjU6fVK3IKJBD+txwdkouP7oFQhUKiuekfZOND5KRWvaHC X-Received: by 2002:aa7:9f5c:0:b0:4c8:fc66:e4a1 with SMTP id h28-20020aa79f5c000000b004c8fc66e4a1mr7083875pfr.22.1643061862741; Mon, 24 Jan 2022 14:04:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643061862; cv=none; d=google.com; s=arc-20160816; b=d/buTjJwcQjRreN3QiynJZA2SK0DPGp9tYdZQGXxlGGbfKNeMg517MTbT3HBprt/Q9 KtKKL8oVc52903jkBWknoSvEMzvZ8Rfyz9a4VjA4UKB5TRW9nCkRk7PZkgSGM9o0u47U 745MsVh+q0GMWJDOnRn0LBfyzTqytOvcwZ/ikv22j/NCfv4UpeT/LJr7O7I/VnAc+m0w A7Ug7exyVZ55p6bSmzZ1mbpQZnWlgnBaw2ecuqEHAfHA+flbD5yvI63UekSxYiOwlUQN Sa3PMS/2GtcTMxyvb85tI0FVIaCWdb1lsWE5i3AkhGunxpsw8Xn4/NYjpnEHclcl0KRp OBXg== 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=YQvAbt3cnQecI0xw/PsB2gdemCdowkfmgw8i4TbN7QwisLtR1YAa9hreJ7k5QmcQzh /BVwKoJwvMnaO3R97KD33yx9PMYaOv/CkH0wG9lbCzJgXHJYA5vTZR1h2iDxMwEOjWE2 yN6XTtvl+4198vOTRWcCIxEOjP+4K+Cf/dn6Z3sNGp59JVfHIfmZzZ/WqHakLvBJPw6h 90v21zh031kBQ2sn45deMkvjFooqunvQeiM4bcpM0KwdlRydokeM8DQSTFHJSTIy/D93 AGUK718ApT1Kfh9y3cvihpe4dW69iIYngNOjsuhp28Pun12h6p0z3O9SsCZD9hAyOmpe wDhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IVcLS4Ml; 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 j191si10514921pge.528.2022.01.24.14.04.10; Mon, 24 Jan 2022 14:04:22 -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=IVcLS4Ml; 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 S1575928AbiAXVwo (ORCPT + 99 others); Mon, 24 Jan 2022 16:52:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351988AbiAXVTB (ORCPT ); Mon, 24 Jan 2022 16:19:01 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9B1BC06F8CB; Mon, 24 Jan 2022 12:12:58 -0800 (PST) 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 7A0EB61375; Mon, 24 Jan 2022 20:12:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 56FCAC340E7; Mon, 24 Jan 2022 20:12:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643055177; bh=RHR1IXkcIgk2HJtIz0MhPowxjEOro65WsiGHJqwdpCQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IVcLS4MlqI9lBDZAkRptHIUKQq26FuWR9YmaM8shZek6anmde8LOyBz9DefcdSf4l plZzyVbPbSa2vHv5fkBQLusP0IY0BqcfF6BIcmG15yAk3bk7C6h+gWK50W/7hY+sA4 jbzv1atBlFIVOlm7jEbSlOrXeOSpnFQGeL1ea4co= 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.15 066/846] drm/tegra: Add back arm_iommu_detach_device() Date: Mon, 24 Jan 2022 19:33:03 +0100 Message-Id: <20220124184103.245035526@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@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