Commit graph

23 commits

Author SHA1 Message Date
Andrew Gallatin 13a5a46c49 Fix new users of MAXPHYS and hide it from the kernel namespace
In cd85379104, kib made maxphys a load-time tunable.  This made
the #define MAXPHYS in sys/param.h  almost entirely obsolete, as
it could now be overridden by kern.maxphys at boot time, or by
opt_maxphys.h.

However, decades of tradition have led to several new, incorrect, uses
of MAXPHYS in other parts of the kernel, mostly by seasoned
developers.  I've corrected those uses here in a mechanical fashion,
and verified that it fixes a bug in the md driver that I was
experiencing.

Since using MAXPHYS is such an easy mistake to make, it is best to
hide it from the kernel namespace.  So I've moved its definition to
_maxphys.h, which is now included in param.h only for userspace.

That brings up the fact that lots of userspace programs use MAXPHYS
for different reasons, most of them probably wrong.  Userspace consumers
that really need to know the value of maxphys should probably be
changed to use the kern.maxphys sysctl.  But that's outside the scope
of this change.

Reviewed by: imp, jkim, kib, markj
Fixes: 30038a8b4e ("md: Get rid of the pbuf zone")
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D44986
2024-04-30 15:29:06 -04:00
Warner Losh fdafd315ad sys: Automated cleanup of cdefs and other formatting
Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by:		Netflix
2023-11-26 22:24:00 -07:00
Warner Losh 685dc743dc sys: Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:54:36 -06:00
Warner Losh 95ee2897e9 sys: Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
2023-08-16 11:54:11 -06:00
Warner Losh 4d846d260e 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
2023-05-12 10:44:03 -06:00
Henri Hennebert 71883128e5 rtsx: Add plug-and-play info
Add MODULE_PNP_INFO() to the driver to make it autoload if not linked
statically into the kernel. Remove the device from amd64/i386 GENERIC.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D35074
2023-04-13 11:12:50 -03:00
Elliott Mitchell 263261e519 rtsx: purge EOL release compatibility
Remove support for FreeBSD 11 and earlier

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/603
Differential Revision: https://reviews.freebsd.org/D35560
2023-02-04 09:13:09 -07:00
John Baldwin 03cfce6f73 rtsx: Remove unused devclass argument to DRIVER_MODULE. 2022-05-06 15:46:56 -07:00
Henri Hennebert 8290c14420 rtsx: Number of tweaks for RTS5260.
MFC after:	2 weeks
2022-04-26 21:43:17 -04:00
Henri Hennebert 2e88306786 rtsx: Remove update of softc during probe and some var rename.
MFC after:	1 week
2022-03-25 15:24:49 -04:00
Henri Hennebert 9b261d2e0a rtsx: Display error if rtsx_read()/rtsx_write() fail.
MFC after:	1 week
2022-03-23 21:01:00 -04:00
Henri Hennebert 6b7718377b rtsx: Don't detach during shutdown
MFC after:	1 week
2022-03-23 20:58:38 -04:00
hlh-restart 1b1bab0078 rtsx: Call rtsx_init() on resume.
MFC after:	3 days
2022-03-19 12:37:24 -04:00
Henri Hennebert 577130e56e rtsx: Add RTS5260 support and replace bootverbose with sysctl.
Tested by:	mav
MFC after:	4 days
Differential Revision:	https://reviews.freebsd.org/D34246
2022-02-19 11:46:40 -05:00
Henri Hennebert ad494d3b2d rtsx: Update driver version number to 2.1c
Differential Revision:	https://reviews.freebsd.org/D32154
2022-02-03 18:43:13 -05:00
Henri Hennebert 1e800a5934 rtsx: Do not display pci_read_config() errors during rtsx_init()
Differential Revision:	https://reviews.freebsd.org/D32154
2022-02-03 18:43:13 -05:00
Henri Hennebert ec1f122b56 rtsx: Add CTLFLAG_STATS flag for read and write counters
Differential Revision:	https://reviews.freebsd.org/D32154
2022-02-03 18:43:12 -05:00
Henri Hennebert 7e5933b333 rtsx: Prefer __FreeBSD_version over __FreeBSD__
No functional change.

Differential Revision:	https://reviews.freebsd.org/D32154
2022-02-03 18:43:12 -05:00
Henri Hennebert 8e9740b62e rtsx: Convert driver to use the mmc_sim interface
A lot more generic cam related things were done in mmc_sim so this
simplifies the driver a lot.

Differential Revision:	https://reviews.freebsd.org/D32154
Reviewed by:		imp
2022-02-03 18:43:12 -05:00
Henri Hennebert 9d3bc16382 rtsx: Call taskqueue sooner, adjust DELAY(9) calls, add an inversion heuristic
- Some configurations, e.g. HP EliteBook 840 G3, come with a dummy card
in the card slot which is detected as a valid SD card.  This added long
timeout at boot time.  To alleviate the problem, the default timeout is
reduced to one second during the setup phase. [1]

- Some configurations crash at boot if rtsx(4) is defined in the kernel
config.  At boot time, without a card inserted, the driver found that
a card is present and just after that a "spontaneous" interrupt is
generated showing that no card is present.  To solve this problem,
DELAY(9) is set to one quarter of a second before checking card presence
during driver attach.

- As advised by adrian, taskqueue and DMA are set up sooner during
the driver attach.  A heuristic to try to detect configuration needing
inversion was added.

PR:		255130 [1]
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D30499
2021-09-09 14:26:17 -04:00
Gordon Bergling 5bdf58e196 Fix some common typos in source code comments
- s/priviledged/privileged/
- s/funtion/function/
- s/doens't/doesn't/
- s/sychronization/synchronization/

MFC after:	3 days
2021-08-28 18:57:23 +02:00
Warner Losh 9339e7c0bd rtsx: Fix wakeup race similar to sdhci one fixed in 35547df5c7
rtsx copied code from sdhci, and has the same wakeup race bug that was
fixed in 35547df5c7, so apply a similar fix here.

Sponsored by:		Netflix
2021-08-10 17:10:25 -06:00
Jung-uk Kim 926ce35a7e Port rtsx(4) driver for Realtek SD card reader from OpenBSD.
This driver provides support for Realtek PCI SD card readers.  It attaches
mmc(4) bus on card insertion and detaches it on card removal.  It has been
tested with RTS5209, RTS5227, RTS5229, RTS522A, RTS525A and RTL8411B.  It
should also work with RTS5249, RTL8402 and RTL8411.

PR:			204521
Submitted by:		Henri Hennebert (hlh at restart dot be)
Reviewed by:		imp, jkim
Differential Revision:	https://reviews.freebsd.org/D26435
2020-11-24 21:28:44 +00:00