Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp2533283ybf; Mon, 2 Mar 2020 10:31:20 -0800 (PST) X-Google-Smtp-Source: ADFU+vutmTLLCNJ14Zr4p/Wr8ywk03d593PH46RXgpX4rifFfyvJVYL8ymEbuBnB/S5nbOWHBb8x X-Received: by 2002:aca:2b0a:: with SMTP id i10mr303620oik.64.1583173880644; Mon, 02 Mar 2020 10:31:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583173880; cv=none; d=google.com; s=arc-20160816; b=qdfhBBSKUlr/Y1uKYJmr+95bdvJK2YFhVCyq+Lbq7zUfZXjbXds0X+4OB1dkyD9hT4 b1SAQ12aO1DGGBbgeonHC/FkEbgtrW9mdGR3s+dul+axIzi8JfbtzNcdU7PtJKh3NRh4 JoNBTaJk83T3oOLiCWQL7y8Etad12hOVNiQinnopQqSqZRpjPtDUwnTDuSaPRnv4cvLr Er5SUrNZEkJZBgIQuZElZjlXAWC29p4MWTFyaw7e22eAiVxTPc6ReI/2/kL32EYIoCbf BMcgigEV2gEiDJ41f6YRk1G9/CU4RpsnYXxo2c1xRunY52aITKz8s9oqeV0GNWLoTeE0 juQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=olrR+JSn2E4EQgdpphIWt9dU/4myCV0vVUEAdGgS0T4=; b=BAu1e+oRU0H+5as/J0mmvpwtRWoeVmUUdKZQlNeI0/m1dYDEb+QI3DV95wxGtvQoet MGXovoy7JlAGYQu0Zfp2/WVZgHKoBYBrGLmzXjGijqPvbmCFwPu4mWZHw6fKOKdK7a4S fFV3BycFF4yLXfWzl3wixyVzWzTiw2JPj8z4JYB/5v4u9kxCnLFZp+iUIu5Qy91OEuoe B/MKyMXwcLmMegP35iCfWBllcnvdiZIAwpwRlcuEh0fEktMSjaNRKrKFB9fftrN79t5g rH9t3uSWMtyzD1RjBnq9ymKobWltSeXbaoBb1KFU6KiFx3l6WGyu0vOFkKAWZ+ODOjMd J1hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="T6WwE/sF"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x10si6185232oic.136.2020.03.02.10.31.08; Mon, 02 Mar 2020 10:31:20 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="T6WwE/sF"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727511AbgCBS31 (ORCPT + 99 others); Mon, 2 Mar 2020 13:29:27 -0500 Received: from mail-vs1-f67.google.com ([209.85.217.67]:47038 "EHLO mail-vs1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727126AbgCBS31 (ORCPT ); Mon, 2 Mar 2020 13:29:27 -0500 Received: by mail-vs1-f67.google.com with SMTP id t12so559207vso.13 for ; Mon, 02 Mar 2020 10:29:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=olrR+JSn2E4EQgdpphIWt9dU/4myCV0vVUEAdGgS0T4=; b=T6WwE/sFz9LPxrVh4ZW7YojE01WCMd2k8z5ascVmoE7gMph1cTnNSLHJBXEJv+xwRl V81E0nWfgeeoJYMstuaKJ2SqpDEuQBrsL+Vb+uh9n34Zyp4Khav9f/FAV0FA2Joek2hQ bzyfS/TBQ+VJFZDOQcjDnt4/ChIWRn8gsudyn5h6WaLPywQqZGFJ4yUEhMhb4nT/guqI /qfdaMVcmh/9L4WG7R96jJzClc9r3S8vCwxaiOg6wq1KT2v/jR1nHht8z5V/dp4y5K8X bgKmKv2EEEySzGhfz7jhlDzUzUWxSrT/GolL8v9k5aG54dNew/NuI0Dqg7yJe1lbKGbK Q9RQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=olrR+JSn2E4EQgdpphIWt9dU/4myCV0vVUEAdGgS0T4=; b=ACBA1lX47tlyd1xZznX+7FWVDDg5UKrJG9mNpuXJ2lM/MRNS/CuMUHYKoyXdW6IwOh 2Cfmf2ROnTxS8yOQRkp9lVkZDiPj3ID3PDb+WnHlgiH4AMOkKIwQedDXlekt7wxFsRsm D/mgGWMBx6FGj/e/kJa/zbgmgxdhLynC9iQQ3SCnaCED8R88V8K4ZCX0qB/VRCIlAif4 YiJ92orAGzMPwqaBS0uVw2kTIKKxCZtLf/3xc+2Y8jeATYh18ZaWQ9JoV+XVqYWHIkmw Jz0rcRvG15ZyF3b9V1IQWDNAprDfGyEPUJctp6A5dsyaI7xpkRzcMmzUrC1AvdvpHO63 Ldqg== X-Gm-Message-State: ANhLgQ0pqw9wCQ+xEPvZL3uA6qoar3oGPSDO8H1oeX90SKyJJ0D0OkXM SyNnw+pu0zxE8FnSuYZQlMa8jNtiUZMeYCO0bJ8= X-Received: by 2002:a05:6102:2365:: with SMTP id o5mr147024vsa.85.1583173765166; Mon, 02 Mar 2020 10:29:25 -0800 (PST) MIME-Version: 1.0 References: <1582710377-15489-1-git-send-email-kevin3.tang@gmail.com> <1582710377-15489-5-git-send-email-kevin3.tang@gmail.com> In-Reply-To: <1582710377-15489-5-git-send-email-kevin3.tang@gmail.com> From: Emil Velikov Date: Mon, 2 Mar 2020 18:28:53 +0000 Message-ID: Subject: Re: [PATCH RFC v4 4/6] drm/sprd: add Unisoc's drm display controller driver To: Kevin Tang Cc: Maarten Lankhorst , Maxime Ripard , Sean Paul , Dave Airlie , Daniel Vetter , Rob Herring , Mark Rutland , Orson Zhai , ML dri-devel , "Linux-Kernel@Vger. Kernel. Org" , Chunyan Zhang , Baolin Wang Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Kevin, There's a few small suggestions, although overall the driver looks a lot better. On Thu, 27 Feb 2020 at 08:14, Kevin Tang wrote: > --- /dev/null > +++ b/drivers/gpu/drm/sprd/dpu/Makefile > @@ -0,0 +1,7 @@ > +# SPDX-License-Identifier: GPL-2.0 > + > +ifdef CONFIG_ARM64 > +KBUILD_CFLAGS += -mstrict-align There are many other drivers that do not use readl/writel for register access, yet none has this workaround... Even those that they are exclusively ARM64. Have you tried that it's not a buggy version of GCC? At the very least, I'd encourage you to add a brief comment about the problem + setup. ... In general I think one should follow the suggestions from Rob Herring. > +static void dpu_dump(struct dpu_context *ctx) > +{ > + u32 *reg = (u32 *)ctx->base; > + int i; > + > + pr_info(" 0 4 8 C\n"); > + for (i = 0; i < 256; i += 4) { > + pr_info("%04x: 0x%08x 0x%08x 0x%08x 0x%08x\n", > + i * 4, reg[i], reg[i + 1], reg[i + 2], reg[i + 3]); Using some of the helpers from drm_print.h would be better than pr_*. This applies for the rest of the patch. > +static void dpu_clean_all(struct dpu_context *ctx) > +{ > + int i; > + struct dpu_reg *reg = (struct dpu_reg *)ctx->base; > + > + for (i = 0; i < 8; i++) This "< 8" seem pretty magical. How about "< ARRAY_SIZE(reg->layers)" Same logic applies through the rest of the patch. > +static int dpu_wait_stop_done(struct dpu_context *ctx) > +{ > + int rc; > + > + if (ctx->stopped) > + return 0; > + The stopped handling does look suspicious. Admittedly I did not look too closely at the dpu_flip code, which seems to require it. Let's add a small comment in the struct dpu_context::stopped declaration, why it is needed, if it truely is. > + rc = wait_event_interruptible_timeout(ctx->wait_queue, ctx->evt_stop, > + msecs_to_jiffies(500)); > + ctx->evt_stop = false; > + > + ctx->stopped = true; > + > + if (!rc) { > + pr_err("dpu wait for stop done time out!\n"); > + return -ETIMEDOUT; > + } > + > + return 0; > +} > + > +static void dpu_stop(struct dpu_context *ctx) > +{ > + struct dpu_reg *reg = (struct dpu_reg *)ctx->base; > + > + if (ctx->stopped) > + return; > + > + if (ctx->if_type == SPRD_DISPC_IF_DPI) > + reg->dpu_ctrl |= BIT(1); > + > + dpu_wait_stop_done(ctx); > + > + pr_info("dpu stop\n"); This and the dpu_run pr_info() messages can be removed. > +} > + > +static void dpu_run(struct dpu_context *ctx) > +{ > + struct dpu_reg *reg = (struct dpu_reg *)ctx->base; > + > + if (!ctx->stopped) > + return; > + > + reg->dpu_ctrl |= BIT(0); > + > + ctx->stopped = false; > + > + pr_info("dpu run\n"); > +} > + > +static int dpu_init(struct dpu_context *ctx) > +{ > + struct dpu_reg *reg = (struct dpu_reg *)ctx->base; > + u32 size; > + > + reg->bg_color = 0; > + > + size = (ctx->vm.vactive << 16) | ctx->vm.hactive; > + reg->panel_size = size; > + reg->blend_size = size; > + > + reg->dpu_cfg0 = BIT(4) | BIT(5); > + > + reg->dpu_cfg1 = 0x004466da; > + reg->dpu_cfg2 = 0; > + > + if (ctx->stopped) > + dpu_clean_all(ctx); > + > + reg->mmu_en = 0; > + reg->mmu_min_ppn1 = 0; > + reg->mmu_ppn_range1 = 0xffff; > + reg->mmu_min_ppn2 = 0; > + reg->mmu_ppn_range2 = 0xffff; > + reg->mmu_vpn_range = 0x1ffff; > + > + reg->dpu_int_clr = 0xffff; > + > + init_waitqueue_head(&ctx->wait_queue); > + > + return 0; Function always returns 0. Let's make it static void dpu_init() > +static u32 to_dpu_rotation(u32 angle) > +{ > + u32 rot = DPU_LAYER_ROTATION_0; > + > + switch (angle) { > + case 0: > + case DRM_MODE_ROTATE_0: > + rot = DPU_LAYER_ROTATION_0; > + break; > + case DRM_MODE_ROTATE_90: > + rot = DPU_LAYER_ROTATION_90; > + break; > + case DRM_MODE_ROTATE_180: > + rot = DPU_LAYER_ROTATION_180; > + break; > + case DRM_MODE_ROTATE_270: > + rot = DPU_LAYER_ROTATION_270; > + break; > + case DRM_MODE_REFLECT_Y: > + rot = DPU_LAYER_ROTATION_180_M; > + break; > + case (DRM_MODE_REFLECT_Y | DRM_MODE_ROTATE_90): > + rot = DPU_LAYER_ROTATION_90_M; > + break; > + case DRM_MODE_REFLECT_X: > + rot = DPU_LAYER_ROTATION_0_M; > + break; > + case (DRM_MODE_REFLECT_X | DRM_MODE_ROTATE_90): > + rot = DPU_LAYER_ROTATION_270_M; > + break; > + default: > + pr_err("rotation convert unsupport angle (drm)= 0x%x\n", angle); > + break; Have you seen a case where the 0 or default case are reached? AFAICT they will never trigger. So one might as well use: switch (angle) { case DRM_MODE_FOO: return DPU_LAYER_ROTATION_FOO; ... case DRM_MODE_BAR: return DPU_LAYER_ROTATION_BAR; } > + } > + > + return rot; > +} > + > +static u32 dpu_img_ctrl(u32 format, u32 blending, u32 rotation) > +{ > + int reg_val = 0; > + > + /* layer enable */ > + reg_val |= BIT(0); > + > + switch (format) { > + case DRM_FORMAT_BGRA8888: > + /* BGRA8888 -> ARGB8888 */ > + reg_val |= SPRD_IMG_DATA_ENDIAN_B3B2B1B0 << 8; > + reg_val |= (DPU_LAYER_FORMAT_ARGB8888 << 4); > + break; > + case DRM_FORMAT_RGBX8888: > + case DRM_FORMAT_RGBA8888: > + /* RGBA8888 -> ABGR8888 */ > + reg_val |= SPRD_IMG_DATA_ENDIAN_B3B2B1B0 << 8; > + /* FALLTHRU */ > + case DRM_FORMAT_ABGR8888: > + /* rb switch */ > + reg_val |= BIT(10); > + /* FALLTHRU */ > + case DRM_FORMAT_ARGB8888: > + reg_val |= (DPU_LAYER_FORMAT_ARGB8888 << 4); > + break; > + case DRM_FORMAT_XBGR8888: > + /* rb switch */ > + reg_val |= BIT(10); > + /* FALLTHRU */ > + case DRM_FORMAT_XRGB8888: > + reg_val |= (DPU_LAYER_FORMAT_ARGB8888 << 4); > + break; > + case DRM_FORMAT_BGR565: > + /* rb switch */ > + reg_val |= BIT(10); > + /* FALLTHRU */ > + case DRM_FORMAT_RGB565: > + reg_val |= (DPU_LAYER_FORMAT_RGB565 << 4); > + break; > + case DRM_FORMAT_NV12: > + /* 2-Lane: Yuv420 */ > + reg_val |= DPU_LAYER_FORMAT_YUV420_2PLANE << 4; > + /* Y endian */ > + reg_val |= SPRD_IMG_DATA_ENDIAN_B0B1B2B3 << 8; > + /* UV endian */ > + reg_val |= SPRD_IMG_DATA_ENDIAN_B0B1B2B3 << 10; > + break; > + case DRM_FORMAT_NV21: > + /* 2-Lane: Yuv420 */ > + reg_val |= DPU_LAYER_FORMAT_YUV420_2PLANE << 4; > + /* Y endian */ > + reg_val |= SPRD_IMG_DATA_ENDIAN_B0B1B2B3 << 8; > + /* UV endian */ > + reg_val |= SPRD_IMG_DATA_ENDIAN_B3B2B1B0 << 10; > + break; > + case DRM_FORMAT_NV16: > + /* 2-Lane: Yuv422 */ > + reg_val |= DPU_LAYER_FORMAT_YUV422_2PLANE << 4; > + /* Y endian */ > + reg_val |= SPRD_IMG_DATA_ENDIAN_B3B2B1B0 << 8; > + /* UV endian */ > + reg_val |= SPRD_IMG_DATA_ENDIAN_B3B2B1B0 << 10; > + break; > + case DRM_FORMAT_NV61: > + /* 2-Lane: Yuv422 */ > + reg_val |= DPU_LAYER_FORMAT_YUV422_2PLANE << 4; > + /* Y endian */ > + reg_val |= SPRD_IMG_DATA_ENDIAN_B0B1B2B3 << 8; > + /* UV endian */ > + reg_val |= SPRD_IMG_DATA_ENDIAN_B0B1B2B3 << 10; > + break; > + case DRM_FORMAT_YUV420: > + reg_val |= DPU_LAYER_FORMAT_YUV420_3PLANE << 4; > + /* Y endian */ > + reg_val |= SPRD_IMG_DATA_ENDIAN_B0B1B2B3 << 8; > + /* UV endian */ > + reg_val |= SPRD_IMG_DATA_ENDIAN_B0B1B2B3 << 10; > + break; > + case DRM_FORMAT_YVU420: > + reg_val |= DPU_LAYER_FORMAT_YUV420_3PLANE << 4; > + /* Y endian */ > + reg_val |= SPRD_IMG_DATA_ENDIAN_B0B1B2B3 << 8; > + /* UV endian */ > + reg_val |= SPRD_IMG_DATA_ENDIAN_B3B2B1B0 << 10; > + break; > + default: > + pr_err("error: invalid format %c%c%c%c\n", format, > + format >> 8, > + format >> 16, > + format >> 24); > + break; The default case here should be unreachable. Either it is or the upper layer (or earlier code) should ensure that. > + } > + > + switch (blending) { > + case DRM_MODE_BLEND_PIXEL_NONE: > + /* don't do blending, maybe RGBX */ > + /* alpha mode select - layer alpha */ > + reg_val |= BIT(2); > + break; > + case DRM_MODE_BLEND_COVERAGE: > + /* alpha mode select - combo alpha */ > + reg_val |= BIT(3); > + /*Normal mode*/ > + reg_val &= (~BIT(16)); > + break; > + case DRM_MODE_BLEND_PREMULTI: > + /* alpha mode select - combo alpha */ > + reg_val |= BIT(3); > + /*Pre-mult mode*/ > + reg_val |= BIT(16); > + break; > + default: > + /* alpha mode select - layer alpha */ > + reg_val |= BIT(2); > + break; Ditto > + } > + > + rotation = to_dpu_rotation(rotation); > + reg_val |= (rotation & 0x7) << 20; > + > + return reg_val; > +} > + > +static void dpu_layer(struct dpu_context *ctx, > + struct sprd_dpu_layer *hwlayer) > +{ > + struct dpu_reg *reg = (struct dpu_reg *)ctx->base; > + const struct drm_format_info *info; > + struct layer_reg *layer; > + u32 addr, size, offset; > + int i; > + > + layer = ®->layers[hwlayer->index]; > + offset = (hwlayer->dst_x & 0xffff) | ((hwlayer->dst_y) << 16); > + > + if (hwlayer->src_w && hwlayer->src_h) > + size = (hwlayer->src_w & 0xffff) | ((hwlayer->src_h) << 16); > + else > + size = (hwlayer->dst_w & 0xffff) | ((hwlayer->dst_h) << 16); > + > + for (i = 0; i < hwlayer->planes; i++) { > + addr = hwlayer->addr[i]; > + > + if (addr % 16) > + pr_err("layer addr[%d] is not 16 bytes align, it's 0x%08x\n", > + i, addr); > + layer->addr[i] = addr; > + } > + > + layer->pos = offset; > + layer->size = size; > + layer->crop_start = (hwlayer->src_y << 16) | hwlayer->src_x; > + layer->alpha = hwlayer->alpha; > + > + info = drm_format_info(hwlayer->format); > + if (info->cpp[0] == 0) { Ditto > + pr_err("layer[%d] bytes per pixel is invalid\n", hwlayer->index); > + return; > + } > + > +static int dpu_capability(struct dpu_context *ctx, > + struct dpu_capability *cap) > +{ > + if (!cap) > + return -EINVAL; > + Ensure the caller always passes cap != NULL and drop the function return type? > + cap->max_layers = 6; > + cap->fmts_ptr = primary_fmts; > + cap->fmts_cnt = ARRAY_SIZE(primary_fmts); > + > + return 0; > +} > +static int sprd_plane_atomic_check(struct drm_plane *plane, > + struct drm_plane_state *state) > +{ > + DRM_DEBUG("%s()\n", __func__); > + Would be nice to hear from the atomic experts, how a no-op atomic_check goes with the overall atomic semantics. > + return 0; > +} > + > +static void sprd_plane_atomic_disable(struct drm_plane *plane, > + struct drm_plane_state *old_state) > +{ > + struct sprd_plane *p = to_sprd_plane(plane); > + > + /* > + * NOTE: > + * The dpu->core->flip() will disable all the planes each time. > + * So there is no need to impliment the atomic_disable() function. > + * But this function can not be removed, because it will change > + * to call atomic_update() callback instead. Which will cause > + * kernel panic in sprd_plane_atomic_update(). > + * > + * We do nothing here but just print a debug log. > + */ > + DRM_DEBUG("%s() layer_id = %u\n", __func__, p->index); Similar to the check - would be nice to see a confirmation, that this isn't abusing atomics in some way. > +} > + > +static int sprd_plane_create_properties(struct sprd_plane *p, int index) > +{ > + unsigned int supported_modes = BIT(DRM_MODE_BLEND_PIXEL_NONE) | > + BIT(DRM_MODE_BLEND_PREMULTI) | > + BIT(DRM_MODE_BLEND_COVERAGE); > + > + /* create rotation property */ > + drm_plane_create_rotation_property(&p->plane, > + DRM_MODE_ROTATE_0, > + DRM_MODE_ROTATE_MASK | > + DRM_MODE_REFLECT_MASK); > + > + /* create alpha property */ > + drm_plane_create_alpha_property(&p->plane); > + > + /* create blend mode property */ > + drm_plane_create_blend_mode_property(&p->plane, supported_modes); > + > + /* create zpos property */ > + drm_plane_create_zpos_immutable_property(&p->plane, index); > + Either check if creating the properties fail (and propagate the error) or drop the function return type. As-is it's in the middle making it fairly misleading. > + return 0; > +} > + > +static struct drm_plane *sprd_plane_init(struct drm_device *drm, > + struct sprd_dpu *dpu) > +{ > + struct drm_plane *primary = NULL; > + struct sprd_plane *p = NULL; > + struct dpu_capability cap = {}; > + int err, i; > + > + if (dpu->core && dpu->core->capability) As mentioned before - this always evaluates to true, so drop the check. Same applies for the other dpu->core->foo checks. Still not a huge fan of the abstraction layer, but I guess you're hesitant on removing it. > + dpu->core->capability(&dpu->ctx, &cap); > + > + dpu->layers = devm_kcalloc(drm->dev, cap.max_layers, > + sizeof(struct sprd_dpu_layer), GFP_KERNEL); > + if (!dpu->layers) > + return ERR_PTR(-ENOMEM); > + > + for (i = 0; i < cap.max_layers; i++) { > + > + p = devm_kzalloc(drm->dev, sizeof(*p), GFP_KERNEL); > + if (!p) > + return ERR_PTR(-ENOMEM); > + > + err = drm_universal_plane_init(drm, &p->plane, 1, > + &sprd_plane_funcs, cap.fmts_ptr, > + cap.fmts_cnt, NULL, > + DRM_PLANE_TYPE_PRIMARY, NULL); > + if (err) { > + DRM_ERROR("fail to init primary plane\n"); > + return ERR_PTR(err); > + } > + > + drm_plane_helper_add(&p->plane, &sprd_plane_helper_funcs); > + > + sprd_plane_create_properties(p, i); > + > + p->index = i; > + if (i == 0) > + primary = &p->plane; > + } > + > + if (p) > + DRM_INFO("dpu plane init ok\n"); This and nearly all the other DRM_INFO() messages look like a debug/development left over. Please remove them - the driver does not need to print when functions are successfull. > + > + return primary; > +} > + > +static void sprd_crtc_mode_set_nofb(struct drm_crtc *crtc) > +{ > + struct sprd_dpu *dpu = crtc_to_dpu(crtc); > + > + if ((dpu->mode->hdisplay == dpu->mode->htotal) || > + (dpu->mode->vdisplay == dpu->mode->vtotal)) > + dpu->ctx.if_type = SPRD_DISPC_IF_EDPI; > + else > + dpu->ctx.if_type = SPRD_DISPC_IF_DPI; > +} > + > +static enum drm_mode_status sprd_crtc_mode_valid(struct drm_crtc *crtc, > + const struct drm_display_mode *mode) > +{ > + struct sprd_dpu *dpu = crtc_to_dpu(crtc); > + > + DRM_INFO("%s() mode: "DRM_MODE_FMT"\n", __func__, DRM_MODE_ARG(mode)); > + If needed, let's move this to core and make it a debug message. As-is it will cause spam for no reason. > + if (mode->type & DRM_MODE_TYPE_DEFAULT) > + dpu->mode = (struct drm_display_mode *)mode; > + > + if (mode->type & DRM_MODE_TYPE_PREFERRED) { > + dpu->mode = (struct drm_display_mode *)mode; Casting away the constness is a bad idea. Instead, let's move the if_type decision here, thus we can remove the nsprd_crtc_mode_set_nofb function? This way we can also remove sprd_dpu::mode. > + drm_display_mode_to_videomode(dpu->mode, &dpu->ctx.vm); Similarly, one could derive the vm based attributes here and remove dpu->ctx.vm. > + } > + > + return MODE_OK; > +} > + > +static void sprd_crtc_atomic_enable(struct drm_crtc *crtc, > + struct drm_crtc_state *old_state) > +{ > + struct sprd_dpu *dpu = crtc_to_dpu(crtc); > + > + DRM_INFO("%s()\n", __func__); > + More sprurious info messages - debug leftover? > +static int sprd_crtc_enable_vblank(struct drm_crtc *crtc) > +{ > + struct sprd_dpu *dpu = crtc_to_dpu(crtc); > + > + DRM_DEBUG("%s()\n", __func__); > + Personally, I don't see the appeal in these debug messages. While a few display controllers have the odd piece, they are an exception in DRM. > +static int sprd_crtc_create_properties(struct drm_crtc *crtc) > +{ > + struct sprd_dpu *dpu = crtc_to_dpu(crtc); > + struct drm_device *drm = dpu->crtc.dev; > + struct drm_property *prop; > + struct drm_property_blob *blob; > + size_t blob_size; > + > + blob_size = strlen(dpu->ctx.version) + 1; > + > + blob = drm_property_create_blob(dpu->crtc.dev, blob_size, > + dpu->ctx.version); > + if (IS_ERR(blob)) { > + DRM_ERROR("drm_property_create_blob dpu version failed\n"); > + return PTR_ERR(blob); > + } > + > + /* create dpu version property */ > + prop = drm_property_create(drm, > + DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB, > + "dpu version", 0); Note: Custom properties should be separate patches. This includes documentation why they are needed and references to open-source userspace. HTH Emil