From owner-freebsd-drivers@freebsd.org Fri Jun 16 09:03:55 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 F3ADFBFB7E4; Fri, 16 Jun 2017 09:03:54 +0000 (UTC) (envelope-from baijiaju1990@163.com) Received: from m12-18.163.com (m12-18.163.com [220.181.12.18]) by mx1.freebsd.org (Postfix) with ESMTP id 2F369772F9; Fri, 16 Jun 2017 09:03:53 +0000 (UTC) (envelope-from baijiaju1990@163.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Message-ID:Date:MIME-Version; bh=FzeDY NBQjRxFdhEBSF9/lL4iz+nzdmMsnDa++ZYKbFo=; b=BasdRqUXKbsxB8BCIyy5A XUYUsNR+4pX5BiIKU+2VfnPihfK2Ko4PQctyjjxFceanPbod3Cs1pm2VdUmMxg1a eeKYODD/dPU17SpMuW0AKIY6ek5QZ3YpzLDwQICoQSLdzessEQaFlAnZnW/jmkHi 92NgXFUo8juuzFq4yqArgg= Received: from [166.111.70.34] (unknown [166.111.70.34]) by smtp14 (Coremail) with SMTP id EsCowACH1Rn3nkNZZ99uNA--.27125S2; Fri, 16 Jun 2017 17:03:51 +0800 (CST) To: freebsd-drivers@freebsd.org, freebsd-net@freebsd.org From: Jia-Ju Bai Subject: [Bug 220032] [if_alc] sys/dev/alc/if_alc.c: sleep-under-mutex bugs Message-ID: <7cc5abf5-f90c-c554-e54e-6f9534ef22ef@163.com> Date: Fri, 16 Jun 2017 17:03:51 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 MIME-Version: 1.0 Content-Language: en-US X-CM-TRANSID: EsCowACH1Rn3nkNZZ99uNA--.27125S2 X-Coremail-Antispam: 1Uf129KBjvdXoW7GF45Xw4fJFy5Jr1kZw18Krg_yoWfZwcE9F yrtry7Xw1xCFW2qa17AFWxuFW5WFW8Wa48ur4ruan8t34xXFs5tr4vvr13urZ3JayIvFnr Wr1Yg3y3CwnFvjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IU0yrW5UUUUU== X-Originating-IP: [166.111.70.34] X-CM-SenderInfo: xedlyx5dmximizq6il2tof0z/1tbiGBf4elXlaGaGGgAAsv 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: Fri, 16 Jun 2017 09:03:55 -0000 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