Commit Graph

1581 Commits

Author SHA1 Message Date
mlelstv 965fbc37fb Don't try to discover wedges when the unit isn't online. 2024-02-24 22:06:49 +00:00
andvar 100a3398b8 fix spelling mistakes, mainly in comments and log messages. 2024-02-09 22:08:30 +00:00
gutteridge 6110164f14 if_dse.c: s/addredses/addresses/ in comment 2024-01-01 22:29:48 +00:00
andvar 2e8b4c7fee s/informtion/information/ in comments. 2023-12-28 19:58:11 +00:00
skrll 5caf51cf3a Remove unnecssary #include 2023-12-20 18:09:18 +00:00
andvar 7e8680faac s/multiplcation/multiplication/ in comment. 2023-12-07 07:04:13 +00:00
nat 04fbd3aa47 Fix condition for ending the pacet read loop.
len is unsigned 16 bit so testing for less than zero is not valid.
2022-12-22 23:06:11 +00:00
nat 6e905c95ef Remove unused commented out code.
Remove unintentional stray debug printfs.
Fix DSE_DEBUG build.
2022-12-22 22:39:20 +00:00
nat 111c077e20 Driver for DaynaPORT SCSI/Link (dse.4).
Written by Hiroshi Noguchi, of which an updated version was posted to
port-mac68k in 2001.

Attachments were added to kernel configs for platforms that already had
the Cabletron (se.4) driver added, although other platorms may benefit.

Reviewed on tech-net by Izumi Tsutsui.
2022-12-22 11:05:54 +00:00
jmcneill e3ffc84a53 Add PQUIRK_ONLYBIG for Oracle OCI BlockVolumes.
Oracle cloud BlockVolumes do not appear to support SCSI READ6 or WRITE6
commands, so set PQUIRK_ONLYBIG to avoid it here.
2022-10-15 18:42:49 +00:00
skrll 6450531d63 Make this build again. Sorry about that. 2022-08-29 07:32:46 +00:00
mlelstv ddea52491e Don't fetch data beyond end of inquiry buffer, which, here, is not
NUL-terminated.

Reduce target buffer to needed size (product name + NUL terminator).
2022-08-28 10:26:37 +00:00
skrll 4b4eca3288 se(4): don't set if_watchdog as it's not used.
if_timer is never set in this driver and so if_watchdog will never be
called.
2022-08-28 09:48:12 +00:00
skrll 70867f5283 Trailing whitespace 2022-07-07 06:11:08 +00:00
andvar 4b8fdc3b57 s/Ramdom/Random/ in comments. 2022-06-26 21:00:28 +00:00
pgoyette 9dda5c7f82 Split some common stuff into scsi_subr module. This enables loading
of the iscsi module whether or not there are any scsi things built
into the kernel.

Addresses the iscsi portion of kern/56772
2022-04-14 16:50:26 +00:00
riastradh ef3476fb57 sys: Use membar_release/acquire around reference drop.
This just goes through my recent reference count membar audit and
changes membar_exit to membar_release and membar_enter to
membar_acquire -- this should make everything cheaper on most CPUs
without hurting correctness, because membar_acquire is generally
cheaper than membar_enter.
2022-04-09 23:38:31 +00:00
riastradh ebc8106f69 sd(4): Use d_cfdriver/devtounit to avoid open/detach races. 2022-03-28 12:39:46 +00:00
riastradh e68bc10fdb scsi(9): Handle bogus number of LUNs in SCSI_REPORT_LUNS.
Reported-by: syzbot+76ef9084533d4bccec66@syzkaller.appspotmail.com
2022-03-12 16:57:15 +00:00
riastradh 122a3e8a60 sys: Membar audit around reference count releases.
If two threads are using an object that is freed when the reference
count goes to zero, we need to ensure that all memory operations
related to the object happen before freeing the object.

Using an atomic_dec_uint_nv(&refcnt) == 0 ensures that only one
thread takes responsibility for freeing, but it's not enough to
ensure that the other thread's memory operations happen before the
freeing.

Consider:

	  Thread A			  Thread B
	obj->foo = 42;			obj->baz = 73;
	mumble(&obj->bar);		grumble(&obj->quux);
	/* membar_exit(); */		/* membar_exit(); */
	atomic_dec -- not last		atomic_dec -- last
					/* membar_enter(); */
					KASSERT(invariant(obj->foo,
					    obj->bar));
					free_stuff(obj);

The memory barriers ensure that

	obj->foo = 42;
	mumble(&obj->bar);

in thread A happens before

	KASSERT(invariant(obj->foo, obj->bar));
	free_stuff(obj);

in thread B.  Without them, this ordering is not guaranteed.

