Skip to contentSkip to conversation

firmware: arm_scmi: Remove set but not used variable 'val'

PATCH In review Zheng Yongjun 3 participants 4 messages Nov 10, 2019 – Nov 11, 2019 System control & power/management interface (SCPI/SCMI) Message Protocol drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 firmware: arm_scmi: Remove set but not used variable 'val'

Fixes gcc '-Wunused-but-set-variable' warning:

drivers/firmware/arm_scmi/perf.c: In function scmi_perf_fc_ring_db:
drivers/firmware/arm_scmi/perf.c:323:7: warning: variable val set but not used [-Wunused-but-set-variable]

val is never used, so remove it.

---
 drivers/firmware/arm_scmi/perf.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/firmware/arm_scmi/perf.c +1 -3
index 4a8012e3cb8c..efa98d2ee045 100644
@@ -319,10 +319,8 @@ static void scmi_perf_fc_ring_db(struct scmi_fc_db_info *db)
 		SCMI_PERF_FC_RING_DB(64);
 #else
 	{
-		u64 val = 0;
-
 		if (db->mask)
-			val = ioread64_hi_lo(db->addr) & db->mask;
+			ioread64_hi_lo(db->addr) & db->mask;
 		iowrite64_hi_lo(db->set, db->addr);
 	}
 #endif
Signature · 1 line
2.23.0
#1 lore raw
Quoted 18 lines · Zheng Yongjun

Fixes gcc '-Wunused-but-set-variable' warning:

drivers/firmware/arm_scmi/perf.c: In function scmi_perf_fc_ring_db:
drivers/firmware/arm_scmi/perf.c:323:7: warning: variable val set but not used [-Wunused-but-set-variable]

val is never used, so remove it.

---
  drivers/firmware/arm_scmi/perf.c | 4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)
drivers/firmware/arm_scmi/perf.c +0 -0
index 4a8012e3cb8c..efa98d2ee045 100644

drivers/firmware/arm_scmi/perf.c static void scmi_perf_fc_ring_db(struct scmi_fc_db_info *db) · line 324

Quoted 9 lines
drivers/firmware/arm_scmi/perf.c +1 -3
@@ -319,10 +319,8 @@ static void scmi_perf_fc_ring_db(struct scmi_fc_db_info *db)
  		SCMI_PERF_FC_RING_DB(64);
  #else
  	{
-		u64 val = 0;
-
  		if (db->mask)
-			val = ioread64_hi_lo(db->addr) & db->mask;
+			ioread64_hi_lo(db->addr) & db->mask;
  		iowrite64_hi_lo(db->set, db->addr);

FWIW, compared to the SCMI_PERF_FC_RING_DB() macro, this looks like the wrong "fix".

Robin.

Quoted 3 lines
drivers/firmware/arm_scmi/perf.c +0 -0
  	}
  #endif
#2 lore raw
Quoted 23 lines · Robin Murphy
Quoted 22 lines · Zheng Yongjun

Fixes gcc '-Wunused-but-set-variable' warning:

drivers/firmware/arm_scmi/perf.c: In function scmi_perf_fc_ring_db:
drivers/firmware/arm_scmi/perf.c:323:7: warning: variable val set but not used [-Wunused-but-set-variable]

val is never used, so remove it.

---
  drivers/firmware/arm_scmi/perf.c | 4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)
drivers/firmware/arm_scmi/perf.c +0 -1
index 4a8012e3cb8c..efa98d2ee045 100644
@@ -319,10 +319,8 @@ static void scmi_perf_fc_ring_db(struct scmi_fc_db_info *db)
  		SCMI_PERF_FC_RING_DB(64);
  #else
  	{
-		u64 val = 0;
Quoted 9 lines

drivers/firmware/arm_scmi/perf.c static void scmi_perf_fc_ring_db(struct scmi_fc_db_info *db) · line 324

Quoted 5 lines
drivers/firmware/arm_scmi/perf.c +1 -2
-
  		if (db->mask)
-			val = ioread64_hi_lo(db->addr) & db->mask;
+			ioread64_hi_lo(db->addr) & db->mask;
  		iowrite64_hi_lo(db->set, db->addr);

FWIW, compared to the SCMI_PERF_FC_RING_DB() macro, this looks like the wrong "fix".

Yes, no idea how I didn't spot this earlier. That could be because this was just added to fix 32-bit build and wasn't tested.

The below patch should fix the warning and also fixes the real bug.

Regards,
Sudeep

drivers/firmware/arm_scmi/perf.c +1 -1
index 4a8012e3cb8c..601af4edad5e 100644
@@ -323,7 +323,7 @@ static void scmi_perf_fc_ring_db(struct scmi_fc_db_info *db)
 
                if (db->mask)
                        val = ioread64_hi_lo(db->addr) & db->mask;
-               iowrite64_hi_lo(db->set, db->addr);
+               iowrite64_hi_lo(db->set | val, db->addr);
        }
 #endif
 }
#3 lore raw

PATCH 1/1 firmware: arm_scmi: Fix doorbell ring logic for !CONFIG_64BIT

In reply to Zheng Yongjun

The logic to ring the scmi performance fastchannel ignores the value read from the doorbell register in case of !CONFIG_64BIT. This bug also shows up as warning with '-Wunused-but-set-variable' gcc flag:

drivers/firmware/arm_scmi/perf.c: In function scmi_perf_fc_ring_db:
drivers/firmware/arm_scmi/perf.c:323:7: warning: variable val set but
not used [-Wunused-but-set-variable]

Fix the same by aligning the logic with CONFIG_64BIT as used in the macro SCMI_PERF_FC_RING_DB().

Fixes 823839571d76 ("firmware: arm_scmi: Make use SCMI v2.0 fastchannel

for performance protocol")

---
 drivers/firmware/arm_scmi/perf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Hi Zheng,

Thanks for the bug report, but the fix is incorrect as discussed. This is proper fix, let me know if this fixes the gcc warning you found.

Regards,
Sudeep

drivers/firmware/arm_scmi/perf.c +1 -1
index 4a8012e3cb8c..601af4edad5e 100644
@@ -323,7 +323,7 @@ static void scmi_perf_fc_ring_db(struct scmi_fc_db_info *db)
 
 		if (db->mask)
 			val = ioread64_hi_lo(db->addr) & db->mask;
-		iowrite64_hi_lo(db->set, db->addr);
+		iowrite64_hi_lo(db->set | val, db->addr);
 	}
 #endif
 }

--
2.17.1