diff --git a/drivers/serial/arm/uart.c b/drivers/serial/arm/uart.c index e5b13dbd3..e3053ff57 100644 --- a/drivers/serial/arm/uart.c +++ b/drivers/serial/arm/uart.c @@ -41,29 +41,18 @@ static void set_baud(long bps) static void tx_provide(void) { - bool reprocess = true; bool transferred = false; - while (reprocess) { - char c; - while (!(uart_regs->fr & PL011_FR_TXFF) && !serial_dequeue(&tx_queue_handle, &c)) { - uart_regs->dr = (uint32_t)c; - transferred = true; - } - - serial_request_producer_signal(&tx_queue_handle); - /* If transmit fifo is full and there is data remaining to be sent, enable interrupt when fifo is no longer full */ - if (uart_regs->fr & PL011_FR_TXFF && !serial_queue_empty(&tx_queue_handle, tx_queue_handle.queue->head)) { - uart_regs->imsc |= PL011_IMSC_TX_INT; - } else { - uart_regs->imsc &= ~PL011_IMSC_TX_INT; - } - reprocess = false; + char c; + while (!(uart_regs->fr & PL011_FR_TXFF) && !serial_dequeue(&tx_queue_handle, &c)) { + uart_regs->dr = (uint32_t)c; + transferred = true; + } - if (!(uart_regs->fr & PL011_FR_TXFF) && !serial_queue_empty(&tx_queue_handle, tx_queue_handle.queue->head)) { - serial_cancel_producer_signal(&tx_queue_handle); - uart_regs->imsc &= ~PL011_IMSC_TX_INT; - reprocess = true; - } + /* If transmit fifo is full and there is data remaining to be sent, enable interrupt when fifo is no longer full */ + if (uart_regs->fr & PL011_FR_TXFF && !serial_queue_empty(&tx_queue_handle, tx_queue_handle.queue->head)) { + uart_regs->imsc |= PL011_IMSC_TX_INT; + } else { + uart_regs->imsc &= ~PL011_IMSC_TX_INT; } if (transferred && serial_require_consumer_signal(&tx_queue_handle)) { @@ -84,7 +73,7 @@ static void rx_return(void) } if (!(uart_regs->fr & PL011_FR_RXFE) && serial_queue_full(&rx_queue_handle, rx_queue_handle.queue->tail)) { - /* Disable rx interrupts until virtualisers queue is no longer empty. */ + /* Disable rx interrupts until virtualisers queue is no longer full. */ uart_regs->imsc &= ~(PL011_IMSC_RX_TIMEOUT | PL011_IMSC_RX_INT); serial_request_consumer_signal(&rx_queue_handle); } @@ -97,8 +86,7 @@ static void rx_return(void) } } - if (enqueued && serial_require_producer_signal(&rx_queue_handle)) { - serial_cancel_producer_signal(&rx_queue_handle); + if (enqueued) { microkit_notify(config.rx.id); } } diff --git a/drivers/serial/imx/uart.c b/drivers/serial/imx/uart.c index 79dd170fa..7b6d45937 100644 --- a/drivers/serial/imx/uart.c +++ b/drivers/serial/imx/uart.c @@ -42,29 +42,18 @@ static void set_baud(long bps) static void tx_provide(void) { - bool reprocess = true; bool transferred = false; - while (reprocess) { - char c; - while (!(uart_regs->ts & UART_TST_TX_FIFO_FULL) && !serial_dequeue(&tx_queue_handle, &c)) { - uart_regs->txd = (uint32_t)c; - transferred = true; - } - - serial_request_producer_signal(&tx_queue_handle); - /* If transmit fifo is full and there is data remaining to be sent, enable interrupt when fifo is no longer full */ - if (uart_regs->ts & UART_TST_TX_FIFO_FULL && !serial_queue_empty(&tx_queue_handle, tx_queue_handle.queue->head)) { - uart_regs->cr1 |= UART_CR1_TX_READY_INT; - } else { - uart_regs->cr1 &= ~UART_CR1_TX_READY_INT; - } - reprocess = false; + char c; + while (!(uart_regs->ts & UART_TST_TX_FIFO_FULL) && !serial_dequeue(&tx_queue_handle, &c)) { + uart_regs->txd = (uint32_t)c; + transferred = true; + } - if (!(uart_regs->ts & UART_TST_TX_FIFO_FULL) && !serial_queue_empty(&tx_queue_handle, tx_queue_handle.queue->head)) { - serial_cancel_producer_signal(&tx_queue_handle); - uart_regs->cr1 &= ~UART_CR1_TX_READY_INT; - reprocess = true; - } + /* If transmit fifo is full and there is data remaining to be sent, enable interrupt when fifo is no longer full */ + if (uart_regs->ts & UART_TST_TX_FIFO_FULL && !serial_queue_empty(&tx_queue_handle, tx_queue_handle.queue->head)) { + uart_regs->cr1 |= UART_CR1_TX_READY_INT; + } else { + uart_regs->cr1 &= ~UART_CR1_TX_READY_INT; } if (transferred && serial_require_consumer_signal(&tx_queue_handle)) { @@ -85,7 +74,7 @@ static void rx_return(void) } if (!(uart_regs->ts & UART_TST_RX_FIFO_EMPTY) && serial_queue_full(&rx_queue_handle, rx_queue_handle.queue->tail)) { - /* Disable rx interrupts until virtualisers queue is no longer empty. */ + /* Disable rx interrupts until virtualisers queue is no longer full. */ uart_regs->cr1 &= ~UART_CR1_RX_READY_INT; serial_request_consumer_signal(&rx_queue_handle); } @@ -98,8 +87,7 @@ static void rx_return(void) } } - if (enqueued && serial_require_producer_signal(&rx_queue_handle)) { - serial_cancel_producer_signal(&rx_queue_handle); + if (enqueued) { microkit_notify(config.rx.id); } } diff --git a/drivers/serial/meson/uart.c b/drivers/serial/meson/uart.c index 77fb1078e..5076c821d 100644 --- a/drivers/serial/meson/uart.c +++ b/drivers/serial/meson/uart.c @@ -73,29 +73,18 @@ static void set_baud(unsigned long baud) static void tx_provide(void) { - bool reprocess = true; bool transferred = false; - while (reprocess) { - char c; - while (!(uart_regs->sr & AML_UART_TX_FULL) && !serial_dequeue(&tx_queue_handle, &c)) { - uart_regs->wfifo = (uint32_t)c; - transferred = true; - } - - serial_request_producer_signal(&tx_queue_handle); - /* If transmit fifo is full and there is data remaining to be sent, enable interrupt when fifo is no longer full */ - if (uart_regs->sr & AML_UART_TX_FULL && !serial_queue_empty(&tx_queue_handle, tx_queue_handle.queue->head)) { - uart_regs->cr |= AML_UART_TX_INT_EN; - } else { - uart_regs->cr &= ~AML_UART_TX_INT_EN; - } - reprocess = false; + char c; + while (!(uart_regs->sr & AML_UART_TX_FULL) && !serial_dequeue(&tx_queue_handle, &c)) { + uart_regs->wfifo = (uint32_t)c; + transferred = true; + } - if (!(uart_regs->sr & AML_UART_TX_FULL) && !serial_queue_empty(&tx_queue_handle, tx_queue_handle.queue->head)) { - serial_cancel_producer_signal(&tx_queue_handle); - uart_regs->cr &= ~AML_UART_TX_INT_EN; - reprocess = true; - } + /* If transmit fifo is full and there is data remaining to be sent, enable interrupt when fifo is no longer full */ + if (uart_regs->sr & AML_UART_TX_FULL && !serial_queue_empty(&tx_queue_handle, tx_queue_handle.queue->head)) { + uart_regs->cr |= AML_UART_TX_INT_EN; + } else { + uart_regs->cr &= ~AML_UART_TX_INT_EN; } if (transferred && serial_require_consumer_signal(&tx_queue_handle)) { @@ -116,7 +105,7 @@ static void rx_return(void) } if (!(uart_regs->sr & AML_UART_RX_EMPTY) && serial_queue_full(&rx_queue_handle, rx_queue_handle.queue->tail)) { - /* Disable rx interrupts until virtualisers queue is no longer empty. */ + /* Disable rx interrupts until virtualisers queue is no longer full. */ uart_regs->cr &= ~AML_UART_RX_INT_EN; serial_request_consumer_signal(&rx_queue_handle); } @@ -129,8 +118,7 @@ static void rx_return(void) } } - if (enqueued && serial_require_producer_signal(&rx_queue_handle)) { - serial_cancel_producer_signal(&rx_queue_handle); + if (enqueued) { microkit_notify(config.rx.id); } } diff --git a/drivers/serial/snps/uart.c b/drivers/serial/snps/uart.c index 3b8a4a6e9..1d8671496 100644 --- a/drivers/serial/snps/uart.c +++ b/drivers/serial/snps/uart.c @@ -47,32 +47,19 @@ static void set_baud(unsigned long baud) static void tx_provide(void) { - bool reprocess = true; bool transferred = false; - while (reprocess) { - char c; - - while ((*REG_PTR(UART_LSR) & UART_LSR_THRE) && !serial_dequeue(&tx_queue_handle, &c)) { - *REG_PTR(UART_THR) = c; - transferred = true; - } - - serial_request_producer_signal(&tx_queue_handle); - /* If transmit FIFO is full and we still have data to be sent, enable TX IRQ */ - if ((*REG_PTR(UART_LSR) & UART_LSR_THRE) == 0 - && !serial_queue_empty(&tx_queue_handle, tx_queue_handle.queue->head)) { - *REG_PTR(UART_IER) |= UART_IER_ETBEI; - } else { - *REG_PTR(UART_IER) &= ~UART_IER_ETBEI; - } - reprocess = false; + char c; + while ((*REG_PTR(UART_LSR) & UART_LSR_THRE) && !serial_dequeue(&tx_queue_handle, &c)) { + *REG_PTR(UART_THR) = c; + transferred = true; + } - if ((*REG_PTR(UART_LSR) & UART_LSR_THRE) - && !serial_queue_empty(&tx_queue_handle, tx_queue_handle.queue->head)) { - serial_cancel_producer_signal(&tx_queue_handle); - *REG_PTR(UART_IER) &= ~UART_IER_ETBEI; - reprocess = true; - } + /* If transmit FIFO is full and we still have data to be sent, enable TX IRQ */ + if ((*REG_PTR(UART_LSR) & UART_LSR_THRE) == 0 + && !serial_queue_empty(&tx_queue_handle, tx_queue_handle.queue->head)) { + *REG_PTR(UART_IER) |= UART_IER_ETBEI; + } else { + *REG_PTR(UART_IER) &= ~UART_IER_ETBEI; } if (transferred && serial_require_consumer_signal(&tx_queue_handle)) { @@ -110,8 +97,7 @@ static void rx_return(void) } } - if (enqueued && serial_require_producer_signal(&rx_queue_handle)) { - serial_cancel_producer_signal(&rx_queue_handle); + if (enqueued) { microkit_notify(config.rx.id); } } diff --git a/drivers/serial/virtio/console.c b/drivers/serial/virtio/console.c index 0f10e0fed..1c3e4ca61 100644 --- a/drivers/serial/virtio/console.c +++ b/drivers/serial/virtio/console.c @@ -107,49 +107,38 @@ volatile virtio_mmio_regs_t *uart_regs; static void tx_provide(void) { - bool reprocess = true; bool transferred = false; - while (reprocess) { - char c; - while (!virtio_avail_full_tx(&tx_virtq) && !serial_dequeue(&tx_queue_handle, &c)) { - - /* First, allocate somewhere to put the character */ - uint32_t char_idx = -1; - int err = ialloc_alloc(&tx_char_ialloc_desc, &char_idx); - assert(!err && char_idx != -1); - - /* Now we need to a descriptor to put into the virtIO ring */ - uint32_t pkt_desc_idx = -1; - err = ialloc_alloc(&tx_ialloc_desc, &pkt_desc_idx); - assert(!err && pkt_desc_idx != -1); + char c; + while (!virtio_avail_full_tx(&tx_virtq) && !serial_dequeue(&tx_queue_handle, &c)) { - /* We should not run out of descriptors assuming that the avail ring is not full. */ - assert(pkt_desc_idx < tx_virtq.num); + /* First, allocate somewhere to put the character */ + uint32_t char_idx = -1; + int err = ialloc_alloc(&tx_char_ialloc_desc, &char_idx); + assert(!err && char_idx != -1); - /* Put the character into the data region */ - virtio_tx_char[char_idx] = c; + /* Now we need to a descriptor to put into the virtIO ring */ + uint32_t pkt_desc_idx = -1; + err = ialloc_alloc(&tx_ialloc_desc, &pkt_desc_idx); + assert(!err && pkt_desc_idx != -1); - /* Set up the packet */ - tx_virtq.desc[pkt_desc_idx].addr = virtio_tx_char_paddr + char_idx; - tx_virtq.desc[pkt_desc_idx].len = 1; - tx_virtq.desc[pkt_desc_idx].flags = 0; + /* We should not run out of descriptors assuming that the avail ring is not full. */ + assert(pkt_desc_idx < tx_virtq.num); - /* Enqueue the packet */ - tx_virtq.avail->ring[tx_virtq.avail->idx % tx_virtq.num] = pkt_desc_idx; + /* Put the character into the data region */ + virtio_tx_char[char_idx] = c; - tx_virtq.avail->idx++; - tx_last_desc_idx += 1; + /* Set up the packet */ + tx_virtq.desc[pkt_desc_idx].addr = virtio_tx_char_paddr + char_idx; + tx_virtq.desc[pkt_desc_idx].len = 1; + tx_virtq.desc[pkt_desc_idx].flags = 0; - transferred = true; - } + /* Enqueue the packet */ + tx_virtq.avail->ring[tx_virtq.avail->idx % tx_virtq.num] = pkt_desc_idx; - serial_request_producer_signal(&tx_queue_handle); - reprocess = false; + tx_virtq.avail->idx++; + tx_last_desc_idx += 1; - if (!virtio_avail_full_tx(&tx_virtq) && !serial_queue_empty(&tx_queue_handle, tx_queue_handle.queue->head)) { - serial_cancel_producer_signal(&tx_queue_handle); - reprocess = true; - } + transferred = true; } if (transferred) { @@ -165,7 +154,7 @@ static void tx_provide(void) static void tx_return(void) { - /* After the tx has been processed, we need to free the packet/character allocation */ + /* After the tx has been processed, we need to free the packet/character allocation */ uint16_t enqueued = 0; uint16_t i = tx_last_seen_used; uint16_t curr_idx = tx_virtq.used->idx; @@ -197,7 +186,7 @@ static void tx_return(void) static void rx_provide(void) { - /* Fill up the virtio available ring buffer */ + /* Fill up the virtio available ring buffer */ bool transferred = false; while (!virtio_avail_full_rx(&rx_virtq)) { // Allocate a desc entry for the packet and the character @@ -278,8 +267,7 @@ static void rx_return(void) rx_last_seen_used += transferred; - if (transferred > 0 && serial_require_producer_signal(&rx_queue_handle)) { - serial_cancel_producer_signal(&rx_queue_handle); + if (transferred > 0) { microkit_notify(RX_CH); } } diff --git a/examples/serial/client.c b/examples/serial/client.c index 3b8ed4d96..2d2665167 100644 --- a/examples/serial/client.c +++ b/examples/serial/client.c @@ -29,28 +29,17 @@ void init(void) uint16_t char_count; void notified(microkit_channel ch) { - bool reprocess = true; char c; - while (reprocess) { - while (!serial_dequeue(&rx_queue_handle, &c)) { - if (c == '\r') { - sddf_putchar_unbuffered('\\'); - sddf_putchar_unbuffered('r'); - } else { - sddf_putchar_unbuffered(c); - } - char_count++; - if (char_count % 10 == 0) { - sddf_printf("\n%s has received %u characters so far!\n", microkit_name, char_count); - } + while (!serial_dequeue(&rx_queue_handle, &c)) { + if (c == '\r') { + sddf_putchar_unbuffered('\\'); + sddf_putchar_unbuffered('r'); + } else { + sddf_putchar_unbuffered(c); } - - serial_request_producer_signal(&rx_queue_handle); - reprocess = false; - - if (!serial_queue_empty(&rx_queue_handle, rx_queue_handle.queue->head)) { - serial_cancel_producer_signal(&rx_queue_handle); - reprocess = true; + char_count++; + if (char_count % 10 == 0) { + sddf_printf("\n%s has received %u characters so far!\n", microkit_name, char_count); } } } diff --git a/include/sddf/serial/queue.h b/include/sddf/serial/queue.h index c57a49079..17a882cee 100644 --- a/include/sddf/serial/queue.h +++ b/include/sddf/serial/queue.h @@ -18,8 +18,6 @@ typedef struct serial_queue { uint32_t tail; /* index to remove from */ uint32_t head; - /* flag to indicate whether consumer requires signalling */ - uint32_t consumer_signalled; /* flag to indicate whether producer requires signalling */ uint32_t producer_signalled; } serial_queue_t; @@ -363,19 +361,6 @@ static inline void serial_request_consumer_signal(serial_queue_handle_t *queue_h #endif } -/** - * Indicate to producer of the queue that consumer requires signalling. - * - * @param queue queue handle of queue that requires signalling upon enqueuing. - */ -static inline void serial_request_producer_signal(serial_queue_handle_t *queue_handle) -{ - queue_handle->queue->consumer_signalled = 0; -#ifdef CONFIG_ENABLE_SMP_SUPPORT - THREAD_MEMORY_RELEASE(); -#endif -} - /** * Indicate that producer has been signalled. * @@ -389,19 +374,6 @@ static inline void serial_cancel_consumer_signal(serial_queue_handle_t *queue_ha #endif } -/** - * Indicate that consumer has been signalled. - * - * @param queue queue handle of the queue that has been signalled. - */ -static inline void serial_cancel_producer_signal(serial_queue_handle_t *queue_handle) -{ - queue_handle->queue->consumer_signalled = 1; -#ifdef CONFIG_ENABLE_SMP_SUPPORT - THREAD_MEMORY_RELEASE(); -#endif -} - /** * Producer of the queue requires signalling. * @@ -411,13 +383,3 @@ static inline bool serial_require_consumer_signal(serial_queue_handle_t *queue_h { return !queue_handle->queue->producer_signalled; } - -/** - * Consumer of the queue requires signalling. - * - * @param queue queue handle of the queue to check. - */ -static inline bool serial_require_producer_signal(serial_queue_handle_t *queue_handle) -{ - return !queue_handle->queue->consumer_signalled; -} diff --git a/serial/components/virt_rx.c b/serial/components/virt_rx.c index e23783906..050ca8a76 100644 --- a/serial/components/virt_rx.c +++ b/serial/components/virt_rx.c @@ -33,85 +33,72 @@ void reset_state(void) void rx_return(void) { - bool reprocess = true; bool transferred = false; uint32_t local_tail = rx_queue_handle_cli[current_client].queue->tail; char c = '\0'; - while (reprocess) { - while (!serial_dequeue(&rx_queue_handle_drv, &c)) { - switch (current_mode) { - case normal: + while (!serial_dequeue(&rx_queue_handle_drv, &c)) { + switch (current_mode) { + case normal: + if (c == config.switch_char) { + current_mode = switched; + } else { + if (!serial_enqueue_local(&rx_queue_handle_cli[current_client], &local_tail, c)) { + transferred = true; + } + } + break; + case switched: + if (sddf_isdigit(c)) { + next_client[next_client_index] = c; + next_client_index++; + current_mode = number; + } else { if (c == config.switch_char) { - current_mode = switched; - } else { if (!serial_enqueue_local(&rx_queue_handle_cli[current_client], &local_tail, c)) { transferred = true; } - } - break; - case switched: - if (sddf_isdigit(c)) { - next_client[next_client_index] = c; - next_client_index ++; - current_mode = number; } else { - if (c == config.switch_char) { - if (!serial_enqueue_local(&rx_queue_handle_cli[current_client], &local_tail, c)) { - transferred = true; - } - } else { - sddf_dprintf("VIRT_RX|LOG: User entered an invalid digit %c\n", c); - } - reset_state(); + sddf_dprintf("VIRT_RX|LOG: User entered an invalid digit %c\n", c); } - break; - default: - if (c == config.terminate_num_char) { - int input_number = sddf_atoi(next_client); - if (input_number >= 0 && input_number < config.num_clients) { - if (transferred && serial_require_producer_signal(&rx_queue_handle_cli[current_client])) { - serial_update_shared_tail(&rx_queue_handle_cli[current_client], local_tail); - serial_cancel_producer_signal(&rx_queue_handle_cli[current_client]); - microkit_notify(config.clients[current_client].id); - } - current_client = (uint32_t)input_number; - local_tail = rx_queue_handle_cli[current_client].queue->tail; - transferred = false; - sddf_dprintf("VIRT_RX|LOG: switching to client %d\n", input_number); - } else { - sddf_dprintf("VIRT_RX|LOG: User requested to switch to an invalid client %d\n", input_number); + reset_state(); + } + break; + default: + if (c == config.terminate_num_char) { + int input_number = sddf_atoi(next_client); + if (input_number >= 0 && input_number < config.num_clients) { + if (transferred) { + serial_update_shared_tail(&rx_queue_handle_cli[current_client], local_tail); + microkit_notify(config.clients[current_client].id); } - reset_state(); - } else if (next_client_index < MAX_CLI_BASE_10 && sddf_isdigit((int)c)) { - next_client[next_client_index] = c; - next_client_index ++; + current_client = (uint32_t)input_number; + local_tail = rx_queue_handle_cli[current_client].queue->tail; + transferred = false; + sddf_dprintf("VIRT_RX|LOG: switching to client %d\n", input_number); } else { - sddf_dprintf("VIRT_RX|LOG: User entered too many (%u < %u) or invalid digit (%c)\n", next_client_index + 1, - MAX_CLI_BASE_10, c); - reset_state(); + sddf_dprintf("VIRT_RX|LOG: User requested to switch to an invalid client %d\n", input_number); } - break; + reset_state(); + } else if (next_client_index < MAX_CLI_BASE_10 && sddf_isdigit((int)c)) { + next_client[next_client_index] = c; + next_client_index++; + } else { + sddf_dprintf("VIRT_RX|LOG: User entered too many (%u < %u) or invalid digit (%c)\n", + next_client_index + 1, MAX_CLI_BASE_10, c); + reset_state(); } - } - - serial_update_shared_tail(&rx_queue_handle_cli[current_client], local_tail); - serial_request_producer_signal(&rx_queue_handle_drv); - reprocess = false; - - if (!serial_queue_empty(&rx_queue_handle_drv, rx_queue_handle_drv.queue->head)) { - serial_cancel_producer_signal(&rx_queue_handle_drv); - reprocess = true; + break; } } + serial_update_shared_tail(&rx_queue_handle_cli[current_client], local_tail); if (!serial_queue_full(&rx_queue_handle_drv, rx_queue_handle_drv.queue->tail) && serial_require_consumer_signal(&rx_queue_handle_drv)) { serial_cancel_consumer_signal(&rx_queue_handle_drv); microkit_notify(config.driver.id); } - if (transferred && serial_require_producer_signal(&rx_queue_handle_cli[current_client])) { - serial_cancel_producer_signal(&rx_queue_handle_cli[current_client]); + if (transferred) { microkit_notify(config.clients[current_client].id); } } diff --git a/serial/components/virt_tx.c b/serial/components/virt_tx.c index 61c54961a..45fe49b40 100644 --- a/serial/components/virt_tx.c +++ b/serial/components/virt_tx.c @@ -85,7 +85,6 @@ bool process_tx_queue(uint32_t client) serial_queue_handle_t *handle = &tx_queue_handle_cli[client]; if (serial_queue_empty(handle, handle->queue->head)) { - serial_request_producer_signal(handle); return false; } @@ -102,9 +101,6 @@ bool process_tx_queue(uint32_t client) /* Request signal from the driver when data has been consumed */ serial_request_consumer_signal(&tx_queue_handle_drv); - - /* Cancel further signals from this client */ - serial_cancel_producer_signal(handle); return false; } @@ -115,7 +111,7 @@ bool process_tx_queue(uint32_t client) } else { serial_transfer_all(&tx_queue_handle_drv, handle); } - serial_request_producer_signal(handle); + return true; } @@ -135,25 +131,11 @@ void tx_return(void) bool transferred = false; for (uint32_t req = 0; req < num_pending_tx; req++) { tx_pending_pop(&client); - bool reprocess = true; - bool client_transferred = false; - while (reprocess) { - client_transferred |= process_tx_queue(client); - reprocess = false; - - /* If more data is available, re-process unless it has been pushed to pending transmits */ - if (!serial_queue_empty(&tx_queue_handle_cli[client], tx_queue_handle_cli[client].queue->head) - && !tx_pending.clients_pending[client]) { - serial_cancel_producer_signal(&tx_queue_handle_cli[client]); - reprocess = true; - } - } - transferred |= client_transferred; - notify_client[client] = client_transferred; + notify_client[client] = process_tx_queue(client); + transferred |= notify_client[client]; } - if (transferred && serial_require_producer_signal(&tx_queue_handle_drv)) { - serial_cancel_producer_signal(&tx_queue_handle_drv); + if (transferred) { microkit_notify(config.driver.id); } @@ -180,22 +162,8 @@ void tx_provide(microkit_channel ch) return; } - bool transferred = false; - bool reprocess = true; - while (reprocess) { - transferred |= process_tx_queue(active_client); - reprocess = false; - - /* If more data is available, re-process unless it has been pushed to pending transmits */ - if (!serial_queue_empty(&tx_queue_handle_cli[active_client], tx_queue_handle_cli[active_client].queue->head) - && !tx_pending.clients_pending[active_client]) { - serial_cancel_producer_signal(&tx_queue_handle_cli[active_client]); - reprocess = true; - } - } - - if (transferred && serial_require_producer_signal(&tx_queue_handle_drv)) { - serial_cancel_producer_signal(&tx_queue_handle_drv); + bool transferred = process_tx_queue(active_client); + if (transferred) { microkit_notify(config.driver.id); } diff --git a/util/putchar_serial.c b/util/putchar_serial.c index e3fe51899..efc659514 100644 --- a/util/putchar_serial.c +++ b/util/putchar_serial.c @@ -30,10 +30,7 @@ void _sddf_putchar(char character) /* Make changes visible to virtualiser if character is flush or if queue is now filled */ if (serial_queue_full(tx_queue_handle, local_tail) || character == FLUSH_CHAR) { serial_update_shared_tail(tx_queue_handle, local_tail); - if (serial_require_producer_signal(tx_queue_handle)) { - serial_cancel_producer_signal(tx_queue_handle); - microkit_notify(tx_ch); - } + microkit_notify(tx_ch); } } @@ -46,10 +43,7 @@ void sddf_putchar_unbuffered(char character) serial_enqueue_local(tx_queue_handle, &local_tail, character); serial_update_shared_tail(tx_queue_handle, local_tail); - if (serial_require_producer_signal(tx_queue_handle)) { - serial_cancel_producer_signal(tx_queue_handle); - microkit_notify(tx_ch); - } + microkit_notify(tx_ch); } /* Initialise the serial putchar library. */