From patchwork Mon Jan 12 06:58:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Kurtz X-Patchwork-Id: 5608311 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D2F51C058D for ; Mon, 12 Jan 2015 06:58:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CC3C720107 for ; Mon, 12 Jan 2015 06:58:50 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id C2FF9200F2 for ; Mon, 12 Jan 2015 06:58:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3F2D56E4A4; Sun, 11 Jan 2015 22:58:47 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pa0-f52.google.com (mail-pa0-f52.google.com [209.85.220.52]) by gabe.freedesktop.org (Postfix) with ESMTP id 5368B6E4A4 for ; Sun, 11 Jan 2015 22:58:46 -0800 (PST) Received: by mail-pa0-f52.google.com with SMTP id eu11so30378876pac.11 for ; Sun, 11 Jan 2015 22:58:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id; bh=94aywr6DLNaimc/gig/ISbhN23e03T2X1XzMWefOic4=; b=XHCcYz2WVUIxwBQaY+3hjrvYYflfMEj8sfZ36nczVkmynBHQDRKB1BQ2wggi+ZAgN/ JyFWO5G3+agP4fYEK4FOU2SvdGffpz4PkDEYB4rB2Y0H3xDcxJuI9ay1d1fVS8dbv9OT wisdqp+kclyI9IYap1A3EtCJWzjAZcisLxGo4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=94aywr6DLNaimc/gig/ISbhN23e03T2X1XzMWefOic4=; b=B8MUv0QifivAGkRuv84YKyipCZdUkY4U86fS1eHGN657A5TtDEbAZ1BK1zEfH+Nqqn QkEKKyRfa4+cX1oMM4B2B+2XkBROzKb95ktgAzUqOgNArX+1eIjPuYL7XySF1UZjVRZC UyBmjR2SGdI10N5qN56Nl70N+H8R3kOXhY1oAFeGA4sixNsphl3aVs+Pa6qPu6VfvWvV PctQ2N1or0EYHRy3URLKpC03rTKSrWQq0ygE+YMGNfCOGfAkZAqWM4vq3gffB+fYHZdo aePaAj/4gbTXZeQhCs96HZnh1iEkijT5orqhX/Lnq6iceVTIMp/YFoxkDUNEJRU1yeRb fd7A== X-Gm-Message-State: ALoCoQk7vO0/YCjTq/2V5Mnr2gOpVtzfz/YFtxl6fARgkyVfVERg6zRcTVV1mno7D79UZcSvfHVN X-Received: by 10.70.6.164 with SMTP id c4mr42016157pda.63.1421045926023; Sun, 11 Jan 2015 22:58:46 -0800 (PST) Received: from djkurtz1.tpe.corp.google.com ([172.30.210.4]) by mx.google.com with ESMTPSA id ob4sm13396390pdb.48.2015.01.11.22.58.42 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 11 Jan 2015 22:58:44 -0800 (PST) From: Daniel Kurtz To: Mark Yao Subject: [PATCH] drm/rockchip: Only alloc a kmap for fbdev gem object Date: Mon, 12 Jan 2015 14:58:23 +0800 Message-Id: <1421045914-26948-1-git-send-email-djkurtz@chromium.org> X-Mailer: git-send-email 2.2.0.rc0.207.ga3a616c Cc: open list , "open list:DRM DRIVERS" X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In general, the data in drm/rockchip GEM objects is never accessed by the kernel. The objects are either accessed by a GPU, by display controller DMA, or by mmap'ing them to user space. Thus, these buffers need not be mapped into kernel address space. The only exception is the fbdev framebuffer(s), which may be written in-kernel by fbcon. Signed-off-by: Daniel Kurtz --- drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c | 2 +- drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 17 ++++++++++++----- drivers/gpu/drm/rockchip/rockchip_drm_gem.h | 3 ++- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c b/drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c index a5d889a8..17d1954 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c @@ -71,7 +71,7 @@ static int rockchip_drm_fbdev_create(struct drm_fb_helper *helper, size = mode_cmd.pitches[0] * mode_cmd.height; - rk_obj = rockchip_gem_create_object(dev, size); + rk_obj = rockchip_gem_create_object(dev, size, true); if (IS_ERR(rk_obj)) return -ENOMEM; diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c index bc98a22..2899385 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c @@ -22,7 +22,8 @@ #include "rockchip_drm_drv.h" #include "rockchip_drm_gem.h" -static int rockchip_gem_alloc_buf(struct rockchip_gem_object *rk_obj) +static int rockchip_gem_alloc_buf(struct rockchip_gem_object *rk_obj, + bool alloc_kmap) { struct drm_gem_object *obj = &rk_obj->base; struct drm_device *drm = obj->dev; @@ -30,7 +31,9 @@ static int rockchip_gem_alloc_buf(struct rockchip_gem_object *rk_obj) init_dma_attrs(&rk_obj->dma_attrs); dma_set_attr(DMA_ATTR_WRITE_COMBINE, &rk_obj->dma_attrs); - /* TODO(djkurtz): Use DMA_ATTR_NO_KERNEL_MAPPING except for fbdev */ + if (!alloc_kmap) + dma_set_attr(DMA_ATTR_NO_KERNEL_MAPPING, &rk_obj->dma_attrs); + rk_obj->kvaddr = dma_alloc_attrs(drm->dev, obj->size, &rk_obj->dma_addr, GFP_KERNEL, &rk_obj->dma_attrs); @@ -106,7 +109,8 @@ int rockchip_gem_mmap(struct file *filp, struct vm_area_struct *vma) } struct rockchip_gem_object * - rockchip_gem_create_object(struct drm_device *drm, unsigned int size) + rockchip_gem_create_object(struct drm_device *drm, unsigned int size, + bool alloc_kmap) { struct rockchip_gem_object *rk_obj; struct drm_gem_object *obj; @@ -122,7 +126,7 @@ struct rockchip_gem_object * drm_gem_private_object_init(drm, obj, size); - ret = rockchip_gem_alloc_buf(rk_obj); + ret = rockchip_gem_alloc_buf(rk_obj, alloc_kmap); if (ret) goto err_free_rk_obj; @@ -166,7 +170,7 @@ rockchip_gem_create_with_handle(struct drm_file *file_priv, struct drm_gem_object *obj; int ret; - rk_obj = rockchip_gem_create_object(drm, size); + rk_obj = rockchip_gem_create_object(drm, size, false); if (IS_ERR(rk_obj)) return ERR_CAST(rk_obj); @@ -285,6 +289,9 @@ void *rockchip_gem_prime_vmap(struct drm_gem_object *obj) { struct rockchip_gem_object *rk_obj = to_rockchip_obj(obj); + if (dma_get_attr(DMA_ATTR_NO_KERNEL_MAPPING, &rk_obj->dma_attrs)) + return NULL; + return rk_obj->kvaddr; } diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.h b/drivers/gpu/drm/rockchip/rockchip_drm_gem.h index 67bcebe..ad22618 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.h +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.h @@ -41,7 +41,8 @@ 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); + rockchip_gem_create_object(struct drm_device *drm, unsigned int size, + bool alloc_kmap); void rockchip_gem_free_object(struct drm_gem_object *obj);