Skip to content

Commit 5983809

Browse files
committed
Merge tag 'driver-core-5.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core
Pull driver core updates from Greg KH: "Here is the "big" set of driver core changes for 5.7-rc1. Nothing huge in here, just lots of little firmware core changes and use of new apis, a libfs fix, a debugfs api change, and some driver core deferred probe rework. All of these have been in linux-next for a while with no reported issues" * tag 'driver-core-5.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (44 commits) Revert "driver core: Set fw_devlink to "permissive" behavior by default" driver core: Set fw_devlink to "permissive" behavior by default driver core: Replace open-coded list_last_entry() driver core: Read atomic counter once in driver_probe_done() libfs: fix infoleak in simple_attr_read() driver core: Add device links from fwnode only for the primary device platform/x86: touchscreen_dmi: Add info for the Chuwi Vi8 Plus tablet platform/x86: touchscreen_dmi: Add EFI embedded firmware info support Input: icn8505 - Switch to firmware_request_platform for retreiving the fw Input: silead - Switch to firmware_request_platform for retreiving the fw selftests: firmware: Add firmware_request_platform tests test_firmware: add support for firmware_request_platform firmware: Add new platform fallback mechanism and firmware_request_platform() Revert "drivers: base: power: wakeup.c: Use built-in RCU list checking" drivers: base: power: wakeup.c: Use built-in RCU list checking component: allow missing unbind callback debugfs: remove return value of debugfs_create_file_size() debugfs: Check module state before warning in {full/open}_proxy_open() firmware: fix a double abort case with fw_load_sysfs_fallback arch_topology: Fix putting invalid cpu clk ...
2 parents db34c5f + 18555cb commit 5983809

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+996
-174
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,6 +1360,24 @@
13601360
can be changed at run time by the max_graph_depth file
13611361
in the tracefs tracing directory. default: 0 (no limit)
13621362

1363+
fw_devlink= [KNL] Create device links between consumer and supplier
1364+
devices by scanning the firmware to infer the
1365+
consumer/supplier relationships. This feature is
1366+
especially useful when drivers are loaded as modules as
1367+
it ensures proper ordering of tasks like device probing
1368+
(suppliers first, then consumers), supplier boot state
1369+
clean up (only after all consumers have probed),
1370+
suspend/resume & runtime PM (consumers first, then
1371+
suppliers).
1372+
Format: { off | permissive | on | rpm }
1373+
off -- Don't create device links from firmware info.
1374+
permissive -- Create device links from firmware info
1375+
but use it only for ordering boot state clean
1376+
up (sync_state() calls).
1377+
on -- Create device links from firmware info and use it
1378+
to enforce probe and suspend/resume ordering.
1379+
rpm -- Like "on", but also use to order runtime PM.
1380+
13631381
gamecon.map[2|3]=
13641382
[HW,JOY] Multisystem joystick and NES/SNES/PSX pad
13651383
support via parallel port (up to 5 devices per port)
@@ -3291,12 +3309,6 @@
32913309
This can be set from sysctl after boot.
32923310
See Documentation/admin-guide/sysctl/vm.rst for details.
32933311

3294-
of_devlink [OF, KNL] Create device links between consumer and
3295-
supplier devices by scanning the devictree to infer the
3296-
consumer/supplier relationships. A consumer device
3297-
will not be probed until all the supplier devices have
3298-
probed successfully.
3299-
33003312
ohci1394_dma=early [HW] enable debugging via the ohci1394 driver.
33013313
See Documentation/debugging-via-ohci1394.txt for more
33023314
info.

Documentation/driver-api/firmware/fallback-mechanisms.rst

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,3 +202,106 @@ the following file:
202202

203203
If you echo 0 into it means MAX_JIFFY_OFFSET will be used. The data type
204204
for the timeout is an int.
205+
206+
EFI embedded firmware fallback mechanism
207+
========================================
208+
209+
On some devices the system's EFI code / ROM may contain an embedded copy
210+
of firmware for some of the system's integrated peripheral devices and
211+
the peripheral's Linux device-driver needs to access this firmware.
212+
213+
Device drivers which need such firmware can use the
214+
firmware_request_platform() function for this, note that this is a
215+
separate fallback mechanism from the other fallback mechanisms and
216+
this does not use the sysfs interface.
217+
218+
A device driver which needs this can describe the firmware it needs
219+
using an efi_embedded_fw_desc struct:
220+
221+
.. kernel-doc:: include/linux/efi_embedded_fw.h
222+
:functions: efi_embedded_fw_desc
223+
224+
The EFI embedded-fw code works by scanning all EFI_BOOT_SERVICES_CODE memory
225+
segments for an eight byte sequence matching prefix; if the prefix is found it
226+
then does a sha256 over length bytes and if that matches makes a copy of length
227+
bytes and adds that to its list with found firmwares.
228+
229+
To avoid doing this somewhat expensive scan on all systems, dmi matching is
230+
used. Drivers are expected to export a dmi_system_id array, with each entries'
231+
driver_data pointing to an efi_embedded_fw_desc.
232+
233+
To register this array with the efi-embedded-fw code, a driver needs to:
234+
235+
1. Always be builtin to the kernel or store the dmi_system_id array in a
236+
separate object file which always gets builtin.
237+
238+
2. Add an extern declaration for the dmi_system_id array to
239+
include/linux/efi_embedded_fw.h.
240+
241+
3. Add the dmi_system_id array to the embedded_fw_table in
242+
drivers/firmware/efi/embedded-firmware.c wrapped in a #ifdef testing that
243+
the driver is being builtin.
244+
245+
4. Add "select EFI_EMBEDDED_FIRMWARE if EFI_STUB" to its Kconfig entry.
246+
247+
The firmware_request_platform() function will always first try to load firmware
248+
with the specified name directly from the disk, so the EFI embedded-fw can
249+
always be overridden by placing a file under /lib/firmware.
250+
251+
Note that:
252+
253+
1. The code scanning for EFI embedded-firmware runs near the end
254+
of start_kernel(), just before calling rest_init(). For normal drivers and
255+
subsystems using subsys_initcall() to register themselves this does not
256+
matter. This means that code running earlier cannot use EFI
257+
embedded-firmware.
258+
259+
2. At the moment the EFI embedded-fw code assumes that firmwares always start at
260+
an offset which is a multiple of 8 bytes, if this is not true for your case
261+
send in a patch to fix this.
262+
263+
3. At the moment the EFI embedded-fw code only works on x86 because other archs
264+
free EFI_BOOT_SERVICES_CODE before the EFI embedded-fw code gets a chance to
265+
scan it.
266+
267+
4. The current brute-force scanning of EFI_BOOT_SERVICES_CODE is an ad-hoc
268+
brute-force solution. There has been discussion to use the UEFI Platform
269+
Initialization (PI) spec's Firmware Volume protocol. This has been rejected
270+
because the FV Protocol relies on *internal* interfaces of the PI spec, and:
271+
1. The PI spec does not define peripheral firmware at all
272+
2. The internal interfaces of the PI spec do not guarantee any backward
273+
compatibility. Any implementation details in FV may be subject to change,
274+
and may vary system to system. Supporting the FV Protocol would be
275+
difficult as it is purposely ambiguous.
276+
277+
Example how to check for and extract embedded firmware
278+
------------------------------------------------------
279+
280+
To check for, for example Silead touchscreen controller embedded firmware,
281+
do the following:
282+
283+
1. Boot the system with efi=debug on the kernel commandline
284+
285+
2. cp /sys/kernel/debug/efi/boot_services_code? to your home dir
286+
287+
3. Open the boot_services_code? files in a hex-editor, search for the
288+
magic prefix for Silead firmware: F0 00 00 00 02 00 00 00, this gives you
289+
the beginning address of the firmware inside the boot_services_code? file.
290+
291+
4. The firmware has a specific pattern, it starts with a 8 byte page-address,
292+
typically F0 00 00 00 02 00 00 00 for the first page followed by 32-bit
293+
word-address + 32-bit value pairs. With the word-address incrementing 4
294+
bytes (1 word) for each pair until a page is complete. A complete page is
295+
followed by a new page-address, followed by more word + value pairs. This
296+
leads to a very distinct pattern. Scroll down until this pattern stops,
297+
this gives you the end of the firmware inside the boot_services_code? file.
298+
299+
5. "dd if=boot_services_code? of=firmware bs=1 skip=<begin-addr> count=<len>"
300+
will extract the firmware for you. Inspect the firmware file in a
301+
hexeditor to make sure you got the dd parameters correct.
302+
303+
6. Copy it to /lib/firmware under the expected name to test it.
304+
305+
7. If the extracted firmware works, you can use the found info to fill an
306+
efi_embedded_fw_desc struct to describe it, run "sha256sum firmware"
307+
to get the sha256sum to put in the sha256 field.

Documentation/driver-api/firmware/lookup-order.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ a driver issues a firmware API call.
1212
return it immediately
1313
* The ''Direct filesystem lookup'' is performed next, if found we
1414
return it immediately
15+
* The ''Platform firmware fallback'' is performed next, but only when
16+
firmware_request_platform() is used, if found we return it immediately
1517
* If no firmware has been found and the fallback mechanism was enabled
1618
the sysfs interface is created. After this either a kobject uevent
1719
is issued or the custom firmware loading is relied upon for firmware

Documentation/driver-api/firmware/request_firmware.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ firmware_request_nowarn
2525
.. kernel-doc:: drivers/base/firmware_loader/main.c
2626
:functions: firmware_request_nowarn
2727

28+
firmware_request_platform
29+
-------------------------
30+
.. kernel-doc:: drivers/base/firmware_loader/main.c
31+
:functions: firmware_request_platform
32+
2833
request_firmware_direct
2934
-----------------------
3035
.. kernel-doc:: drivers/base/firmware_loader/main.c

Documentation/filesystems/debugfs.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ missing.
6262
Create a file with an initial size, the following function can be used
6363
instead::
6464

65-
struct dentry *debugfs_create_file_size(const char *name, umode_t mode,
66-
struct dentry *parent, void *data,
67-
const struct file_operations *fops,
68-
loff_t file_size);
65+
void debugfs_create_file_size(const char *name, umode_t mode,
66+
struct dentry *parent, void *data,
67+
const struct file_operations *fops,
68+
loff_t file_size);
6969

7070
file_size is the initial file size. The other parameters are the same
7171
as the function debugfs_create_file.

arch/x86/platform/efi/efi.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ int __init efi_memblock_x86_reserve_range(void)
243243
efi.memmap.desc_version);
244244

245245
memblock_reserve(pmap, efi.memmap.nr_map * efi.memmap.desc_size);
246+
set_bit(EFI_PRESERVE_BS_REGIONS, &efi.flags);
246247

247248
return 0;
248249
}
@@ -943,6 +944,7 @@ static void __init __efi_enter_virtual_mode(void)
943944
goto err;
944945
}
945946

947+
efi_check_for_embedded_firmwares();
946948
efi_free_boot_services();
947949

948950
/*

arch/x86/platform/efi/quirks.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,10 @@ void __init efi_free_boot_services(void)
410410
int num_entries = 0;
411411
void *new, *new_md;
412412

413+
/* Keep all regions for /sys/kernel/debug/efi */
414+
if (efi_enabled(EFI_DBG))
415+
return;
416+
413417
for_each_efi_memory_desc(md) {
414418
unsigned long long start = md->phys_addr;
415419
unsigned long long size = md->num_pages << EFI_PAGE_SHIFT;

drivers/base/arch_topology.c

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ static void update_topology_flags_workfn(struct work_struct *work)
9494
update_topology = 0;
9595
}
9696

97-
static u32 capacity_scale;
97+
static DEFINE_PER_CPU(u32, freq_factor) = 1;
9898
static u32 *raw_capacity;
9999

100100
static int free_raw_capacity(void)
@@ -108,17 +108,23 @@ static int free_raw_capacity(void)
108108
void topology_normalize_cpu_scale(void)
109109
{
110110
u64 capacity;
111+
u64 capacity_scale;
111112
int cpu;
112113

113114
if (!raw_capacity)
114115
return;
115116

116-
pr_debug("cpu_capacity: capacity_scale=%u\n", capacity_scale);
117+
capacity_scale = 1;
117118
for_each_possible_cpu(cpu) {
118-
pr_debug("cpu_capacity: cpu=%d raw_capacity=%u\n",
119-
cpu, raw_capacity[cpu]);
120-
capacity = (raw_capacity[cpu] << SCHED_CAPACITY_SHIFT)
121-
/ capacity_scale;
119+
capacity = raw_capacity[cpu] * per_cpu(freq_factor, cpu);
120+
capacity_scale = max(capacity, capacity_scale);
121+
}
122+
123+
pr_debug("cpu_capacity: capacity_scale=%llu\n", capacity_scale);
124+
for_each_possible_cpu(cpu) {
125+
capacity = raw_capacity[cpu] * per_cpu(freq_factor, cpu);
126+
capacity = div64_u64(capacity << SCHED_CAPACITY_SHIFT,
127+
capacity_scale);
122128
topology_set_cpu_scale(cpu, capacity);
123129
pr_debug("cpu_capacity: CPU%d cpu_capacity=%lu\n",
124130
cpu, topology_get_cpu_scale(cpu));
@@ -127,6 +133,7 @@ void topology_normalize_cpu_scale(void)
127133

128134
bool __init topology_parse_cpu_capacity(struct device_node *cpu_node, int cpu)
129135
{
136+
struct clk *cpu_clk;
130137
static bool cap_parsing_failed;
131138
int ret;
132139
u32 cpu_capacity;
@@ -146,10 +153,22 @@ bool __init topology_parse_cpu_capacity(struct device_node *cpu_node, int cpu)
146153
return false;
147154
}
148155
}
149-
capacity_scale = max(cpu_capacity, capacity_scale);
150156
raw_capacity[cpu] = cpu_capacity;
151157
pr_debug("cpu_capacity: %pOF cpu_capacity=%u (raw)\n",
152158
cpu_node, raw_capacity[cpu]);
159+
160+
/*
161+
* Update freq_factor for calculating early boot cpu capacities.
162+
* For non-clk CPU DVFS mechanism, there's no way to get the
163+
* frequency value now, assuming they are running at the same
164+
* frequency (by keeping the initial freq_factor value).
165+
*/
166+
cpu_clk = of_clk_get(cpu_node, 0);
167+
if (!PTR_ERR_OR_ZERO(cpu_clk)) {
168+
per_cpu(freq_factor, cpu) =
169+
clk_get_rate(cpu_clk) / 1000;
170+
clk_put(cpu_clk);
171+
}
153172
} else {
154173
if (raw_capacity) {
155174
pr_err("cpu_capacity: missing %pOF raw capacity\n",
@@ -188,11 +207,8 @@ init_cpu_capacity_callback(struct notifier_block *nb,
188207

189208
cpumask_andnot(cpus_to_visit, cpus_to_visit, policy->related_cpus);
190209

191-
for_each_cpu(cpu, policy->related_cpus) {
192-
raw_capacity[cpu] = topology_get_cpu_scale(cpu) *
193-
policy->cpuinfo.max_freq / 1000UL;
194-
capacity_scale = max(raw_capacity[cpu], capacity_scale);
195-
}
210+
for_each_cpu(cpu, policy->related_cpus)
211+
per_cpu(freq_factor, cpu) = policy->cpuinfo.max_freq / 1000;
196212

197213
if (cpumask_empty(cpus_to_visit)) {
198214
topology_normalize_cpu_scale();
@@ -281,7 +297,7 @@ static int __init get_cpu_for_node(struct device_node *node)
281297
static int __init parse_core(struct device_node *core, int package_id,
282298
int core_id)
283299
{
284-
char name[10];
300+
char name[20];
285301
bool leaf = true;
286302
int i = 0;
287303
int cpu;
@@ -327,7 +343,7 @@ static int __init parse_core(struct device_node *core, int package_id,
327343

328344
static int __init parse_cluster(struct device_node *cluster, int depth)
329345
{
330-
char name[10];
346+
char name[20];
331347
bool leaf = true;
332348
bool has_cores = false;
333349
struct device_node *c;

drivers/base/component.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,8 @@ static void component_unbind(struct component *component,
528528
{
529529
WARN_ON(!component->bound);
530530

531-
component->ops->unbind(component->dev, master->dev, data);
531+
if (component->ops && component->ops->unbind)
532+
component->ops->unbind(component->dev, master->dev, data);
532533
component->bound = false;
533534

534535
/* Release all resources claimed in the binding of this component */

0 commit comments

Comments
 (0)