Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3083317rwb; Mon, 15 Aug 2022 17:43:13 -0700 (PDT) X-Google-Smtp-Source: AA6agR47A0mcM4s/dcMtR4NKeathATBC11/9Y2QWfmebG+Ui7Juzq/H0bF7iCZprvBA0qFpLcxOn X-Received: by 2002:a17:907:6da8:b0:730:8ed5:2df8 with SMTP id sb40-20020a1709076da800b007308ed52df8mr11876916ejc.75.1660610593298; Mon, 15 Aug 2022 17:43:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660610593; cv=none; d=google.com; s=arc-20160816; b=pVY/23jTn53tpS1qp+fkeSFYlKTtczl94FXWEXydFSppiBB1DiZI0H/VCvpqejtyHd N16rRqTiASq2ei/eUuYxFzphEFd8Nplt4haiQh02JEUn8sWA7IleijbdeBZMkvlum+yC 07oqnrcOaBb+ffIO8HWsu+rEzvzUkIWPB/J4cNNcVglnGhfUOmf732R+vuh1MXGQytRb lOHnGo2s3UhfWRtj0xLU7icKfh8kTvOyJdlngyIbVcqNrl10HelYaeNTmjoA0TgVd6X7 86qPuzri3VAaoxKE2tO2yFrKjHhf1vsDYXWsGX6VVwjG8SLcbrtSpBw0M0pCbxfdjD8D cP5Q== 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=37vRYQvqluol5UfhBMiGdlr1NbdU83PSsMeiGbQAlr4=; b=NV7uiOkLoqSRrAyS+KWlQ3eh+y9h2Zk5pDZ+VCKswxVOEbJat0+T9uYyxCOoB9nLec 9Kv6o9yrsEXD3fbklCIXvExoyk7A6Qy6OpMDAWQzjnMEbMdWrIAbnfMuVlCnYvdBjPVY xbJBdZU0l1S02unE/N4i7zOd/ocle4j34hkDo45gvn4kFjOsyOoSPIxnW95vaGPAoNCD l7OsaoadRKu2HGpZAMbqxiyo4uu9SIdUguEIKGSsQ8k5KH5zihHO0CV/fuER39OohCLP ssKd6hYPjVOyg1wIqeumHfSyktAeF8Xb9uBcEpXn25H1If9a4NVb+Xb+0eGIYwJF4s3K yLzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QBBvZXY1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g5-20020aa7d1c5000000b00436c8577a9bsi8269549edp.464.2022.08.15.17.42.48; Mon, 15 Aug 2022 17:43:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QBBvZXY1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S232363AbiHOWNs (ORCPT + 99 others); Mon, 15 Aug 2022 18:13:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349541AbiHOWLb (ORCPT ); Mon, 15 Aug 2022 18:11:31 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D34011B4F3; Mon, 15 Aug 2022 12:38:44 -0700 (PDT) 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 E1CFD60FB9; Mon, 15 Aug 2022 19:38:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CFA23C433C1; Mon, 15 Aug 2022 19:38:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660592322; bh=lVE6si0vEtraGgGv0n6yqWBROaRF84v5MFZZ0BLmqaA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QBBvZXY18a7RN8p3AdGYto241JUo21aZ89m6SwCH+P1blzWte/Kp1zU/dANYBEX4a Ww3mKDiD6xxgBxB7EsZur/R3j/TOUvFl9fPr2xj1vckqt2Cdya6a6TqycDlj7batWG TXNiY6t3sYZLaznaFK5DAP2w/bv+DzRjV4usc9Ko= 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.19 0093/1157] drm/tegra: Fix vmapping of prime buffers Date: Mon, 15 Aug 2022 19:50:49 +0200 Message-Id: <20220815180443.314575317@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dmitry Osipenko commit c7860cbee9989882d2908682526a5ef617523cfe upstream. The code assumes that Tegra GEM is permanently vmapped, which is not true for the scattered buffers. After converting Tegra video decoder driver to V4L API, we're now getting a BUG_ON from dma-buf core on playing video using libvdpau-tegra on T30+ because tegra_gem_prime_vmap() sets vaddr to NULL. Older pre-V4L video decoder driver wasn't vmapping dma-bufs. Fix it by actually vmapping the exported GEMs. Cc: stable@vger.kernel.org Signed-off-by: Dmitry Osipenko Signed-off-by: Thierry Reding Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/tegra/gem.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) --- a/drivers/gpu/drm/tegra/gem.c +++ b/drivers/gpu/drm/tegra/gem.c @@ -704,14 +704,23 @@ static int tegra_gem_prime_vmap(struct d { struct drm_gem_object *gem = buf->priv; struct tegra_bo *bo = to_tegra_bo(gem); + void *vaddr; - iosys_map_set_vaddr(map, bo->vaddr); + vaddr = tegra_bo_mmap(&bo->base); + if (IS_ERR(vaddr)) + return PTR_ERR(vaddr); + + iosys_map_set_vaddr(map, vaddr); return 0; } static void tegra_gem_prime_vunmap(struct dma_buf *buf, struct iosys_map *map) { + struct drm_gem_object *gem = buf->priv; + struct tegra_bo *bo = to_tegra_bo(gem); + + tegra_bo_munmap(&bo->base, map->vaddr); } static const struct dma_buf_ops tegra_gem_prime_dmabuf_ops = {