Date: Sun, 20 Nov 2005 21:34:29 +0530 From: rashmi ns <nsrashmi@gmail.com> To: bugi@lists.redbrick.dcu.ie, freebsd-hackers@freebsd.org Subject: Driver crashes after unloading a module Message-ID: <9f9993160511200804w177a521s9cddc6e56afe221e@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
Hello List , Thanks for the help you given me . We have written driver for hdlc controller .The kernel is crashing after unloading the module with trap 12 fault .here is the order in which we release the resources while detaching the device. 1. stop polling timer(if polling mode) 2. destroy_dev() 3. disable the device 4. free Tx and Rx structures 5. deallocate allocated dma memory 6. bus_deactivate_resource(irq) 7. release all bus resources here is the piece of code /*release bus resources*/ static void hdlc_release(struct hdlc_softc *sc) { dbgprint("Entering"); bus_generic_detach(sc->dev); /*Release the resources held*/ if (sc->irq){ bus_teardown_intr(sc->dev, sc->irq,sc->int_handler_tag); sc->int_handler_tag =3D NULL; bus_release_resource(sc->dev, SYS_RES_IRQ,sc->irq_rid, sc->irq); dbgprint("deallocated irq res irq_rid =3D %d\n",sc->irq_rid); } if (sc->mem){ bus_release_resource (sc->dev, SYS_RES_MEMORY, sc->mem_rid, sc->mem); dbgprint("deallocated bus res\n"); } if(&sc->sc_mtx) mtx_destroy(&sc->sc_mtx); } /*detach function*/ static int hdlc_detach(device_t dev) { struct hdlc_softc *sc =3D device_get_softc(dev); int s; dbgprint("Entering\n"); s=3Dsplimp(); /*If drv is in poll mode then stop the poll timer */ if(sc->intr_mode =3D=3D 0) hdlc_clear_poll_mode(sc); if(!(sc->hdlc_cdev =3D=3D NULL) ){ destroy_dev(sc->hdlc_cdev); } /*stop the controller */ hdlc_hw_reset(sc); /*free hdlc Tx and Rx structures */ hdlc_stop(sc); /*deallocate allocated dma memory*/ hdlc_free_descriptors(sc); bus_deactivate_resource(sc->dev,SYS_RES_IRQ,sc->irq_rid,sc->irq); splx(s); /*free bus resources*/ hdlc_release(sc); uprintf("Detached\n"); return 0; } After unloading the module the it gives the debug print "Module unloaded" kld_loader function from and kernel crashes with trap 12 .Kindly let me know does the order of releasing the resources is the reason for this. Thanks and regards, Rashmi.n.s
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?9f9993160511200804w177a521s9cddc6e56afe221e>