-
Notifications
You must be signed in to change notification settings - Fork 7.6k
drivers: usb: rename UDC buffer to USB buffer #86920
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
Open
jfischer-no
wants to merge
5
commits into
zephyrproject-rtos:main
Choose a base branch
from
jfischer-no:pr-usb-buf
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+142
−81
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2f621c3
include: usb: introduce UDC_ROUND_UP macro
jfischer-no 6596aad
drivers: usb: move common driver headers to include
jfischer-no 7445e68
drivers: usb: move UDC net_buf_data_cb implementation to USB common
jfischer-no 35cbeb8
include: drivers: usb: rename UDC buffer to USB buffer
jfischer-no 5491f63
usb: host: use USB buffer macros
jfischer-no File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,4 +17,4 @@ API reference | |
|
||
.. doxygengroup:: udc_api | ||
|
||
.. doxygengroup:: udc_buf | ||
.. doxygengroup:: usb_buf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
add_subdirectory_ifdef(CONFIG_HAS_NRFX nrf_usbd_common) | ||
add_subdirectory(buf) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Copyright Nordic Semiconductor ASA | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
zephyr_library() | ||
zephyr_library_sources_ifdef(CONFIG_UDC_DRIVER usb_buf.c) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright 2025 Nordic Semiconductor ASA | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <zephyr/kernel.h> | ||
#include <zephyr/net_buf.h> | ||
#include <zephyr/drivers/usb/usb_buf.h> | ||
|
||
static inline uint8_t *usb_pool_data_alloc(struct net_buf *const buf, | ||
size_t *const size, k_timeout_t timeout) | ||
{ | ||
struct net_buf_pool *const buf_pool = net_buf_pool_get(buf->pool_id); | ||
struct k_heap *const pool = buf_pool->alloc->alloc_data; | ||
void *b; | ||
|
||
*size = USB_BUF_ROUND_UP(*size); | ||
b = k_heap_aligned_alloc(pool, USB_BUF_ALIGN, *size, timeout); | ||
if (b == NULL) { | ||
*size = 0; | ||
return NULL; | ||
} | ||
|
||
return b; | ||
} | ||
|
||
static inline void usb_pool_data_unref(struct net_buf *buf, uint8_t *const data) | ||
{ | ||
struct net_buf_pool *buf_pool = net_buf_pool_get(buf->pool_id); | ||
struct k_heap *pool = buf_pool->alloc->alloc_data; | ||
|
||
k_heap_free(pool, data); | ||
} | ||
|
||
const struct net_buf_data_cb net_buf_dma_cb = { | ||
.alloc = usb_pool_data_alloc, | ||
.unref = usb_pool_data_unref, | ||
}; |
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't remove the prompt as part of rename macro commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing functional behavior is something that should not be done in rename commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where did you get that?
What functional behavior has been changed that is not described in the commit message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Kconfig symbol is now promptless.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should not have a prompt. And now it is moved up one level and it must not have a prompt. Rather there also should be
menu USB
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @jfischer-no Could you please help to explain why it should not have a prompt? Without prompt, it can't be configured in application. Take NXP USB controller as one example,
USB_BUF_FORCE_NOCACHE
can be true default. application can set it as false, then data is in cached ram and data size aligned with cache line size, NXP USB controller will do the cached data maintenance.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If your driver can handle it, the driver should not select this option at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I understand your point. My original thought is:
USB_BUF_FORCE_NOCACHE
can give option that can be selected by User/Application. For example: User put the USB transfer buffer to non-cached ram that is faster (internal ram) than cached ram (external ram) in order that CPU can process the USB data faster, then theUSB_BUF_FORCE_NOCACHE
can be enabled by application. Anyway the USB buffer of application can be put in non-cached ram evenUSB_BUF_FORCE_NOCACHE
is disabled. But the stack's USB transfer buffer's location can only be controlled byUSB_BUF_FORCE_NOCACHE
, application can't control it.If you think it should not be controlled by application, I don't see the strong request now.
After this is merged, I can create PR to not select
USB_BUF_FORCE_NOCACHE
default in NXP controller drivers.