Skip to contentSkip to conversation

hw/misc/bcm2835_cprman: correct register index in test for mux update

PATCH In review Jonathan Gilbert 3 participants 5 messages Sep 25 – Sep 29

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/misc/bcm2835_cprman: correct register index in test for mux update

After each register write handled by cprman_write, function update_mux checks each of the clocks to see whether the supplied register index applies to it, calling clock_mux_update if so. Each clock has two registers, so it needs to check the base cm_offset for CM_CTL and then the next slot for CM_DIV. But, it was checking for cm_offset plus 4, as though it were a byte offset when it's a logical index.

---
 hw/misc/bcm2835_cprman.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/misc/bcm2835_cprman.c +1 -1
index 8220f7a6b4..f9a77ff9bb 100644
@@ -508,7 +508,7 @@ static inline void update_mux_from_cm(BCM2835CprmanState *s, size_t idx)
 
     for (i = 0; i < CPRMAN_NUM_CLOCK_MUX; i++) {
         if ((CLOCK_MUX_INIT_INFO[i].cm_offset == idx) ||
-            (CLOCK_MUX_INIT_INFO[i].cm_offset + 4 == idx)) {
+            (CLOCK_MUX_INIT_INFO[i].cm_offset + 1 == idx)) {
             /* matches CM_CTL or CM_DIV mux register */
             clock_mux_update(&s->clock_muxes[i]);
             return;
Signature · 1 line
2.53.0
#1 lore raw

Cc'ing Luc

Quoted 25 lines · Jonathan Gilbert

After each register write handled by cprman_write, function update_mux checks each of the clocks to see whether the supplied register index applies to it, calling clock_mux_update if so. Each clock has two registers, so it needs to check the base cm_offset for CM_CTL and then the next slot for CM_DIV. But, it was checking for cm_offset plus 4, as though it were a byte offset when it's a logical index.

---
  hw/misc/bcm2835_cprman.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
hw/misc/bcm2835_cprman.c +1 -1
index 8220f7a6b4..f9a77ff9bb 100644
@@ -508,7 +508,7 @@ static inline void update_mux_from_cm(BCM2835CprmanState *s, size_t idx)
 
      for (i = 0; i < CPRMAN_NUM_CLOCK_MUX; i++) {
          if ((CLOCK_MUX_INIT_INFO[i].cm_offset == idx) ||
-            (CLOCK_MUX_INIT_INFO[i].cm_offset + 4 == idx)) {
+            (CLOCK_MUX_INIT_INFO[i].cm_offset + 1 == idx)) {
              /* matches CM_CTL or CM_DIV mux register */
              clock_mux_update(&s->clock_muxes[i]);
              return;
#2 lore raw
Quoted 10 lines · Philippe Mathieu-Daudé

Cc'ing Luc

Quoted 7 lines · Jonathan Gilbert

After each register write handled by cprman_write, function update_mux checks each of the clocks to see whether the supplied register index applies to it, calling clock_mux_update if so. Each clock has two registers, so it needs to check the base cm_offset for CM_CTL and then the next slot for CM_DIV. But, it was checking for cm_offset plus 4, as though it were a byte offset when it's a logical index.

Fixes 7281362484a ("hw/misc/bcm2835_cprman: clock mux skeleton implementation")
Quoted 20 lines
Quoted 18 lines

---
  hw/misc/bcm2835_cprman.c | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)
hw/misc/bcm2835_cprman.c +0 -0
index 8220f7a6b4..f9a77ff9bb 100644
@@ -508,7 +508,7 @@ static inline void 
 update_mux_from_cm(BCM2835CprmanState *s, size_t idx)
       for (i = 0; i < CPRMAN_NUM_CLOCK_MUX; i++) {

          if ((CLOCK_MUX_INIT_INFO[i].cm_offset == idx) || -            (CLOCK_MUX_INIT_INFO[i].cm_offset + 4 == idx)) { +            (CLOCK_MUX_INIT_INFO[i].cm_offset + 1 == idx)) { /* matches CM_CTL or CM_DIV mux register */ clock_mux_update(&s->clock_muxes[i]); return;

#3 lore raw
Quoted 12 lines · Philippe Mathieu-Daudé
Quoted 10 lines · Philippe Mathieu-Daudé

Cc'ing Luc

Quoted 7 lines · Jonathan Gilbert

After each register write handled by cprman_write, function update_mux checks each of the clocks to see whether the supplied register index applies to it, calling clock_mux_update if so. Each clock has two registers, so it needs to check the base cm_offset for CM_CTL and then the next slot for CM_DIV. But, it was checking for cm_offset plus 4, as though it were a byte offset when it's a logical index.

Quoted 7 lines
Fixes 7281362484a ("hw/misc/bcm2835_cprman: clock mux skeleton implementation")
Quoted 4 lines
Quoted 4 lines

---
  hw/misc/bcm2835_cprman.c | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)

Trivial fix so patch queued, thanks.

Reviewed-by
#4 lore raw
Quoted 17 lines · Philippe Mathieu-Daudé
Quoted 16 lines · Philippe Mathieu-Daudé
Quoted 10 lines · Philippe Mathieu-Daudé

Cc'ing Luc

Quoted 7 lines · Jonathan Gilbert

After each register write handled by cprman_write, function update_mux checks each of the clocks to see whether the supplied register index applies to it, calling clock_mux_update if so. Each clock has two registers, so it needs to check the base cm_offset for CM_CTL and then the next slot for CM_DIV. But, it was checking for cm_offset plus 4, as though it were a byte offset when it's a logical index.

Fixes 7281362484a ("hw/misc/bcm2835_cprman: clock mux skeleton

implementation")

Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

---
  hw/misc/bcm2835_cprman.c | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)

Trivial fix so patch queued, thanks.

Thanks for the fix.
A bit late: