Commit Graph

683 Commits

Author SHA1 Message Date
blymn
ce0d56725b Make sure a channel has drives attached before resetting it otherwise
wdc_reset will panic the kernel due to a null derefrence of ch_drives.
2013-08-07 12:50:17 +00:00
soren
2d96a254f8 TRIM showed up sometime between ATA-7 and ATA-8. 2013-08-06 19:13:13 +00:00
christos
7b845fa9dc phase 1 of disk geometry cleanup:
- centralize the geometry -> plist code so that we don't have
	  n useless copies of it.
2013-05-29 00:47:48 +00:00
jakllsch
b66aa8a3bf Wait for DRDY after the PMP commands and don't wait before.
Should fix the worst part of PR kern/47793.
2013-05-03 20:02:08 +00:00
jakllsch
305bcb916e Also print port multiplier port number when register accesses fail. 2013-04-17 12:22:43 +00:00
bouyer
d672ee0cfa Fix kernel dump on ahci controller, by making sure we won't sleep
while dumping:
- introduce ata_delay() which either use delay() or kpause()
  depending on flags. use it in sata_reset_interface() and
  some ahci functions
- kill ATA_NOSLEEP, it was tested but never set. use ATA_POLL instead.
- reduce delay while polling in ahci, to speed up the dump

Should fix PR kern/41095
2013-04-03 17:15:07 +00:00
jakllsch
4637996056 Add argument to wdccommandext() to allow the entire contents of the
device/head register to be specified.  Needed for upcoming port multipler
support in mvsata(4).
2013-02-03 20:13:27 +00:00
riastradh
bc01998d73 Initialize b_resid before biodone in wdioctlstrategy error branch.
Otherwise we may panic when physio's biodone callback kasserts
something about b_resid, since nothing will have initialized it.
2013-01-09 22:03:49 +00:00
riastradh
6eb4026e2b Name the ATA SECURITY commands. 2013-01-09 17:55:04 +00:00
rkujawa
b53ade0bc2 Introduce WDC_CAPABILITY_NO_AUXCTL flag. For lame controllers that don't
have aux control registers (driver coming soon).
2012-11-19 22:22:56 +00:00
abs
6a65e108a0 Allow setting ATADEBUG_MASK to default value of atadebug_mask 2012-11-01 13:46:52 +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
drochner
5724e77fda Implement experimental support to pass notifications that a file
was deleted from the filesystem to the disk driver, commonly
known as "discard" or "trim".
fs/driver support is in ffs and ata wd for now.
This is what was posted here:
http://mail-index.netbsd.org/tech-kern/2012/02/28/msg012813.html
with minor cleanup, and the global switch replaced by a mount option.
2012-10-19 17:09:06 +00:00
bouyer
45b66ef963 If ch_ndrives is > 0, then ch_drive is not supposed to be NULL. 2012-08-04 21:21:09 +00:00
bouyer
b174797739 Make this compile again after DRIVET rename 2012-08-01 09:38:55 +00:00
bouyer
f815d4c9ca Apply back changes that were reverted on Jul 24 and Jul 26 (general ata/wdc
cleanup and SATA PMP support), now that I'm back to fix the fallouts.
2012-08-01 09:02:03 +00:00
bouyer
9edd4d81c5 Apply back changes that were reverted on Jul 24 and Jul 26 (general ata/wdc
cleanup and SATA PMP support), now that I'm back to fix the fallouts.
2012-07-31 15:50:31 +00:00
jakllsch
db53477265 Remove ata_channel->ata_drives, it's redundant with the pointer in
ata_drive_datas.  Originally part of a commit by bouyer@.
2012-07-29 21:10:50 +00:00
jakllsch
102f7b2016 Revert, with intention of restoring in a less invasive way, the SATA Port
Multiplier code.

