Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp35345296rwd; Mon, 10 Jul 2023 06:16:06 -0700 (PDT) X-Google-Smtp-Source: APBJJlEnzcwXXidTs6u2bJB5cJj5nkA0CVdaTApKbP3xYnGIJ51Z8YrfF1yHlKSX2IBKxfm0lUOy X-Received: by 2002:ac2:4bc8:0:b0:4fb:8c52:611 with SMTP id o8-20020ac24bc8000000b004fb8c520611mr11917053lfq.38.1688994965930; Mon, 10 Jul 2023 06:16:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688994965; cv=none; d=google.com; s=arc-20160816; b=JHQzXONIFcUJNftmWDG3pX3BCGKpfKFB5nI6ZhthTfp5+xpHbC4zNvfUp2cO8/sIGz B950IaBsuOs2UuJ6UlG0e7+uSg0aC81qpzd2odlbc2gBOTWM6F6hss9UWuIKx3Cq8jwz 1nVaqAIbEiVRi0whVmhVM4ta6JNiKMeTWir8JJaaEimpoSJ2Q6VSJ3Tv9cvUzIDcZN2z +zENqrbcgI9OhY7stzQLRL8uNmTenicJv6UUjAPZPD/yo7WPr8Bm04PSZGiA95k7f3/z pzDGh4fXvF0JKVhzYjJ8GaV0i9wVrGVyCwRQULuyPhac/jRdkv8RpcakboDZEKD/zA3d 8rGQ== 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=G9uLYXLUt2VQg6uf5aje/xBTq/6a7/5d3xW4WUFH3hM=; fh=lIn0zXxGLzxuPQcrmHUw12atC9DV8UhQBm5FCbwUHy0=; b=xQh/Wpv+KV7tSvXInvPlFKG03RGziUDepCVIzZaujevgxylHYb11a+I5z7yGBUaS4P Ofq7IaQcDybtCXZoPBhxVPRx24FIqOvQIoqaoo518YiGQ5FZtPm0rDOgJBUgk9JYknHY hOPYbbv9Hh3pRriZxsj+8xANwYW7Q6iwTgwsE9mW3jJwH7YcDMx+hRhPKqr9/68xKFmc /gnjclQFeUEaMZgmziYSLV2whK0zMDhF5khRsTE23/NYen+1Xa9YJDd12BP4+efJtgfj 9UWrFCMmKU3/FlZkxaojhL/w4Iin/jBJlkL0optGIoPs9HAAO1d/ESz3Fi4efsL03N8G QAzQ== 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 t21-20020aa7d4d5000000b0051e168ec86csi6459668edr.310.2023.07.10.06.15.40; Mon, 10 Jul 2023 06:16: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 S229863AbjGJNKp (ORCPT + 99 others); Mon, 10 Jul 2023 09:10:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229939AbjGJNKn (ORCPT ); Mon, 10 Jul 2023 09:10:43 -0400 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 813A0FA for ; Mon, 10 Jul 2023 06:10:28 -0700 (PDT) Received: from loongson.cn (unknown [10.20.42.43]) by gateway (Coremail) with SMTP id _____8Cx7+tBA6xkUCsDAA--.8164S3; Mon, 10 Jul 2023 21:10:25 +0800 (CST) Received: from [10.20.42.43] (unknown [10.20.42.43]) by localhost.localdomain (Coremail) with SMTP id AQAAf8AxX89BA6xkv1snAA--.45620S3; Mon, 10 Jul 2023 21:10:25 +0800 (CST) Message-ID: Date: Mon, 10 Jul 2023 21:10:25 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH] drm/loongson: Fix two warnings because of passing wrong type Content-Language: en-US To: Jani Nikula , David Airlie , Daniel Vetter , Thomas Zimmermann , Li Yi Cc: loongson-kernel@lists.loongnix.cn, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, kernel test robot References: <20230710100931.255234-1-suijingfeng@loongson.cn> <87h6qcjc46.fsf@intel.com> From: suijingfeng In-Reply-To: <87h6qcjc46.fsf@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-CM-TRANSID: AQAAf8AxX89BA6xkv1snAA--.45620S3 X-CM-SenderInfo: xvxlyxpqjiv03j6o00pqjv00gofq/ X-Coremail-Antispam: 1Uk129KBj93XoWxZr47KFWrKr48Zr43tw13trc_yoW5XFW8pF s8Ca4Utr4DJr12yrs7WF1jq34Fv3Z3XFWSqrZrC3Z09w1DJr1UZF1kuay5Kry3ZFWjy3Wa yrs3GrW3K3ZFvwcCm3ZEXasCq-sJn29KB7ZKAUJUUUUx529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUPqb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1Y6r17M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Gr0_Xr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AK xVW8Jr0_Cr1UM2kKe7AKxVWUAVWUtwAS0I0E0xvYzxvE52x082IY62kv0487Mc804VCY07 AIYIkI8VC2zVCFFI0UMc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWU AVWUtwAv7VC2z280aVAFwI0_Cr0_Gr1UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvEwI xGrwCYjI0SjxkI62AI1cAE67vIY487MxkF7I0En4kS14v26r126r1DMxAIw28IcxkI7VAK I48JMxC20s026xCaFVCjc4AY6r1j6r4UMxCIbckI1I0E14v26r126r1DMI8I3I0E5I8CrV AFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUtVW8ZwCI c40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1I6r4UMIIF0xvE2Ix0cI8IcVCY1x0267 AKxVWUJVW8JwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Cr0_ Gr1UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x07jb_- PUUUUU= X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,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/10 18:26, Jani Nikula wrote: > On Mon, 10 Jul 2023, Sui Jingfeng wrote: >> When accessing I/O memory, we should pass '__iomem *' type instead of >> 'void *' simply, otherwise sparse tests will complain. After applied >> this patch, the following two sparse warnings got fixed. > Usually the commit message should explain why it's okay to cast away the > warning. > > Because realistically this doesn't "fix" the warning, this merely hides > it. My understanding is that a point itself is just a variable where store a address, if this address originally point to I/O memory, then, we can other cast it to u64 type, then cast it back to '__iomem *' again. as long as the type's  bit-width is width enough to store this address, we won't lost the information. 'void *' or 'u64' is just a intermediate represent of the address. we can other cast it to u64 type, then cast it back to 'void __iomem *' or 'void *' again. Why it's okay ? My answer is that As long as a address is really point to the I/O memory, cast it to 'void __iomem *' is OK. As long as a address is really point to the system memory, cast it to 'void *' is OK. > BR, > Jani. > >> 1) drivers/gpu/drm/loongson/lsdc_benchmark.c:27:35: >> sparse: expected void volatile [noderef] __iomem * >> sparse: got void *kptr >> >> 2) drivers/gpu/drm/loongson/lsdc_benchmark.c:42:51: >> sparse: expected void const volatile [noderef] __iomem * >> sparse: got void *kptr >> >> Reported-by: kernel test robot >> Closes: https://lore.kernel.org/oe-kbuild-all/202307100243.v3hv6aes-lkp@intel.com/ >> Signed-off-by: Sui Jingfeng >> --- >> drivers/gpu/drm/loongson/lsdc_benchmark.c | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/gpu/drm/loongson/lsdc_benchmark.c b/drivers/gpu/drm/loongson/lsdc_benchmark.c >> index b088646a2ff9..36e352820bdb 100644 >> --- a/drivers/gpu/drm/loongson/lsdc_benchmark.c >> +++ b/drivers/gpu/drm/loongson/lsdc_benchmark.c >> @@ -24,7 +24,7 @@ static void lsdc_copy_gtt_to_vram_cpu(struct lsdc_bo *src_bo, >> lsdc_bo_kmap(dst_bo); >> >> while (n--) >> - memcpy_toio(dst_bo->kptr, src_bo->kptr, size); >> + memcpy_toio((void __iomem *)dst_bo->kptr, src_bo->kptr, size); >> >> lsdc_bo_kunmap(src_bo); >> lsdc_bo_kunmap(dst_bo); >> @@ -39,7 +39,7 @@ static void lsdc_copy_vram_to_gtt_cpu(struct lsdc_bo *src_bo, >> lsdc_bo_kmap(dst_bo); >> >> while (n--) >> - memcpy_fromio(dst_bo->kptr, src_bo->kptr, size); >> + memcpy_fromio(dst_bo->kptr, (void __iomem *)src_bo->kptr, size); >> >> lsdc_bo_kunmap(src_bo); >> lsdc_bo_kunmap(dst_bo);