aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/firewire/firewire.c
Commit message (Collapse)AuthorAgeFilesLines
* sys: Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-161-2/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* firewire: Initialize firewire_devclass in fw_modevent.John Baldwin2022-04-271-2/+2
| | | | | | | | | | The use of devclass_get_softc() combined with cdev unit numbers is probably not ideal (probably should be initializing si_drv1 when each cdev is created instead), but it looks like a bit of a PITA to do, so just initialize the devclass explicitly instead. Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D35060
* firewire(4): Fix "set but not used" warningsEdward Tomasz Napierala2021-12-201-1/+4
| | | | Sponsored By: EPSRC
* Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many)Pawel Biernacki2020-02-261-1/+2
| | | | | | | | | | | | | | | | | | | r357614 added CTLFLAG_NEEDGIANT to make it easier to find nodes that are still not MPSAFE (or already are but aren’t properly marked). Use it in preparation for a general review of all nodes. This is non-functional change that adds annotations to SYSCTL_NODE and SYSCTL_PROC nodes using one of the soon-to-be-required flags. Mark all obvious cases as MPSAFE. All entries that haven't been marked as MPSAFE before are by default marked as NEEDGIANT Approved by: kib (mentor, blanket) Commented by: kib, gallatin, melifaro Differential Revision: https://reviews.freebsd.org/D23718 Notes: svn path=/head/; revision=358333
* Extract eventfilter declarations to sys/_eventfilter.hConrad Meyer2019-05-201-6/+5
| | | | | | | | | | | | | | | | | | | | | | | | This allows replacing "sys/eventfilter.h" includes with "sys/_eventfilter.h" in other header files (e.g., sys/{bus,conf,cpu}.h) and reduces header pollution substantially. EVENTHANDLER_DECLARE and EVENTHANDLER_LIST_DECLAREs were moved out of .c files into appropriate headers (e.g., sys/proc.h, powernv/opal.h). As a side effect of reduced header pollution, many .c files and headers no longer contain needed definitions. The remainder of the patch addresses adding appropriate includes to fix those files. LOCK_DEBUG and LOCK_FILE_LINE_ARG are moved to sys/_lock.h, as required by sys/mutex.h since r326106 (but silently protected by header pollution prior to this change). No functional change (intended). Of course, any out of tree modules that relied on header pollution for sys/eventhandler.h, sys/lock.h, or sys/mutex.h inclusion need to be fixed. __FreeBSD_version has been bumped. Notes: svn path=/head/; revision=347984
* sys/dev: further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-271-0/+2
| | | | | | | | | | | | | | | 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. Notes: svn path=/head/; revision=326255
* firewire: initialize tag label to -1 in fw_xfer_alloc()Andriy Gapon2016-11-241-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Zero can be confused for a potentially valid value. For example, if I load and unload sbp driver I get a lot of messages like the following: fw_tl_free: the xfer is not in the queue (tlabel=0, flag=0x0) send: dst=0x00 tl=0x00 rt=0 tcode=0x0 pri=0x0 src=0x000 recv: dst=0x01 tl=0x21 rt=1 tcode=0x1 pri=0x0 src=0xffc0 KDB: stack backtrace: db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe04464407e0 fw_tl_free() at fw_tl_free+0x18d/frame 0xfffffe0446440820 fw_xfer_unload() at fw_xfer_unload+0xca/frame 0xfffffe0446440840 fw_xferlist_remove() at fw_xferlist_remove+0x2f/frame 0xfffffe0446440870 sbp_detach() at sbp_detach+0x1e0/frame 0xfffffe04464408e0 device_detach() at device_detach+0x80/frame 0xfffffe0446440900 devclass_driver_deleted() at devclass_driver_deleted+0x6a/frame 0xfffffe0446440940 devclass_delete_driver() at devclass_delete_driver+0x7d/frame 0xfffffe0446440980 driver_module_handler() at driver_module_handler+0xff/frame 0xfffffe04464409d0 module_unload() at module_unload+0x32/frame 0xfffffe04464409f0 linker_file_unload() at linker_file_unload+0x24b/frame 0xfffffe0446440a40 kern_kldunload() at kern_kldunload+0xbc/frame 0xfffffe0446440a70 amd64_syscall() at amd64_syscall+0x314/frame 0xfffffe0446440bf0 Xfast_syscall() at Xfast_syscall+0xfb/frame 0xfffffe0446440bf0 MFC after: 2 weeks Notes: svn path=/head/; revision=309093
* sys/dev: minor spelling fixes.Pedro F. Giffuni2016-05-031-1/+1
| | | | | | | Most affect comments, very few have user-visible effects. Notes: svn path=/head/; revision=298955
* Fix firewire panic when issuing a reply to an unhandledWill Andrews2015-01-211-0/+1
| | | | | | | | | | | | | | | | | asynchronous remote dma request (DMA request that the hardware cannot automatically handle). sys/dev/firewire/firewire.c In fw_rcv(), add missing early return in the error path for DMA requests to unregistered regions. Submitted by: gibbs MFC after: 1 week Sponsored by: Spectra Logic MFSpectraBSD: 1110993 on 2015/01/06 Notes: svn path=/head/; revision=277510
* Properly lock accesss to the firewire_comm->devices list.Will Andrews2015-01-211-13/+5
| | | | | | | | | | | | | | | | | | sys/dev/firewire/firewire.c: Add missing FW_GLOCK/UNLOCK() usage to fw_noderesolve_nodeid(). sys/dev/firewire/firewire.c: sys/dev/firewire/fwmem.c: Remove no-op splfw() calls from functions that have been audited for proper lock usage. Submitted by: gibbs MFC after: 1 week Sponsored by: Spectra Logic MFSpectraBSD: 1110992 on 2015/01/06 Notes: svn path=/head/; revision=277509
* Fix panic in firewire and creation of invalid config ROM.Will Andrews2015-01-211-10/+19
| | | | | | | | | | | | | | | | | | | | sys/boot/i386/libfirewire/firewire.c: sys/dev/firewire/firewire.c: Fix configuration ROM generation count wrapping logic so that the generation count is never outside of allowed limits (0x2 -> 0xF). sys/dev/firewire/firewire.c: In fw_xfer_unload(), xfer->fc may be NULL. Protect against this before taking the fc lock. Submitted by: gibbs MFC after: 1 week Sponsored by: Spectra Logic MFSpectraBSD: 1110685 on 2015/01/05 Notes: svn path=/head/; revision=277508
* Fix a FWXF_INQ race in the firewire driver.Will Andrews2015-01-211-10/+2
| | | | | | | | | | | | | | | sys/dev/firewire/firewire.c: In fw_xfer_unload() expand lock coverage so that the test for FWXF_INQ doesn't race with it being cleared in another thread. Submitted by: gibbs MFC after: 1 week Sponsored by: Spectra Logic MFSpectraBSD: 1110207 on 2015/01/02 Notes: svn path=/head/; revision=277507
* Fix one cause of firewire panics.Will Andrews2015-01-211-0/+1
| | | | | | | | | | | | | | | | | | | sys/dev/firewire/firewire.c: In fw_xfer_unload(), clear the FWXF_INQ flag on the xfer under protection of the FW_GMTX, after the xfer is removeed from the tx/rx queue. Otherwise it is possible for the xfer to be removed again (corrupting the list or immediately panicing) from another thread that has found this xfer in the transaction label table. Submitted by: gibbs MFC after: 1 week Sponsored by: Spectra Logic MFSpectraBSD: 1110200 on 2015/01/02 Notes: svn path=/head/; revision=277506
* Remove obsolete compatibility glue and improve firewire code readability.Alexander Kabaev2014-09-271-346/+329
| | | | | | | | | | | 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 Notes: svn path=/head/; revision=272214
* Start the process of cleaning up FreeBSD's firewire driver.Will Andrews2014-09-181-25/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=271795
* Silence noisy firewire logging.Will Andrews2014-09-181-13/+0
| | | | | | | | | MFC after: 1 month Sponsored by: Spectra Logic MFSpectraBSD: 974594 on 2013/08/02 Notes: svn path=/head/; revision=271793
* Fix undefined behavior: (1 << 31) is not defined as 1 is an int and thisEitan Adler2013-11-301-1/+1
| | | | | | | | | | | | | | | | shifts into the sign bit. Instead use (1U << 31) which gets the expected result. This fix is not ideal as it assumes a 32 bit int, but does fix the issue for most cases. A similar change was made in OpenBSD. Discussed with: -arch, rdivacky Reviewed by: cperciva Notes: svn path=/head/; revision=258780
* FireWire: Don't allow a tlabel to reference an xfer after free.Will Andrews2013-04-081-3/+12
| | | | | | | | | | | | | | | | | | sys/dev/firewire/firewire.c: - fw_xfer_unload(): Since we are about to free this xfer, call fw_tl_free() to remove the xfer from its tlabel's list, if it has a tlabel. - In every occasion when a xfer is removed from a tlabel's list, reset xfer->tl to -1 while holding fc->tlabel_lock, so that the xfer isn't mis-identified as belonging to a tlabel. This doesn't fix all the use-after-free problems for M_FWMEM, but is an incremental towards that goal. Reviewed by: kan, sbruno Sponsored by: Spectra Logic Notes: svn path=/head/; revision=249291
* - There's no need to overwrite the default device method with the defaultMarius Strobl2011-11-221-5/+4
| | | | | | | | | | | | | one. Interestingly, these are actually the default for quite some time (bus_generic_driver_added(9) since r52045 and bus_generic_print_child(9) since r52045) but even recently added device drivers do this unnecessarily. Discussed with: jhb, marcel - While at it, use DEVMETHOD_END. Discussed with: jhb - Also while at it, use __FBSDID. Notes: svn path=/head/; revision=227843
* bus_add_child: change type of order parameter to u_intAndriy Gapon2010-09-101-2/+2
| | | | | | | | | | | | | This reflects actual type used to store and compare child device orders. Change is mostly done via a Coccinelle (soon to be devel/coccinelle) semantic patch. Verified by LINT+modules kernel builds. Followup to: r212213 MFC after: 10 days Notes: svn path=/head/; revision=212413
* Rename the host-related prison fields to be the same as the host.*Jamie Gritton2009-06-131-1/+1
| | | | | | | | | | parameters they represent, and the variables they replaced, instead of abbreviated versions of them. Approved by: bz (mentor) Notes: svn path=/head/; revision=194118
* Place hostnames and similar information fully under the prison system.Jamie Gritton2009-05-291-2/+4
| | | | | | | | | | | | | | | | | | | | The system hostname is now stored in prison0, and the global variable "hostname" has been removed, as has the hostname_mtx mutex. Jails may have their own host information, or they may inherit it from the parent/system. The proper way to read the hostname is via getcredhostname(), which will copy either the hostname associated with the passed cred, or the system hostname if you pass NULL. The system hostname can still be accessed directly (and without locking) at prison0.pr_host, but that should be avoided where possible. The "similar information" referred to is domainname, hostid, and hostuuid, which have also become prison parameters and had their associated global variables removed. Approved by: bz (mentor) Notes: svn path=/head/; revision=193066
* Minor updates as a precursor to fixing sbp_targSean Bruno2009-04-071-1/+5
| | | | | | | | | | firewire.c -- expand a comment and repair a typo sbp.h -- define Logical Unit Reset so it can be used in sbp_targ Reviewed by: scottl@freebsd.org Notes: svn path=/head/; revision=190792
* Reviewed by: scott (scottl@freebsd.org)Sean Bruno2009-03-171-32/+52
| | | | | | | | | | | | | | | Obtained from: Hideotshi Shimokawa This update is based on comments from Hidetoshi. Changeset 183550 removed the call to crom_load() in fw_busreset(). Restore that call such that the Configuration ROM is valid. Stash and update fwdev settings in fw_explore_node() so that negotiation works again. Notes: svn path=/head/; revision=189928
* Introduce 1394a-2000 extended PHY Self ID packets.Sean Bruno2009-02-171-6/+23
| | | | | | | | | | | | | Deprecate unused phy_delay Self ID field as it was removed by 1394a-2000. Attempt to parse extended Self ID PHY packets if they are detected Reviewed by: scottl (mentor) MFC after: 2 weeks Notes: svn path=/head/; revision=188726
* Simplify some debugging messages and try to consolodate some of the moreSean Bruno2009-02-171-65/+109
| | | | | | | | | | | | | | interesting conditional printf's into single device_printf's Change a couple of variable names so that I don't have to trace what they acutally do anymore. Enable the display of the Self ID PHY packet if firewire_debug > 0 Reviewed by: scottl(mentor) MFC after: 2 weeks Notes: svn path=/head/; revision=188722
* Synopsis:Sean Bruno2009-02-171-6/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | If speed of link between two devices is slower than the reported max speed of both endpoints, the current driver will fail and be unable to negotiate. Summary: Test negotiated speed by reading the CSRROM into a dummy variable. If that read fails, decrement our speed and retry. If all else fails, go to lowest speed possible(0). Report speed to the user. Add display of the Bus Info Block when debug.firewire_debug > 1 Support the Bus Info Block(1394a-2000) method of speed detection. I also should note that I am moving "hold_count" to 0 for future releases. This variable determines how many bus resets to "hold" a removed firewire device before deletion. I don't feel this is useful and will probably drop support for this sysctl in the future. Reviewed by: scottl(mentor) MFC after: 2 weeks Notes: svn path=/head/; revision=188704
* Some updates and bug squashing in the firewire stack.Sean Bruno2009-02-011-36/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Move the interupt handler to a driver_intr_t type function as it was trying to do way to much for a lightweight filter interrupt function. Introduce much more locking around fc->mtx. Tested this for lock reversals and other such lockups. Locking seems to be working better, but there is much more to do with regard to locking. The most significant lock is in the BUS RESET handler. It was possible, before this checkin, to set a bus reset via "fwcontrol -r" and have the BUS RESET handler fire before the code responsible for asserting BUS RESET was complete. This locking fixes that issue. Move some of the memory allocations in the fc struct to the attach function in firewire.c Rework the businfo.generation indicator to be merely a on/off bit now. It's purpose according to spec is to notify the bus that the config ROM has changed. That's it. Catch and squash a possible panic in SBP where in the SBP_LOCK was held during a possible error case. The error handling code would definitely panic as it would try to acquire the SBP_LOCK on entrance. Catch and squash a camcontrol/device lockup when firewire drives go away. When a firewire device was powered off or disconnected from the firewire bus, a "camcontrol rescan all" would hang trying to poll removed devices as they were not properly detached. Don't do that. Approved by: scottl MFC after: 2 weeks Notes: svn path=/head/; revision=187993
* Step 1.5 of importing the network stack virtualization infrastructureMarko Zec2008-10-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | from the vimage project, as per plan established at devsummit 08/08: http://wiki.freebsd.org/Image/Notes200808DevSummit Introduce INIT_VNET_*() initializer macros, VNET_FOREACH() iterator macros, and CURVNET_SET() context setting macros, all currently resolving to NOPs. Prepare for virtualization of selected SYSCTL objects by introducing a family of SYSCTL_V_*() macros, currently resolving to their global counterparts, i.e. SYSCTL_V_INT() == SYSCTL_INT(). Move selected #defines from sys/sys/vimage.h to newly introduced header files specific to virtualized subsystems (sys/net/vnet.h, sys/netinet/vinet.h etc.). All the changes are verified to have zero functional impact at this point in time by doing MD5 comparision between pre- and post-change object files(*). (*) netipsec/keysock.c did not validate depending on compile time options. Implemented by: julian, bz, brooks, zec Reviewed by: julian, bz, brooks, kris, rwatson, ... Approved by: julian (mentor) Obtained from: //depot/projects/vimage-commit2/... X-MFC after: never Sponsored by: NLnet Foundation, The FreeBSD Foundation Notes: svn path=/head/; revision=183550
* Commit step 1 of the vimage project, (network stack)Bjoern A. Zeeb2008-08-171-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | virtualization work done by Marko Zec (zec@). This is the first in a series of commits over the course of the next few weeks. Mark all uses of global variables to be virtualized with a V_ prefix. Use macros to map them back to their global names for now, so this is a NOP change only. We hope to have caught at least 85-90% of what is needed so we do not invalidate a lot of outstanding patches again. Obtained from: //depot/projects/vimage-commit2/... Reviewed by: brooks, des, ed, mav, julian, jamie, kris, rwatson, zec, ... (various people I forgot, different versions) md5 (with a bit of help) Sponsored by: NLnet Foundation, The FreeBSD Foundation X-MFC after: never V_Commit_Message_Reviewed_By: more people than the patch Notes: svn path=/head/; revision=181803
* - Fix panic on detach.Hidetoshi Shimokawa2008-05-101-1/+4
| | | | | | | | | - Fix a comment. MFC after: 2 weeks Notes: svn path=/head/; revision=178915
* Rename the kthread_xxx (e.g. kthread_create()) callsJulian Elischer2007-10-201-2/+2
| | | | | | | | | | | | | | to kproc_xxx as they actually make whole processes. Thos makes way for us to add REAL kthread_create() and friends that actually make theads. it turns out that most of these calls actually end up being moved back to the thread version when it's added. but we need to make this cosmetic change first. I'd LOVE to do this rename in 7.0 so that we can eventually MFC the new kthread_xxx() calls. Notes: svn path=/head/; revision=172836
* Protect transaction labels by its own lock to reduce lock contention.Hidetoshi Shimokawa2007-07-201-12/+16
| | | | | | | Approved by: re (rwatson) Notes: svn path=/head/; revision=171513
* Improve acquisition of transaction labels.Hidetoshi Shimokawa2007-07-151-20/+16
| | | | | | | | | | | - Keep last transaction label for each destination. - If the next label is not free, just give up. - This should reduce CPU load for TX on if_fwip under heavy load. Approved by: re (hrs) Notes: svn path=/head/; revision=171457
* Fix a bug of retrieving configuration ROM.Hidetoshi Shimokawa2007-07-081-2/+2
| | | | | | | | | | | | | - Handle directories and leaves other than unit directories and text leaves correctly. - Now we can retrieve CROM of iSight correctly. Approved by: re (hrs) Tested by: flz MFC after: 3 days Notes: svn path=/head/; revision=171302
* Timestamp after sent.Hidetoshi Shimokawa2007-06-081-4/+3
| | | | Notes: svn path=/head/; revision=170427
* Fix a race after a bus reset.Hidetoshi Shimokawa2007-06-081-11/+12
| | | | | | | | - We are in FWBUSINIT state just after SID interrupt. - Do not pass normal xfers before bus probe is done. Notes: svn path=/head/; revision=170425
* MFp4: MPSAFE firewire stack.Hidetoshi Shimokawa2007-06-061-69/+214
| | | | | | | | | | | | | | | | - 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() Notes: svn path=/head/; revision=170374
* Make sure fwsid is not NULL.Hidetoshi Shimokawa2007-05-211-1/+3
| | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=169829
* MFp4: Simplify the bus probe routin using a kthread.Hidetoshi Shimokawa2007-05-211-335/+236
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=169806
* MFp4:Hidetoshi Shimokawa2007-04-301-9/+11
| | | | | | | | | | - Update state in fw_xferq_dorain() after removed from the send queue. - Remove unnecessary 'goto err;". MFC after: 1 week Notes: svn path=/head/; revision=169131
* MFp4: Fix broken userland API for async packets.Hidetoshi Shimokawa2007-04-301-54/+45
| | | | | | | | | | | - Introduce fw_xferlist_add/remove(). - Introduce fw_read/write_async(). - Remove unused FWACT_CH. MFC after: 1 week Notes: svn path=/head/; revision=169130
* MFp4: Fix typo in recv spd.Hidetoshi Shimokawa2007-04-301-1/+1
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=169127
* MFp4: remove unused fw_asybusy().Hidetoshi Shimokawa2007-04-301-14/+0
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=169122
* MFp4: Simplify tlabel handlingHidetoshi Shimokawa2007-04-301-33/+27
| | | | | | | | | | | - Remove struct tl_label and runtime malloc() for it. - Include tl_lable list in struct fw_xfer. - Don't free unallocated tlabel. MFC after: 1 week Notes: svn path=/head/; revision=169119
* Initialize configuration ROM before a bus reset.Hidetoshi Shimokawa2007-04-301-2/+3
| | | | | | | MFC: after 3 days Notes: svn path=/head/; revision=169117
* Free tlabel in fw_xfer_done().Hidetoshi Shimokawa2007-03-301-2/+1
| | | | Notes: svn path=/head/; revision=168051
* - Don't call fw_busreset() in firewire_attach().Hidetoshi Shimokawa2007-03-301-1/+0
| | | | | | | | | | This should fix the problem that the first bus reset is sometimes ignored because of FWBUSRESET status. MFC after: 3 days Notes: svn path=/head/; revision=168050
* Replace xfer->act.hand with xfer->hand.Hidetoshi Shimokawa2007-03-161-16/+16
| | | | Notes: svn path=/head/; revision=167632
* Remove retry_count.Hidetoshi Shimokawa2007-03-161-1/+0
| | | | Notes: svn path=/head/; revision=167631