Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 18 Jun 2017 15:47:46 +0800
From:      Jia-Ju Bai <baijiaju1990@163.com>
To:        Kevin Oberman <rkoberman@gmail.com>
Cc:        freebsd-drivers@freebsd.org, "freebsd-net@freebsd.org" <freebsd-net@freebsd.org>
Subject:   Re: [Bug 220032] [if_alc] sys/dev/alc/if_alc.c: sleep-under-mutex bugs
Message-ID:  <fbc0f04f-b7cf-ee86-9681-d6dd97122038@163.com>
In-Reply-To: <CAN6yY1uQxR3HTLYzy3uOwpcbLFGAKtCBxRU1HPAb8jjGVC9Hkg@mail.gmail.com>
References:  <7cc5abf5-f90c-c554-e54e-6f9534ef22ef@163.com> <CAN6yY1uQxR3HTLYzy3uOwpcbLFGAKtCBxRU1HPAb8jjGVC9Hkg@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Thanks a lot, your advice is very helpful :)
I will submit a patch according to your advice, and update my bug report.

By the way, I have found many similar possible bugs in network drivers 
in FreeBSD.
And they are all caused by "BUS_DMA_WAITOK" in bus_dmamap_load and other 
dmamap-load related functions.
If my reported bugs can be quickly confirmed, I will write and submit 
patches for them as soon as possible.
I am looking forward to helpful comments and advice :)

Thanks,
Jia-Ju Bai

On 2017/6/18 13:31, Kevin Oberman wrote:
> On Fri, Jun 16, 2017 at 2:03 AM, Jia-Ju Bai <baijiaju1990@163.com 
> <mailto:baijiaju1990@163.com>> wrote:
>
>     The alc driver may sleep under a mutex, and the function call
>     paths in file
>     "sys/dev/alc/if_alc.c" in FreeBSD 11.0 is:
>     alc_resume [line 2648: acquire the mutex]
>       alc_init_locked [line 2664]
>         alc_init_rx_ring [line 3911]
>           alc_newbuf [line 4469]
>             bus_dmamap_load_mbuf_sg(BUS_DMA_WAITOK) [line 3472] -->
>     may sleep
>
>     alc_int_task [line 3330: acquire the mutex]
>       alc_start_locked [line 3372]
>         alc_encap [line 2942]
>           bus_dmamap_load_mbuf_sg(BUS_DMA_WAITOK) [line 2780] --> may
>     sleep
>
>     The possible fix of these bugs is to set the last parameter in
>     bus_dmamap_load_mbuf_sg to "BUS_DMA_NOWAIT".
>
>     This bug is found by a static analysis tool written by myself, and
>     it is
>     checked by my review of the FreeBSD code.
>
>     By the way, I am a freshman in developing FreeBSD drivers, and I
>     am willing to
>     submit a patch. But I do not know how to write and submit a patch,
>     and where to
>     submit, so I am looking forward to useful advice :)
>
>     Jia-Ju Bai
>
>
> To submit a patch, use svn to download the source from a repository. 
> Be sure the file in your source directory is the current, unmodified file.
> Edit the file or files as needed to correct the bug
> Generate the diff with the command "svn diff 
> path-to-directory-containing-file(s) > diff-file.diff"
> Update the bug report attaching the patch (with a brief description)
> --
> Kevin Oberman, Part time kid herder and retired Network Engineer
> E-mail: rkoberman@gmail.com <mailto:rkoberman@gmail.com>
> PGP Fingerprint: D03FB98AFA78E3B78C1694B318AB39EF1B055683




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?fbc0f04f-b7cf-ee86-9681-d6dd97122038>