Commit Graph

35 Commits

Author SHA1 Message Date
Warner Losh
2ced565834 Tag the current round of deprecated drivers.
Differential Revision: https://reviews.freebsd.org/D13818
2018-01-29 00:14:46 +00:00
Pedro F. Giffuni
718cf2ccb9 sys/dev: further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.
2017-11-27 14:52:40 +00:00
Ravi Pokala
d3c06026c2 In the same vein as r311350, fix whitespace in handling of XPT_PATH_INQ in
several more drivers.

Sponsored by:	Panasas
2017-01-05 03:08:57 +00:00
Alan Somers
4195c7de24 Always null-terminate ccb_pathinq.(sim_vid|hba_vid|dev_name)
The sim_vid, hba_vid, and dev_name fields of struct ccb_pathinq are
fixed-length strings. AFAICT the only place they're read is in
sbin/camcontrol/camcontrol.c, which assumes they'll be null-terminated.
However, the kernel doesn't null-terminate them. A bunch of copy-pasted code
uses strncpy to write them, and doesn't guarantee null-termination. For at
least 4 drivers (mpr, mps, ciss, and hyperv), the hba_vid field actually
overflows. You can see the result by doing "camcontrol negotiate da0 -v".

This change null-terminates those fields everywhere they're set in the
kernel. It also shortens a few strings to ensure they'll fit within the
16-character field.

PR:		215474
Reported by:	Coverity
CID:		1009997 1010000 1010001 1010002 1010003 1010004 1010005
CID:		1331519 1010006 1215097 1010007 1288967 1010008 1306000
CID:		1211924 1010009 1010010 1010011 1010012 1010013 1010014
CID:		1147190 1010017 1010016 1010018 1216435 1010020 1010021
CID:		1010022 1009666 1018185 1010023 1010025 1010026 1010027
CID:		1010028 1010029 1010030 1010031 1010033 1018186 1018187
CID:		1010035 1010036 1010042 1010041 1010040 1010039
Reviewed by:	imp, sephe, slm
MFC after:	4 weeks
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D9037
Differential Revision:	https://reviews.freebsd.org/D9038
2017-01-04 20:26:42 +00:00
Pedro F. Giffuni
323b076e9c sys: use our nitems() macro when param.h is available.
This should cover all the remaining cases in the kernel.

Discussed in:	freebsd-current
2016-04-21 19:40:10 +00:00
Steven Hartland
85c9dd9d89 Prevent overflow issues in timeout processing
Previously, any timeout value for which (timeout * hz) will overflow the
signed integer, will give weird results, since callout(9) routines will
convert negative values of ticks to '1'. For unsigned integer overflow we
will get sufficiently smaller timeout values than expected.

Switch from callout_reset, which requires conversion to int based ticks
to callout_reset_sbt to avoid this.

Also correct isci to correctly resolve ccb timeout.

This was based on the original work done by Eygene Ryabinkin
<rea@freebsd.org> back in 5 Aug 2011 which used a macro to help avoid
the overlow.

Differential Revision:	https://reviews.freebsd.org/D1157
Reviewed by:	mav, davide
MFC after:	1 month
Sponsored by:	Multiplay
2014-11-21 21:01:24 +00:00
Konstantin Belousov
dd0b4fb6d5 Reform the busdma API so that new types may be added without modifying
every architecture's busdma_machdep.c.  It is done by unifying the
bus_dmamap_load_buffer() routines so that they may be called from MI
code.  The MD busdma is then given a chance to do any final processing
in the complete() callback.

The cam changes unify the bus_dmamap_load* handling in cam drivers.

The arm and mips implementations are updated to track virtual
addresses for sync().  Previously this was done in a type specific
way.  Now it is done in a generic way by recording the list of
virtuals in the map.

Submitted by:	jeff (sponsored by EMC/Isilon)
Reviewed by:	kan (previous version), scottl,
	mjacob (isp(4), no objections for target mode changes)
Discussed with:	     ian (arm changes)
Tested by:	marius (sparc64), mips (jmallet), isci(4) on x86 (jharris),
	amd64 (Fabian Keil <freebsd-listen@fabiankeil.de>)
