Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion drivers/usb/dwc3/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1999,7 +1999,8 @@ int dwc3_probe(struct dwc3 *dwc,
*/
dwc_res = *res;
dwc_res.start += DWC3_GLOBALS_REGS_START;
dwc_res.end = res->start + DWC3_OTG_REGS_END;
dwc_res.end = min_t(resource_size_t, res->end,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

这里感觉会是个隐患。可能检查res->end是否满足res->start + DWC3_LLUCTL_REGS_END再赋值,不然warning并赋值res->start + DWC3_OTG_REGS_END更安全一点

res->start + DWC3_LLUCTL_REGS_END);

if (dev->of_node) {
struct device_node *parent = of_get_parent(dev->of_node);
Expand Down
2 changes: 2 additions & 0 deletions drivers/usb/dwc3/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@
#define DWC3_DEVICE_REGS_END 0xcbff
#define DWC3_OTG_REGS_START 0xcc00
#define DWC3_OTG_REGS_END 0xccff
/* DWC_usb31 LLUCTL sits past the OTG register block. */

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
/* DWC_usb31 LLUCTL sits past the OTG register block. */
#define DWC3_LLUCTL_REGS_START 0xXXXXXX

补一个DWC3_LLUCTL_REGS_START吧。另外那个注释没必要,寄存器自然不会重叠

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

这个 DWC3_LLUCTL_REGS_START 应该不需要吧, 用不上, dwc_res.start 用的是 DWC3_GLOBALS_REGS_START 的值, DWC3_LLUCTL_REGS_END 指的是 DWC3 Core 到 LLUCTL 所在偏移为止的寄存器空间(DWC Core 寄存器区域的终点)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

其他几个寄存器都是包含了起始的定义的。start那边没问题

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

DWC3_LLUCTL_REGS_END 指 DWC3 Core 的映射上限

其实应该这么写的:
#define DWC3_LLUCTL 0xd024
#define DWC3_LLUCTL_MAP_END 0xda00

#define DWC3_LLUCTL_REGS_END 0xda00

#define DWC3_RTK_RTD_GLOBALS_REGS_START 0x8100

Expand Down