Commit Graph

64 Commits

Author SHA1 Message Date
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
Edward Tomasz Napierala
256a4cb9d7 Remove NULL checks after M_WAITOK allocations from firewire.
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-05-10 10:21:03 +00:00
Pedro F. Giffuni
453130d9bf sys/dev: minor spelling fixes.
Most affect comments, very few have user-visible effects.
2016-05-03 03:41:25 +00:00
Konstantin Belousov
e1da986b54 Make it explicit that D_MEM cdevsw d_flag is to signify that the
driver is (or behaves identically to) /dev/mem.  Remove the D_MEM flag
from random drivers.

Note that currently the D_MEM flag does not affect any behaviour, but
this going to change in the next commit.

Noted and reviewed by:	alc
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
X-Differential revision:	https://reviews.freebsd.org/D6149
2016-05-01 17:46:56 +00:00
Alexander Kabaev
23667f089d Remove obsolete compatibility glue and improve firewire code readability.
Commit my version of style(9) pass over the firewire code. Now that
other people have started changing the code carrying this is as a
local patch is not longer a viable option.

MFC after:	1 month
2014-09-27 16:50:21 +00:00
Will Andrews
138ebd1b64 Start the process of cleaning up FreeBSD's firewire driver.
sys/dev/firewire/firewire.c:
sys/dev/firewire/firewire.h:
sys/dev/firewire/firewirereg.h:
sys/dev/firewire/fwcrom.c:
sys/dev/firewire/fwdev.c:
sys/dev/firewire/fwdma.c:
sys/dev/firewire/fwmem.c:
sys/dev/firewire/fwohci.c:
sys/dev/firewire/fwohci_pci.c:
sys/dev/firewire/fwohcivar.h:
sys/dev/firewire/if_fwe.c:
sys/dev/firewire/if_fwip.c:
sys/dev/firewire/sbp.c:
sys/dev/firewire/sbp_targ.c:
	Unifdef the code, removing support for DragonflyBSD
	and FreeBSD prior to version 5.

Submitted by:	gibbs
MFC after:	1 month
Sponsored by:	Spectra Logic
MFSpectraBSD:	1081188 on 2014/08/01
2014-09-18 17:28:21 +00:00
Davide Italiano
d56b4cd4ac - Use make_dev_credf(MAKEDEV_REF) instead of the race-prone make_dev()+
dev_ref() in the clone handlers that still use it.
- Don't set SI_CHEAPCLONE flag, it's not used anywhere neither in devfs
(for anything real)

Reviewed by:	kib
2013-09-07 13:45:44 +00:00
Robert Noland
cfd7bacef2 Update d_mmap() to accept vm_ooffset_t and vm_memattr_t.
This replaces d_mmap() with the d_mmap2() implementation and also
changes the type of offset to vm_ooffset_t.

Purge d_mmap2().

All driver modules will need to be rebuilt since D_VERSION is also
bumped.

Reviewed by:	jhb@
MFC after:	Not in this lifetime...
2009-12-29 21:51:28 +00:00
Poul-Henning Kamp
6778431478 Revert previous commit and add myself to the list of people who should
know better than to commit with a cat in the area.
2009-09-08 13:19:05 +00:00
Poul-Henning Kamp
b34421bf9c Add necessary include. 2009-09-08 13:16:55 +00:00
Roman Divacky
03cd51df00 Fix what seems to be an obvious typo preventing the body of the
if statement to ever be executed.

Approved by:	ed (mentor)
2009-06-23 09:02:24 +00:00
Ed Schouten
6bfa9a2d66 Replace all calls to minor() with dev2unit().
After I removed all the unit2minor()/minor2unit() calls from the kernel
yesterday, I realised calling minor() everywhere is quite confusing.
Character devices now only have the ability to store a unit number, not
a minor number. Remove the confusion by using dev2unit() everywhere.

This commit could also be considered as a bug fix. A lot of drivers call
minor(), while they should actually be calling dev2unit(). In -CURRENT
this isn't a problem, but it turns out we never had any problem reports
related to that issue in the past. I suspect not many people connect
more than 256 pieces of the same hardware.

Reviewed by:	kib
2008-09-27 08:51:18 +00:00
Hidetoshi Shimokawa
9950b741e9 MFp4: MPSAFE firewire stack.
- lock its own locks and drop Giant.
- create its own taskqueue thread.
- split interrupt routine
- use interrupt filter as a fast interrupt.
- run watchdog timer in taskqueue so that it should be
   serialized with the bottom half.
- add extra sanity check for transaction labels.
   disable ad-hoc workaround for unknown tlabels.
- add sleep/wakeup synchronization primitives
- don't reset OHCI in fwohci_stop()
2007-06-06 14:31:36 +00:00
Hidetoshi Shimokawa
0892f4c5ec MFp4: Fix broken userland API for async packets.
- Introduce fw_xferlist_add/remove().
- Introduce fw_read/write_async().
- Remove unused FWACT_CH.

MFC after: 1 week
2007-04-30 13:41:40 +00:00
Hidetoshi Shimokawa
e340a7ac14 Configuration ROM length should be unsigned.
MFC: 1 week
2007-04-24 12:15:05 +00:00
Hidetoshi Shimokawa
801167a869 Replace xfer->act.hand with xfer->hand. 2007-03-16 05:39:33 +00:00
Colin Percival
8b0a738288 Correct a signedness bug which allowed members of the operator
group to read kernel memory.

Security:	FreeBSD-SA-06:25.kmem
2006-12-06 09:13:51 +00:00
Robert Watson
6a113b3de7 Merge the dev_clone and dev_clone_cred event handlers into a single
event handler, dev_clone, which accepts a credential argument.
Implementors of the event can ignore it if they're not interested,
and most do.  This avoids having multiple event handler types and
fall-back/precedence logic in devfs.

This changes the kernel API for /dev cloning, and may affect third
party packages containg cloning kernel modules.

Requested by:	phk
MFC after:	3 days
2005-08-08 19:55:32 +00:00
Poul-Henning Kamp
f4f6abcb4e Explicitly hold a reference to the cdev we have just cloned. This
closes the race where the cdev was reclaimed before it ever made it
back to devfs lookup.
2005-03-31 12:19:44 +00:00
Warner Losh
098ca2bda9 Start each of the license/copyright comments with /*-, minor shuffle of lines 2005-01-06 01:43:34 +00:00
Poul-Henning Kamp
f3732fd15b Second half of the dev_t cleanup.
The big lines are:
	NODEV -> NULL
	NOUDEV -> NODEV
	udev_t -> dev_t
	udev2dev() -> findcdev()

Various minor adjustments including handling of userland access to kernel
space struct cdev etc.
2004-06-17 17:16:53 +00:00
Poul-Henning Kamp
89c9c53da0 Do the dreaded s/dev_t/struct cdev */
Bump __FreeBSD_version accordingly.
2004-06-16 09:47:26 +00:00
Doug Rabson
7b1f628606 Don't try to copy out the result payload if there isn't one. This ioctl
interface really needs changing to split out the various async request
types.
2004-05-23 18:43:44 +00:00
Doug Rabson
03161bbcf6 Change u_intXX_t to uintXX_t. Change a couple of 'unsigned long's to
uint32_t where appropriate.
2004-05-22 16:14:17 +00:00
Hidetoshi Shimokawa
10d3ed6459 MFp4: FireWire
* all
- s/__FUNCTION__/__func__/.
	Submitted by: Stefan Farfeleder <stefan@fafoe.narf.at>
- Compatibility for RELENG_4 and DragonFly.

* firewire
- Timestamp just before queuing.
- Retry bus probe if it fails.
- Use device_printf() for debug message.
- Invalidiate CROM while update.
- Don't process minimum/invalid CROM.

* sbp
- Add ORB_SHORTAGE flag.
- Add sbp.tags tunable.
- Revive doorbell support. It's not enabled by default.
2004-03-26 23:17:10 +00:00
Hidetoshi Shimokawa
a832f947f3 Fix a bug introduced in rev 1.33(mega API change).
Because xfer->send.payload is a pointer to the buffer, '&' shouldn't be there.

Submitted by: John Weisgerber <weisgerberj@gsilumonics.com>
PR: misc/64623
2004-03-24 01:29:08 +00:00
Poul-Henning Kamp
dc08ffec87 Device megapatch 4/6:
Introduce d_version field in struct cdevsw, this must always be
initialized to D_VERSION.

Flip sense of D_NOGIANT flag to D_NEEDGIANT, this involves removing
four D_NOGIANT flags and adding 145 D_NEEDGIANT flags.
2004-02-21 21:10:55 +00:00
Poul-Henning Kamp
c9c7976f7f Device megapatch 1/6:
Free approx 86 major numbers with a mostly automatically generated patch.

A number of strategic drivers have been left behind by caution, and a few
because they still (ab)use their major number.
2004-02-21 19:42:58 +00:00
Hidetoshi Shimokawa
4c790222f6 Add missing free() in exception handlers.
Reported by:    Stanford Metacompilation research group
2004-01-22 14:41:17 +00:00
Hidetoshi Shimokawa
3a927c871a Respect a return code of fwmem_open(). 2003-11-07 12:30:57 +00:00
Hidetoshi Shimokawa
102ebc1f95 Fix for FW_ASYREQ.
- set send.pay_len correctly.
- copy response only if needed.
- remove unnecessary 'err = 0'.
2003-10-24 13:55:51 +00:00
Hidetoshi Shimokawa
c4778b5d1c MFp4: Change struct fw_xfer to reduce memory copy in fwmem_*() functions.
And many changes.

* all
	- Major change of struct fw_xfer.
		o {send,recv}.buf is splitted into hdr and payload.
		o Remove unnecessary fields.
		o spd is moved under send and recv.
	- Remove unnecessary 'volatile' keyword.
	- Add definition of rtcode and extcode.

* firewire.c
	- Ignore FWDEVINVAL devices in fw_noderesolve_nodeid().
	- Check the existance of the bind before call STAILQ_REMOVE().
	- Fix bug in the fw_bindadd().
	- Change element of struct fw_bind for simplicity.
	- Check rtcode of response packet.
	- Reduce split transaction timeout to 200 msec.
		(100msec is the default value in the spec.)
	- Set watchdog timer cycle to 10 Hz.
	- Set xfer->tv just before calling fw_get_tlabel().

* fwohci.c
	- Simplifies fwohci_get_plen().

* sbp.c
	- Fix byte order of multibyte scsi_status informations.
	- Split sbp.c and sbp.h.
	- Unit number is not necessary for FIFO¤ address.
	- Reduce LOGIN_DELAY and SCAN_DELAY to 1 sec.
	- Add some constants defineded in SBP-2 spec.

* fwmem.c
	- Introduce fwmem_strategy() and reduce memory copy.
2003-10-02 04:06:56 +00:00
Hidetoshi Shimokawa
c727011a76 Fix a bug in fwdev_clone().
Spotted by: grog
2003-10-01 06:04:30 +00:00
Hidetoshi Shimokawa
a160e00e41 Change device name notation.
- /dev/fw{,mem}X.Y represents the Y'th unit on the X'th bus.
- /dev/fw{,mem}X is an alias of fw{,mem}X.0 for compatibility.
- Clone devices.
2003-08-05 03:11:39 +00:00
Hidetoshi Shimokawa
6cada79a78 Clean up fwdev.
Allocate iso DMA channel dynamically.  This allows us to have more
/dev/fw* than number of DMA channels for asyn. transactions and etc.
2003-08-01 04:51:21 +00:00
Hidetoshi Shimokawa
d7e486b41d Allow retrieval of local Configuration ROM. 2003-07-12 09:34:44 +00:00
Hidetoshi Shimokawa
85b2d114c0 Set the local bus address in xfer->dst.
Submitted by: Buzz Slye <buzz@gaia.arc.nasa.gov>
2003-04-22 02:31:31 +00:00
Hidetoshi Shimokawa
e863fbcdb0 Remove unused code. 2003-04-21 16:41:20 +00:00
Hidetoshi Shimokawa
77ee030b5f MFp4(simokawa_firewire):
Many internal structure changes for the FireWire driver.

- Compute CRC in CROM parsing.
- Add support for configuration ROM build.
- Simplify dummy buffer handling.
- busdma conversion
- Use swi_taskqueue_giant for -current.  Mark the interrupt routine as MPSAFE.
- AR buffer handling.
	Don't reallocate AR buffer but just recycle it.
	Don't malloc and copy per packet in fwohci_arcv().
	Pass packet to fw_rcv() using iovec.
	Application must prepare receiving buffer in advance.
- Change fw_bind API so that application should pre-allocate xfer structure.
- Add fw_xfer_unload() for recycling struct fw_xfer.
- Add post_busreset hook
- Remove unused 'sub' and 'act_type' in struct fw_xfer.
- Remove npacket from struct fw_bulkxfer.
- Don't call back handlers in fwochi_arcv() if the packet has
	not drained in AT queue
- Make firewire works on big endian platform.
- Use native endian for packet header and remove unnecessary ntohX/htonX.
- Remove FWXFERQ_PACKET mode.  We don't use it anymore.
- Remove unnecessary restriction of FWSTMAXCHUNK.
- Don't set root node for phy config packet if the root node is
	not cycle master capable but set myself for root node.
	We should be the root node after next bus reset.

	Spotted by: Yoshihiro Tabira <tabira@scd.mei.co.jp>
- Improve self id handling

Tested on: i386, sparc64 and i386 with forced bounce buffer
2003-04-17 03:38:03 +00:00
Hidetoshi Shimokawa
2b4601d10b MFp4(simokawa_sbp)
Improve if_fwe performance.
- Simplify mbuf handling by using bulkxfer.
	Now, it uses mbuf clusters for RX buffer as usual ethernet drivers.
- Recycle struct xfer buffer and don't call malloc at runtime.
- Count input and output errors.
- Handle a mbuf chain longer than 6 correctly.
- Increase queue length.
2003-03-06 05:06:44 +00:00
Poul-Henning Kamp
7ac40f5f59 Gigacommit to improve device-driver source compatibility between
branches:

Initialize struct cdevsw using C99 sparse initializtion and remove
all initializations to default values.

This patch is automatically generated and has been tested by compiling
LINT with all the fields in struct cdevsw in reverse order on alpha,
sparc64 and i386.

Approved by:    re(scottl)
2003-03-03 12:15:54 +00:00
Poul-Henning Kamp
95e4359c8e Use canonical format for cdevsw initialization. 2003-03-02 18:51:46 +00:00
Dag-Erling Smørgrav
521f364b80 More low-hanging fruit: kill caddr_t in calls to wakeup(9) / [mt]sleep(9). 2003-03-02 16:54:40 +00:00
Hidetoshi Shimokawa
455454994f MFp4(simokawa_sbp branch)
Improve SBP device probeing:
- Wait 2 sec before issuing LOGIN ORB expecting the reconnection
	hold timer expires.
- Serialize management ORB and scanning LUN by CAM on each target.
	This should fix the problem for devices which have multiple LUNs.
	Test device is donated by: Jaye Mathisen <mrcpu@internetcds.com>
- Freeze SIM queue for 2 sec after BUS RESET.
- Retry with LOGIN rather than RECONNECT after LOGIN is not completed for
	BUS RESET.
- Use appropriate CAM status for BUS RESET and DEVICE RESET.
- Let CAM to scan targets after BUS REST.
- Implement CAM scan target function.
- Keep our own devq freeze count.
- Let CAM to know that SBP does tagged queuing.

These should be merged to RELENG_4 before 4.8-RELEASE.
2003-02-27 12:51:24 +00:00
Maxime Henrion
07159f9c56 Cleanup of the d_mmap_t interface.
- Get rid of the useless atop() / pmap_phys_address() detour.  The
  device mmap handlers must now give back the physical address
  without atop()'ing it.
- Don't borrow the physical address of the mapping in the returned
  int.  Now we properly pass a vm_offset_t * and expect it to be
  filled by the mmap handler when the mapping was successful.  The
  mmap handler must now return 0 when successful, any other value
  is considered as an error.  Previously, returning -1 was the only
  way to fail.  This change thus accidentally fixes some devices
  which were bogusly returning errno constants which would have been
  considered as addresses by the device pager.
- Garbage collect the poorly named pmap_phys_address() now that it's
  no longer used.
- Convert all the d_mmap_t consumers to the new API.

I'm still not sure wheter we need a __FreeBSD_version bump for this,
since and we didn't guarantee API/ABI stability until 5.1-RELEASE.

Discussed with:		alc, phk, jake
Reviewed by:		peter
Compile-tested on:	LINT (i386), GENERIC (alpha and sparc64)
Runtime-tested on:	i386
2003-02-25 03:21:22 +00:00
Hidetoshi Shimokawa
233b1b978b Add new ioctl to specify target EUI64 for fwmem. 2003-02-09 10:14:22 +00:00
Hidetoshi Shimokawa
beb19fc5dd Remove unnecessary M_NOWAIT. 2003-02-03 09:41:42 +00:00
Hidetoshi Shimokawa
48249fe0c8 - Take malloc type as an argument in fw_xfer_alloc().
- Fix overwrite problem of freed buffers. It was rare but could happen
	when fwohci_arcv() is called before fwohci_txd() is called for
	the transcation.
- Drain AT queues and pend AR queues on SID receive rather than BUS reset to
	make sure DMA actually stops.
- Do agent reset in sbp_timeout().
2003-02-03 07:33:31 +00:00
Hidetoshi Shimokawa
5166f1df39 Define new malloc type M_FW and use it. 2003-02-01 15:04:33 +00:00
Hidetoshi Shimokawa
0981f5f00e - replace timeout with callout_*.
- replace TAILQ with STAILQ for device list.
- some clean up.
2003-02-01 14:42:49 +00:00