From owner-freebsd-drivers@freebsd.org Sun Jun 18 11:42:41 2017 Return-Path: Delivered-To: freebsd-drivers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4DA1BD8F020; Sun, 18 Jun 2017 11:42:41 +0000 (UTC) (envelope-from baijiaju1990@163.com) Received: from m12-12.163.com (m12-12.163.com [220.181.12.12]) by mx1.freebsd.org (Postfix) with ESMTP id A836E68A67; Sun, 18 Jun 2017 11:42:40 +0000 (UTC) (envelope-from baijiaju1990@163.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=Subject:From:Message-ID:Date:MIME-Version; bh=dTwY6 94F92qcjd4snrOZPQKu+7AwZaDvu+ivpZQ0/Vk=; b=k+VrEsmSRp/hkPBssP2O1 unzivYflR89zywrEdxXLGdgDjA6Q5uWzdzbeIhQ3dkAVyUN7Ff15pg5lhNkp6Xma uzjOF7EyHioVfyRAtdramzmSbl3lucl2xPsKTsdouxhsuSu2gZxXmiEcJBGdsCNw fkxBINv5o5md3RTNcjpSRU= Received: from [166.111.70.13] (unknown [166.111.70.13]) by smtp8 (Coremail) with SMTP id DMCowADHXp8vZ0ZZD2MEDA--.24469S2; Sun, 18 Jun 2017 19:42:39 +0800 (CST) Subject: Re: [Bug 220032] [if_alc] sys/dev/alc/if_alc.c: sleep-under-mutex bugs From: Jia-Ju Bai To: Kevin Oberman Cc: freebsd-drivers@freebsd.org, "freebsd-net@freebsd.org" References: <7cc5abf5-f90c-c554-e54e-6f9534ef22ef@163.com> Message-ID: <00aa0c88-70b6-cb34-461e-34e25029f481@163.com> Date: Sun, 18 Jun 2017 19:42:39 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-CM-TRANSID: DMCowADHXp8vZ0ZZD2MEDA--.24469S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7ur17ZryxGF15Kr4UArWxtFb_yoW8KF18p3 yagas0yryDArWfA3s7Ar4xuFyfX395GrZ8GF45urZFqw15Wr12gr1SgFWUZFyrur9xCFWI vFWUX3ykZFs0yaDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jrWrZUUUUU= X-Originating-IP: [166.111.70.13] X-CM-SenderInfo: xedlyx5dmximizq6il2tof0z/1tbiHg-6elSIVqMxCQAAsA Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Jun 2017 11:42:41 -0000 Hi, I have read the manual page ofbus_dmamap_load and other dmamap-load related functions. These calls will always return immediately and will not block for any reason. Sorry for my wrong report, please ignore it. Thanks, Jia-Ju Bai On 2017/6/18 15:47, Jia-Ju Bai wrote: > 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 > > 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 >> PGP Fingerprint: D03FB98AFA78E3B78C1694B318AB39EF1B055683 >