1. 17 8月, 2020 4 次提交
    • N
      s390/pci: fix PF/VF linking on hot plug · b97bf44f
      Niklas Schnelle 提交于
      Currently there are four places in which a PCI function is scanned
      and made available to drivers:
       1. In pci_scan_root_bus() as part of the initial zbus
          creation.
       2. In zpci_bus_add_devices() when registering
          a device in configured state on a zbus that has already been
          scanned.
       3. When a function is already known to zPCI (in reserved/standby state)
          and configuration is triggered through firmware by PEC 0x301.
       4. When a device is already known to zPCI (in standby/reserved state)
          and configuration is triggered from within Linux using
          enable_slot().
      
      The PF/VF linking step and setting of pdev->is_virtfn introduced with
      commit e5794cf1 ("s390/pci: create links between PFs and VFs") was
      only triggered for the second case, which is where VFs created through
      sriov_numvfs usually land. However unlike some other platforms but like
      POWER VFs can be individually enabled/disabled through
      /sys/bus/pci/slots.
      
      Fix this by doing VF setup as part of pcibios_bus_add_device() which is
      called in all of the above cases.
      
      Finally to remove the PF/VF links call the common code
      pci_iov_remove_virtfn() function to remove linked VFs.
      This takes care of the necessary sysfs cleanup.
      
      Fixes: e5794cf1 ("s390/pci: create links between PFs and VFs")
      Cc: <stable@vger.kernel.org> # 5.8: 2f0230b2: s390/pci: re-introduce zpci_remove_device()
      Cc: <stable@vger.kernel.org> # 5.8
      Acked-by: NPierre Morel <pmorel@linux.ibm.com>
      Signed-off-by: NNiklas Schnelle <schnelle@linux.ibm.com>
      Signed-off-by: NHeiko Carstens <hca@linux.ibm.com>
      b97bf44f
    • N
      s390/pci: re-introduce zpci_remove_device() · 2f0230b2
      Niklas Schnelle 提交于
      For fixing the PF to VF link removal we need to perform some action on
      every removal of a zdev from the common PCI subsystem.
      So in preparation re-introduce zpci_remove_device() and use that instead
      of directly calling the common code functions. This  was actually still
      declared from earlier code but no longer implemented.
      Reviewed-by: NPierre Morel <pmorel@linux.ibm.com>
      Signed-off-by: NNiklas Schnelle <schnelle@linux.ibm.com>
      Signed-off-by: NHeiko Carstens <hca@linux.ibm.com>
      2f0230b2
    • N
      s390/pci: fix zpci_bus_link_virtfn() · 3cddb79a
      Niklas Schnelle 提交于
      We were missing the pci_dev_put() for candidate PFs.  Furhtermore in
      discussion with upstream it turns out that somewhat counterintuitively
      some common code, in particular the vfio-pci driver, assumes that
      pdev->is_virtfn always implies that pdev->physfn is set, i.e. that VFs
      are always linked.
      While POWER does seem to set pdev->is_virtfn even for unlinked functions
      (see comments in arch/powerpc/kernel/eeh.c:eeh_debugfs_break_device())
      for now just be safe and only set pdev->is_virtfn on linking.
      Also make sure that we only search for parent PFs if the zbus is
      multifunction and we thus know the devfn values supplied by firmware
      come from the RID.
      
      Fixes: e5794cf1 ("s390/pci: create links between PFs and VFs")
      Cc: <stable@vger.kernel.org> # 5.8
      Reviewed-by: NPierre Morel <pmorel@linux.ibm.com>
      Signed-off-by: NNiklas Schnelle <schnelle@linux.ibm.com>
      Signed-off-by: NHeiko Carstens <hca@linux.ibm.com>
      3cddb79a
    • N
      s390/pci: ignore stale configuration request event · b76fee1b
      Niklas Schnelle 提交于
      A configuration request event may be stale, that is the event
      may reference a zdev which was already configured.
      This can happen when a hotplug happens during boot such that
      the device is discovered and configured in the initial clp_list_pci(),
      then after initialization we enable events and process
      the original configuration request which additionally still contains
      the old disabled function handle leading to a failure during device
      enablement and subsequent I/O lockout.
      
      Fix this by restoring the check that the device to be configured is in
      standby which was removed in commit f606b3ef ("s390/pci: adapt events
      for zbus").
      
      This check does not need serialization as we only enable the events after
      zPCI has fully initialized, which includes the initial clp_list_pci(),
      rescan only does updates and events are serialized with respect to each
      other.
      
      Fixes: f606b3ef ("s390/pci: adapt events for zbus")
      Cc: <stable@vger.kernel.org> # 5.8
      Reported-by: NShalini Chellathurai Saroja <shalini@linux.ibm.com>
      Tested-by: NShalini Chellathurai Saroja <shalini@linux.ibm.com>
      Acked-by: NPierre Morel <pmorel@linux.ibm.com>
      Signed-off-by: NNiklas Schnelle <schnelle@linux.ibm.com>
      Signed-off-by: NHeiko Carstens <hca@linux.ibm.com>
      b76fee1b
  2. 27 7月, 2020 1 次提交
  3. 29 6月, 2020 1 次提交
    • N
      s390/pci: fix enabling a reserved PCI function · 3047766b
      Niklas Schnelle 提交于
      In usual IPL or hot plug scenarios a zPCI function transitions directly
      from reserved (invisible to Linux) to configured state or is configured
      by Linux itself using an SCLP, however it can also first go from
      reserved to standby and then from standby to configured without
      Linux initiative.
      In this scenario we first get a PEC event 0x302 and then 0x301.  This may
      happen for example when the device is deconfigured at another LPAR and
      made available for this LPAR. It may also happen under z/VM when
      a device is attached while in some inconsistent state.
      
      However when we get the 0x301 the device is already known to zPCI
      so calling zpci_create() will add it twice resulting in the below
      BUG. Instead we should only enable the existing device and finally
      scan it through the PCI subsystem.
      
      list_add double add: new=00000000ed5a9008, prev=00000000ed5a9008, next=0000000083502300.
      kernel BUG at lib/list_debug.c:31!
      Krnl PSW : 0704c00180000000 0000000082dc2db8 (__list_add_valid+0x70/0xa8)
      Call Trace:
       [<0000000082dc2db8>] __list_add_valid+0x70/0xa8
      ([<0000000082dc2db4>] __list_add_valid+0x6c/0xa8)
       [<00000000828ea920>] zpci_create_device+0x60/0x1b0
       [<00000000828ef04a>] zpci_event_availability+0x282/0x2f0
       [<000000008315f848>] chsc_process_crw+0x2b8/0xa18
       [<000000008316735c>] crw_collect_info+0x254/0x348
       [<00000000829226ea>] kthread+0x14a/0x168
       [<000000008319d5c0>] ret_from_fork+0x24/0x2c
      
      Fixes: f606b3ef ("s390/pci: adapt events for zbus")
      Reported-by: NAlexander Egorenkov <egorenar@linux.ibm.com>
      Tested-by: NAlexander Egorenkov <egorenar@linux.ibm.com>
      Signed-off-by: NNiklas Schnelle <schnelle@linux.ibm.com>
      Signed-off-by: NHeiko Carstens <heiko.carstens@de.ibm.com>
      3047766b
  4. 10 6月, 2020 1 次提交
  5. 28 5月, 2020 1 次提交
  6. 20 5月, 2020 2 次提交
  7. 15 5月, 2020 1 次提交
    • N
      s390/pci: Fix s390_mmio_read/write with MIO · f058599e
      Niklas Schnelle 提交于
      The s390_mmio_read/write syscalls are currently broken when running with
      MIO.
      
      The new pcistb_mio/pcstg_mio/pcilg_mio instructions are executed
      similiarly to normal load/store instructions and do address translation
      in the current address space. That means inside the kernel they are
      aware of mappings into kernel address space while outside the kernel
      they use user space mappings (usually created through mmap'ing a PCI
      device file).
      
      Now when existing user space applications use the s390_pci_mmio_write
      and s390_pci_mmio_read syscalls, they pass I/O addresses that are mapped
      into user space so as to be usable with the new instructions without
      needing a syscall. Accessing these addresses with the old instructions
      as done currently leads to a kernel panic.
      
      Also, for such a user space mapping there may not exist an equivalent
      kernel space mapping which means we can't just use the new instructions
      in kernel space.
      
      Instead of replicating user mappings in the kernel which then might
      collide with other mappings, we can conceptually execute the new
      instructions as if executed by the user space application using the
      secondary address space. This even allows us to directly store to the
      user pointer without the need for copy_to/from_user().
      
      Cc: stable@vger.kernel.org
      Fixes: 71ba41c9 ("s390/pci: provide support for MIO instructions")
      Signed-off-by: NNiklas Schnelle <schnelle@linux.ibm.com>
      Reviewed-by: NSven Schnelle <svens@linux.ibm.com>
      Signed-off-by: NVasily Gorbik <gor@linux.ibm.com>
      f058599e
  8. 06 5月, 2020 1 次提交
  9. 28 4月, 2020 7 次提交
  10. 22 4月, 2020 1 次提交
  11. 23 3月, 2020 3 次提交
  12. 04 3月, 2020 1 次提交
  13. 22 1月, 2020 2 次提交
    • N
      s390/pci: Fix possible deadlock in recover_store() · 576c75e3
      Niklas Schnelle 提交于
      With zpci_disable() working, lockdep detected a potential deadlock
      (lockdep output at the end).
      
      The deadlock is between recovering a PCI function via the
      
      /sys/bus/pci/devices/<dev>/recover
      
      attribute vs powering it off via
      
      /sys/bus/pci/slots/<slot>/power.
      
      The fix is analogous to the changes in commit 0ee223b2 ("scsi: core:
      Avoid that SCSI device removal through sysfs triggers a deadlock")
      that fixed a potential deadlock on removing a SCSI device via sysfs.
      
      [  204.830107] ======================================================
      [  204.830109] WARNING: possible circular locking dependency detected
      [  204.830111] 5.5.0-rc2-06072-gbc03ecc9a672 #6 Tainted: G        W
      [  204.830112] ------------------------------------------------------
      [  204.830113] bash/1034 is trying to acquire lock:
      [  204.830115] 0000000192a1a610 (kn->count#200){++++}, at: kernfs_remove_by_name_ns+0x5c/0xa8
      [  204.830122]
                     but task is already holding lock:
      [  204.830123] 00000000c16134a8 (pci_rescan_remove_lock){+.+.}, at: pci_stop_and_remove_bus_device_locked+0x26/0x48
      [  204.830128]
                     which lock already depends on the new lock.
      
      [  204.830129]
                     the existing dependency chain (in reverse order) is:
      [  204.830130]
                     -> #1 (pci_rescan_remove_lock){+.+.}:
      [  204.830134]        validate_chain+0x93a/0xd08
      [  204.830136]        __lock_acquire+0x4ae/0x9d0
      [  204.830137]        lock_acquire+0x114/0x280
      [  204.830140]        __mutex_lock+0xa2/0x960
      [  204.830142]        mutex_lock_nested+0x32/0x40
      [  204.830145]        recover_store+0x4c/0xa8
      [  204.830147]        kernfs_fop_write+0xe6/0x218
      [  204.830151]        vfs_write+0xb0/0x1b8
      [  204.830152]        ksys_write+0x6c/0xf8
      [  204.830154]        system_call+0xd8/0x2d8
      [  204.830155]
                     -> #0 (kn->count#200){++++}:
      [  204.830187]        check_noncircular+0x1e6/0x240
      [  204.830189]        check_prev_add+0xfc/0xdb0
      [  204.830190]        validate_chain+0x93a/0xd08
      [  204.830192]        __lock_acquire+0x4ae/0x9d0
      [  204.830193]        lock_acquire+0x114/0x280
      [  204.830194]        __kernfs_remove.part.0+0x2e4/0x360
      [  204.830196]        kernfs_remove_by_name_ns+0x5c/0xa8
      [  204.830198]        remove_files.isra.0+0x4c/0x98
      [  204.830199]        sysfs_remove_group+0x66/0xc8
      [  204.830201]        sysfs_remove_groups+0x46/0x68
      [  204.830204]        device_remove_attrs+0x52/0x90
      [  204.830207]        device_del+0x182/0x418
      [  204.830208]        pci_remove_bus_device+0x8a/0x130
      [  204.830210]        pci_stop_and_remove_bus_device_locked+0x3a/0x48
      [  204.830212]        disable_slot+0x68/0x100
      [  204.830213]        power_write_file+0x7c/0x130
      [  204.830215]        kernfs_fop_write+0xe6/0x218
      [  204.830217]        vfs_write+0xb0/0x1b8
      [  204.830218]        ksys_write+0x6c/0xf8
      [  204.830220]        system_call+0xd8/0x2d8
      [  204.830221]
                     other info that might help us debug this:
      
      [  204.830223]  Possible unsafe locking scenario:
      
      [  204.830224]        CPU0                    CPU1
      [  204.830225]        ----                    ----
      [  204.830226]   lock(pci_rescan_remove_lock);
      [  204.830227]                                lock(kn->count#200);
      [  204.830229]                                lock(pci_rescan_remove_lock);
      [  204.830231]   lock(kn->count#200);
      [  204.830233]
                      *** DEADLOCK ***
      
      [  204.830234] 4 locks held by bash/1034:
      [  204.830235]  #0: 00000001b6fbc498 (sb_writers#4){.+.+}, at: vfs_write+0x158/0x1b8
      [  204.830239]  #1: 000000018c9f5090 (&of->mutex){+.+.}, at: kernfs_fop_write+0xaa/0x218
      [  204.830242]  #2: 00000001f7da0810 (kn->count#235){.+.+}, at: kernfs_fop_write+0xb6/0x218
      [  204.830245]  #3: 00000000c16134a8 (pci_rescan_remove_lock){+.+.}, at: pci_stop_and_remove_bus_device_locked+0x26/0x48
      [  204.830248]
                     stack backtrace:
      [  204.830250] CPU: 2 PID: 1034 Comm: bash Tainted: G        W         5.5.0-rc2-06072-gbc03ecc9a672 #6
      [  204.830252] Hardware name: IBM 8561 T01 703 (LPAR)
      [  204.830253] Call Trace:
      [  204.830257]  [<00000000c05e10c0>] show_stack+0x88/0xf0
      [  204.830260]  [<00000000c112dca4>] dump_stack+0xa4/0xe0
      [  204.830261]  [<00000000c0694c06>] check_noncircular+0x1e6/0x240
      [  204.830263]  [<00000000c0695bec>] check_prev_add+0xfc/0xdb0
      [  204.830264]  [<00000000c06971da>] validate_chain+0x93a/0xd08
      [  204.830266]  [<00000000c06994c6>] __lock_acquire+0x4ae/0x9d0
      [  204.830267]  [<00000000c069867c>] lock_acquire+0x114/0x280
      [  204.830269]  [<00000000c09ca15c>] __kernfs_remove.part.0+0x2e4/0x360
      [  204.830270]  [<00000000c09cb5c4>] kernfs_remove_by_name_ns+0x5c/0xa8
      [  204.830272]  [<00000000c09cee14>] remove_files.isra.0+0x4c/0x98
      [  204.830274]  [<00000000c09cf2ae>] sysfs_remove_group+0x66/0xc8
      [  204.830276]  [<00000000c09cf356>] sysfs_remove_groups+0x46/0x68
      [  204.830278]  [<00000000c0e3dfe2>] device_remove_attrs+0x52/0x90
      [  204.830280]  [<00000000c0e40382>] device_del+0x182/0x418
      [  204.830281]  [<00000000c0dcfd7a>] pci_remove_bus_device+0x8a/0x130
      [  204.830283]  [<00000000c0dcfe92>] pci_stop_and_remove_bus_device_locked+0x3a/0x48
      [  204.830285]  [<00000000c0de7190>] disable_slot+0x68/0x100
      [  204.830286]  [<00000000c0de6514>] power_write_file+0x7c/0x130
      [  204.830288]  [<00000000c09cc846>] kernfs_fop_write+0xe6/0x218
      [  204.830290]  [<00000000c08f3480>] vfs_write+0xb0/0x1b8
      [  204.830291]  [<00000000c08f378c>] ksys_write+0x6c/0xf8
      [  204.830293]  [<00000000c1154374>] system_call+0xd8/0x2d8
      [  204.830294] INFO: lockdep is turned off.
      Signed-off-by: NNiklas Schnelle <schnelle@linux.ibm.com>
      Reviewed-by: NPeter Oberparleiter <oberpar@linux.ibm.com>
      Signed-off-by: NVasily Gorbik <gor@linux.ibm.com>
      576c75e3
    • N
      s390/pci: Recover handle in clp_set_pci_fn() · 17cdec96
      Niklas Schnelle 提交于
      When we try to recover a PCI function using
      
          echo 1 > /sys/bus/pci/devices/<id>/recover
      
      or manually with
      
          echo 1 > /sys/bus/pci/devices/<id>/remove
          echo 0 > /sys/bus/pci/slots/<slot>/power
          echo 1 > /sys/bus/pci/slots/<slot>/power
      
      clp_disable_fn() / clp_enable_fn() call clp_set_pci_fn() to first
      disable and then reenable the function.
      
      When the function is already in the requested state we may be left with
      an invalid function handle.
      
      To get a new valid handle we do a clp_list_pci() call. For this we need
      both the function ID and function handle in clp_set_pci_fn() so pass the
      zdev and get both.
      
      To simplify things also pull setting the refreshed function handle into
      clp_set_pci_fn()
      Signed-off-by: NNiklas Schnelle <schnelle@linux.ibm.com>
      Reviewed-by: NPeter Oberparleiter <oberpar@linux.ibm.com>
      Signed-off-by: NVasily Gorbik <gor@linux.ibm.com>
      17cdec96
  14. 30 11月, 2019 2 次提交
  15. 14 10月, 2019 1 次提交
  16. 04 10月, 2019 1 次提交
  17. 16 9月, 2019 1 次提交
  18. 04 9月, 2019 1 次提交
    • C
      dma-mapping: explicitly wire up ->mmap and ->get_sgtable · f9f3232a
      Christoph Hellwig 提交于
      While the default ->mmap and ->get_sgtable implementations work for the
      majority of our dma_map_ops impementations they are inherently safe
      for others that don't use the page allocator or CMA and/or use their
      own way of remapping not covered by the common code.  So remove the
      defaults if these methods are not wired up, but instead wire up the
      default implementations for all safe instances.
      
      Fixes: e1c7e324 ("dma-mapping: always provide the dma_map_ops based implementation")
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      f9f3232a
  19. 29 8月, 2019 1 次提交
  20. 21 8月, 2019 1 次提交
  21. 12 7月, 2019 2 次提交
  22. 04 7月, 2019 2 次提交
  23. 03 6月, 2019 2 次提交
    • M
      locking/atomic, s390/pci: Remove redundant casts · 6a6a9d5f
      Mark Rutland 提交于
      Now that atomic64_read() returns s64 consistently, we don't need to
      explicitly cast its return value. Drop the redundant casts.
      Signed-off-by: NMark Rutland <mark.rutland@arm.com>
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: aou@eecs.berkeley.edu
      Cc: arnd@arndb.de
      Cc: bp@alien8.de
      Cc: catalin.marinas@arm.com
      Cc: davem@davemloft.net
      Cc: fenghua.yu@intel.com
      Cc: herbert@gondor.apana.org.au
      Cc: ink@jurassic.park.msu.ru
      Cc: jhogan@kernel.org
      Cc: linux@armlinux.org.uk
      Cc: mattst88@gmail.com
      Cc: mpe@ellerman.id.au
      Cc: palmer@sifive.com
      Cc: paul.burton@mips.com
      Cc: paulus@samba.org
      Cc: ralf@linux-mips.org
      Cc: rth@twiddle.net
      Cc: tony.luck@intel.com
      Cc: vgupta@synopsys.com
      Link: https://lkml.kernel.org/r/20190522132250.26499-19-mark.rutland@arm.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      6a6a9d5f
    • M
      locking/atomic, s390/pci: Prepare for atomic64_read() conversion · 982164d6
      Mark Rutland 提交于
      The return type of atomic64_read() varies by architecture. It may return
      long (e.g. powerpc), long long (e.g. arm), or s64 (e.g. x86_64). This is
      somewhat painful, and mandates the use of explicit casts in some cases
      (e.g. when printing the return value).
      
      To ameliorate matters, subsequent patches will make the atomic64 API
      consistently use s64.
      
      As a preparatory step, this patch updates the s390 pci debug code to
      treat the return value of atomic64_read() as s64, using an explicit
      cast. This cast will be removed once the s64 conversion is complete.
      Signed-off-by: NMark Rutland <mark.rutland@arm.com>
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: aou@eecs.berkeley.edu
      Cc: arnd@arndb.de
      Cc: bp@alien8.de
      Cc: catalin.marinas@arm.com
      Cc: davem@davemloft.net
      Cc: fenghua.yu@intel.com
      Cc: herbert@gondor.apana.org.au
      Cc: ink@jurassic.park.msu.ru
      Cc: jhogan@kernel.org
      Cc: linux@armlinux.org.uk
      Cc: mattst88@gmail.com
      Cc: mpe@ellerman.id.au
      Cc: palmer@sifive.com
      Cc: paul.burton@mips.com
      Cc: paulus@samba.org
      Cc: ralf@linux-mips.org
      Cc: rth@twiddle.net
      Cc: tony.luck@intel.com
      Cc: vgupta@synopsys.com
      Link: https://lkml.kernel.org/r/20190522132250.26499-3-mark.rutland@arm.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      982164d6