An error occurred fetching the project authors.
  1. 13 Feb, 2021 1 commit
  2. 09 Dec, 2020 12 commits
  3. 09 Nov, 2020 1 commit
    • Saravana Kannan's avatar
      driver core: Fix lockdep warning on wfs_lock · 7008e58c
      Saravana Kannan authored
      There's a potential deadlock with the following cycle:
      wfs_lock --> device_links_lock --> kn->count
      
      Fix this by simply dropping the lock around a list_empty() check that's
      just exported to a sysfs file. The sysfs file output is an instantaneous
      check anyway and the lock doesn't really add any protection.
      
      Lockdep log:
      
      [   48.808132]
      [   48.808132] the existing dependency chain (in reverse order) is:
      [   48.809069]
      [   48.809069] -> #2 (kn->count){++++}:
      [   48.809707]        __kernfs_remove.llvm.7860393000964815146+0x2d4/0x460
      [   48.810537]        kernfs_remove_by_name_ns+0x54/0x9c
      [   48.811171]        sysfs_remove_file_ns+0x18/0x24
      [   48.811762]        device_del+0x2b8/0x5a8
      [   48.812269]        __device_link_del+0x98/0xb8
      [   48.812829]        device_links_driver_bound+0x210/0x2d8
      [   48.813496]        driver_bound+0x44/0xf8
      [   48.814000]        really_probe+0x340/0x6e0
      [   48.814526]        driver_probe_device+0xb8/0x100
      [   48.815117]        device_driver_attach+0x78/0xb8
      [   48.815708]        __driver_attach+0xe0/0x194
      [   48.816255]        bus_for_each_dev+0xa8/0x11c
      [   48.816816]        driver_attach+0x24/0x30
      [   48.817331]        bus_add_driver+0x100/0x1e0
      [   48.817880]        driver_register+0x78/0x114
      [   48.818427]        __platform_driver_register+0x44/0x50
      [   48.819089]        0xffffffdbb3227038
      [   48.819551]        do_one_initcall+0xd8/0x1e0
      [   48.820099]        do_init_module+0xd8/0x298
      [   48.820636]        load_module+0x3afc/0x44c8
      [   48.821173]        __arm64_sys_finit_module+0xbc/0xf0
      [   48.821807]        el0_svc_common+0xbc/0x1d0
      [   48.822344]        el0_svc_handler+0x74/0x98
      [   48.822882]        el0_svc+0x8/0xc
      [   48.823310]
      [   48.823310] -> #1 (device_links_lock){+.+.}:
      [   48.824036]        __mutex_lock_common+0xe0/0xe44
      [   48.824626]        mutex_lock_nested+0x28/0x34
      [   48.825185]        device_link_add+0xd4/0x4ec
      [   48.825734]        of_link_to_suppliers+0x158/0x204
      [   48.826347]        of_fwnode_add_links+0x50/0x64
      [   48.826928]        device_link_add_missing_supplier_links+0x90/0x11c
      [   48.827725]        fw_devlink_resume+0x58/0x130
      [   48.828296]        of_platform_default_populate_init+0xb4/0xd0
      [   48.829030]        do_one_initcall+0xd8/0x1e0
      [   48.829578]        do_initcall_level+0xb8/0xcc
      [   48.830137]        do_basic_setup+0x60/0x7c
      [   48.830662]        kernel_init_freeable+0x128/0x1ac
      [   48.831275]        kernel_init+0x18/0x29c
      [   48.831781]        ret_from_fork+0x10/0x18
      [   48.832297]
      [   48.832297] -> #0 (wfs_lock){+.+.}:
      [   48.832922]        __lock_acquire+0xe04/0x2e20
      [   48.833480]        lock_acquire+0xbc/0xec
      [   48.833984]        __mutex_lock_common+0xe0/0xe44
      [   48.834577]        mutex_lock_nested+0x28/0x34
      [   48.835136]        waiting_for_supplier_show+0x3c/0x98
      [   48.835781]        dev_attr_show+0x48/0xb4
      [   48.836295]        sysfs_kf_seq_show+0xe8/0x184
      [   48.836864]        kernfs_seq_show+0x48/0x8c
      [   48.837401]        seq_read+0x1c8/0x600
      [   48.837884]        kernfs_fop_read+0x68/0x204
      [   48.838431]        __vfs_read+0x60/0x214
      [   48.838925]        vfs_read+0xbc/0x15c
      [   48.839397]        ksys_read+0x78/0xe4
      [   48.839869]        __arm64_sys_read+0x1c/0x28
      [   48.840416]        el0_svc_common+0xbc/0x1d0
      [   48.840953]        el0_svc_handler+0x74/0x98
      [   48.841490]        el0_svc+0x8/0xc
      [   48.841917]
      [   48.841917] other info that might help us debug this:
      [   48.841917]
      [   48.842920] Chain exists of:
      [   48.842920]   wfs_lock --> device_links_lock --> kn->count
      [   48.842920]
      [   48.844152]  Possible unsafe locking scenario:
      [   48.844152]
      [   48.844895]        CPU0                    CPU1
      [   48.845463]        ----                    ----
      [   48.846032]   lock(kn->count);
      [   48.846417]                                lock(device_links_lock);
      [   48.847203]                                lock(kn->count);
      [   48.847902]   lock(wfs_lock);
      [   48.848276]
      [   48.848276]  *** DEADLOCK ***
      
      Reported-by: Cheng-Jui.Wang@mediatek.com
      Signed-off-by: default avatarSaravana Kannan <saravanak@google.com>
      Link: https://lore.kernel.org/r/20201104205431.3795207-1-saravanak@google.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7008e58c
  4. 02 Nov, 2020 1 commit
  5. 27 Oct, 2020 2 commits
  6. 15 Oct, 2020 1 commit
  7. 14 Oct, 2020 1 commit
    • Dan Williams's avatar
      drivers/base: make device_find_child_by_name() compatible with sysfs inputs · c77f520d
      Dan Williams authored
      Use sysfs_streq() in device_find_child_by_name() to allow it to use a
      sysfs input string that might contain a trailing newline.
      
      The other "device by name" interfaces,
      {bus,driver,class}_find_device_by_name(), already account for sysfs
      strings.
      Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Ard Biesheuvel <ardb@kernel.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Ben Skeggs <bskeggs@redhat.com>
      Cc: Bjorn Helgaas <bhelgaas@google.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
      Cc: Brice Goglin <Brice.Goglin@inria.fr>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Daniel Vetter <daniel@ffwll.ch>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Dave Jiang <dave.jiang@intel.com>
      Cc: David Airlie <airlied@linux.ie>
      Cc: David Hildenbrand <david@redhat.com>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Hulk Robot <hulkci@huawei.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Ira Weiny <ira.weiny@intel.com>
      Cc: Jason Gunthorpe <jgg@mellanox.com>
      Cc: Jason Yan <yanaijie@huawei.com>
      Cc: Jeff Moyer <jmoyer@redhat.com>
      Cc: "Jérôme Glisse" <jglisse@redhat.com>
      Cc: Jia He <justin.he@arm.com>
      Cc: Joao Martins <joao.m.martins@oracle.com>
      Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
      Cc: Juergen Gross <jgross@suse.com>
      Cc: kernel test robot <lkp@intel.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Mike Rapoport <rppt@linux.ibm.com>
      Cc: Paul Mackerras <paulus@ozlabs.org>
      Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
      Cc: Randy Dunlap <rdunlap@infradead.org>
      Cc: Stefano Stabellini <sstabellini@kernel.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Tom Lendacky <thomas.lendacky@amd.com>
      Cc: Vishal Verma <vishal.l.verma@intel.com>
      Cc: Vivek Goyal <vgoyal@redhat.com>
      Cc: Wei Yang <richard.weiyang@linux.alibaba.com>
      Cc: Will Deacon <will@kernel.org>
      Link: https://lkml.kernel.org/r/159643102106.4062302.12229802117645312104.stgit@dwillia2-desk3.amr.corp.intel.com
      Link: https://lkml.kernel.org/r/160106114576.30709.2960091665444712180.stgit@dwillia2-desk3.amr.corp.intel.comSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      c77f520d
  8. 02 Oct, 2020 3 commits
    • Joe Perches's avatar
      drivers core: Miscellaneous changes for sysfs_emit · 948b3edb
      Joe Perches authored
      Change additional instances that could use sysfs_emit and sysfs_emit_at
      that the coccinelle script could not convert.
      
      o macros creating show functions with ## concatenation
      o unbound sprintf uses with buf+len for start of output to sysfs_emit_at
      o returns with ?: tests and sprintf to sysfs_emit
      o sysfs output with struct class * not struct device * arguments
      
      Miscellanea:
      
      o remove unnecessary initializations around these changes
      o consistently use int len for return length of show functions
      o use octal permissions and not S_<FOO>
      o rename a few show function names so DEVICE_ATTR_<FOO> can be used
      o use DEVICE_ATTR_ADMIN_RO where appropriate
      o consistently use const char *output for strings
      o checkpatch/style neatening
      Signed-off-by: default avatarJoe Perches <joe@perches.com>
      Link: https://lore.kernel.org/r/8bc24444fe2049a9b2de6127389b57edfdfe324d.1600285923.git.joe@perches.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      948b3edb
    • Joe Perches's avatar
      drivers core: Remove strcat uses around sysfs_emit and neaten · 973c3911
      Joe Perches authored
      strcat is no longer necessary for sysfs_emit and sysfs_emit_at uses.
      
      Convert the strcat uses to sysfs_emit calls and neaten other block
      uses of direct returns to use an intermediate const char *.
      Signed-off-by: default avatarJoe Perches <joe@perches.com>
      Link: https://lore.kernel.org/r/5d606519698ce4c8f1203a2b35797d8254c6050a.1600285923.git.joe@perches.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      973c3911
    • Joe Perches's avatar
      drivers core: Use sysfs_emit and sysfs_emit_at for show(device *...) functions · aa838896
      Joe Perches authored
      Convert the various sprintf fmaily calls in sysfs device show functions
      to sysfs_emit and sysfs_emit_at for PAGE_SIZE buffer safety.
      
      Done with:
      
      $ spatch -sp-file sysfs_emit_dev.cocci --in-place --max-width=80 .
      
      And cocci script:
      
      $ cat sysfs_emit_dev.cocci
      @@
      identifier d_show;
      identifier dev, attr, buf;
      @@
      
      ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf)
      {
      	<...
      	return
      -	sprintf(buf,
      +	sysfs_emit(buf,
      	...);
      	...>
      }
      
      @@
      identifier d_show;
      identifier dev, attr, buf;
      @@
      
      ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf)
      {
      	<...
      	return
      -	snprintf(buf, PAGE_SIZE,
      +	sysfs_emit(buf,
      	...);
      	...>
      }
      
      @@
      identifier d_show;
      identifier dev, attr, buf;
      @@
      
      ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf)
      {
      	<...
      	return
      -	scnprintf(buf, PAGE_SIZE,
      +	sysfs_emit(buf,
      	...);
      	...>
      }
      
      @@
      identifier d_show;
      identifier dev, attr, buf;
      expression chr;
      @@
      
      ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf)
      {
      	<...
      	return
      -	strcpy(buf, chr);
      +	sysfs_emit(buf, chr);
      	...>
      }
      
      @@
      identifier d_show;
      identifier dev, attr, buf;
      identifier len;
      @@
      
      ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf)
      {
      	<...
      	len =
      -	sprintf(buf,
      +	sysfs_emit(buf,
      	...);
      	...>
      	return len;
      }
      
      @@
      identifier d_show;
      identifier dev, attr, buf;
      identifier len;
      @@
      
      ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf)
      {
      	<...
      	len =
      -	snprintf(buf, PAGE_SIZE,
      +	sysfs_emit(buf,
      	...);
      	...>
      	return len;
      }
      
      @@
      identifier d_show;
      identifier dev, attr, buf;
      identifier len;
      @@
      
      ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf)
      {
      	<...
      	len =
      -	scnprintf(buf, PAGE_SIZE,
      +	sysfs_emit(buf,
      	...);
      	...>
      	return len;
      }
      
      @@
      identifier d_show;
      identifier dev, attr, buf;
      identifier len;
      @@
      
      ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf)
      {
      	<...
      -	len += scnprintf(buf + len, PAGE_SIZE - len,
      +	len += sysfs_emit_at(buf, len,
      	...);
      	...>
      	return len;
      }
      
      @@
      identifier d_show;
      identifier dev, attr, buf;
      expression chr;
      @@
      
      ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf)
      {
      	...
      -	strcpy(buf, chr);
      -	return strlen(buf);
      +	return sysfs_emit(buf, chr);
      }
      Signed-off-by: default avatarJoe Perches <joe@perches.com>
      Link: https://lore.kernel.org/r/3d033c33056d88bbe34d4ddb62afd05ee166ab9a.1600285923.git.joe@perches.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      aa838896
  9. 22 Sep, 2020 1 commit
  10. 17 Sep, 2020 2 commits
  11. 04 Sep, 2020 2 commits
  12. 21 Aug, 2020 1 commit
  13. 30 Jul, 2020 2 commits
  14. 24 Jul, 2020 1 commit
  15. 23 Jul, 2020 1 commit
  16. 10 Jul, 2020 5 commits
  17. 17 Jun, 2020 1 commit
  18. 27 May, 2020 1 commit
    • Saravana Kannan's avatar
      driver core: Update device link status correctly for SYNC_STATE_ONLY links · 8c3e315d
      Saravana Kannan authored
      When SYNC_STATE_ONLY support was added in commit 05ef983e ("driver
      core: Add device link support for SYNC_STATE_ONLY flag"),
      SYNC_STATE_ONLY links were treated similar to STATELESS links in terms
      of not blocking consumer probe if the supplier hasn't probed yet.
      
      That caused a SYNC_STATE_ONLY device link's status to not get updated.
      Since SYNC_STATE_ONLY device link is no longer useful once the
      consumer probes, commit 21c27f06 ("driver core: Fix
      SYNC_STATE_ONLY device link implementation") addresses the status
      update issue by deleting the SYNC_STATE_ONLY device link instead of
      complicating the status update code.
      
      However, there are still some cases where we need to update the status
      of a SYNC_STATE_ONLY device link. This is because a SYNC_STATE_ONLY
      device link can later get converted into a normal MANAGED device link
      when a normal MANAGED device link is created between a supplier and
      consumer that already have a SYNC_STATE_ONLY device link between them.
      
      If a SYNC_STATE_ONLY device link's status isn't maintained correctly
      till it's converted to a normal MANAGED device link, then the normal
      MANAGED device link will end up with a wrong link status. This can cause
      a warning stack trace[1] when the consumer device probes successfully.
      
      This commit fixes the SYNC_STATE_ONLY device link status update issue
      where it wouldn't transition correctly from DL_STATE_DORMANT or
      DL_STATE_AVAILABLE to DL_STATE_CONSUMER_PROBE. It also resets the status
      back to DL_STATE_DORMANT or DL_STATE_AVAILABLE if the consumer probe
      fails.
      
      [1] - https://lore.kernel.org/lkml/20200522204120.3b3c9ed6@apollo/
      Fixes: 05ef983e ("driver core: Add device link support for SYNC_STATE_ONLY flag")
      Fixes: 21c27f06 ("driver core: Fix SYNC_STATE_ONLY device link implementation")
      Reported-by: default avatarMichael Walle <michael@walle.cc>
      Tested-by: default avatarMichael Walle <michael@walle.cc>
      Signed-off-by: default avatarSaravana Kannan <saravanak@google.com>
      Reviewed-by: default avatarRafael J. Wysocki <rrafael.j.wysocki@intel.com>
      Link: https://lore.kernel.org/r/20200526220928.49939-1-saravanak@google.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8c3e315d
  19. 21 May, 2020 1 commit