1. 17 9月, 2022 1 次提交
    • H
      PCI: loongson: Improve the MRRS quirk for LS7A · 81e3f828
      Huacai Chen 提交于
      LoongArch inclusion
      category: feature
      bugzilla: https://gitee.com/openeuler/kernel/issues/I5OHOB
      
      --------------------------------
      
      In new revision of LS7A, some PCIe ports support larger value than 256,
      but their maximum supported MRRS values are not detectable. Moreover,
      the current loongson_mrrs_quirk() cannot avoid devices increasing its
      MRRS after pci_enable_device(), and some devices (e.g. Realtek 8169)
      will actually set a big value in its driver. So the only possible way
      is configure MRRS of all devices in BIOS, and add a pci host bridge bit
      flag (i.e., no_inc_mrrs) to stop the increasing MRRS operations.
      
      However, according to PCIe Spec, it is legal for an OS to program any
      value for MRRS, and it is also legal for an endpoint to generate a Read
      Request with any size up to its MRRS. As the hardware engineers say, the
      root cause here is LS7A doesn't break up large read requests. In detail,
      LS7A PCIe port reports CA (Completer Abort) if it receives a Memory Read
      request with a size that's "too big" ("too big" means larger than the
      PCIe ports can handle, which means 256 for some ports and 4096 for the
      others, and of course this is a problem in the LS7A's hardware design).
      Signed-off-by: NHuacai Chen <chenhuacai@loongson.cn>
      81e3f828
  2. 21 4月, 2022 3 次提交
  3. 31 12月, 2021 2 次提交
    • T
      kabi: reserve space for pci subsystem related structure · d93099c0
      Tan Xiaojun 提交于
      hulk inclusion
      category: feature
      bugzilla: https://gitee.com/openeuler/kernel/issues/I4JBL0
      CVE: NA
      
      -------------------------------
      
      Reserve space for the structure in pci subsystem.
      Signed-off-by: NTan Xiaojun <tanxiaojun@huawei.com>
      Reviewed-by: NXie XiuQi <xiexiuqi@huawei.com>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      Signed-off-by: NJialin Zhang <zhangjialin11@huawei.com>
      Reviewed-by: Nwangxiongfeng 00379786 <wangxiongfeng2@huawei.com>
      Reviewed-by: NYang Yingliang <yangyingliang@huawei.com>
      Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
      d93099c0
    • X
      pciehp: fix a race between pciehp and removing operations by sysfs · 601aca9f
      Xiongfeng Wang 提交于
      hulk inclusion
      category: bugfix
      bugzilla: 16100,20881,https://gitee.com/openeuler/kernel/issues/I4OG3O?from=project-issue
      CVE: NA
      
      -------------------------------------------------
      
      When I run a stress test about pcie hotplug and removing operations by
      sysfs, I got a hange task, and the following call trace is printed.
      
       INFO: task irq/746-pciehp:41551 blocked for more than 120 seconds.
             Tainted: P        W  OE     4.19.25-
       "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
       irq/746-pciehp  D    0 41551      2 0x00000228
       Call trace:
        __switch_to+0x94/0xe8
        __schedule+0x270/0x8b0
        schedule+0x2c/0x88
        schedule_preempt_disabled+0x14/0x20
        __mutex_lock.isra.1+0x1fc/0x540
        __mutex_lock_slowpath+0x24/0x30
        mutex_lock+0x80/0xa8
        pci_lock_rescan_remove+0x20/0x28
        pciehp_configure_device+0x30/0x140
        pciehp_handle_presence_or_link_change+0x35c/0x4b0
        pciehp_ist+0x1cc/0x1d0
        irq_thread_fn+0x30/0x80
        irq_thread+0x128/0x200
        kthread+0x134/0x138
        ret_from_fork+0x10/0x18
       INFO: task bash:6424 blocked for more than 120 seconds.
             Tainted: P        W  OE     4.19.25-
       "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
       bash            D    0  6424   2231 0x00000200
       Call trace:
        __switch_to+0x94/0xe8
        __schedule+0x270/0x8b0
        schedule+0x2c/0x88
        schedule_timeout+0x224/0x448
        wait_for_common+0x198/0x2a0
        wait_for_completion+0x28/0x38
        kthread_stop+0x60/0x190
        __free_irq+0x1c0/0x348
        free_irq+0x40/0x88
        pcie_shutdown_notification+0x54/0x80
        pciehp_remove+0x30/0x50
        pcie_port_remove_service+0x3c/0x58
        device_release_driver_internal+0x1b4/0x250
        device_release_driver+0x28/0x38
        bus_remove_device+0xd4/0x160
        device_del+0x128/0x348
        device_unregister+0x24/0x78
        remove_iter+0x48/0x58
        device_for_each_child+0x6c/0xb8
        pcie_port_device_remove+0x2c/0x48
        pcie_portdrv_remove+0x5c/0x68
        pci_device_remove+0x48/0xd8
        device_release_driver_internal+0x1b4/0x250
        device_release_driver+0x28/0x38
        pci_stop_bus_device+0x84/0xb8
        pci_stop_and_remove_bus_device_locked+0x24/0x40
        remove_store+0xa4/0xb8
        dev_attr_store+0x44/0x60
        sysfs_kf_write+0x58/0x80
        kernfs_fop_write+0xe8/0x1f0
        __vfs_write+0x60/0x190
        vfs_write+0xac/0x1c0
        ksys_write+0x6c/0xd8
        __arm64_sys_write+0x24/0x30
        el0_svc_common+0xa0/0x180
        el0_svc_handler+0x38/0x78
        el0_svc+0x8/0xc
      
      When we remove a slot by sysfs.
      'pci_stop_and_remove_bus_device_locked()' will be called. This function
      will get the global mutex lock 'pci_rescan_remove_lock', and remove the
      slot. If the irq thread 'pciehp_ist' is still running, we will wait
      until it exits.
      
      If a pciehp interrupt happens immediately after we remove the slot by
      sysfs, but before we free the pciehp irq in
      'pci_stop_and_remove_bus_device_locked()'. 'pciehp_ist' will hung
      because the global mutex lock 'pci_rescan_remove_lock' is held by the
      sysfs operation. But the sysfs operation is waiting for the pciehp irq
      thread 'pciehp_ist' ends. Then a hung task occurs.
      
      So this two kinds of operation, removing through attention buttion and
      removing through /sys/devices/pci***/remove, should not be excuted at
      the same time. This patch add a global variable to mark that one of these
      operations is under processing. When this variable is set,  if another
      operation is requested, it will be rejected.
      
      We use a global variable 'slot_being_removed_rescaned' to mark whether a
      slot is being removed or rescaned. This will cause a slot hotplug
      operation is delayed if another slot is being remove or rescaned. But
      if these two slots are under different root ports, they should not
      influence each other. This patch make the flag
      'slot_being_removed_rescanned' per root port so that one slot hotplug
      operation doesn't influence slots below another root port.
      
      We record the root port in struct pci_dev when the pci device is
      initialized and added into the system instead of using
      'pcie_find_root_port()' to find the root port when we need it. Because
      iterating the pci tree needs the protection of
      'pci_lock_rescan_remove()'. This will make the problem more complexed
      because the lock is very coarse-grained. We don't need to worry about
      'use-after-free' because child pci devices are always removed before the
      root port device is removed.
      Signed-off-by: NXiongfeng Wang <wangxiongfeng2@huawei.com>
      Reviewed-by: NHanjun Guo <guohanjun@huawei.com>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      Signed-off-by: NJialin Zhang <zhangjialin11@huawei.com>
      Reviewed-by: NXiongfeng Wang <wangxiongfeng2@huawei.com>
      Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
      601aca9f
  4. 06 12月, 2021 1 次提交
  5. 21 10月, 2021 1 次提交
  6. 26 9月, 2021 1 次提交
  7. 08 2月, 2021 1 次提交
    • X
      PCI: add a member in 'struct pci_bus' to record the original 'pci_ops' · 8dd667f5
      Xiongfeng Wang 提交于
      hulk inclusion
      category: bugfix
      bugzilla: 47453
      CVE: NA
      
      -------------------------------------------------------------------------
      
      When I test 'aer-inject' with the following procedures:
      1. inject a fatal error into a upstream PCI bridge
      2. remove the upstream bridge by sysfs
      3. rescan the PCI tree by 'echo 1 > /sys/bus/pci/rescan'
      4. execute command 'rmmod aer-inject'
      5. remove the upstream bridge by sysfs again
      
      I came across the following Oops.
      
      [  799.713238] Internal error: Oops: 96000007 [#1] SMP
      [  799.718099] Process bash (pid: 10683, stack limit = 0x00000000125a3b1b)
      [  799.724686] CPU: 108 PID: 10683 Comm: bash Kdump: loaded Not tainted 4.19.36 #2
      [  799.731962] Hardware name: Huawei TaiShan 2280 V2/BC82AMDD, BIOS 1.05 09/18/2019
      [  799.739325] pstate: 40400009 (nZcv daif +PAN -UAO)
      [  799.744104] pc : pci_remove_bus+0xc0/0x1c0
      [  799.748182] lr : pci_remove_bus+0x94/0x1c0
      [  799.752260] sp : ffffa02e335df940
      [  799.755560] x29: ffffa02e335df940 x28: ffff2000088216a8
      [  799.760849] x27: 1ffff405c66bbfbc x26: ffff20000a9518c0
      [  799.766139] x25: ffffa02dea6ec418 x24: 1ffff405bd4dd883
      [  799.771427] x23: ffffa02e72576628 x22: 1ffff405ce4aecc0
      [  799.776715] x21: ffffa02e72576608 x20: ffff200002e75080
      [  799.782003] x19: ffffa02e72576600 x18: 0000000000000000
      [  799.787291] x17: 0000000000000000 x16: 0000000000000000
      [  799.792578] x15: 0000000000000001 x14: dfff200000000000
      [  799.797866] x13: ffff20000a6dfaf0 x12: 0000000000000000
      [  799.803154] x11: 1fffe4000159b217 x10: ffff04000159b217
      [  799.808442] x9 : dfff200000000000 x8 : ffff20000acd90bf
      [  799.813730] x7 : 0000000000000000 x6 : 0000000000000000
      [  799.819017] x5 : 0000000000000001 x4 : 0000000000000000
      [  799.824306] x3 : 1ffff405dbe62603 x2 : 1fffe400005cea11
      [  799.829593] x1 : dfff200000000000 x0 : ffff200002e75088
      [  799.834882] Call trace:
      [  799.837323]  pci_remove_bus+0xc0/0x1c0
      [  799.841056]  pci_remove_bus_device+0xd0/0x2f0
      [  799.845392]  pci_stop_and_remove_bus_device_locked+0x2c/0x40
      [  799.851028]  remove_store+0x1b8/0x1d0
      [  799.854679]  dev_attr_store+0x60/0x80
      [  799.858330]  sysfs_kf_write+0x104/0x170
      [  799.862149]  kernfs_fop_write+0x23c/0x430
      [  799.866143]  __vfs_write+0xec/0x4e0
      [  799.869615]  vfs_write+0x12c/0x3d0
      [  799.873001]  ksys_write+0xd0/0x190
      [  799.876389]  __arm64_sys_write+0x70/0xa0
      [  799.880298]  el0_svc_common+0xfc/0x278
      [  799.884030]  el0_svc_handler+0x50/0xc0
      [  799.887764]  el0_svc+0x8/0xc
      [  799.890634] Code: d2c40001 f2fbffe1 91002280 d343fc02 (38e16841)
      [  799.896700] kernel fault(0x1) notification starting on CPU 108
      
      It is because when we alloc a new bus in rescanning process, the
      'pci_ops' of the newly allocced 'pci_bus' is inherited from its parent
      pci bus. Whereas, the 'pci_ops' of the parent bus may be changed to
      'aer_inj_pci_ops' in 'aer_inject()'. When we unload the module
      'aer_inject', we only restore the 'pci_ops' for the pci bus of the
      error-injected device and the root port in 'aer_inject_exit'. After we
      have unloaded the module, the 'pci_ops' of the newly allocced pci bus is
      still 'aer_inj_pci_ops'. When we access it, an Oops happened.
      
      This patch add a member 'backup_ops' in 'struct pci_bus' to record the
      original 'ops'. When we alloc a child pci bus, we assign the
      'backup_ops' of the parent bus to the 'ops' of the child bus.
      
      Maybe the best way is to not modify the 'pci_ops' in 'struct pci_bus',
      but this will refactor the 'aer_inject' framework a lot. I haven't found
      a better way to handle it.
      Signed-off-by: NXiongfeng Wang <wangxiongfeng2@huawei.com>
      Reviewed-by: NHanjun Guo <guohanjun@huawei.com>
      Signed-off-by: Nyangerkun <yangerkun@huawei.com>
      
      Conflicts:
      	drivers/pci/probe.c
      	include/linux/pci.h
      Signed-off-by: NXiongfeng Wang <wangxiongfeng2@huawei.com>
      Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
      8dd667f5
  8. 17 10月, 2020 1 次提交
  9. 30 9月, 2020 2 次提交
  10. 22 9月, 2020 1 次提交
  11. 07 9月, 2020 1 次提交
  12. 04 8月, 2020 1 次提交
  13. 30 7月, 2020 1 次提交
  14. 11 7月, 2020 2 次提交
  15. 08 7月, 2020 1 次提交
  16. 01 7月, 2020 1 次提交
  17. 02 6月, 2020 1 次提交
  18. 22 5月, 2020 1 次提交
  19. 20 5月, 2020 1 次提交
  20. 15 5月, 2020 1 次提交
  21. 12 5月, 2020 1 次提交
    • G
      PCI: Replace zero-length array with flexible-array · 914a1951
      Gustavo A. R. Silva 提交于
      The current codebase makes use of the zero-length array language extension
      to the C90 standard, but the preferred mechanism to declare variable-length
      types such as these as a flexible array member [1][2], introduced in C99:
      
        struct foo {
          int stuff;
          struct boo array[];
        };
      
      By making use of the mechanism above, we will get a compiler warning in
      case the flexible array does not occur last in the structure, which will
      help us prevent some kind of undefined behavior bugs from being
      inadvertently introduced[3] to the codebase from now on.
      
      Also, notice that dynamic memory allocations won't be affected by this
      change:
      
        Flexible array members have incomplete type, and so the sizeof operator
        may not be applied. As a quirk of the original implementation of
        zero-length arrays, sizeof evaluates to zero. [1]
      
      sizeof(flexible-array-member) triggers a warning because flexible array
      members have incomplete type [1]. There are some instances of code in which
      the sizeof() operator is being incorrectly/erroneously applied to
      zero-length arrays, and the result is zero. Such instances may be hiding
      some bugs. So, this work (flexible-array member conversions) will also help
      to get completely rid of those sorts of issues.
      
      This issue was found with the help of Coccinelle.
      
      [1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
      [2] https://github.com/KSPP/linux/issues/21
      [3] commit 76497732 ("cxgb3/l2t: Fix undefined behaviour")
      
      Link: https://lore.kernel.org/r/20200507190544.GA15633@embeddedorSigned-off-by: NGustavo A. R. Silva <gustavoars@kernel.org>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      914a1951
  22. 30 3月, 2020 2 次提交
    • I
      PCI: Add support for root bus sizing · 2c8d5a2d
      Ivan Kokshaysky 提交于
      In certain cases we should be able to enumerate IO and MEM ranges of all
      PCI devices installed in the system, and then set respective host bridge
      apertures basing on calculated size and alignment.  Particularly when
      firmware is broken and fails to assign bridge windows properly, like on
      Alpha UP1500 platform.
      
      Actually, almost everything is already in place, and required changes are
      minimal:
      
      - add "size_windows" flag to struct pci_host_bridge: when set, it
        instructs __pci_bus_size_bridges() to continue with the root bus;
      - in the __pci_bus_size_bridges() path: add checks for bus->self,
        as it can legitimately be null for the root bus.
      
      Link: https://lore.kernel.org/r/20200314194355.GA12510@mail.rc.ruTested-by: NMatt Turner <mattst88@gmail.com>
      Signed-off-by: NIvan Kokshaysky <ink@jurassic.park.msu.ru>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      2c8d5a2d
    • M
      PCI: Use ioremap(), not phys_to_virt() for platform ROM · 72e0ef0e
      Mikel Rychliski 提交于
      On some EFI systems, the video BIOS is provided by the EFI firmware.  The
      boot stub code stores the physical address of the ROM image in pdev->rom.
      Currently we attempt to access this pointer using phys_to_virt(), which
      doesn't work with CONFIG_HIGHMEM.
      
      On these systems, attempting to load the radeon module on a x86_32 kernel
      can result in the following:
      
        BUG: unable to handle page fault for address: 3e8ed03c
        #PF: supervisor read access in kernel mode
        #PF: error_code(0x0000) - not-present page
        *pde = 00000000
        Oops: 0000 [#1] PREEMPT SMP
        CPU: 0 PID: 317 Comm: systemd-udevd Not tainted 5.6.0-rc3-next-20200228 #2
        Hardware name: Apple Computer, Inc. MacPro1,1/Mac-F4208DC8, BIOS     MP11.88Z.005C.B08.0707021221 07/02/07
        EIP: radeon_get_bios+0x5ed/0xe50 [radeon]
        Code: 00 00 84 c0 0f 85 12 fd ff ff c7 87 64 01 00 00 00 00 00 00 8b 47 08 8b 55 b0 e8 1e 83 e1 d6 85 c0 74 1a 8b 55 c0 85 d2 74 13 <80> 38 55 75 0e 80 78 01 aa 0f 84 a4 03 00 00 8d 74 26 00 68 dc 06
        EAX: 3e8ed03c EBX: 00000000 ECX: 3e8ed03c EDX: 00010000
        ESI: 00040000 EDI: eec04000 EBP: eef3fc60 ESP: eef3fbe0
        DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068 EFLAGS: 00010206
        CR0: 80050033 CR2: 3e8ed03c CR3: 2ec77000 CR4: 000006d0
        Call Trace:
         r520_init+0x26/0x240 [radeon]
         radeon_device_init+0x533/0xa50 [radeon]
         radeon_driver_load_kms+0x80/0x220 [radeon]
         drm_dev_register+0xa7/0x180 [drm]
         radeon_pci_probe+0x10f/0x1a0 [radeon]
         pci_device_probe+0xd4/0x140
      
      Fix the issue by updating all drivers which can access a platform provided
      ROM. Instead of calling the helper function pci_platform_rom() which uses
      phys_to_virt(), call ioremap() directly on the pdev->rom.
      
      radeon_read_platform_bios() previously directly accessed an __iomem
      pointer. Avoid this by calling memcpy_fromio() instead of kmemdup().
      
      pci_platform_rom() now has no remaining callers, so remove it.
      
      Link: https://lore.kernel.org/r/20200319021623.5426-1-mikel@mikelr.comSigned-off-by: NMikel Rychliski <mikel@mikelr.com>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      Acked-by: NAlex Deucher <alexander.deucher@amd.com>
      72e0ef0e
  23. 29 3月, 2020 2 次提交
  24. 28 3月, 2020 1 次提交
  25. 11 3月, 2020 1 次提交
    • B
      PCI: Add pci_speed_string() · e56faff5
      Bjorn Helgaas 提交于
      Add pci_speed_string() to return a text description of the supplied bus or
      link speed.  The slot code previously used the private
      pci_bus_speed_strings[] array for this purpose, but adding this interface
      will enable us to consolidate similar code elsewhere.
      
      Export pcie_link_speed[] and pci_speed_string() so they can be used by
      modules.
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      e56faff5
  26. 06 3月, 2020 1 次提交
  27. 05 3月, 2020 2 次提交
  28. 25 1月, 2020 1 次提交
  29. 19 12月, 2019 1 次提交
  30. 27 11月, 2019 1 次提交
  31. 21 11月, 2019 2 次提交