So in general it is necessary to do

	membar_exit();
	if (atomic_dec_uint_nv(&obj->refcnt) != 0)
		return;
	membar_enter();

to release a reference, for the `last one out hit the lights' style
of reference counting.  (This is in contrast to the style where one
thread blocks new references and then waits under a lock for existing
ones to drain with a condvar -- no membar needed thanks to mutex(9).)

I searched for atomic_dec to find all these.  Obviously we ought to
have a better abstraction for this because there's so much copypasta.
This is a stop-gap measure to fix actual bugs until we have that.  It
would be nice if an abstraction could gracefully handle the different
styles of reference counting in use -- some years ago I drafted an
API for this, but making it cover everything got a little out of hand
(particularly with struct vnode::v_usecount) and I ended up setting
it aside to work on psref/localcount instead for better scalability.

I got bored of adding #ifdef __HAVE_ATOMIC_AS_MEMBAR everywhere, so I
only put it on things that look performance-critical on 5sec review.
We should really adopt membar_enter_preatomic/membar_exit_postatomic
or something (except they are applicable only to atomic r/m/w, not to
atomic_load/store_*, making the naming annoying) and get rid of all
the ifdefs.
2022-03-12 15:32:30 +00:00
andvar 1daa1a7b85 fix various typos in comments, mainly immediatly/immediately/,
as well shared and recently fixed typos in OpenBSD code by Jonathan Grey.
2022-02-23 21:54:40 +00:00
hannken 2c24201950 Initialize "replun" -- found with KMSAN. 2022-02-05 17:32:59 +00:00
martin 3c0daa59b0 In some cases the gcc optimizer is not smart enough to figure out why
the luns and nluns variables are never actually used when they are not
initialized - so initialize them always.
2022-01-29 11:20:30 +00:00
christos 501a9727b6 Factor out the lun detection code to simplify control flow. 2022-01-28 18:23:28 +00:00
jakllsch 6fc380f232 shut up GCC about possibly-uninit; some KNF 2022-01-28 14:02:45 +00:00
jakllsch 7e64fd0859 use powerof2() in sd_validate_blksize() 2022-01-27 18:44:49 +00:00
jakllsch e655ab4194 Try REPORT LUNS command to enumerate logical units. 2022-01-27 18:37:02 +00:00
msaitoh 988ab2c9fa s/sytem/system/ 2022-01-01 10:32:28 +00:00
andvar 3746949308 fix few typos in comments, mainly in word "parameter". 2021-12-31 20:22:48 +00:00
riastradh 30d406507b scsi(4): Take kernel lock around entry into autoconf.
This code paths is entered by kthreads marked MP-safe, not just from
autoconf.

I'm not sure this is sufficient -- it's not clear to me whether
anything prevents concurrently scanning the same target.  Someone with
a better understanding of scsi(4) locking will have to audit this.

(For example, maybe it is guaranteed only to happen only either (a)
in autoconf, or (b) in a thread that doesn't start until autoconf is
done.  But I don't know -- and if it is this, it should be asserted
so we can verify it.)
2021-12-21 22:53:21 +00:00
msaitoh 6ecef65d01 availabe -> available in comment. 2021-12-05 02:21:08 +00:00
msaitoh a396010d93 s/desciptor/descriptor/ in comment. 2021-11-10 16:17:34 +00:00
andvar de4fa9d769 fix various typos, mainly in comments. 2021-10-12 08:36:28 +00:00
rin 94e57d87a7 PR kern/56403
Fix kernel freeze for wdc(4) variants with ATAC_CAP_NOIRQ:

(1) Change ata_xfer_ops:c_poll from void to int function. When it returns
    ATAPOLL_AGAIN, let ata_xfer_start() iterate itself again.

(2) Let wdc_ata_bio_poll() return ATAPOLL_AGAIN until ATA_ITSDONE is
    achieved.

A similar change has been made for mvsata(4) (see mvsata_bio_poll()),
and no functional changes for other devices.

This is how the drivers worked before jdolecek-ncq branch was merged.

Note that this changes are less likely to cause infinite recursion:

(1) wdc_ata_bio_intr() called from wdc_ata_bio_poll() asserts ATA_ITSDONE
    in its error handling paths via wdc_ata_bio_done().

(2) Return value from c_start (= wdc_ata_bio_start()) is checked in
    ata_xfer_start().

Therefore, errors encountered in ata_xfer_ops:c_poll and c_start routines
terminate the recursion for wdc(4). The situation is similar for mvsata(4).

Still, there is a possibility where ata_xfer_start() takes long time to
finish a normal operation. This can result in a delayed response for lower
priority interrupts. But, I've never observed such a situation, even when
heavy thrashing takes place for swap partition in wd(4).

"Go ahead" by jdolecek@.
2021-10-05 08:01:05 +00:00
thorpej ae9dd4a008 Use seltrue_filtops rather than rolling our own with filt_seltrue. 2021-09-26 14:57:19 +00:00
thorpej 12ae65d98c Change the kqueue filterops::f_isfd field to filterops::f_flags, and
define a flag FILTEROP_ISFD that has the meaning of the prior f_isfd.
Field and flag name aligned with OpenBSD.

This does not constitute a functional or ABI change, as the field location
and size, and the value placed in that field, are the same as the previous
code, but we're bumping __NetBSD_Version__ so 3rd-party module source code
can adapt, as needed.

NetBSD 9.99.89
2021-09-26 01:16:07 +00:00
andvar a136e22ab6 fix various typos in comments, messages and documentation. 2021-09-19 10:34:06 +00:00
riastradh 35947fb16c sys/dev: Memset zero before copyout.
Just in case of uninitialized padding which would lead to kernel
stack disclosure.  If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.

I think the iwi(4), mcd(4), and ses(4) changes actually plug leaks;
the raidframe(4) change probably doesn't (but doesn't hurt).
2021-09-09 23:26:36 +00:00
andvar c69f42d323 fix mainly same typos as in my previous commit but outside sys/dev/dm. 2021-08-21 23:00:30 +00:00
thorpej c7fb772b85 Merge thorpej-cfargs2. 2021-08-07 16:18:40 +00:00
riastradh 076e35792d if_attach and if_initialize cannot fail, don't test return value
These were originally made failable back in 2017 when if_initialize
allocated a softint in every interface for link state changes, so
that it could fail gracefully instead of panicking:

https://mail-index.NetBSD.org/source-changes/2017/10/23/msg089053.html

However, this spawned many seldom- or never-tested error branches,
which are risky to have around.  And that softint in every interface
has since been replaced by a single global workqueue, because link
state changes require thread context but not low latency or high
throughput:

https://mail-index.NetBSD.org/source-changes/2020/02/06/msg113759.html

So there is no longer any reason for if_initialize to fail.  (The
subroutine if_stats_init can't fail because percpu_alloc can't fail
either.)

There is a snag: the softint_establish in if_percpuq_create could
fail, potentially leading to bad consequences later on trying to use
the softint.  This change doesn't introduce any new bugs because of
the snag -- if_percpuq_attach was already broken.  However, the snag
can be better addressed without spawning error branches, either by
using a single softint or making softints less scarce.

(Separate commit will change the signatures of if_attach and
if_initialize to return void, scheduled to ride whatever is the next
convenient kernel bump.)

Patch and testing on amd64 and evbmips64-eb by maya@; commit message
soliloquy, and compile-testing on evbppc/i386/earmv7hf, by me.
2021-06-16 00:21:17 +00:00
mlelstv 5135cb9641 Restore EOM handling. 2021-06-13 10:07:56 +00:00
pgoyette 202be4ee97 As with usbverbose and pciverbose, these modules are not safe to be
auto-unloaded.  Disable for now.

All of these need to be updated with an appropriate refcount mechanism
to ensure that the code and/or tables aren't unloaded while they are
being used.
2021-06-05 22:21:15 +00:00
dholland 4bdf3741c4 typo in comment 2021-05-30 06:46:46 +00:00
thorpej 2685996b0e Merge thorpej-cfargs branch:
Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
  actually needed.
- Don't be explicit about what interface attribute is attaching if
  the device only has one.  (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
  situations, making is visibly easier to see when indirect config is
  in play, and allowing for future change in semantics.  (As of now,
  this is just a wrapper around config_match(), but that is an
  implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance.  This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
2021-04-24 23:36:23 +00:00
reinoud 519a7d1514 Limit buffer size for device capabilities requests as a work-around for PR
kern/56109.
2021-04-16 12:58:54 +00:00
christos 45516a99e8 PR/55986: Ryo Onodera: DK_BUSY must have mask as second argument. Make cd.c
consistent by also using __BIT()
2021-02-10 16:30:01 +00:00
thorpej 03d3394d5e Use sel{record,remove}_knote(). 2020-12-18 01:54:22 +00:00
mlelstv 3216cb9734 Avoid buffer overflow when copying from bounce buffer.
Fixes PR 54810

Don't use uninitialized pointer in split bounce buffer case and
free a partially allocated bounce buffer on error.
2020-10-26 11:39:48 +00:00
msaitoh 8d86b96727 s/settng/setting/ 2020-09-29 03:04:03 +00:00