Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp7066996rwp; Tue, 18 Jul 2023 09:31:33 -0700 (PDT) X-Google-Smtp-Source: APBJJlFw6nIpE1MYVlcqtMsveD0JqDtdWtLaXFT3ozi2PpEH2sK8sUcwKXOmrHBCchNWAUHWwvws X-Received: by 2002:a05:6402:2791:b0:514:a566:104a with SMTP id b17-20020a056402279100b00514a566104amr266944ede.3.1689697892867; Tue, 18 Jul 2023 09:31:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689697892; cv=none; d=google.com; s=arc-20160816; b=y6zTv3aB5NMGpchg4b1h6gmHb7q4gelS1IrLaHJktJC9ecXe5IiYC/HVztQ5qQCimm 8mrovqaB1PIRXSOdE1RqbTT2WikCGzePV0uHQA2wxYnTBujkMvQ+fAzocXlEVxqpccaJ p1Va9AyQv8DISmc9EhdcXzRelKEJ2NDrbT1Ry3PbP+euokiIOeTbis+gtPYHCCMbzakK A+sDoDkmgTEMoj4M1s+K4YvwdJ2pBG1+VNOPJIVqipmmMvJOtRjyqCaiy7eo7Uou180L xH12aE8lu0Nzm3qMkDhxsvikezrZ5DpwvHgcZoWRkyimODb9r4hllEb8UTTw+YFc5xY0 gQDg== 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; bh=hmaTIWhJ4MfIBSRMuemlm+p3dyNQ5//jcWKAGWhdE70=; fh=/5aYbXV50FAH+KpnMsSbDxip+rlUM4B5VPwbxcNyIGY=; b=eanHJXBjuVo18zSFRRfOFdxEJWmITmDzqQgjRVLsvU7vslLOtCn0nqF35+T8XCHx0F hwq6NSaUT6b8T7lH4Ht2QDJVbeQHxUpR26eYi7MOLxZFYcwfmTu+i+A6BN6/CuMWhxI0 A6RC3WGY33vXRYzdZAJwLIuZYpnRE55F1nfHuQAk85RB1v+dYh5p5MfELW8M5yWxG8vr UI28SjnFW520zoj8ctjHGg3QPPLHu0obYNsUbWTT64qkGmQLfMAJeRhRe2dYGRX0erw1 ios/HHMlILS16+HNfhLlgmN4SAJjNtMYHSSqdrdLW1CPZFJ9hbt6USmCaG/syn+IyiQH QbaQ== 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 a22-20020aa7d756000000b0051e472af82asi1431210eds.209.2023.07.18.09.31.08; Tue, 18 Jul 2023 09:31:32 -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 S232067AbjGRQQY (ORCPT + 99 others); Tue, 18 Jul 2023 12:16:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230178AbjGRQQX (ORCPT ); Tue, 18 Jul 2023 12:16:23 -0400 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EE74613E for ; Tue, 18 Jul 2023 09:16:19 -0700 (PDT) Received: from loongson.cn (unknown [10.20.42.43]) by gateway (Coremail) with SMTP id _____8AxDOvSurZk99cGAA--.12298S3; Wed, 19 Jul 2023 00:16:18 +0800 (CST) Received: from [10.20.42.43] (unknown [10.20.42.43]) by localhost.localdomain (Coremail) with SMTP id AQAAf8BxniPRurZkMX0zAA--.35913S3; Wed, 19 Jul 2023 00:16:17 +0800 (CST) Message-ID: <06b291d4-9cab-5179-2a90-a73449ddb2dd@loongson.cn> Date: Wed, 19 Jul 2023 00:16:17 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v1 3/8] drm/etnaviv: Drop the second argument of the etnaviv_gem_new_impl() Content-Language: en-US To: Lucas Stach , Sui Jingfeng , Russell King , Christian Gmeiner , David Airlie , Daniel Vetter Cc: loongson-kernel@lists.loongnix.cn, etnaviv@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org References: <20230623100822.274706-1-sui.jingfeng@linux.dev> <20230623100822.274706-4-sui.jingfeng@linux.dev> <862358e67a6f118b11ba16fb94828e9d1635cb66.camel@pengutronix.de> From: suijingfeng In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-CM-TRANSID: AQAAf8BxniPRurZkMX0zAA--.35913S3 X-CM-SenderInfo: xvxlyxpqjiv03j6o00pqjv00gofq/ X-Coremail-Antispam: 1Uk129KBj97XoW5WF1fGFyUKFWUWFy7XFyxp5X_Ary8JoWSv3 W3Ja1rGF95tws0k342gFn8A3yUC345Ga4Yq3WDAw4vqay7try7Wa1ftFWIvF10kF47Xwnr Ka43uwsrXFn5l-sFpf9Il3svdjkaLaAFLSUrUUUU0b8apTn2vfkv8UJUUUU8wcxFpf9Il3 svdxBIdaVrn0xqx4xG64xvF2IEw4CE5I8CrVC2j2Jv73VFW2AGmfu7bjvjm3AaLaJ3UjIY CTnIWjp_UUUOj7kC6x804xWl14x267AKxVWUJVW8JwAFc2x0x2IEx4CE42xK8VAvwI8IcI k0rVWrJVCq3wAFIxvE14AKwVWUXVWUAwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK 021l84ACjcxK6xIIjxv20xvE14v26r1I6r4UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r 1j6r4UM28EF7xvwVC2z280aVAFwI0_Jr0_Gr1l84ACjcxK6I8E87Iv6xkF7I0E14v26r1j 6r4UM2kKe7AKxVWUAVWUtwAS0I0E0xvYzxvE52x082IY62kv0487Mc804VCY07AIYIkI8V C2zVCFFI0UMc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUAVWUtwAv 7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcVAKI48JMxk0xI A0c2IEe2xFo4CEbIxvr21lc7CjxVAaw2AFwI0_JF0_Jw1l42xK82IYc2Ij64vIr41l4I8I 3I0E4IkC6x0Yz7v_Jr0_Gr1l4IxYO2xFxVAFwI0_JF0_Jw1lx2IqxVAqx4xG67AKxVWUJV WUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1q6r43MIIYrxkI7VAK I48JMIIF0xvE2Ix0cI8IcVAFwI0_JFI_Gr1lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r 4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY 6I8E87Iv6xkF7I0E14v26r1j6r4UYxBIdaVFxhVjvjDU0xZFpf9x07j5o7tUUUUU= X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,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 Hi, On 2023/7/18 16:12, Lucas Stach wrote: > Hi Jingfeng, > > Am Dienstag, dem 18.07.2023 um 02:34 +0800 schrieb suijingfeng: >> Hi,  Lucas >> >> >> Thanks for you guidance! >> >> >> On 2023/7/17 17:51, Lucas Stach wrote: >>> Hi Jingfeng, >>> >>> Am Freitag, dem 23.06.2023 um 18:08 +0800 schrieb Sui Jingfeng: >>>> From: Sui Jingfeng >>>> >>>> Because it is not used by the etnaviv_gem_new_impl() function, >>>> no functional change. >>>> >>> I think it would make sense to move into the opposite direction: in >>> both callsites of etnaviv_gem_new_impl we immediately call >>> drm_gem_object_init with the size. >> Really? >> >> But there are multiple call path to the etnaviv_gem_new_impl() function. >> >> >> Code path 1 (PRIME): >> >>> - etnaviv_gem_prime_import_sg_table() >>> --  etnaviv_gem_new_private() >>> --- etnaviv_gem_new_impl(dev, size, flags, ops, &obj) >>> --- drm_gem_private_object_init(dev, obj, size) >> >> Code path 2 (USERPTR): >> >>> - etnaviv_gem_new_userptr() >>> --  etnaviv_gem_new_private() >>> --- etnaviv_gem_new_impl(dev, size, flags, ops, &obj) >>> --- drm_gem_private_object_init(dev, obj, size) >> >> Code path 3 (construct a GEM buffer object for the user-space): >> >>> - etnaviv_ioctl_gem_new() >>> -- etnaviv_gem_new_handle() >>> --- etnaviv_gem_new_impl(dev, size, flags, &etnaviv_gem_shmem_ops, &obj); >>> ---  drm_gem_object_init(dev, obj, size); >> >> If I understand this correctly: >> >> >> Code path 1 is for cross device (and cross driver) buffer-sharing, >> >> Code path 2 is going to share the buffer the userspace, >> >> >> *Only* the code path 3 is to construct a GEM buffer object for the >> user-space the userspace, >> >> that is say, *only* the code path 3 need to do the backing memory >> allocation work for the userspace. >> >> thus it need to call drm_gem_object_init() function, which really the >> shmem do the backing memory >> >> allocation. >> >> >> The code path 1 and the code path 2 do not need the kernel space >> allocate the backing memory. >> >> Because they are going to share the buffer already allocated by others. >> >> thus, code path 2 and code path 3 should call drm_gem_private_object_init(), >> >> *not* the drm_gem_object_init() function. >> >> >> When import buffer from the a specific KMS driver, >> >> then etnaviv_gem_prime_import_sg_table() will be called. >> >> >> I guess you means that drm_gem_private_object_init() (not the >> drm_gem_object_init() function)here ? >> >> >>> A better cleanup would be to make >>> use of the size parameter and move this object init call into >>> etnaviv_gem_new_impl. >> If I following you guidance, how do I differentiate the cases >> >> when to call drm_gem_private_object_init() not drm_gem_object_init() ? >> >> and when call drm_gem_object_init() not drm_gem_private_object_init()? >> >> >> I don't think you are right here. >> > Yes, clearly I was not taking into account the differences between > drm_gem_private_object_init and drm_gem_object_init properly. Please > disregard my comment, this patch is good as-is. I have study your patch in the past frequently. As you could solve very complex(and difficulty) bugs. So I still believe that you know everything about etnaviv. I'm just wondering that you are designing the traps. But I'm not sure. Okay, still acceptable. Because communicate will you is interesting. Thank you. > Regards, > Lucas > >>> Regards, >>> Lucas >>> >>>> Signed-off-by: Sui Jingfeng >>>> --- >>>> drivers/gpu/drm/etnaviv/etnaviv_gem.c | 7 +++---- >>>> 1 file changed, 3 insertions(+), 4 deletions(-) >>>> >>>> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem.c b/drivers/gpu/drm/etnaviv/etnaviv_gem.c >>>> index b5f73502e3dd..be2f459c66b5 100644 >>>> --- a/drivers/gpu/drm/etnaviv/etnaviv_gem.c >>>> +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.c >>>> @@ -542,7 +542,7 @@ static const struct drm_gem_object_funcs etnaviv_gem_object_funcs = { >>>> .vm_ops = &vm_ops, >>>> }; >>>> >>>> -static int etnaviv_gem_new_impl(struct drm_device *dev, u32 size, u32 flags, >>>> +static int etnaviv_gem_new_impl(struct drm_device *dev, u32 flags, >>>> const struct etnaviv_gem_ops *ops, struct drm_gem_object **obj) >>>> { >>>> struct etnaviv_gem_object *etnaviv_obj; >>>> @@ -591,8 +591,7 @@ int etnaviv_gem_new_handle(struct drm_device *dev, struct drm_file *file, >>>> >>>> size = PAGE_ALIGN(size); >>>> >>>> - ret = etnaviv_gem_new_impl(dev, size, flags, >>>> - &etnaviv_gem_shmem_ops, &obj); >>>> + ret = etnaviv_gem_new_impl(dev, flags, &etnaviv_gem_shmem_ops, &obj); >>>> if (ret) >>>> goto fail; >>>> >>>> @@ -627,7 +626,7 @@ int etnaviv_gem_new_private(struct drm_device *dev, size_t size, u32 flags, >>>> struct drm_gem_object *obj; >>>> int ret; >>>> >>>> - ret = etnaviv_gem_new_impl(dev, size, flags, ops, &obj); >>>> + ret = etnaviv_gem_new_impl(dev, flags, ops, &obj); >>>> if (ret) >>>> return ret; >>>>