ok christos@
2012-07-26 20:49:44 +00:00
jakllsch
5b9a15ee6c Revert dsl@'s changes of Sun, 15 Jul 2012 10:55:35 +0000 and
Sun, 15 Jul 2012 10:56:50 +0000, excepting the kernel version bump.
First step in reverting regressions to ata(4) subsystem during the addition of
port multiplier support.
2012-07-24 14:04:28 +00:00
jakllsch
217ea076e5 It turns out my previous commit here was off by one. 2012-07-22 19:07:33 +00:00
jakllsch
dc6a13a152 FLUSH CACHE EXT is a 48-bit command, issue as such. Both FLUSH CACHE commands
will return the LBA of first failure in the return task file, specifiy that we
want it read, even if we don't look at the value.
2012-07-22 18:42:11 +00:00
jakllsch
4c0d1d5807 ATA-6 and ACS-2 drafts both say the flush cache commands may take longer than
30 seconds to complete.  For now assume 5 minutes will always be enough.
2012-07-22 18:37:31 +00:00
jakllsch
e6706273af Port multiplier registers are 64-bits wide (although the ones we need only
implement 32-bits).  Implement the access routines using 64-bit values and add
32-bit wrappers thereto.
2012-07-22 18:21:17 +00:00
jakllsch
78a12c25c2 The vendor and product IDs are 16-bit, print out as such. 2012-07-22 18:17:30 +00:00
jakllsch
935da2146f Correctly issue port multiplier register access commands as LBA48 now that the
FIS code doesn't get in the way of doing that.
2012-07-22 18:12:01 +00:00
jakllsch
c2b3a5ec40 KASSERT if we attempt to access an invalid port.
Also, small whitespace change for internal consistency.
2012-07-22 18:03:34 +00:00
jakllsch
be34f7e01d SATA uses the head portion of the device register in the command protocol for
port multiplier register access.  Thus, in the LBA48 case, pass the complete
r(hd|dh)_dh byte back and forth to the upper layers.  (This is irrelevant in
the LBA28/CHS code path for what should be obvious reasons.)
2012-07-22 17:57:57 +00:00
jakllsch
ec123dfac9 Stopgap crash prevention when atadebug_mask includes DEBUG_PROBE bit. 2012-07-15 15:49:46 +00:00
dsl
c9fe3ca8c3 Some namespace protection (and add greppablity).
Prefix the DRIVE_ and DRIVET_ constants from atavar.h with ATA_.
Don't use an enum for drive_type - you don't know how big it will be.
Move driver_type to avoid implicit structure padding (esp on arm).
This change is purely lexical and mechanical.

Update to 6.99.9 - this wasn't done when the SATA PMP changes
were made - I'm sure they warranted a bump.
2012-07-15 10:55:27 +00:00
bouyer
03c9df05c6 Add sata Port MultiPlier (PMP) support to the ata bus layer,
as described in
http://mail-index.netbsd.org/tech-kern/2012/06/23/msg013442.html
PMP support in integrated to the atabus layer.
struct ata_channel's ch_drive[] is not dynamically allocated, and ch_ndrive
(renamed to ch_ndrives) closely reflects the size of the ch_drive[] array.
Add helper functions atabus_alloc_drives() and atabus_free_drives()
to manage ch_drive[]/ch_ndrives.
Add wdc_maxdrives to struct wdc_softc so that bus front-end can specify
how much drive they really support (master/slave or single).
ata_reset_drive() callback gains a uint32_t *sigp argument which,
when not NULL, will contain the signature of the device being reset.
While there, some cosmetic changes:
- added a drive_type enum to ata_drive_datas, and stop encoding the
  probed drive type in drive_flags (we were out of drive flags anyway).
- rename DRIVE_ATAPIST to DRIVE_ATAPIDSCW to better reflect what this
  really is
- remove ata_channel->ata_drives, it's redundant with the pointer in
  ata_drive_datas
- factor out the interpretation of SATA signatures in sata_interpet_sig()

propagate these changes to the ATA HBA drivers, and add support for PMP
to ahcisata(4) and siisata(4).

