Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp4169954ybe; Mon, 9 Sep 2019 05:28:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqxJZvCS3Xf1SZx1QuNiAjHBmKsOazNBE6XIegBcZ2nTL3CsoSsPDIznH0UwB32d9tqS8Hbd X-Received: by 2002:aa7:da8b:: with SMTP id q11mr23878505eds.19.1568032130831; Mon, 09 Sep 2019 05:28:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568032130; cv=none; d=google.com; s=arc-20160816; b=trEWikcDoTFyuvUjw9p8V82rvn5QE+SWILMwErD/xEPRPyFRbVvshRob8UAgbhJSCs Qw92+Lvj4cTQI+vCOtnJluK5u5VtdS6eGFGzYakX7PSl64tf8zZhXjJGGhhMwvFiv6TG B8+vqLYq6WIGaWtyDq52JOKLAw7TBBzp5umeq55lVp2Bhb/phYzKGP5U3HOs4N0fEMdk PTXzaLL05Nv0Lmk7SQzc+cYeswo7fI0eCT/9kQaWuM5NJbQUcL900W9F12U4d+aDjhzq WUqWTSgO9e52LQGApn/oG5jeZ7YaBFfKdv9Jmu9o+FKxYqO5U6ea4y/jFNv7SV5+936R fF7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vwAxAQbjXJ254wMI5WOsmKWKrflS4Vho3v5vAMLHgnc=; b=0/HkgOXeJaPO8rSmMJHcVHL/ZKgoBMcAWtvIIQb3oeSpOUmDLfn5rfz4wyQMVxvgRg POVP3tfmGSSPJgUCF62+jTl0bG3gd+3pXl+ALp6Z6piWxpqSvYHoLtF/IZtcTdO8bP7G oT9/wnvfmGsTyFdUFXSq9lN8XgLlVQ3j8iHFnHyfYJ8gF2y2Z7VPsyulRoNgTg2Qqpzw KaVp03CTnzzpP4LYEd5yX+CqEBMEpIN8vQqFkeu4QtheVo5QnwAEawEUj0bKE6Sjc6LC H1AJMJaiOb5tqQ3udnxuNJ3/5mNhWk4a9LDknIV5ll+GShz8mWgi6AC9ME6AJa9PZu22 EiNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FvLMX7aH; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h17si8863389edb.89.2019.09.09.05.28.26; Mon, 09 Sep 2019 05:28:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FvLMX7aH; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726566AbfIHM66 (ORCPT + 99 others); Sun, 8 Sep 2019 08:58:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:34398 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730433AbfIHMqi (ORCPT ); Sun, 8 Sep 2019 08:46:38 -0400 Received: from localhost (unknown [62.28.240.114]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BE4F62081B; Sun, 8 Sep 2019 12:46:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567946798; bh=sQ4dfnDcjH8d9tQ+CCUtld6pKau5HKXGqpYZhRRicCM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FvLMX7aHBWutans+0rMzpL/bx6874K36MMI/ofw5MELrnnTC/vUydnP6vqxOnjeB0 w7jAAKWTHeHD7kuSL+85KUgARJ80PzTcOzvMjM3TABwDhVhKd4NFnqQLG/DUrcBjjd vbzLBjsUV2S7sLU2iNcfI70//53ICtjnK+XTMEJA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexandre Courbot , CK Hu , Sasha Levin Subject: [PATCH 4.14 08/40] drm/mediatek: use correct device to import PRIME buffers Date: Sun, 8 Sep 2019 13:41:41 +0100 Message-Id: <20190908121117.957075712@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190908121114.260662089@linuxfoundation.org> References: <20190908121114.260662089@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 4c6f3196e6ea111c456c6086dc3f57d4706b0b2d ] PRIME buffers should be imported using the DMA device. To this end, use a custom import function that mimics drm_gem_prime_import_dev(), but passes the correct device. Fixes: 119f5173628aa ("drm/mediatek: Add DRM Driver for Mediatek SoC MT8173.") Signed-off-by: Alexandre Courbot Signed-off-by: CK Hu Signed-off-by: Sasha Levin --- drivers/gpu/drm/mediatek/mtk_drm_drv.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c index cada1c75c41cd..4a89cd2e4f1c5 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c @@ -287,6 +287,18 @@ static const struct file_operations mtk_drm_fops = { .compat_ioctl = drm_compat_ioctl, }; +/* + * We need to override this because the device used to import the memory is + * not dev->dev, as drm_gem_prime_import() expects. + */ +struct drm_gem_object *mtk_drm_gem_prime_import(struct drm_device *dev, + struct dma_buf *dma_buf) +{ + struct mtk_drm_private *private = dev->dev_private; + + return drm_gem_prime_import_dev(dev, dma_buf, private->dma_dev); +} + static struct drm_driver mtk_drm_driver = { .driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME | DRIVER_ATOMIC, @@ -298,7 +310,7 @@ static struct drm_driver mtk_drm_driver = { .prime_handle_to_fd = drm_gem_prime_handle_to_fd, .prime_fd_to_handle = drm_gem_prime_fd_to_handle, .gem_prime_export = drm_gem_prime_export, - .gem_prime_import = drm_gem_prime_import, + .gem_prime_import = mtk_drm_gem_prime_import, .gem_prime_get_sg_table = mtk_gem_prime_get_sg_table, .gem_prime_import_sg_table = mtk_gem_prime_import_sg_table, .gem_prime_mmap = mtk_drm_gem_mmap_buf, -- 2.20.1