diff mbox series

[04/20] scsi: pm8001: fix __iomem pointer use in pm8001_phy_control()

Message ID 20220210114218.632725-5-damien.lemoal@opensource.wdc.com (mailing list archive)
State Superseded
Headers show
Series libsas and pm8001 fixes | expand

Commit Message

Damien Le Moal Feb. 10, 2022, 11:42 a.m. UTC
Avoid the sparse warning "warning: cast removes address space '__iomem'
of expression" by using a local unsigned long variable to store an
iomem address.

Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
---
 drivers/scsi/pm8001/pm8001_sas.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Christoph Hellwig Feb. 11, 2022, 6:11 a.m. UTC | #1
On Thu, Feb 10, 2022 at 08:42:02PM +0900, Damien Le Moal wrote:
>  			struct sas_phy *phy = sas_phy->phy;
> -			uint32_t *qp = (uint32_t *)(((char *)
> -				pm8001_ha->io_mem[2].memvirtaddr)
> -				+ 0x1034 + (0x4000 * (phy_id & 3)));
> +			unsigned long vaddr = (unsigned long)
> +				pm8001_ha->io_mem[2].memvirtaddr;
> +			uint32_t *qp = (uint32_t *)
> +				(vaddr + 0x1034 + (0x4000 * (phy_id & 3)));

This just removes the warning, but does not actually fix the issue.
Both long_vaddr and qp need to be __iomem pointers...

>  
>  			phy->invalid_dword_count = qp[0];
>  			phy->running_disparity_error_count = qp[1];

... and reads from qp need to use readl.
Damien Le Moal Feb. 11, 2022, 7:03 a.m. UTC | #2
On 2/11/22 15:11, Christoph Hellwig wrote:
> On Thu, Feb 10, 2022 at 08:42:02PM +0900, Damien Le Moal wrote:
>>  			struct sas_phy *phy = sas_phy->phy;
>> -			uint32_t *qp = (uint32_t *)(((char *)
>> -				pm8001_ha->io_mem[2].memvirtaddr)
>> -				+ 0x1034 + (0x4000 * (phy_id & 3)));
>> +			unsigned long vaddr = (unsigned long)
>> +				pm8001_ha->io_mem[2].memvirtaddr;
>> +			uint32_t *qp = (uint32_t *)
>> +				(vaddr + 0x1034 + (0x4000 * (phy_id & 3)));
> 
> This just removes the warning, but does not actually fix the issue.
> Both long_vaddr and qp need to be __iomem pointers...
> 
>>  
>>  			phy->invalid_dword_count = qp[0];
>>  			phy->running_disparity_error_count = qp[1];
> 
> ... and reads from qp need to use readl.

OK. About to send a v2 with more fixes. Will rework this one and patch 8
too.
diff mbox series

Patch

diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c
index 32edda3e55c6..6805c7f43e41 100644
--- a/drivers/scsi/pm8001/pm8001_sas.c
+++ b/drivers/scsi/pm8001/pm8001_sas.c
@@ -234,9 +234,10 @@  int pm8001_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func,
 		}
 		{
 			struct sas_phy *phy = sas_phy->phy;
-			uint32_t *qp = (uint32_t *)(((char *)
-				pm8001_ha->io_mem[2].memvirtaddr)
-				+ 0x1034 + (0x4000 * (phy_id & 3)));
+			unsigned long vaddr = (unsigned long)
+				pm8001_ha->io_mem[2].memvirtaddr;
+			uint32_t *qp = (uint32_t *)
+				(vaddr + 0x1034 + (0x4000 * (phy_id & 3)));
 
 			phy->invalid_dword_count = qp[0];
 			phy->running_disparity_error_count = qp[1];