Commit Graph

243 Commits

Author SHA1 Message Date
Mariusz Zaborski
346483b1f1 ahci: increase timout
For some devices, like Marvell 88SE9230, it takes more time
to connect to the device. This patch introduces a special flag
that extends the timeout from around 100ms to around 500ms.

This change is based on the work of: Peter Eriksson <pen@lysator.liu.se>

PR:		243401
Reviewed by:	imp
Tested by:	dch
MFC after:	3 days
Sponsored by:	Equinix
Sponsored by:	SkunkWerks, GmbH
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D38413
2023-02-10 17:10:04 +01:00
Gordon Bergling
bc9228749c ahci(4): Fix a typo in a source code comment
- s/reqests/requests/

MFC after:	3 days
2023-01-11 10:46:58 +01:00
Alexander Motin
2a31a06bf1 Add random VMware device IDs.
Just to make dmesg look nicer there.

MFC after:	1 week
2022-10-20 10:19:24 -04:00
John Baldwin
07c15a9d35 ahci: Remove unused devclass arguments to DRIVER_MODULE. 2022-05-06 15:39:28 -07:00
John Baldwin
23802d41fa Remove unused ahci_devclass. 2022-05-06 15:39:28 -07:00
Alexander Motin
25375b1415 ahci/siis/mvs: Fix panics after 3394d4239b.
Full CCB header overwrites made frees go into wrong zones, causing
kernel panics.  Instead of copying full header use xpt_setup_ccb(),
since the only field I see used from all the header is target_id.

PR:	262263
2022-03-04 20:55:23 -05:00
Alexander Motin
9aba757e92 ahci(4): Allow enclosure emulation without hardware.
After 53f5ac1310 allowed SATA device mapping to enclosure slots,
it may have sense to provide enclosure device emulation even without
real hardware interface like SGPIO just for purposes of physical
device location tracking (still assuming straight cabling).

MFC after:	1 week
Sponsored by:	iXsystems, Inc.
2021-12-17 15:34:43 -05:00
Adrian Chadd
288a92252b ahci: Add Intel Comet Lake RAID/RST controller PCI ID
This is needed on my ASUS motherboard / Intel Comet Lake i5-10500
desktop machine.

This with some work arounds for nvme behind the RST controller
boots and works.

Reviewed by: cognet
2021-12-05 21:28:39 +00:00
Alexander Motin
dc238358f9 Add some of Intel Alder Lake device IDs.
MFC after:	1 week
2021-11-05 23:06:59 -04:00
Alexander Motin
b776de6796 Mark some sysctls as CTLFLAG_MPSAFE.
MFC after:	2 weeks
2021-08-10 20:44:27 -04:00
Warner Losh
ddfc9c4c59 newbus: Move from bus_child_{pnpinfo,location}_src to bus_child_{pnpinfo,location} with sbuf
Now that the upper layers all go through a layer to tie into these
information functions that translates an sbuf into char * and len. The
current interface suffers issues of what to do in cases of truncation,
etc. Instead, migrate all these functions to using struct sbuf and these
issues go away. The caller is also in charge of any memory allocation
and/or expansion that's needed during this process.

Create a bus_generic_child_{pnpinfo,location} and make it default. It
just returns success. This is for those busses that have no information
for these items. Migrate the now-empty routines to using this as
appropriate.

Document these new interfaces with man pages, and oversight from before.

Reviewed by:		jhb, bcr
Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D29937
2021-06-22 20:52:06 -06:00
Alexander Motin
5a8d32b53b Add IDs for ASMedia ASM116x PCIe 3.0 AHCI controllers.
MFC after:	1 week
2021-04-07 15:09:56 -04:00
Alexander Motin
006e2b2b82 Add Intel Gemini Lake AHCI ID.
Submitted by:	Dmitry Luhtionov <dmitryluhtionov@gmail.com>
MFC after:	1 week
2021-01-15 09:53:35 -05:00
Michal Meloun
6844eecfed Add basic support for Freescale LX2160A SoC.
All peripherals but the network processor are supported.
2020-12-05 12:08:37 +00:00
Konstantin Belousov
cd85379104 Make MAXPHYS tunable. Bump MAXPHYS to 1M.
Replace MAXPHYS by runtime variable maxphys. It is initialized from
MAXPHYS by default, but can be also adjusted with the tunable kern.maxphys.

