您尚未登录。

#1 工业芯 匠芯创 » 【Luban】D21x Linux UDC 驱动中一处 aic_writel 参数顺序错误 » 今天 10:20:40

boa
回复: 0

最近在进行 ArtInChip D21x 的 QEMU 适配,使用 Luban SDK 固件进行启动验证时,发现 Linux UDC 驱动中有一处寄存器写入参数顺序错误,反馈一下。

测试环境:

  • SoC:D21x

  • SDK:Luban V1.3.2

  • Kernel:Linux 5.10.44

问题位于:

source/linux-5.10/drivers/usb/gadget/udc/aic_udc.c

在 aic_core_hw_init1() 函数中:

/* soft disconnect */
aic_writel(gg, USBDEVFUNC, USBDEVFUNC_SFTDISCON);

而 aic_writel() 的定义为:

static inline void aic_writel(struct aic_usb_gadget *gg,
                             u32 value, u32 offset)
{
    writel(value, gg->regs + offset);
}

同时,aic_udc.h 中的相关定义为:

#define USBDEVFUNC             UDC_REG(0x204)
#define USBDEVFUNC_SFTDISCON   BIT(1)

因此,原代码实际向 UDC 基地址偏移 0x002 的位置执行了一次值为 0x204 的 32 位写入,而不是向偏移 0x204 的 USBDEVFUNC 寄存器写入 0x02。

在 QEMU 环境中启动 ADB 服务时,观察到了 Store Access Fault,相关日志如下:

Oops - store (or AMO) access fault
badaddr: ffffffff40970002
cause: 0000000000000007

建议修改为:

 /* soft disconnect */
-aic_writel(gg, USBDEVFUNC, USBDEVFUNC_SFTDISCON);
+aic_writel(gg, USBDEVFUNC_SFTDISCON, USBDEVFUNC);

目前官方 GitHub 仓库的 master 分支中仍能看到这处代码:

https://github.com/artinchip/luban/blob/master/source/linux-5.10/drivers/usb/gadget/udc/aic_udc.c#L1145

暂未在实际开发板上复现该异常,麻烦官方工程师确认一下,是否可以在后续 SDK 版本中修正。

谢谢!

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn


东莞哇酷科技有限公司开发