Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3983160pxb; Tue, 25 Jan 2022 00:38:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJwoIq47tWizzOI8lq5uHz5zdIQTzDRtglPZSqJ60VoCis4czJ1CDU6d5O3fwjPU+fQIy07o X-Received: by 2002:a63:904c:: with SMTP id a73mr14562379pge.449.1643099916956; Tue, 25 Jan 2022 00:38:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643099916; cv=none; d=google.com; s=arc-20160816; b=Q3HpsGjEshMhDRntCQGvTa5ujWIctSwITfBYmY2KlR/WoqZstQY1vn15gGf47Jd6Ha J/rC6bLJP3dSihN5YvFjp+cJ6gGqas0HQmAsHHI2Nq/8o8aTWXXNAk4HSupiY5PtUPEY F4Evk15BqaD9XFqVkHy4Pxn5QRZoxzv5QDP6fo21Q+1puRgZvvFxRnS2Oq5A8Lr/nWwJ 49VNA7m94ilR362iw0damPRc60cIduxiMniZrI0BuTe6xcwojMBeDyKRTvkUUbDOHXR8 Y0rC7zbPYQ7yRkLXYjV7P5LgoAE+9tBZXy4iuHsM0YI9dl01gWQeoKUB21RzzvDvtuXt jLIA== 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=vqKsMdI0WuEd6wRuSygVCOE2PWxMoEihSx68DolWemA=; b=Ev2iKwdAaJeZLloCpKsQt+UYusAtvik/iOc/YLIuf744MjrlPj7bPcpqo4ADcAY1DV eopquNeraX6sq6yrUxcFvS7I/jT16w9yBprmByAY2jTF9dKWz6cYiUX4h2uQkT5i9Lic QDi+WNbTsiKjq0qdZUlNhAaMXk0Y/Jrd7n9AH7YtSgllqc81aa6qtm1jh1Xd2iX+gqCE pyAVEWfhzUjlcBx63dwua6Ik7OgqZl64bYsuRbp2EIa8ps684Ww1tzyvx/I2+rybvg2v 4DOaAfeb61FY6JwP2kgYY5pFYcQpKVk3BvEa6q/iUNn86TkojSeanhDKeto9coLZzp09 MmfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JTrEt8S1; 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 y15si14903633plr.199.2022.01.25.00.38.25; Tue, 25 Jan 2022 00:38:36 -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=JTrEt8S1; 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 S235779AbiAYCzr (ORCPT + 99 others); Mon, 24 Jan 2022 21:55:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S3413913AbiAYAlT (ORCPT ); Mon, 24 Jan 2022 19:41:19 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87EFBC06F8C8; Mon, 24 Jan 2022 12:12:57 -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 ams.source.kernel.org (Postfix) with ESMTPS id F0F64B8119E; Mon, 24 Jan 2022 20:12:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2EF8BC340E5; Mon, 24 Jan 2022 20:12:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643055174; bh=JtuOwGjrs+4E0N1ONfB/JKaOLTOJtjSWdNVu1Zx8gZU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JTrEt8S1RokD0kXJRKESv6nS7FYriTAkcgFYnCJbWZmoPi4tgkimcM1mxxIVCySOP ZbzYo7oB9u/s1AEuDn7dzMJxxGY3YpbBlzHR1wWjUXBDqcLa2AfYZkMD8anVvQgUtO R0SzFTnM6VlGRY1BVSds+UbzKFSzy5V6cDA+2774= 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 065/846] gpu: host1x: Add back arm_iommu_detach_device() Date: Mon, 24 Jan 2022 19:33:02 +0100 Message-Id: <20220124184103.206921316@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 d5185965c3b59073c4520bad7dd2adf725b9abba upstream. Host1x DMA buffer isn't mapped properly when CONFIG_ARM_DMA_USE_IOMMU=y. The memory management code of Host1x 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 Host1x device from the offending implicit IOMMU domain. This fixes a completely broken Host1x DMA in case of ARM32 multiplatform kernel config. Cc: stable@vger.kernel.org Fixes: af1cbfb9bf0f ("gpu: host1x: Support DMA mapping of buffers") Signed-off-by: Dmitry Osipenko Signed-off-by: Thierry Reding Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/host1x/dev.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) --- a/drivers/gpu/host1x/dev.c +++ b/drivers/gpu/host1x/dev.c @@ -18,6 +18,10 @@ #include #undef CREATE_TRACE_POINTS +#if IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU) +#include +#endif + #include "bus.h" #include "channel.h" #include "debug.h" @@ -238,6 +242,17 @@ static struct iommu_domain *host1x_iommu struct iommu_domain *domain = iommu_get_domain_for_dev(host->dev); int err; +#if IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU) + if (host->dev->archdata.mapping) { + struct dma_iommu_mapping *mapping = + to_dma_iommu_mapping(host->dev); + arm_iommu_detach_device(host->dev); + arm_iommu_release_mapping(mapping); + + domain = iommu_get_domain_for_dev(host->dev); + } +#endif + /* * We may not always want to enable IOMMU support (for example if the * host1x firewall is already enabled and we don't support addressing