Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp7043097ybf; Fri, 6 Mar 2020 09:15:38 -0800 (PST) X-Google-Smtp-Source: ADFU+vsTJoQfDhkcPpQQMD8u5d214Uycr4RdFtvnaW93bWnCwG4rdLf6nBd+N0xudFzkKUUYm52Y X-Received: by 2002:aca:c586:: with SMTP id v128mr3479665oif.166.1583514938395; Fri, 06 Mar 2020 09:15:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583514938; cv=none; d=google.com; s=arc-20160816; b=GTD3JvMget/CYDIqwkgF41QyYddIpM1p/l8jMn27BOzLerMUHCoX0tM92Qe4qQyMAT YxHF0iOtffFO+ctAOQ6vi+QQ/5JC/XpyWP/6vDn7dObQ6FmlvqxTrJ5y8fa5/+HdEfRx Welb+hUZg0XzTor9A7tDwq7IetZ9ouyib10VJcYx/YDrHLTDRR7m46o1tGpbUYfzShNZ dwHrE5D0ZbEaa5xFtwlNMA7z/4imi61upKAHY4SzSMj6XMtTSM1ggVxTkExtheujU4lf 9lD3DxtoDFapG/CwnilsKWiicfOX6aAiwXv3KYd2FDNzgsy7Yo/ufaQdbRYGTfSXRdGS SDmQ== 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=lzpbKokk11BRaCUTE3S0a/MWb4B/MGyZwwWpbEvm8gE=; b=skaqHMmccUui/lPGp0il59qI0kdR0idlNZk4QET2+RiBkoKobbAxEbG/T9mW5WbkJZ qgX5vSZ7m3w0bll8M7bvmkcaatljKQbvTQzYLssY3WYjoRy/fNbUKguYxrOCrbBKyXIJ FExsiJaE8Yy7fEPpiTjZi8Bef6ZF65+biNGL8ahG5X6DRKsQGJTaQIC+glW2WrFCXvCz +vusBYxoTgwOTWTByFcbW8gXxD9peiVzZy8RdN1vSNYUmszeDIyGpikcWJMu2sNziCLV 3DN4X6+OB79KGM+kLFAi0U6E3y9YNfkLMcvRwXGuQ2XhM57B5Xx7WESt09TYZ+jnY0P8 7XpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=oxCDkIfp; 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 s24si1925770otp.86.2020.03.06.09.15.22; Fri, 06 Mar 2020 09:15:38 -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=oxCDkIfp; 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 S1726738AbgCFROz (ORCPT + 99 others); Fri, 6 Mar 2020 12:14:55 -0500 Received: from mail-vk1-f193.google.com ([209.85.221.193]:33006 "EHLO mail-vk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725935AbgCFROz (ORCPT ); Fri, 6 Mar 2020 12:14:55 -0500 Received: by mail-vk1-f193.google.com with SMTP id i78so808320vke.0 for ; Fri, 06 Mar 2020 09:14:54 -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=lzpbKokk11BRaCUTE3S0a/MWb4B/MGyZwwWpbEvm8gE=; b=oxCDkIfplYvmZlhq6A8KbraYVjcHaKeefRxBL8EIvkKEnpVIYk9BqMe2YAGtaBuacA gTxymGa8mmHE4f5Kchdkx5OHQTrN4vkO+8HY7eUjUfycchnS7ZveJa+qE25qaqXvLBUR UnV34k/3O9CK7UlH6y1PtGmgqt3iMAxNDqnQz13Ll6ZyjWcf45YAH3rXBMQw17+ytK6L q2ZXbgrsMyyfdt91luG8Ewklm02sfdTYkN6sM+NctRvmmCWTTva/8aOGyKylA9iZqxcf CAJhyPvic+eQoJKOGrct7AQ3oDtI8TBA/6FW5G2LvYd8lDiK3jEPbEIar6Rlo8khbZoE uZWg== 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=lzpbKokk11BRaCUTE3S0a/MWb4B/MGyZwwWpbEvm8gE=; b=QnGCemIT+gCD0KwKYzmScaLIGK5Mdo8MdXQr82kuy21Ji5zzZRNvesV6m/FdNQeGvb 9oSnB8fYYNG7n8eoWVd/bBXyVGfjJ7R9MzI1ibfSBaBZtPaXO0zJPWvGOx85HGpZQebG z3uHmzjDguxwxE7fi7LmrEWA++fY+xDhYhDUh9ll2tYskmSiD2W2dT7G7cQTF4cUlDIl RzvYqKAbjWRTwb7eLqIoipC802bw4Jqh7a8jfOCx2s16L2v6/TLLC+DdVuv7DNnPYdeW h9DuPsufYvN07FXaVydP6+zTrkvyEYlTUPXdmLFEOjoFdTvBYvxOTW6B1+hgZjKAMVdT ln/g== X-Gm-Message-State: ANhLgQ1923RqTTPFk4BQ7+G7VZgFL5xJ8J2jfmHNQ2ksgL+CfetXDddR 0Tz5DgQSRb3vrTgpFwtB8PFNMkcelJCb23/SaCI= X-Received: by 2002:a1f:264b:: with SMTP id m72mr2236379vkm.51.1583514893670; Fri, 06 Mar 2020 09:14:53 -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: From: Emil Velikov Date: Fri, 6 Mar 2020 17:14:14 +0000 Message-ID: Subject: Re: [PATCH RFC v4 4/6] drm/sprd: add Unisoc's drm display controller driver To: tang pengchuan 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 On Thu, 5 Mar 2020 at 13:15, tang pengchuan wrote: > On Tue, Mar 3, 2020 at 2:29 AM Emil Velikov wrote: >> 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; >> } >> > Yeah, the 0 maybe unused code, i will remove it. > But i think default is need, because userspace could give an incorrect value . > So we need to setup a default value and doing error check. As mentioned in the documentation [0] input (userspace) validation should happen in atomic_check. This function here is called during atomic_flush which is _not_ allowed to fail. >> The default case here should be unreachable. Either it is or the upper layer (or >> earlier code) should ensure that. > > There will be some differences in the formats supported by different chips, but userspace will only have one set of code. > So it is necessary to check whether the parameters passed by the user layer are wrong. I think it is necessary As said above - this type of issues should be checked _before_ reaching atomic_flush - aka in atomic_check. >> > +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. > > Sometimes, some "dpu->core->foo" maybe always need, compatibility will be better. > eg: > > if (dpu->glb && dpu->glb->power) > dpu->glb->power(ctx, true); > if (dpu->glb && dpu->glb->enable) > dpu->glb->enable(ctx); > > if (ctx->is_stopped && dpu->glb && dpu->glb->reset) > dpu->glb->reset(ctx); > > if (dpu->clk && dpu->clk->init) > dpu->clk->init(ctx); > if (dpu->clk && dpu->clk->enable) > dpu->clk->enable(ctx); > > if (dpu->core && dpu->core->init) > dpu->core->init(ctx); > if (dpu->core && dpu->core->ifconfig) > dpu->core->ifconfig(ctx); > If there are no hooks, then the whole thing is dead code. As such it should not be included. > > > > Note: Custom properties should be separate patches. This includes documentation > > why they are needed and references to open-source userspace. > This only need for our chips, what documentation do we need to provide? > KMS properties should be generic. Reason being is that divergence causes substantial overhead, and fragility, to each and every userspace consumer. The documentation has some general notes on the topic [1]. Don't forget the "Testing and validation" section ;-) Although I've tried to catch everything, I might have missed a comment or two due the HTML formatting. Please toggle to plain text [2] for the future. Thanks -Emil [0] https://www.kernel.org/doc/html/v5.5/gpu/drm-kms.html [1] Documentation/gpu/drm-uapi.rst in particular "Open-Source Userspace Requirements" [2] https://smallbusiness.chron.com/reply-inline-gmail-40679.html