免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1686 | 回复: 1
打印 上一主题 下一主题

[硬件及驱动] kernel启动到USB HUB挂死,请各位大神帮忙给个解决的思路,谢谢! [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-11-08 01:01 |只看该作者 |倒序浏览
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()完了后调度到内核的其它地方)。
请教一下各位大神,为了找出真正挂死的地方,如何查看挂死在那个内核模块?如何查出此时系统调度到什么地方?

论坛徽章:
0
2 [报告]
发表于 2012-11-08 01:08 |只看该作者
各位大虾,提问贴不小心把现场草稿也贴上去了,是从////////////////////////////////////////开始的,不好意思
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP