Commit Graph

342 Commits

Author SHA1 Message Date
jakllsch 83286ae20c Fix fwdma_free() for when bus_dmamap_unload() clobbers the dmamap.
Prevents KASSERTs on detaches of sbp(4) and fwohci(4) on amd64.

We should pass the dmamem segs around seperately, not in loaded dmamap...
2018-12-13 16:38:26 +00:00
maxv 5c98710094 Remove the 't' argument from m_tag_find(). 2018-11-15 10:23:55 +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
sevan 82043fb060 Listed UniNorth device is in fact the UniNorth 2 interface, rename.
https://pci-ids.ucw.cz/read/PC/106b/0031
2018-03-31 14:50:45 +00:00
maxv b76f52ce46 memory leak, found by Mootja; it seems that we should check the return
value of 'fw_bindadd' in several other places, but whatever
2017-06-25 12:39:27 +00:00
riastradh fa99ca920a Let's try initializing the pointers *before* dereferencing them!
Oops.
2016-11-21 01:19:35 +00:00
riastradh ed4a54337c KASSERT(mutex_owner(...)) ---> KASSERT(mutex_owned(...))
If this is not correct, then there's something bogus in this code
anyway, so better to fail early.

Final part of PR kern/47114.
2016-11-20 22:56:13 +00:00
riastradh 1ebf7dd190 Kill some more tsleep.
And no, surrounding tsleep by mutex_exit/mutex_enter does not fix
problems even if the LOCKDEBUG panic symptom goes away...
2016-11-20 22:47:39 +00:00
riastradh da248a6bc3 Defer initialization of isodma channels until we know how many.
Should fix a bug I introduced four years ago in:
https://mail-index.netbsd.org/source-changes/2012/08/04/msg036211.html
2016-11-20 22:36:45 +00:00
ozaki-r d938d837b3 Introduce m_set_rcvif and m_reset_rcvif
The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.
2016-06-10 13:27:10 +00:00
joerg c1bb8c29b0 No reason not to make the string const. 2014-11-21 23:37:25 +00:00
snj f0a7346d21 src is too big these days to tolerate superfluous apostrophes. It's
"its", people!
2014-10-18 08:33:23 +00:00
christos 32693e8fdf ran sed too agressively. 2014-09-21 18:03:47 +00:00
christos 4afc391a9b fix cut-n-paste, use arrays instead of separate variables to avoid code
duplication.
2014-09-21 17:10:00 +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
dholland 8c70ef39af Add d_discard to all struct bdevsw instances I could find.
I've set them all to nodiscard. Some of them (wd, dk, vnd, ld,
raidframe, maybe cgd) should be implemented for real.
2014-07-25 08:02:18 +00:00
htodd e4ef43c25c Fix build. 2014-03-28 04:09:19 +00:00
christos e85af085ed Deal with snprintf more gracefully. 2014-03-28 02:16:47 +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
pooka 4f6fb3bf35 Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.
2014-02-25 18:30:08 +00:00
christos 5db9fd6992 add missing ifdefs 2013-10-16 17:40:55 +00:00
christos 11beb626a3 Pass the device name in, so we can debug what deferred drivers did not work. 2013-10-12 16:49:00 +00:00
martin fc72d19c3b Remove unused variables 2013-09-15 13:52:23 +00:00
martin 444987700c Make it compilable with gcc 4.8.1 2013-09-12 20:16:51 +00:00
kiyohara d00b1fbba5 Add '\n' to tail of printing string. 2013-04-07 07:42:20 +00:00
riastradh d237c30a6a ...and be sure to config_pending_decr if kthread_create fails.
This error branch looks suspect, though.  Shouldn't we bail at this
point rather than blithely try to proceed?
2012-08-05 02:47:52 +00:00
riastradh 17be18e233 Restore config pending stuff, adjusted to avoid the race.
Leave a note about what this code probably should look like for
anyone who comes rummaging around with the intent to really fix it.
I would do that myself if I had time and resources to test this at
the moment, and more comfort with our firewire stack, but I don't.
2012-08-05 02:36:16 +00:00
riastradh 934b1cc688 Fix error branches and config pending races in firewire init.
This way, if anything fails, it just fails; you don't panic.  This can
happen if suspending and resuming of firewire is broken (e.g., as I
encountered in PR kern/44581).
2012-08-04 03:55:43 +00:00
dsl e05eb71de5 Remove everything to do with 'struct malloc_type' and the malloc link_set.
To make code in 'external' (etc) still compile, MALLOC_DECLARE() still
  has to generate something of type 'struct malloc_type *', with
  normal optimisation gcc generates a compile-time 0.
