From owner-freebsd-current@FreeBSD.ORG Tue Aug 6 10:42:00 2013 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 38172BA5; Tue, 6 Aug 2013 10:42:00 +0000 (UTC) (envelope-from jiashiun@gmail.com) Received: from mail-ob0-x230.google.com (mail-ob0-x230.google.com [IPv6:2607:f8b0:4003:c01::230]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id E73C02647; Tue, 6 Aug 2013 10:41:59 +0000 (UTC) Received: by mail-ob0-f176.google.com with SMTP id uz19so99128obc.35 for ; Tue, 06 Aug 2013 03:41:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=Z2f65XjncTiLsTfjiR6laMOKPkFNMWYWAHZi5F29vfs=; b=yDHk0wZAXgl5QpiDQLwPrp/zf0L9+qQiorK9uxmPGl5Bvl708uSv5Wh/BYTYQ/xakw jyd82ahQvEGQDNvRceJ5Kar13k979UEzGGFNRQkA2Psj8qHD8pHtJ52UiszPx0jyAkDB K+kdTWlonUTIC2Qx9JlY508eXuIv1gvLbUrYjBcIqNsbk74Ywf5mQAloipj9jxBnZw2M a0R5pU03kI+gZeC4yxyWh+z7uzntcl5Zm7T/joL8txHxwND7Pufl8Oxs0oQD8qam54Yr HVdrBY8q2ubMm7yz+fu1fKlRvw7iDsFmyIFcnIcRRGGYuoBTRtg3KSS1jhaiDJvyo3OL hHkg== X-Received: by 10.60.79.131 with SMTP id j3mr418815oex.96.1375785719259; Tue, 06 Aug 2013 03:41:59 -0700 (PDT) MIME-Version: 1.0 Received: by 10.76.131.111 with HTTP; Tue, 6 Aug 2013 03:41:29 -0700 (PDT) In-Reply-To: References: <51EEAA36.6030206@bitfrost.no> <51EEABA3.7060909@FreeBSD.org> <51EEE15C.6020900@FreeBSD.org> From: Jia-Shiun Li Date: Tue, 6 Aug 2013 18:41:29 +0800 Message-ID: Subject: Re: Panic at USB drive plugging in To: Alexander Motin Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.14 Cc: Hans Petter Selasky , freebsd-current@freebsd.org X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Aug 2013 10:42:00 -0000 2013/7/24 =E4=B8=8B=E5=8D=8810:26 =E6=96=BC "Jia-Shiun Li" =E5=AF=AB=E9=81=93=EF=BC=9A > On Wed, Jul 24, 2013 at 4:02 AM, Alexander Motin wrote: > > cam.k kernel module includes all existing periph drivers in one bundle. > > Loading cam.ko you are probably getting sg driver also, that triggers > > reported issue. You may try to rip out sg with single line hack to > module's > > Makefile. The real fix require looking closer on sg, which I never used= . > > > > Indeed. Test result did confirm that if sg is not included in cam.ko > USB drives will not cause kernel to panic. > > Hi all, turns out, it may be conflicts between assumed and actual sg usage. The sg driver specifically assumes a write-read sequence. If a read comes first it will cause sg to panic at msleep() in sgread. In my case the process is hald-probe-storage tasting new devices. But it can be as simple as "dd if=3D/dev/sgX". I am wondering that, is sg necessary on FreeBSD? Since most applications seem to live happily without it in GENERIC kernel. Maybe we can isolate it from cam.ko to make cam usable as module, and make the standalone sg module depending on cam module before sg got more resistant to misuse? Regards, Jia-Shiun.