soc.lore.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] soc: kunpeng_hccs: fix some sparse warnings about incorrect type
@ 2023-08-15 12:52 Huisong Li
  2023-08-16  7:37 ` [PATCH v2] " Huisong Li
  2023-08-16 13:17 ` [PATCH] " Arnd Bergmann
  0 siblings, 2 replies; 8+ messages in thread
From: Huisong Li @ 2023-08-15 12:52 UTC (permalink / raw)
  To: xuwei5, arnd, arnd
  Cc: linux-kernel, soc, linux-arm-kernel, liuyonglong, lihuisong

This patch fixes some sparse warnings about incorrect type.
The address about PCC communication space should use '__iomem' tag.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202308151142.dH5Muhva-lkp@intel.com/
Fixes: 886bdf9c883b ("soc: hisilicon: Support HCCS driver on Kunpeng SoC")
Signed-off-by: Huisong Li <lihuisong@huawei.com>
---
 drivers/soc/hisilicon/kunpeng_hccs.c | 13 +++++++------
 drivers/soc/hisilicon/kunpeng_hccs.h |  2 +-
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/soc/hisilicon/kunpeng_hccs.c b/drivers/soc/hisilicon/kunpeng_hccs.c
index 0d6f6bacd3f6..4e94753ab0f7 100644
--- a/drivers/soc/hisilicon/kunpeng_hccs.c
+++ b/drivers/soc/hisilicon/kunpeng_hccs.c
@@ -156,8 +156,8 @@ static int hccs_register_pcc_channel(struct hccs_dev *hdev)
 	}
 
 	if (pcc_chan->shmem_base_addr) {
-		cl_info->pcc_comm_addr = (void __force *)ioremap(
-			pcc_chan->shmem_base_addr, pcc_chan->shmem_size);
+		cl_info->pcc_comm_addr = ioremap(pcc_chan->shmem_base_addr,
+						 pcc_chan->shmem_size);
 		if (!cl_info->pcc_comm_addr) {
 			dev_err(dev, "Failed to ioremap PCC communication region for channel-%d.\n",
 				hdev->chan_id);
@@ -177,7 +177,8 @@ static int hccs_register_pcc_channel(struct hccs_dev *hdev)
 static int hccs_check_chan_cmd_complete(struct hccs_dev *hdev)
 {
 	struct hccs_mbox_client_info *cl_info = &hdev->cl_info;
-	struct acpi_pcct_shared_memory *comm_base = cl_info->pcc_comm_addr;
+	struct acpi_pcct_shared_memory __iomem *comm_base =
+							cl_info->pcc_comm_addr;
 	u16 status;
 	int ret;
 
@@ -199,8 +200,8 @@ static int hccs_pcc_cmd_send(struct hccs_dev *hdev, u8 cmd,
 			     struct hccs_desc *desc)
 {
 	struct hccs_mbox_client_info *cl_info = &hdev->cl_info;
-	struct acpi_pcct_shared_memory *comm_base = cl_info->pcc_comm_addr;
-	void *comm_space = (void *)(comm_base + 1);
+	void __iomem *comm_space = (u8 *)cl_info->pcc_comm_addr +
+					sizeof(struct acpi_pcct_shared_memory);
 	struct hccs_fw_inner_head *fw_inner_head;
 	struct acpi_pcct_shared_memory tmp = {0};
 	u16 comm_space_size;
@@ -212,7 +213,7 @@ static int hccs_pcc_cmd_send(struct hccs_dev *hdev, u8 cmd,
 	tmp.command = cmd;
 	/* Clear cmd complete bit */
 	tmp.status = 0;
-	memcpy_toio(comm_base, (void *)&tmp,
+	memcpy_toio(cl_info->pcc_comm_addr, (void *)&tmp,
 			sizeof(struct acpi_pcct_shared_memory));
 
 	/* Copy the message to the PCC comm space */
diff --git a/drivers/soc/hisilicon/kunpeng_hccs.h b/drivers/soc/hisilicon/kunpeng_hccs.h
index 9d71fb78443f..6012d2776028 100644
--- a/drivers/soc/hisilicon/kunpeng_hccs.h
+++ b/drivers/soc/hisilicon/kunpeng_hccs.h
@@ -50,7 +50,7 @@ struct hccs_mbox_client_info {
 	struct mbox_chan *mbox_chan;
 	struct pcc_mbox_chan *pcc_chan;
 	u64 deadline_us;
-	void *pcc_comm_addr;
+	void __iomem *pcc_comm_addr;
 };
 
 struct hccs_dev {
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2] soc: kunpeng_hccs: fix some sparse warnings about incorrect type
  2023-08-15 12:52 [PATCH] soc: kunpeng_hccs: fix some sparse warnings about incorrect type Huisong Li
@ 2023-08-16  7:37 ` Huisong Li
  2023-08-22  2:31   ` patchwork-bot+linux-soc
  2023-08-16 13:17 ` [PATCH] " Arnd Bergmann
  1 sibling, 1 reply; 8+ messages in thread
From: Huisong Li @ 2023-08-16  7:37 UTC (permalink / raw)
  To: xuwei5, arnd, arnd
  Cc: linux-kernel, soc, linux-arm-kernel, liuyonglong, lihuisong

This patch fixes some sparse warnings about incorrect type.
The address about PCC communication space should use '__iomem' tag.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202308151142.dH5Muhva-lkp@intel.com/
Fixes: 886bdf9c883b ("soc: hisilicon: Support HCCS driver on Kunpeng SoC")
Signed-off-by: Huisong Li <lihuisong@huawei.com>
---
v2: remove (u8 *) before cl_info->pcc_comm_addr to resolve "cast removes
    address space '__iomem' of expression" warning.

---
 drivers/soc/hisilicon/kunpeng_hccs.c | 13 +++++++------
 drivers/soc/hisilicon/kunpeng_hccs.h |  2 +-
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/soc/hisilicon/kunpeng_hccs.c b/drivers/soc/hisilicon/kunpeng_hccs.c
index 0d6f6bacd3f6..f3810d9d1caa 100644
--- a/drivers/soc/hisilicon/kunpeng_hccs.c
+++ b/drivers/soc/hisilicon/kunpeng_hccs.c
@@ -156,8 +156,8 @@ static int hccs_register_pcc_channel(struct hccs_dev *hdev)
 	}
 
 	if (pcc_chan->shmem_base_addr) {
-		cl_info->pcc_comm_addr = (void __force *)ioremap(
-			pcc_chan->shmem_base_addr, pcc_chan->shmem_size);
+		cl_info->pcc_comm_addr = ioremap(pcc_chan->shmem_base_addr,
+						 pcc_chan->shmem_size);
 		if (!cl_info->pcc_comm_addr) {
 			dev_err(dev, "Failed to ioremap PCC communication region for channel-%d.\n",
 				hdev->chan_id);
@@ -177,7 +177,8 @@ static int hccs_register_pcc_channel(struct hccs_dev *hdev)
 static int hccs_check_chan_cmd_complete(struct hccs_dev *hdev)
 {
 	struct hccs_mbox_client_info *cl_info = &hdev->cl_info;
-	struct acpi_pcct_shared_memory *comm_base = cl_info->pcc_comm_addr;
+	struct acpi_pcct_shared_memory __iomem *comm_base =
+							cl_info->pcc_comm_addr;
 	u16 status;
 	int ret;
 
@@ -199,8 +200,8 @@ static int hccs_pcc_cmd_send(struct hccs_dev *hdev, u8 cmd,
 			     struct hccs_desc *desc)
 {
 	struct hccs_mbox_client_info *cl_info = &hdev->cl_info;
-	struct acpi_pcct_shared_memory *comm_base = cl_info->pcc_comm_addr;
-	void *comm_space = (void *)(comm_base + 1);
+	void __iomem *comm_space = cl_info->pcc_comm_addr +
+					sizeof(struct acpi_pcct_shared_memory);
 	struct hccs_fw_inner_head *fw_inner_head;
 	struct acpi_pcct_shared_memory tmp = {0};
 	u16 comm_space_size;
@@ -212,7 +213,7 @@ static int hccs_pcc_cmd_send(struct hccs_dev *hdev, u8 cmd,
 	tmp.command = cmd;
 	/* Clear cmd complete bit */
 	tmp.status = 0;
-	memcpy_toio(comm_base, (void *)&tmp,
+	memcpy_toio(cl_info->pcc_comm_addr, (void *)&tmp,
 			sizeof(struct acpi_pcct_shared_memory));
 
 	/* Copy the message to the PCC comm space */
diff --git a/drivers/soc/hisilicon/kunpeng_hccs.h b/drivers/soc/hisilicon/kunpeng_hccs.h
index 9d71fb78443f..6012d2776028 100644
--- a/drivers/soc/hisilicon/kunpeng_hccs.h
+++ b/drivers/soc/hisilicon/kunpeng_hccs.h
@@ -50,7 +50,7 @@ struct hccs_mbox_client_info {
 	struct mbox_chan *mbox_chan;
 	struct pcc_mbox_chan *pcc_chan;
 	u64 deadline_us;
-	void *pcc_comm_addr;
+	void __iomem *pcc_comm_addr;
 };
 
 struct hccs_dev {
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] soc: kunpeng_hccs: fix some sparse warnings about incorrect type
  2023-08-15 12:52 [PATCH] soc: kunpeng_hccs: fix some sparse warnings about incorrect type Huisong Li
  2023-08-16  7:37 ` [PATCH v2] " Huisong Li
@ 2023-08-16 13:17 ` Arnd Bergmann
  2023-08-17  1:37   ` lihuisong (C)
  1 sibling, 1 reply; 8+ messages in thread
From: Arnd Bergmann @ 2023-08-16 13:17 UTC (permalink / raw)
  To: Huisong Li, xuwei5, Arnd Bergmann
  Cc: linux-kernel, soc, linux-arm-kernel, liuyonglong

On Tue, Aug 15, 2023, at 14:52, Huisong Li wrote:
> @@ -199,8 +200,8 @@ static int hccs_pcc_cmd_send(struct hccs_dev *hdev, u8 cmd,
>  			     struct hccs_desc *desc)
>  {
>  	struct hccs_mbox_client_info *cl_info = &hdev->cl_info;
> -	struct acpi_pcct_shared_memory *comm_base = cl_info->pcc_comm_addr;
> -	void *comm_space = (void *)(comm_base + 1);
> +	void __iomem *comm_space = (u8 *)cl_info->pcc_comm_addr +
> +					sizeof(struct acpi_pcct_shared_memory);
>  	struct hccs_fw_inner_head *fw_inner_head;
>  	struct acpi_pcct_shared_memory tmp = {0};
>  	u16 comm_space_size;

The cast still looks wrong, while both comm_space and ->pcc_comm_addr
are __iomem pointers, casting to a non-__iomem u8 pointer should
still produce that warning. I'd suggest casting to (u8 __iomem *)
or (void __iomem *), I assume you still need a cast here to get
the correct address.

      Arnd

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] soc: kunpeng_hccs: fix some sparse warnings about incorrect type
  2023-08-16 13:17 ` [PATCH] " Arnd Bergmann
@ 2023-08-17  1:37   ` lihuisong (C)
  2023-08-17 11:54     ` Arnd Bergmann
  0 siblings, 1 reply; 8+ messages in thread
From: lihuisong (C) @ 2023-08-17  1:37 UTC (permalink / raw)
  To: Arnd Bergmann, xuwei5, Arnd Bergmann
  Cc: linux-kernel, soc, linux-arm-kernel, liuyonglong, lihuisong


在 2023/8/16 21:17, Arnd Bergmann 写道:
> On Tue, Aug 15, 2023, at 14:52, Huisong Li wrote:
>> @@ -199,8 +200,8 @@ static int hccs_pcc_cmd_send(struct hccs_dev *hdev, u8 cmd,
>>   			     struct hccs_desc *desc)
>>   {
>>   	struct hccs_mbox_client_info *cl_info = &hdev->cl_info;
>> -	struct acpi_pcct_shared_memory *comm_base = cl_info->pcc_comm_addr;
>> -	void *comm_space = (void *)(comm_base + 1);
>> +	void __iomem *comm_space = (u8 *)cl_info->pcc_comm_addr +
>> +					sizeof(struct acpi_pcct_shared_memory);
>>   	struct hccs_fw_inner_head *fw_inner_head;
>>   	struct acpi_pcct_shared_memory tmp = {0};
>>   	u16 comm_space_size;
> The cast still looks wrong, while both comm_space and ->pcc_comm_addr
> are __iomem pointers, casting to a non-__iomem u8 pointer should
> still produce that warning. I'd suggest casting to (u8 __iomem *)
> or (void __iomem *), I assume you still need a cast here to get
> the correct address.
Thanks Arnd.

You are right. So I modify it by dropping (u8 *) here in patch v2.
Please take a look at this again.
If it is ok for you, can you apply this patch to soc/soc.git?

/Huisong

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] soc: kunpeng_hccs: fix some sparse warnings about incorrect type
  2023-08-17  1:37   ` lihuisong (C)
@ 2023-08-17 11:54     ` Arnd Bergmann
  2023-08-18  1:38       ` lihuisong (C)
  0 siblings, 1 reply; 8+ messages in thread
From: Arnd Bergmann @ 2023-08-17 11:54 UTC (permalink / raw)
  To: Huisong Li, xuwei5, Arnd Bergmann
  Cc: linux-kernel, soc, linux-arm-kernel, liuyonglong

On Thu, Aug 17, 2023, at 03:37, lihuisong (C) wrote:
> 在 2023/8/16 21:17, Arnd Bergmann 写道:
>> On Tue, Aug 15, 2023, at 14:52, Huisong Li wrote:
>>> @@ -199,8 +200,8 @@ static int hccs_pcc_cmd_send(struct hccs_dev *hdev, u8 cmd,
>>>   			     struct hccs_desc *desc)
>>>   {
>>>   	struct hccs_mbox_client_info *cl_info = &hdev->cl_info;
>>> -	struct acpi_pcct_shared_memory *comm_base = cl_info->pcc_comm_addr;
>>> -	void *comm_space = (void *)(comm_base + 1);
>>> +	void __iomem *comm_space = (u8 *)cl_info->pcc_comm_addr +
>>> +					sizeof(struct acpi_pcct_shared_memory);
>>>   	struct hccs_fw_inner_head *fw_inner_head;
>>>   	struct acpi_pcct_shared_memory tmp = {0};
>>>   	u16 comm_space_size;
>> The cast still looks wrong, while both comm_space and ->pcc_comm_addr
>> are __iomem pointers, casting to a non-__iomem u8 pointer should
>> still produce that warning. I'd suggest casting to (u8 __iomem *)
>> or (void __iomem *), I assume you still need a cast here to get
>> the correct address.
> Thanks Arnd.
>
> You are right. So I modify it by dropping (u8 *) here in patch v2.
> Please take a look at this again.

Right, if pcc_comm_addr is already a u8 __iomem* or void*, that
works, I though the cast was needed since it points to a larger
object, which would throw off the calculation.

> If it is ok for you, can you apply this patch to soc/soc.git?

Yes, of course.

       Arnd

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] soc: kunpeng_hccs: fix some sparse warnings about incorrect type
  2023-08-17 11:54     ` Arnd Bergmann
@ 2023-08-18  1:38       ` lihuisong (C)
  2023-08-18  1:57         ` Arnd Bergmann
  0 siblings, 1 reply; 8+ messages in thread
From: lihuisong (C) @ 2023-08-18  1:38 UTC (permalink / raw)
  To: Arnd Bergmann, Arnd Bergmann
  Cc: linux-kernel, soc, linux-arm-kernel, liuyonglong, xuwei5, lihuisong


在 2023/8/17 19:54, Arnd Bergmann 写道:
> On Thu, Aug 17, 2023, at 03:37, lihuisong (C) wrote:
>> 在 2023/8/16 21:17, Arnd Bergmann 写道:
>>> On Tue, Aug 15, 2023, at 14:52, Huisong Li wrote:
>>>> @@ -199,8 +200,8 @@ static int hccs_pcc_cmd_send(struct hccs_dev *hdev, u8 cmd,
>>>>    			     struct hccs_desc *desc)
>>>>    {
>>>>    	struct hccs_mbox_client_info *cl_info = &hdev->cl_info;
>>>> -	struct acpi_pcct_shared_memory *comm_base = cl_info->pcc_comm_addr;
>>>> -	void *comm_space = (void *)(comm_base + 1);
>>>> +	void __iomem *comm_space = (u8 *)cl_info->pcc_comm_addr +
>>>> +					sizeof(struct acpi_pcct_shared_memory);
>>>>    	struct hccs_fw_inner_head *fw_inner_head;
>>>>    	struct acpi_pcct_shared_memory tmp = {0};
>>>>    	u16 comm_space_size;
>>> The cast still looks wrong, while both comm_space and ->pcc_comm_addr
>>> are __iomem pointers, casting to a non-__iomem u8 pointer should
>>> still produce that warning. I'd suggest casting to (u8 __iomem *)
>>> or (void __iomem *), I assume you still need a cast here to get
>>> the correct address.
>> Thanks Arnd.
>>
>> You are right. So I modify it by dropping (u8 *) here in patch v2.
>> Please take a look at this again.
> Right, if pcc_comm_addr is already a u8 __iomem* or void*, that
> works, I though the cast was needed since it points to a larger
> object, which would throw off the calculation.
This pcc_comm_addr is already defined "void __iomem *" type in patch v2.
So that works well, right?

/Huisong
>
>> If it is ok for you, can you apply this patch to soc/soc.git?
> Yes, of course.
>
>         Arnd
> .

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] soc: kunpeng_hccs: fix some sparse warnings about incorrect type
  2023-08-18  1:38       ` lihuisong (C)
@ 2023-08-18  1:57         ` Arnd Bergmann
  0 siblings, 0 replies; 8+ messages in thread
From: Arnd Bergmann @ 2023-08-18  1:57 UTC (permalink / raw)
  To: Huisong Li, Arnd Bergmann
  Cc: linux-kernel, soc, linux-arm-kernel, liuyonglong, xuwei5

On Fri, Aug 18, 2023, at 03:38, lihuisong (C) wrote:
> 在 2023/8/17 19:54, Arnd Bergmann 写道:
>> On Thu, Aug 17, 2023, at 03:37, lihuisong (C) wrote:
>>> 在 2023/8/16 21:17, Arnd Bergmann 写道:
>>>> On Tue, Aug 15, 2023, at 14:52, Huisong Li wrote:
>>>>> @@ -199,8 +200,8 @@ static int hccs_pcc_cmd_send(struct hccs_dev *hdev, u8 cmd,
>>>>>    			     struct hccs_desc *desc)
>>>>>    {
>>>>>    	struct hccs_mbox_client_info *cl_info = &hdev->cl_info;
>>>>> -	struct acpi_pcct_shared_memory *comm_base = cl_info->pcc_comm_addr;
>>>>> -	void *comm_space = (void *)(comm_base + 1);
>>>>> +	void __iomem *comm_space = (u8 *)cl_info->pcc_comm_addr +
>>>>> +					sizeof(struct acpi_pcct_shared_memory);
>>>>>    	struct hccs_fw_inner_head *fw_inner_head;
>>>>>    	struct acpi_pcct_shared_memory tmp = {0};
>>>>>    	u16 comm_space_size;
>>>> The cast still looks wrong, while both comm_space and ->pcc_comm_addr
>>>> are __iomem pointers, casting to a non-__iomem u8 pointer should
>>>> still produce that warning. I'd suggest casting to (u8 __iomem *)
>>>> or (void __iomem *), I assume you still need a cast here to get
>>>> the correct address.
>>> Thanks Arnd.
>>>
>>> You are right. So I modify it by dropping (u8 *) here in patch v2.
>>> Please take a look at this again.
>> Right, if pcc_comm_addr is already a u8 __iomem* or void*, that
>> works, I though the cast was needed since it points to a larger
>> object, which would throw off the calculation.
> This pcc_comm_addr is already defined "void __iomem *" type in patch v2.
> So that works well, right?

Yes, that works.

     Arnd

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2] soc: kunpeng_hccs: fix some sparse warnings about incorrect type
  2023-08-16  7:37 ` [PATCH v2] " Huisong Li
@ 2023-08-22  2:31   ` patchwork-bot+linux-soc
  0 siblings, 0 replies; 8+ messages in thread
From: patchwork-bot+linux-soc @ 2023-08-22  2:31 UTC (permalink / raw)
  To: lihuisong; +Cc: soc

Hello:

This patch was applied to soc/soc.git (for-next)
by Arnd Bergmann <arnd@arndb.de>:

On Wed, 16 Aug 2023 15:37:06 +0800 you wrote:
> This patch fixes some sparse warnings about incorrect type.
> The address about PCC communication space should use '__iomem' tag.
> 
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202308151142.dH5Muhva-lkp@intel.com/
> Fixes: 886bdf9c883b ("soc: hisilicon: Support HCCS driver on Kunpeng SoC")
> Signed-off-by: Huisong Li <lihuisong@huawei.com>
> 
> [...]

Here is the summary with links:
  - [v2] soc: kunpeng_hccs: fix some sparse warnings about incorrect type
    https://git.kernel.org/soc/soc/c/7d6612834d17

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-08-22  2:31 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-15 12:52 [PATCH] soc: kunpeng_hccs: fix some sparse warnings about incorrect type Huisong Li
2023-08-16  7:37 ` [PATCH v2] " Huisong Li
2023-08-22  2:31   ` patchwork-bot+linux-soc
2023-08-16 13:17 ` [PATCH] " Arnd Bergmann
2023-08-17  1:37   ` lihuisong (C)
2023-08-17 11:54     ` Arnd Bergmann
2023-08-18  1:38       ` lihuisong (C)
2023-08-18  1:57         ` Arnd Bergmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).