- 论坛徽章:
- 0
|
6318把USB驱动配置关掉,系统可以起来,但这样的话还不能区分是硬件还是驱动的问题;
有HUB,hub_events() jump endhub_thread() after hub_events(),死掉,没有输出;
无HUB,hub_events() jump endhub_thread() after hub_events()<6>NET: Registered protocol family 17,从这里可以看出,有HUB的时候死掉无法调度到内核的其它线程,怀疑跟调度关系;
在hub_thread中hub_events()后主动调度,仍然出现挂死的现象;
int usb_hub_init(void)
{
if (usb_register(&hub_driver) < 0) {
printk(KERN_ERR "%s: can't register hub driver\n",
usbcore_name);
return -1;
}
khubd_task = kthread_run(hub_thread, NULL, "khubd");
if (!IS_ERR(khubd_task))
return 0;
/* Fall through if kernel_thread failed */
usb_deregister(&hub_driver);
printk(KERN_ERR "%s: can't start khubd\n", usbcore_name);
return -1;
}
static int hub_thread(void *__unused)
{
/* khubd needs to be freezable to avoid intefering with USB-PERSIST
* port handover. Otherwise it might see that a full-speed device
* was gone before the EHCI controller had handed its port over to
* the companion full-speed controller.
*/
set_freezable();
do {
hub_events();
printk("hub_thread() after hub_events()");
//schedule();
wait_event_freezable(khubd_wait,
!list_empty(&hub_event_list) ||
kthread_should_stop());
printk("hub_thread() after wait_event_freezable()");
} while (!kthread_should_stop() || !list_empty(&hub_event_list));
printk("%s: khubd exiting\n", usbcore_name);
//pr_debug("%s: khubd exiting\n", usbcore_name);
return 0;
}
static void hub_events(void)
{
}
输出LOG:
。。。。。。
hub 1-1:1.0: state 7 ports 4 chg 0000 evt 0000
======zdstest hub_event() call usb_lock_device() =====
======zdstest hub_event() loop kref->refcount zds_ref = 0 =====
=======zdstest in handle event_list in zds_cnt=6=========
=======zdstest hub_events() get event lock in zds_cnt=6=========
hub_event_list empty
hub_events() jump end
hub_thread() after hub_events()
////////////////////////////////////////////////////////////////////////////////////////////////////
现象:开发板CPU接了一个HUB芯片作为扩展,上电启动后,串口输出的最后一句:
hub 1-1:1.0: state 7 ports 4 chg 0000 evt 0000后再也没有任何输出,按MagicSys键也没有中断响应
在内核的driver/usb/core/hub.c中
int usb_hub_init(void)
{
if (usb_register(&hub_driver) < 0) {
printk(KERN_ERR "%s: can't register hub driver\n",
usbcore_name);
return -1;
}
khubd_task = kthread_run(hub_thread, NULL, "khubd");
if (!IS_ERR(khubd_task))
return 0;
/* Fall through if kernel_thread failed */
usb_deregister(&hub_driver);
printk(KERN_ERR "%s: can't start khubd\n", usbcore_name);
return -1;
}
static int hub_thread(void *__unused)
{
/* khubd needs to be freezable to avoid intefering with USB-PERSIST
* port handover. Otherwise it might see that a full-speed device
* was gone before the EHCI controller had handed its port over to
* the companion full-speed controller.
*/
set_freezable();
do {
hub_events();
printk("hub_thread() after hub_events()");
wait_event_freezable(khubd_wait,
!list_empty(&hub_event_list) ||
kthread_should_stop());
printk("hub_thread() after wait_event_freezable()");
} while (!kthread_should_stop() || !list_empty(&hub_event_list));
printk("%s: khubd exiting\n", usbcore_name);
//pr_debug("%s: khubd exiting\n", usbcore_name);
return 0;
}
先说一下我的定位过程,
我在hub_events()的几个点上加了打印,hub_events()已经走完,并且满足hub_event_list为empty,挂死前有hub_thread() after hub_events()的打印,但是没有hub_thread() after wait_event_freezable()打印,wait_event_freezable是把当前的线程挂到等待队列中,我理解为此时就会发生调度,直到再有HUB的event再把它唤醒
再进入hub_events()处理。为了定位方便,我特意做了强制调度,把wait_event_freezable换成schedule(),但此时也是挂死,只输出了一句VFS后挂死时串口再也没有输出(正常情况是hub_thread() after hub_events()完了后调度到内核的其它地方)。
请教一下各位大神,为了找出真正挂死的地方,如何查看挂死在那个内核模块?如何查出此时系统调度到什么地方?
|
|