Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2672523rwd; Mon, 22 May 2023 02:27:03 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4tHmucpfR+dh2AJeXo3W48v0WIaCh5I2TZ8lRe+jdnshmVfKPTCLeeKAFsdnHcT0ztrdyy X-Received: by 2002:a17:90a:d302:b0:23f:2661:f94c with SMTP id p2-20020a17090ad30200b0023f2661f94cmr10057348pju.47.1684747623153; Mon, 22 May 2023 02:27:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684747623; cv=none; d=google.com; s=arc-20160816; b=Az3xAaC3leRQRcDwvO7+wGme1qsgdMrSqGRAWMrn7TRh92BHRnwA+OM/53w8v7cWCE aL5lDDlL4koCqL3u2wPPM6VrpGnX377zhE3TK8CPsWNJX/FEYM+ICJs/nudvv6sI87kf T0XJuh/VtJltXcvF8xIfXA3hsh5VhQfaziAAcMeD2dAXhpY1+2KHbr1NwL6p1TUrJRdA ZoA6KiJ/5q/cp90mmWNavOx3IJ5pB7Ye67K8HcUaHiJ66YcHVfncSDTbYiq/lFQCb9QX 7W7xQkRv3mbjOkfyalTuctG7UPYOjKnl8m1tQJN8vB/i5DQAujX9+1F/m27wpI9mk/TA 0UZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=2WvexY6yUTzwI7RkqhT0l2I8EMjpGrmZ++HfQ+FlShQ=; b=dG1Wpe80CFN16RlzVEQudP7cFoxUjFtF3czhOWUebrc13kQBlDoGMCvYSXLmHSgWrx kXgwCYMvWmbNb/zKOx/VnONx55LO0KXQozeP8pM7so4QPWxX+V3aKlZ0+YCChYaTMTh9 jyW828ojIvrzrbgLYhykmVfuff2g4j4ZALbYetTbo3uQLrs7/L14wBQyEHUyLqvR+qi6 +Nt6k1+e1qhKgnzYWDdyykh8vgDR1uLhJW8jF41Q2X5P3o99npqZeWdypLWCpYX/FEf/ //i3ELToJHTlzkW916HxwDn0mhiqQWezfVq+YKi+tsBDpRyi3uAIy3ZqmaILh0TsxPbo Fzow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xen0n.name header.s=mail header.b=AwmSSYYo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h14-20020a17090a604e00b00252fc82b3afsi4359868pjm.128.2023.05.22.02.26.48; Mon, 22 May 2023 02:27:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@xen0n.name header.s=mail header.b=AwmSSYYo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232660AbjEVJGH (ORCPT + 99 others); Mon, 22 May 2023 05:06:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232754AbjEVJFs (ORCPT ); Mon, 22 May 2023 05:05:48 -0400 Received: from mailbox.box.xen0n.name (mail.xen0n.name [115.28.160.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29C43E50; Mon, 22 May 2023 02:05:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xen0n.name; s=mail; t=1684746332; bh=BvafpoMALSkBY+N8iyu1yI8+hZDb+7ttS5xnPbBUstI=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=AwmSSYYozspEZwRyLCQRnSMqjHss6FwHp3xYrfmKjSu/L4Bp17OT38n8gVW7qJiN4 CIoFpp+bBZXn4w4KSGjMKkp3fQ/8xc6dqdLw9gMMfVCuOGv76RLKKICf/2qjlxIxAp iVpkubxEQYDK8hUtGbLFQTx/CkddvAp+/mBgGDcI= Received: from [100.100.57.122] (unknown [58.34.185.106]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mailbox.box.xen0n.name (Postfix) with ESMTPSA id 8E4F6600A6; Mon, 22 May 2023 17:05:31 +0800 (CST) Message-ID: <588a03c7-ae1f-f449-752d-aa94cc1ab491@xen0n.name> Date: Mon, 22 May 2023 17:05:30 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH v14 1/2] drm: add kms driver for loongson display controller Content-Language: en-US To: Sui Jingfeng <15330273260@189.cn>, Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Sui Jingfeng , Li Yi , Sumit Semwal , Christian Koenig , Emil Velikov Cc: linaro-mm-sig@lists.linaro.org, loongson-kernel@lists.loongnix.cn, Geert Uytterhoeven , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Javier Martinez Canillas , Nathan Chancellor , Liu Peibao , linux-media@vger.kernel.org References: <20230520105718.325819-1-15330273260@189.cn> <20230520105718.325819-2-15330273260@189.cn> <26fd78b9-c074-8341-c99c-4e3b38cd861a@xen0n.name> <2f701944-588c-3f56-06f3-abcbbf12be1e@189.cn> From: WANG Xuerui In-Reply-To: <2f701944-588c-3f56-06f3-abcbbf12be1e@189.cn> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2023/5/22 16:51, Sui Jingfeng wrote: > Hi, > > On 2023/5/21 20:21, WANG Xuerui wrote: >> >>> >>> + >>> +static void lsdc_crtc0_soft_reset(struct lsdc_crtc *lcrtc) >>> +{ >>> +    struct lsdc_device *ldev = lcrtc->ldev; >>> +    u32 val; >>> + >>> +    val = lsdc_rreg32(ldev, LSDC_CRTC0_CFG_REG); >>> + >>> +    val &= CFG_VALID_BITS_MASK; >>> + >>> +    /* soft reset bit, active low */ >>> +    val &= ~CFG_RESET_N; >>> + >>> +    val &= ~CFG_PIX_FMT_MASK; >>> + >>> +    lsdc_wreg32(ldev, LSDC_CRTC0_CFG_REG, val); >>> + >>> +    udelay(5); >>> + >>> +    val |= CFG_RESET_N | LSDC_PF_XRGB8888 | CFG_OUTPUT_ENABLE; >>> + >>> +    lsdc_wreg32(ldev, LSDC_CRTC0_CFG_REG, val); >>> + >>> +    mdelay(20); >>> +} >>> + >>> +static void lsdc_crtc1_soft_reset(struct lsdc_crtc *lcrtc) >>> +{ >>> +    struct lsdc_device *ldev = lcrtc->ldev; >>> +    u32 val; >>> + >>> +    val = lsdc_rreg32(ldev, LSDC_CRTC1_CFG_REG); >>> + >>> +    val &= CFG_VALID_BITS_MASK; >>> + >>> +    /* soft reset bit, active low */ >>> +    val &= ~CFG_RESET_N; >>> + >>> +    val &= ~CFG_PIX_FMT_MASK; >>> + >>> +    lsdc_wreg32(ldev, LSDC_CRTC1_CFG_REG, val); >>> + >>> +    udelay(5); >>> + >>> +    val |= CFG_RESET_N | LSDC_PF_XRGB8888 | CFG_OUTPUT_ENABLE; >>> + >>> +    lsdc_wreg32(ldev, LSDC_CRTC1_CFG_REG, val); >>> + >>> +    msleep(20); >> >> So many magic sleeps without documentation? >> > It is just that you should wait the device for a while before it can > reaction when doing the soft reset. > > I think this is engineering... As an engineer myself, I fully concur with this, but I mainly wanted some explanation as to "why 5 there? why 20 here? why 9 there?" -- where did all the discrete values come from, implied by HDL or found out by experimentations? Can these be extracted to properly named constants? Can some of the values get coalesced into one without harming functionality? Can some of them get shorter? -- questions like this. > >>> + >>> +/* All loongson display controller support scanout position hardware */ >> >> Commit message implies only 7A2000+ LSDC IPs have the "scanout >> position recorders". Either that part or this code would need tweaking... > > Both LS7A2000 and LS7A1000 have the scanout position recorders hardware. > > Preciously, datasheet of LS7A1000 didn't told us if it support this > feature. > > I will adjust the commit message at next version, the code doesn't need > change. That's fine, the intent is always making the code more approachable and maintainable. Thanks. -- WANG "xen0n" Xuerui Linux/LoongArch mailing list: https://lore.kernel.org/loongarch/