Skip to contentSkip to conversation

hw/char/cmsdk-apb-uart.c: Correctly clear INTSTATUS bits on writes

PATCH In review Peter Maydell 2 participants 2 messages Apr 10, 2018 – Apr 11, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/char/cmsdk-apb-uart.c: Correctly clear INTSTATUS bits on writes

The CMSDK APB UART INTSTATUS register bits are all write-one-to-clear. We were getting this correct for the TXO and RXO bits (which need special casing because their state lives in the STATE register), but had forgotten to handle the normal bits for RX and TX which we do store in our s->intstatus field.

Perform the W1C operation on the bits in s->intstatus too.

---
Not a disaster if this doesn't get into 2.12, I guess. I think it's missed the rc3 boat, so if we need an rc4 for some other reason we can put it in.

 hw/char/cmsdk-apb-uart.c | 1 +
 1 file changed, 1 insertion(+)
hw/char/cmsdk-apb-uart.c +1 -0
index 1ad1e14295..9c0929d8a2 100644
@@ -274,6 +274,7 @@ static void uart_write(void *opaque, hwaddr offset, uint64_t value,
          * is then reflected into the intstatus value by the update function).
          */
         s->state &= ~(value & (R_INTSTATUS_TXO_MASK | R_INTSTATUS_RXO_MASK));
+        s->intstatus &= ~value;
         cmsdk_apb_uart_update(s);
         break;
     case A_BAUDDIV:
Signature · 1 line
2.16.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 24 lines · Peter Maydell

The CMSDK APB UART INTSTATUS register bits are all write-one-to-clear. We were getting this correct for the TXO and RXO bits (which need special casing because their state lives in the STATE register), but had forgotten to handle the normal bits for RX and TX which we do store in our s->intstatus field.

Perform the W1C operation on the bits in s->intstatus too.

---
Not a disaster if this doesn't get into 2.12, I guess. I think it's missed the rc3 boat, so if we need an rc4 for some other reason we can put it in.

 hw/char/cmsdk-apb-uart.c | 1 +
 1 file changed, 1 insertion(+)
hw/char/cmsdk-apb-uart.c +0 -0
index 1ad1e14295..9c0929d8a2 100644

hw/char/cmsdk-apb-uart.c static void uart_write(void *opaque, hwaddr offset, uint64_t value, · line 274

Quoted 1 line
hw/char/cmsdk-apb-uart.c +0 -0
@@ -274,6 +274,7 @@ static void uart_write(void *opaque, hwaddr offset, uint64_t value,
          * is then reflected into the intstatus value by the update function).

The comment was correct :)

Quoted 7 lines
hw/char/cmsdk-apb-uart.c +1 -0
          */
         s->state &= ~(value & (R_INTSTATUS_TXO_MASK | R_INTSTATUS_RXO_MASK));
+        s->intstatus &= ~value;
         cmsdk_apb_uart_update(s);
         break;
     case A_BAUDDIV: