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.15-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core

Pull driver core fixes from Greg KH:
"Here are some driver core and kernfs fixes for reported issues for
5.15-rc4. These fixes include:

- kernfs positive dentry bugfix

- debugfs_create_file_size error path fix

- cpumask sysfs file bugfix to preserve the user/kernel abi (has been
reported multiple times.)

- devlink fixes for mdiobus devices as reported by the subsystem
maintainers.

Also included in here are some devlink debugging changes to make it
easier for people to report problems when asked. They have already
helped with the mdiobus and other subsystems reporting issues.

All of these have been linux-next for a while with no reported issues"

* tag 'driver-core-5.15-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core:
kernfs: also call kernfs_set_rev() for positive dentry
driver core: Add debug logs when fwnode links are added/deleted
driver core: Create __fwnode_link_del() helper function
driver core: Set deferred probe reason when deferred by driver core
net: mdiobus: Set FWNODE_FLAG_NEEDS_CHILD_BOUND_ON_ADD for mdiobus parents
driver core: fw_devlink: Add support for FWNODE_FLAG_NEEDS_CHILD_BOUND_ON_ADD
driver core: fw_devlink: Improve handling of cyclic dependencies
cpumask: Omit terminating null byte in cpumap_print_{list,bitmask}_to_buf
debugfs: debugfs_create_file_size(): use IS_ERR to check for error

+87 -36
+63 -27
drivers/base/core.c
··· 95 95 96 96 list_add(&link->s_hook, &sup->consumers); 97 97 list_add(&link->c_hook, &con->suppliers); 98 + pr_debug("%pfwP Linked as a fwnode consumer to %pfwP\n", 99 + con, sup); 98 100 out: 99 101 mutex_unlock(&fwnode_link_lock); 100 102 101 103 return ret; 104 + } 105 + 106 + /** 107 + * __fwnode_link_del - Delete a link between two fwnode_handles. 108 + * @link: the fwnode_link to be deleted 109 + * 110 + * The fwnode_link_lock needs to be held when this function is called. 111 + */ 112 + static void __fwnode_link_del(struct fwnode_link *link) 113 + { 114 + pr_debug("%pfwP Dropping the fwnode link to %pfwP\n", 115 + link->consumer, link->supplier); 116 + list_del(&link->s_hook); 117 + list_del(&link->c_hook); 118 + kfree(link); 102 119 } 103 120 104 121 /** ··· 129 112 struct fwnode_link *link, *tmp; 130 113 131 114 mutex_lock(&fwnode_link_lock); 132 - list_for_each_entry_safe(link, tmp, &fwnode->suppliers, c_hook) { 133 - list_del(&link->s_hook); 134 - list_del(&link->c_hook); 135 - kfree(link); 136 - } 115 + list_for_each_entry_safe(link, tmp, &fwnode->suppliers, c_hook) 116 + __fwnode_link_del(link); 137 117 mutex_unlock(&fwnode_link_lock); 138 118 } 139 119 ··· 145 131 struct fwnode_link *link, *tmp; 146 132 147 133 mutex_lock(&fwnode_link_lock); 148 - list_for_each_entry_safe(link, tmp, &fwnode->consumers, s_hook) { 149 - list_del(&link->s_hook); 150 - list_del(&link->c_hook); 151 - kfree(link); 152 - } 134 + list_for_each_entry_safe(link, tmp, &fwnode->consumers, s_hook) 135 + __fwnode_link_del(link); 153 136 mutex_unlock(&fwnode_link_lock); 154 137 } 155 138 ··· 986 975 { 987 976 struct device_link *link; 988 977 int ret = 0; 978 + struct fwnode_handle *sup_fw; 989 979 990 980 /* 991 981 * Device waiting for supplier to become available is not allowed to ··· 995 983 mutex_lock(&fwnode_link_lock); 996 984 if (dev->fwnode && !list_empty(&dev->fwnode->suppliers) && 997 985 !fw_devlink_is_permissive()) { 998 - dev_dbg(dev, "probe deferral - wait for supplier %pfwP\n", 999 - list_first_entry(&dev->fwnode->suppliers, 1000 - struct fwnode_link, 1001 - c_hook)->supplier); 986 + sup_fw = list_first_entry(&dev->fwnode->suppliers, 987 + struct fwnode_link, 988 + c_hook)->supplier; 989 + dev_err_probe(dev, -EPROBE_DEFER, "wait for supplier %pfwP\n", 990 + sup_fw); 1002 991 mutex_unlock(&fwnode_link_lock); 1003 992 return -EPROBE_DEFER; 1004 993 } ··· 1014 1001 if (link->status != DL_STATE_AVAILABLE && 1015 1002 !(link->flags & DL_FLAG_SYNC_STATE_ONLY)) { 1016 1003 device_links_missing_supplier(dev); 1017 - dev_dbg(dev, "probe deferral - supplier %s not ready\n", 1018 - dev_name(link->supplier)); 1004 + dev_err_probe(dev, -EPROBE_DEFER, 1005 + "supplier %s not ready\n", 1006 + dev_name(link->supplier)); 1019 1007 ret = -EPROBE_DEFER; 1020 1008 break; 1021 1009 } ··· 1736 1722 struct device *sup_dev; 1737 1723 int ret = 0; 1738 1724 1725 + /* 1726 + * In some cases, a device P might also be a supplier to its child node 1727 + * C. However, this would defer the probe of C until the probe of P 1728 + * completes successfully. This is perfectly fine in the device driver 1729 + * model. device_add() doesn't guarantee probe completion of the device 1730 + * by the time it returns. 1731 + * 1732 + * However, there are a few drivers that assume C will finish probing 1733 + * as soon as it's added and before P finishes probing. So, we provide 1734 + * a flag to let fw_devlink know not to delay the probe of C until the 1735 + * probe of P completes successfully. 1736 + * 1737 + * When such a flag is set, we can't create device links where P is the 1738 + * supplier of C as that would delay the probe of C. 1739 + */ 1740 + if (sup_handle->flags & FWNODE_FLAG_NEEDS_CHILD_BOUND_ON_ADD && 1741 + fwnode_is_ancestor_of(sup_handle, con->fwnode)) 1742 + return -EINVAL; 1743 + 1739 1744 sup_dev = get_dev_from_fwnode(sup_handle); 1740 1745 if (sup_dev) { 1741 1746 /* ··· 1805 1772 * be broken by applying logic. Check for these types of cycles and 1806 1773 * break them so that devices in the cycle probe properly. 1807 1774 * 1808 - * If the supplier's parent is dependent on the consumer, then 1809 - * the consumer-supplier dependency is a false dependency. So, 1810 - * treat it as an invalid link. 1775 + * If the supplier's parent is dependent on the consumer, then the 1776 + * consumer and supplier have a cyclic dependency. Since fw_devlink 1777 + * can't tell which of the inferred dependencies are incorrect, don't 1778 + * enforce probe ordering between any of the devices in this cyclic 1779 + * dependency. Do this by relaxing all the fw_devlink device links in 1780 + * this cycle and by treating the fwnode link between the consumer and 1781 + * the supplier as an invalid dependency. 1811 1782 */ 1812 1783 sup_dev = fwnode_get_next_parent_dev(sup_handle); 1813 1784 if (sup_dev && device_is_dependent(con, sup_dev)) { 1814 - dev_dbg(con, "Not linking to %pfwP - False link\n", 1815 - sup_handle); 1785 + dev_info(con, "Fixing up cyclic dependency with %pfwP (%s)\n", 1786 + sup_handle, dev_name(sup_dev)); 1787 + device_links_write_lock(); 1788 + fw_devlink_relax_cycle(con, sup_dev); 1789 + device_links_write_unlock(); 1816 1790 ret = -EINVAL; 1817 1791 } else { 1818 1792 /* ··· 1898 1858 if (!own_link || ret == -EAGAIN) 1899 1859 continue; 1900 1860 1901 - list_del(&link->s_hook); 1902 - list_del(&link->c_hook); 1903 - kfree(link); 1861 + __fwnode_link_del(link); 1904 1862 } 1905 1863 } 1906 1864 ··· 1950 1912 if (!own_link || ret == -EAGAIN) 1951 1913 continue; 1952 1914 1953 - list_del(&link->s_hook); 1954 - list_del(&link->c_hook); 1955 - kfree(link); 1915 + __fwnode_link_del(link); 1956 1916 1957 1917 /* If no device link was created, nothing more to do. */ 1958 1918 if (ret)
+4
drivers/net/phy/mdio_bus.c
··· 525 525 NULL == bus->read || NULL == bus->write) 526 526 return -EINVAL; 527 527 528 + if (bus->parent && bus->parent->of_node) 529 + bus->parent->of_node->fwnode.flags |= 530 + FWNODE_FLAG_NEEDS_CHILD_BOUND_ON_ADD; 531 + 528 532 BUG_ON(bus->state != MDIOBUS_ALLOCATED && 529 533 bus->state != MDIOBUS_UNREGISTERED); 530 534
+1 -1
fs/debugfs/inode.c
··· 528 528 { 529 529 struct dentry *de = debugfs_create_file(name, mode, parent, data, fops); 530 530 531 - if (de) 531 + if (!IS_ERR(de)) 532 532 d_inode(de)->i_size = file_size; 533 533 } 534 534 EXPORT_SYMBOL_GPL(debugfs_create_file_size);
+7 -2
fs/kernfs/dir.c
··· 1116 1116 if (!inode) 1117 1117 inode = ERR_PTR(-ENOMEM); 1118 1118 } 1119 - /* Needed only for negative dentry validation */ 1120 - if (!inode) 1119 + /* 1120 + * Needed for negative dentry validation. 1121 + * The negative dentry can be created in kernfs_iop_lookup() 1122 + * or transforms from positive dentry in dentry_unlink_inode() 1123 + * called from vfs_rmdir(). 1124 + */ 1125 + if (!IS_ERR(inode)) 1121 1126 kernfs_set_rev(parent, dentry); 1122 1127 up_read(&kernfs_rwsem); 1123 1128
+4 -3
include/linux/cpumask.h
··· 996 996 * cpumask; Typically used by bin_attribute to export cpumask bitmask 997 997 * ABI. 998 998 * 999 - * Returns the length of how many bytes have been copied. 999 + * Returns the length of how many bytes have been copied, excluding 1000 + * terminating '\0'. 1000 1001 */ 1001 1002 static inline ssize_t 1002 1003 cpumap_print_bitmask_to_buf(char *buf, const struct cpumask *mask, 1003 1004 loff_t off, size_t count) 1004 1005 { 1005 1006 return bitmap_print_bitmask_to_buf(buf, cpumask_bits(mask), 1006 - nr_cpu_ids, off, count); 1007 + nr_cpu_ids, off, count) - 1; 1007 1008 } 1008 1009 1009 1010 /** ··· 1019 1018 loff_t off, size_t count) 1020 1019 { 1021 1020 return bitmap_print_list_to_buf(buf, cpumask_bits(mask), 1022 - nr_cpu_ids, off, count); 1021 + nr_cpu_ids, off, count) - 1; 1023 1022 } 1024 1023 1025 1024 #if NR_CPUS <= BITS_PER_LONG
+8 -3
include/linux/fwnode.h
··· 22 22 * LINKS_ADDED: The fwnode has already be parsed to add fwnode links. 23 23 * NOT_DEVICE: The fwnode will never be populated as a struct device. 24 24 * INITIALIZED: The hardware corresponding to fwnode has been initialized. 25 + * NEEDS_CHILD_BOUND_ON_ADD: For this fwnode/device to probe successfully, its 26 + * driver needs its child devices to be bound with 27 + * their respective drivers as soon as they are 28 + * added. 25 29 */ 26 - #define FWNODE_FLAG_LINKS_ADDED BIT(0) 27 - #define FWNODE_FLAG_NOT_DEVICE BIT(1) 28 - #define FWNODE_FLAG_INITIALIZED BIT(2) 30 + #define FWNODE_FLAG_LINKS_ADDED BIT(0) 31 + #define FWNODE_FLAG_NOT_DEVICE BIT(1) 32 + #define FWNODE_FLAG_INITIALIZED BIT(2) 33 + #define FWNODE_FLAG_NEEDS_CHILD_BOUND_ON_ADD BIT(3) 29 34 30 35 struct fwnode_handle { 31 36 struct fwnode_handle *secondary;