Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'driver-core-5.11-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core

Pull driver core fixes from Greg KH:
"Here are some small driver core fixes for 5.11-rc5 that resolve some
reported problems:

- revert of a -rc1 patch that was causing problems with some machines

- device link device name collision problem fix (busses only have to
name devices unique to their bus, not unique to all busses)

- kernfs splice bugfixes to resolve firmware loading problems for
Qualcomm systems.

- other tiny driver core fixes for minor issues reported.

All of these have been in linux-next with no reported problems"

* tag 'driver-core-5.11-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core:
driver core: Fix device link device name collision
driver core: Extend device_is_dependent()
kernfs: wire up ->splice_read and ->splice_write
kernfs: implement ->write_iter
kernfs: implement ->read_iter
Revert "driver core: Reorder devices on successful probe"
Driver core: platform: Add extra error check in devm_platform_get_irqs_affinity()
drivers core: Free dma_range_map when driver probe failed

+77 -67
+3 -2
Documentation/ABI/testing/sysfs-devices-consumer
··· 4 4 Description: 5 5 The /sys/devices/.../consumer:<consumer> are symlinks to device 6 6 links where this device is the supplier. <consumer> denotes the 7 - name of the consumer in that device link. There can be zero or 8 - more of these symlinks for a given device. 7 + name of the consumer in that device link and is of the form 8 + bus:device name. There can be zero or more of these symlinks 9 + for a given device.
+3 -2
Documentation/ABI/testing/sysfs-devices-supplier
··· 4 4 Description: 5 5 The /sys/devices/.../supplier:<supplier> are symlinks to device 6 6 links where this device is the consumer. <supplier> denotes the 7 - name of the supplier in that device link. There can be zero or 8 - more of these symlinks for a given device. 7 + name of the supplier in that device link and is of the form 8 + bus:device name. There can be zero or more of these symlinks 9 + for a given device.
+31 -13
drivers/base/core.c
··· 208 208 #endif 209 209 #endif /* !CONFIG_SRCU */ 210 210 211 + static bool device_is_ancestor(struct device *dev, struct device *target) 212 + { 213 + while (target->parent) { 214 + target = target->parent; 215 + if (dev == target) 216 + return true; 217 + } 218 + return false; 219 + } 220 + 211 221 /** 212 222 * device_is_dependent - Check if one device depends on another one 213 223 * @dev: Device to check dependencies for. ··· 231 221 struct device_link *link; 232 222 int ret; 233 223 234 - if (dev == target) 224 + /* 225 + * The "ancestors" check is needed to catch the case when the target 226 + * device has not been completely initialized yet and it is still 227 + * missing from the list of children of its parent device. 228 + */ 229 + if (dev == target || device_is_ancestor(dev, target)) 235 230 return 1; 236 231 237 232 ret = device_for_each_child(dev, target, device_is_dependent); ··· 471 456 struct device *con = link->consumer; 472 457 char *buf; 473 458 474 - len = max(strlen(dev_name(sup)), strlen(dev_name(con))); 459 + len = max(strlen(dev_bus_name(sup)) + strlen(dev_name(sup)), 460 + strlen(dev_bus_name(con)) + strlen(dev_name(con))); 461 + len += strlen(":"); 475 462 len += strlen("supplier:") + 1; 476 463 buf = kzalloc(len, GFP_KERNEL); 477 464 if (!buf) ··· 487 470 if (ret) 488 471 goto err_con; 489 472 490 - snprintf(buf, len, "consumer:%s", dev_name(con)); 473 + snprintf(buf, len, "consumer:%s:%s", dev_bus_name(con), dev_name(con)); 491 474 ret = sysfs_create_link(&sup->kobj, &link->link_dev.kobj, buf); 492 475 if (ret) 493 476 goto err_con_dev; 494 477 495 - snprintf(buf, len, "supplier:%s", dev_name(sup)); 478 + snprintf(buf, len, "supplier:%s:%s", dev_bus_name(sup), dev_name(sup)); 496 479 ret = sysfs_create_link(&con->kobj, &link->link_dev.kobj, buf); 497 480 if (ret) 498 481 goto err_sup_dev; ··· 500 483 goto out; 501 484 502 485 err_sup_dev: 503 - snprintf(buf, len, "consumer:%s", dev_name(con)); 486 + snprintf(buf, len, "consumer:%s:%s", dev_bus_name(con), dev_name(con)); 504 487 sysfs_remove_link(&sup->kobj, buf); 505 488 err_con_dev: 506 489 sysfs_remove_link(&link->link_dev.kobj, "consumer"); ··· 523 506 sysfs_remove_link(&link->link_dev.kobj, "consumer"); 524 507 sysfs_remove_link(&link->link_dev.kobj, "supplier"); 525 508 526 - len = max(strlen(dev_name(sup)), strlen(dev_name(con))); 509 + len = max(strlen(dev_bus_name(sup)) + strlen(dev_name(sup)), 510 + strlen(dev_bus_name(con)) + strlen(dev_name(con))); 511 + len += strlen(":"); 527 512 len += strlen("supplier:") + 1; 528 513 buf = kzalloc(len, GFP_KERNEL); 529 514 if (!buf) { ··· 533 514 return; 534 515 } 535 516 536 - snprintf(buf, len, "supplier:%s", dev_name(sup)); 517 + snprintf(buf, len, "supplier:%s:%s", dev_bus_name(sup), dev_name(sup)); 537 518 sysfs_remove_link(&con->kobj, buf); 538 - snprintf(buf, len, "consumer:%s", dev_name(con)); 519 + snprintf(buf, len, "consumer:%s:%s", dev_bus_name(con), dev_name(con)); 539 520 sysfs_remove_link(&sup->kobj, buf); 540 521 kfree(buf); 541 522 } ··· 756 737 757 738 link->link_dev.class = &devlink_class; 758 739 device_set_pm_not_required(&link->link_dev); 759 - dev_set_name(&link->link_dev, "%s--%s", 760 - dev_name(supplier), dev_name(consumer)); 740 + dev_set_name(&link->link_dev, "%s:%s--%s:%s", 741 + dev_bus_name(supplier), dev_name(supplier), 742 + dev_bus_name(consumer), dev_name(consumer)); 761 743 if (device_register(&link->link_dev)) { 762 744 put_device(consumer); 763 745 put_device(supplier); ··· 1828 1808 * never change once they are set, so they don't need special care. 1829 1809 */ 1830 1810 drv = READ_ONCE(dev->driver); 1831 - return drv ? drv->name : 1832 - (dev->bus ? dev->bus->name : 1833 - (dev->class ? dev->class->name : "")); 1811 + return drv ? drv->name : dev_bus_name(dev); 1834 1812 } 1835 1813 EXPORT_SYMBOL(dev_driver_string); 1836 1814
+2 -7
drivers/base/dd.c
··· 371 371 device_pm_check_callbacks(dev); 372 372 373 373 /* 374 - * Reorder successfully probed devices to the end of the device list. 375 - * This ensures that suspend/resume order matches probe order, which 376 - * is usually what drivers rely on. 377 - */ 378 - device_pm_move_to_tail(dev); 379 - 380 - /* 381 374 * Make sure the device is no longer in one of the deferred lists and 382 375 * kick off retrying all pending devices 383 376 */ ··· 612 619 else if (drv->remove) 613 620 drv->remove(dev); 614 621 probe_failed: 622 + kfree(dev->dma_range_map); 623 + dev->dma_range_map = NULL; 615 624 if (dev->bus) 616 625 blocking_notifier_call_chain(&dev->bus->p->bus_notifier, 617 626 BUS_NOTIFY_DRIVER_NOT_BOUND, dev);
+24 -41
fs/kernfs/file.c
··· 14 14 #include <linux/pagemap.h> 15 15 #include <linux/sched/mm.h> 16 16 #include <linux/fsnotify.h> 17 + #include <linux/uio.h> 17 18 18 19 #include "kernfs-internal.h" 19 20 ··· 181 180 * it difficult to use seq_file. Implement simplistic custom buffering for 182 181 * bin files. 183 182 */ 184 - static ssize_t kernfs_file_direct_read(struct kernfs_open_file *of, 185 - char __user *user_buf, size_t count, 186 - loff_t *ppos) 183 + static ssize_t kernfs_file_read_iter(struct kiocb *iocb, struct iov_iter *iter) 187 184 { 188 - ssize_t len = min_t(size_t, count, PAGE_SIZE); 185 + struct kernfs_open_file *of = kernfs_of(iocb->ki_filp); 186 + ssize_t len = min_t(size_t, iov_iter_count(iter), PAGE_SIZE); 189 187 const struct kernfs_ops *ops; 190 188 char *buf; 191 189 ··· 210 210 of->event = atomic_read(&of->kn->attr.open->event); 211 211 ops = kernfs_ops(of->kn); 212 212 if (ops->read) 213 - len = ops->read(of, buf, len, *ppos); 213 + len = ops->read(of, buf, len, iocb->ki_pos); 214 214 else 215 215 len = -EINVAL; 216 216 ··· 220 220 if (len < 0) 221 221 goto out_free; 222 222 223 - if (copy_to_user(user_buf, buf, len)) { 223 + if (copy_to_iter(buf, len, iter) != len) { 224 224 len = -EFAULT; 225 225 goto out_free; 226 226 } 227 227 228 - *ppos += len; 228 + iocb->ki_pos += len; 229 229 230 230 out_free: 231 231 if (buf == of->prealloc_buf) ··· 235 235 return len; 236 236 } 237 237 238 - /** 239 - * kernfs_fop_read - kernfs vfs read callback 240 - * @file: file pointer 241 - * @user_buf: data to write 242 - * @count: number of bytes 243 - * @ppos: starting offset 244 - */ 245 - static ssize_t kernfs_fop_read(struct file *file, char __user *user_buf, 246 - size_t count, loff_t *ppos) 238 + static ssize_t kernfs_fop_read_iter(struct kiocb *iocb, struct iov_iter *iter) 247 239 { 248 - struct kernfs_open_file *of = kernfs_of(file); 249 - 250 - if (of->kn->flags & KERNFS_HAS_SEQ_SHOW) 251 - return seq_read(file, user_buf, count, ppos); 252 - else 253 - return kernfs_file_direct_read(of, user_buf, count, ppos); 240 + if (kernfs_of(iocb->ki_filp)->kn->flags & KERNFS_HAS_SEQ_SHOW) 241 + return seq_read_iter(iocb, iter); 242 + return kernfs_file_read_iter(iocb, iter); 254 243 } 255 244 256 - /** 257 - * kernfs_fop_write - kernfs vfs write callback 258 - * @file: file pointer 259 - * @user_buf: data to write 260 - * @count: number of bytes 261 - * @ppos: starting offset 262 - * 245 + /* 263 246 * Copy data in from userland and pass it to the matching kernfs write 264 247 * operation. 265 248 * ··· 252 269 * modify only the the value you're changing, then write entire buffer 253 270 * back. 254 271 */ 255 - static ssize_t kernfs_fop_write(struct file *file, const char __user *user_buf, 256 - size_t count, loff_t *ppos) 272 + static ssize_t kernfs_fop_write_iter(struct kiocb *iocb, struct iov_iter *iter) 257 273 { 258 - struct kernfs_open_file *of = kernfs_of(file); 274 + struct kernfs_open_file *of = kernfs_of(iocb->ki_filp); 275 + ssize_t len = iov_iter_count(iter); 259 276 const struct kernfs_ops *ops; 260 - ssize_t len; 261 277 char *buf; 262 278 263 279 if (of->atomic_write_len) { 264 - len = count; 265 280 if (len > of->atomic_write_len) 266 281 return -E2BIG; 267 282 } else { 268 - len = min_t(size_t, count, PAGE_SIZE); 283 + len = min_t(size_t, len, PAGE_SIZE); 269 284 } 270 285 271 286 buf = of->prealloc_buf; ··· 274 293 if (!buf) 275 294 return -ENOMEM; 276 295 277 - if (copy_from_user(buf, user_buf, len)) { 296 + if (copy_from_iter(buf, len, iter) != len) { 278 297 len = -EFAULT; 279 298 goto out_free; 280 299 } ··· 293 312 294 313 ops = kernfs_ops(of->kn); 295 314 if (ops->write) 296 - len = ops->write(of, buf, len, *ppos); 315 + len = ops->write(of, buf, len, iocb->ki_pos); 297 316 else 298 317 len = -EINVAL; 299 318 ··· 301 320 mutex_unlock(&of->mutex); 302 321 303 322 if (len > 0) 304 - *ppos += len; 323 + iocb->ki_pos += len; 305 324 306 325 out_free: 307 326 if (buf == of->prealloc_buf) ··· 654 673 655 674 /* 656 675 * Write path needs to atomic_write_len outside active reference. 657 - * Cache it in open_file. See kernfs_fop_write() for details. 676 + * Cache it in open_file. See kernfs_fop_write_iter() for details. 658 677 */ 659 678 of->atomic_write_len = ops->atomic_write_len; 660 679 ··· 941 960 EXPORT_SYMBOL_GPL(kernfs_notify); 942 961 943 962 const struct file_operations kernfs_file_fops = { 944 - .read = kernfs_fop_read, 945 - .write = kernfs_fop_write, 963 + .read_iter = kernfs_fop_read_iter, 964 + .write_iter = kernfs_fop_write_iter, 946 965 .llseek = generic_file_llseek, 947 966 .mmap = kernfs_fop_mmap, 948 967 .open = kernfs_fop_open, 949 968 .release = kernfs_fop_release, 950 969 .poll = kernfs_fop_poll, 951 970 .fsync = noop_fsync, 971 + .splice_read = generic_file_splice_read, 972 + .splice_write = iter_file_splice_write, 952 973 }; 953 974 954 975 /**
+12
include/linux/device.h
··· 609 609 return kobject_name(&dev->kobj); 610 610 } 611 611 612 + /** 613 + * dev_bus_name - Return a device's bus/class name, if at all possible 614 + * @dev: struct device to get the bus/class name of 615 + * 616 + * Will return the name of the bus/class the device is attached to. If it is 617 + * not attached to a bus/class, an empty string will be returned. 618 + */ 619 + static inline const char *dev_bus_name(const struct device *dev) 620 + { 621 + return dev->bus ? dev->bus->name : (dev->class ? dev->class->name : ""); 622 + } 623 + 612 624 __printf(2, 3) int dev_set_name(struct device *dev, const char *name, ...); 613 625 614 626 #ifdef CONFIG_NUMA