Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dev][uart][pl011] Move to common driver #274

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cleverca22
Copy link
Contributor

@cleverca22 cleverca22 commented Oct 11, 2020

while merging the 2 drivers, i found a bug in the qemu variant of uart_getc that didnt reveal itself under qemu, and fixed it

i also added some code for the other 4 PL011's in the pi4, but no target for that yet

confirmed to function on both PROJECT=rpi2-test and scripts/do-qemuarm

@travisg
Copy link
Member

travisg commented Oct 11, 2020

Nice, looks like a good start. I'll do a review in a little bit but on pass, can you update the comment itself to include what it's doing? I'm not a fan at all of commit changes that just say it fixes a commit # without any context.

Something like [dev][uart][pl011] Move to common driver

And then a line or two describing what it did, including the bug fix and a mention that it fixes a bug #.

@cleverca22
Copy link
Contributor Author

i do have some further improvements to the uart driver on the vc4 fork, but trying to keep this commit clear of those, so its easier to see just the merging, and the improvements can come later

merges the qemu and bcm28xx versions of the uart driver together
fixed a bug that was present in the qemu version, that only reveals itself on real hw
increase the fifo level interrupt to 7/8 to get more bytes/irq under high load

fix bug littlekernel#272
@cleverca22 cleverca22 changed the title [dev][pl011] fix issue #272 [dev][uart][pl011] Move to common driver Oct 12, 2020
Copy link
Member

@travisg travisg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments, but nothing majorly structurally wrong.

@@ -0,0 +1,4 @@
#pragma once
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the standard license header here.

}

static enum handler_return uart_irq(void *arg) {
bool resched = false;
uint port = (uintptr_t)arg;
uint port = (uint)arg;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an issue with 64bit targets, since its down casting to a smaller size. Perhaps cast it through uintptr_t first, then down to uint.

void uart_init(void) {
for (size_t i = 0; i < NUM_UART; i++) {
uintptr_t base = uart_to_ptr(i);
void pl011_uart_init(int irq, int nr, uintptr_t base) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To generally be consistent with existing apis, put the number first.

// create circular buffer to hold received data
cbuf_initialize(&uart_rx_buf[i], RXBUF_SIZE);
// assumes interrupts are contiguous
register_int_handler(irq, &uart_irq, (void *)nr);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the (void *) is a warning on arm64. Perhaps as before, cast it through uintptr_t first.

@@ -33,6 +32,7 @@ MODULE_DEPS += \
dev/virtio/block \
dev/virtio/gpu \
dev/virtio/net \
dev/pl011 \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be consistent, sort the list of the devs.

@@ -42,8 +42,8 @@ SMP_CPU_ID_BITS := 8
GLOBAL_DEFINES += \
BCM2836=1

MODULE_SRCS += \
$(LOCAL_DIR)/uart.c
MODULES += \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use MODULE_DEPS instead of MODULES. MODULES sometimes works but the _DEPS is the correct solution.

@@ -0,0 +1,7 @@
LOCAL_DIR := $(GET_LOCAL_DIR)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please name this dev/uart/pl011 instead of at the top level of dev.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants