From owner-freebsd-drivers@freebsd.org Sun Jun 18 05:31:29 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 0C943D89558; Sun, 18 Jun 2017 05:31:29 +0000 (UTC) (envelope-from kob6558@gmail.com) Received: from mail-pg0-x231.google.com (mail-pg0-x231.google.com [IPv6:2607:f8b0:400e:c05::231]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id CB876840BD; Sun, 18 Jun 2017 05:31:28 +0000 (UTC) (envelope-from kob6558@gmail.com) Received: by mail-pg0-x231.google.com with SMTP id 132so2028439pgb.2; Sat, 17 Jun 2017 22:31:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=jpVbkf9+duGDRxNn0+O7dH8WBytsjUcZ8kcgHMyaOUQ=; b=EOrV6Ci7Rz9APjBashsYPaaoXTjMwvVq1uL1G33cvlB4x+sEnGJNcj5Zo/5xAWdiwi n9NjTaBLdbmvpWFULSxuA16szZnVXl7UO72SnQYoFGAowj5J8og0eL+Vkni4DegEKodv N9sTJ1J6/pTHkj3XEfXikRR308k10yuGsXWJF2+oN3CBX7cWI+esLvddc2YgodsMApny 4ro6vpjRqDQReoG05VNID2ARYSz9EmRmzFXzV2c6A8NO1W1ComwTLhFVdQg9GVubCWRp eAVmGxfPE7Bt80DOJ8aViEnpgVd5QYAtsEpP2ih4YBSDCyO7NGDAe5A4Piv5PYPJi4BG QNnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=jpVbkf9+duGDRxNn0+O7dH8WBytsjUcZ8kcgHMyaOUQ=; b=NQa5KLUuveZ39HiAEmiztEJXopCBxE8hBB0PAR9JbZZwyQVjTj8UWwePHUN1IC2YLX LV9WoYx7OgLOHQa7fPwZPk6NkWHXRVzXNs6VMio6xiwBHWqB4N9VuqQy03wRyR72NfGt jtIqgq7mo7FX4ml5Gwy1v02x42WTIrWvtipzkJWGZxx2wqN8vb2Wu+aTabQaPMY7DA41 KOHdH2dmOKJJajMpM/H1XmbBeiIY1hDwe58esi2BuRMRWw5enrleBtRCDOi2EzoS21o6 021wCVLgd32AtlKhMNIVMpHfaiye7n0jN+DjzhpJVnmeOtWbzFqm9nqnesNPY2/sTf02 bPdg== X-Gm-Message-State: AKS2vOy/+RaDb6ErWTTaImdZRLT0dyofw+i5u9p7sCX0xjbPh4wfZX4v ws1HaDJT221n2LBxcPgEQNRIhkgHYw== X-Received: by 10.84.225.130 with SMTP id u2mr22114218plj.255.1497763888419; Sat, 17 Jun 2017 22:31:28 -0700 (PDT) MIME-Version: 1.0 Sender: kob6558@gmail.com Received: by 10.100.140.202 with HTTP; Sat, 17 Jun 2017 22:31:27 -0700 (PDT) In-Reply-To: <7cc5abf5-f90c-c554-e54e-6f9534ef22ef@163.com> References: <7cc5abf5-f90c-c554-e54e-6f9534ef22ef@163.com> From: Kevin Oberman Date: Sat, 17 Jun 2017 22:31:27 -0700 X-Google-Sender-Auth: D0C4coGfhN1xdwQo4bPtvqfZEbA Message-ID: Subject: Re: [Bug 220032] [if_alc] sys/dev/alc/if_alc.c: sleep-under-mutex bugs To: Jia-Ju Bai Cc: freebsd-drivers@freebsd.org, "freebsd-net@freebsd.org" Content-Type: text/plain; charset="UTF-8" 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 05:31:29 -0000 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