Commit Graph

166 Commits

Author SHA1 Message Date
chs d47bcd296c in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
2019-11-10 21:16:21 +00:00
riastradh d1579b2d70 Rename min/max -> uimin/uimax for better honesty.
These functions are defined on unsigned int.  The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER!  Some subsystems have

	#define min(a, b)	((a) < (b) ? (a) : (b))
	#define max(a, b)	((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX.  Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate.  But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all.  (Who knows, maybe in some cases integer
truncation is actually intended!)
2018-09-03 16:29:22 +00:00
riastradh 792031649a Add some #includes to make a few more header files compile. 2017-10-28 06:27:32 +00:00
riastradh 82b8caba92 Kill some more extern struct cfdriver declarations.
Down with externs in .c!
2017-10-28 04:53:54 +00:00
mlelstv 5b68a5ee6d While ld(4) is MP safe, many backends are not.
Add a flag for backends that are MP safe. Take KERNEL_LOCK when calling
into a backend that doesn't have the flag set. Do the same for the
discard routine.

Fixes PR 52462.
2017-08-09 16:44:39 +00:00
mlelstv fd946ab215 Don't wait for allocation in polling mode. 2017-08-09 16:09:16 +00:00
jdolecek afe4d516fc refactor the ld(4) DIOCCACHESYNC hook into general ioctl hook, so that attachments
would be able to implement arbitrary other ioctls
2017-02-27 21:32:33 +00:00
jdolecek e90b5bdddb modify ldattach() to have default strategy as a parameter 2016-09-16 15:20:50 +00:00
dholland 1fbab01a93 More on PR 41200: headers that declare ioctls should include sys/ioccom.h.
This covers (I think) all the MI headers outside of external/ (and dist/).
2015-09-06 06:00:59 +00:00
msaitoh 33a7e10081 Fix device_t/softc split bug. 2015-08-16 19:22:33 +00:00
msaitoh 706bba66ba Fix a buffer pointer check in iop_msg_unmap(). The number of im_xfer
is IOP_MAX_MSG_XFERS and it's three. iop_systab_set() makes three ximit
buffers. In this case, iop_msg_unmap() overrruns by "if((++ix)->ix_size == 0)".
Check overrun first.

 This change fixes a bug that iop(4) panics while attaching iopsp(4).
2015-08-16 19:21:33 +00:00
riastradh 233f556c2e Convert sys/dev to use <sys/rndsource.h>. 2015-04-13 16:33:23 +00:00
dholland f9228f4225 Add d_discard to all struct cdevsw instances I could find.
All have been set to "nodiscard"; some should get a real implementation.
2014-07-25 08:10:31 +00:00
christos 4591c8e2e5 make this compile again.
XXX: 32 bit pointer issues.
2014-03-20 20:40:42 +00:00
dholland a68f9396b6 Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.
2014-03-16 05:20:22 +00:00
christos cafe8b9a3c remove unused variables and __USE a debugging variable 2013-10-17 21:16:12 +00:00
joerg fc6d69fab6 #if 0 iop_status, but keep it for documentation purposes. 2013-09-14 13:08:31 +00:00
chs cbab9cadce split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
2012-10-27 17:17:22 +00:00
tls 7b0b7dedd9 Entropy-pool implementation move and cleanup.
1) Move core entropy-pool code and source/sink/sample management code
   to sys/kern from sys/dev.

2) Remove use of NRND as test for presence of entropy-pool code throughout
   source tree.

3) Remove use of RND_ENABLED in device drivers as microoptimization to
   avoid expensive operations on disabled entropy sources; make the
   rnd_add calls do this directly so all callers benefit.

4) Fix bug in recent rnd_add_data()/rnd_add_uint32() changes that might
   have lead to slight entropy overestimation for some sources.

5) Add new source types for environmental sensors, power sensors, VM
   system events, and skew between clocks, with a sample implementation
   for each.