MALLOC_DEFINE() and friends have no effect.
Fix one or two places where the code would no longer compile.
2012-04-29 20:27:31 +00:00
dsl fc04895e7b Change to consistently use M_FW for all malloc/free.
It probably doesn't matter any more, but the code doesn't appear to
have matched its mallocs and frees - so the stats would have been awol.
2012-04-29 18:31:40 +00:00
uebayasi c8c01f2329 Put back #include "ioconf.h" per popular demand. 2011-07-31 13:51:53 +00:00
uebayasi 3f383b9dd4 Declare cfdrivers using extern rather than including ioconf.h. 2011-05-25 16:33:37 +00:00
rmind 177a8696c7 Inclusion for malloc decls (missed in previous commit). 2011-04-24 18:52:26 +00:00
uebayasi dff67e454b Include dependencies directly. 2010-11-14 15:47:20 +00:00
cegger 31b69ed482 do not assume all fw devices speak sbp.
teach the fw attach code to deal with different fw device classes.
this allows other fw drivers than sbp to attach
2010-09-07 07:26:54 +00:00
cegger f8af7a09a8 convert tsleep to kpause 2010-09-07 07:19:45 +00:00
cegger 06b4e82a5b fix grammar in error message 2010-08-29 21:15:26 +00:00
cegger 6bb3ec6d99 Confilict -> Conflict 2010-08-29 21:14:16 +00:00
cegger 0fd1c01632 don't call tsleep() with any mutexes hold 2010-08-26 12:48:19 +00:00
cegger e6026ef12c fix crash when detaching/re-attaching a cable where three firewire devices are on the bus. 2010-08-26 08:56:15 +00:00
cegger 0d3d36a951 - print expected crc when it does not match
- add and print secondary text leaf. This prints the model name of my webcam.
- add csr keys that are printed as 'unknown' otherwise
2010-08-26 07:36:53 +00:00
cegger d546ccf4b9 do not hold mutexes when calling tsleep(9).
Fixes LOCKDEBUG panics
2010-08-16 06:05:07 +00:00
jym f3fb0a5620 Fix some code paths where pointers are dereferenced after checking that
they are NULL (oops?)

XXX pull-ups for NetBSD-4 and NetBSD-5.
2010-08-14 18:28:59 +00:00
cegger 0bf9ca9c59 Fix sbp attach/detach.
When plugging a firewire webcam, sbp attaches.
sbpattach() calls sbp_alloc_target().
In sbp_alloc_target, crom_search_key() fails and sbp_alloc_target() returns NULL.
Move mutex and list initializations up in sbpattach() and in sbp_alloc_target()
so that destroyal of them through sbpdetach() does not cause
LOCKDEBUG panics when unplugging the firewire webcam.
2010-08-14 10:39:33 +00:00
christos 32e80c5d9d Revert all previous kmem_ commits. This needs to be done in a different way
because we cannot call kmem_ from an interrupt context. I opened PR/43341 for
it.
2010-05-23 18:56:58 +00:00
christos f651b8a7c3 Don't allocate sid scratch memory from an interrupt context:
fwohci0: BUS reset
fwohci0: node_id=0xc800ffc0, gen=1, CYCLEMASTER mode
panic: kernel diagnostic assertion "!cpu_intr_p()" failed: file "../../../../ker
n/subr_kmem.c", line 195
fatal breakpoint trap in supervisor mode
trap type 1 code 0 rip ffffffff8022db1d cs 8 rflags 246 cr2  0 cpl 6 rsp fffffff
f80fafb68
breakpoint() at netbsd:breakpoint+0x5
panic() at netbsd:panic+0x2ba
kern_assert() at netbsd:kern_assert+0x2d
kmem_alloc() at netbsd:kmem_alloc+0x18a
fwohci_intr() at netbsd:fwohci_intr+0xbe2
...

I will send-pr for the next one... Looks like someone did not use DIAGNOSTIC
when made the changes.
2010-05-23 02:25:50 +00:00
christos e9c888b9ca don't allocate rom scratch memory from an interrupt context:
fwohci0: BUS reset
panic: kernel diagnostic assertion "!cpu_intr_p()" failed: file "../../../../ker
n/subr_kmem.c", line 195
fatal breakpoint trap in supervisor mode
trap type 1 code 0 rip ffffffff8022db1d cs 8 rflags 246 cr2  0 cpl 6 rsp fffffff
f80fafb08
breakpoint() at netbsd:breakpoint+0x5
panic() at netbsd:panic+0x2ba
kern_assert() at netbsd:kern_assert+0x2d
kmem_alloc() at netbsd:kmem_alloc+0x18a
kmem_zalloc() at netbsd:kmem_zalloc+0xf
fw_busreset() at netbsd:fw_busreset+0x23b
fwohci_intr() at netbsd:fwohci_intr+0xa56
...
2010-05-23 02:24:40 +00:00
kiyohara 5c2c106932 Add mutex.h. 2010-05-15 10:42:51 +00:00
kiyohara 931a85be79 May be easy to understand 'pay_len > 0' more than 'paylaod != NULL'. 2010-05-14 12:25:19 +00:00
kiyohara 0f5342ae85 Use kmem(9) instead of malloc(9). 2010-05-14 12:10:07 +00:00