History log of /freebsd-current/sys/dev/usb/usb_busdma.c
Revision Date Author Comments
# 71625ec9 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

sys: Remove $FreeBSD$: one-line .c comment pattern

Remove /^/[*/]\s*\$FreeBSD\$.*\n/


# 4d846d26 10-May-2023 Warner Losh <imp@FreeBSD.org>

spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD

The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix


# dfd37770 07-Sep-2022 Gordon Bergling <gbe@FreeBSD.org>

net80211(4): Bring back an accidently reverted grammar correction

- s/that that/that/

Reported by: se, danfe
MFC after: 3 days


# 94466c43 04-Sep-2022 Gordon Bergling <gbe@FreeBSD.org>

Revert "usb: Remove a double words in a source code comments"

This reverts commit 8ca67bf1273a5168f8a3787183159c477632e582.

The original comment was correct; changing it loses a key part.

Reported by: jrtc27


# 8ca67bf1 04-Sep-2022 Gordon Bergling <gbe@FreeBSD.org>

usb: Remove a double words in a source code comments

- s/that that/that/

MFC after: 3 days


# dc91a971 28-Sep-2021 Ian Lepore <ian@FreeBSD.org>

Fix busdma resource leak on usb device detach.

When a usb device is detached, usb_pc_dmamap_destroy() called
bus_dmamap_destroy() while the map was still loaded. That's harmless on x86
architectures, but on all other platforms it causes bus_dmamap_destroy() to
return EBUSY and leak away any memory resources (including bounce buffers)
associated with the mapping, as well as any allocated map structure itself.

This change introduces a new is_loaded flag to the usb_page_cache struct to
track whether a map is loaded or not. If the map is loaded,
bus_dmamap_unload() is called before bus_dmamap_destroy() to avoid leaking
away resources.

MFC after: 7 days
Differential Revision: https://reviews.freebsd.org/D32208


# a1581cd7 14-Aug-2021 Gordon Bergling <gbe@FreeBSD.org>

Fix a common typo in source code comments

- s/aligment/alignment/

MFC after: 5 days


# 9dd3156e 01-Sep-2020 Mateusz Guzik <mjg@FreeBSD.org>

usb: clean up empty lines in .c and .h files


# 718cf2cc 27-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

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.


# 3e85b721 16-May-2017 Ed Maste <emaste@FreeBSD.org>

Remove register keyword from sys/ and ANSIfy prototypes

A long long time ago the register keyword told the compiler to store
the corresponding variable in a CPU register, but it is not relevant
for any compiler used in the FreeBSD world today.

ANSIfy related prototypes while here.

Reviewed by: cem, jhb
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D10193


# 0eb8d462 13-Sep-2016 Hans Petter Selasky <hselasky@FreeBSD.org>

Improve USB polling mode by not locking any mutexes, asserting any
mutexes or using any callouts when active.

Trying to lock a mutex when KDB is active or the scheduler is stopped
can result in infinite wait loops. The same goes for calling callout
related functions which in turn lock mutexes.

If the USB controller at which a USB keyboard is connected is idle
when KDB is entered, polling the USB keyboard via USB will always
succeed. Else polling may fail depending on which state the USB
subsystem and USB interrupt handler is in. This is unavoidable unless
KDB can wait for USB interrupt threads to complete before stalling the
CPU(s).

Tested by: Bruce Evans <bde@freebsd.org>
MFC after: 4 weeks


# d9c9c81c 21-Apr-2016 Pedro F. Giffuni <pfg@FreeBSD.org>

sys: use our roundup2/rounddown2() macros when param.h is available.

rounddown2 tends to produce longer lines than the original code
and when the code has a high indentation level it was not really
advantageous to do the replacement.

This tries to strike a balance between readability using the macros
and flexibility of having the expressions, so not everything is
converted.


# 288edd19 29-Mar-2016 Hans Petter Selasky <hselasky@FreeBSD.org>

Verify that all segments in the loaded segment list are back to back
with regard to the page offset, and not only the two first ones.


# c6b6f546 07-Nov-2015 Hans Petter Selasky <hselasky@FreeBSD.org>

Add helper function to check if a USB page cache buffer is properly
aligned to reduce the use of bounce buffers in PIO mode.

MFC after: 1 week


# a2aa9beb 03-Nov-2015 Hans Petter Selasky <hselasky@FreeBSD.org>

Relax the BUS_DMA_KEEP_PG_OFFSET requirement to allow optimising
allocation of DMA bounce buffers.

Discussed with: ian @
MFC after: 3 weeks


# 5fb878a9 05-Feb-2014 Hans Petter Selasky <hselasky@FreeBSD.org>

Fix a regression issue. Contiguous single segment allocations above
PAGE_SIZE bytes should only use one USB page structure. Fixes a
problem with some external drivers.

MFC after: 2 days


# bce421e9 05-Dec-2013 Hans Petter Selasky <hselasky@FreeBSD.org>

Fix external compiler warning about write-only assigned variable.


# d2b99310 30-Jan-2013 Hans Petter Selasky <hselasky@FreeBSD.org>

Modify the FreeBSD USB kernel code so that it can be compiled directly
into the FreeBSD boot loader, typically for non-USB aware BIOSes, EFI systems
or embedded platforms. This is also useful for out of the system compilation
of the FreeBSD USB stack for various purposes. The USB kernel files can
now optionally include a global header file which should include all needed
definitions required to compile the FreeBSD USB stack. When the global USB
header file is included, no other USB header files will be included by
default.

Add new file containing the USB stack configuration for the
FreeBSD loader build.

Replace some __FBSDID()'s by /* $FreeBSD$ */ comments. Now all
USB files follow the same style.

Use cases:
- console in loader via USB
- loading kernel via USB

Discussed with: Hiroki Sato, hrs @ EuroBSDCon


# b7b11d00 27-Jan-2013 Hans Petter Selasky <hselasky@FreeBSD.org>

Fix regression issue after r244500 and r244503:

If a BUSDMA load operation results in a single segment which
is greater than the PAGE_SIZE, the USB computed physical
addresses will not be correct. Make sure that the first
segment is unfolded like the sub-sequent segments are into
USB_PAGE_SIZE big ranges.

Found by: Alexander Nedotsukov
MFC after: 1 week


# 1a7c3e90 21-Dec-2012 Hans Petter Selasky <hselasky@FreeBSD.org>

Regression issue:
Use a boundary of zero, hence a PAGE_SIZE boundary
is implied by all memory allocations.

Background:
Busdma has problems to allocate more than PAGE_SIZE
bytes when the boundary is PAGE_SIZE bytes too.
Initially it was thought that a boundary of PAGE_SIZE
bytes will only affect loading of DMA memory, so that
segments get split correctly, but it also affects
allocation of DMA'able memory.

Solution:
USB can detect big segments and split them as required
by the USB code.

MFC after: 1 week
Reported by: gonzo


# 6d917491 02-Apr-2012 Hans Petter Selasky <hselasky@FreeBSD.org>

Fix compiler warnings, mostly signed issues,
when USB modules are compiled with WARNS=9.

MFC after: 1 weeks


# 271ae033 12-Nov-2011 Hans Petter Selasky <hselasky@FreeBSD.org>

Style change.
- Make it easier to port the USB code to other platforms by only using
one set of memory functions for clearing and copying memory. None of
the memory copies are overlapping. This means using bcopy() is not
required.
- Fix a compile warning when USB_HAVE_BUSDMA=0
- Add missing semicolon in avr32dci.
- Update some comments.

MFC after: 1 week


# 58ccf5b4 11-Jan-2011 John Baldwin <jhb@FreeBSD.org>

Remove unneeded includes of <sys/linker_set.h>. Other headers that use
it internally contain nested includes.

Reviewed by: bde


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# 6c3c4d71 14-Sep-2010 Marius Strobl <marius@FreeBSD.org>

Use saner nsegments and maxsegsz parameters when creating certain DMA tags;
tags for 1-byte allocations cannot possibly be split across 2 segments and
maxsegsz must not exceed maxsize.


# af0cbe00 10-Jun-2010 Marcel Moolenaar <marcel@FreeBSD.org>

Revert rev. 208882.


# 65e93cbe 06-Jun-2010 Marcel Moolenaar <marcel@FreeBSD.org>

Don't call bus_dmamap_sync() with a NULL dmamap.


# c1b5138f 09-Dec-2009 Andrew Thompson <thompsa@FreeBSD.org>

MFC r199816

Remove overuse of exclamation marks in kernel printfs, there mere fact a
message has been printed is enough to get someones attention. Also remove the
line number for DPRINTF/DPRINTFN, it already prints the funtion name and a
unique message.


# 767cb2e2 25-Nov-2009 Andrew Thompson <thompsa@FreeBSD.org>

Remove overuse of exclamation marks in kernel printfs, there mere fact a
message has been printed is enough to get someones attention. Also remove the
line number for DPRINTF/DPRINTFN, it already prints the funtion name and a
unique message.


# f18778a4 29-Oct-2009 Andrew Thompson <thompsa@FreeBSD.org>

MFC r196496

Add a reminder comment to optimize bus_dmamap_sync calls.


# f2db024f 23-Aug-2009 Alfred Perlstein <alfred@FreeBSD.org>

Add a reminder comment to optimize bus_dmamap_sync calls.

Submitted by: hps


# 49d96dc6 19-Aug-2009 Rafal Jaworowski <raj@FreeBSD.org>

MFC r196380

Fix USB cache sync operations for platforms with non-coherent DMA.

- usb_pc_cpu_invalidate() is called between [consecutive] reads from a device,
so a sequence of BUS_DMASYNC_POSTREAD and _PREREAD should be used. Note we
cannot use or'ed shorthand ( _POSTREAD | _PREREAD) for BUS_DMASYNC flags, as
the low level bus dma sync operation is implementation dependent and we
cannot assume the required order of operations to be guaranteed.

- usb_pc_cpu_flush() is called before writing to a device, so
BUS_DMASYNC_PREWRITE should be used.

Submitted by: Grzegorz Bernacki
Reviewed by: HPS, arm@, usb@ ML
Tested by: HPS, Mike Tancsa
Approved by: re (kib)
Obtained from: Semihalf


# 35d01728 19-Aug-2009 Rafal Jaworowski <raj@FreeBSD.org>

Fix USB cache sync operations for platforms with non-coherent DMA.

- usb_pc_cpu_invalidate() is called between [consecutive] reads from a device,
so a sequence of BUS_DMASYNC_POSTREAD and _PREREAD should be used. Note we
cannot use or'ed shorthand ( _POSTREAD | _PREREAD) for BUS_DMASYNC flags, as
the low level bus dma sync operation is implementation dependent and we
cannot assume the required order of operations to be guaranteed.

- usb_pc_cpu_flush() is called before writing to a device, so
BUS_DMASYNC_PREWRITE should be used.

Submitted by: Grzegorz Bernacki
Reviewed by: HPS, arm@, usb@ ML
Tested by: HPS, Mike Tancsa
Approved by: re (kib)
Obtained from: Semihalf


# 58f6d273 12-Jul-2009 Marcel Moolenaar <marcel@FreeBSD.org>

MFp4:
USB CORE: busdma improvement

For single segment allocations the boundary field
of the BUSDMA tag should be zero. Currently all
single segment allocations are less than or equal
to 4096 bytes, so the limit does not kick in. If
any single segment USB allocations would be greater
than 4K, then it would be a problem.

Approved by: re (kensmith)
Obtained from: HPS


# ed6d949a 22-Jun-2009 Andrew Thompson <thompsa@FreeBSD.org>

- Make struct usb_xfer opaque so that drivers can not access the internals
- Reduce the number of headers needed for a usb driver, the common case is just usb.h and usbdi.h


# a593f6b8 14-Jun-2009 Andrew Thompson <thompsa@FreeBSD.org>

s/usb2_/usb_|usbd_/ on all function names for the USB stack.


# 8437751d 14-Jun-2009 Andrew Thompson <thompsa@FreeBSD.org>

Remove usb2_cv_* and just use the kernel condvar implementation, it was needed
earlier since condition variables didnt work with Giant but this was fixed 10
months ago.


# f9cb546c 29-May-2009 Andrew Thompson <thompsa@FreeBSD.org>

Revert the size_t part of the last commit for the moment, this blows up the
USB_ADD_BYTES macro.


# e0a69b51 29-May-2009 Andrew Thompson <thompsa@FreeBSD.org>

s/usb2_/usb_/ on all typedefs for the USB stack.


# 760bc48e 28-May-2009 Andrew Thompson <thompsa@FreeBSD.org>

s/usb2_/usb_/ on all C structs for the USB stack.


# 3e873976 26-May-2009 Andrew Thompson <thompsa@FreeBSD.org>

Unifdef __NetBSD__ here, the usb stack as a whole doesnt support NetBSD and it
obsfucates the code.


# f29a0724 20-May-2009 Andrew Thompson <thompsa@FreeBSD.org>

- rename usb2_mode to usb_mode [1]
- change variable types to use the enum

Submitted by: Hans Petter Selasky [1]


# 578d0eff 20-Mar-2009 Andrew Thompson <thompsa@FreeBSD.org>

MFp4 //depot/projects/usb @159431,159437,159438

- start using the new USB typedefs in the USB core
- Remove usage of USB_ADD_BYTES()

Submitted by: Hans Petter Selasky


# bdc081c6 20-Mar-2009 Andrew Thompson <thompsa@FreeBSD.org>

MFp4 //depot/projects/usb@159392

Add ifdefs for making parts of usb conditional.

Submitted by: Hans Petter Selasky


# ab42e8b2 20-Mar-2009 Andrew Thompson <thompsa@FreeBSD.org>

MFp4 //depot/projects/usb @159430

- Move tunable defines into usb_core.h and dependancy towards usb_defs.h
- Leave hardcoded defines in "usb_defs.h".
- Allow overriding all tunable defines.
- Add more customisable typedefs.
- Correct maximum device number.

Submitted by: Hans Petter Selasky


# 02ac6454 23-Feb-2009 Andrew Thompson <thompsa@FreeBSD.org>

Move the new USB stack into its new home.