2013-02-12 16:57:20 +00:00
John Baldwin
4bb96a7418 Add locking to the aic(4) driver and mark it MPSAFE.
- Move 'free_scbs' into the softc rather than having it be a global list
  and convert it to an SLIST instead of a hand-rolled linked-list.
- Use device_printf() and device_get_unit() instead of storing the unit
  number in the softc.
- Remove use of explicit bus space handles and tags.
- Don't call device_set_desc() in the pccard attach routine, instead
  set a default description during the pccard probe if the matching
  product doesn't have a name.

Tested by:	no one
2012-10-15 16:09:59 +00:00
Dag-Erling Smørgrav
e872228f51 Snip redundant assignment.
Approved by:	scottl
MFC after:	2 weeks
Coverity ID:	3863
2009-05-13 22:31:25 +00:00
Scott Long
b50569b71d Prepare for future integration between CAM and newbus. xpt_bus_register
now takes a device_t to be the parent of the bus that is being created.
Most SIMs have been updated with a reasonable argument, but a few exceptions
just pass NULL for now.  This argument isn't used yet and the newbus
integration likely won't be ready until after 7.0-RELEASE.
2007-06-17 05:55:54 +00:00
Scott Long
2b83592fdc Remove Giant from CAM. Drivers (SIMs) now register a mutex that CAM will
use to synchornize and protect all data objects that are used for that
SIM.  Drivers that are not yet MPSAFE register Giant and operate as
usual.  RIght now, no drivers are MPSAFE, though a few will be changed
in the coming week as this work settles down.

The driver API has changed, so all CAM drivers will need to be recompiled.
The userland API has not changed, so tools like camcontrol do not need to
be recompiled.
2007-04-15 08:49:19 +00:00
Matt Jacob
bd3fd815a7 2nd and final commit that moves us to CAM_NEW_TRAN_CODE
as the default.

Reviewed by multitudes.
2006-11-02 00:54:38 +00:00
Matt Jacob
fa9ed86506 The first of 3 major steps to move the CAM layer forward to using
the CAM_NEW_TRAN_CODE that has been in the tree for some years now.

This first step consists solely of adding to or correcting
CAM_NEW_TRAN_CODE pieces in the kernel source tree such
that a both a GENERIC (at least on i386) and a LINT build
with CAM_NEW_TRAN_CODE as an option will compile correctly
and run (at least with some the h/w I have).

After a short settle time, the other pieces (making
CAM_NEW_TRAN_CODE the default and updating libcam
and camcontrol) will be brought in.

This will be an incompatible change in that the size of structures
related to XPT_PATH_INQ and XPT_{GET,SET}_TRAN_SETTINGS change
in both size and content. However, basic system operation and
basic system utilities work well enough with this change.

Reviewed by:	freebsd-scsi and specific stakeholders
2006-10-31 05:53:29 +00:00
Yoshihiro Takahashi
d4fcf3cba5 Remove bus_{mem,p}io.h and related code for a micro-optimization on i386
and amd64.  The optimization is a trivial on recent machines.

Reviewed by:	-arch (imp, marcel, dfr)
2005-05-29 04:42:30 +00:00
David E. O'Brien
aad970f1fe Use __FBSDID().
Also some minor style cleanups.
2003-08-24 17:55:58 +00:00
Marcel Moolenaar
e5282aea6b In aic_reconnect()i, initialize scb. On ia64 the compiler warns about
a possible uninitialized variable.
2003-08-23 09:00:56 +00:00
Nate Lawson
2813692cc2 Merge common XPT_CALC_GEOMETRY functions into a single convenience function.
Devices below may experience a change in geometry.

* Due to a bug, aic(4) never used extended geometry.  Changes all drives
  >1G to now use extended translation.
* sbp(4) drives exactly 1 GB in size now no longer use extended geometry.
* umass(4) drives exactly 1 GB in size now no longer use extended geometry.

For all other controllers in this commit, this should be a no-op.

Looked over by:	scottl
2003-06-14 22:17:41 +00:00
Poul-Henning Kamp
37c841831f Be consistent about "static" functions: if the function is marked
static in its prototype, mark it static at the definition too.

Inspired by:    FlexeLint warning #512
2002-09-28 17:15:38 +00:00
Alfred Perlstein
e51a25f850 Remove __P. 2002-03-20 02:08:01 +00:00
Luoqi Chen
6774c4e510 Support for LG GM82C700, an AIC6360 clone. 2002-03-15 21:30:41 +00:00
Joerg Wunsch
31f639ecdf Back out the hack from rev 1.13 that was done to initiate a bus rescan
at insert time.  When asking gibbs for approval for an MFC, this was
his reply:

1) It leaks memory if it can't allocate a path.

2) It defers allocation of aic->path until the call to scan the
   bus.  This means the path may be NULL when an interrupt occurs
   prior to the call to scan the bus (stray bus reset for instance),
   which will lead to a panic.

3) The driver in current doesn't recover from the failure to allocate
   aic->path.  The driver doesn't check during normal operation if
   the path is NULL, so again a panic will result.

4) aic_cam_rescan calls malloc with M_WAITOK.  aic_cam_rescan is called
   from attach where it isn't necessarily safe to sleep.

5) And most importantly, it co-opts the xpt_periph from the driver level.
   This was never part of the design (xpt_periph used to be static).  Making
   a call of this type may completely confuse the XPT if other XPT operations
   are ongoing.

In the long term, Justin and Warner agreed to implement solution where
CAM itself will initiate the bus rescan if a new bus is added.  For
the time being (and in particular in light of the upcoming 4.5
release), we now have camcontrol available on the boot floppy, and can
have pccardd initiate the rescan through it.
2002-01-17 20:34:58 +00:00
Kenneth D. Merry
76db0ab017 Fix a few things in the aic(4) driver:
- enable 10MHz (fast SCSI) operation on boards that support it.  (only
   aic6360 boards with fast SCSI enabled can do it)

 - bounds check sync periods and offsets passed in from the transport layer

 - tell the user which resource allocation failed (for the ISA probe) if we
   weren't able to allocate an IRQ, DRQ or I/O port.
2001-03-16 22:20:19 +00:00
Peter Wemm
c14e19116f Sigh, nobody ever got back to me about this. So, here it is..
Implement auto scsi scan at insert time for the aic driver.
2001-02-23 02:32:31 +00:00
Poul-Henning Kamp
db7e3af111 Remove unneeded #include <machine/clock.h> 2000-10-15 14:19:01 +00:00
Warner Losh
4d678f2674 remove 5 unnecessary includes, per phk's script 2000-09-20 19:34:17 +00:00
Poul-Henning Kamp
3389ae9350 Remove ~25 unneeded #include <sys/conf.h>
Remove ~60 unneeded #include <sys/malloc.h>
2000-04-19 14:58:28 +00:00
Poul-Henning Kamp
ed6aff7387 Remove unneeded <sys/buf.h> includes.
Due to some interesting cpp tricks in lockmgr, the LINT kernel shrinks
by 924 bytes.
2000-04-18 15:15:39 +00:00
Warner Losh
2a457ef118 Add support to aic for pccard attachments. Reports from testers have
been so positive that I'm going to go ahead and commit this now rather
than do another round of patches.

My Adaptec 1460D works great with these changes.
2000-01-14 23:42:36 +00:00
Luoqi Chen
da2c318f0b Adjust data pointers for untransmitted bytes in fifos when there's phase
change during data transfer.
1999-12-16 16:11:49 +00:00
Luoqi Chen
6f59da2daa Disconnect and tagged queueing now really work. Also fix a bug that's
causing problems to slow devices.
1999-12-04 22:15:02 +00:00
Luoqi Chen
4b80d3dd0b Bug fix: allow reset device command to complete. 1999-10-28 05:28:00 +00:00
Luoqi Chen
9da0c0ca63 Fix a typo which would result a bad REQUEST SENSE command be sent to
a device at lun != 0.

Enable tagged queueing (should it be spelled as queuing?) by default.
1999-10-26 22:11:45 +00:00
Luoqi Chen
cb6c99d54e A few improvements and cleanups. 1999-10-21 21:15:02 +00:00
Luoqi Chen
86a4b08dc7 Non-functional changes. Add some comments before I start to forget how
everything works myself.
1999-10-21 15:49:25 +00:00
Luoqi Chen
81ef553683 Adaptec 6260/6360 CAM driver. 1999-10-21 08:56:53 +00:00