ok releng to go in before the branch due to the difficulty of later
pullup (widespread #ifdef removal and moved files).  Tested with release
builds on amd64 and evbarm and live testing on amd64.
2012-02-02 19:42:57 +00:00
rmind 1293cee4bd Replace some wakeup_one(9) uses with mutex(9) or plain wakeup(9). 2011-08-07 13:39:23 +00:00
uebayasi 8184d5dc03 Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants.  These are provided by sys/param.h now.
2010-11-13 13:51:57 +00:00
bouyer 8f7318d794 Fix confusion about PRE/POST in previous; and another place that has the
same issue. Also add a BUS_DMASYNC_POSTWRITE to the POLL operation.
Problem pointed out by tsutsui@.
Still not perfect (a BUS_DMASYNC_PREREAD would be needed after the
testing the condition in the POLL() macro), but closer.
2010-02-21 18:50:10 +00:00
bouyer 80f97b6e05 Fix bus_dmamap_sync(): it should be a BUS_DMASYNC_POSTWRITE after
writing to DMA memory.
Found by code inspection.
2010-02-21 14:16:47 +00:00
asau bf551971e8 Don't mix BUS_DMASYNC_PREREAD and BUS_DMASYNC_POSTWRITE.
Suggested by <bouyer>, fixes PR kern/42662
2010-02-19 12:36:15 +00:00
rmind 40cf6f3659 Remove uarea swap-out functionality:
- Addresses the issue described in PR/38828.
- Some simplification in threading and sleepq subsystems.
- Eliminates pmap_collect() and, as a side note, allows pmap optimisations.
- Eliminates XS_CTL_DATA_ONSTACK in scsipi code.
- Avoids few scans on LWP list and thus potentially long holds of proc_lock.
- Cuts ~1.5k lines of code.  Reduces amd64 kernel size by ~4k.
- Removes __SWAP_BROKEN cases.

Tested on x86, mips, acorn32 (thanks <mpumford>) and partly tested on
acorn26 (thanks to <bjh21>).

Discussed on <tech-kern>, reviewed by <ad>.
2009-10-21 21:11:57 +00:00
cegger 529e91fca1 struct device * -> device_t, no functional changes intended. 2009-05-12 14:16:35 +00:00
cegger 32c4940900 struct cfdata * -> cfdata_t, no functional changes intended. 2009-05-12 12:10:29 +00:00
mhitch 2c6d71a592 More device_t/softc split fallout, this time in iop(4). Fix from
Juan Romero Pardines.  Tested on alpha by me.
2008-12-15 18:35:48 +00:00
mhitch f60765db47 Use the physical address from the bus_dmamap_load() map, not the one from
the bus_dmamem_alloc().  Fixes iop(4) on alpha, and possibly sparc64 as
described in the thread
http://mail-index.netbsd.org/port-sparc64/2008/06/04/msg000413.html.
2008-09-14 18:12:16 +00:00
tron 362b2f2b14 Complete device_t/softc split for the ld(4) attachments. This should
prevent crashes while attaching a drive.

Patch supplied by Juan RP in PR kern/39468.
2008-09-09 12:45:39 +00:00
gmcgarry 0de5da9678 Replace most gcc-specific __attribute__ uses with BSD-style sys/cdef.h
preprocessor macros.
2008-09-08 23:36:53 +00:00
simonb 82bb1c2ff8 Add a flags argument to the ld(4) flush handlers, and call these with a
"poll" flag when called from ld_shutdown().

This is the infrastructure part of kern/38655 - in itself it doesn't
fix the panic referenced in that PR.

XXX: At least ld_twa.c and perhaps ld_iop.c and ld_icp.c need to
check for this new poll flag and do something useful.
2008-08-11 06:43:37 +00:00
tsutsui 1f459d82b5 Replace device_lookup() with device_lookup_private() on getting softc
for future device_t/softc spilt.
2008-06-08 12:43:51 +00:00
ad 536e41c542 Fix up bus_dmamap_sync calls. 2008-06-08 11:58:50 +00:00
ad 107b551a56 Include machine/cputypes.h explicitly. 2008-05-11 14:25:48 +00:00
simonb dc15915150 Fix a tyop in a comment. 2008-05-10 14:52:55 +00:00
ad e071d39c84 - Convert hashinit() to use kmem_alloc(). The hash tables can be large
and it's better to not have them in kmem_map.
- Convert a couple of minor items along the way to kmem_alloc().
- Fix some memory leaks.
2008-05-05 17:11:16 +00:00
martin ce099b4099 Remove clause 3 and 4 from TNF licenses 2008-04-28 20:22:51 +00:00
cegger 0e50a9464d use aprint_*_dev and device_xname 2008-04-06 20:25:59 +00:00
dyoung 6127f4ed3f Don't get under the device_t abstraction by measuring the length
of dv_xname, especially not to set the length of a buffer that
(apparently) belongs to the kernel ABI.  Instead, set the buffer
length to 16, which is the current length of dv_xname.
2008-02-11 03:36:25 +00:00
ad 598ab03ad0 Match the docs: MUTEX_DRIVER/SPIN are now only for porting code written
for Solaris.
2007-12-05 07:06:50 +00:00
ad 0e93b3c25e The I2O LAN stuff was never tested and is just more code to maintain -
remove it.
2007-12-01 18:14:48 +00:00
ad b46323f065 I2OVERBOSE/opt_i2o.h were removed 2007-12-01 18:13:17 +00:00
ad 8ef7991906 Noisy printfs. 2007-12-01 18:12:37 +00:00
christos f5673d6a27 defopt I2OVERBOSE 2007-11-16 21:14:26 +00:00
ad a2a3828545 machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h 2007-10-19 11:59:34 +00:00
dyoung c53c02b0c9 Once again, use ether_ioctl() instead of (cmd == SIOCADDMULTI) ?
ether_addmulti() : ether_delmulti().
2007-09-01 07:43:36 +00:00
dyoung f004b71d98 Constify. 2007-08-26 22:36:35 +00:00
ad eb171eaaa7 It's not a good idea for device drivers to modify b_flags, as they don't
need to understand the locking around that field. Instead of setting
B_ERROR, set b_error instead. b_error is 'owned' by whoever completes
the I/O request.
2007-07-29 12:50:17 +00:00
ad 88ab7da936 Merge some of the less invasive changes from the vmlocking branch:
- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
2007-07-09 20:51:58 +00:00