Thanks to:
- Protocase (http://www.protocase.com/) which provided a system
  with lots of controllers, SATA PMP and drive slots
- Conservation Genomics Laboratory, Department of Biology, New Mexico State
  University for hosting the above system
- Brook Milligan, who set up remote access and has been very responsive
  when SATA cable move was needed
2012-07-02 18:15:44 +00:00
bouyer
931da08bf7 In some case, when an error is reported by the disk, the ahci controller
still reports a number of bytes transfered equal to bcount.
This then triggers a KASSERT in physio_biodone:
        if (done == todo)
		KASSERT(bp->b_error == 0);
Detect this case in wd(4) (so that the workaround works for other controllers
too if they have the same issue, or if the issue is with the drive)
and claim we didn't read/write anything.
2012-06-26 09:49:24 +00:00
bouyer
6cafcc75f4 If the PHY reports link up but no communication, wait 5 more
seconds for communications to be established. This seems to be needed for
some configurations.
2012-05-15 19:01:10 +00:00
isaki
5c9d9eaa20 Fix a typo (that I found 5 years ago). Though the definition of
atabusiodetach_args is the same as atabusioscan_args (at the moment).
2012-04-06 02:52:00 +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
jakllsch
e1f88cea88 Rework struct ata_command to support LBA28 and LBA48-protocol commands.
Implement 28- and 48-bit command issuance and parameter read-back in the
various ATA host drivers. Add LBA28-protocol support to ATAIOCCOMMAND ioctl.
2012-01-24 20:04:07 +00:00
jakllsch
abc09c9d3d Instead of assume that 'features' is 0 in wdccommandext(),
pass it as an argument, as is done for wdccommand().
2012-01-09 01:01:48 +00:00
joerg
81780d0204 Replace broken memset with M_ZERO 2011-11-25 13:55:40 +00:00
tls
3afd44cf08 First step of random number subsystem rework described in
<20111022023242.BA26F14A158@mail.netbsd.org>.  This change includes
the following:

	An initial cleanup and minor reorganization of the entropy pool
	code in sys/dev/rnd.c and sys/dev/rndpool.c.  Several bugs are
	fixed.  Some effort is made to accumulate entropy more quickly at
	boot time.

	A generic interface, "rndsink", is added, for stream generators to
	request that they be re-keyed with good quality entropy from the pool
	as soon as it is available.

	The arc4random()/arc4randbytes() implementation in libkern is
	adjusted to use the rndsink interface for rekeying, which helps
	address the problem of low-quality keys at boot time.

	An implementation of the FIPS 140-2 statistical tests for random
	number generator quality is provided (libkern/rngtest.c).  This
	is based on Greg Rose's implementation from Qualcomm.

	A new random stream generator, nist_ctr_drbg, is provided.  It is
	based on an implementation of the NIST SP800-90 CTR_DRBG by
	Henric Jungheim.  This generator users AES in a modified counter
	mode to generate a backtracking-resistant random stream.

	An abstraction layer, "cprng", is provided for in-kernel consumers
	of randomness.  The arc4random/arc4randbytes API is deprecated for
	in-kernel use.  It is replaced by "cprng_strong".  The current
	cprng_fast implementation wraps the existing arc4random
	implementation.  The current cprng_strong implementation wraps the
	new CTR_DRBG implementation.  Both interfaces are rekeyed from
	the entropy pool automatically at intervals justifiable from best
	current cryptographic practice.

	In some quick tests, cprng_fast() is about the same speed as
	the old arc4randbytes(), and cprng_strong() is about 20% faster
	than rnd_extract_data().  Performance is expected to improve.

	The AES code in src/crypto/rijndael is no longer an optional
	kernel component, as it is required by cprng_strong, which is
	not an optional kernel component.

	The entropy pool output is subjected to the rngtest tests at
	startup time; if it fails, the system will reboot.  There is
	approximately a 3/10000 chance of a false positive from these
	tests.  Entropy pool _input_ from hardware random numbers is
	subjected to the rngtest tests at attach time, as well as the
	FIPS continuous-output test, to detect bad or stuck hardware
	RNGs; if any are detected, they are detached, but the system
	continues to run.

	A problem with rndctl(8) is fixed -- datastructures with
	pointers in arrays are no longer passed to userspace (this
	was not a security problem, but rather a major issue for
	compat32).  A new kernel will require a new rndctl.

	The sysctl kern.arandom() and kern.urandom() nodes are hooked
	up to the new generators, but the /dev/*random pseudodevices
	are not, yet.

	Manual pages for the new kernel interfaces are forthcoming.
2011-11-19 22:51:18 +00:00
jakllsch
f57df1b3b2 Drop trailing whitespace. 2011-11-02 18:41:58 +00:00
jakllsch
38ef45691e Some comment improvements; spelling and grammar. 2011-10-29 18:43:58 +00:00
jakllsch
f17998b840 Attempt to complete the WD_QUIRK_SPLIT_MOD15_WRITE list.
Per Seagate Publication number 100221381, Rev. B, the ST360015AS
is the only other drive in the Seagate Barracuda Serial ATA V
family that was not already listed.

Also, correct spelling of "globing".
2011-10-27 13:07:37 +00:00
jakllsch
41fe8656e7 SATA_SIGNAL_GEN3 definition for Serial ATA capabilities word in
IDENTIFY DEVICE structure.
2011-10-24 20:52:34 +00:00
jakllsch
46398bbea4 Add defines for SET FEATURES for the SATA, PUIS and AAM feature sets. 2011-10-24 16:09:58 +00:00
jakllsch
d28b4ac9f1 Limit wd(4) transfers to 128 (512-byte) logical sectors, as the traditional
MAXPHYS value has for at least the past decade.

There are issues in wd(4) and possibly in host adapter drivers that need
work before this should be raised.
2011-10-05 03:40:18 +00:00
christos
47b3217165 make this compile. 2011-08-28 09:43:25 +00:00
bouyer
8282898f08 The loongon2f+cs5526+jmicron PATA->SATA bridge cause an interresting issue:
1) because the CS5536 is not associated with a x86 CPU, interrupts are not
  ack'ed as it expects so interrupts cannot configured as edge-triggered
  (as is expected for a PCIIDE in compat mode)
2) the PATA->SATA bridge ignores the WDC_IDS (interrupt disable bit) so
  the PATA IRQ line gets asserted when resetting or running some polled
  commands. It also wrongly asserts IRQ when the (nonexistent) slave
  device is selected
2) wouldn't be an issue with edge-triggered interrupt because we would
   get a spurious interrupt and continue operation, a new interrupt only shows
   up when the PATA IRQ line goes low and high again. But because of 1),
   we get an unclearable interrupt instead, and the system loops on the
   interrupt handler.

To workaround this, introduce a WDC_NO_IDS compile option which runs
all polled commands (including reset) at splbio() and without sleeps,
so that the controller's interrupt is effectively disabled and
won't be reenabled before the interrupt can be cleared.

The conditions triggering this problem are speficic enough to handle
this via a compile-time option; no need for a run-time (e.g. a
config(9), device property or callback to disable interrupts) solution.
2011-08-27 17:05:57 +00:00
jakllsch
e2bd65b954 Add some additional consistency checking paranoia with KASSERT. 2011-07-30 04:42:03 +00:00
rmind
e225b7bd09 Welcome to 5.99.53! Merge rmind-uvmplock branch:
- Reorganize locking in UVM and provide extra serialisation for pmap(9).
  New lock order: [vmpage-owner-lock] -> pmap-lock.

- Simplify locking in some pmap(9) modules by removing P->V locking.

- Use lock object on vmobjlock (and thus vnode_t::v_interlock) to share
  the locks amongst UVM objects where necessary (tmpfs, layerfs, unionfs).

- Rewrite and optimise x86 TLB shootdown code, make it simpler and cleaner.
  Add TLBSTATS option for x86 to collect statistics about TLB shootdowns.

- Unify /dev/mem et al in MI code and provide required locking (removes
  kernel-lock on some ports).  Also, avoid cache-aliasing issues.

Thanks to Andrew Doran and Joerg Sonnenberger, as their initial patches
formed the core changes of this branch.
2011-06-12 03:35:36 +00:00
jakllsch
fb405999a1 Add simplistic atabus(4) rescan support. 2011-04-30 00:34:03 +00:00