Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5415874rwl; Tue, 11 Apr 2023 05:17:05 -0700 (PDT) X-Google-Smtp-Source: AKy350aR3jPOvtzw0pbqO6GCVmBXob2Zz4l1XTsiUukn6t0/f9p7/yo32dLpzFTGx3cahB5dtXvG X-Received: by 2002:a17:906:2b97:b0:931:6921:bdb7 with SMTP id m23-20020a1709062b9700b009316921bdb7mr8927918ejg.60.1681215425362; Tue, 11 Apr 2023 05:17:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681215425; cv=none; d=google.com; s=arc-20160816; b=yuMQWNuWk5MDbNjNALanQW0lDkGq9JVxPa0XHXrwpFRmZnvD2TKy7WBDv+s3APD2cX G7+8d3HCu+5MafxJy4XGGqrxtWrixnO+QIKeDoaFm1cHCIZIqmG3putQOWooIFrns7Nz gtMHREdTMVhM+qHSmqx5kw0NdUdyv8FHl8NQIeyptXyJaBcVz3mwLPJBbL6J+1ktlwOO 7zEPuKlwGK3oEXahue3UFFUZoBMTc8+I8Q7n1WAcvo7t1x5oXP8Ftlld39Fb25V0kg9A fAYRjqhcUp65V1DV9OV+l3tLPD+IFg5OifL0EiGyJxKKmdUkvvLGUD8X5k+uT17xDu1K vmNg== 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=gUgUTb498vZcMqpXaX9ZusUOOD/oHFhVUpCMXPJSY8k=; b=CCqbFX98fwXR8xZZ2k3o5xNgkIxREQQR3ItQP0nOL0RPtMHpQlLO7VdFpqZdOG6g6f G6XYBpDOmxcPlBGH0ltsvH+0ohqAY1JyVj0L9R4tZfLZ5LdOAtk2QXb75weGGoCqrGPU kjeOBK5yiMZ7tGK9yFXYQj58OqJ/QcnQaHDaktkfLXFeGI0ZVdzryIa8jrtWkezUbIK7 0kKblLlkSDoPtt/I23kJztzwWJRuY8V6JZhKBKqbdZHJSKNLPACyF3CF+Ix3aYzbFJfh gkPznhoDboopQoi5CbhxmY7W/OyCMIm06MGs+y0Lg0NcTa9ewviRRy28gxzMJaWo5Ytw SAKg== 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 gs15-20020a170906f18f00b0093e19977b9esi3086640ejb.126.2023.04.11.05.16.39; Tue, 11 Apr 2023 05:17:05 -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 S229906AbjDKMQA (ORCPT + 99 others); Tue, 11 Apr 2023 08:16:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229617AbjDKMP7 (ORCPT ); Tue, 11 Apr 2023 08:15:59 -0400 Received: from 189.cn (ptr.189.cn [183.61.185.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0BAA93A91; Tue, 11 Apr 2023 05:15:54 -0700 (PDT) HMM_SOURCE_IP: 10.64.8.41:43318.1095697603 HMM_ATTACHE_NUM: 0000 HMM_SOURCE_TYPE: SMTP Received: from clientip-114.242.206.180 (unknown [10.64.8.41]) by 189.cn (HERMES) with SMTP id 7164810020E; Tue, 11 Apr 2023 20:15:51 +0800 (CST) Received: from ([114.242.206.180]) by gateway-151646-dep-7b48884fd-ljp89 with ESMTP id c863400433aa4172ade34a0a231e4e5e for emil.l.velikov@gmail.com; Tue, 11 Apr 2023 20:15:53 CST X-Transaction-ID: c863400433aa4172ade34a0a231e4e5e 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 20:15:50 +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=-1.6 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: >> +++ b/drivers/gpu/drm/loongson/lsdc_drv.h >> @@ -0,0 +1,324 @@ >> +/* SPDX-License-Identifier: GPL-2.0 */ >> +/* >> + * Copyright (C) 2022 Loongson Corporation >> + * > We're in 2023, update the year across the files? > OK, it just that we started to upstream this driver since 2022. >> +struct lsdc_gem { >> + /* @mutex: protect objects list */ >> + struct mutex mutex; >> + struct list_head objects; >> +}; >> + >> +struct lsdc_device { >> + struct drm_device base; >> + struct ttm_device bdev; >> + >> + /* @descp: features description of the DC variant */ >> + const struct lsdc_desc *descp; >> + >> + struct pci_dev *gpu; >> + >> + /* @reglock: protects concurrent access */ >> + spinlock_t reglock; >> + void __iomem *reg_base; >> + resource_size_t vram_base; >> + resource_size_t vram_size; >> + >> + resource_size_t gtt_size; >> + >> + struct lsdc_display_pipe dispipe[LSDC_NUM_CRTC]; >> + >> + struct lsdc_gem gem; >> + > Last time I looked there was no other driver with a list of gem > objects (and a mutex) in its device struct. Are you sure we need this? Sure, this is absolutely necessary. Without this I can't see how much buffer object has been created. where they are(SYETEM, GTT or VRAM) and how much size it the buffer is. When sharing buffer with other driver,   cat /sys/kernel/debug/dri/0/bos can be used to see that the shared buffer is pinned in the GTT. > Very few drivers use TTM directly and I think you want to use > drm_gem_vram_helper or drm_gem_ttm_helper instead. We love you reviews,  yet... yet using the TTM is pretty good. drm_gem_vram_helper is also good for beginners. We can explicitly specify where to put the bo with TTM, We also need this to implement the S3 properly. Thomas also recommend us switch to TTM. >> +static int ls7a1000_pixpll_param_update(struct lsdc_pll * const this, >> + struct lsdc_pll_parms const *pin) >> +{ >> + void __iomem *reg = this->mmio; >> + unsigned int counter = 0; >> + bool locked; >> + u32 val; >> + >> + /* Bypass the software configured PLL, using refclk directly */ >> + val = readl(reg + 0x4); >> + val &= ~(1 << 8); >> + writel(val, reg + 0x4); >> + > There are a lot of magic numbers in this function. Let's define them > properly in the header. > Ok, I  will improve this function at the next version. >> +/* Helpers for chip detection */ >> +bool lsdc_is_ls2k2000(void); >> +bool lsdc_is_ls2k1000(void); >> +unsigned int loongson_cpu_get_prid(u8 *impl, u8 *rev); > Since this revision does pci_devices only, we don't need this detection right? No, we need it. In order to get a fine control, we need to know what the host is.