Make b_pages[] array in struct buf flexible.  Size b_pages[] for buffer
cache buffers exactly to atop(maxbcachebuf) (currently it is sized to
atop(MAXPHYS)), and b_pages[] for pbufs is sized to atop(maxphys) + 1.
The +1 for pbufs allow several pbuf consumers, among them vmapbuf(),
to use unaligned buffers still sized to maxphys, esp. when such
buffers come from userspace (*).  Overall, we save significant amount
of otherwise wasted memory in b_pages[] for buffer cache buffers,
while bumping MAXPHYS to desired high value.

Eliminate all direct uses of the MAXPHYS constant in kernel and driver
sources, except a place which initialize maxphys.  Some random (and
arguably weird) uses of MAXPHYS, e.g. in linuxolator, are converted
straight.  Some drivers, which use MAXPHYS to size embeded structures,
get private MAXPHYS-like constant; their convertion is out of scope
for this work.

Changes to cam/, dev/ahci, dev/ata, dev/mpr, dev/mpt, dev/mvs,
dev/siis, where either submitted by, or based on changes by mav.

Suggested by: mav (*)
Reviewed by:	imp, mav, imp, mckusick, scottl (intermediate versions)
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D27225
2020-11-28 12:12:51 +00:00
Alexander Motin
69df0af073 Fix stupid math mistake in r366922.
MFC after:	3 days
2020-11-21 00:51:39 +00:00
Alexander Motin
06c888ecb9 Add icc (Isochronous Command Completion) ccb_ataio field.
MFC after:	1 week
2020-11-02 01:01:41 +00:00
Ruslan Bukin
9729b14985 Move the iommu stubs to a generic place, so they are available on all the
platforms.

This allows to not depend on the IOMMU macro in AHCI driver.

Requested by:	kib
Suggested by:	andrew
Reviewed by:	kib
Sponsored by:	Innovate DSbD
Differential Revision:	https://reviews.freebsd.org/D26887
2020-10-23 21:27:48 +00:00
Alexander Motin
4138a74460 Pass lower 3 bits of sector_count for FPDMA commands.
When this code was written those bits were N/A, but now the lowest bit
is Rebuild Assist Recovery Control (RARC).

MFC after:	1 month
2020-10-22 03:30:39 +00:00
Ruslan Bukin
bce74ff0ce Fix build: only set iommu buswide flag if IOMMU code is included.
Sponsored by:	Innovate DSbD
2020-10-19 22:32:36 +00:00
Ruslan Bukin
c489ab6141 Add IOMMU_BUSWIDE ahci quirk.
Some controllers use PCI function 1 as the requester ID for DMA transfers,
but the controllers are not PCI multifunction.

Set the iommu buswide flag for them. This should instruct an IOMMU driver
to use the same translation rule for all the devices and functions of
a bus.

This was discovered on the ARM Neoverse N1 System Development Platform
(ARM N1SDP).

Bug reference: https://bugzilla.kernel.org/show_bug.cgi?id=42679

Reported by:	andrew
Reviewed by:	kib, mav
Sponsored by:	Innovate DSbD
Differential Revision:	https://reviews.freebsd.org/D26857
2020-10-19 21:27:27 +00:00
Emmanuel Vadot
6b74091dd5 ahci_generic: add quirk for NXP0004 (NXP Layerscape LX2160A)
This fixes this error :
(aprobe3:ahcich3:0:15:0): NOP FLUSHQUEUE. ACB: 00 00 00 00 00 00 00 00 00 00 00 00
(aprobe3:ahcich3:0:15:0): CAM status: Command timeout
(aprobe3:ahcich3:0:15:0): Error 5, Retries exhausted

Submitted by:	Greg V <greg@unrelenting.technology>
Reviewed by:	imp, mav
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D25157
2020-09-30 17:10:49 +00:00
Mateusz Guzik
f051a2b0d5 ahci: clean up empty lines in .c and .h files 2020-09-01 21:36:40 +00:00
Alexander Motin
32e50ae464 Add Intel Apollo Lake AHCI ID.
Submitted by:	Dmitry Luhtionov <dmitryluhtionov@gmail.com>
MFC after:	1 week
2020-08-06 15:17:44 +00:00
Alexander Motin
abab2155ed Limit AHCI to only one MSI if more is not needed.
My AMD Ryzen system has 4 AHCI controllers, each supporting 16 MSI vectors.
Since two of the controllers have only one SATA port, limit to single MSI
saves system 30 interrupt vectors for free.

