From patchwork Thu Jun 28 18:29:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 10494707 X-Patchwork-Delegate: agross@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1F18560230 for ; Thu, 28 Jun 2018 18:29:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1ECE02A762 for ; Thu, 28 Jun 2018 18:29:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 12EA02A782; Thu, 28 Jun 2018 18:29:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 23DF02A762 for ; Thu, 28 Jun 2018 18:29:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030488AbeF1S3W (ORCPT ); Thu, 28 Jun 2018 14:29:22 -0400 Received: from mail-yb0-f196.google.com ([209.85.213.196]:42564 "EHLO mail-yb0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030482AbeF1S3S (ORCPT ); Thu, 28 Jun 2018 14:29:18 -0400 Received: by mail-yb0-f196.google.com with SMTP id i3-v6so2378843ybl.9 for ; Thu, 28 Jun 2018 11:29:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2UmISA1/cJZdiize29rLvsn3hpmNrepq1NesTTn1u5I=; b=OIWBjf74PDKUeqZcBck9+w8nFVpmbak1EV+BYfX0Jq6JINeNEIDw2RRk9wC1PJ8XOB L3qUdEQjCVfAoir1eJHAVfIA0CIsjIplIjQMey9CyxF1obH0Mpza9tJ2tdJElPXbRN8d zMYxLTAOGmvpcPumqj2dqcCgAbbZ2wWqBjHRY= 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; bh=2UmISA1/cJZdiize29rLvsn3hpmNrepq1NesTTn1u5I=; b=PQdSqKMxcU6xSrY74Z3GYQy6bkSWwiPJD8YbQICKFYjyDc+m4vBa0vJOiptgJ+Yh+j suJdjW9+JYgjdAFRwuoiOpltNEsVTUwRmDkFi1uv+N0AAk8KIWfo2fzbOQVmKf6DSPRs s4b+QXba50LBvn1af+GHU7b+FPWz9imauo2AEXgkoa528pw36UNrJGEoVWTRag3NvteI +OiFeStCl8NuRvpxT5cSYI3UA83H4Z9WdMTEGhN7hx6TiBNFF7ArOAyFrG1T1M8s+xDb dCsYgWLVMSmHfYfRT6wTV+0lC6hxn7pA93ARTzqoGn3QUvNe4g34whehz3etRsZZah5g 4xmg== X-Gm-Message-State: APt69E0K1Gk0m+d2srUQnXDere+ojV4DJvLNeq62xZV4PBuO66e/S8Kd t6+35Q22raa/jD12Nb64l7ZK6A== X-Google-Smtp-Source: ADUXVKLkQoQpQF1v8eoE1odgSY9VNtLy5N9cqbTI4hMz84mgyluFZe9l8Tzg6aX4y3ObOmRqDnWBuA== X-Received: by 2002:a25:3d3:: with SMTP id 202-v6mr5593031ybd.123.1530210557068; Thu, 28 Jun 2018 11:29:17 -0700 (PDT) Received: from rosewood.cam.corp.google.com ([2620:0:1013:11:ad55:b1db:adfe:3b9f]) by smtp.gmail.com with ESMTPSA id g145-v6sm2732140ywe.17.2018.06.28.11.29.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 11:29:16 -0700 (PDT) From: Sean Paul To: freedreno@lists.freedesktop.org, linux-arm-msm@vger.kernel.org Cc: robdclark@gmail.com, hoegsberg@chromium.org, jsanka@codeaurora.org, abhinavk@codeaurora.org, Sean Paul Subject: [DPU PATCH 10/15] drm/msm: Remove dpu_kms_fbo and associated functions Date: Thu, 28 Jun 2018 14:29:01 -0400 Message-Id: <20180628182906.84926-11-seanpaul@chromium.org> X-Mailer: git-send-email 2.18.0.rc2.346.g013aa6912e-goog In-Reply-To: <20180628182906.84926-1-seanpaul@chromium.org> References: <20180628182906.84926-1-seanpaul@chromium.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP It's not used anywhere and it lets us revert the changes to msm_fb to match upstream. Signed-off-by: Sean Paul --- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 279 ------------------------ drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h | 69 ------ drivers/gpu/drm/msm/msm_drv.h | 3 - drivers/gpu/drm/msm/msm_fb.c | 4 +- 4 files changed, 3 insertions(+), 352 deletions(-) diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c index 30da3e047384..ddba0873466b 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c @@ -698,134 +698,6 @@ static int _dpu_kms_drm_obj_init(struct dpu_kms *dpu_kms) return ret; } -/** - * struct dpu_kms_fbo_fb - framebuffer creation list - * @list: list of framebuffer attached to framebuffer object - * @fb: Pointer to framebuffer attached to framebuffer object - */ -struct dpu_kms_fbo_fb { - struct list_head list; - struct drm_framebuffer *fb; -}; - -struct drm_framebuffer *dpu_kms_fbo_create_fb(struct drm_device *dev, - struct dpu_kms_fbo *fbo) -{ - struct drm_framebuffer *fb = NULL; - struct dpu_kms_fbo_fb *fbo_fb; - struct drm_mode_fb_cmd2 mode_cmd = {0}; - u32 base_offset = 0; - int i, ret; - - if (!dev) { - DPU_ERROR("invalid drm device node\n"); - return NULL; - } - - fbo_fb = kzalloc(sizeof(struct dpu_kms_fbo_fb), GFP_KERNEL); - if (!fbo_fb) - return NULL; - - mode_cmd.pixel_format = fbo->pixel_format; - mode_cmd.width = fbo->width; - mode_cmd.height = fbo->height; - mode_cmd.flags = fbo->flags; - - for (i = 0; i < fbo->nplane; i++) { - mode_cmd.offsets[i] = base_offset; - mode_cmd.pitches[i] = fbo->layout.plane_pitch[i]; - mode_cmd.modifier[i] = fbo->modifier[i]; - base_offset += fbo->layout.plane_size[i]; - DPU_DEBUG("offset[%d]:%x\n", i, mode_cmd.offsets[i]); - } - - fb = msm_framebuffer_init(dev, &mode_cmd, fbo->bo); - if (IS_ERR(fb)) { - ret = PTR_ERR(fb); - fb = NULL; - DPU_ERROR("failed to allocate fb %d\n", ret); - goto fail; - } - - /* need to take one reference for gem object */ - for (i = 0; i < fbo->nplane; i++) - drm_gem_object_get(fbo->bo[i]); - - DPU_DEBUG("register private fb:%d\n", fb->base.id); - - INIT_LIST_HEAD(&fbo_fb->list); - fbo_fb->fb = fb; - drm_framebuffer_get(fbo_fb->fb); - list_add_tail(&fbo_fb->list, &fbo->fb_list); - - return fb; - -fail: - kfree(fbo_fb); - return NULL; -} - -static void dpu_kms_fbo_destroy(struct dpu_kms_fbo *fbo) -{ - struct msm_drm_private *priv; - struct dpu_kms *dpu_kms; - struct drm_device *dev; - struct dpu_kms_fbo_fb *curr, *next; - int i; - - if (!fbo) { - DPU_ERROR("invalid drm device node\n"); - return; - } - dev = fbo->dev; - - if (!dev || !dev->dev_private) { - DPU_ERROR("invalid drm device node\n"); - return; - } - priv = dev->dev_private; - - if (!priv->kms) { - DPU_ERROR("invalid kms handle\n"); - return; - } - dpu_kms = to_dpu_kms(priv->kms); - - DPU_DEBUG("%dx%d@%c%c%c%c/%llx/%x\n", fbo->width, fbo->height, - fbo->pixel_format >> 0, fbo->pixel_format >> 8, - fbo->pixel_format >> 16, fbo->pixel_format >> 24, - fbo->modifier[0], fbo->flags); - - list_for_each_entry_safe(curr, next, &fbo->fb_list, list) { - DPU_DEBUG("unregister private fb:%d\n", curr->fb->base.id); - drm_framebuffer_unregister_private(curr->fb); - drm_framebuffer_put(curr->fb); - list_del(&curr->list); - kfree(curr); - } - - for (i = 0; i < fbo->layout.num_planes; i++) { - if (fbo->bo[i]) { - mutex_lock(&dev->struct_mutex); - drm_gem_object_put(fbo->bo[i]); - mutex_unlock(&dev->struct_mutex); - fbo->bo[i] = NULL; - } - } - - if (fbo->dma_buf) { - dma_buf_put(fbo->dma_buf); - fbo->dma_buf = NULL; - } - -#ifdef CONFIG_ION - if (dpu_kms->iclient && fbo->ihandle) { - ion_free(dpu_kms->iclient, fbo->ihandle); - fbo->ihandle = NULL; - } -#endif -} - #ifdef CONFIG_ION static void dpu_kms_set_gem_flags(struct msm_gem_object *msm_obj, uint32_t flags) @@ -835,157 +707,6 @@ static void dpu_kms_set_gem_flags(struct msm_gem_object *msm_obj, } #endif -struct dpu_kms_fbo *dpu_kms_fbo_alloc(struct drm_device *dev, u32 width, - u32 height, u32 pixel_format, u64 modifier[4], u32 flags) -{ - struct msm_drm_private *priv; - struct dpu_kms *dpu_kms; - struct dpu_kms_fbo *fbo; - int i, ret; - - if (!dev || !dev->dev_private) { - DPU_ERROR("invalid drm device node\n"); - return NULL; - } - priv = dev->dev_private; - - if (!priv->kms) { - DPU_ERROR("invalid kms handle\n"); - return NULL; - } - dpu_kms = to_dpu_kms(priv->kms); - - DPU_DEBUG("%dx%d@%c%c%c%c/%llx/%x\n", width, height, - pixel_format >> 0, pixel_format >> 8, - pixel_format >> 16, pixel_format >> 24, - modifier[0], flags); - - fbo = kzalloc(sizeof(struct dpu_kms_fbo), GFP_KERNEL); - if (!fbo) - return NULL; - - atomic_set(&fbo->refcount, 0); - INIT_LIST_HEAD(&fbo->fb_list); - fbo->dev = dev; - fbo->width = width; - fbo->height = height; - fbo->pixel_format = pixel_format; - fbo->flags = flags; - for (i = 0; i < ARRAY_SIZE(fbo->modifier); i++) - fbo->modifier[i] = modifier[i]; - fbo->nplane = drm_format_num_planes(fbo->pixel_format); - fbo->fmt = dpu_get_dpu_format_ext(fbo->pixel_format, fbo->modifier[0]); - if (!fbo->fmt) { - ret = -EINVAL; - DPU_ERROR("failed to find pixel format\n"); - goto done; - } - - ret = dpu_format_get_plane_sizes(fbo->fmt, fbo->width, fbo->height, - &fbo->layout, fbo->layout.plane_pitch); - if (ret) { - DPU_ERROR("failed to get plane sizes\n"); - goto done; - } - - /* allocate backing buffer object */ - if (dpu_kms->iclient) { -#ifdef CONFIG_ION - u32 heap_id = ION_HEAP(ION_SYSTEM_HEAP_ID); - - fbo->ihandle = ion_alloc(dpu_kms->iclient, - fbo->layout.total_size, SZ_4K, heap_id, 0); - if (IS_ERR_OR_NULL(fbo->ihandle)) { - DPU_ERROR("failed to alloc ion memory\n"); - ret = PTR_ERR(fbo->ihandle); - fbo->ihandle = NULL; - goto done; - } - - fbo->dma_buf = ion_share_dma_buf(dpu_kms->iclient, - fbo->ihandle); - if (IS_ERR(fbo->dma_buf)) { - DPU_ERROR("failed to share ion memory\n"); - ret = -ENOMEM; - fbo->dma_buf = NULL; - goto done; - } - - fbo->bo[0] = dev->driver->gem_prime_import(dev, - fbo->dma_buf); - if (IS_ERR(fbo->bo[0])) { - DPU_ERROR("failed to import ion memory\n"); - ret = PTR_ERR(fbo->bo[0]); - fbo->bo[0] = NULL; - goto done; - } - - /* insert extra bo flags */ - dpu_kms_set_gem_flags(to_msm_bo(fbo->bo[0]), MSM_BO_KEEPATTRS); -#endif - } else { - fbo->bo[0] = msm_gem_new(dev, fbo->layout.total_size, - MSM_BO_SCANOUT | MSM_BO_WC); - if (IS_ERR(fbo->bo[0])) { - DPU_ERROR("failed to new gem buffer\n"); - ret = PTR_ERR(fbo->bo[0]); - fbo->bo[0] = NULL; - goto done; - } - } - - mutex_lock(&dev->struct_mutex); - for (i = 1; i < fbo->layout.num_planes; i++) { - fbo->bo[i] = fbo->bo[0]; - drm_gem_object_get(fbo->bo[i]); - } - mutex_unlock(&dev->struct_mutex); - -done: - if (ret) { - dpu_kms_fbo_destroy(fbo); - kfree(fbo); - fbo = NULL; - } else { - dpu_kms_fbo_reference(fbo); - } - - return fbo; -} - -int dpu_kms_fbo_reference(struct dpu_kms_fbo *fbo) -{ - if (!fbo) { - DPU_ERROR("invalid parameters\n"); - return -EINVAL; - } - - DPU_DEBUG("%pS refcount:%d\n", __builtin_return_address(0), - atomic_read(&fbo->refcount)); - - atomic_inc(&fbo->refcount); - - return 0; -} - -void dpu_kms_fbo_unreference(struct dpu_kms_fbo *fbo) -{ - if (!fbo) { - DPU_ERROR("invalid parameters\n"); - return; - } - - DPU_DEBUG("%pS refcount:%d\n", __builtin_return_address(0), - atomic_read(&fbo->refcount)); - - if (!atomic_read(&fbo->refcount)) { - DPU_ERROR("invalid refcount\n"); - return; - } else if (atomic_dec_return(&fbo->refcount) == 0) { - dpu_kms_fbo_destroy(fbo); - } -} - #ifdef CONFIG_DEBUG_FS static int dpu_kms_debugfs_init(struct msm_kms *kms, struct drm_minor *minor) { diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h index 4f86a51affdc..6308bd84e6a9 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h @@ -110,37 +110,6 @@ struct dpu_irq { struct dentry *debugfs_file; }; -/** - * struct dpu_kms_fbo - framebuffer memory object - * @refcount: reference/usage count of this object - * @dev: Pointer to containing drm device - * @width: width of the framebuffer - * @height: height of the framebuffer - * @flags: drm framebuffer flags - * @modifier: pixel format modifier of the framebuffer - * @fmt: Pointer to dpu format descriptor - * @layout: dpu format layout descriptor - * @ihandle: framebuffer object ion handle - * @dma_buf: framebuffer object dma buffer - * @bo: per plane buffer object - * @fb_list: llist of fb created from this buffer object - */ -struct dpu_kms_fbo { - atomic_t refcount; - struct drm_device *dev; - u32 width, height; - u32 pixel_format; - u32 flags; - u64 modifier[4]; - int nplane; - const struct dpu_format *fmt; - struct dpu_hw_fmt_layout layout; - struct ion_handle *ihandle; - struct dma_buf *dma_buf; - struct drm_gem_object *bo[4]; - struct list_head fb_list; -}; - struct dpu_kms { struct msm_kms base; struct drm_device *dev; @@ -426,44 +395,6 @@ void dpu_kms_info_stop(struct dpu_kms_info *info); int dpu_enable_vblank(struct msm_kms *kms, struct drm_crtc *crtc); void dpu_disable_vblank(struct msm_kms *kms, struct drm_crtc *crtc); -/** - * dpu_kms_fbo_create_fb - create framebuffer from given framebuffer object - * @dev: Pointer to drm device - * @fbo: Pointer to framebuffer object - * return: Pointer to drm framebuffer on success; NULL on error - */ -struct drm_framebuffer *dpu_kms_fbo_create_fb(struct drm_device *dev, - struct dpu_kms_fbo *fbo); - -/** - * dpu_kms_fbo_alloc - create framebuffer object with given format parameters - * @dev: pointer to drm device - * @width: width of framebuffer - * @height: height of framebuffer - * @pixel_format: pixel format of framebuffer - * @modifier: pixel format modifier - * @flags: DRM_MODE_FB flags - * return: Pointer to framebuffer memory object on success; NULL on error - */ -struct dpu_kms_fbo *dpu_kms_fbo_alloc(struct drm_device *dev, - u32 width, u32 height, u32 pixel_format, - u64 modifiers[4], u32 flags); - -/** - * dpu_kms_fbo_reference - increment reference count of given framebuffer object - * @fbo: Pointer to framebuffer memory object - * return: 0 on success; error code otherwise - */ -int dpu_kms_fbo_reference(struct dpu_kms_fbo *fbo); - -/** - * dpu_kms_fbo_unreference - decrement reference count of given framebuffer - * object - * @fbo: Pointer to framebuffer memory object - * return: 0 on success; error code otherwise - */ -void dpu_kms_fbo_unreference(struct dpu_kms_fbo *fbo); - void dpu_kms_encoder_enable(struct drm_encoder *encoder); /** diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h index 4a2f87fe11a9..c370a962d0a3 100644 --- a/drivers/gpu/drm/msm/msm_drv.h +++ b/drivers/gpu/drm/msm/msm_drv.h @@ -339,9 +339,6 @@ uint32_t msm_framebuffer_iova(struct drm_framebuffer *fb, uint32_t msm_framebuffer_phys(struct drm_framebuffer *fb, int plane); struct drm_gem_object *msm_framebuffer_bo(struct drm_framebuffer *fb, int plane); const struct msm_format *msm_framebuffer_format(struct drm_framebuffer *fb); -struct drm_framebuffer *msm_framebuffer_init(struct drm_device *dev, - const struct drm_mode_fb_cmd2 *mode_cmd, - struct drm_gem_object **bos); struct drm_framebuffer *msm_framebuffer_create(struct drm_device *dev, struct drm_file *file, const struct drm_mode_fb_cmd2 *mode_cmd); struct drm_framebuffer * msm_alloc_stolen_fb(struct drm_device *dev, diff --git a/drivers/gpu/drm/msm/msm_fb.c b/drivers/gpu/drm/msm/msm_fb.c index 32e0f33ff43b..ce604a6ab599 100644 --- a/drivers/gpu/drm/msm/msm_fb.c +++ b/drivers/gpu/drm/msm/msm_fb.c @@ -29,6 +29,8 @@ struct msm_framebuffer { }; #define to_msm_framebuffer(x) container_of(x, struct msm_framebuffer, base) +static struct drm_framebuffer *msm_framebuffer_init(struct drm_device *dev, + const struct drm_mode_fb_cmd2 *mode_cmd, struct drm_gem_object **bos); static int msm_framebuffer_create_handle(struct drm_framebuffer *fb, struct drm_file *file_priv, @@ -161,7 +163,7 @@ struct drm_framebuffer *msm_framebuffer_create(struct drm_device *dev, return ERR_PTR(ret); } -struct drm_framebuffer *msm_framebuffer_init(struct drm_device *dev, +static struct drm_framebuffer *msm_framebuffer_init(struct drm_device *dev, const struct drm_mode_fb_cmd2 *mode_cmd, struct drm_gem_object **bos) { struct msm_drm_private *priv = dev->dev_private;