Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5313936rwl; Tue, 11 Apr 2023 03:45:57 -0700 (PDT) X-Google-Smtp-Source: AKy350YM2uoi9OiAwF/UhJ4+Bv+1ec74Wi2W532Zqrh+u9s7NvzW66a2GcwqO2hYcry1o1/r98Rk X-Received: by 2002:a17:90b:4c11:b0:246:b2de:f13f with SMTP id na17-20020a17090b4c1100b00246b2def13fmr6724561pjb.24.1681209956796; Tue, 11 Apr 2023 03:45:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681209956; cv=none; d=google.com; s=arc-20160816; b=DLhfAtXBWiJmpYeffTgkaXIGYVSZ/JoffXgSwQz02Ko+LJVpuaznydZuoTjmi6j2EI XQ+grB7Nbki7wGL1bOlB/D0Ziw+ApjrrTASeYbIqN2I4iUv1r2mIqn9bbeUWbvX4udOr h/cDC9T0POurSP0bc7j64Ohfe7Um04y2dhUVLm3lzZtCJ1nPI8AvkLMJ6zWrqF7SX1Iz R+VtuJqiXHLAHmgrDFHKxqMrVAJtnpm03H5KyvzuWlwxjI9huuH65azA0HdLFfMUEZSk ErnPA7r/Ylb4+JO3Ic7hHMDF0aOGK5bz+oAzwQjjcKjAuqaOtPExpGAhtxD1MU2m1WTF xaIw== 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=18L9iY5MudeqP69UrPCP6HAtOtyiN3KILw3wh90KDhY=; b=rhLKeCwPe9kINxDIMUE/bh2CFs+eJioHi1AsRVVgzSShtwIzJtvuX9Lf1beovHqWYI KY1uMLG4DS6jB7e7/EWctzSvLXsP1Lwfaeon1yvYth4rRbqxmUlEkelPOMQxrCQzu+kp /NqAPEyPP9zfAnflyVe7eVQbPAkH6UMD6um8fnj4gIYOIroRB9fFrtg6Pxh1Oyn7oHcm QhvnfwnR7ycn2OgQGh/cdeq02WRbvNcrsNTaYe/Dfd40o6eGOOjslTIbF2XCeS+Pz9Yn 68AJVttlybclv8pQvlzT6kpJn2u2wb8x1ogUUeAilrfUaUCiuLoBpT+OnFwfy9KRRZIc knNA== 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 q11-20020a17090a2dcb00b00240263ef11bsi6810000pjm.120.2023.04.11.03.45.44; Tue, 11 Apr 2023 03:45:56 -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 S229745AbjDKKVo (ORCPT + 99 others); Tue, 11 Apr 2023 06:21:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229581AbjDKKVn (ORCPT ); Tue, 11 Apr 2023 06:21:43 -0400 Received: from 189.cn (ptr.189.cn [183.61.185.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id DA4ECDD; Tue, 11 Apr 2023 03:21:40 -0700 (PDT) HMM_SOURCE_IP: 10.64.8.43:55572.1747296415 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 F1B78100208; Tue, 11 Apr 2023 18:21:37 +0800 (CST) Received: from ([114.242.206.180]) by gateway-151646-dep-7b48884fd-tj646 with ESMTP id 8ce6a0aaf01b4ef78285af8e79f77ddf for emil.l.velikov@gmail.com; Tue, 11 Apr 2023 18:21:39 CST X-Transaction-ID: 8ce6a0aaf01b4ef78285af8e79f77ddf X-Real-From: 15330273260@189.cn X-Receive-IP: 114.242.206.180 X-MEDUSA-Status: 0 Sender: 15330273260@189.cn Message-ID: <860cb3b3-5247-c6ad-c13a-619cde221208@189.cn> Date: Tue, 11 Apr 2023 18:21:37 +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: >> +static enum drm_mode_status >> +lsdc_mode_config_mode_valid(struct drm_device *ddev, >> + const struct drm_display_mode *mode) >> +{ >> + struct lsdc_device *ldev = to_lsdc(ddev); >> + const struct drm_format_info *info = drm_format_info(DRM_FORMAT_XRGB8888); > Short-term hard coding a format is fine, but there should be a comment > describing why. Because our driver only support DRM_FORMAT_XRGB8888 frame buffer currently. After carry out the IGT test, I found this function may not sufficient  anymore. >> + u64 min_pitch = drm_format_info_min_pitch(info, 0, mode->hdisplay); >> + u64 fb_size = min_pitch * mode->vdisplay; >> + >> + if (fb_size * 3 > ldev->vram_size) { > Why are we using 3 here? Please add an inline comment. > Originally lsdc_mode_config_mode_valid() is copy from drm_gem_vram_helper.c with the observation that there no need for the compute of the number of pages in the terms of PAGE_SIZE. The '3' here is  a experience number, it intend to restrict single allocation overlarge. In my opinion, it stand for one frame buffer plus another two dumb buffer allocation when running  the running pageflip test(from the libdrm modetest). Therefore, the kernel space drm driver should guarantee at least 3 times frame buffer allocation to the user-space. Otherwise, the pageflip test can not even being able to run. While when testing this driver with IGT, I found the  dumb_buffer test of IGT will try to create a very large dumb buffer,  as large as 256MB in my case. Currently our driver could not satisfy such a large allocation, I test it with drm/radeon driver on LoongArch and X86-64, redeon can not even passing it. The restriction put in here is not effective anymore, because it is too late. I'm think we should put the restriction in the lsdc_dumb_create() function. We will revise our driver at next version. Great thanks for your valuable reviews.