From patchwork Mon Oct 21 21:45:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rob Herring (Arm)" X-Patchwork-Id: 11203061 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E75E2913 for ; Mon, 21 Oct 2019 21:46:35 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C2B9820659 for ; Mon, 21 Oct 2019 21:46:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="kyi/PjOE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C2B9820659 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=KhEaf+hNmDRzNjz/QN+w3WNk5iVrS1hjh93ZfpG/vRI=; b=kyi/PjOEpyjjPJ 7IXqdyTmNqDTGCcLbSZOx17lUlJ7Y9wC0htkDDffqE+gx5cby5htroy3UfxKaKdIjINvT5QKjitiG fsuoF3UDTh9njmawBKUDoX/+PGdCAPNW1KiyGUwVeEgRqN3oweoqWhk4XnAPwz1DSfOfdAsTotw9x th5SSMNpDj0QA5iCBYlIHVq9GLEl2iDnjrtd5RtkctZJ44GZd4NLIGLqBsWNzZ0eGncvuJIafFVrr DOs8tef2iHUP8WWCpi+51KP8H/esrlGts/WNMn4t9S1m2oGUW4rsFdLhf1diqy2/i5AZq/pXtoILg Rvr1ieyuvSoZdnU13RNA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iMfVY-0000lA-1N; Mon, 21 Oct 2019 21:46:32 +0000 Received: from mail-oi1-f196.google.com ([209.85.167.196]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iMfUy-0000CL-Bq; Mon, 21 Oct 2019 21:45:57 +0000 Received: by mail-oi1-f196.google.com with SMTP id k20so12416870oih.3; Mon, 21 Oct 2019 14:45:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nG1jrqiVrLvARMweYNsyPG+j+EFZbDQxRJlgrVpfL4I=; b=VtycW8IzP8a16ec088v9Wa5wOzPnIqXpPHvZq1QwM6EuCXm10+KxTth0leun8lQPM8 KLWjGN3HqMoUJAJh+toSfEx6XwQ0hXN92YJplM4PCJke62yFBUEOkNKAEIdORImon/+/ QMcq1AXsIRJrorpQIBWza0/E3mv8RqgP+bV/Pjl2C/PWNcwrNK0TTgd1w0hgTcaFZFD8 M4nhXTPGNgbwc0P9iPpldP4+Ipm5TBjOSky2F95PIZ+FbmpqeVWtSOyS5jZXB7A38Chk rxV82myZFOEjVnJgrqn0+Z4uZOytABHE9zZChpIHp9JF8YQuyRWAZQTCsVpGssAyOS5V LHOw== X-Gm-Message-State: APjAAAW/rpJR5O7X7moJ4nzpzPrD40lDAObYtZFvS/sX/qndJsKttOO0 IGrF3Si9IoemnQyQgpli8A== X-Google-Smtp-Source: APXvYqz194LkjFFcxBO2leMnWf7q2qSETO24ZDGsm0zsCS7yjuJ9BThF7g7KveiT7DMyfLh8WcF/xA== X-Received: by 2002:aca:40b:: with SMTP id 11mr191900oie.59.1571694355381; Mon, 21 Oct 2019 14:45:55 -0700 (PDT) Received: from xps15.herring.priv (24-155-109-49.dyn.grandenetworks.net. [24.155.109.49]) by smtp.googlemail.com with ESMTPSA id u130sm4122676oib.56.2019.10.21.14.45.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2019 14:45:54 -0700 (PDT) From: Rob Herring To: dri-devel@lists.freedesktop.org Subject: [PATCH 1/6] drm/kirin: Use DRM_GEM_CMA_VMAP_DRIVER_OPS Date: Mon, 21 Oct 2019 16:45:45 -0500 Message-Id: <20191021214550.1461-2-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191021214550.1461-1-robh@kernel.org> References: <20191021214550.1461-1-robh@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191021_144556_401901_241DAF68 X-CRM114-Status: GOOD ( 11.45 ) X-Spam-Score: 0.7 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.167.196 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (robherring2[at]gmail.com) 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit (robherring2[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.167.196 listed in wl.mailspike.net] 0.2 FREEMAIL_FORGED_FROMDOMAIN 2nd level domains in From and EnvelopeFrom freemail headers are different X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Heiko_St=C3=BCbner?= , Neil Armstrong , David Airlie , Liviu Dudau , Sandy Huang , Laurent Pinchart , Benjamin Gaignard , Yannick Fertre , Kevin Hilman , Xinwei Kong , Xinliang Liu , linux-rockchip@lists.infradead.org, Chen-Yu Tsai , =?utf-8?q?Noralf_Tr=C3=B8nnes?= , "James \(Qian\) Wang" , CK Hu , Philipp Zabel , Alexandre Torgue , Chen Feng , Maarten Lankhorst , Maxime Ripard , linux-mediatek@lists.infradead.org, Matthias Brugger , Daniel Vetter , Sean Paul , linux-arm-kernel@lists.infradead.org, Philippe Cornu , Vincent Abriou , Kieran Bingham , Maxime Coquelin , Rongrong Zou Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org drm_gem_cma_dumb_create_internal() is not supposed to be used for .dumb_create directly. drm_gem_cma_dumb_create() should be used instead. If we do that, we might as well convert over to using DRM_GEM_CMA_VMAP_DRIVER_OPS instead. Cc: Xinliang Liu Cc: Rongrong Zou Cc: Xinwei Kong Cc: Chen Feng Cc: David Airlie Cc: Daniel Vetter Signed-off-by: Rob Herring --- drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c index 73cd28a6ea07..490537a1d035 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c @@ -941,16 +941,7 @@ DEFINE_DRM_GEM_CMA_FOPS(ade_fops); static struct drm_driver ade_driver = { .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC, .fops = &ade_fops, - .gem_free_object_unlocked = drm_gem_cma_free_object, - .gem_vm_ops = &drm_gem_cma_vm_ops, - .dumb_create = drm_gem_cma_dumb_create_internal, - .prime_handle_to_fd = drm_gem_prime_handle_to_fd, - .prime_fd_to_handle = drm_gem_prime_fd_to_handle, - .gem_prime_get_sg_table = drm_gem_cma_prime_get_sg_table, - .gem_prime_import_sg_table = drm_gem_cma_prime_import_sg_table, - .gem_prime_vmap = drm_gem_cma_prime_vmap, - .gem_prime_vunmap = drm_gem_cma_prime_vunmap, - .gem_prime_mmap = drm_gem_cma_prime_mmap, + DRM_GEM_CMA_VMAP_DRIVER_OPS, .name = "kirin", .desc = "Hisilicon Kirin620 SoC DRM Driver", From patchwork Mon Oct 21 21:45:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rob Herring (Arm)" X-Patchwork-Id: 11203067 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1B7BD913 for ; Mon, 21 Oct 2019 21:46:54 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id ED53920659 for ; Mon, 21 Oct 2019 21:46:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="XPjHdLhE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ED53920659 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=1EwWrS/aessvb7bZz9AlRn/bd0TnDeBXPo9gqPSKQzY=; b=XPjHdLhEuXbDs0 b1RJwnQQOGk4QNcF2pgv4wJuY4+Pn79HLm837sSlkS22CeOwmLAjIP/Wkn24B+lC/Imtbc0B5DE8w JA3jyJGFEbLAmvmemFQzgV1cumA2ar4edBFuDsrhFHshVQih8YefBh4bTW3xvzrug1BySRm9e1fRS Yy2UAjOW14jbrENWWv1UkT89n3RKKPqUQlM5HdHIFuvrc8AOyoBYKUTFm8V1OOcXTpAGXLMJfYb6M VrUgRQYsIU869mX4eNESL35rIDroPPEkCGmt1YAJ/r6pe12RH26ZHtq+NVXBVw9k/ovayCeHk5nPe LIQLB5W4w9gQdokXzIOQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iMfVr-00012s-3i; Mon, 21 Oct 2019 21:46:51 +0000 Received: from mail-oi1-f195.google.com ([209.85.167.195]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iMfV0-0000D0-6m; Mon, 21 Oct 2019 21:46:00 +0000 Received: by mail-oi1-f195.google.com with SMTP id b25so793033oib.7; Mon, 21 Oct 2019 14:45:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TsrtW/3IwxExUlY3NAEem6qIu9cq5ThxwAPMPnLEB1M=; b=j6uwDb0aBUOnKVp3/h323Eze5VhQ5ZFno80BjVTxkX0TCLvTVGXb1f9NUjkK0RZPZO J2eYPblsRxIWVJXk6kP99Sw0hojiYXdJGxsvo2WtoDK33evkIOWo/WZE0ku6rvzuKNpc 1K9ZbAWz+cmxEqSDFWOHgl4mqVHattFq4vqtlvdZZ9yRlGAcCt1PPrdLzjJSTFiVJ5qU snMsImW5ipHDOQ13xY6seBNj9KoJMs2EPZZc1xmIyNj0dGb+5+qijXg6lqGu/t6A82q5 F/vHuc7p2TcEJ6HgxD2CsbZDyCKNhUVheNDtms+Da+vql7D9rO7OV3GLXo6Fg3apSskI vUKA== X-Gm-Message-State: APjAAAUE+NMtPb7/r7bfrwjJZTw1Xmi5T2IomSjP1Oef19mcb057t1C1 Pd8mfyVuoqb4WnHXhXE9yw== X-Google-Smtp-Source: APXvYqzlUvmVTKM2zNkWI5ewyGDS0Ga/AUXcXwnS+qOaifG3c/ZJADZnnQIk2JtuB+GHcDhGYasXJg== X-Received: by 2002:a54:4182:: with SMTP id 2mr188880oiy.148.1571694357143; Mon, 21 Oct 2019 14:45:57 -0700 (PDT) Received: from xps15.herring.priv (24-155-109-49.dyn.grandenetworks.net. [24.155.109.49]) by smtp.googlemail.com with ESMTPSA id u130sm4122676oib.56.2019.10.21.14.45.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2019 14:45:56 -0700 (PDT) From: Rob Herring To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/6] drm: Introduce DRM_MODE_DUMB_KERNEL_MAP flag Date: Mon, 21 Oct 2019 16:45:46 -0500 Message-Id: <20191021214550.1461-3-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191021214550.1461-1-robh@kernel.org> References: <20191021214550.1461-1-robh@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191021_144558_271114_4817FE14 X-CRM114-Status: GOOD ( 14.75 ) X-Spam-Score: 0.7 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.167.195 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.167.195 listed in wl.mailspike.net] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (robherring2[at]gmail.com) 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit (robherring2[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.2 FREEMAIL_FORGED_FROMDOMAIN 2nd level domains in From and EnvelopeFrom freemail headers are different X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Heiko_St=C3=BCbner?= , Neil Armstrong , David Airlie , Liviu Dudau , Sandy Huang , Laurent Pinchart , Benjamin Gaignard , Yannick Fertre , Kevin Hilman , Xinwei Kong , Xinliang Liu , linux-rockchip@lists.infradead.org, Chen-Yu Tsai , =?utf-8?q?Noralf_Tr=C3=B8nnes?= , "James \(Qian\) Wang" , CK Hu , Philipp Zabel , Alexandre Torgue , Chen Feng , Maarten Lankhorst , Maxime Ripard , linux-mediatek@lists.infradead.org, Matthias Brugger , Daniel Vetter , Sean Paul , linux-arm-kernel@lists.infradead.org, Philippe Cornu , Vincent Abriou , Kieran Bingham , Maxime Coquelin , Rongrong Zou Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org Introduce a new flag, DRM_MODE_DUMB_KERNEL_MAP, for struct drm_mode_create_dumb. This flag is for internal kernel use to indicate if dumb buffer allocation needs a kernel mapping. This is needed only for CMA where creating a kernel mapping or not has to be decided at allocation time because creating a mapping on demand (with vmap()) is not guaranteed to work. Several drivers are using CMA, but not the CMA helpers because they distinguish between kernel and userspace allocations to create a kernel mapping or not. Update the callers of drm_mode_dumb_create() to set drm_mode_dumb_create.flags to appropriate defaults. Currently, flags can be set to anything by userspace, but is unused within the kernel. Let's force flags to zero (no kernel mapping) for userspace callers by default. For in kernel clients, set DRM_MODE_DUMB_KERNEL_MAP by default. Drivers can override this as needed. Cc: David Airlie Cc: Daniel Vetter Cc: Maarten Lankhorst Cc: Maxime Ripard Cc: Sean Paul Signed-off-by: Rob Herring --- drivers/gpu/drm/drm_client.c | 1 + drivers/gpu/drm/drm_dumb_buffers.c | 5 ++++- include/uapi/drm/drm_mode.h | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_client.c b/drivers/gpu/drm/drm_client.c index d9a2e3695525..dbfc8061b392 100644 --- a/drivers/gpu/drm/drm_client.c +++ b/drivers/gpu/drm/drm_client.c @@ -264,6 +264,7 @@ drm_client_buffer_create(struct drm_client_dev *client, u32 width, u32 height, u dumb_args.width = width; dumb_args.height = height; dumb_args.bpp = info->cpp[0] * 8; + dumb_args.flags = DRM_MODE_DUMB_KERNEL_MAP; ret = drm_mode_create_dumb(dev, &dumb_args, client->file); if (ret) goto err_delete; diff --git a/drivers/gpu/drm/drm_dumb_buffers.c b/drivers/gpu/drm/drm_dumb_buffers.c index d18a740fe0f1..74a13f14c173 100644 --- a/drivers/gpu/drm/drm_dumb_buffers.c +++ b/drivers/gpu/drm/drm_dumb_buffers.c @@ -97,7 +97,10 @@ int drm_mode_create_dumb(struct drm_device *dev, int drm_mode_create_dumb_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv) { - return drm_mode_create_dumb(dev, data, file_priv); + struct drm_mode_create_dumb *args = data; + + args->flags = 0; + return drm_mode_create_dumb(dev, args, file_priv); } /** diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h index 735c8cfdaaa1..02712f46b94c 100644 --- a/include/uapi/drm/drm_mode.h +++ b/include/uapi/drm/drm_mode.h @@ -796,6 +796,8 @@ struct drm_mode_crtc_page_flip_target { __u64 user_data; }; +#define DRM_MODE_DUMB_KERNEL_MAP (1<<0) /* For internal kernel use */ + /* create a dumb scanout buffer */ struct drm_mode_create_dumb { __u32 height; From patchwork Mon Oct 21 21:45:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rob Herring (Arm)" X-Patchwork-Id: 11203075 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F405814ED for ; Mon, 21 Oct 2019 21:47:24 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D23C220659 for ; Mon, 21 Oct 2019 21:47:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="clDKd4Zu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D23C220659 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=rwcn6dthG6dPOFt4seLHKaQZiaKwg9wwHdrtQ+fOCVA=; b=clDKd4Zu4ZMn2B YLtobwzqehc4cRwabeK/hpFs/Ud8H+TTaC+sN/AHqgMu146Zw93f29BQOLzBNpY0xtrioT4S3ZGVA wyzZFKyZlM3+YH8T3NB4ona2/mzE1mASE1tmVdGbXo2TTNAEVAVULOMe9uqodrNgM9E1yUJNMoVUD bisV1ziHW4Qwm01R34BZM01uY0guk75ldv72Xd/B/n0R2kC7ovwYMx2IkxjufPOXn+dz4nrczUrda zMuzGSFaqNMVC5MBFtwc5Aombh+o+Uq1fI6KiBgvzVcqszY77oAWDzR3AcM32y8qogNnWlAk2rb3X aP2ZjYdsn1HB6ivtnqog==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iMfWM-0001bA-Nv; Mon, 21 Oct 2019 21:47:22 +0000 Received: from mail-oi1-f194.google.com ([209.85.167.194]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iMfV2-0000FY-H5; Mon, 21 Oct 2019 21:46:02 +0000 Received: by mail-oi1-f194.google.com with SMTP id w6so12381072oie.11; Mon, 21 Oct 2019 14:46:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dtmBYecTmxMYIL93VEKcTUybHl02f54X+UyJdNEnFs0=; b=grVLfjA6uIqqDXQRxq/oROkkGRhOWylVsccMBvzhXpAo7FvKOnwYzHswKk9yuyBtM3 c6VCWBECr6D6nUsUr/RXLgVrAtq9F5HAqbBuCaOxOkNlieHv6g+4u7dZXAFq0citri0b YIoEcqfewbQLGtwuJn7aUu27h1tdW8nElAIUQtzVIaG0LGn3Smg68EmHHkdP8KL0a/Tb 8fKalyvYLm99GFhaoYuStQWvfwGdYEwAK/HQcZrc8091Iqf/pV8yGlfSpKFvpq0ukX8v jAPX8QjBZ0MI8vVikll1KhNfnnb8fjiSkDf9T08iV2sGKqs1rwV6LHGZuxWJyRapSc24 ylFQ== X-Gm-Message-State: APjAAAWAFPOlZkTU2wn7zFKMCLIVyRQdSBTiJIJxHhqwPMhVziYuCGtq g2kvBSV4vvwaAmD5SB4m5Q== X-Google-Smtp-Source: APXvYqyz1m7uoM6wvUfRplSP1iQymDszqO/9xcsWMNqwVBdfqFtz0UeGdkdMsN8oAPMI7ImLHrZS7A== X-Received: by 2002:aca:bd08:: with SMTP id n8mr193003oif.107.1571694359449; Mon, 21 Oct 2019 14:45:59 -0700 (PDT) Received: from xps15.herring.priv (24-155-109-49.dyn.grandenetworks.net. [24.155.109.49]) by smtp.googlemail.com with ESMTPSA id u130sm4122676oib.56.2019.10.21.14.45.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2019 14:45:58 -0700 (PDT) From: Rob Herring To: dri-devel@lists.freedesktop.org Subject: [PATCH 3/6] drm/cma-helper: Use the dma_*_attr API variant Date: Mon, 21 Oct 2019 16:45:47 -0500 Message-Id: <20191021214550.1461-4-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191021214550.1461-1-robh@kernel.org> References: <20191021214550.1461-1-robh@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191021_144600_608706_CEA57D4C X-CRM114-Status: GOOD ( 13.94 ) X-Spam-Score: 0.7 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.167.194 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.167.194 listed in wl.mailspike.net] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (robherring2[at]gmail.com) 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit (robherring2[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.2 FREEMAIL_FORGED_FROMDOMAIN 2nd level domains in From and EnvelopeFrom freemail headers are different X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Heiko_St=C3=BCbner?= , Neil Armstrong , David Airlie , Liviu Dudau , Sandy Huang , Laurent Pinchart , Benjamin Gaignard , Yannick Fertre , Kevin Hilman , Xinwei Kong , Xinliang Liu , linux-rockchip@lists.infradead.org, Chen-Yu Tsai , =?utf-8?q?Noralf_Tr=C3=B8nnes?= , "James \(Qian\) Wang" , CK Hu , Philipp Zabel , Alexandre Torgue , Chen Feng , Maarten Lankhorst , Maxime Ripard , linux-mediatek@lists.infradead.org, Matthias Brugger , Daniel Vetter , Sean Paul , linux-arm-kernel@lists.infradead.org, Philippe Cornu , Vincent Abriou , Kieran Bingham , Maxime Coquelin , Rongrong Zou Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org In preparation to allow DRM CMA users to adjust the DMA_ATTR_* flags, convert the CMA helper code to use the dma_*_attr APIs instead of the dma_*_wc variants. Only the DMA_ATTR_WRITE_COMBINE and DMA_ATTR_NO_WARN attributes are set in this commit, so there's no functional change. Cc: Maarten Lankhorst Cc: Maxime Ripard Cc: Sean Paul Cc: David Airlie Cc: Daniel Vetter Signed-off-by: Rob Herring Reviewed-by: Laurent Pinchart --- drivers/gpu/drm/drm_gem_cma_helper.c | 20 ++++++++++++-------- include/drm/drm_gem_cma_helper.h | 1 + 2 files changed, 13 insertions(+), 8 deletions(-) -- 2.20.1 diff --git a/drivers/gpu/drm/drm_gem_cma_helper.c b/drivers/gpu/drm/drm_gem_cma_helper.c index 12e98fb28229..4cebfe01e6ea 100644 --- a/drivers/gpu/drm/drm_gem_cma_helper.c +++ b/drivers/gpu/drm/drm_gem_cma_helper.c @@ -70,6 +70,7 @@ __drm_gem_cma_create(struct drm_device *drm, size_t size) goto error; } + cma_obj->dma_attrs |= DMA_ATTR_NO_WARN | DMA_ATTR_WRITE_COMBINE; return cma_obj; error: @@ -102,8 +103,9 @@ struct drm_gem_cma_object *drm_gem_cma_create(struct drm_device *drm, if (IS_ERR(cma_obj)) return cma_obj; - cma_obj->vaddr = dma_alloc_wc(drm->dev, size, &cma_obj->paddr, - GFP_KERNEL | __GFP_NOWARN); + cma_obj->vaddr = dma_alloc_attrs(drm->dev, size, &cma_obj->paddr, + GFP_KERNEL | __GFP_NOWARN, + cma_obj->dma_attrs); if (!cma_obj->vaddr) { dev_dbg(drm->dev, "failed to allocate buffer with size %zu\n", size); @@ -184,8 +186,9 @@ void drm_gem_cma_free_object(struct drm_gem_object *gem_obj) dma_buf_vunmap(gem_obj->import_attach->dmabuf, cma_obj->vaddr); drm_prime_gem_destroy(gem_obj, cma_obj->sgt); } else if (cma_obj->vaddr) { - dma_free_wc(gem_obj->dev->dev, cma_obj->base.size, - cma_obj->vaddr, cma_obj->paddr); + dma_free_attrs(gem_obj->dev->dev, cma_obj->base.size, + cma_obj->vaddr, cma_obj->paddr, + cma_obj->dma_attrs); } drm_gem_object_release(gem_obj); @@ -279,8 +282,9 @@ static int drm_gem_cma_mmap_obj(struct drm_gem_cma_object *cma_obj, vma->vm_flags &= ~VM_PFNMAP; vma->vm_pgoff = 0; - ret = dma_mmap_wc(cma_obj->base.dev->dev, vma, cma_obj->vaddr, - cma_obj->paddr, vma->vm_end - vma->vm_start); + ret = dma_mmap_attrs(cma_obj->base.dev->dev, vma, cma_obj->vaddr, + cma_obj->paddr, vma->vm_end - vma->vm_start, + cma_obj->dma_attrs); if (ret) drm_gem_vm_close(vma); @@ -434,8 +438,8 @@ struct sg_table *drm_gem_cma_prime_get_sg_table(struct drm_gem_object *obj) if (!sgt) return ERR_PTR(-ENOMEM); - ret = dma_get_sgtable(obj->dev->dev, sgt, cma_obj->vaddr, - cma_obj->paddr, obj->size); + ret = dma_get_sgtable_attrs(obj->dev->dev, sgt, cma_obj->vaddr, + cma_obj->paddr, obj->size, cma_obj->dma_attrs); if (ret < 0) goto out; diff --git a/include/drm/drm_gem_cma_helper.h b/include/drm/drm_gem_cma_helper.h index 947ac95eb24a..d042213c3595 100644 --- a/include/drm/drm_gem_cma_helper.h +++ b/include/drm/drm_gem_cma_helper.h @@ -24,6 +24,7 @@ struct drm_gem_cma_object { /* For objects with DMA memory allocated by GEM CMA */ void *vaddr; + unsigned long dma_attrs; }; #define to_drm_gem_cma_obj(gem_obj) \ From patchwork Mon Oct 21 21:45:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Rob Herring (Arm)" X-Patchwork-Id: 11203081 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F2F3B913 for ; Mon, 21 Oct 2019 21:48:04 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CDE8E20659 for ; Mon, 21 Oct 2019 21:48:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="amTv1+0d" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CDE8E20659 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=1grdORgba+yxxlwoKabpmys72n+Smfr//0HsHpxNwJ4=; b=amTv1+0dpE6ZWa RbHdZ/aOcNjpUR9PU0IWE7mznNZQq+xgyjGMflY+pa5FBURwtOi+sj6TePtwmF0zfAZfHwfE6rdvi kAYgmrKFQDPdwjjpbGezq9JitnmvZ4mZ8lsjS3nFDviDILqDg0AKf7tka78q1hUGYmgXc4yxNMWw2 5WMf2dY1TEB0/D4jUdze/rhO89nbnaFGdS9i6tMzZ6GdAZL7D3T21IORKSGH1548yZIMScruiJKFe cUZYU1HQ1qLHvXEtzs+3p46xMDX4DC+KpfRxcdItdA5kvAZyOMEjN4igaaL+BMkHSPmMLEQ75K28i hoVsznmD3ojYCHL5dwXQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iMfX0-0002Pk-6K; Mon, 21 Oct 2019 21:48:02 +0000 Received: from mail-ot1-f66.google.com ([209.85.210.66]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iMfV4-0000HV-Fv; Mon, 21 Oct 2019 21:46:05 +0000 Received: by mail-ot1-f66.google.com with SMTP id c7so1602260otm.3; Mon, 21 Oct 2019 14:46:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=v85itWVb55sjk1S2/4vfjQdYVBkEeNhYbZwroc8bhoE=; b=uIEiTwG4Q7c59PocTtnhRKONA17NdISaISmR4179+Wi9ccqDlA6WdiQ9zMPmqBCpk0 +OLNgwHPEfHtPAQnySzuZ/Fds7nj0vWGX1OzSSU9hznoGtbnHUVC7t2iDHVFPkBttbB9 aW8Dgp5ukxmLE7Mm8Q4CYT0VjM87KuoiDocbx1SmqOXBfZMEXKY1tlJIRcSLEDzKGaA9 Jvyd0VQlr5bX8NY3yKiVLi2JWDC4IGpaR6ZTr61AHjHNfK5A07LKhlPwP9VpCztLatl4 pImO25MdHYPU7ZSdTGSMRHqte/zEGFyUaCiqoJdt+DX35CgjGAjCiIbFokztYSoWQBwg uzhA== X-Gm-Message-State: APjAAAUs9xaumcqxBTZWSUDSQViMgOg4TtHn7Wn8r0weIEIQYCDWQ8LT w7QEitRNDtI9OCw+CqDRLA== X-Google-Smtp-Source: APXvYqzkNxCqlFqsK5HBa4boCVhpMxwfWAj66hdD/5mch5qmynl4RhUugcgkNWf4J602suw2X3Zo7Q== X-Received: by 2002:a9d:5c0e:: with SMTP id o14mr57383otk.79.1571694361346; Mon, 21 Oct 2019 14:46:01 -0700 (PDT) Received: from xps15.herring.priv (24-155-109-49.dyn.grandenetworks.net. [24.155.109.49]) by smtp.googlemail.com with ESMTPSA id u130sm4122676oib.56.2019.10.21.14.45.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2019 14:46:00 -0700 (PDT) From: Rob Herring To: dri-devel@lists.freedesktop.org Subject: [PATCH 4/6] drm/cma-helper: Support DRM_MODE_DUMB_KERNEL_MAP flag Date: Mon, 21 Oct 2019 16:45:48 -0500 Message-Id: <20191021214550.1461-5-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191021214550.1461-1-robh@kernel.org> References: <20191021214550.1461-1-robh@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191021_144602_850663_3BC32AC6 X-CRM114-Status: GOOD ( 16.72 ) X-Spam-Score: 0.7 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.210.66 listed in list.dnswl.org] 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.210.66 listed in wl.mailspike.net] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (robherring2[at]gmail.com) 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit (robherring2[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders 0.2 FREEMAIL_FORGED_FROMDOMAIN 2nd level domains in From and EnvelopeFrom freemail headers are different X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Heiko_St=C3=BCbner?= , Neil Armstrong , David Airlie , Liviu Dudau , Sandy Huang , Laurent Pinchart , Benjamin Gaignard , linux-amlogic@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Yannick Fertre , Kevin Hilman , Xinwei Kong , Xinliang Liu , linux-rockchip@lists.infradead.org, Chen-Yu Tsai , =?utf-8?q?Noralf_Tr=C3=B8nnes?= , "James \(Qian\) Wang" , CK Hu , Philipp Zabel , Alexandre Torgue , Chen Feng , Maarten Lankhorst , linux-renesas-soc@vger.kernel.org, Maxime Ripard , linux-mediatek@lists.infradead.org, Matthias Brugger , Daniel Vetter , Sean Paul , linux-arm-kernel@lists.infradead.org, Philippe Cornu , Vincent Abriou , Kieran Bingham , Maxime Coquelin , Rongrong Zou , Brian Starkey Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org Add support in CMA helpers to handle callers specifying DRM_MODE_DUMB_KERNEL_MAP flag. Existing behavior is maintained with this change. drm_gem_cma_dumb_create() always creates a kernel mapping as before. drm_gem_cma_dumb_create_internal() lets the caller set the flags as desired. Therefore, update all the existing callers of drm_gem_cma_dumb_create_internal() to also set the DRM_MODE_DUMB_KERNEL_MAP flag. Cc: Maarten Lankhorst Cc: Maxime Ripard Cc: Sean Paul Cc: David Airlie Cc: Daniel Vetter Cc: "James (Qian) Wang" Cc: Liviu Dudau Cc: Brian Starkey Cc: Neil Armstrong Cc: Kevin Hilman Cc: Laurent Pinchart Cc: Kieran Bingham Cc: Sandy Huang Cc: "Heiko Stübner" Cc: Yannick Fertre Cc: Philippe Cornu Cc: Benjamin Gaignard Cc: Vincent Abriou Cc: Maxime Coquelin Cc: Alexandre Torgue Cc: Chen-Yu Tsai Cc: linux-amlogic@lists.infradead.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-renesas-soc@vger.kernel.org Cc: linux-rockchip@lists.infradead.org Cc: linux-stm32@st-md-mailman.stormreply.com Signed-off-by: Rob Herring Reviewed-by: James Qian Wang (Arm Technology China) Reviewed-by: Neil Armstrong # for drm_gem_cma_helper and meson drm driver Reviewed-by: Laurent Pinchart --- .../gpu/drm/arm/display/komeda/komeda_kms.c | 1 + drivers/gpu/drm/arm/malidp_drv.c | 1 + drivers/gpu/drm/drm_gem_cma_helper.c | 48 +++++++++++-------- drivers/gpu/drm/meson/meson_drv.c | 1 + drivers/gpu/drm/rcar-du/rcar_du_kms.c | 1 + drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 1 + drivers/gpu/drm/stm/drv.c | 1 + drivers/gpu/drm/sun4i/sun4i_drv.c | 1 + 8 files changed, 36 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c index d49772de93e0..7cf0dc4cbfc1 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c +++ b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c @@ -31,6 +31,7 @@ static int komeda_gem_cma_dumb_create(struct drm_file *file, u32 pitch = DIV_ROUND_UP(args->width * args->bpp, 8); args->pitch = ALIGN(pitch, mdev->chip.bus_width); + args->flags = DRM_MODE_DUMB_KERNEL_MAP; return drm_gem_cma_dumb_create_internal(file, dev, args); } diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c index 8a76315aaa0f..aeb1a779ecc1 100644 --- a/drivers/gpu/drm/arm/malidp_drv.c +++ b/drivers/gpu/drm/arm/malidp_drv.c @@ -465,6 +465,7 @@ static int malidp_dumb_create(struct drm_file *file_priv, u8 alignment = malidp_hw_get_pitch_align(malidp->dev, 1); args->pitch = ALIGN(DIV_ROUND_UP(args->width * args->bpp, 8), alignment); + args->flags = DRM_MODE_DUMB_KERNEL_MAP; return drm_gem_cma_dumb_create_internal(file_priv, drm, args); } diff --git a/drivers/gpu/drm/drm_gem_cma_helper.c b/drivers/gpu/drm/drm_gem_cma_helper.c index 4cebfe01e6ea..f91e9e8adeaf 100644 --- a/drivers/gpu/drm/drm_gem_cma_helper.c +++ b/drivers/gpu/drm/drm_gem_cma_helper.c @@ -78,21 +78,8 @@ __drm_gem_cma_create(struct drm_device *drm, size_t size) return ERR_PTR(ret); } -/** - * drm_gem_cma_create - allocate an object with the given size - * @drm: DRM device - * @size: size of the object to allocate - * - * This function creates a CMA GEM object and allocates a contiguous chunk of - * memory as backing store. The backing memory has the writecombine attribute - * set. - * - * Returns: - * A struct drm_gem_cma_object * on success or an ERR_PTR()-encoded negative - * error code on failure. - */ -struct drm_gem_cma_object *drm_gem_cma_create(struct drm_device *drm, - size_t size) +static struct drm_gem_cma_object * +drm_gem_cma_create_flags(struct drm_device *drm, size_t size, u32 flags) { struct drm_gem_cma_object *cma_obj; int ret; @@ -103,6 +90,9 @@ struct drm_gem_cma_object *drm_gem_cma_create(struct drm_device *drm, if (IS_ERR(cma_obj)) return cma_obj; + if (!(flags & DRM_MODE_DUMB_KERNEL_MAP)) + cma_obj->dma_attrs |= DMA_ATTR_NO_KERNEL_MAPPING; + cma_obj->vaddr = dma_alloc_attrs(drm->dev, size, &cma_obj->paddr, GFP_KERNEL | __GFP_NOWARN, cma_obj->dma_attrs); @@ -119,6 +109,25 @@ struct drm_gem_cma_object *drm_gem_cma_create(struct drm_device *drm, drm_gem_object_put_unlocked(&cma_obj->base); return ERR_PTR(ret); } + +/** + * drm_gem_cma_create - allocate an object with the given size + * @drm: DRM device + * @size: size of the object to allocate + * + * This function creates a CMA GEM object and allocates a contiguous chunk of + * memory as backing store. The backing memory has the writecombine attribute + * set. + * + * Returns: + * A struct drm_gem_cma_object * on success or an ERR_PTR()-encoded negative + * error code on failure. + */ +struct drm_gem_cma_object *drm_gem_cma_create(struct drm_device *drm, + size_t size) +{ + return drm_gem_cma_create_flags(drm, size, DRM_MODE_DUMB_KERNEL_MAP); +} EXPORT_SYMBOL_GPL(drm_gem_cma_create); /** @@ -139,14 +148,14 @@ EXPORT_SYMBOL_GPL(drm_gem_cma_create); */ static struct drm_gem_cma_object * drm_gem_cma_create_with_handle(struct drm_file *file_priv, - struct drm_device *drm, size_t size, + struct drm_device *drm, size_t size, u32 flags, uint32_t *handle) { struct drm_gem_cma_object *cma_obj; struct drm_gem_object *gem_obj; int ret; - cma_obj = drm_gem_cma_create(drm, size); + cma_obj = drm_gem_cma_create_flags(drm, size, flags); if (IS_ERR(cma_obj)) return cma_obj; @@ -225,7 +234,7 @@ int drm_gem_cma_dumb_create_internal(struct drm_file *file_priv, args->size = args->pitch * args->height; cma_obj = drm_gem_cma_create_with_handle(file_priv, drm, args->size, - &args->handle); + args->flags, &args->handle); return PTR_ERR_OR_ZERO(cma_obj); } EXPORT_SYMBOL_GPL(drm_gem_cma_dumb_create_internal); @@ -256,9 +265,10 @@ int drm_gem_cma_dumb_create(struct drm_file *file_priv, args->pitch = DIV_ROUND_UP(args->width * args->bpp, 8); args->size = args->pitch * args->height; + args->flags = DRM_MODE_DUMB_KERNEL_MAP; cma_obj = drm_gem_cma_create_with_handle(file_priv, drm, args->size, - &args->handle); + args->flags, &args->handle); return PTR_ERR_OR_ZERO(cma_obj); } EXPORT_SYMBOL_GPL(drm_gem_cma_dumb_create); diff --git a/drivers/gpu/drm/meson/meson_drv.c b/drivers/gpu/drm/meson/meson_drv.c index 397c33182f4f..1593518dcbe4 100644 --- a/drivers/gpu/drm/meson/meson_drv.c +++ b/drivers/gpu/drm/meson/meson_drv.c @@ -81,6 +81,7 @@ static int meson_dumb_create(struct drm_file *file, struct drm_device *dev, */ args->pitch = ALIGN(DIV_ROUND_UP(args->width * args->bpp, 8), SZ_64); args->size = PAGE_ALIGN(args->pitch * args->height); + args->flags = DRM_MODE_DUMB_KERNEL_MAP; return drm_gem_cma_dumb_create_internal(file, dev, args); } diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/rcar-du/rcar_du_kms.c index 2dc9caee8767..c9b1f298ce7e 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c @@ -299,6 +299,7 @@ int rcar_du_dumb_create(struct drm_file *file, struct drm_device *dev, align = 16 * args->bpp / 8; args->pitch = roundup(min_pitch, align); + args->flags = DRM_MODE_DUMB_KERNEL_MAP; return drm_gem_cma_dumb_create_internal(file, dev, args); } diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c index 7582d0e6a60a..f09b9a035376 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c @@ -419,6 +419,7 @@ int rockchip_gem_dumb_create(struct drm_file *file_priv, * align to 64 bytes since Mali requires it. */ args->pitch = ALIGN(min_pitch, 64); + args->flags = DRM_MODE_DUMB_KERNEL_MAP; args->size = args->pitch * args->height; rk_obj = rockchip_gem_create_with_handle(file_priv, dev, args->size, diff --git a/drivers/gpu/drm/stm/drv.c b/drivers/gpu/drm/stm/drv.c index 5a9f9aca8bc2..0f76a4ac95b3 100644 --- a/drivers/gpu/drm/stm/drv.c +++ b/drivers/gpu/drm/stm/drv.c @@ -47,6 +47,7 @@ static int stm_gem_cma_dumb_create(struct drm_file *file, */ args->pitch = roundup(min_pitch, 128); args->height = roundup(args->height, 4); + args->flags = DRM_MODE_DUMB_KERNEL_MAP; return drm_gem_cma_dumb_create_internal(file, dev, args); } diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c b/drivers/gpu/drm/sun4i/sun4i_drv.c index a5757b11b730..f653a5d1e2d6 100644 --- a/drivers/gpu/drm/sun4i/sun4i_drv.c +++ b/drivers/gpu/drm/sun4i/sun4i_drv.c @@ -34,6 +34,7 @@ static int drm_sun4i_gem_dumb_create(struct drm_file *file_priv, { /* The hardware only allows even pitches for YUV buffers. */ args->pitch = ALIGN(DIV_ROUND_UP(args->width * args->bpp, 8), 2); + args->flags = DRM_MODE_DUMB_KERNEL_MAP; return drm_gem_cma_dumb_create_internal(file_priv, drm, args); } From patchwork Mon Oct 21 21:45:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rob Herring (Arm)" X-Patchwork-Id: 11203083 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AE28F913 for ; Mon, 21 Oct 2019 21:48:07 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8887B20659 for ; Mon, 21 Oct 2019 21:48:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="int6D4by" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8887B20659 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=/NiAlVzAuj8ZJtieJ3AGCSMKOapnuLR+6NNZM6nup6M=; b=int6D4byIU/ROU edgdqQr9p+ATZopEaVSyijeQ6zRQ0VpqjaizpImCD7UBfi5xOP/ZFYYjdFykNpTdhZ7RH4LAN772h bvsMHB2r+q+sh0VhR81qQjiTfyaEN+otXarBRiNqblrXRJM9Um/umOQtpCCuaRcOWJsgaaFm/iPfg OqVud3c2ONKlDso6xmyW4ZNv7b80/b3SGgTDD5HJAUgFDjKetiHIDfk/1EQdTM801Pgu+Al0DXc/v TOdwaNRkBDnhTdwmkfZPlwJbOxI/wwcTy/OWT6vpqogMzDZYAlO/LHoxaEuOSTY9J1schONuneLli vWQnJSY4TGM6moQxKNkA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iMfX2-0002Rr-Pd; Mon, 21 Oct 2019 21:48:04 +0000 Received: from mail-ot1-f67.google.com ([209.85.210.67]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iMfV6-0000JL-Di; Mon, 21 Oct 2019 21:46:07 +0000 Received: by mail-ot1-f67.google.com with SMTP id e11so12373826otl.5; Mon, 21 Oct 2019 14:46:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QQDw9NPftsDM5OhHs6ZNOxGtsrxVPosqKf8720sJxbM=; b=UU/4gXVzkca73PEEl1ZezHLkWFrkddXIlFuYG8iiUUcX7+UC5yS+uFPUltu474kmuZ 85GDhHpoXBuJ+bMLd5rbeCNQBCFAvtrBb2ElqWyDijc+xnmZTEQ1mJ4C15j+gWntFfIz YivMrabcSimRiCSTU/u9So63jbPVo4T8gewRBlyy1lX35U6oX0NtMAKNsKLYPiOa8uzM KJdgq/mxiZKzzs6DTEZlvOkTaLWUu5agnMTogxfmCwPXK6Y8MdKw8c2pxx/ZdKDznc0t cQn1+xU9cYoCFjFcU1weyrPTKTn4O9OWUwkS1Z4WfXeWlsYMUwvoJ3i/iWZ8MfaiuilG jxSQ== X-Gm-Message-State: APjAAAV+lGtJEcJI9cdavjOYYv1vmiQR/d8HakZWSO471MN6iSZNM5HC STPW6wyWFUz1DQ3Xub/lIQ== X-Google-Smtp-Source: APXvYqw6b8W3vI30N7gM1+NXuyDoi2C4I2ewSclJeKb4IZyrqQe6H9toYKkWgNpHOdph0+3yURR+Rw== X-Received: by 2002:a9d:344a:: with SMTP id v68mr55638otb.85.1571694363240; Mon, 21 Oct 2019 14:46:03 -0700 (PDT) Received: from xps15.herring.priv (24-155-109-49.dyn.grandenetworks.net. [24.155.109.49]) by smtp.googlemail.com with ESMTPSA id u130sm4122676oib.56.2019.10.21.14.46.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2019 14:46:02 -0700 (PDT) From: Rob Herring To: dri-devel@lists.freedesktop.org Subject: [PATCH 5/6] drm/mediatek: Convert to use CMA helpers Date: Mon, 21 Oct 2019 16:45:49 -0500 Message-Id: <20191021214550.1461-6-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191021214550.1461-1-robh@kernel.org> References: <20191021214550.1461-1-robh@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191021_144604_481693_D1DCF7B1 X-CRM114-Status: GOOD ( 23.61 ) X-Spam-Score: 0.7 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.210.67 listed in list.dnswl.org] 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.210.67 listed in wl.mailspike.net] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (robherring2[at]gmail.com) 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit (robherring2[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders 0.2 FREEMAIL_FORGED_FROMDOMAIN 2nd level domains in From and EnvelopeFrom freemail headers are different X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Heiko_St=C3=BCbner?= , Neil Armstrong , David Airlie , Liviu Dudau , Sandy Huang , Laurent Pinchart , Benjamin Gaignard , Yannick Fertre , Kevin Hilman , Xinwei Kong , Xinliang Liu , linux-rockchip@lists.infradead.org, Chen-Yu Tsai , =?utf-8?q?Noralf_Tr=C3=B8nnes?= , "James \(Qian\) Wang" , CK Hu , Philipp Zabel , Alexandre Torgue , Chen Feng , Maarten Lankhorst , Maxime Ripard , linux-mediatek@lists.infradead.org, Matthias Brugger , Daniel Vetter , Sean Paul , linux-arm-kernel@lists.infradead.org, Philippe Cornu , Vincent Abriou , Kieran Bingham , Maxime Coquelin , Rongrong Zou Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org The only reason the Mediatek driver doesn't use the CMA helpers is it sets DMA_ATTR_NO_KERNEL_MAPPING and does a vmap() on demand. Using vmap() is not even guaranteed to work as DMA buffers may not have a struct page. Now that the CMA helpers support setting DMA_ATTR_NO_KERNEL_MAPPING as needed or not, convert Mediatek driver to use CMA helpers. Cc: CK Hu Cc: Philipp Zabel Cc: David Airlie Cc: Daniel Vetter Cc: Matthias Brugger Cc: linux-arm-kernel@lists.infradead.org Cc: linux-mediatek@lists.infradead.org Signed-off-by: Rob Herring --- drivers/gpu/drm/mediatek/Makefile | 1 - drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 2 +- drivers/gpu/drm/mediatek/mtk_drm_drv.c | 28 +-- drivers/gpu/drm/mediatek/mtk_drm_fb.c | 1 - drivers/gpu/drm/mediatek/mtk_drm_gem.c | 289 ----------------------- drivers/gpu/drm/mediatek/mtk_drm_gem.h | 51 ---- drivers/gpu/drm/mediatek/mtk_drm_plane.c | 7 +- 7 files changed, 15 insertions(+), 364 deletions(-) delete mode 100644 drivers/gpu/drm/mediatek/mtk_drm_gem.c delete mode 100644 drivers/gpu/drm/mediatek/mtk_drm_gem.h diff --git a/drivers/gpu/drm/mediatek/Makefile b/drivers/gpu/drm/mediatek/Makefile index 82ae49c64221..50a50e86738f 100644 --- a/drivers/gpu/drm/mediatek/Makefile +++ b/drivers/gpu/drm/mediatek/Makefile @@ -8,7 +8,6 @@ mediatek-drm-y := mtk_disp_color.o \ mtk_drm_ddp_comp.o \ mtk_drm_drv.o \ mtk_drm_fb.o \ - mtk_drm_gem.o \ mtk_drm_plane.o \ mtk_dsi.o \ mtk_mipi_tx.o \ diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c index 34a731755791..638d57e8ac12 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c @@ -11,6 +11,7 @@ #include #include +#include #include #include @@ -18,7 +19,6 @@ #include "mtk_drm_crtc.h" #include "mtk_drm_ddp.h" #include "mtk_drm_ddp_comp.h" -#include "mtk_drm_gem.h" #include "mtk_drm_plane.h" /** diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c index 352b81a7a670..36f32507e5fb 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c @@ -28,7 +28,6 @@ #include "mtk_drm_ddp_comp.h" #include "mtk_drm_drv.h" #include "mtk_drm_fb.h" -#include "mtk_drm_gem.h" #define DRIVER_NAME "mediatek" #define DRIVER_DESC "Mediatek SoC DRM" @@ -335,16 +334,14 @@ static void mtk_drm_kms_deinit(struct drm_device *drm) drm_mode_config_cleanup(drm); } -static const struct file_operations mtk_drm_fops = { - .owner = THIS_MODULE, - .open = drm_open, - .release = drm_release, - .unlocked_ioctl = drm_ioctl, - .mmap = mtk_drm_gem_mmap, - .poll = drm_poll, - .read = drm_read, - .compat_ioctl = drm_compat_ioctl, -}; +DEFINE_DRM_GEM_CMA_FOPS(mtk_drm_fops); + +static int mtk_drm_gem_dumb_create(struct drm_file *file_priv, + struct drm_device *dev, + struct drm_mode_create_dumb *args) +{ + return drm_gem_cma_dumb_create_internal(file_priv, dev, args); +} /* * We need to override this because the device used to import the memory is @@ -361,18 +358,15 @@ struct drm_gem_object *mtk_drm_gem_prime_import(struct drm_device *dev, static struct drm_driver mtk_drm_driver = { .driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_ATOMIC, - .gem_free_object_unlocked = mtk_drm_gem_free_object, .gem_vm_ops = &drm_gem_cma_vm_ops, + .gem_create_object = drm_cma_gem_create_object_default_funcs, .dumb_create = mtk_drm_gem_dumb_create, .prime_handle_to_fd = drm_gem_prime_handle_to_fd, .prime_fd_to_handle = drm_gem_prime_fd_to_handle, .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, - .gem_prime_vmap = mtk_drm_gem_prime_vmap, - .gem_prime_vunmap = mtk_drm_gem_prime_vunmap, + .gem_prime_import_sg_table = drm_gem_cma_prime_import_sg_table_vmap, + .gem_prime_mmap = drm_gem_prime_mmap, .fops = &mtk_drm_fops, .name = DRIVER_NAME, diff --git a/drivers/gpu/drm/mediatek/mtk_drm_fb.c b/drivers/gpu/drm/mediatek/mtk_drm_fb.c index 3f230a28a2dc..596b4d5ed002 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_fb.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_fb.c @@ -14,7 +14,6 @@ #include "mtk_drm_drv.h" #include "mtk_drm_fb.h" -#include "mtk_drm_gem.h" static const struct drm_framebuffer_funcs mtk_drm_fb_funcs = { .create_handle = drm_gem_fb_create_handle, diff --git a/drivers/gpu/drm/mediatek/mtk_drm_gem.c b/drivers/gpu/drm/mediatek/mtk_drm_gem.c deleted file mode 100644 index ca672f1d140d..000000000000 --- a/drivers/gpu/drm/mediatek/mtk_drm_gem.c +++ /dev/null @@ -1,289 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* - * Copyright (c) 2015 MediaTek Inc. - */ - -#include - -#include -#include -#include -#include - -#include "mtk_drm_drv.h" -#include "mtk_drm_gem.h" - -static struct mtk_drm_gem_obj *mtk_drm_gem_init(struct drm_device *dev, - unsigned long size) -{ - struct mtk_drm_gem_obj *mtk_gem_obj; - int ret; - - size = round_up(size, PAGE_SIZE); - - mtk_gem_obj = kzalloc(sizeof(*mtk_gem_obj), GFP_KERNEL); - if (!mtk_gem_obj) - return ERR_PTR(-ENOMEM); - - ret = drm_gem_object_init(dev, &mtk_gem_obj->base, size); - if (ret < 0) { - DRM_ERROR("failed to initialize gem object\n"); - kfree(mtk_gem_obj); - return ERR_PTR(ret); - } - - return mtk_gem_obj; -} - -struct mtk_drm_gem_obj *mtk_drm_gem_create(struct drm_device *dev, - size_t size, bool alloc_kmap) -{ - struct mtk_drm_private *priv = dev->dev_private; - struct mtk_drm_gem_obj *mtk_gem; - struct drm_gem_object *obj; - int ret; - - mtk_gem = mtk_drm_gem_init(dev, size); - if (IS_ERR(mtk_gem)) - return ERR_CAST(mtk_gem); - - obj = &mtk_gem->base; - - mtk_gem->dma_attrs = DMA_ATTR_WRITE_COMBINE; - - if (!alloc_kmap) - mtk_gem->dma_attrs |= DMA_ATTR_NO_KERNEL_MAPPING; - - mtk_gem->cookie = dma_alloc_attrs(priv->dma_dev, obj->size, - &mtk_gem->dma_addr, GFP_KERNEL, - mtk_gem->dma_attrs); - if (!mtk_gem->cookie) { - DRM_ERROR("failed to allocate %zx byte dma buffer", obj->size); - ret = -ENOMEM; - goto err_gem_free; - } - - if (alloc_kmap) - mtk_gem->kvaddr = mtk_gem->cookie; - - DRM_DEBUG_DRIVER("cookie = %p dma_addr = %pad size = %zu\n", - mtk_gem->cookie, &mtk_gem->dma_addr, - size); - - return mtk_gem; - -err_gem_free: - drm_gem_object_release(obj); - kfree(mtk_gem); - return ERR_PTR(ret); -} - -void mtk_drm_gem_free_object(struct drm_gem_object *obj) -{ - struct mtk_drm_gem_obj *mtk_gem = to_mtk_gem_obj(obj); - struct mtk_drm_private *priv = obj->dev->dev_private; - - if (mtk_gem->sg) - drm_prime_gem_destroy(obj, mtk_gem->sg); - else - dma_free_attrs(priv->dma_dev, obj->size, mtk_gem->cookie, - mtk_gem->dma_addr, mtk_gem->dma_attrs); - - /* release file pointer to gem object. */ - drm_gem_object_release(obj); - - kfree(mtk_gem); -} - -int mtk_drm_gem_dumb_create(struct drm_file *file_priv, struct drm_device *dev, - struct drm_mode_create_dumb *args) -{ - struct mtk_drm_gem_obj *mtk_gem; - int ret; - - args->pitch = DIV_ROUND_UP(args->width * args->bpp, 8); - args->size = args->pitch * args->height; - - mtk_gem = mtk_drm_gem_create(dev, args->size, false); - if (IS_ERR(mtk_gem)) - return PTR_ERR(mtk_gem); - - /* - * allocate a id of idr table where the obj is registered - * and handle has the id what user can see. - */ - ret = drm_gem_handle_create(file_priv, &mtk_gem->base, &args->handle); - if (ret) - goto err_handle_create; - - /* drop reference from allocate - handle holds it now. */ - drm_gem_object_put_unlocked(&mtk_gem->base); - - return 0; - -err_handle_create: - mtk_drm_gem_free_object(&mtk_gem->base); - return ret; -} - -static int mtk_drm_gem_object_mmap(struct drm_gem_object *obj, - struct vm_area_struct *vma) - -{ - int ret; - struct mtk_drm_gem_obj *mtk_gem = to_mtk_gem_obj(obj); - struct mtk_drm_private *priv = obj->dev->dev_private; - - /* - * dma_alloc_attrs() allocated a struct page table for mtk_gem, so clear - * VM_PFNMAP flag that was set by drm_gem_mmap_obj()/drm_gem_mmap(). - */ - vma->vm_flags &= ~VM_PFNMAP; - - ret = dma_mmap_attrs(priv->dma_dev, vma, mtk_gem->cookie, - mtk_gem->dma_addr, obj->size, mtk_gem->dma_attrs); - if (ret) - drm_gem_vm_close(vma); - - return ret; -} - -int mtk_drm_gem_mmap_buf(struct drm_gem_object *obj, struct vm_area_struct *vma) -{ - int ret; - - ret = drm_gem_mmap_obj(obj, obj->size, vma); - if (ret) - return ret; - - return mtk_drm_gem_object_mmap(obj, vma); -} - -int mtk_drm_gem_mmap(struct file *filp, struct vm_area_struct *vma) -{ - struct drm_gem_object *obj; - int ret; - - ret = drm_gem_mmap(filp, vma); - if (ret) - return ret; - - obj = vma->vm_private_data; - - /* - * Set vm_pgoff (used as a fake buffer offset by DRM) to 0 and map the - * whole buffer from the start. - */ - vma->vm_pgoff = 0; - - return mtk_drm_gem_object_mmap(obj, vma); -} - -/* - * Allocate a sg_table for this GEM object. - * Note: Both the table's contents, and the sg_table itself must be freed by - * the caller. - * Returns a pointer to the newly allocated sg_table, or an ERR_PTR() error. - */ -struct sg_table *mtk_gem_prime_get_sg_table(struct drm_gem_object *obj) -{ - struct mtk_drm_gem_obj *mtk_gem = to_mtk_gem_obj(obj); - struct mtk_drm_private *priv = obj->dev->dev_private; - struct sg_table *sgt; - int ret; - - sgt = kzalloc(sizeof(*sgt), GFP_KERNEL); - if (!sgt) - return ERR_PTR(-ENOMEM); - - ret = dma_get_sgtable_attrs(priv->dma_dev, sgt, mtk_gem->cookie, - mtk_gem->dma_addr, obj->size, - mtk_gem->dma_attrs); - if (ret) { - DRM_ERROR("failed to allocate sgt, %d\n", ret); - kfree(sgt); - return ERR_PTR(ret); - } - - return sgt; -} - -struct drm_gem_object *mtk_gem_prime_import_sg_table(struct drm_device *dev, - struct dma_buf_attachment *attach, struct sg_table *sg) -{ - struct mtk_drm_gem_obj *mtk_gem; - int ret; - struct scatterlist *s; - unsigned int i; - dma_addr_t expected; - - mtk_gem = mtk_drm_gem_init(dev, attach->dmabuf->size); - - if (IS_ERR(mtk_gem)) - return ERR_CAST(mtk_gem); - - expected = sg_dma_address(sg->sgl); - for_each_sg(sg->sgl, s, sg->nents, i) { - if (sg_dma_address(s) != expected) { - DRM_ERROR("sg_table is not contiguous"); - ret = -EINVAL; - goto err_gem_free; - } - expected = sg_dma_address(s) + sg_dma_len(s); - } - - mtk_gem->dma_addr = sg_dma_address(sg->sgl); - mtk_gem->sg = sg; - - return &mtk_gem->base; - -err_gem_free: - kfree(mtk_gem); - return ERR_PTR(ret); -} - -void *mtk_drm_gem_prime_vmap(struct drm_gem_object *obj) -{ - struct mtk_drm_gem_obj *mtk_gem = to_mtk_gem_obj(obj); - struct sg_table *sgt; - struct sg_page_iter iter; - unsigned int npages; - unsigned int i = 0; - - if (mtk_gem->kvaddr) - return mtk_gem->kvaddr; - - sgt = mtk_gem_prime_get_sg_table(obj); - if (IS_ERR(sgt)) - return NULL; - - npages = obj->size >> PAGE_SHIFT; - mtk_gem->pages = kcalloc(npages, sizeof(*mtk_gem->pages), GFP_KERNEL); - if (!mtk_gem->pages) - goto out; - - for_each_sg_page(sgt->sgl, &iter, sgt->orig_nents, 0) { - mtk_gem->pages[i++] = sg_page_iter_page(&iter); - if (i > npages) - break; - } - mtk_gem->kvaddr = vmap(mtk_gem->pages, npages, VM_MAP, - pgprot_writecombine(PAGE_KERNEL)); - -out: - kfree((void *)sgt); - - return mtk_gem->kvaddr; -} - -void mtk_drm_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr) -{ - struct mtk_drm_gem_obj *mtk_gem = to_mtk_gem_obj(obj); - - if (!mtk_gem->pages) - return; - - vunmap(vaddr); - mtk_gem->kvaddr = 0; - kfree((void *)mtk_gem->pages); -} diff --git a/drivers/gpu/drm/mediatek/mtk_drm_gem.h b/drivers/gpu/drm/mediatek/mtk_drm_gem.h deleted file mode 100644 index ff9f976d9807..000000000000 --- a/drivers/gpu/drm/mediatek/mtk_drm_gem.h +++ /dev/null @@ -1,51 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* - * Copyright (c) 2015 MediaTek Inc. - */ - -#ifndef _MTK_DRM_GEM_H_ -#define _MTK_DRM_GEM_H_ - -#include - -/* - * mtk drm buffer structure. - * - * @base: a gem object. - * - a new handle to this gem object would be created - * by drm_gem_handle_create(). - * @cookie: the return value of dma_alloc_attrs(), keep it for dma_free_attrs() - * @kvaddr: kernel virtual address of gem buffer. - * @dma_addr: dma address of gem buffer. - * @dma_attrs: dma attributes of gem buffer. - * - * P.S. this object would be transferred to user as kms_bo.handle so - * user can access the buffer through kms_bo.handle. - */ -struct mtk_drm_gem_obj { - struct drm_gem_object base; - void *cookie; - void *kvaddr; - dma_addr_t dma_addr; - unsigned long dma_attrs; - struct sg_table *sg; - struct page **pages; -}; - -#define to_mtk_gem_obj(x) container_of(x, struct mtk_drm_gem_obj, base) - -void mtk_drm_gem_free_object(struct drm_gem_object *gem); -struct mtk_drm_gem_obj *mtk_drm_gem_create(struct drm_device *dev, size_t size, - bool alloc_kmap); -int mtk_drm_gem_dumb_create(struct drm_file *file_priv, struct drm_device *dev, - struct drm_mode_create_dumb *args); -int mtk_drm_gem_mmap(struct file *filp, struct vm_area_struct *vma); -int mtk_drm_gem_mmap_buf(struct drm_gem_object *obj, - struct vm_area_struct *vma); -struct sg_table *mtk_gem_prime_get_sg_table(struct drm_gem_object *obj); -struct drm_gem_object *mtk_gem_prime_import_sg_table(struct drm_device *dev, - struct dma_buf_attachment *attach, struct sg_table *sg); -void *mtk_drm_gem_prime_vmap(struct drm_gem_object *obj); -void mtk_drm_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr); - -#endif diff --git a/drivers/gpu/drm/mediatek/mtk_drm_plane.c b/drivers/gpu/drm/mediatek/mtk_drm_plane.c index 584a9ecadce6..8f256602f075 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_plane.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_plane.c @@ -8,13 +8,14 @@ #include #include #include +#include +#include #include #include "mtk_drm_crtc.h" #include "mtk_drm_ddp_comp.h" #include "mtk_drm_drv.h" #include "mtk_drm_fb.h" -#include "mtk_drm_gem.h" #include "mtk_drm_plane.h" static const u32 formats[] = { @@ -108,7 +109,6 @@ static void mtk_plane_atomic_update(struct drm_plane *plane, struct drm_crtc *crtc = plane->state->crtc; struct drm_framebuffer *fb = plane->state->fb; struct drm_gem_object *gem; - struct mtk_drm_gem_obj *mtk_gem; unsigned int pitch, format; dma_addr_t addr; @@ -116,8 +116,7 @@ static void mtk_plane_atomic_update(struct drm_plane *plane, return; gem = fb->obj[0]; - mtk_gem = to_mtk_gem_obj(gem); - addr = mtk_gem->dma_addr; + addr = to_drm_gem_cma_obj(gem)->paddr; pitch = fb->pitches[0]; format = fb->format->format; From patchwork Mon Oct 21 21:45:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Rob Herring (Arm)" X-Patchwork-Id: 11203085 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 64CDC14ED for ; Mon, 21 Oct 2019 21:48:08 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3F5D120659 for ; Mon, 21 Oct 2019 21:48:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="frYtskqg" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3F5D120659 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=8/IAogX1Ev/ctsg4i4H2GQ7skSoY/QfGx5Vz6abN8tE=; b=frYtskqgFKtDl8 zZGicw95JG1eTxLbp9VOg+arDyyw4RlpicduL+klkC/8SC7AShCqBkRY+zyzkrln0R7/Q6dpUJgGm QOtju68MMSqeuTVx5azdh1vVgq/pjQSqjdXLLs0nQhzJKyDB2jMUMPxpIHFVDFW8dJHSn/eik/ar0 gVuxirN6YUobfmpjEg7QO11RmBiy2GLdhwGj1VG9iWasQVtjHMB7ym3N/ifMtAKqoDXVt56HCBGd8 oslRCaiiLiaGS4qwcfpma2JxN8gNS/mItCiymAgtKpdHaSCyUUPyIBbObQ28hWqnltC8DDzJU29iL U9Am6DZPnJ6PhdBjrsxw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iMfX4-0002TS-Ey; Mon, 21 Oct 2019 21:48:06 +0000 Received: from mail-ot1-f67.google.com ([209.85.210.67]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iMfV8-0000LA-Rq; Mon, 21 Oct 2019 21:46:09 +0000 Received: by mail-ot1-f67.google.com with SMTP id s22so12367799otr.6; Mon, 21 Oct 2019 14:46:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PYPtBAV4HvBXyxpYafYBRi+ornFWpusKrf/ucuegk3I=; b=lY9ss3hxff0Cj4DGHVN5MXSBOikb3qjYrt4OOyYU1ywifOHNfnfDbx4i50R2NpE17P /djnaxaxk2UcgZPpNpSGmaRGL8VsoQgsUEp9AY1vQwpI1v7F+Rfnlc0lImptBXN677Ps Os7VxB2ZFcHIXYudmFv6RnkivzsJoVsUu2zcsK9o1zqm6gzCN+7ukUTXdFwcJo06JQQo v/oVvfic0TDFDTCrxG6Rak/jztzJCJWpW6MUiVQH+STjH/EYfb09t7YMJj2FMCIszqGa jRLwMcta4TusI1DyyQDmXqhgRT6O21M6a/PqPgBvmC4LiHIVUGhvbRllDk18kAoxx4fl vEyw== X-Gm-Message-State: APjAAAXTkiI6INKXFLbqQ8BwI6py8pkwZ+aXvG2Mya3KRmR7Qf81hqnB nH0TlNjbwdUySuDBcW9Qjw== X-Google-Smtp-Source: APXvYqyPVAk1vvCG+w3iQXoxcyNVQkKK0BmP34FPQyqqEpA2ioCZ2qzql1ZGNMWvTbmLVyE+nVV4Cw== X-Received: by 2002:a9d:6f07:: with SMTP id n7mr89656otq.8.1571694365138; Mon, 21 Oct 2019 14:46:05 -0700 (PDT) Received: from xps15.herring.priv (24-155-109-49.dyn.grandenetworks.net. [24.155.109.49]) by smtp.googlemail.com with ESMTPSA id u130sm4122676oib.56.2019.10.21.14.46.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2019 14:46:04 -0700 (PDT) From: Rob Herring To: dri-devel@lists.freedesktop.org Subject: [PATCH 6/6] drm/rockchip: Convert to use generic fbdev emulation Date: Mon, 21 Oct 2019 16:45:50 -0500 Message-Id: <20191021214550.1461-7-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191021214550.1461-1-robh@kernel.org> References: <20191021214550.1461-1-robh@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191021_144607_062505_BE81867C X-CRM114-Status: GOOD ( 23.70 ) X-Spam-Score: 0.7 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.210.67 listed in list.dnswl.org] 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.210.67 listed in wl.mailspike.net] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (robherring2[at]gmail.com) 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit (robherring2[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders 0.2 FREEMAIL_FORGED_FROMDOMAIN 2nd level domains in From and EnvelopeFrom freemail headers are different X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Heiko_St=C3=BCbner?= , Neil Armstrong , David Airlie , Liviu Dudau , Sandy Huang , Laurent Pinchart , Benjamin Gaignard , Yannick Fertre , Kevin Hilman , Xinwei Kong , Xinliang Liu , linux-rockchip@lists.infradead.org, Chen-Yu Tsai , =?utf-8?q?Noralf_Tr=C3=B8nnes?= , "James \(Qian\) Wang" , CK Hu , Philipp Zabel , Alexandre Torgue , Chen Feng , Maarten Lankhorst , Maxime Ripard , linux-mediatek@lists.infradead.org, Matthias Brugger , Daniel Vetter , Sean Paul , linux-arm-kernel@lists.infradead.org, Philippe Cornu , Vincent Abriou , Kieran Bingham , Maxime Coquelin , Rongrong Zou Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org Now that we have the DRM_MODE_DUMB_KERNEL_MAP flag to indicate whether or not a kernel mapping is required, the Rockchip driver can be converted to using the generic fbdev emulation. This patch makes full use of the generic fbdev emulation by using its drm_client callbacks. This means that drm_mode_config_funcs->output_poll_changed and drm_driver->lastclose are now handled by the emulation code. Additionally fbdev unregister happens automatically on drm_dev_unregister(). The drm_fbdev_generic_setup() call is put after drm_dev_register() in the driver. This is done to highlight the fact that fbdev emulation is an internal client that makes use of the driver, it is not part of the driver as such. If fbdev setup fails, an error is printed, but the driver succeeds probing. Cc: Noralf Trønnes Cc: Sandy Huang Cc: "Heiko Stübner" Cc: David Airlie Cc: Daniel Vetter Cc: linux-arm-kernel@lists.infradead.org Cc: linux-rockchip@lists.infradead.org Signed-off-by: Rob Herring --- drivers/gpu/drm/rockchip/Makefile | 1 - drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 10 +- drivers/gpu/drm/rockchip/rockchip_drm_drv.h | 2 - drivers/gpu/drm/rockchip/rockchip_drm_fb.c | 14 -- drivers/gpu/drm/rockchip/rockchip_drm_fb.h | 6 - drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c | 170 ------------------ drivers/gpu/drm/rockchip/rockchip_drm_fbdev.h | 24 --- drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 5 +- drivers/gpu/drm/rockchip/rockchip_drm_gem.h | 4 - 9 files changed, 6 insertions(+), 230 deletions(-) delete mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c delete mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.h diff --git a/drivers/gpu/drm/rockchip/Makefile b/drivers/gpu/drm/rockchip/Makefile index 17a9e7eb2130..1a56f696558c 100644 --- a/drivers/gpu/drm/rockchip/Makefile +++ b/drivers/gpu/drm/rockchip/Makefile @@ -5,7 +5,6 @@ rockchipdrm-y := rockchip_drm_drv.o rockchip_drm_fb.o \ rockchip_drm_gem.o rockchip_drm_vop.o rockchip_vop_reg.o -rockchipdrm-$(CONFIG_DRM_FBDEV_EMULATION) += rockchip_drm_fbdev.o rockchipdrm-$(CONFIG_ROCKCHIP_ANALOGIX_DP) += analogix_dp-rockchip.o rockchipdrm-$(CONFIG_ROCKCHIP_CDN_DP) += cdn-dp-core.o cdn-dp-reg.o diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c index 20ecb1508a22..95a489c481d5 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c @@ -25,7 +25,6 @@ #include "rockchip_drm_drv.h" #include "rockchip_drm_fb.h" -#include "rockchip_drm_fbdev.h" #include "rockchip_drm_gem.h" #define DRIVER_NAME "rockchip" @@ -156,10 +155,6 @@ static int rockchip_drm_bind(struct device *dev) */ drm_dev->irq_enabled = true; - ret = rockchip_drm_fbdev_init(drm_dev); - if (ret) - goto err_unbind_all; - /* init kms poll for handling hpd */ drm_kms_helper_poll_init(drm_dev); @@ -167,10 +162,11 @@ static int rockchip_drm_bind(struct device *dev) if (ret) goto err_kms_helper_poll_fini; + drm_fbdev_generic_setup(drm_dev, 32); + return 0; err_kms_helper_poll_fini: drm_kms_helper_poll_fini(drm_dev); - rockchip_drm_fbdev_fini(drm_dev); err_unbind_all: component_unbind_all(dev, drm_dev); err_mode_config_cleanup: @@ -189,7 +185,6 @@ static void rockchip_drm_unbind(struct device *dev) drm_dev_unregister(drm_dev); - rockchip_drm_fbdev_fini(drm_dev); drm_kms_helper_poll_fini(drm_dev); drm_atomic_helper_shutdown(drm_dev); @@ -215,7 +210,6 @@ static const struct file_operations rockchip_drm_driver_fops = { static struct drm_driver rockchip_drm_driver = { .driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_ATOMIC, - .lastclose = drm_fb_helper_lastclose, .gem_vm_ops = &drm_gem_cma_vm_ops, .gem_free_object_unlocked = rockchip_gem_free_object, .dumb_create = rockchip_gem_dumb_create, diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h index c5b06048124e..397d6582aabe 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h @@ -42,8 +42,6 @@ struct rockchip_crtc_state { * @mm_lock: protect drm_mm on multi-threads. */ struct rockchip_drm_private { - struct drm_fb_helper fbdev_helper; - struct drm_gem_object *fbdev_bo; struct iommu_domain *domain; struct mutex mm_lock; struct drm_mm mm; diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c index ca01234c037c..2c01074b0d3c 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c @@ -116,20 +116,6 @@ static const struct drm_mode_config_funcs rockchip_drm_mode_config_funcs = { .atomic_commit = drm_atomic_helper_commit, }; -struct drm_framebuffer * -rockchip_drm_framebuffer_init(struct drm_device *dev, - const struct drm_mode_fb_cmd2 *mode_cmd, - struct drm_gem_object *obj) -{ - struct drm_framebuffer *fb; - - fb = rockchip_fb_alloc(dev, mode_cmd, &obj, 1); - if (IS_ERR(fb)) - return ERR_CAST(fb); - - return fb; -} - void rockchip_drm_mode_config_init(struct drm_device *dev) { dev->mode_config.min_width = 0; diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_fb.h b/drivers/gpu/drm/rockchip/rockchip_drm_fb.h index 1a696521096d..bae4e079dfb1 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_fb.h +++ b/drivers/gpu/drm/rockchip/rockchip_drm_fb.h @@ -7,11 +7,5 @@ #ifndef _ROCKCHIP_DRM_FB_H #define _ROCKCHIP_DRM_FB_H -struct drm_framebuffer * -rockchip_drm_framebuffer_init(struct drm_device *dev, - const struct drm_mode_fb_cmd2 *mode_cmd, - struct drm_gem_object *obj); -void rockchip_drm_framebuffer_fini(struct drm_framebuffer *fb); - void rockchip_drm_mode_config_init(struct drm_device *dev); #endif /* _ROCKCHIP_DRM_FB_H */ diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c b/drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c deleted file mode 100644 index 02be6c5ff857..000000000000 --- a/drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c +++ /dev/null @@ -1,170 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* - * Copyright (C) Fuzhou Rockchip Electronics Co.Ltd - * Author:Mark Yao - */ - -#include -#include -#include -#include - -#include "rockchip_drm_drv.h" -#include "rockchip_drm_gem.h" -#include "rockchip_drm_fb.h" -#include "rockchip_drm_fbdev.h" - -#define PREFERRED_BPP 32 -#define to_drm_private(x) \ - container_of(x, struct rockchip_drm_private, fbdev_helper) - -static int rockchip_fbdev_mmap(struct fb_info *info, - struct vm_area_struct *vma) -{ - struct drm_fb_helper *helper = info->par; - struct rockchip_drm_private *private = to_drm_private(helper); - - return rockchip_gem_mmap_buf(private->fbdev_bo, vma); -} - -static struct fb_ops rockchip_drm_fbdev_ops = { - .owner = THIS_MODULE, - DRM_FB_HELPER_DEFAULT_OPS, - .fb_mmap = rockchip_fbdev_mmap, - .fb_fillrect = drm_fb_helper_cfb_fillrect, - .fb_copyarea = drm_fb_helper_cfb_copyarea, - .fb_imageblit = drm_fb_helper_cfb_imageblit, -}; - -static int rockchip_drm_fbdev_create(struct drm_fb_helper *helper, - struct drm_fb_helper_surface_size *sizes) -{ - struct rockchip_drm_private *private = to_drm_private(helper); - struct drm_mode_fb_cmd2 mode_cmd = { 0 }; - struct drm_device *dev = helper->dev; - struct rockchip_gem_object *rk_obj; - struct drm_framebuffer *fb; - unsigned int bytes_per_pixel; - unsigned long offset; - struct fb_info *fbi; - size_t size; - int ret; - - bytes_per_pixel = DIV_ROUND_UP(sizes->surface_bpp, 8); - - mode_cmd.width = sizes->surface_width; - mode_cmd.height = sizes->surface_height; - mode_cmd.pitches[0] = sizes->surface_width * bytes_per_pixel; - mode_cmd.pixel_format = drm_mode_legacy_fb_format(sizes->surface_bpp, - sizes->surface_depth); - - size = mode_cmd.pitches[0] * mode_cmd.height; - - rk_obj = rockchip_gem_create_object(dev, size, true); - if (IS_ERR(rk_obj)) - return -ENOMEM; - - private->fbdev_bo = &rk_obj->base; - - fbi = drm_fb_helper_alloc_fbi(helper); - if (IS_ERR(fbi)) { - DRM_DEV_ERROR(dev->dev, "Failed to create framebuffer info.\n"); - ret = PTR_ERR(fbi); - goto out; - } - - helper->fb = rockchip_drm_framebuffer_init(dev, &mode_cmd, - private->fbdev_bo); - if (IS_ERR(helper->fb)) { - DRM_DEV_ERROR(dev->dev, - "Failed to allocate DRM framebuffer.\n"); - ret = PTR_ERR(helper->fb); - goto out; - } - - fbi->fbops = &rockchip_drm_fbdev_ops; - - fb = helper->fb; - drm_fb_helper_fill_info(fbi, helper, sizes); - - offset = fbi->var.xoffset * bytes_per_pixel; - offset += fbi->var.yoffset * fb->pitches[0]; - - dev->mode_config.fb_base = 0; - fbi->screen_base = rk_obj->kvaddr + offset; - fbi->screen_size = rk_obj->base.size; - fbi->fix.smem_len = rk_obj->base.size; - - DRM_DEBUG_KMS("FB [%dx%d]-%d kvaddr=%p offset=%ld size=%zu\n", - fb->width, fb->height, fb->format->depth, - rk_obj->kvaddr, - offset, size); - - return 0; - -out: - rockchip_gem_free_object(&rk_obj->base); - return ret; -} - -static const struct drm_fb_helper_funcs rockchip_drm_fb_helper_funcs = { - .fb_probe = rockchip_drm_fbdev_create, -}; - -int rockchip_drm_fbdev_init(struct drm_device *dev) -{ - struct rockchip_drm_private *private = dev->dev_private; - struct drm_fb_helper *helper; - int ret; - - if (!dev->mode_config.num_crtc || !dev->mode_config.num_connector) - return -EINVAL; - - helper = &private->fbdev_helper; - - drm_fb_helper_prepare(dev, helper, &rockchip_drm_fb_helper_funcs); - - ret = drm_fb_helper_init(dev, helper, ROCKCHIP_MAX_CONNECTOR); - if (ret < 0) { - DRM_DEV_ERROR(dev->dev, - "Failed to initialize drm fb helper - %d.\n", - ret); - return ret; - } - - ret = drm_fb_helper_single_add_all_connectors(helper); - if (ret < 0) { - DRM_DEV_ERROR(dev->dev, - "Failed to add connectors - %d.\n", ret); - goto err_drm_fb_helper_fini; - } - - ret = drm_fb_helper_initial_config(helper, PREFERRED_BPP); - if (ret < 0) { - DRM_DEV_ERROR(dev->dev, - "Failed to set initial hw config - %d.\n", - ret); - goto err_drm_fb_helper_fini; - } - - return 0; - -err_drm_fb_helper_fini: - drm_fb_helper_fini(helper); - return ret; -} - -void rockchip_drm_fbdev_fini(struct drm_device *dev) -{ - struct rockchip_drm_private *private = dev->dev_private; - struct drm_fb_helper *helper; - - helper = &private->fbdev_helper; - - drm_fb_helper_unregister_fbi(helper); - - if (helper->fb) - drm_framebuffer_put(helper->fb); - - drm_fb_helper_fini(helper); -} diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_fbdev.h b/drivers/gpu/drm/rockchip/rockchip_drm_fbdev.h deleted file mode 100644 index 5fb7ac2371a8..000000000000 --- a/drivers/gpu/drm/rockchip/rockchip_drm_fbdev.h +++ /dev/null @@ -1,24 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* - * Copyright (C) Fuzhou Rockchip Electronics Co.Ltd - * Author:Mark Yao - */ - -#ifndef _ROCKCHIP_DRM_FBDEV_H -#define _ROCKCHIP_DRM_FBDEV_H - -#ifdef CONFIG_DRM_FBDEV_EMULATION -int rockchip_drm_fbdev_init(struct drm_device *dev); -void rockchip_drm_fbdev_fini(struct drm_device *dev); -#else -static inline int rockchip_drm_fbdev_init(struct drm_device *dev) -{ - return 0; -} - -static inline void rockchip_drm_fbdev_fini(struct drm_device *dev) -{ -} -#endif - -#endif /* _ROCKCHIP_DRM_FBDEV_H */ diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c index f09b9a035376..0562d7e30af5 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c @@ -370,13 +370,14 @@ void rockchip_gem_free_object(struct drm_gem_object *obj) static struct rockchip_gem_object * rockchip_gem_create_with_handle(struct drm_file *file_priv, struct drm_device *drm, unsigned int size, + bool alloc_kmap, unsigned int *handle) { struct rockchip_gem_object *rk_obj; struct drm_gem_object *obj; int ret; - rk_obj = rockchip_gem_create_object(drm, size, false); + rk_obj = rockchip_gem_create_object(drm, size, alloc_kmap); if (IS_ERR(rk_obj)) return ERR_CAST(rk_obj); @@ -414,6 +415,7 @@ int rockchip_gem_dumb_create(struct drm_file *file_priv, { struct rockchip_gem_object *rk_obj; int min_pitch = DIV_ROUND_UP(args->width * args->bpp, 8); + bool alloc_kmap = args->flags & DRM_MODE_DUMB_KERNEL_MAP; /* * align to 64 bytes since Mali requires it. @@ -423,6 +425,7 @@ int rockchip_gem_dumb_create(struct drm_file *file_priv, args->size = args->pitch * args->height; rk_obj = rockchip_gem_create_with_handle(file_priv, dev, args->size, + alloc_kmap, &args->handle); return PTR_ERR_OR_ZERO(rk_obj); diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.h b/drivers/gpu/drm/rockchip/rockchip_drm_gem.h index 7ffc541bea07..3a2e7065ab13 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.h +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.h @@ -41,10 +41,6 @@ int rockchip_gem_mmap(struct file *filp, struct vm_area_struct *vma); int rockchip_gem_mmap_buf(struct drm_gem_object *obj, struct vm_area_struct *vma); -struct rockchip_gem_object * - rockchip_gem_create_object(struct drm_device *drm, unsigned int size, - bool alloc_kmap); - void rockchip_gem_free_object(struct drm_gem_object *obj); int rockchip_gem_dumb_create(struct drm_file *file_priv,