From owner-svn-src-all@FreeBSD.ORG Thu Feb 26 19:28:39 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 59A566F9; Thu, 26 Feb 2015 19:28:39 +0000 (UTC) Received: from mail-wg0-x22c.google.com (mail-wg0-x22c.google.com [IPv6:2a00:1450:400c:c00::22c]) (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 DBFAE961; Thu, 26 Feb 2015 19:28:38 +0000 (UTC) Received: by wghl18 with SMTP id l18so14047000wgh.7; Thu, 26 Feb 2015 11:28:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=4RYtWCM/8cfoHU9NVgl0Cvi2gnQVB+NyS45srKMm4ro=; b=Q9efJj4EQw7fkzas4vjVhXculVbSRTepUhoUgEbnXhijQ4m0WnC+/GCG1E7114p1Ib Hk9OUTfPO4hH3LNskbF+3RTclO3BIt2wUAEHZqyp+fdva1+HvGE7oBv7DbLqCLRMV+XO O4v/s7IMLQiNgICb7AE+1BqTvPRaL3b5KpblFviqInTv242zEixQlZyLGIVBzdstkCsZ 4MNiTNB8dbly4oKmaUHCc9NtCcNlO03W+5J3w8kHehO5G+jaRDRwUPZTjW8tUQHvYvKI JOpybHhR4XsWEKHA4GOAxh6AHhbp66I5jxDAaL+rkMwsOXMPDD/C5++aeg39o3dTibGx UuFw== X-Received: by 10.180.149.206 with SMTP id uc14mr53203520wib.57.1424978917284; Thu, 26 Feb 2015 11:28:37 -0800 (PST) Received: from dft-labs.eu (n1x0n-1-pt.tunnel.tserv5.lon1.ipv6.he.net. [2001:470:1f08:1f7::2]) by mx.google.com with ESMTPSA id uo6sm2691921wjc.49.2015.02.26.11.28.35 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 26 Feb 2015 11:28:36 -0800 (PST) Date: Thu, 26 Feb 2015 20:28:33 +0100 From: Mateusz Guzik To: John Baldwin Subject: Re: svn commit: r278320 - in head: contrib/mdocml lib lib/libdevctl share/mk sys/dev/acpica sys/dev/pci sys/kern sys/sys usr.sbin usr.sbin/devctl Message-ID: <20150226192833.GB3799@dft-labs.eu> References: <201502061609.t16G92rn091851@svn.freebsd.org> <20150225234006.GB30998@dft-labs.eu> <6369280.lTKc42i0bJ@ralph.baldwin.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <6369280.lTKc42i0bJ@ralph.baldwin.cx> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Feb 2015 19:28:39 -0000 On Thu, Feb 26, 2015 at 07:46:38AM -0500, John Baldwin wrote: > On Thursday, February 26, 2015 12:40:06 AM Mateusz Guzik wrote: > > On Fri, Feb 06, 2015 at 04:09:02PM +0000, John Baldwin wrote: > > > Author: jhb > > > Date: Fri Feb 6 16:09:01 2015 > > > New Revision: 278320 > > > URL: https://svnweb.freebsd.org/changeset/base/278320 > > > > > > Log: > > > Add a new device control utility for new-bus devices called devctl. > > > This > > > allows the user to request administrative changes to individual devices > > > > [..] > > > > > +static int > > > +devctl2_ioctl(struct cdev *cdev, u_long cmd, caddr_t data, int fflag, > > > + struct thread *td) > > > +{ > > > + struct devreq *req; > > > + device_t dev; > > > + int error, old; > > > + > > > + /* Locate the device to control. */ > > > + mtx_lock(&Giant); > > > + req = (struct devreq *)data; > > > > [..] > > > > > + switch (cmd) { > > > > [..] > > > > > + case DEV_SET_DRIVER: { > > > + devclass_t dc; > > > + char driver[128]; > > > + > > > + error = copyinstr(req->dr_data, driver, sizeof(driver), NULL); > > > > [..] > > > > > + if (!driver_exists(dev->parent, driver)) { > > > + error = ENOENT; > > > + break; > > > + } > > > > [..] > > > > > + } > > > + mtx_unlock(&Giant); > > > + return (error); > > > +} > > > > I only skimmed thourgh this, will not a page fault drop + reacquire Giant > > lock? > > > > iow, would not it be better to copy prior to taking the lock? > > It won't make a difference. All the logic is done after the copy, so it is > still atomic. > Are devices guaranteed to be persistent? find_device does ref them in any way, so i would assume that the dev you found is only stable as long as Giant lock is held. -- Mateusz Guzik