From: suijingfeng <suijingfeng@loongson.cn>
To: Jani Nikula <jani.nikula@linux.intel.com>,
David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>,
Thomas Zimmermann <tzimmermann@suse.de>, Li Yi <liyi@loongson.cn>
Cc: loongson-kernel@lists.loongnix.cn, linux-kernel@vger.kernel.org,
dri-devel@lists.freedesktop.org,
kernel test robot <lkp@intel.com>
Subject: Re: [PATCH] drm/loongson: Fix two warnings because of passing wrong type
Date: Mon, 10 Jul 2023 21:50:15 +0800 [thread overview]
Message-ID: <425f7fb4-265f-2d71-9554-eabafdd227d2@loongson.cn> (raw)
In-Reply-To: <87h6qcjc46.fsf@intel.com>
Hi,
On 2023/7/10 18:26, Jani Nikula wrote:
> On Mon, 10 Jul 2023, Sui Jingfeng <suijingfeng@loongson.cn> 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.
The reason why we don't fix this at the very beginning is that
we are following the ttm_kmap_obj_virtual() and the ttm_bo_kmap() function.
Our lsdc_bo_kmap() is implemented with the ttm_bo_kmap() function.
Another reason is that this warning don't emerge when compile with W=1,
at least this is true on our platform.
We don't think this warning is harmful, because implicit cast will do
the cast for us.
It is just that we need eliminate the noise as a programmer.
Again, for the code at here, before you do the de-reference operation,
As long as a address is really(originally) point to the I/O memory, cast
it to 'void __iomem *' is OK.
As long as a address is really(originally) 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 <lkp@intel.com>
>> Closes: https://lore.kernel.org/oe-kbuild-all/202307100243.v3hv6aes-lkp@intel.com/
>> Signed-off-by: Sui Jingfeng <suijingfeng@loongson.cn>
>> ---
>> 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);
next prev parent reply other threads:[~2023-07-10 13:50 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-10 10:09 Sui Jingfeng
2023-07-10 10:26 ` Jani Nikula
2023-07-10 13:10 ` suijingfeng
2023-07-11 8:03 ` Jani Nikula
2023-07-10 13:50 ` suijingfeng [this message]
2023-07-10 10:36 ` Thomas Zimmermann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=425f7fb4-265f-2d71-9554-eabafdd227d2@loongson.cn \
--to=suijingfeng@loongson.cn \
--cc=airlied@gmail.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=liyi@loongson.cn \
--cc=lkp@intel.com \
--cc=loongson-kernel@lists.loongnix.cn \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®