Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1891573rwb; Sat, 19 Nov 2022 05:31:30 -0800 (PST) X-Google-Smtp-Source: AA0mqf4SClqyE6KmAFuZesIhwWuqiBdrQCMXtLuoJjRDy3/9hfO/4jCHpaUm2lnqUdeQ86gWl2KP X-Received: by 2002:a17:90b:3544:b0:218:8666:f0fc with SMTP id lt4-20020a17090b354400b002188666f0fcmr7834282pjb.184.1668864690690; Sat, 19 Nov 2022 05:31:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668864690; cv=none; d=google.com; s=arc-20160816; b=jcApMVyen6cOfUgE/pJFknbMsTPpqLQ5LiuFtv1qjVV06cIdRD3QBbou2DgxQaa3BD aTCq+TpkllwKgESpONxZRlJ3Ti28vDWL9WWhDRF/wFtm7BBzT76uBVdWM3NsWJIgziJM TZ5GsdmC/jtdb1cYGVdbmLzOn1h2kZBBID7YRKbn6Nf6i3zIP+JHdguG64pTbGZ8Wt9q 3w6bEfLf29W/grQLjwTAR+wHwbWpdCNtJ1XLh6BT5edBxy/BWT93hFPB2dKu92kHHFXk TFfsWcIGiaKIsRZcNXRaseyOrOEVR5QnY3bnVfoWKl6YhacIMpqNVBylxHnH5dXJYXXS 7MdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=fy6afVpQVp+s47iXbRFbTFn/d/ubN9Lj4kkhTdq2T2g=; b=ctvTijOjcgB2WO4V32xa0UYa9DQQ1TCVbOxsI/lfcvgDFux62ufynKtHwfGWN1hFMC 1N8nF66z4MiHLqVLhWWUvI00OgRay5aZ1HQ+YY1XYKuN4sTKL1br+FlM8WCrZwzfFCDj YFqr0FCZv9XnEJ+ve1Lk4PN1v3n/PtMp+fT4jff7vgwsa2oJk39WJ8gPBs1VjyFpeaQ0 IMIIEW5jbpCiff1+b1GQFEcuh1+PmW4WGxcwwPOv+TX9W9EXWSSD0skJLV6FTjpBm9d4 yJ3ofb5+f0dh5B+aZmqBiBwu9XIuqUotUyfwLMHDLxD86q/zUadbLpWrk0+4mXLe20Bb 7yyw== 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 e5-20020a17090301c500b00186c41eced7si7321729plh.36.2022.11.19.05.31.12; Sat, 19 Nov 2022 05:31:30 -0800 (PST) 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 S230398AbiKSNRM (ORCPT + 92 others); Sat, 19 Nov 2022 08:17:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229601AbiKSNRK (ORCPT ); Sat, 19 Nov 2022 08:17:10 -0500 Received: from cstnet.cn (smtp23.cstnet.cn [159.226.251.23]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3D61A8B12A for ; Sat, 19 Nov 2022 05:17:05 -0800 (PST) Received: from localhost.localdomain (unknown [124.16.138.125]) by APP-03 (Coremail) with SMTP id rQCowACXn5dD13hjEbIYAA--.22946S2; Sat, 19 Nov 2022 21:16:51 +0800 (CST) From: Jiasheng Jiang To: contact@emersion.fr Cc: harry.wentland@amd.com, sunpeng.li@amd.com, Rodrigo.Siqueira@amd.com, alexander.deucher@amd.com, christian.koenig@amd.com, Xinhui.Pan@amd.com, airlied@gmail.com, daniel@ffwll.ch, nicholas.kazlauskas@amd.com, roman.li@amd.com, aurabindo.pillai@amd.com, Jerry.Zuo@amd.com, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, Jiasheng Jiang Subject: [PATCH] drm/amd/display: rewrite the check for mods Date: Sat, 19 Nov 2022 21:16:50 +0800 Message-Id: <20221119131650.21525-1-jiasheng@iscas.ac.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: rQCowACXn5dD13hjEbIYAA--.22946S2 X-Coremail-Antispam: 1UD129KBjvdXoWrur1fCrW7JF1UZrykKFWxJFb_yoWkKwb_WF 1kC3WDuw1DuF1Fvrs5G343CwsIyF4kJr1IgFs3tw4Dtwn8WrZ5Xr92v3s3Ga1xur4ftrsr GF1qv343Xw1DujkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbV8FF20E14v26ryj6rWUM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8w A2z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Cr0_ Gr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s 0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xII jxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr 1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4IIrI8v6xkF7I0E8cxa n2IY04v7MxkIecxEwVAFwVW5GwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJV W8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF 1VAFwI0_GFv_WrylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6x IIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvE x4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvj DU0xZFpf9x0JU3uc_UUUUU= X-Originating-IP: [124.16.138.125] X-CM-SenderInfo: pmld2xxhqjqxpvfd2hldfou0/ X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS 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 Thu, 17 Nov 2022 15:56:09 +0800, Simon Ser wrote: >> @@ -638,11 +638,14 @@ static int get_plane_modifiers(struct amdgpu_device *adev, unsigned int plane_ty >> return 0; >> >> *mods = kmalloc(capacity * sizeof(uint64_t), GFP_KERNEL); >> + if (!*mods) >> + return -ENOMEM; >> + >> >> if (plane_type == DRM_PLANE_TYPE_CURSOR) { >> add_modifier(mods, &size, &capacity, DRM_FORMAT_MOD_LINEAR); >> add_modifier(mods, &size, &capacity, DRM_FORMAT_MOD_INVALID); >> - return *mods ? 0 : -ENOMEM; >> + return 0; >> } >> >> switch (adev->family) { >> @@ -671,9 +674,6 @@ static int get_plane_modifiers(struct amdgpu_device *adev, unsigned int plane_ty >> /* INVALID marks the end of the list. */ >> add_modifier(mods, &size, &capacity, DRM_FORMAT_MOD_INVALID); >> >> - if (!*mods) >> - return -ENOMEM; >> - >> return 0; >> } > This breaks the "size" out-parameter. No, it will not change the value of the "size". The "size" can only be modified by add_modifier(). However, when the "*mods" is NULL, add_modifier() will return immediately, without the execution of "*size += 1;". Therefore, when the "*mods" is NULL, the rest of the function is useless, which should be better to skip. Jiang