It may be possible to also limit number of MSI vectors to 4 and 8 for the
other two controllers, but according to the AHCI specification after that
controllers may revert to only one vector, that would be a bigger loss to
risk.

MFC after:	2 weeks
2020-06-05 02:21:46 +00:00
Marcin Wojtas
9085d7d6b8 Introduce a driver for NXP LS1046A SoC AHCI.
Implement support for AHCI controller found in
NXP QorIQ Layerscape SoCs.

Submitted by: Artur Rojek <ar@semihalf.com>
Reviewed by: manu
Obtained from: Semihalf
Sponsored by: Alstom Group
Differential Revision: https://reviews.freebsd.org/D24466
2020-05-25 16:00:08 +00:00
Alexander Motin
274328a4ef Add support for AHCI BIOS/OS Handoff.
This allows clean handoff from BIOS implementing some asynchronous I/O to
the OS AHCI driver.  During attach driver declares OS ownership request
and waits from 25ms to 2s for BIOS to complete operation and release the
hardware.

MFC after:	2 weeks
2020-04-01 03:27:47 +00:00
Alexander Motin
16b766eed4 Add ID for JMicron JMB582/JMB585 AHCI controller.
JMB582 has 2 6Gbps SATA ports and PCIe 3.0 x1.
JMB585 has 5 6Gbps SATA ports and PCIe 3.0 x2.

Both chips support AHCI v1.31, Port Multiplier with FBS and 8 MSI vectors.

MFC after:	2 weeks
2020-04-01 03:19:42 +00:00
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
Alexander Motin
a6da07a319 Add Hygon PCI ID and description for AHCI SATA controller.
Submitted by:	Pu Wen <puwen@hygon.cn>
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D23556
2020-02-14 14:55:40 +00:00
John Baldwin
65d2f9c12b Use a void * argument to callout handlers instead of timeout_t casts.
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D22684
2019-12-05 18:47:29 +00:00
Alexander Motin
d93f6d3af3 Add some IDs of Intel Wildcat Point-LP.
MFC after:	1 week
2019-11-26 15:52:19 +00:00
Alexander Motin
610defb17c Fix AHCI Enclosure Management, broken by r351356.
ivars value of -1 was used to distinguish EM device, and r351356 left some
wrong checks for it.  Give EM device separate flag there instead.
2019-08-28 22:04:04 +00:00
Warner Losh
93289cfcd2 Create a AHCI attachment for nvme.
Intel has created RST and many laptops from vendors like Lenovo and Asus. It's a
mechanism for creating multiple boot devices under windows. It effectively hides
the nvme drive inside of the ahci controller. The details are supposed to be a
trade secret. However, there's a reverse engineered Linux driver, and this
implements similar operations to allow nvme drives to attach. The ahci driver
attaches nvme children that proxy the remapped resources to the child. nvme_ahci
is just like nvme_pci, except it doesn't do the PCI specific things. That's
moved into ahci where appropriate.

When the nvme drive is remapped, MSI-x interrupts aren't forwarded (the linux
driver doesn't know how to use this either). INTx interrupts are used
instead. This is suboptimal, but usually sufficient for the laptops these parts
are in.

This is based loosely on https://www.spinics.net/lists/linux-ide/msg53364.html
submitted, but not accepted by, Linux. It was written by Dan Williams. These
changes were written from scratch by Olivier Houchard.

Submitted by: cognet@ (Olivier Houchard)
2019-08-21 22:18:01 +00:00
Alexander Motin
53f5ac1310 Improve AHCI Enclosure Management and SES interoperation.
Since SES specs do not define mechanism to map enclosure slots to SATA
disks, AHCI EM code I written many years ago appeared quite useless,
that always bugged me.  I was thinking whether it was a good idea, but
if LSI HBAs do that, why I shouldn't?

