Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5035275rwl; Mon, 10 Apr 2023 22:40:03 -0700 (PDT) X-Google-Smtp-Source: AKy350bVpKoMkP1Pu9HUkS3T0zaxMJVW++cQw3z2zT9yHekAgiNfim2vfKNUONQDjjtlGFXuw0h2 X-Received: by 2002:a05:6402:12:b0:4fb:5fe1:bc3b with SMTP id d18-20020a056402001200b004fb5fe1bc3bmr10752921edu.0.1681191603455; Mon, 10 Apr 2023 22:40:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681191603; cv=none; d=google.com; s=arc-20160816; b=ncn1Boe2xw3efJln00WJP67fL3sqJDbv9ecmG4Edt28jajyal1TX3ZrWVSw9DhdEiZ +WeABxXLoAZRRxekwGQJJrmhss5JDCOQDWLQCGw1ZgKQ3oQVzNJtPgPpDxaM+Xq/r3s6 inSUGjWjR21AlijufGB4T01BIqJwwRA/FYOe7Ilq93/Y5aUOpeOHyeO87oHN8WmDjDi+ oBdA7fEBiJrkxJ8G7cLb0NpavrYNzFdoIaHOx7smjKBlcub1T9amidL4fJeWf28mFCVY /A7WMYgotwrxcWyXrMVTnpCZ6YV2pUnTA6cGybMgLR52B9F9bNdElCOFjB4A0P6AVkgV eypQ== 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:sender:hmm_source_type:hmm_attache_num :hmm_source_ip; bh=yuxb++w4K4oamNPVX4d4yww4HjIPTbv0wIzKs3PRotg=; b=yqcI0bQkibghqRsg4WqrF3NhqvkGsSk5WNIJzmiLIut/mLx15aTAkT7+4XMm2XYeA+ qkCUoSjREZYXtEWT9vkZWGPpBrGP5//olVnokyAeO4lgHuFyc4A3oL4R1PYQ79YIT1uv 6dButYpy/VJvN9Is7P/OCalvt2rijpVQEscWtMf0xcDdLsbVzcgL8MbqXz5DtbL3n/6d M8T754bzzLaKWfH4tiYTnL4fNe0E0+VOkwPRUaA3WRXnlIDaee7e/+r2Ek26OEifGfsa mw56D8parTbHjSJid41H5enCcYFoxeMWHyX7Heb2TTkrBwwyU6IvUGXnaGonchq8OtDh slJQ== ARC-Authentication-Results: i=1; mx.google.com; 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 h5-20020a50ed85000000b00504a290ccccsi3997017edr.6.2023.04.10.22.39.39; Mon, 10 Apr 2023 22:40: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; 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 S229960AbjDKFjR (ORCPT + 99 others); Tue, 11 Apr 2023 01:39:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229694AbjDKFjP (ORCPT ); Tue, 11 Apr 2023 01:39:15 -0400 Received: from 189.cn (ptr.189.cn [183.61.185.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C5AE02D41; Mon, 10 Apr 2023 22:39:12 -0700 (PDT) HMM_SOURCE_IP: 10.64.8.43:59606.589911955 HMM_ATTACHE_NUM: 0000 HMM_SOURCE_TYPE: SMTP Received: from clientip-114.242.206.180 (unknown [10.64.8.43]) by 189.cn (HERMES) with SMTP id 6BC8C1002F6; Tue, 11 Apr 2023 13:39:08 +0800 (CST) Received: from ([114.242.206.180]) by gateway-151646-dep-7b48884fd-tj646 with ESMTP id f7efde40c6bc459b9f649b6547f1e147 for emil.l.velikov@gmail.com; Tue, 11 Apr 2023 13:39:11 CST X-Transaction-ID: f7efde40c6bc459b9f649b6547f1e147 X-Real-From: 15330273260@189.cn X-Receive-IP: 114.242.206.180 X-MEDUSA-Status: 0 Sender: 15330273260@189.cn Message-ID: Date: Tue, 11 Apr 2023 13:39:07 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [PATCH v10 2/2] drm: add kms driver for loongson display controller Content-Language: en-US To: Emil Velikov Cc: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Sumit Semwal , Christian Koenig , linaro-mm-sig@lists.linaro.org, Li Yi , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, nathan@kernel.org, linux-media@vger.kernel.org, loongson-kernel@lists.loongnix.cn References: <20230403171304.2157326-1-suijingfeng@loongson.cn> <20230403171304.2157326-3-suijingfeng@loongson.cn> From: Sui Jingfeng <15330273260@189.cn> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.7 required=5.0 tests=FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,FROM_LOCAL_DIGITS,FROM_LOCAL_HEX,NICE_REPLY_A, SPF_HELO_PASS,SPF_PASS autolearn=unavailable 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 Hi, On 2023/4/4 22:10, Emil Velikov wrote: >> +static void lsdc_crtc_reset(struct drm_crtc *crtc) >> +{ >> + struct lsdc_display_pipe *dispipe = crtc_to_display_pipe(crtc); >> + struct drm_device *ddev = crtc->dev; >> + struct lsdc_device *ldev = to_lsdc(ddev); >> + struct lsdc_crtc_state *priv_crtc_state; >> + unsigned int index = dispipe->index; >> + u32 val; >> + >> + val = LSDC_PF_XRGB8888 | CFG_RESET_N; >> + if (ldev->descp->chip == CHIP_LS7A2000) >> + val |= LSDC_DMA_STEP_64_BYTES; >> + >> + lsdc_crtc_wreg32(ldev, LSDC_CRTC0_CFG_REG, index, val); >> + >> + if (ldev->descp->chip == CHIP_LS7A2000) { >> + val = PHY_CLOCK_EN | PHY_DATA_EN; >> + lsdc_crtc_wreg32(ldev, LSDC_CRTC0_PANEL_CONF_REG, index, val); >> + } >> + > AFAICT no other driver touches the HW in their reset callback. Should > the above be moved to another callback? > You may correct in the 95% of all cases. After reading the comments of the reset callback of struct drm_crtc_funcs in drm_crtc.h, It seems that it does not prohibit us to touches the hardware. I copy that comments and paste into here for easier to read,as below:     /*      * @reset:      *      * Reset CRTC hardware and software state to off. This function isn't      * called by the core directly, only through drm_mode_config_reset().      * It's not a helper hook only for historical reasons.      *      * Atomic drivers can use drm_atomic_helper_crtc_reset() to reset      * atomic state using this hook.      */ It seem allowable to reset CRTC hardware in this callback, did it cue us? What we know is that this reset callback (and others, such as encoder's reset) is called by drm_mode_config_reset(). It is the first set of functions get called before other hardware related callbacks. I don't not see how other drivers implement this callback, after you mention this I skim over a few, I found tilcdc also writing the hardware in their tilcdc_crtc_reset() function. See it in drm/tildc/tilclc_crtc.c In addition, Loongson platform support efifb,  in order to light up the monitor in firmware stage and the booting stage, the firmware touch the display hardware register directly. After efifb get kick out, when drm/loongson driver taken over the hardware, the register setting state still remain in the hardware register. Those register setting may no longer correct for the subsequent operationd. What we doing here is to giving the hardware a basic healthy state prepare to be update further. As the reset callback is call very early, we found that it's the best fit. The reset will also get called when resume(S3). The problem is that we don't find a good to place to move those setting currently.