summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_conf.c
Commit message (Collapse)AuthorAgeFilesLines
* Provide yet another KPI for cdev creation, make_dev_s(9).kib2016-01-071-23/+75
| | | | | | | | | | | | | | | | | | | Immediate problem fixed by the new KPI is the long-standing race between device creation and assignments to cdev->si_drv1 and cdev->si_drv2, which allows the window where cdevsw methods might be called with si_drv1,2 fields not yet set. Devices typically checked for NULL and returned spurious errors to usermode, and often left some methods unchecked. The new function interface is designed to be extensible, which should allow to add more features to make_dev_s(9) without inventing yet another name for function to create devices, while maintaining KPI and even KBI backward-compatibility. Reviewed by: hps, jhb Sponsored by: The FreeBSD Foundation MFC after: 3 weeks Differential revision: https://reviews.freebsd.org/D4746
* Fix for out of order device destruction notifications when using thehselasky2015-03-221-2/+18
| | | | | | | | | delist_dev() function. In addition to this change: - add a proper description of this function - add a proper witness assert inside this function - switch a nearby line to use the "cdp" pointer instead of cdev2priv() MFC after: 3 days
* Stop enforcing additional reference on all cdevs, which was introducedkib2015-01-191-5/+28
| | | | | | | | | | | | in r277199. Acquire the neccessary reference in delist_dev_locked() and inform destroy_devl() about it using CDP_UNREF_DTR flag. Fix some style nits, add asserts. Discussed with: hselasky Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week
* Avoid race with "dev_rel()" when using the recently addedhselasky2015-01-141-2/+0
| | | | | | | | | "delist_dev()" function. Make sure the character device structure doesn't go away until the end of the "destroy_dev()" function due to concurrently running cleanup code inside "devfs_populate()". MFC after: 1 week Reported by: dchagin@
* Add a kernel function to delist our kernel character devices, so thathselasky2015-01-141-0/+17
| | | | | | | | the device name can be re-used right away in case we are destroying the character devices in the background. MFC after: 4 days Reported by: dchagin@
* Adjust printf format specifiers for dev_t and ino_t in kernel.gleb2014-12-171-1/+2
| | | | | | ino_t and dev_t are about to become uint64_t. Reviewed by: kib, mckusick
* Remove global device lock acquisition from dev_relthread(), replacing itmav2013-10-221-5/+3
| | | | with atomics on per-device data.
* Reject spaces and double quotation marks in device names. devctl(4)jh2012-12-221-0/+7
| | | | | | | and devd(8) can't handle names with such characters properly. PR: bin/144736, kern/161912 Discussed with: imp, kib, pjd
* Remove unused SI_* flags.ed2012-08-281-3/+0
| | | | | The SI_DEVOPEN, SI_CONSOPEN and SI_CANDELETE flags are not used by any piece of code in the tree.
* Remove D_NEEDGIANT from dead_devsw. biofinish() (and thus dead_strategy)jhb2012-08-161-1/+0
| | | | | | does not need Giant. MFC after: 1 month
* MFprojects/zfsd:mav2012-05-241-3/+4
| | | | Hide warning behind bootverbose. Average user has nothing to do about it.
* Remove unneeded newline. It fits in 80 columns now.ed2012-02-101-2/+1
| | | | Pointed out by: jh
* Merge si_name and __si_namebuf.ed2012-02-101-7/+7
| | | | | The si_name pointer always points to the __si_namebuf member inside the same object. Remove it and rename __si_namebuf to si_name.
* Use TASK_INITIALIZER() for dev_dtr_task rather than a dedicated SYSINIT().jhb2011-12-221-10/+2
|
* Style.kib2011-11-111-2/+1
| | | | MFC after: 1 week
* Guard against the unlikely case of the alias path containing the '%' symbols.kib2011-11-111-1/+1
| | | | | Reported by: arundel MFC after: 1 week
* Fix the devmtx lock leak from make_dev(9) when the old device cloningkib2011-07-301-1/+2
| | | | | | | | failed due to invalid or duplicated path being generated. Reviewed by: jh Approved by: re (kensmith) MFC after: 1 week
* sys/sys/conf.h:gibbs2011-06-141-0/+62
| | | | | | | | | | | | | | | | | | | | sys/kern/kern_conf.c: Add make_dev_physpath_alias(). This interface takes the parent cdev of the alias, an old alias cdev (if any) to replace with the newly created alias, and the physical path string. The alias is visiable as a symlink to the parent, with the same name as the parent, rooted at physpath in devfs. Note: make_dev_physpath_alias() has hard coded knowledge of the Solaris style prefix convention for physical path data, "id1,". In the future, I expect the convention to change to allow "physical path quality" to be reported in the prefix. For example, a physical path based on NewBus topology would be of "lower quality" than a physical path reported by a device enclosure. Sponsored by: Spectra Logic Corporation
* The CDP_ACTIVE flag is cleared at the beginning of destroy_devl(),kib2011-05-181-1/+2
| | | | | | | | | and destroy_devl() drops dev_mtx. The protection against the race with dev_rel(), introduced in r163328, should be extended to cover destroy_devl() calls for the children of the destroyed dev. Reported and tested by: joerg MFC after: 1 week
* Add make_dev_alias_p() function. It is similar to make_dev_alias(),ae2011-05-031-10/+51
| | | | | | | but it may return an error like make_dev_p() does. Reviewed by: kib (previous version) MFC after: 2 weeks
* Fix race in devfs by using LIST_FIRST() instead ofhselasky2010-12-111-2/+2
| | | | | | | | | LIST_FOREACH_SAFE() when freeing the devfs private data entries. Reviewed by: kib MFC after: 3 days Approved by: thompsa (mentor)
* Add missing curly brackets. By chance, the missing brackets didn't alterjh2010-11-071-1/+2
| | | | | | the code behavior. Submitted by: Lucius Windschuh
* Check the device name validity on device registration.jh2010-10-071-27/+87
| | | | | | | | | | | | | | | | A new function prep_devname() sanitizes a device name by removing leading and redundant sequential slashes. The function returns an error for names which already exist or are considered invalid. A new flag MAKEDEV_CHECKNAME for make_dev_p(9) and make_dev_credf(9) indicates that the caller is prepared to handle an error related to the device name. An invalid name triggers a panic if the flag is not specified. Document the MAKEDEV_CHECKNAME flag in the make_dev(9) manual page. Idea from: kib Reviewed by: kib
* Add "show cdev" ddb command.kib2010-08-061-0/+68
| | | | | In collaboration with: pho MFC after: 1 month
* Add new make_dev_p(9) flag MAKEDEV_ETERNAL to inform devfs that createdkib2010-08-061-43/+76
| | | | | | | | | cdev will never be destroyed. Propagate the flag to devfs vnodes as VV_ETERNVALDEV. Use the flags to avoid acquiring devmtx and taking a thread reference on such nodes. In collaboration with: pho MFC after: 1 month
* Remove the unit argument from the recently added make_dev_p().ed2010-06-171-2/+2
| | | | | | | | New code that creates character devices shouldn't use device unit numbers, but only si_drv[12] to hold pointer to per-device data. Make this function more future proof by removing the unit number argument. Discussed with: kib
* Correct the function name in a KASSERT.jh2010-06-161-1/+1
|
* Add another variation of make_dev(9), make_dev_p(9), that is allowedkib2010-06-121-24/+53
| | | | | | | | to fail and can return useful error code. Requested by: jh Reviewed by: imp, jh MFC after: 3 weeks
* When make_dev_credf(MAKEDEV_WAITOK) is called, usekib2010-06-121-4/+4
| | | | | | | | devctl_notify_f(M_WAITOK) for devfs notifications. Suggested by: jh Reviewed by: imp, jh MFC after: 3 weeks
* Add MAKEDEV_NOWAIT flag to make_dev_credf(9), to create a device nodekib2010-05-061-19/+28
| | | | | | | | in a no-sleep context. If resource allocation cannot be done without sleep, make_dev_credf() fails and returns NULL. Reviewed by: jh MFC after: 2 weeks
* Fix several style issues.kib2010-02-271-2/+5
| | | | | | Define make_dev_credv() as static to match declaration. MFC after: 3 days
* Update d_mmap() to accept vm_ooffset_t and vm_memattr_t.rnoland2009-12-291-13/+7
| | | | | | | | | | | | | This replaces d_mmap() with the d_mmap2() implementation and also changes the type of offset to vm_ooffset_t. Purge d_mmap2(). All driver modules will need to be rebuilt since D_VERSION is also bumped. Reviewed by: jhb@ MFC after: Not in this lifetime...
* (S)LIST_HEAD_INITIALIZER takes a (S)LIST_HEAD as an argument.antoine2009-12-281-1/+1
| | | | | | | | | Fix some wrong usages. Note: this does not affect generated binaries as this argument is not used. PR: 137213 Submitted by: Eygene Ryabinkin (initial version) MFC after: 1 month
* Extend the device pager to support different memory attributes on differentjhb2009-08-281-4/+10
| | | | | | | | | | | | | | | pages in an object. - Add a new variant of d_mmap() currently called d_mmap2() which accepts an additional in/out parameter that is the memory attribute to use for the requested page. - A driver either uses d_mmap() or d_mmap2() for all requests but not both. The current implementation uses a flag in the cdevsw (D_MMAP2) to indicate that the driver provides a d_mmap2() handler instead of d_mmap(). This is done to make the change ABI compatible with existing drivers and MFC'able to 7 and 8. Submitted by: alc MFC after: 1 month
* Add an extension to the character device interface that allows characterjhb2009-06-011-2/+27
| | | | | | | | | | | | | | | | | | | | device drivers to use arbitrary VM objects to satisfy individual mmap() requests. - A new d_mmap_single(cdev, &foff, objsize, &object, prot) callback is added to cdevsw. This function is called for each mmap() request. If it returns ENODEV, then the mmap() request will fall back to using the device's device pager object and d_mmap(). Otherwise, the method can return a VM object to satisfy this entire mmap() request via *object. It can also modify the starting offset into this object via *foff. This allows device drivers to use the file offset as a cookie to identify specific VM objects. - vm_mmap_vnode() has been changed to call vm_mmap_cdev() directly when mapping V_CHR vnodes. This avoids duplicating all the cdev mmap handling code and simplifies some of vm_mmap_vnode(). - D_VERSION has been bumped to D_VERSION_02. Older device drivers using D_VERSION_01 are still supported. MFC after: 1 month
* Move the M_WAITOK flag in notify() into an M_NOWAIT one in order to matchattilio2009-05-211-1/+3
| | | | | | | | | | | the behaviour alredy present with the further malloc() call in devctl_notify(). This fixes a bug in the CAM layer where the camisr handler finished to call camperiphfree() (and subsequently destroy_dev() resulting in a new dev notify) while the xpt lock is held. PR: kern/130330 Tested by: Riccardo Torrini <riccardo dot torrini at esaote dot com>
* Remove dead code from devtoname().ed2009-04-151-18/+1
| | | | | | | | In the good old days it was possible to have dev_t's that referred to nonexistent devices. In these cases devtoname() automatically generated names. This is no longer possible, so remove this dead code. Discussed with: kib
* Remove unneeded variable and casting from newdev().ed2009-04-151-5/+3
| | | | | | | Remove the `udev' variable, which has a different type than the original function argument and si_drv0. The `udev' name is also misleading, because it is not the number returned by dev2udev(). Rename this argument to `unit'. It is the same number as returned by dev2unit().
* Don't use si_drv0 directly.ed2009-04-151-2/+2
| | | | | | | We should still access si_drv0 using dev2unit(). Also change the KASSERT() to really print the udev instead of the unit number. I suspect it's still useful to print the unit number, especially for devices that use clone lists, so keep the unit number in the panic string.
* Extract the no_poll() and vop_nopoll() code into the common routinekib2009-03-061-11/+1
| | | | | | | | | poll_no_poll(). Return a poll_no_poll() result from devfs_poll_f() when filedescriptor does not reference the live cdev, instead of ENXIO. Noted and tested by: hps MFC after: 1 week
* Explicitely note that destroy_dev() sleeps.kib2008-11-271-0/+1
| | | | Requested by: ed (some time ago), Jaakko Heinonen <jh saunalahti fi>
* Move uminor() and umajor() to the same place as userspace minor() and major().ed2008-09-271-14/+0
| | | | | | | | | | | | | | | | | | | | | | | The uminor() and umajor() functions have the same use in kernel space as the minor() and major() functions in userspace. If we ever get rid of the minor() function in kernel space, we could decide to just expose minor() and major() to kernel space, making uminor() and umajor() redundant. There are two reasons why we want to have uminor() and umajor() in <sys/types.h>: - Having them close together prevents them from diverting. Even though it's unlikely the definitions will change, it's a good habit to have them at the same place. - They don't really belong in kern_conf.c. kern_conf.c has been liberated from dealing with device major and minor number handling. The device_ids(9) manpage now lists the wrong #include's, because it should only list <sys/types.h> now. I'm leaving it as it is now, because I wonder if we should document them anyway. We're probably better off documenting minor(3) and major(3).
* Replace all calls to minor() with dev2unit().ed2008-09-271-3/+3
| | | | | | | | | | | | | | | After I removed all the unit2minor()/minor2unit() calls from the kernel yesterday, I realised calling minor() everywhere is quite confusing. Character devices now only have the ability to store a unit number, not a minor number. Remove the confusion by using dev2unit() everywhere. This commit could also be considered as a bug fix. A lot of drivers call minor(), while they should actually be calling dev2unit(). In -CURRENT this isn't a problem, but it turns out we never had any problem reports related to that issue in the past. I suspect not many people connect more than 256 pieces of the same hardware. Reviewed by: kib
* Rename the `minor' argument of make_dev(9) to `unit'.ed2008-09-261-9/+9
| | | | | | | | | To prevent any further confusion about device minor and unit numbers, we'd better just refer to device unit numbers. Many people still think the numbers we show inside devfs have any relation to the numbers passed to make_dev(9), which is not the case. Discussed with: kib
* Remove unit2minor() use from kernel code.ed2008-09-261-1/+1
| | | | | | | | | | | | | | | When I changed kern_conf.c three months ago I made device unit numbers equal to (unneeded) device minor numbers. We used to require bitshifting, because there were eight bits in the middle that were reserved for a device major number. Not very long after I turned dev2unit(), minor(), unit2minor() and minor2unit() into macro's. The unit2minor() and minor2unit() macro's were no-ops. We'd better not remove these four macro's from the kernel, because there is a lot of (external) code that may still depend on them. For now it's harmless to remove all invocations of unit2minor() and minor2unit(). Reviewed by: kib
* Integrate the new MPSAFE TTY layer to the FreeBSD operating system.ed2008-08-201-11/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The last half year I've been working on a replacement TTY layer for the FreeBSD kernel. The new TTY layer was designed to improve the following: - Improved driver model: The old TTY layer has a driver model that is not abstract enough to make it friendly to use. A good example is the output path, where the device drivers directly access the output buffers. This means that an in-kernel PPP implementation must always convert network buffers into TTY buffers. If a PPP implementation would be built on top of the new TTY layer (still needs a hooks layer, though), it would allow the PPP implementation to directly hand the data to the TTY driver. - Improved hotplugging: With the old TTY layer, it isn't entirely safe to destroy TTY's from the system. This implementation has a two-step destructing design, where the driver first abandons the TTY. After all threads have left the TTY, the TTY layer calls a routine in the driver, which can be used to free resources (unit numbers, etc). The pts(4) driver also implements this feature, which means posix_openpt() will now return PTY's that are created on the fly. - Improved performance: One of the major improvements is the per-TTY mutex, which is expected to improve scalability when compared to the old Giant locking. Another change is the unbuffered copying to userspace, which is both used on TTY device nodes and PTY masters. Upgrading should be quite straightforward. Unlike previous versions, existing kernel configuration files do not need to be changed, except when they reference device drivers that are listed in UPDATING. Obtained from: //depot/projects/mpsafetty/... Approved by: philip (ex-mentor) Discussed: on the lists, at BSDCan, at the DevSummit Sponsored by: Snow B.V., the Netherlands dcons(4) fixed by: kan
* Make it atomic for the devfs_populate_loop() to see the setting ofkib2008-07-111-1/+2
| | | | | | | | | | | | SI_ALIAS flag and initialization of the si_parent when alias is created. Assert that supplied parent device is not NULL. Both situations could cause NULL dereference in the devfs_populate_loop() when creating a symlink for SI_ALIAS'ed device. Namely, cdp->cdp_c.si_parent may be NULL. Reported by: mav MFC after: 2 weeks
* Struct cdev is always the member of the struct cdev_priv. When devfskib2008-06-161-6/+6
| | | | | | | | | | | needed to promote cdev to cdev_priv, the si_priv pointer was followed. Use member2struct() to calculate address of the wrapping cdev_priv. Rename si_priv to __si_reserved. Tested by: pho Reviewed by: ed MFC after: 2 weeks
* Turn dev2unit(), minor(), unit2minor() and minor2unit() into macro's.ed2008-06-121-35/+0
| | | | | | | | | | | | | Now that we got rid of the minor-to-unit conversion and the constraints on device minor numbers, we can convert the functions that operate on minor and unit numbers to simple macro's. The unit2minor() and minor2unit() macro's are now no-ops. The ZFS code als defined a macro named `minor'. Change the ZFS code to use umajor() and uminor() here, as it is the correct approach to do this. Also add $FreeBSD$ to keep SVN happy. Approved by: philip (mentor), pjd
* Don't enforce unique device minor number policy anymore.ed2008-06-111-4/+9
| | | | | | | | | | | | | | | | | | | | | | | Except for the case where we use the cloner library (clone_create() and friends), there is no reason to enforce a unique device minor number policy. There are various drivers in the source tree that allocate unr pools and such to provide minor numbers, without using them themselves. Because we still need to support unique device minor numbers for the cloner library, introduce a new flag called D_NEEDMINOR. All cdevsw's that are used in combination with the cloner library should be marked with this flag to make the cloning work. This means drivers can now freely use si_drv0 to store their own flags and state, making it effectively the same as si_drv1 and si_drv2. We still keep the minor() and dev2unit() routines around to make drivers happy. The NTFS code also used the minor number in its hash table. We should not do this anymore. If the si_drv0 field would be changed, it would no longer end up in the same list. Approved by: philip (mentor)
OpenPOWER on IntegriCloud