Skip to content

Commit 975f9ce

Browse files
committed
Merge tag 'driver-core-5.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core
Pull driver core updates from Greg KH: "Here is a small set of changes for 5.6-rc1 for the driver core and some firmware subsystem changes. Included in here are: - device.h splitup like you asked for months ago - devtmpfs minor cleanups - firmware core minor changes - debugfs fix for lockdown mode - kernfs cleanup fix - cpu topology minor fix All of these have been in linux-next for a while with no reported issues" * tag 'driver-core-5.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (22 commits) firmware: Rename FW_OPT_NOFALLBACK to FW_OPT_NOFALLBACK_SYSFS devtmpfs: factor out common tail of devtmpfs_{create,delete}_node devtmpfs: initify a bit devtmpfs: simplify initialization of mount_dev devtmpfs: factor out setup part of devtmpfsd() devtmpfs: fix theoretical stale pointer deref in devtmpfsd() driver core: platform: fix u32 greater or equal to zero comparison cpu-topology: Don't error on more than CONFIG_NR_CPUS CPUs in device tree debugfs: Return -EPERM when locked down driver core: Print device when resources present in really_probe() driver core: Fix test_async_driver_probe if NUMA is disabled driver core: platform: Prevent resouce overflow from causing infinite loops fs/kernfs/dir.c: Clean code by removing always true condition component: do not dereference opaque pointer in debugfs drivers/component: remove modular code debugfs: Fix warnings when building documentation device.h: move 'struct driver' stuff out to device/driver.h device.h: move 'struct class' stuff out to device/class.h device.h: move 'struct bus' stuff out to device/bus.h device.h: move dev_printk()-like functions to dev_printk.h ...
2 parents 7ba31c3 + 85db1cd commit 975f9ce

File tree

22 files changed

+1219
-1093
lines changed

22 files changed

+1219
-1093
lines changed

drivers/base/arch_topology.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,16 @@ core_initcall(free_raw_capacity);
248248
#endif
249249

250250
#if defined(CONFIG_ARM64) || defined(CONFIG_RISCV)
251+
/*
252+
* This function returns the logic cpu number of the node.
253+
* There are basically three kinds of return values:
254+
* (1) logic cpu number which is > 0.
255+
* (2) -ENODEV when the device tree(DT) node is valid and found in the DT but
256+
* there is no possible logical CPU in the kernel to match. This happens
257+
* when CONFIG_NR_CPUS is configure to be smaller than the number of
258+
* CPU nodes in DT. We need to just ignore this case.
259+
* (3) -1 if the node does not exist in the device tree
260+
*/
251261
static int __init get_cpu_for_node(struct device_node *node)
252262
{
253263
struct device_node *cpu_node;
@@ -261,7 +271,8 @@ static int __init get_cpu_for_node(struct device_node *node)
261271
if (cpu >= 0)
262272
topology_parse_cpu_capacity(cpu_node, cpu);
263273
else
264-
pr_crit("Unable to find CPU node for %pOF\n", cpu_node);
274+
pr_info("CPU node for %pOF exist but the possible cpu range is :%*pbl\n",
275+
cpu_node, cpumask_pr_args(cpu_possible_mask));
265276

266277
of_node_put(cpu_node);
267278
return cpu;
@@ -286,9 +297,8 @@ static int __init parse_core(struct device_node *core, int package_id,
286297
cpu_topology[cpu].package_id = package_id;
287298
cpu_topology[cpu].core_id = core_id;
288299
cpu_topology[cpu].thread_id = i;
289-
} else {
290-
pr_err("%pOF: Can't get CPU for thread\n",
291-
t);
300+
} else if (cpu != -ENODEV) {
301+
pr_err("%pOF: Can't get CPU for thread\n", t);
292302
of_node_put(t);
293303
return -EINVAL;
294304
}
@@ -307,7 +317,7 @@ static int __init parse_core(struct device_node *core, int package_id,
307317

308318
cpu_topology[cpu].package_id = package_id;
309319
cpu_topology[cpu].core_id = core_id;
310-
} else if (leaf) {
320+
} else if (leaf && cpu != -ENODEV) {
311321
pr_err("%pOF: Can't get CPU for leaf core\n", core);
312322
return -EINVAL;
313323
}

drivers/base/base.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
/* SPDX-License-Identifier: GPL-2.0 */
2+
/*
3+
* Copyright (c) 2001-2003 Patrick Mochel <[email protected]>
4+
* Copyright (c) 2004-2009 Greg Kroah-Hartman <[email protected]>
5+
* Copyright (c) 2008-2012 Novell Inc.
6+
* Copyright (c) 2012-2019 Greg Kroah-Hartman <[email protected]>
7+
* Copyright (c) 2012-2019 Linux Foundation
8+
*
9+
* Core driver model functions and structures that should not be
10+
* shared outside of the drivers/base/ directory.
11+
*
12+
*/
213
#include <linux/notifier.h>
314

415
/**
@@ -175,3 +186,11 @@ extern void device_links_unbind_consumers(struct device *dev);
175186

176187
/* device pm support */
177188
void device_pm_move_to_tail(struct device *dev);
189+
190+
#ifdef CONFIG_DEVTMPFS
191+
int devtmpfs_create_node(struct device *dev);
192+
int devtmpfs_delete_node(struct device *dev);
193+
#else
194+
static inline int devtmpfs_create_node(struct device *dev) { return 0; }
195+
static inline int devtmpfs_delete_node(struct device *dev) { return 0; }
196+
#endif

drivers/base/bus.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010

1111
#include <linux/async.h>
12+
#include <linux/device/bus.h>
1213
#include <linux/device.h>
1314
#include <linux/module.h>
1415
#include <linux/errno.h>

drivers/base/class.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* Copyright (c) 2003-2004 IBM Corp.
99
*/
1010

11+
#include <linux/device/class.h>
1112
#include <linux/device.h>
1213
#include <linux/module.h>
1314
#include <linux/init.h>

drivers/base/component.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include <linux/device.h>
1212
#include <linux/kref.h>
1313
#include <linux/list.h>
14-
#include <linux/module.h>
1514
#include <linux/mutex.h>
1615
#include <linux/slab.h>
1716
#include <linux/debugfs.h>
@@ -102,11 +101,11 @@ static int component_devices_show(struct seq_file *s, void *data)
102101
seq_printf(s, "%-40s %20s\n", "device name", "status");
103102
seq_puts(s, "-------------------------------------------------------------\n");
104103
for (i = 0; i < match->num; i++) {
105-
struct device *d = (struct device *)match->compare[i].data;
104+
struct component *component = match->compare[i].component;
106105

107-
seq_printf(s, "%-40s %20s\n", dev_name(d),
108-
match->compare[i].component ?
109-
"registered" : "not registered");
106+
seq_printf(s, "%-40s %20s\n",
107+
component ? dev_name(component->dev) : "(unknown)",
108+
component ? (component->bound ? "bound" : "not bound") : "not registered");
110109
}
111110
mutex_unlock(&component_mutex);
112111

@@ -775,5 +774,3 @@ void component_del(struct device *dev, const struct component_ops *ops)
775774
kfree(component);
776775
}
777776
EXPORT_SYMBOL_GPL(component_del);
778-
779-
MODULE_LICENSE("GPL v2");

drivers/base/dd.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,10 @@ static int really_probe(struct device *dev, struct device_driver *drv)
516516
atomic_inc(&probe_count);
517517
pr_debug("bus: '%s': %s: probing driver %s with device %s\n",
518518
drv->bus->name, __func__, drv->name, dev_name(dev));
519-
WARN_ON(!list_empty(&dev->devres_head));
519+
if (!list_empty(&dev->devres_head)) {
520+
dev_crit(dev, "Resources present before probing\n");
521+
return -EBUSY;
522+
}
520523

521524
re_probe:
522525
dev->driver = drv;

drivers/base/devtmpfs.c

Lines changed: 39 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,7 @@
3030

3131
static struct task_struct *thread;
3232

33-
#if defined CONFIG_DEVTMPFS_MOUNT
34-
static int mount_dev = 1;
35-
#else
36-
static int mount_dev;
37-
#endif
33+
static int __initdata mount_dev = IS_ENABLED(CONFIG_DEVTMPFS_MOUNT);
3834

3935
static DEFINE_SPINLOCK(req_lock);
4036

@@ -93,6 +89,23 @@ static inline int is_blockdev(struct device *dev)
9389
static inline int is_blockdev(struct device *dev) { return 0; }
9490
#endif
9591

92+
static int devtmpfs_submit_req(struct req *req, const char *tmp)
93+
{
94+
init_completion(&req->done);
95+
96+
spin_lock(&req_lock);
97+
req->next = requests;
98+
requests = req;
99+
spin_unlock(&req_lock);
100+
101+
wake_up_process(thread);
102+
wait_for_completion(&req->done);
103+
104+
kfree(tmp);
105+
106+
return req->err;
107+
}
108+
96109
int devtmpfs_create_node(struct device *dev)
97110
{
98111
const char *tmp = NULL;
@@ -117,19 +130,7 @@ int devtmpfs_create_node(struct device *dev)
117130

118131
req.dev = dev;
119132

120-
init_completion(&req.done);
121-
122-
spin_lock(&req_lock);
123-
req.next = requests;
124-
requests = &req;
125-
spin_unlock(&req_lock);
126-
127-
wake_up_process(thread);
128-
wait_for_completion(&req.done);
129-
130-
kfree(tmp);
131-
132-
return req.err;
133+
return devtmpfs_submit_req(&req, tmp);
133134
}
134135

135136
int devtmpfs_delete_node(struct device *dev)
@@ -147,18 +148,7 @@ int devtmpfs_delete_node(struct device *dev)
147148
req.mode = 0;
148149
req.dev = dev;
149150

150-
init_completion(&req.done);
151-
152-
spin_lock(&req_lock);
153-
req.next = requests;
154-
requests = &req;
155-
spin_unlock(&req_lock);
156-
157-
wake_up_process(thread);
158-
wait_for_completion(&req.done);
159-
160-
kfree(tmp);
161-
return req.err;
151+
return devtmpfs_submit_req(&req, tmp);
162152
}
163153

164154
static int dev_mkdir(const char *name, umode_t mode)
@@ -359,7 +349,7 @@ static int handle_remove(const char *nodename, struct device *dev)
359349
* If configured, or requested by the commandline, devtmpfs will be
360350
* auto-mounted after the kernel mounted the root filesystem.
361351
*/
362-
int devtmpfs_mount(void)
352+
int __init devtmpfs_mount(void)
363353
{
364354
int err;
365355

@@ -388,18 +378,30 @@ static int handle(const char *name, umode_t mode, kuid_t uid, kgid_t gid,
388378
return handle_remove(name, dev);
389379
}
390380

391-
static int devtmpfsd(void *p)
381+
static int devtmpfs_setup(void *p)
392382
{
393-
int *err = p;
394-
*err = ksys_unshare(CLONE_NEWNS);
395-
if (*err)
383+
int err;
384+
385+
err = ksys_unshare(CLONE_NEWNS);
386+
if (err)
396387
goto out;
397-
*err = do_mount("devtmpfs", "/", "devtmpfs", MS_SILENT, NULL);
398-
if (*err)
388+
err = do_mount("devtmpfs", "/", "devtmpfs", MS_SILENT, NULL);
389+
if (err)
399390
goto out;
400391
ksys_chdir("/.."); /* will traverse into overmounted root */
401392
ksys_chroot(".");
393+
out:
394+
*(int *)p = err;
402395
complete(&setup_done);
396+
return err;
397+
}
398+
399+
static int devtmpfsd(void *p)
400+
{
401+
int err = devtmpfs_setup(p);
402+
403+
if (err)
404+
return err;
403405
while (1) {
404406
spin_lock(&req_lock);
405407
while (requests) {
@@ -420,9 +422,6 @@ static int devtmpfsd(void *p)
420422
schedule();
421423
}
422424
return 0;
423-
out:
424-
complete(&setup_done);
425-
return *err;
426425
}
427426

428427
/*

drivers/base/driver.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* Copyright (c) 2007 Novell Inc.
99
*/
1010

11+
#include <linux/device/driver.h>
1112
#include <linux/device.h>
1213
#include <linux/module.h>
1314
#include <linux/errno.h>

drivers/base/firmware_loader/fallback.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ static bool fw_run_sysfs_fallback(enum fw_opt opt_flags)
606606
return false;
607607
}
608608

609-
if ((opt_flags & FW_OPT_NOFALLBACK))
609+
if ((opt_flags & FW_OPT_NOFALLBACK_SYSFS))
610610
return false;
611611

612612
/* Also permit LSMs and IMA to fail firmware sysfs fallback */
@@ -630,10 +630,11 @@ static bool fw_run_sysfs_fallback(enum fw_opt opt_flags)
630630
* interface. Userspace is in charge of loading the firmware through the sysfs
631631
* loading interface. This sysfs fallback mechanism may be disabled completely
632632
* on a system by setting the proc sysctl value ignore_sysfs_fallback to true.
633-
* If this false we check if the internal API caller set the @FW_OPT_NOFALLBACK
634-
* flag, if so it would also disable the fallback mechanism. A system may want
635-
* to enfoce the sysfs fallback mechanism at all times, it can do this by
636-
* setting ignore_sysfs_fallback to false and force_sysfs_fallback to true.
633+
* If this is false we check if the internal API caller set the
634+
* @FW_OPT_NOFALLBACK_SYSFS flag, if so it would also disable the fallback
635+
* mechanism. A system may want to enforce the sysfs fallback mechanism at all
636+
* times, it can do this by setting ignore_sysfs_fallback to false and
637+
* force_sysfs_fallback to true.
637638
* Enabling force_sysfs_fallback is functionally equivalent to build a kernel
638639
* with CONFIG_FW_LOADER_USER_HELPER_FALLBACK.
639640
**/

drivers/base/firmware_loader/firmware.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@
2727
* firmware file lookup on storage is avoided. Used for calls where the
2828
* file may be too big, or where the driver takes charge of its own
2929
* firmware caching mechanism.
30-
* @FW_OPT_NOFALLBACK: Disable the fallback mechanism. Takes precedence over
31-
* &FW_OPT_UEVENT and &FW_OPT_USERHELPER.
30+
* @FW_OPT_NOFALLBACK_SYSFS: Disable the sysfs fallback mechanism. Takes
31+
* precedence over &FW_OPT_UEVENT and &FW_OPT_USERHELPER.
3232
*/
3333
enum fw_opt {
34-
FW_OPT_UEVENT = BIT(0),
35-
FW_OPT_NOWAIT = BIT(1),
36-
FW_OPT_USERHELPER = BIT(2),
37-
FW_OPT_NO_WARN = BIT(3),
38-
FW_OPT_NOCACHE = BIT(4),
39-
FW_OPT_NOFALLBACK = BIT(5),
34+
FW_OPT_UEVENT = BIT(0),
35+
FW_OPT_NOWAIT = BIT(1),
36+
FW_OPT_USERHELPER = BIT(2),
37+
FW_OPT_NO_WARN = BIT(3),
38+
FW_OPT_NOCACHE = BIT(4),
39+
FW_OPT_NOFALLBACK_SYSFS = BIT(5),
4040
};
4141

4242
enum fw_status {

0 commit comments

Comments
 (0)