Commit Graph

145 Commits

Author SHA1 Message Date
Pawel Biernacki
7029da5c36 Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many)
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
2020-02-26 14:26:36 +00:00
Olivier Cochard
16f9d2f3b8 Fix a minor typo
Approved by:	lwhsu
MFC after:	1 month
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D19970
2019-09-24 16:49:42 +00:00
Conrad Meyer
e2e050c8ef Extract eventfilter declarations to sys/_eventfilter.h
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.
2019-05-20 00:38:23 +00:00
Warner Losh
a7db1b744a Fix a race between setting up the interrupt handler and it firing by
setting the data prior to setting up the interrupt. Now we only set
the cookie afterwards, and that (a) cannot be helpd and (b) isn't used
in the ISR.

PR: 147127
Submitted by: hps@
2019-01-07 06:19:51 +00:00
Warner Losh
d21a52ae1b pccard: recode to use devctl_safe_quote_sb instead of devctl_safe_quote.
Sponsored by: Netflix
Differential Review: https://reviews.freebsd.org/D16026
2018-06-27 04:11:14 +00:00
Warner Losh
4e96c99bdf Push down Giant one layer. In the days of yore, back when Penitums
were the new kids on the block and F00F hacks were all the rage, one
needed to take out Giant to do anything moderately complicated with
the VM, mappings and such. So the pccard / cardbus code held Giant for
the entire insertion or removal process.

Today, the VM is MP safe. The lock is only needed for dealing with
newbus things. Move locking and unlocking Giant to be only around
adding and probing devices in pccard and cardbus.
2018-03-20 22:01:18 +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
Pedro F. Giffuni
4d24901ac9 sys/dev: Replace zero with NULL for pointers.
Makes things easier to read, plus architectures may set NULL to something
different than zero.

Found with:	devel/coccinelle
MFC after:	3 weeks
2017-02-20 03:43:12 +00:00
Warner Losh
cb49b65481 Move pccard_safe_quote() up to subr_bus.c and rename to
devctl_safe_quote() so it can be used more generally.
2016-03-28 20:16:29 +00:00
Justin Hibbits
da1b038af9 Use uintmax_t (typedef'd to rman_res_t type) for rman ranges.
On some architectures, u_long isn't large enough for resource definitions.
Particularly, powerpc and arm allow 36-bit (or larger) physical addresses, but
type `long' is only 32-bit.  This extends rman's resources to uintmax_t.  With
this change, any resource can feasibly be placed anywhere in physical memory
(within the constraints of the driver).

Why uintmax_t and not something machine dependent, or uint64_t?  Though it's
possible for uintmax_t to grow, it's highly unlikely it will become 128-bit on
32-bit architectures.  64-bit architectures should have plenty of RAM to absorb
the increase on resource sizes if and when this occurs, and the number of
resources on memory-constrained systems should be sufficiently small as to not
pose a drastic overhead.  That being said, uintmax_t was chosen for source
clarity.  If it's specified as uint64_t, all printf()-like calls would either
need casts to uintmax_t, or be littered with PRI*64 macros.  Casts to uintmax_t
aren't horrible, but it would also bake into the API for
resource_list_print_type() either a hidden assumption that entries get cast to
uintmax_t for printing, or these calls would need the PRI*64 macros.  Since
source code is meant to be read more often than written, I chose the clearest
path of simply using uintmax_t.

Tested on a PowerPC p5020-based board, which places all device resources in
0xfxxxxxxxx, and has 8GB RAM.
Regression tested on qemu-system-i386
Regression tested on qemu-system-mips (malta profile)

Tested PAE and devinfo on virtualbox (live CD)

Special thanks to bz for his testing on ARM.

Reviewed By: bz, jhb (previous)
Relnotes:	Yes
Sponsored by:	Alex Perez/Inertial Computing
Differential Revision: https://reviews.freebsd.org/D4544
2016-03-18 01:28:41 +00:00
Justin Hibbits
534ccd7bbf Replace all resource occurrences of '0UL/~0UL' with '0/~0'.
Summary:
The idea behind this is '~0ul' is well-defined, and casting to uintmax_t, on a
32-bit platform, will leave the upper 32 bits as 0.  The maximum range of a
resource is 0xFFF.... (all bits of the full type set).  By dropping the 'ul'
suffix, C type promotion rules apply, and the sign extension of ~0 on 32 bit
platforms gets it to a type-independent 'unsigned max'.

Reviewed By: cem
Sponsored by:	Alex Perez/Inertial Computing
Differential Revision: https://reviews.freebsd.org/D5255
2016-03-03 05:07:35 +00:00
Justin Hibbits
c47476d7e6 Migrate many bus_alloc_resource() calls to bus_alloc_resource_anywhere().
Most calls to bus_alloc_resource() use "anywhere" as the range, with a given
count.  Migrate these to use the new bus_alloc_resource_anywhere() API.

Reviewed by:	jhb
Differential Revision:	https://reviews.freebsd.org/D5370
2016-02-27 03:38:01 +00:00
Justin Hibbits
7915adb560 Introduce a RMAN_IS_DEFAULT_RANGE() macro, and use it.
This simplifies checking for default resource range for bus_alloc_resource(),
and improves readability.

This is part of, and related to, the migration of rman_res_t from u_long to
uintmax_t.

Discussed with:	jhb
Suggested by:	marcel
2016-02-20 01:32:58 +00:00
Justin Hibbits
2dd1bdf183 Convert rman to use rman_res_t instead of u_long
Summary:
Migrate to using the semi-opaque type rman_res_t to specify rman resources.  For
now, this is still compatible with u_long.

This is step one in migrating rman to use uintmax_t for resources instead of
u_long.

Going forward, this could feasibly be used to specify architecture-specific
definitions of resource ranges, rather than baking a specific integer type into
the API.

This change has been broken out to facilitate MFC'ing drivers back to 10 without
breaking ABI.

Reviewed By: jhb
Sponsored by:	Alex Perez/Inertial Computing
Differential Revision: https://reviews.freebsd.org/D5075
2016-01-27 02:23:54 +00:00
Hans Petter Selasky
af3b2549c4 Pull in r267961 and r267973 again. Fix for issues reported will follow. 2014-06-28 03:56:17 +00:00
Glen Barber
37a107a407 Revert r267961, r267973:
These changes prevent sysctl(8) from returning proper output,
such as:

 1) no output from sysctl(8)
 2) erroneously returning ENOMEM with tools like truss(1)
    or uname(1)
 truss: can not get etype: Cannot allocate memory
2014-06-27 22:05:21 +00:00
Hans Petter Selasky
3da1cf1e88 Extend the meaning of the CTLFLAG_TUN flag to automatically check if
there is an environment variable which shall initialize the SYSCTL
during early boot. This works for all SYSCTL types both statically and
dynamically created ones, except for the SYSCTL NODE type and SYSCTLs
which belong to VNETs. A new flag, CTLFLAG_NOFETCH, has been added to
be used in the case a tunable sysctl has a custom initialisation
function allowing the sysctl to still be marked as a tunable. The
kernel SYSCTL API is mostly the same, with a few exceptions for some
special operations like iterating childrens of a static/extern SYSCTL
node. This operation should probably be made into a factored out
common macro, hence some device drivers use this. The reason for
changing the SYSCTL API was the need for a SYSCTL parent OID pointer
and not only the SYSCTL parent OID list pointer in order to quickly
generate the sysctl path. The motivation behind this patch is to avoid
parameter loading cludges inside the OFED driver subsystem. Instead of
adding special code to the OFED driver subsystem to post-load tunables
into dynamically created sysctls, we generalize this in the kernel.

Other changes:
- Corrected a possibly incorrect sysctl name from "hw.cbb.intr_mask"
to "hw.pcic.intr_mask".
- Removed redundant TUNABLE statements throughout the kernel.
- Some minor code rewrites in connection to removing not needed
TUNABLE statements.
- Added a missing SYSCTL_DECL().
- Wrapped two very long lines.
- Avoid malloc()/free() inside sysctl string handling, in case it is
called to initialize a sysctl from a tunable, hence malloc()/free() is
not ready when sysctls from the sysctl dataset are registered.
- Bumped FreeBSD version to indicate SYSCTL API change.

MFC after:	2 weeks
Sponsored by:	Mellanox Technologies
2014-06-27 16:33:43 +00:00
Warner Losh
96eb909a84 Simplify resource activation a bit. 2012-06-28 07:26:44 +00:00
Ed Schouten
6472ac3d8a Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs.
The SYSCTL_NODE macro defines a list that stores all child-elements of
that node. If there's no SYSCTL_DECL macro anywhere else, there's no
reason why it shouldn't be static.
2011-11-07 15:43:11 +00:00
Warner Losh
54e397e566 Make a couple of debug printfs DEVPRINTF. 2011-06-06 16:27:38 +00:00
Warner Losh
96a31ac3e8 Add in parsing of the disk FUNCE tuples. 2009-03-03 18:57:59 +00:00
Wojciech A. Koszek
1e9e2b22b8 Bring consistent debugging output for all values that are supposed
to be printed in a hexadecimal format. Otherwise, '270' doesn't say
much.

Reviewed by:	imp
2009-02-05 23:51:11 +00:00
Warner Losh
73e04c0b84 Fix parameter types for set_res_flags and read_ivars 2009-02-05 19:38:31 +00:00
Warner Losh
0e66b169d6 Fix a small problem in the comment about departure from NetBSD.
Also, r181392 fixed a small problem with multifunction cards that would
cause the card not to power down when the last driver detached from it.
2008-08-07 21:16:14 +00:00
Warner Losh
431b127e40 Add NEC PC-9802N-J02 (confirmed) and NEC PC-9202N-J02R (speculative)
to the list of devices.
2008-08-07 20:52:54 +00:00
Warner Losh
69e401fe28 Unify the initial card probe/attach procedure with the kldload
procedure.  There were some subtle differences before that could lead
to a variety of bugs, including resources being lost (in one case
forever).  pccard_probe_and_attach_card does this now, and includes
comments about what's going on and why, since it isn't obvious from
the code.  Please let me know if I've missed anything...

Provide a new function called pccard_select_cfe that allows drivers to
select which configuration entry to use.  This is needed for some
older pre-MFC standard cards with many functions that want to activate
all their functions by selecting alternative entries, or to work
around broken ones.  pccard_select_cfe will migrate into the
pccard_if.m interface as its interface stabilizes to keep all the
pccard drivers from referencing any symbols in the pccard.ko module
directly.

Fix a printf to refer to the right function name.
2008-08-06 07:34:35 +00:00
Warner Losh
fab38de2d3 only register a ithread handler if the card requests an ithread
handler.
2007-06-16 23:33:57 +00:00
Paolo Pisati
97caddeea2 Make the interrupt handler wrapper capable of correctly support filter+ithread handler.
Discussed and reviewed with: bsdimp, simokawa
2007-05-31 19:29:20 +00:00
Paolo Pisati
ef544f6312 o break newbus api: add a new argument of type driver_filter_t to
bus_setup_intr()

o add an int return code to all fast handlers

o retire INTR_FAST/IH_FAST

For more info: http://docs.freebsd.org/cgi/getmsg.cgi?fetch=465712+0+current/freebsd-current

Reviewed by: many
Approved by: re@
2007-02-23 12:19:07 +00:00
Warner Losh
8ccfb0607f We need to free the ivars for the child that we just deleted. 2007-02-03 07:09:36 +00:00
Warner Losh
c171ec35b6 When pccard_safe_quote is passed NULL for src, it shouldn't panic.
Someone sent me this a while ago, but I can't find who to give them
proper credit...
2006-04-27 20:47:13 +00:00
Warner Losh
df2f828a8f Add some sanity checking to the pccard insertion case. Whine if the
bridge tries to tell us about a new card when we have one already in
the socket.
2005-12-28 05:30:09 +00:00
Warner Losh
6242d774d9 Remove compat layer for OLDCARD compatibility. All instances of it
are now gone from the tree.
2005-09-22 14:51:11 +00:00
Warner Losh
255e4915dc remove some dead code 2005-09-20 19:34:10 +00:00
Warner Losh
73cac3387f Implement /dev/pccardN.cis. This mirrors the CIS for the card to userland.
pccardc dumpcis /dev/pccardN.cis will work now, but I may rewrite pccardc.

Also, move more of the private data to a new file called pccardvarp.h.
2005-09-20 06:47:33 +00:00
Warner Losh
fe364ce963 Add a few new functions interfaces to allow reading/writing attribute
memory, the CCR and a tweak to cis_scan.
2005-09-13 17:56:36 +00:00
Warner Losh
395fee2331 Define and use PCCARD_MEM_PAGE_SIZE. 2005-09-13 17:49:47 +00:00
Warner Losh
faf98cda63 Insert missing int i; 2005-07-15 01:43:08 +00:00
Warner Losh
2bb5d7f9ac Also provide the function type in the nomatch routine. 2005-07-14 20:40:42 +00:00
Warner Losh
e6e34c5689 o Check to make sure the card has a function (panic if not) in read_ivar.
o Use pf more consistantly for pccard_function.
o Make sure we quote the strings properly (maybe this function belongs in
  subr_bus.c)
o Tweak a comment to be more accurate after code changed.
2005-07-13 15:00:59 +00:00
Warner Losh
26db48b9b2 Add a much-requested feature: The ability for pccard attachments to
scan the CIS for interesting tuples.  95% of what can be obtained from
the CIS is harvested by the pccard layer and presented to the user in
standard function calls.  However, there are special needs at times
where the standard stuff doesn't suffice.  This is for those special
cases.

CARD_SCAN_CIS(device_get_parent(dev), function, argp)
	scans the CIS of the card, passing each tuple to function with
	the tuple and argp as its arguments.  Returning 0 continues the scan,
	while returning 1 terminates the scan.  The value of the last
	invocation of function is returned from this function.

int (*pccard_scan_t)(struct pccard_tuple *tuple, void *argp)
	function called for each tuple.  Elements of the CIS tuple can be
	read with pccard_tuple_read_{1,2,3,4,n}().  You are reading
	the actual tuple memory each time, in case your card has
	registers in the CIS.

# I suppose these things should be documented in pccard(4) or something like
# that.

# I plan on unifying cardbus CIS support in a similar way.

Approved by: re (scottl)
2005-07-01 03:40:28 +00:00
Warner Losh
2bf7a0e949 Big cleanup of resource code for pccard. Once coventry noticed
problems here, it became clear we were being too complex.

o Don't keep track of resources in two places
o Use resource_list_purge instead of rolling our own
o Just reassign the ownership of the resource, rather than freeing it
  and reallocating it.
o Fix compile problems when sizeof(u_long) != sizeof(int)
2005-04-12 15:25:31 +00:00
Warner Losh
1a3f777ef4 Cleanup of resource allocation code after having my attention focused on
this code:
o rid is stored in the resource, so don't bother keeping track of it here.
o Implement memory space
o Don't try to activate 'memory card' CFEs.  This is type memory, as opposed
  to the memory resource.
2005-04-12 06:00:06 +00:00
Warner Losh
a3e2432858 Use return value of resource_list_add to avoid a second
resource_list_find.  Check to make sure that rle is not NULL and panic
if it is (but it appears that resource_list_add already panics, so I'm
not entirely sure it is necessary now).

Add a test to make sure we have a interrupt resource when we're
disabling it.  This is also a cannot happen, but the extra care
shoudln't hurt.

Found by: Coventry tool via sam@
2005-04-12 04:30:35 +00:00
Warner Losh
3eafe746ab Need to initialize the resource list that we keep for our children.
STAILQ's require this, while it is optional for SLIST (well, as long
as the memory is bzeroed).

Noticed by: phk's crash
2005-03-18 16:37:51 +00:00
Warner Losh
36fed96550 Use STAILQ in preference to SLIST for the resources. Insert new resources
last in the list rather than first.

This makes the resouces print in the 4.x order rather than the 5.x order
(eg fdc0 at 0x3f0-0x3f5,0x3f7 is 4.x, but 0x3f7,0x3f0-0x3f5 is 5.x).  This
also means that the pci code will once again print the resources in BAR
ascending order.
2005-03-18 05:19:50 +00:00
Warner Losh
1a0c32073e Add an XXX comment about string quoting. 2005-02-16 01:03:30 +00:00
Warner Losh
d4c6cdea21 Ignore the expected function number.
NetBSD went this route a while ago.  FreeBSD originally tried this to
cope with multifunction cards.  However, it turns out that we're
better off not worrying about the function number, and instead worry
about the function type for the function.  This has worked well in
NetBSD, and all FreeBSD's relevant drivers have been converted.

# I'll rework the macros that specify them shortly, as soon as I can
# come up with a good, compatible way to deal...
2005-01-24 06:54:05 +00:00
Warner Losh
7d57300f4c u_intXX_t -> uintXX_t 2005-01-24 06:48:26 +00:00
Warner Losh
b72e9f1719 Fix spelling error
submitted by: Anders Hanssen
2005-01-19 20:21:44 +00:00