From owner-freebsd-drivers@freebsd.org Fri Jun 16 09:16:57 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 83EE3BFBC3D; Fri, 16 Jun 2017 09:16:57 +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 BE5F677998; Fri, 16 Jun 2017 09:16:56 +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=yKLFn 01hX4duwPXV7AfqMAxpTXHOTXvVK0oZo/z+Wp0=; b=TWuM0rtpT7cHsIWnHog+V lxwV4EK+P1YX2gaQLjaOcGeY8CkTPVibbEkty7VdbqcMt1nquo1cJ9CKimvxWNrj JATaMeREptRNzPaMhh+/7bBkIYD/DkHrvLE/QK3nWTSFg9+aojYtT190U13qBXKX HLh1ZrVma3UHBSkVlSeGeY= Received: from [166.111.70.34] (unknown [166.111.70.34]) by smtp14 (Coremail) with SMTP id EsCowACnVa52nkNZ8rluNA--.63932S2; Fri, 16 Jun 2017 17:01:43 +0800 (CST) To: freebsd-drivers@freebsd.org, freebsd-net@freebsd.org From: Jia-Ju Bai Subject: [Bug 220033] [if_ixgb] sys/dev/ixgb/if_ixgb.c: a sleep-under-mutex bug in ixge_get_buf Message-ID: <4f7481c7-f70b-a76d-2169-8e57f9ba3cb8@163.com> Date: Fri, 16 Jun 2017 17:01:42 +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: EsCowACnVa52nkNZ8rluNA--.63932S2 X-Coremail-Antispam: 1Uf129KBjvdXoW7GF4rAr1kKF4fXw1UGrWDXFb_yoW3ZFgE9F 1IvryUAw13WFW2ga13Cr48uFWF9FWfuFy8Wr4rXws0yFyxXFn5trsa9rWa9rWxG3yxuFn7 Zr1aq3y7C3ZrXjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUnldgJUUUUU== X-Originating-IP: [166.111.70.34] X-CM-SenderInfo: xedlyx5dmximizq6il2tof0z/xtbBRRf4elO-7oHhLAAAse 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:16:57 -0000 The ixgb driver may sleep under a mutex, and the function call path in file "sys/dev/ixgb/if_ixgb.c" in FreeBSD 11.0 is: ixgb_init [line 750: acquire the mutex] ixgb_init_locked [line 751] ixgb_setup_receive_structures [line 699] ixgb_allocate_receive_structures [line 1913] ixgb_get_buf [line 1885] bus_dmamap_load(BUS_DMA_WAITOK) [line 1812] --> may sleep The possible fix of these bugs is to set the last parameter in bus_dmamap_load 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