This change introduces simple non-standard mechanism for the mapping
into both AHCI EM and SES code, that makes AHCI EM on capable controllers
(most of Intel's) a first-class SES citizen, allowing it to report disk
physical path to GEOM, show devices inserted into each enclosure slot in
`sesutil map` and `getencstat`, control locate and fault LEDs for specific
devices with `sesutil locate adaX on` and `sesutil fault adaX on`, etc.

I've successfully tested this on Supermicro X10DRH-i motherboard connected
with sideband cable of its S-SATA Mini-SAS connector to SAS815TQ backplane.
It can indicate with LEDs Locate, Fault and Rebuild/Remap SES statuses for
each disk identical to real SES of Supermicro SAS2 backplanes.

MFC after:	2 weeks
2019-06-23 19:05:01 +00:00
Emmanuel Vadot
73f707e259 ahci: Check if bus is cache-coherent
We do this for FDT systems but not for ACPI ones.
Check the presence of the _CCA attribute.

Sponsored by: Ampere Computing, LLC
Reviewed by:	andrew
Differential Revision:	https://reviews.freebsd.org/D20144
2019-05-10 16:43:53 +00:00
Alexander Motin
abb7ac4d18 Add some Cannon Lake chipset IDs.
Submitted by:	Dmitry Luhtionov <dmitryluhtionov@gmail.com>
MFC after:	2 weeks
2019-03-20 17:27:00 +00:00
Konstantin Belousov
d91cc9dd63 Fix use of busdma(9) KPI in ahci(4).
Use BUS_DMA_NOWAIT for loads at initialization time.
Report actual numeric error code if any problem occurs at the
initialization.

Reported and tested by:	pho
Reviewed by:	mav
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D18741
2019-01-07 02:39:40 +00:00
Xin LI
99f65e3efe Remove questionable initialization for ICH8M, rely on BIOS to properly
initialize the controller.

According to the datasheet, the old code checks if port 2 (P2E, 0x4) was
the only enabled port (except port 0, which was ignored by mask 0xfe),
and issue a write to the PCS register to disable all but port 0, right
before ahci_ctlr_reset.

Some other operating systems would issue a port enable to all ports, but
since the current code only does the special initialization for ICH8M,
it entirely and rely on BIOS to do the right thing (the alternative
would be https://reviews.freebsd.org/D18300?id=50922 , should we see
reports that we really need to do it).

Reviewed by:	mav
MFC after:	3 months
Differential Revision:	https://reviews.freebsd.org/D18300
2018-12-11 05:10:22 +00:00
Warner Losh
4668666fe4 Implement ability to turn on/off PHYs for AHCI devices.
As part of Chuck's work on fixing kernel crashes caused by disk I/O
errors, it is useful to be able to trigger various kinds of
errors. This patch allows causing an AHCI-attached disk to disappear,
by having the driver keep the PHY disabled when the driver would
otherwise enable the PHY. It also allows making the disk reappear by
having the driver go back to setting the PHY enable/disable state as
it normal would and simulating the hardware event that causes a bus
rescan.

Submitted by: Chuck Silvers
Sponsored by: Netflix, Inc
Differential Revision: https://reviews.freebsd.org/D16043
2018-11-03 00:37:51 +00:00
Martin Wilke
f5a7a8cd67 - Add quirk for Samsung on Mac Mini 7,1
PR:		201676
Submitted by:	Ruben Kerkhof
Approved by:	araujo (mentor)
Obtained from:	TrueOS
Sponsored by:	iXsystems Inc.
Differential Revision:	https://review.freebsd.org/D17815
2018-11-02 07:48:23 +00:00
Warner Losh
329e817fcc Reapply, with minor tweaks, r338025, from the original commit:
Remove unused and easy to misuse PNP macro parameter

Inspired by r338025, just remove the element size parameter to the
MODULE_PNP_INFO macro entirely.  The 'table' parameter is now required to
have correct pointer (or array) type.  Since all invocations of the macro
already had this property and the emitted PNP data continues to include the
element size, there is no functional change.

Mostly done with the coccinelle 'spatch' tool:

  $ cat modpnpsize0.cocci
    @normaltables@
    identifier b,c;
    expression a,d,e;
    declarer MODULE_PNP_INFO;
    @@
     MODULE_PNP_INFO(a,b,c,d,
    -sizeof(d[0]),
     e);

    @singletons@
    identifier b,c,d;
    expression a;
    declarer MODULE_PNP_INFO;
    @@
     MODULE_PNP_INFO(a,b,c,&d,
    -sizeof(d),
     1);

  $ rg -l MODULE_PNP_INFO -- sys | \
    xargs spatch --in-place --sp-file modpnpsize0.cocci

(Note that coccinelle invokes diff(1) via a PATH search and expects diff to
tolerate the -B flag, which BSD diff does not.  So I had to link gdiff into
PATH as diff to use spatch.)

Tinderbox'd (-DMAKE_JUST_KERNELS).
Approved by: re (glen)
2018-09-26 17:12:14 +00:00
Conrad Meyer
b8e771e97a Back out r338035 until Warner is finished churning GSoC PNP patches
I was not aware Warner was making or planning to make forward progress in
this area and have since been informed of that.

It's easy to apply/reapply when churn dies down.
2018-08-19 00:46:22 +00:00
Conrad Meyer
faa319436f Remove unused and easy to misuse PNP macro parameter
Inspired by r338025, just remove the element size parameter to the
MODULE_PNP_INFO macro entirely.  The 'table' parameter is now required to
have correct pointer (or array) type.  Since all invocations of the macro
already had this property and the emitted PNP data continues to include the
element size, there is no functional change.

Mostly done with the coccinelle 'spatch' tool:

  $ cat modpnpsize0.cocci
    @normaltables@
    identifier b,c;
    expression a,d,e;
    declarer MODULE_PNP_INFO;
    @@
     MODULE_PNP_INFO(a,b,c,d,
    -sizeof(d[0]),
     e);

    @singletons@
    identifier b,c,d;
    expression a;
    declarer MODULE_PNP_INFO;
    @@
     MODULE_PNP_INFO(a,b,c,&d,
    -sizeof(d),
     1);

  $ rg -l MODULE_PNP_INFO -- sys | \
    xargs spatch --in-place --sp-file modpnpsize0.cocci

(Note that coccinelle invokes diff(1) via a PATH search and expects diff to
tolerate the -B flag, which BSD diff does not.  So I had to link gdiff into
PATH as diff to use spatch.)

Tinderbox'd (-DMAKE_JUST_KERNELS).
2018-08-19 00:22:21 +00:00
Leandro Lupori
33dc803991 Fixed endianess issue in AHCI driver
There were some bits that were being set in cmd_flags (a field of AHCI's
command list structure) after cmd_flags was converted to little endian.
On a big endian host, such as PowerPC, this would set the wrong bits.
This was preventing AHCI driver from working on these hosts.

Reviewed by:	jhibbits
Approved by:	jhibbits (mentor)
2018-07-27 13:11:05 +00:00
Mark Johnston
ca0a66ba34 Add PCI IDs for AMD X370 AHCI and XHCI.
Submitted by:	Greg V <greg@unrelenting.technology>
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D15398
2018-07-12 18:44:00 +00:00
Warner Losh
491589f3af Add PNP info to the PCI attachment of the ahci driver
Mark the PNP table, but still need to handle the CLASS / SUBCLASS /
REVID matching.

Reviewed by: imp, chuck
Submitted by: Lakhan Shiva Kamireddy <lakhanshiva@gmail.com>
Sponsored by: Google, Inc. (GSoC 2018)
2018-06-13 20:25:04 +00:00
Marcin Wojtas
c58ed0b07f Fix kernel modules names for Marvell armv7
Two modules with the same name cannot be loaded, so Marvell specific drivers
cannot have the same name as the generic drivers.
Files with the same name, even in different folders overlaps their .o files,
so in order to prepare for supporting Marvell platforms in GENERIC armv7
config, modify conflicting names.

Submitted by: Rafal Kozik <rk@semihalf.com>
Obtained from: Semihalf
Sponsored by: Stormshield
Differential Revision: https://reviews.freebsd.org/D14743
2018-04-03 23:49:35 +00:00
Conrad Meyer
66ad253880 Add AHCI/XHCI device IDs found on AMD 1950X+X399 system
A follow-up to r327094.

Sponsored by:	Dell EMC Isilon
2017-12-29 22:24:41 +00:00
Alexander Motin
d171d2f281 Add AHCI/XHCI device IDs found on AMD Ryzen+B350 system.
MFC after:	2 weeks
2017-12-22 20:44:21 +00:00