Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp723840pxb; Mon, 25 Oct 2021 17:29:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJymh2+8kPalpFmsmon+39/UadLVAqqy9f/9U8jMOzscFuG962IcXLbu2szweegDNyuim9+6 X-Received: by 2002:a17:90b:1bce:: with SMTP id oa14mr39412526pjb.225.1635208177650; Mon, 25 Oct 2021 17:29:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635208177; cv=none; d=google.com; s=arc-20160816; b=npiU7VnYgPIxMhyJGEQn2oaGko/Cwcr4uLi6DQNJuaiCoQ68v0jcGSiIV5MshnX8vi /NTL1EZiAFkJNc8YkzSnXZzxkoZLI7aLZX7FgS7JjaLmD3Wx61Mavy83rNExe4G3woKY +VR6U2yopDEbDI4qC6+milDDwmgHqSjq9iHSkXfy35QlGplblmxDkAIaqYPiTw/o4FJr LgVQXw36RlEUZML5vRyPjHX0yWmwWb3QE3ppPtFkUTqNC+CRSHSqO6JN7ffY54XAUCCA +NluG1iW51jtLGf3VP6sObbVgkpXgw11cjp3yZP5m7lq3RibD7gFQKiwxOf++vlwQrIX HzrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=fuaUZ6YZQjYTPv7vAjH7dhkzvUruA98nTrnBlydRal0=; b=H15lXAPgttvJ5sHdkcXln/co7Yv/vm+bWEs6IyFTuVs1fUbDlWPrI/tU/ja7tpsq6j vVqZzjzDX+jIS51BobOWYWaGXPHdTQ1znxdvP6EQU30iZGMR0RcSJXoSCCjNYAQE+c+3 t2jWOK7UccBELLiFPFcSdadJ58GDOgqZvaFcAWdQpcS64p5tvMmugiHuqSuqLXoAKUme aWZtErg/UzLHmK6wAnf2Y8ZMFLcNBNDW94JIHzM1HZ/jjO734i8JRNd21lnPOI1o7nQQ dz8zEAkmvEp88HQeFGaWyZG8Vz6USVmY9Qlap5wMzsZjIglgFyPrrAbVQrEyff6bllWG 61BA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vUVHK+rC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a15si28870111pgw.185.2021.10.25.17.29.24; Mon, 25 Oct 2021 17:29:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vUVHK+rC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235830AbhJYTwc (ORCPT + 99 others); Mon, 25 Oct 2021 15:52:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:37926 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237885AbhJYTqk (ORCPT ); Mon, 25 Oct 2021 15:46:40 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C5BC6611C6; Mon, 25 Oct 2021 19:39:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1635190777; bh=YIHW13cDRJP5kWNiL/7/1vcqEh+IIZBZ5tzxJSOydRc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vUVHK+rCUkKQnWFbd5Avlrsh9KGcIfPbgY6zKQrzigpFf2iPWTZ//Z4Xykh3XXOa9 mz0VLpq+CrU2rrsD0y6+H7FUWZx2fiygE1W7xXw1I9Xswp9H0EVO1GiVyQzw7kmGWT 5RXxPQUCtVINghXW4fp/sFyRvfBNzNH9QR8DUyzw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Edmund Dea , Anitha Chrisanthus , Sam Ravnborg , Maarten Lankhorst , Sasha Levin Subject: [PATCH 5.14 060/169] drm/kmb: Disable change of plane parameters Date: Mon, 25 Oct 2021 21:14:01 +0200 Message-Id: <20211025191025.114156921@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211025191017.756020307@linuxfoundation.org> References: <20211025191017.756020307@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Edmund Dea [ Upstream commit 982f8ad666a1123028a077b6b009871a0dc9df26 ] Due to HW limitations, KMB cannot change height, width, or pixel format after initial plane configuration. v2: removed memset disp_cfg as it is already zero. Fixes: 7f7b96a8a0a1 ("drm/kmb: Add support for KeemBay Display") Signed-off-by: Edmund Dea Signed-off-by: Anitha Chrisanthus Acked-by: Sam Ravnborg Link: https://patchwork.freedesktop.org/patch/msgid/20211013233632.471892-4-anitha.chrisanthus@intel.com Signed-off-by: Maarten Lankhorst Signed-off-by: Sasha Levin --- drivers/gpu/drm/kmb/kmb_drv.h | 1 + drivers/gpu/drm/kmb/kmb_plane.c | 43 ++++++++++++++++++++++++++++++++- drivers/gpu/drm/kmb/kmb_plane.h | 6 +++++ 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/kmb/kmb_drv.h b/drivers/gpu/drm/kmb/kmb_drv.h index ebbaa5f422d5..178aa14f2efc 100644 --- a/drivers/gpu/drm/kmb/kmb_drv.h +++ b/drivers/gpu/drm/kmb/kmb_drv.h @@ -45,6 +45,7 @@ struct kmb_drm_private { spinlock_t irq_lock; int irq_lcd; int sys_clk_mhz; + struct disp_cfg init_disp_cfg[KMB_MAX_PLANES]; struct layer_status plane_status[KMB_MAX_PLANES]; int kmb_under_flow; int kmb_flush_done; diff --git a/drivers/gpu/drm/kmb/kmb_plane.c b/drivers/gpu/drm/kmb/kmb_plane.c index ecee6782612d..45cb096455b5 100644 --- a/drivers/gpu/drm/kmb/kmb_plane.c +++ b/drivers/gpu/drm/kmb/kmb_plane.c @@ -67,8 +67,21 @@ static const u32 kmb_formats_v[] = { static unsigned int check_pixel_format(struct drm_plane *plane, u32 format) { + struct kmb_drm_private *kmb; + struct kmb_plane *kmb_plane = to_kmb_plane(plane); int i; + int plane_id = kmb_plane->id; + struct disp_cfg init_disp_cfg; + kmb = to_kmb(plane->dev); + init_disp_cfg = kmb->init_disp_cfg[plane_id]; + /* Due to HW limitations, changing pixel format after initial + * plane configuration is not supported. + */ + if (init_disp_cfg.format && init_disp_cfg.format != format) { + drm_dbg(&kmb->drm, "Cannot change format after initial plane configuration"); + return -EINVAL; + } for (i = 0; i < plane->format_count; i++) { if (plane->format_types[i] == format) return 0; @@ -81,11 +94,17 @@ static int kmb_plane_atomic_check(struct drm_plane *plane, { struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state, plane); + struct kmb_drm_private *kmb; + struct kmb_plane *kmb_plane = to_kmb_plane(plane); + int plane_id = kmb_plane->id; + struct disp_cfg init_disp_cfg; struct drm_framebuffer *fb; int ret; struct drm_crtc_state *crtc_state; bool can_position; + kmb = to_kmb(plane->dev); + init_disp_cfg = kmb->init_disp_cfg[plane_id]; fb = new_plane_state->fb; if (!fb || !new_plane_state->crtc) return 0; @@ -98,6 +117,16 @@ static int kmb_plane_atomic_check(struct drm_plane *plane, return -EINVAL; if (new_plane_state->crtc_w < KMB_MIN_WIDTH || new_plane_state->crtc_h < KMB_MIN_HEIGHT) return -EINVAL; + + /* Due to HW limitations, changing plane height or width after + * initial plane configuration is not supported. + */ + if ((init_disp_cfg.width && init_disp_cfg.height) && + (init_disp_cfg.width != fb->width || + init_disp_cfg.height != fb->height)) { + drm_dbg(&kmb->drm, "Cannot change plane height or width after initial configuration"); + return -EINVAL; + } can_position = (plane->type == DRM_PLANE_TYPE_OVERLAY); crtc_state = drm_atomic_get_existing_crtc_state(state, @@ -296,6 +325,7 @@ static void kmb_plane_atomic_update(struct drm_plane *plane, unsigned char plane_id; int num_planes; static dma_addr_t addr[MAX_SUB_PLANES]; + struct disp_cfg *init_disp_cfg; if (!plane || !new_plane_state || !old_plane_state) return; @@ -317,7 +347,8 @@ static void kmb_plane_atomic_update(struct drm_plane *plane, } spin_unlock_irq(&kmb->irq_lock); - src_w = (new_plane_state->src_w >> 16); + init_disp_cfg = &kmb->init_disp_cfg[plane_id]; + src_w = new_plane_state->src_w >> 16; src_h = new_plane_state->src_h >> 16; crtc_x = new_plane_state->crtc_x; crtc_y = new_plane_state->crtc_y; @@ -448,6 +479,16 @@ static void kmb_plane_atomic_update(struct drm_plane *plane, /* Enable DMA */ kmb_write_lcd(kmb, LCD_LAYERn_DMA_CFG(plane_id), dma_cfg); + + /* Save initial display config */ + if (!init_disp_cfg->width || + !init_disp_cfg->height || + !init_disp_cfg->format) { + init_disp_cfg->width = width; + init_disp_cfg->height = height; + init_disp_cfg->format = fb->format->format; + } + drm_dbg(&kmb->drm, "dma_cfg=0x%x LCD_DMA_CFG=0x%x\n", dma_cfg, kmb_read_lcd(kmb, LCD_LAYERn_DMA_CFG(plane_id))); diff --git a/drivers/gpu/drm/kmb/kmb_plane.h b/drivers/gpu/drm/kmb/kmb_plane.h index 486490f7a3ec..99207b35365c 100644 --- a/drivers/gpu/drm/kmb/kmb_plane.h +++ b/drivers/gpu/drm/kmb/kmb_plane.h @@ -62,6 +62,12 @@ struct layer_status { u32 ctrl; }; +struct disp_cfg { + unsigned int width; + unsigned int height; + unsigned int format; +}; + struct kmb_plane *kmb_plane_init(struct drm_device *drm); void kmb_plane_destroy(struct drm_plane *plane); #endif /* __KMB_PLANE_H__ */ -- 2.33.0