File: s390-tools-zdev

package info (click to toggle)
s390-tools 2.40.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,288 kB
  • sloc: ansic: 187,079; sh: 12,157; cpp: 5,049; makefile: 2,812; perl: 2,541; asm: 1,097; python: 697; xml: 29
file content (88 lines) | stat: -rw-r--r-- 2,072 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/sh
#
# Copyright IBM Corp. 2017,2021
#
# s390-tools is free software; you can redistribute it and/or modify
# it under the terms of the MIT license. See LICENSE for details.
#
# scripts/init-top/s390-tools-zdev
#   Parse the kernel command line for rd.zdev kernel parameters. These
#   parameters are evaluated and used to configure z Systems specific devices.
#
# Format:
#   rd.zdev=no-auto
#
#     where
#
#   no-auto:       Indicates that firmware-provided I/O configuration data
#                  should not be applied. This also affects automatic
#                  activation of PCI and crypto devices when running in a DPM
#                  LPAR.
#

PREREQ="udev"

prereqs()
{
	echo "$PREREQ"
}

case $1 in
prereqs)
	prereqs
	exit 0
	;;
esac

. /scripts/functions

zdev_fw_file="/sys/firmware/sclp_sd/config/data"
zdev_base_args="--force --yes --no-root-update --no-settle --auto-conf --quiet"
zdev_id="/lib/s390-tools/zdev_id"

if [ -e "$zdev_fw_file" ] ; then
	zdev_auto=1
else
	zdev_auto=0
fi

for x in $(cat /proc/cmdline); do
        case ${x} in
	rd.zdev=*)
		zdev_arg=${x#*=}
		if [ "$zdev_arg" = "no-auto" ] ; then
			zdev_auto=0
		fi
		;;
	esac
done

if [ $zdev_auto -eq 1 ] ; then
	log_begin_msg "Starting firmware auto-configuration"
	chzdev --import "$zdev_fw_file" $zdev_base_args
	log_end_msg

	# Repeat cold-plug after creating udev rules
	udevadm control --reload
	udevadm trigger --type=subsystems --action=add
	udevadm trigger --action=add
	udevadm settle || true

	# Get information about DPM environment
	for line in $($zdev_id) ; do
		eval "$line"
	done

	if [ "$ZDEV_IS_DPM,$ZDEV_NEST_LEVEL,$ZDEV_HYPERVISOR_0" = "1,1,LPAR" ] ; then
		# Manually iterate over existing PCI devices - there is a udev
		# rule that handles this for PCI devices added at runtime but
		# that doesn't work for PCI devices defined before boot because
		# there is no coldplug trigger for /sys/bus/pci/slots
		for slot in /sys/bus/pci/slots/* ; do
			read power < "$slot/power"
			if [ "$power" = "0" ] ; then
				echo 1 > "$slot/power"
			fi
		done
	fi
fi