summaryrefslogtreecommitdiffstats
path: root/platform-intel.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* mdadm: add xmalloc.hMariusz Tkaczyk2024-09-271-0/+2
| | | | | | | | | | Move memory declaration helpers outside mdadm.h. They seems to be useful so keep them but include separatelly. Rework them to not reffer to Name[] declared internally in mdadm/mdmon. This is first step to start decomplexing mdadm.h. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* imsm: add IMSM_OROM_CAPABILITIES_TPV to nvme oromMariusz Tkaczyk2024-08-301-1/+2
| | | | | | | | | | | | | | Add it to avoid excluding. It has some value for users even if it is always true for nvme virtual orom. Rework detail-platform printing code, move printing 3rd party nvmes to print_imsm_capability (as it should be), but keep it meaningful only for nvme controllers (NVME and VMD hba types). Pass whole orom_entry instead of orom there. Squash code responsible for printing NVME and VMD hbas. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* platform-intel: refactor path_attached_to_hba()Mateusz Kusiak2024-08-301-17/+14
| | | | | | | dprintf() call in path_attached_to_hba() is too noisy. Remove the call and refactor the function. Remove obsolete env variables check. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com>
* imsm: get bus from VMD driver directoryMariusz Tkaczyk2024-08-301-11/+77
| | | | | | | | | | | | | | | Enumeration of VMD child devices is started early, kernel is not waiting for VMD enumeration to finish. It causes that: /sys/bus/pci/drivers/vmd/{dev}/domain/device link might be not yet ready. With PCI gen5 devices we can observe that mdadm is failing to start IMSM raid arrays because of that. In that case, it needs to find bus path manually. Look for bus device in VMD driver directory if realpath() failed with ENOENT. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* imsm: add read OROM form ACPI UEFI tablesBlazej Kucman2024-08-131-25/+299
| | | | | | | | | | | | | | | | | | | | | | | OROM - IMSM hardware capabilities EFI vars depends on userspace, they need to be mounted to be accessible. Sporadic problems have been observed with availability at an early assemble stage. It is not possible to fully synchronize EFI vars mounts with udev rules processing. For the reason above, read of IMSM OROM from ACPI tables as secondary option is added. This method will be used for SATA and VMD family controllers. ACPI tables are generated by sysfs, earlier in the boot process, before the stage of RAID assembly. The way of loading OROM via EFI vars is retained, ACPI tables will be a backup way. Two paths will be maintained, because IMSM hardware capabilities are necessary for RAID assembly during booting, so access to them must be provided. Signed-off-by: Blazej Kucman <blazej.kucman@intel.com>
* mdadm/platform-intel: buffer overflow detectedXiao Ni2024-05-281-2/+2
| | | | | | | | | | | | | | mdadm -CR /dev/md0 -l1 -n2 /dev/nvme0n1 /dev/nvme2n1 *** buffer overflow detected ***: terminated Aborted (core dumped) It doesn't happen 100% and it depends on the building environment. It can be fixed by replacing sprintf with snprintf. Fixes: d835518b6b53 ('imsm: nvme multipath support') Reported-by: Guang Wu <guazhang@redhat.com> Signed-off-by: Xiao Ni <xni@redhat.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* imsm: define RAID_10 attributeMateusz Kusiak2024-05-071-1/+2
| | | | | | | | | | | | | Add MPB_ATTRIB_RAID10_EXT attribute to support RAID 10 with more than 4 drives. Allow more than 4 drives in imsm_orom_support_raid_disks_raid10(). This is one of last patches for introducing R10D4+ to imsm. Only small adjustments in reshape behaviours are needed. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* imsm: refactor RAID level handlingMateusz Kusiak2024-05-071-0/+57
| | | | | | | | | | | | | | | | | Add imsm_level_ops struct for better handling and unifying raid level support. Add helper methods and move "orom_has_raid[...]" methods from header to source file. RAID 1e is not supported under Linux, remove RAID 1e associated code. Refactor imsm_analyze_change() and is_raid_level_supported(). Remove hardcoded check for 4 drives and make devNumChange a multiplier for RAID 10. Refactor printing supported raid levels. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* imsm: Add reading vmd register for finding imsm capabilityMateusz Grzonka2023-09-011-2/+112
| | | | | | | | | | | | Currently mdadm does not find imsm capability when running inside VM. This patch adds the possibility to read from vmd register and check for capability, effectively allowing to use mdadm with imsm inside virtual machines. Additionally refactor find_imsm_capability() to make assignments in new lines. Signed-off-by: Mateusz Grzonka <mateusz.grzonka@intel.com> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* platform-intel: limit guid lengthKinga Tanska2023-09-011-3/+0
| | | | | | | | Moving GUID_STR_MAX to header to use it as a length limitation for snprintf function. Signed-off-by: Kinga Tanska <kinga.tanska@intel.com> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* Fix unsafe string functionsKinga Tanska2023-09-011-1/+1
| | | | | | | | Add string length limitations where necessary to avoid buffer overflows. Signed-off-by: Kinga Tanska <kinga.tanska@intel.com> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* enable RAID for SATA under VMDKevin Friedberg2023-05-081-3/+18
| | | | | | | | | | Detect when a SATA controller has been mapped under Intel Alderlake RST VMD, so that it can use the VMD controller's RAID capabilities. Create new device type SYS_DEV_SATA_VMD and list separate controller to prevent mixing with the NVMe SYS_DEV_VMD devices on the same VMD domain. Signed-off-by: Kevin Friedberg <kev.friedberg@gmail.com> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* mdadm: added support for Intel Alderlake RST on VMD platformOldřich Jedlička2022-09-141-5/+13
| | | | | | | | Alderlake RST on VMD uses RstVmdV UEFI variable name, so detect it. Signed-off-by: Oldřich Jedlička <oldium.pro@gmail.com> Reviewed-by: Kinga Tanska <kinga.tanska@linux.intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* imsm: Limit support to the lowest namespaceMariusz Tkaczyk2021-05-261-21/+60
| | | | | | | | First namespace existence is not quaranted by NVMe specification. Instead first the smallest one shall be chosen. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* imsm: add devpath_to_char methodMariusz Tkaczyk2021-05-261-0/+23
| | | | | | | Add method for reading sysfs attributes and propagate it across IMSM code. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* imsm: add generic method to resolve "device" linksMariusz Tkaczyk2021-05-261-24/+51
| | | | | | | | | | | | | | | | | | | Each virtual device is linked with parent by "device". This patch adds possibility to get previous device in sysfs tree. Depending on device type, there is a different amount of virutal layers. The best we can do is allow to directly specify how many "device" links need to be resolved. This approach also allows to get previous virtual device, which may contain some attributes. Simplify fd2devname, this function doesn't require new functionality and shall use generic fd2kname. For nvme drives represented via nvme-subystem when path to block device if requested, then return it without translation. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* imsm: support for third Sata controllerMariusz Tkaczyk2021-03-181-27/+31
| | | | | | | | | Add new UEFI TSata variable. Remove CSata variable. This variable has been never exposed by UEFI. Remove vulnerability to match different hbas with SATA variable. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* imsm: nvme multipath supportBlazej Kucman2021-03-161-1/+78
| | | | | | | | | | | Add support for nvme devices which are represented via nvme-subsystem. Print warning when multi-path disk is added to RAID. Signed-off-by: Oleksandr Shchirskyi <oleksandr.shchirskyi@intel.com> Signed-off-by: Blazej Kucman <blazej.kucman@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* imsm: limit support to first NVMe namespaceMariusz Tkaczyk2020-11-261-0/+31
| | | | | | Due to metadata limitations NVMe multinamespace support has to be removed. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com>
* imsm: Avoid duplicate entries in --detail-platformRoman Sobanski2018-09-271-0/+3
| | | | | | | | In some scenarios mdadm --detail-platform shows duplicated info about one of controllers. Block it. Signed-off-by: Roman Sobanski <roman.sobanski@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdadm: Fixup more broken logical operator formattingJes Sorensen2017-05-161-2/+2
| | | | Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* imsm: count arrays under VMD HBAs correctlyAlexey Obitotskiy2017-01-091-0/+10
| | | | | | | | | | | | | | | OROM defines maximum number of arrays supported. On array creation mdadm checks if number of arrays doesn't exceed that limit, however it is not calculated correctly for VMD now. The current code performs a lookup of HBA using the id. VMD HBAs have the same id so each lookup returns the same structure (first encountered). Take a different approach for VMD HBAs. As id is not unique and cannot be used for lookups, iterate over all VMD HBAs and compare both id and HBA path. Signed-off-by: Alexey Obitotskiy <aleksey.obitotskiy@intel.com> Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
* Don't assume VMD sysfs path ends with a disk entryAlexey Obitotskiy2017-01-041-12/+21
| | | | | | | | | | When VMD is enabled but no drive is attached to the PCIe port, mdadm crashes trying to parse the path. Skip entry if valid path has not been returned. Do it early to avoid unnecessary memory allocation. Signed-off-by: Alexey Obitotskiy <aleksey.obitotskiy@intel.com> Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com> Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
* {platform,super}-intel: Fix two resource leaksJes Sorensen2016-03-091-1/+6
| | | | | | | | | The code did not free 'dir' allocated by opendir(). An additional benefit is that this simplifies the for() loops. Fixes: 60f0f54d ("IMSM: Add support for VMD") Reviewed-by: NeilBrown <neilb@suse.com> Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
* Assorted fixed for a "make everything" buildNeilBrown2016-01-281-2/+1
| | | | Signed-off-by: NeilBrown <neilb@suse.com>
* IMSM: Add support for VMDPawel Baldysiak2016-01-061-7/+80
| | | | | | | | | | | | | The Intel Volume Management Device (VMD) is an integrated endpoint on the platform's PCIe root complex that acts as a host bridge to a secondary PCIe domain. This patch adds proper handling of NVMe devices attached to VMD domain. Each VMD domain is treated as a separate controller (HBA). Spanning between domains is forbidden. Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com> Signed-off-by: NeilBrown <neilb@suse.com>
* IMSM: Count arrays per oromPawel Baldysiak2015-04-091-2/+12
| | | | | | | | | | | Active arrays with IMSM metadata are counted per hba so far. This is bad due to new functionality of orom shared between multiple controllers i.e. more arrays can be created than is supported by orom. This patch changes the way of counting arrays, so the result will be sum of arrays under every hba supported by specific orom. Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* IMSM-orom: make sure, that device list is supportedPawel Baldysiak2015-03-041-1/+4
| | | | | | | | Devices list in PCI Data Structure is supported only in 3 and above revision. Make sure that this is checked. Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* imsm: simplified multiple OROMs supportArtur Paszkiewicz2015-03-041-50/+46
| | | | | | | | | Replaced oroms array with list, add_orom() now only appends to this list and add_orom_device_id() only appends devid_list node to an orom_entry. Reported-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* imsm: use efivarfs interface for reading UEFI variablesArtur Paszkiewicz2014-11-251-1/+36
| | | | | | | | Read UEFI variables using the new efivarfs interface, fallback to sysfs-efivars if that fails. Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* imsm: detail-platform improvementsArtur Paszkiewicz2014-11-251-10/+16
| | | | | | | | | | Print platform details per OROM, not per controller, differentiate RST(e) platforms from legacy IMSM, print NVMe device paths, adjust port printing to newer sysfs path. Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com> Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* imsm: add support for NVMe devicesPawel Baldysiak2014-11-251-2/+44
| | | | | | | | Recognize Intel(R) NVMe devices as IMSM-capable. Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com> Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* imsm: support for second and combined AHCI controllers in UEFI modeArtur Paszkiewicz2014-11-251-1/+23
| | | | | | | | | | Grantly platform introduces a second AHCI controller (sSATA) and two new UEFI variables for the RSTe firmware. This patch adds support for those variables in order to correctly determine IMSM platform capabilities in UEFI mode. Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* imsm: support for OROMs shared by multiple HBAsArtur Paszkiewicz2014-11-251-103/+145
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The IMSM platform code was based on an assumption that the OROM or UEFI capability structure (represented by struct imsm_orom) always belongs to only one HBA. This assumption is no longer valid, because of newer platforms with dual AHCI HBAs. Each HBA can have a separate OROM, but some versions have a combined OROM for both HBAs. This patch implements this HBA-OROM relationship in struct orom_entry, which matches an OROM with a list of HBA PCI ids. All the detected orom_entries are stored and retrieved using a global array and the functions add_orom(), add_orom_device_id() and get_orom_by_device_id(). This replaces the arrays: imsm_orom, populated_orom, imsm_efi, populated_efi. The scan() function is extended to find all HBAs for an OROM. The list of their device ids is retrieved from the PCI Expansion ROM Data Structure, hence the additional field devListOffset in struct pciExpDataStructFormat. In UEFI mode we can't read the PCI Expansion ROM Data Structure and the imsm_orom structures are stored in UEFI variables. They do not provide a similar device id list, so we also check the HBA PCI class to make sure that the HBA has RAID mode enabled. In super-intel.c there are changes which allow spanning of IMSM containers over HBAs of the same type, but only if the HBAs share the same OROM. This is done by comparing imsm_orom pointers, which (outside of platform-intel.c) always point to the global array containing all the detected oroms. Additional warnings are added to validate_container_imsm() to warn about potentially dangerous operations in all the possible cases, e.g. when an array is assembled using disks attached to HBAs with separate OROMs. Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Remove lots of unnecessary white space.NeilBrown2013-06-191-8/+0
| | | | | | | Now that I am using white-space mode in Emacs I can see all of this, and I don't like it :-) Signed-off-by: NeilBrown <neilb@suse.de>
* platform-intel: canonicalize_file_name() is not portableJohn Spencer2013-02-101-2/+2
| | | | | | | | | | | | | this is a GLIBC specific feature and should not be used. according to its manpage: "The call canonicalize_file_name(path) is equivalent to the call realpath(path, NULL)." thus, we use realpath so it works everywhere. Signed-off-by: John Spencer <maillist-mdadm@barfooze.de> Signed-off-by: NeilBrown <neilb@suse.de>
* platform-intel - cache 'intel_devices' for a few seconds.NeilBrown2013-01-071-11/+12
| | | | | | | | | find_intel_devices() has take a little while to run as it scans some directory tree, and the result isn't likely to change often. So cache the value and only discard it after 10 seconds. Signed-off-by: NeilBrown <neilb@suse.de>
* Replace a lot of leading spaces with tabs.NeilBrown2012-10-101-2/+2
| | | | Signed-off-by: NeilBrown <neilb@suse.de>
* Remove scattered checks for malloc success.NeilBrown2012-07-091-2/+2
| | | | | | | | | | | | | | malloc should never fail, and if it does it is unlikely that anything else useful can be done. Best approach is to abort and let some super-daemon restart. So define xmalloc, xcalloc, xrealloc, xstrdup which don't fail but just print a message and exit. Then use those removing all the tests for failure. Also replace all "malloc;memset" sequences with 'xcalloc'. Signed-off-by: NeilBrown <neilb@suse.de>
* imsm: reading of UEFI variables needs an updateHawrylewicz Czarnowski, Przemyslaw2011-03-281-17/+45
| | | | | | | | | | Content of EFI variable is stored in "data" file. Moreover size of data provided by given variable can be initially validated by reading value of "size" file. Function read_efi_variable() has been introduced to simplify the code. Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* imsm: remove OEM table from detection of OROM and EFI.Hawrylewicz Czarnowski, Przemyslaw2011-03-281-9/+1
| | | | | | | | OEM table does not suit our needs so it cannot be used. This patch removes feature added in commit 8a0bf4f378c8b. Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* platform_intel: support EFI SCU OEM variableLabun, Marcin2011-03-201-2/+9
| | | | | | | | | RstScuV and RstScuO variable names are supported. First try reading from RstScuV, when it fails try RstScuO. Signed-off-by: Marcin Labun <marcin.labun@intel.com> Tested-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* platfrom_intel: find OROM based on Intel AHCI and SAS driver device idLabun, Marcin2011-03-141-19/+60
| | | | | | | | | | | We use PCI device id exposed by AHCI and ISCU drivers (SAS controller) to find OROM version table. In this way there is no need to maintain AHCI and ISCU device id list in mdadm. The consequence is that the OROM properties can be found by mdadm when AHCI or SAS drivers are loaded in the system. Signed-off-by: Marcin Labun <marcin.labun@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* platform_intel: support for OROM OEM capabilitiesLabun, Marcin2011-03-101-1/+2
| | | | | | | Scan memory to match $VER and $OEM. Signed-off-by: Marcin Labun <marcin.labun@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* read platform capabilities from EFILabun, Marcin2011-03-101-0/+64
| | | | | | | | | | If operating system is installed using efi, IMSM platform capabilities are not available via option ROM, but are stored as efi variables. New mechanism has been introduced to obtain capabilities by variables. Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com> Signed-off-by: Marcin Labun <marcin.labun@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Some guid manipulation utilities has been added.Labun, Marcin2011-03-101-0/+9
| | | | | | | It will be used for reading efi variables with capabilities. Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Platform-intel: support for OROM SAS and AHCI controllerLabun, Marcin2011-03-101-30/+100
| | | | | Signed-off-by: Marcin Labun <marcin.labun@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* probe_roms: allow to probe expansion ROMs using vendor and device id.Labun, Marcin2011-03-101-2/+19
| | | | | | | | | Adds data offset to PCI expansion ROM Data Structure in resource describing Expansion ROMs. This allows AHCI OROM scanning function to identify AHCI OROM by device id 0x2822 and vendor id 0x8086. Signed-off-by: Marcin Labun <marcin.labun@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* imsm platform: support for Intel(R) SAS controller.Labun Marcin2011-01-261-21/+46
| | | | | | | | | This patch adds platform support for SAS controller(s) built in Intel(R) Patsburg chipset. Signed-off-by: Marcin Labun <marcin.labun@intel.com> Signed-off-by: Artur Wojcik <artur.wojcik@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Compile with -Wextra by defaultNeilBrown2010-08-051-1/+1
| | | | | | This produced lots of warning, some of which pointed to actual bugs. Signed-off-by: NeilBrown <neilb@suse.de>