1. May 30, 2023
    • David Epping's avatar
      net: phy: mscc: add VSC8502 to MODULE_DEVICE_TABLE · 2f32b89d
      David Epping authored
      
      
      commit 57fb54ab9f6945e204740b696bd4cee61ee04e5e upstream.
      
      The mscc driver implements support for VSC8502, so its ID should be in
      the MODULE_DEVICE_TABLE for automatic loading.
      
      Signed-off-by: default avatarDavid Epping <david.epping@missinglinkelectronics.com>
      Fixes: d3169863
      
       ("net: phy: mscc: add support for VSC8502")
      Reviewed-by: default avatarVladimir Oltean <olteanv@gmail.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2f32b89d
    • Christophe JAILLET's avatar
      3c589_cs: Fix an error handling path in tc589_probe() · 3bcb97e4
      Christophe JAILLET authored
      commit 640bf95b2c7c2981fb471acdafbd3e0458f8390d upstream.
      
      Should tc589_config() fail, some resources need to be released as already
      done in the remove function.
      
      Fixes: 15b99ac1
      
       ("[PATCH] pcmcia: add return value to _config() functions")
      Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
      Reviewed-by: default avatarSimon Horman <simon.horman@corigine.com>
      Link: https://lore.kernel.org/r/d8593ae867b24c79063646e36f9b18b0790107cb.1684575975.git.christophe.jaillet@wanadoo.fr
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3bcb97e4
    • Wen Gu's avatar
      net/smc: Reset connection when trying to use SMCRv2 fails. · 9540765d
      Wen Gu authored
      commit 35112271672ae98f45df7875244a4e33aa215e31 upstream.
      
      We found a crash when using SMCRv2 with 2 Mellanox ConnectX-4. It
      can be reproduced by:
      
      - smc_run nginx
      - smc_run wrk -t 32 -c 500 -d 30 http://<ip>:<port>
      
       BUG: kernel NULL pointer dereference, address: 0000000000000014
       #PF: supervisor read access in kernel mode
       #PF: error_code(0x0000) - not-present page
       PGD 8000000108713067 P4D 8000000108713067 PUD 151127067 PMD 0
       Oops: 0000 [#1] PREEMPT SMP PTI
       CPU: 4 PID: 2441 Comm: kworker/4:249 Kdump: loaded Tainted: G        W   E      6.4.0-rc1+ #42
       Workqueue: smc_hs_wq smc_listen_work [smc]
       RIP: 0010:smc_clc_send_confirm_accept+0x284/0x580 [smc]
       RSP: 0018:ffffb8294b2d7c78 EFLAGS: 00010a06
       RAX: ffff8f1873238880 RBX: ffffb8294b2d7dc8 RCX: 0000000000000000
       RDX: 00000000000000b4 RSI: 0000000000000001 RDI: 0000000000b40c00
       RBP: ffffb8294b2d7db8 R08: ffff8f1815c5860c R09: 0000000000000000
       R10: 0000000000000400 R11: 0000000000000000 R12: ffff8f1846f56180
       R13: ffff8f1815c5860c R14: 0000000000000001 R15: 0000000000000001
       FS:  0000000000000000(0000) GS:ffff8f1aefd00000(0000) knlGS:0000000000000000
       CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
       CR2: 0000000000000014 CR3: 00000001027a0001 CR4: 00000000003706e0
       DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
       DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
       Call Trace:
        <TASK>
        ? mlx5_ib_map_mr_sg+0xa1/0xd0 [mlx5_ib]
        ? smcr_buf_map_link+0x24b/0x290 [smc]
        ? __smc_buf_create+0x4ee/0x9b0 [smc]
        smc_clc_send_accept+0x4c/0xb0 [smc]
        smc_listen_work+0x346/0x650 [smc]
        ? __schedule+0x279/0x820
        process_one_work+0x1e5/0x3f0
        worker_thread+0x4d/0x2f0
        ? __pfx_worker_thread+0x10/0x10
        kthread+0xe5/0x120
        ? __pfx_kthread+0x10/0x10
        ret_from_fork+0x2c/0x50
        </TASK>
      
      During the CLC handshake, server sequentially tries available SMCRv2
      and SMCRv1 devices in smc_listen_work().
      
      If an SMCRv2 device is found. SMCv2 based link group and link will be
      assigned to the connection. Then assumed that some buffer assignment
      errors happen later in the CLC handshake, such as RMB registration
      failure, server will give up SMCRv2 and try SMCRv1 device instead. But
      the resources assigned to the connection won't be reset.
      
      When server tries SMCRv1 device, the connection creation process will
      be executed again. Since conn->lnk has been assigned when trying SMCRv2,
      it will not be set to the correct SMCRv1 link in
      smcr_lgr_conn_assign_link(). So in such situation, conn->lgr points to
      correct SMCRv1 link group but conn->lnk points to the SMCRv2 link
      mistakenly.
      
      Then in smc_clc_send_confirm_accept(), conn->rmb_desc->mr[link->link_idx]
      will be accessed. Since the link->link_idx is not correct, the related
      MR may not have been initialized, so crash happens.
      
       | Try SMCRv2 device first
       |     |-> conn->lgr:	assign existed SMCRv2 link group;
       |     |-> conn->link:	assign existed SMCRv2 link (link_idx may be 1 in SMC_LGR_SYMMETRIC);
       |     |-> sndbuf & RMB creation fails, quit;
       |
       | Try SMCRv1 device then
       |     |-> conn->lgr:	create SMCRv1 link group and assign;
       |     |-> conn->link:	keep SMCRv2 link mistakenly;
       |     |-> sndbuf & RMB creation succeed, only RMB->mr[link_idx = 0]
       |         initialized.
       |
       | Then smc_clc_send_confirm_accept() accesses
       | conn->rmb_desc->mr[conn->link->link_idx, which is 1], then crash.
       v
      
      This patch tries to fix this by cleaning conn->lnk before assigning
      link. In addition, it is better to reset the connection and clean the
      resources assigned if trying SMCRv2 failed in buffer creation or
      registration.
      
      Fixes: e49300a6 ("net/smc: add listen processing for SMC-Rv2")
      Link: https://lore.kernel.org/r/20220523055056.2078994-1-liuyacan@corp.netease.com/
      
      
      Signed-off-by: default avatarWen Gu <guwen@linux.alibaba.com>
      Reviewed-by: default avatarTony Lu <tonylu@linux.alibaba.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9540765d
    • Sen Chu's avatar
      regulator: mt6359: add read check for PMIC MT6359 · be402266
      Sen Chu authored
      
      
      commit a511637502b1caa135046d0f8fdabd55a31af8ef upstream.
      
      Add hardware version read check for PMIC MT6359
      
      Signed-off-by: default avatarSen Chu <sen.chu@mediatek.com>
      Fixes: 4cfc9654
      
       ("regulator: mt6359: Add support for MT6359P regulator")
      Reviewed-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
      Link: https://lore.kernel.org/r/20230518040646.8730-1-sen.chu@mediatek.com
      
      
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      be402266
    • Sudeep Holla's avatar
      firmware: arm_ffa: Set reserved/MBZ fields to zero in the memory descriptors · 22157f74
      Sudeep Holla authored
      commit 111a833dc5cbef3d05b2a796a7e23cb7f6ff2192 upstream.
      
      The transmit buffers allocated by the driver can be used to transmit data
      by any messages/commands needing the buffer. However, it is not guaranteed
      to have been zero-ed before every new transmission and hence it will just
      contain residual value from the previous transmission. There are several
      reserved fields in the memory descriptors that must be zero(MBZ). The
      receiver can reject the transmission if any such MBZ fields are non-zero.
      
      While we can set the whole page to zero, it is not optimal as most of the
      fields get initialised to the value required for the current transmission.
      
      So, just set the reserved/MBZ fields to zero in the memory descriptors
      explicitly to honour the requirement and keep the receiver happy.
      
      Fixes: cc2195fe
      
       ("firmware: arm_ffa: Add support for MEM_* interfaces")
      Reported-by: default avatarMarc Bonnici <marc.bonnici@arm.com>
      Link: https://lore.kernel.org/r/20230503131252.12585-1-sudeep.holla@arm.com
      
      
      Signed-off-by: default avatarSudeep Holla <sudeep.holla@arm.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      22157f74
    • Hugo Villeneuve's avatar
      arm64: dts: imx8mn-var-som: fix PHY detection bug by adding deassert delay · 1ae70faa
      Hugo Villeneuve authored
      commit f161cea5a20f3aeeb637a88ad1705fc2720b4d58 upstream.
      
      While testing the ethernet interface on a Variscite symphony carrier
      board using an imx8mn SOM with an onboard ADIN1300 PHY (EC hardware
      configuration), the ethernet PHY is not detected.
      
      The ADIN1300 datasheet indicate that the "Management interface
      active (t4)" state is reached at most 5ms after the reset signal is
      deasserted.
      
      The device tree in Variscite custom git repository uses the following
      property:
      
          phy-reset-post-delay = <20>;
      
      Add a new MDIO property 'reset-deassert-us' of 20ms to have the same
      delay inside the ethphy node. Adding this property fixes the problem
      with the PHY detection.
      
      Note that this SOM can also have an Atheros AR8033 PHY. In this case,
      a 1ms deassert delay is sufficient. Add a comment to that effect.
      
      Fixes: ade0176d
      
       ("arm64: dts: imx8mn-var-som: Add Variscite VAR-SOM-MX8MN System on Module")
      Signed-off-by: default avatarHugo Villeneuve <hvilleneuve@dimonoff.com>
      Signed-off-by: default avatarShawn Guo <shawnguo@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1ae70faa
    • Shay Drory's avatar
      net/mlx5: Devcom, serialize devcom registration · 3e8a82fb
      Shay Drory authored
      commit 1f893f57a3bf9fe1f4bcb25b55aea7f7f9712fe7 upstream.
      
      From one hand, mlx5 driver is allowing to probe PFs in parallel.
      From the other hand, devcom, which is a share resource between PFs, is
      registered without any lock. This might resulted in memory problems.
      
      Hence, use the global mlx5_dev_list_lock in order to serialize devcom
      registration.
      
      Fixes: fadd59fc
      
       ("net/mlx5: Introduce inter-device communication mechanism")
      Signed-off-by: default avatarShay Drory <shayd@nvidia.com>
      Reviewed-by: default avatarMark Bloch <mbloch@nvidia.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3e8a82fb
    • Shay Drory's avatar
      net/mlx5: Devcom, fix error flow in mlx5_devcom_register_device · eaa365c1
      Shay Drory authored
      commit af87194352cad882d787d06fb7efa714acd95427 upstream.
      
      In case devcom allocation is failed, mlx5 is always freeing the priv.
      However, this priv might have been allocated by a different thread,
      and freeing it might lead to use-after-free bugs.
      Fix it by freeing the priv only in case it was allocated by the
      running thread.
      
      Fixes: fadd59fc
      
       ("net/mlx5: Introduce inter-device communication mechanism")
      Signed-off-by: default avatarShay Drory <shayd@nvidia.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      eaa365c1
    • Shay Drory's avatar
      net/mlx5: Collect command failures data only for known commands · 411e4d6c
      Shay Drory authored
      commit 2a0a935fb64ee8af253b9c6133bb6702fb152ac2 upstream.
      
      DEVX can issue a general command, which is not used by mlx5 driver.
      In case such command is failed, mlx5 is trying to collect the failure
      data, However, mlx5 doesn't create a storage for this command, since
      mlx5 doesn't use it. This lead to array-index-out-of-bounds error.
      
      Fix it by checking whether the command is known before collecting the
      failure data.
      
      Fixes: 34f46ae0
      
       ("net/mlx5: Add command failures data to debugfs")
      Signed-off-by: default avatarShay Drory <shayd@nvidia.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      411e4d6c
    • Roi Dayan's avatar
      net/mlx5: Fix error message when failing to allocate device memory · 390aa5c0
      Roi Dayan authored
      commit a65735148e0328f80c0f72f9f8d2f609bfcf4aff upstream.
      
      Fix spacing for the error and also the correct error code pointer.
      
      Fixes: c9b9dcb4
      
       ("net/mlx5: Move device memory management to mlx5_core")
      Signed-off-by: default avatarRoi Dayan <roid@nvidia.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      390aa5c0
    • Yevgeny Kliteynik's avatar
      net/mlx5: DR, Check force-loopback RC QP capability independently from RoCE · 59dd110c
      Yevgeny Kliteynik authored
      commit c7dd225bc224726c22db08e680bf787f60ebdee3 upstream.
      
      SW Steering uses RC QP for writing STEs to ICM. This writingis done in LB
      (loopback), and FL (force-loopback) QP is preferred for performance. FL is
      available when RoCE is enabled or disabled based on RoCE caps.
      This patch adds reading of FL capability from HCA caps in addition to the
      existing reading from RoCE caps, thus fixing the case where we didn't
      have loopback enabled when RoCE was disabled.
      
      Fixes: 7304d603
      
       ("net/mlx5: DR, Add support for force-loopback QP")
      Signed-off-by: default avatarItamar Gozlan <igozlan@nvidia.com>
      Signed-off-by: default avatarYevgeny Kliteynik <kliteyn@nvidia.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      59dd110c
    • Shay Drory's avatar
      net/mlx5: Handle pairing of E-switch via uplink un/load APIs · b17294e7
      Shay Drory authored
      commit 2be5bd42a5bba1a05daedc86cf0e248210009669 upstream.
      
      In case user switch a device from switchdev mode to legacy mode, mlx5
      first unpair the E-switch and afterwards unload the uplink vport.
      From the other hand, in case user remove or reload a device, mlx5
      first unload the uplink vport and afterwards unpair the E-switch.
      
      The latter is causing a bug[1], hence, handle pairing of E-switch as
      part of uplink un/load APIs.
      
      [1]
      In case VF_LAG is used, every tc fdb flow is duplicated to the peer
      esw. However, the original esw keeps a pointer to this duplicated
      flow, not the peer esw.
      e.g.: if user create tc fdb flow over esw0, the flow is duplicated
      over esw1, in FW/HW, but in SW, esw0 keeps a pointer to the duplicated
      flow.
      During module unload while a peer tc fdb flow is still offloaded, in
      case the first device to be removed is the peer device (esw1 in the
      example above), the peer net-dev is destroyed, and so the mlx5e_priv
      is memset to 0.
      Afterwards, the peer device is trying to unpair himself from the
      original device (esw0 in the example above). Unpair API invoke the
      original device to clear peer flow from its eswitch (esw0), but the
      peer flow, which is stored over the original eswitch (esw0), is
      trying to use the peer mlx5e_priv, which is memset to 0 and result in
      bellow kernel-oops.
      
      [  157.964081 ] BUG: unable to handle page fault for address: 000000000002ce60
      [  157.964662 ] #PF: supervisor read access in kernel mode
      [  157.965123 ] #PF: error_code(0x0000) - not-present page
      [  157.965582 ] PGD 0 P4D 0
      [  157.965866 ] Oops: 0000 [#1] SMP
      [  157.967670 ] RIP: 0010:mlx5e_tc_del_fdb_flow+0x48/0x460 [mlx5_core]
      [  157.976164 ] Call Trace:
      [  157.976437 ]  <TASK>
      [  157.976690 ]  __mlx5e_tc_del_fdb_peer_flow+0xe6/0x100 [mlx5_core]
      [  157.977230 ]  mlx5e_tc_clean_fdb_peer_flows+0x67/0x90 [mlx5_core]
      [  157.977767 ]  mlx5_esw_offloads_unpair+0x2d/0x1e0 [mlx5_core]
      [  157.984653 ]  mlx5_esw_offloads_devcom_event+0xbf/0x130 [mlx5_core]
      [  157.985212 ]  mlx5_devcom_send_event+0xa3/0xb0 [mlx5_core]
      [  157.985714 ]  esw_offloads_disable+0x5a/0x110 [mlx5_core]
      [  157.986209 ]  mlx5_eswitch_disable_locked+0x152/0x170 [mlx5_core]
      [  157.986757 ]  mlx5_eswitch_disable+0x51/0x80 [mlx5_core]
      [  157.987248 ]  mlx5_unload+0x2a/0xb0 [mlx5_core]
      [  157.987678 ]  mlx5_uninit_one+0x5f/0xd0 [mlx5_core]
      [  157.988127 ]  remove_one+0x64/0xe0 [mlx5_core]
      [  157.988549 ]  pci_device_remove+0x31/0xa0
      [  157.988933 ]  device_release_driver_internal+0x18f/0x1f0
      [  157.989402 ]  driver_detach+0x3f/0x80
      [  157.989754 ]  bus_remove_driver+0x70/0xf0
      [  157.990129 ]  pci_unregister_driver+0x34/0x90
      [  157.990537 ]  mlx5_cleanup+0xc/0x1c [mlx5_core]
      [  157.990972 ]  __x64_sys_delete_module+0x15a/0x250
      [  157.991398 ]  ? exit_to_user_mode_prepare+0xea/0x110
      [  157.991840 ]  do_syscall_64+0x3d/0x90
      [  157.992198 ]  entry_SYSCALL_64_after_hwframe+0x46/0xb0
      
      Fixes: 04de7dda ("net/mlx5e: Infrastructure for duplicated offloading of TC flows")
      Fixes: 1418ddd9
      
       ("net/mlx5e: Duplicate offloaded TC eswitch rules under uplink LAG")
      Signed-off-by: default avatarShay Drory <shayd@nvidia.com>
      Reviewed-by: default avatarRoi Dayan <roid@nvidia.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b17294e7
    • Erez Shitrit's avatar
      net/mlx5: DR, Fix crc32 calculation to work on big-endian (BE) CPUs · e501ab13
      Erez Shitrit authored
      commit 1e5daf5565b61a96e570865091589afc9156e3d3 upstream.
      
      When calculating crc for hash index we use the function crc32 that
      calculates for little-endian (LE) arch.
      Then we convert it to network endianness using htonl(), but it's wrong
      to do the conversion in BE archs since the crc32 value is already LE.
      
      The solution is to switch the bytes from the crc result for all types
      of arc.
      
      Fixes: 40416d8e
      
       ("net/mlx5: DR, Replace CRC32 implementation to use kernel lib")
      Signed-off-by: default avatarErez Shitrit <erezsh@nvidia.com>
      Reviewed-by: default avatarAlex Vesker <valex@nvidia.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e501ab13
    • Jakub Kicinski's avatar
      net/mlx5e: do as little as possible in napi poll when budget is 0 · 6f0dce5f
      Jakub Kicinski authored
      
      
      commit afbed3f74830163f9559579dee382cac3cff82da upstream.
      
      NAPI gets called with budget of 0 from netpoll, which has interrupts
      disabled. We should try to free some space on Tx rings and nothing
      else.
      
      Specifically do not try to handle XDP TX or try to refill Rx buffers -
      we can't use the page pool from IRQ context. Don't check if IRQs moved,
      either, that makes no sense in netpoll. Netpoll calls _all_ the rings
      from whatever CPU it happens to be invoked on.
      
      In general do as little as possible, the work quickly adds up when
      there's tens of rings to poll.
      
      The immediate stack trace I was seeing is:
      
          __do_softirq+0xd1/0x2c0
          __local_bh_enable_ip+0xc7/0x120
          </IRQ>
          <TASK>
          page_pool_put_defragged_page+0x267/0x320
          mlx5e_free_xdpsq_desc+0x99/0xd0
          mlx5e_poll_xdpsq_cq+0x138/0x3b0
          mlx5e_napi_poll+0xc3/0x8b0
          netpoll_poll_dev+0xce/0x150
      
      AFAIU page pool takes a BH lock, releases it and since BH is now
      enabled tries to run softirqs.
      
      Reviewed-by: default avatarTariq Toukan <tariqt@nvidia.com>
      Fixes: 60bbf7ee
      
       ("mlx5: use page_pool for xdp_return_frame call")
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Reviewed-by: default avatarSimon Horman <simon.horman@corigine.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6f0dce5f
    • Vlad Buslov's avatar
      net/mlx5e: Use correct encap attribute during invalidation · 00959a1b
      Vlad Buslov authored
      commit be071cdb167fc3e25fe81922166b3d499d23e8ac upstream.
      
      With introduction of post action infrastructure most of the users of encap
      attribute had been modified in order to obtain the correct attribute by
      calling mlx5e_tc_get_encap_attr() helper instead of assuming encap action
      is always on default attribute. However, the cited commit didn't modify
      mlx5e_invalidate_encap() which prevents it from destroying correct modify
      header action which leads to a warning [0]. Fix the issue by using correct
      attribute.
      
      [0]:
      
      Feb 21 09:47:35 c-237-177-40-045 kernel: WARNING: CPU: 17 PID: 654 at drivers/net/ethernet/mellanox/mlx5/core/en_tc.c:684 mlx5e_tc_attach_mod_hdr+0x1cc/0x230 [mlx5_core]
      Feb 21 09:47:35 c-237-177-40-045 kernel: RIP: 0010:mlx5e_tc_attach_mod_hdr+0x1cc/0x230 [mlx5_core]
      Feb 21 09:47:35 c-237-177-40-045 kernel: Call Trace:
      Feb 21 09:47:35 c-237-177-40-045 kernel:  <TASK>
      Feb 21 09:47:35 c-237-177-40-045 kernel:  mlx5e_tc_fib_event_work+0x8e3/0x1f60 [mlx5_core]
      Feb 21 09:47:35 c-237-177-40-045 kernel:  ? mlx5e_take_all_encap_flows+0xe0/0xe0 [mlx5_core]
      Feb 21 09:47:35 c-237-177-40-045 kernel:  ? lock_downgrade+0x6d0/0x6d0
      Feb 21 09:47:35 c-237-177-40-045 kernel:  ? lockdep_hardirqs_on_prepare+0x273/0x3f0
      Feb 21 09:47:35 c-237-177-40-045 kernel:  ? lockdep_hardirqs_on_prepare+0x273/0x3f0
      Feb 21 09:47:35 c-237-177-40-045 kernel:  process_one_work+0x7c2/0x1310
      Feb 21 09:47:35 c-237-177-40-045 kernel:  ? lockdep_hardirqs_on_prepare+0x3f0/0x3f0
      Feb 21 09:47:35 c-237-177-40-045 kernel:  ? pwq_dec_nr_in_flight+0x230/0x230
      Feb 21 09:47:35 c-237-177-40-045 kernel:  ? rwlock_bug.part.0+0x90/0x90
      Feb 21 09:47:35 c-237-177-40-045 kernel:  worker_thread+0x59d/0xec0
      Feb 21 09:47:35 c-237-177-40-045 kernel:  ? __kthread_parkme+0xd9/0x1d0
      
      Fixes: 8300f225
      
       ("net/mlx5e: Create new flow attr for multi table actions")
      Signed-off-by: default avatarVlad Buslov <vladbu@nvidia.com>
      Reviewed-by: default avatarRoi Dayan <roid@nvidia.com>
      Reviewed-by: default avatarTariq Toukan <tariqt@nvidia.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      00959a1b
    • Vlad Buslov's avatar
      net/mlx5e: Fix deadlock in tc route query code · 362063df
      Vlad Buslov authored
      commit 691c041bf20899fc13c793f92ba61ab660fa3a30 upstream.
      
      Cited commit causes ABBA deadlock[0] when peer flows are created while
      holding the devcom rw semaphore. Due to peer flows offload implementation
      the lock is taken much higher up the call chain and there is no obvious way
      to easily fix the deadlock. Instead, since tc route query code needs the
      peer eswitch structure only to perform a lookup in xarray and doesn't
      perform any sleeping operations with it, refactor the code for lockless
      execution in following ways:
      
      - RCUify the devcom 'data' pointer. When resetting the pointer
      synchronously wait for RCU grace period before returning. This is fine
      since devcom is currently only used for synchronization of
      pairing/unpairing of eswitches which is rare and already expensive as-is.
      
      - Wrap all usages of 'paired' boolean in {READ|WRITE}_ONCE(). The flag has
      already been used in some unlocked contexts without proper
      annotations (e.g. users of mlx5_devcom_is_paired() function), but it wasn't
      an issue since all relevant code paths checked it again after obtaining the
      devcom semaphore. Now it is also used by mlx5_devcom_get_peer_data_rcu() as
      "best effort" check to return NULL when devcom is being unpaired. Note that
      while RCU read lock doesn't prevent the unpaired flag from being changed
      concurrently it still guarantees that reader can continue to use 'data'.
      
      - Refactor mlx5e_tc_query_route_vport() function to use new
      mlx5_devcom_get_peer_data_rcu() API which fixes the deadlock.
      
      [0]:
      
      [  164.599612] ======================================================
      [  164.600142] WARNING: possible circular locking dependency detected
      [  164.600667] 6.3.0-rc3+ #1 Not tainted
      [  164.601021] ------------------------------------------------------
      [  164.601557] handler1/3456 is trying to acquire lock:
      [  164.601998] ffff88811f1714b0 (&esw->offloads.encap_tbl_lock){+.+.}-{3:3}, at: mlx5e_attach_encap+0xd8/0x8b0 [mlx5_core]
      [  164.603078]
                     but task is already holding lock:
      [  164.603617] ffff88810137fc98 (&comp->sem){++++}-{3:3}, at: mlx5_devcom_get_peer_data+0x37/0x80 [mlx5_core]
      [  164.604459]
                     which lock already depends on the new lock.
      
      [  164.605190]
                     the existing dependency chain (in reverse order) is:
      [  164.605848]
                     -> #1 (&comp->sem){++++}-{3:3}:
      [  164.606380]        down_read+0x39/0x50
      [  164.606772]        mlx5_devcom_get_peer_data+0x37/0x80 [mlx5_core]
      [  164.607336]        mlx5e_tc_query_route_vport+0x86/0xc0 [mlx5_core]
      [  164.607914]        mlx5e_tc_tun_route_lookup+0x1a4/0x1d0 [mlx5_core]
      [  164.608495]        mlx5e_attach_decap_route+0xc6/0x1e0 [mlx5_core]
      [  164.609063]        mlx5e_tc_add_fdb_flow+0x1ea/0x360 [mlx5_core]
      [  164.609627]        __mlx5e_add_fdb_flow+0x2d2/0x430 [mlx5_core]
      [  164.610175]        mlx5e_configure_flower+0x952/0x1a20 [mlx5_core]
      [  164.610741]        tc_setup_cb_add+0xd4/0x200
      [  164.611146]        fl_hw_replace_filter+0x14c/0x1f0 [cls_flower]
      [  164.611661]        fl_change+0xc95/0x18a0 [cls_flower]
      [  164.612116]        tc_new_tfilter+0x3fc/0xd20
      [  164.612516]        rtnetlink_rcv_msg+0x418/0x5b0
      [  164.612936]        netlink_rcv_skb+0x54/0x100
      [  164.613339]        netlink_unicast+0x190/0x250
      [  164.613746]        netlink_sendmsg+0x245/0x4a0
      [  164.614150]        sock_sendmsg+0x38/0x60
      [  164.614522]        ____sys_sendmsg+0x1d0/0x1e0
      [  164.614934]        ___sys_sendmsg+0x80/0xc0
      [  164.615320]        __sys_sendmsg+0x51/0x90
      [  164.615701]        do_syscall_64+0x3d/0x90
      [  164.616083]        entry_SYSCALL_64_after_hwframe+0x46/0xb0
      [  164.616568]
                     -> #0 (&esw->offloads.encap_tbl_lock){+.+.}-{3:3}:
      [  164.617210]        __lock_acquire+0x159e/0x26e0
      [  164.617638]        lock_acquire+0xc2/0x2a0
      [  164.618018]        __mutex_lock+0x92/0xcd0
      [  164.618401]        mlx5e_attach_encap+0xd8/0x8b0 [mlx5_core]
      [  164.618943]        post_process_attr+0x153/0x2d0 [mlx5_core]
      [  164.619471]        mlx5e_tc_add_fdb_flow+0x164/0x360 [mlx5_core]
      [  164.620021]        __mlx5e_add_fdb_flow+0x2d2/0x430 [mlx5_core]
      [  164.620564]        mlx5e_configure_flower+0xe33/0x1a20 [mlx5_core]
      [  164.621125]        tc_setup_cb_add+0xd4/0x200
      [  164.621531]        fl_hw_replace_filter+0x14c/0x1f0 [cls_flower]
      [  164.622047]        fl_change+0xc95/0x18a0 [cls_flower]
      [  164.622500]        tc_new_tfilter+0x3fc/0xd20
      [  164.622906]        rtnetlink_rcv_msg+0x418/0x5b0
      [  164.623324]        netlink_rcv_skb+0x54/0x100
      [  164.623727]        netlink_unicast+0x190/0x250
      [  164.624138]        netlink_sendmsg+0x245/0x4a0
      [  164.624544]        sock_sendmsg+0x38/0x60
      [  164.624919]        ____sys_sendmsg+0x1d0/0x1e0
      [  164.625340]        ___sys_sendmsg+0x80/0xc0
      [  164.625731]        __sys_sendmsg+0x51/0x90
      [  164.626117]        do_syscall_64+0x3d/0x90
      [  164.626502]        entry_SYSCALL_64_after_hwframe+0x46/0xb0
      [  164.626995]
                     other info that might help us debug this:
      
      [  164.627725]  Possible unsafe locking scenario:
      
      [  164.628268]        CPU0                    CPU1
      [  164.628683]        ----                    ----
      [  164.629098]   lock(&comp->sem);
      [  164.629421]                                lock(&esw->offloads.encap_tbl_lock);
      [  164.630066]                                lock(&comp->sem);
      [  164.630555]   lock(&esw->offloads.encap_tbl_lock);
      [  164.630993]
                      *** DEADLOCK ***
      
      [  164.631575] 3 locks held by handler1/3456:
      [  164.631962]  #0: ffff888124b75130 (&block->cb_lock){++++}-{3:3}, at: tc_setup_cb_add+0x5b/0x200
      [  164.632703]  #1: ffff888116e512b8 (&esw->mode_lock){++++}-{3:3}, at: mlx5_esw_hold+0x39/0x50 [mlx5_core]
      [  164.633552]  #2: ffff88810137fc98 (&comp->sem){++++}-{3:3}, at: mlx5_devcom_get_peer_data+0x37/0x80 [mlx5_core]
      [  164.634435]
                     stack backtrace:
      [  164.634883] CPU: 17 PID: 3456 Comm: handler1 Not tainted 6.3.0-rc3+ #1
      [  164.635431] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014
      [  164.636340] Call Trace:
      [  164.636616]  <TASK>
      [  164.636863]  dump_stack_lvl+0x47/0x70
      [  164.637217]  check_noncircular+0xfe/0x110
      [  164.637601]  __lock_acquire+0x159e/0x26e0
      [  164.637977]  ? mlx5_cmd_set_fte+0x5b0/0x830 [mlx5_core]
      [  164.638472]  lock_acquire+0xc2/0x2a0
      [  164.638828]  ? mlx5e_attach_encap+0xd8/0x8b0 [mlx5_core]
      [  164.639339]  ? lock_is_held_type+0x98/0x110
      [  164.639728]  __mutex_lock+0x92/0xcd0
      [  164.640074]  ? mlx5e_attach_encap+0xd8/0x8b0 [mlx5_core]
      [  164.640576]  ? __lock_acquire+0x382/0x26e0
      [  164.640958]  ? mlx5e_attach_encap+0xd8/0x8b0 [mlx5_core]
      [  164.641468]  ? mlx5e_attach_encap+0xd8/0x8b0 [mlx5_core]
      [  164.641965]  mlx5e_attach_encap+0xd8/0x8b0 [mlx5_core]
      [  164.642454]  ? lock_release+0xbf/0x240
      [  164.642819]  post_process_attr+0x153/0x2d0 [mlx5_core]
      [  164.643318]  mlx5e_tc_add_fdb_flow+0x164/0x360 [mlx5_core]
      [  164.643835]  __mlx5e_add_fdb_flow+0x2d2/0x430 [mlx5_core]
      [  164.644340]  mlx5e_configure_flower+0xe33/0x1a20 [mlx5_core]
      [  164.644862]  ? lock_acquire+0xc2/0x2a0
      [  164.645219]  tc_setup_cb_add+0xd4/0x200
      [  164.645588]  fl_hw_replace_filter+0x14c/0x1f0 [cls_flower]
      [  164.646067]  fl_change+0xc95/0x18a0 [cls_flower]
      [  164.646488]  tc_new_tfilter+0x3fc/0xd20
      [  164.646861]  ? tc_del_tfilter+0x810/0x810
      [  164.647236]  rtnetlink_rcv_msg+0x418/0x5b0
      [  164.647621]  ? rtnl_setlink+0x160/0x160
      [  164.647982]  netlink_rcv_skb+0x54/0x100
      [  164.648348]  netlink_unicast+0x190/0x250
      [  164.648722]  netlink_sendmsg+0x245/0x4a0
      [  164.649090]  sock_sendmsg+0x38/0x60
      [  164.649434]  ____sys_sendmsg+0x1d0/0x1e0
      [  164.649804]  ? copy_msghdr_from_user+0x6d/0xa0
      [  164.650213]  ___sys_sendmsg+0x80/0xc0
      [  164.650563]  ? lock_acquire+0xc2/0x2a0
      [  164.650926]  ? lock_acquire+0xc2/0x2a0
      [  164.651286]  ? __fget_files+0x5/0x190
      [  164.651644]  ? find_held_lock+0x2b/0x80
      [  164.652006]  ? __fget_files+0xb9/0x190
      [  164.652365]  ? lock_release+0xbf/0x240
      [  164.652723]  ? __fget_files+0xd3/0x190
      [  164.653079]  __sys_sendmsg+0x51/0x90
      [  164.653435]  do_syscall_64+0x3d/0x90
      [  164.653784]  entry_SYSCALL_64_after_hwframe+0x46/0xb0
      [  164.654229] RIP: 0033:0x7f378054f8bd
      [  164.654577] Code: 28 89 54 24 1c 48 89 74 24 10 89 7c 24 08 e8 6a c3 f4 ff 8b 54 24 1c 48 8b 74 24 10 41 89 c0 8b 7c 24 08 b8 2e 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 33 44 89 c7 48 89 44 24 08 e8 be c3 f4 ff 48
      [  164.656041] RSP: 002b:00007f377fa114b0 EFLAGS: 00000293 ORIG_RAX: 000000000000002e
      [  164.656701] RAX: ffffffffffffffda RBX: 0000000000000001 RCX: 00007f378054f8bd
      [  164.657297] RDX: 0000000000000000 RSI: 00007f377fa11540 RDI: 0000000000000014
      [  164.657885] RBP: 00007f377fa12278 R08: 0000000000000000 R09: 000000000000015c
      [  164.658472] R10: 00007f377fa123d0 R11: 0000000000000293 R12: 0000560962d99bd0
      [  164.665317] R13: 0000000000000000 R14: 0000560962d99bd0 R15: 00007f377fa11540
      
      Fixes: f9d196bd
      
       ("net/mlx5e: Use correct eswitch for stack devices with lag")
      Signed-off-by: default avatarVlad Buslov <vladbu@nvidia.com>
      Reviewed-by: default avatarRoi Dayan <roid@nvidia.com>
      Reviewed-by: default avatarShay Drory <shayd@nvidia.com>
      Reviewed-by: default avatarTariq Toukan <tariqt@nvidia.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      362063df
    • Rahul Rameshbabu's avatar
      net/mlx5e: Fix SQ wake logic in ptp napi_poll context · 2051f762
      Rahul Rameshbabu authored
      commit 7aa50380191635e5897a773f272829cc961a2be5 upstream.
      
      Check in the mlx5e_ptp_poll_ts_cq context if the ptp tx sq should be woken
      up. Before change, the ptp tx sq may never wake up if the ptp tx ts skb
      fifo is full when mlx5e_poll_tx_cq checks if the queue should be woken up.
      
      Fixes: 1880bc4e
      
       ("net/mlx5e: Add TX port timestamp support")
      Signed-off-by: default avatarRahul Rameshbabu <rrameshbabu@nvidia.com>
      Reviewed-by: default avatarTariq Toukan <tariqt@nvidia.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2051f762
    • Dan Carpenter's avatar
      platform/mellanox: mlxbf-pmc: fix sscanf() error checking · 47b4f741
      Dan Carpenter authored
      commit 95e4b25192e9238fd2dbe85d96dd2f8fd1ce9d14 upstream.
      
      The sscanf() function never returns negatives.  It returns the number of
      items successfully read.
      
      Fixes: 1a218d31
      
       ("platform/mellanox: mlxbf-pmc: Add Mellanox BlueField PMC driver")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
      Reviewed-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
      Link: https://lore.kernel.org/r/4ccdfd28-099b-40bf-8d77-ad4ea2e76b93@kili.mountain
      
      
      Reviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      47b4f741
    • Christophe JAILLET's avatar
      forcedeth: Fix an error handling path in nv_probe() · 04238c23
      Christophe JAILLET authored
      commit 5b17a4971d3b2a073f4078dd65331efbe35baa2d upstream.
      
      If an error occures after calling nv_mgmt_acquire_sema(), it should be
      undone with a corresponding nv_mgmt_release_sema() call.
      
      Add it in the error handling path of the probe as already done in the
      remove function.
      
      Fixes: cac1c52c
      
       ("forcedeth: mgmt unit interface")
      Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
      Acked-by: default avatarZhu Yanjun <zyjzyj2000@gmail.com>
      Link: https://lore.kernel.org/r/355e9a7d351b32ad897251b6f81b5886fcdc6766.1684571393.git.christophe.jaillet@wanadoo.fr
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      04238c23
    • Xin Long's avatar
      sctp: fix an issue that plpmtu can never go to complete state · 0392c918
      Xin Long authored
      commit 6ca328e985cd995dfd1d5de44046e6074f853fbb upstream.
      
      When doing plpmtu probe, the probe size is growing every time when it
      receives the ACK during the Search state until the probe fails. When
      the failure occurs, pl.probe_high is set and it goes to the Complete
      state.
      
      However, if the link pmtu is huge, like 65535 in loopback_dev, the probe
      eventually keeps using SCTP_MAX_PLPMTU as the probe size and never fails.
      Because of that, pl.probe_high can not be set, and the plpmtu probe can
      never go to the Complete state.
      
      Fix it by setting pl.probe_high to SCTP_MAX_PLPMTU when the probe size
      grows to SCTP_MAX_PLPMTU in sctp_transport_pl_recv(). Also, not allow
      the probe size greater than SCTP_MAX_PLPMTU in the Complete state.
      
      Fixes: b87641af
      
       ("sctp: do state transition when a probe succeeds on HB ACK recv path")
      Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0392c918
    • Dave Jiang's avatar
      cxl: Wait Memory_Info_Valid before access memory related info · c9e09b07
      Dave Jiang authored
      commit ce17ad0d54985e2595a3e615fda31df61808a08c upstream.
      
      The Memory_Info_Valid bit (CXL 3.0 8.1.3.8.2) indicates that the CXL
      Range Size High and Size Low registers are valid. The bit must be set
      within 1 second of reset deassertion to the device. Check valid bit
      before we check the Memory_Active bit when waiting for
      cxl_await_media_ready() to ensure that the memory info is valid for
      consumption. Also ensures both DVSEC ranges 1 and 2 are ready if DVSEC
      Capability indicates they are both supported.
      
      Fixes: 523e594d
      
       ("cxl/pci: Implement wait for media active")
      Reviewed-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarDave Jiang <dave.jiang@intel.com>
      Link: https://lore.kernel.org/r/168444687469.3134781.11033518965387297327.stgit@djiang5-mobl3
      
      
      Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c9e09b07
    • Amadeusz Sławiński's avatar
      ASoC: Intel: avs: Access path components under lock · ad72cb58
      Amadeusz Sławiński authored
      commit d849996f7458042af803b7d15a181922834c5249 upstream.
      
      Path and its components should be accessed under lock to prevent
      problems with one thread modifying them while other tries to read.
      
      Fixes: c8c960c1
      
       ("ASoC: Intel: avs: APL-based platforms support")
      Reviewed-by: default avatarCezary Rojewski <cezary.rojewski@intel.com>
      Signed-off-by: default avatarAmadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
      Link: https://lore.kernel.org/r/20230519201711.4073845-3-amadeuszx.slawinski@linux.intel.com
      
      
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ad72cb58
    • Cezary Rojewski's avatar
      ASoC: Intel: avs: Fix declaration of enum avs_channel_config · 6ae9cf40
      Cezary Rojewski authored
      commit 1cf036deebcdec46d6348842bd2f8931202fd4cd upstream.
      
      Constant 'C4_CHANNEL' does not exist on the firmware side. Value 0xC is
      reserved for 'C7_1' instead.
      
      Fixes: 580a5912
      
       ("ASoC: Intel: avs: Declare module configuration types")
      Signed-off-by: default avatarCezary Rojewski <cezary.rojewski@intel.com>
      Signed-off-by: default avatarAmadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
      Link: https://lore.kernel.org/r/20230519201711.4073845-5-amadeuszx.slawinski@linux.intel.com
      
      
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6ae9cf40
    • Cezary Rojewski's avatar
      ASoC: Intel: Skylake: Fix declaration of enum skl_ch_cfg · 5eaaad19
      Cezary Rojewski authored
      commit 95109657471311601b98e71f03d0244f48dc61bb upstream.
      
      Constant 'C4_CHANNEL' does not exist on the firmware side. Value 0xC is
      reserved for 'C7_1' instead.
      
      Fixes: 04afbbbb
      
       ("ASoC: Intel: Skylake: Update the topology interface structure")
      Signed-off-by: default avatarCezary Rojewski <cezary.rojewski@intel.com>
      Signed-off-by: default avatarAmadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
      Link: https://lore.kernel.org/r/20230519201711.4073845-4-amadeuszx.slawinski@linux.intel.com
      
      
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5eaaad19
    • Vernon Lovejoy's avatar
      x86/show_trace_log_lvl: Ensure stack pointer is aligned, again · d8cfe5cc
      Vernon Lovejoy authored
      commit 2e4be0d011f21593c6b316806779ba1eba2cd7e0 upstream.
      
      The commit e335bb51 ("x86/unwind: Ensure stack pointer is aligned")
      tried to align the stack pointer in show_trace_log_lvl(), otherwise the
      "stack < stack_info.end" check can't guarantee that the last read does
      not go past the end of the stack.
      
      However, we have the same problem with the initial value of the stack
      pointer, it can also be unaligned. So without this patch this trivial
      kernel module
      
      	#include <linux/module.h>
      
      	static int init(void)
      	{
      		asm volatile("sub    $0x4,%rsp");
      		dump_stack();
      		asm volatile("add    $0x4,%rsp");
      
      		return -EAGAIN;
      	}
      
      	module_init(init);
      	MODULE_LICENSE("GPL");
      
      crashes the kernel.
      
      Fixes: e335bb51
      
       ("x86/unwind: Ensure stack pointer is aligned")
      Signed-off-by: default avatarVernon Lovejoy <vlovejoy@redhat.com>
      Signed-off-by: default avatarOleg Nesterov <oleg@redhat.com>
      Link: https://lore.kernel.org/r/20230512104232.GA10227@redhat.com
      
      
      Signed-off-by: default avatarJosh Poimboeuf <jpoimboe@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d8cfe5cc
    • Dan Carpenter's avatar
      xen/pvcalls-back: fix double frees with pvcalls_new_active_socket() · a7edc86e
      Dan Carpenter authored
      commit 8fafac202d18230bb9926bda48e563fd2cce2a4f upstream.
      
      In the pvcalls_new_active_socket() function, most error paths call
      pvcalls_back_release_active(fedata->dev, fedata, map) which calls
      sock_release() on "sock".  The bug is that the caller also frees sock.
      
      Fix this by making every error path in pvcalls_new_active_socket()
      release the sock, and don't free it in the caller.
      
      Fixes: 5db4d286
      
       ("xen/pvcalls: implement connect command")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
      Reviewed-by: default avatarJuergen Gross <jgross@suse.com>
      Link: https://lore.kernel.org/r/e5f98dc2-0305-491f-a860-71bbd1398a2f@kili.mountain
      
      
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a7edc86e
    • Maximilian Heyne's avatar
      x86/pci/xen: populate MSI sysfs entries · 53384076
      Maximilian Heyne authored
      commit 335b4223466dd75f9f3ea4918187afbadd22e5c8 upstream.
      
      Commit bf5e758f ("genirq/msi: Simplify sysfs handling") reworked the
      creation of sysfs entries for MSI IRQs. The creation used to be in
      msi_domain_alloc_irqs_descs_locked after calling ops->domain_alloc_irqs.
      Then it moved into __msi_domain_alloc_irqs which is an implementation of
      domain_alloc_irqs. However, Xen comes with the only other implementation
      of domain_alloc_irqs and hence doesn't run the sysfs population code
      anymore.
      
      Commit 6c796996 ("x86/pci/xen: Fixup fallout from the PCI/MSI
      overhaul") set the flag MSI_FLAG_DEV_SYSFS for the xen msi_domain_info
      but that doesn't actually have an effect because Xen uses it's own
      domain_alloc_irqs implementation.
      
      Fix this by making use of the fallback functions for sysfs population.
      
      Fixes: bf5e758f
      
       ("genirq/msi: Simplify sysfs handling")
      Signed-off-by: default avatarMaximilian Heyne <mheyne@amazon.de>
      Reviewed-by: default avatarJuergen Gross <jgross@suse.com>
      Link: https://lore.kernel.org/r/20230503131656.15928-1-mheyne@amazon.de
      
      
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      53384076
    • Alexander Stein's avatar
      ARM: dts: imx6qdl-mba6: Add missing pvcie-supply regulator · 84b211b0
      Alexander Stein authored
      commit 91aa4b3782448a7a13baa8cbcdfd5fd19defcbd9 upstream.
      
      This worked before by coincidence, as the regulator was probed and enabled
      before PCI RC probe. But probe order changed since commit 259b93b21a9f
      ("regulator: Set PROBE_PREFER_ASYNCHRONOUS for drivers that existed in
      4.14") and PCIe supply is enabled after RC.
      Fix this by adding the regulator to RC node.
      
      The PCIe vaux regulator still needs to be enabled unconditionally for
      Mini-PCIe USB-only devices.
      
      Fixes: ef384624
      
       ("ARM: dts: imx6qdl: add TQ-Systems MBa6x device trees")
      Signed-off-by: default avatarAlexander Stein <alexander.stein@ew.tq-group.com>
      Signed-off-by: default avatarShawn Guo <shawnguo@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      84b211b0
    • Dan Carpenter's avatar
      coresight: Fix signedness bug in tmc_etr_buf_insert_barrier_packet() · 225a5f39
      Dan Carpenter authored
      commit f67bc15e526bb9920683ad6c1891ff9e08981335 upstream.
      
      This code generates a Smatch warning:
      
          drivers/hwtracing/coresight/coresight-tmc-etr.c:947 tmc_etr_buf_insert_barrier_packet()
          error: uninitialized symbol 'bufp'.
      
      The problem is that if tmc_sg_table_get_data() returns -EINVAL, then
      when we test if "len < CORESIGHT_BARRIER_PKT_SIZE", the negative "len"
      value is type promoted to a high unsigned long value which is greater
      than CORESIGHT_BARRIER_PKT_SIZE.  Fix this bug by adding an explicit
      check for error codes.
      
      Fixes: 75f4e361
      
       ("coresight: tmc-etr: Add transparent buffer management")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
      Signed-off-by: default avatarSuzuki K Poulose <suzuki.poulose@arm.com>
      Link: https://lore.kernel.org/r/7d33e244-d8b9-4c27-9653-883a13534b01@kili.mountain
      
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      225a5f39
    • Steve Wahl's avatar
      platform/x86: ISST: Remove 8 socket limit · 55224690
      Steve Wahl authored
      commit bbb320bfe2c3e9740fe89cfa0a7089b4e8bfc4ff upstream.
      
      Stop restricting the PCI search to a range of PCI domains fed to
      pci_get_domain_bus_and_slot().  Instead, use for_each_pci_dev() and
      look at all PCI domains in one pass.
      
      On systems with more than 8 sockets, this avoids error messages like
      "Information: Invalid level, Can't get TDP control information at
      specified levels on cpu 480" from the intel speed select utility.
      
      Fixes: aa2ddd24
      
       ("platform/x86: ISST: Use numa node id for cpu pci dev mapping")
      Signed-off-by: default avatarSteve Wahl <steve.wahl@hpe.com>
      Reviewed-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
      Link: https://lore.kernel.org/r/20230519160420.2588475-1-steve.wahl@hpe.com
      
      
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      55224690
    • Alexander Stein's avatar
      regulator: pca9450: Fix BUCK2 enable_mask · f34428b5
      Alexander Stein authored
      commit d67dada3e2524514b09496b9ee1df22d4507a280 upstream.
      
      This fixes a copy & paste error.
      No functional change intended, BUCK1_ENMODE_MASK equals BUCK2_ENMODE_MASK.
      
      Fixes: 0935ff5f
      
       ("regulator: pca9450: add pca9450 pmic driver")
      Originally-from: Robin Gong <yibin.gong@nxp.com
      Signed-off-by: default avatarAlexander Stein <alexander.stein@ew.tq-group.com>
      Reviewed-by: default avatarFrieder Schrempf <frieder.schrempf@kontron.de>
      Link: https://lore.kernel.org/r/20230512081935.2396180-1-alexander.stein@ew.tq-group.com
      
      
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f34428b5
    • Hao Ge's avatar
      fs: fix undefined behavior in bit shift for SB_NOUSER · ccc6e9de
      Hao Ge authored
      commit f15afbd34d8fadbd375f1212e97837e32bc170cc upstream.
      
      Shifting signed 32-bit value by 31 bits is undefined, so changing
      significant bit to unsigned. It was spotted by UBSAN.
      
      So let's just fix this by using the BIT() helper for all SB_* flags.
      
      Fixes: e462ec50
      
       ("VFS: Differentiate mount flags (MS_*) from internal superblock flags")
      Signed-off-by: default avatarHao Ge <gehao@kylinos.cn>
      Message-Id: <20230424051835.374204-1-gehao@kylinos.cn>
      [brauner@kernel.org: use BIT() for all SB_* flags]
      Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ccc6e9de
    • Sudeep Holla's avatar
      firmware: arm_ffa: Fix FFA device names for logical partitions · dfc5aaa5
      Sudeep Holla authored
      commit 19b8766459c41c6f318f8a548cc1c66dffd18363 upstream.
      
      Each physical partition can provide multiple services each with UUID.
      Each such service can be presented as logical partition with a unique
      combination of VM ID and UUID. The number of distinct UUID in a system
      will be less than or equal to the number of logical partitions.
      
      However, currently it fails to register more than one logical partition
      or service within a physical partition as the device name contains only
      VM ID while both VM ID and UUID are maintained in the partition information.
      The kernel complains with the below message:
      
        | sysfs: cannot create duplicate filename '/devices/arm-ffa-8001'
        | CPU: 1 PID: 1 Comm: swapper/0 Not tainted 6.3.0-rc7 #8
        | Hardware name: FVP Base RevC (DT)
        | Call trace:
        |  dump_backtrace+0xf8/0x118
        |  show_stack+0x18/0x24
        |  dump_stack_lvl+0x50/0x68
        |  dump_stack+0x18/0x24
        |  sysfs_create_dir_ns+0xe0/0x13c
        |  kobject_add_internal+0x220/0x3d4
        |  kobject_add+0x94/0x100
        |  device_add+0x144/0x5d8
        |  device_register+0x20/0x30
        |  ffa_device_register+0x88/0xd8
        |  ffa_setup_partitions+0x108/0x1b8
        |  ffa_init+0x2ec/0x3a4
        |  do_one_initcall+0xcc/0x240
        |  do_initcall_level+0x8c/0xac
        |  do_initcalls+0x54/0x94
        |  do_basic_setup+0x1c/0x28
        |  kernel_init_freeable+0x100/0x16c
        |  kernel_init+0x20/0x1a0
        |  ret_from_fork+0x10/0x20
        | kobject_add_internal failed for arm-ffa-8001 with -EEXIST, don't try to
        | register things with the same name in the same directory.
        | arm_ffa arm-ffa: unable to register device arm-ffa-8001 err=-17
        | ARM FF-A: ffa_setup_partitions: failed to register partition ID 0x8001
      
      By virtue of being random enough to avoid collisions when generated in a
      distributed system, there is no way to compress UUID keys to the number
      of bits required to identify each. We can eliminate '-' in the name but
      it is not worth eliminating 4 bytes and add unnecessary logic for doing
      that. Also v1.0 doesn't provide the UUID of the partitions which makes
      it hard to use the same for the device name.
      
      So to keep it simple, let us alloc an ID using ida_alloc() and append the
      same to "arm-ffa" to make up a unique device name. Also stash the id value
      in ffa_dev to help freeing the ID later when the device is destroyed.
      
      Fixes: e7818584
      
       ("firmware: arm_ffa: Add initial FFA bus support for device enumeration")
      Reported-by: default avatarLucian Paul-Trifu <lucian.paul-trifu@arm.com>
      Link: https://lore.kernel.org/r/20230419-ffa_fixes_6-4-v2-3-d9108e43a176@arm.com
      
      
      Signed-off-by: default avatarSudeep Holla <sudeep.holla@arm.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      dfc5aaa5
    • Sudeep Holla's avatar
      firmware: arm_ffa: Check if ffa_driver remove is present before executing · ad73dc72
      Sudeep Holla authored
      commit b71b55248a580e9c9befc4ae060539f1f8e477da upstream.
      
      Currently ffa_drv->remove() is called unconditionally from
      ffa_device_remove(). Since the driver registration doesn't check for it
      and allows it to be registered without .remove callback, we need to check
      for the presence of it before executing it from ffa_device_remove() to
      above a NULL pointer dereference like the one below:
      
        | Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000
        | Mem abort info:
        |   ESR = 0x0000000086000004
        |   EC = 0x21: IABT (current EL), IL = 32 bits
        |   SET = 0, FnV = 0
        |   EA = 0, S1PTW = 0
        |   FSC = 0x04: level 0 translation fault
        | user pgtable: 4k pages, 48-bit VAs, pgdp=0000000881cc8000
        | [0000000000000000] pgd=0000000000000000, p4d=0000000000000000
        | Internal error: Oops: 0000000086000004 [#1] PREEMPT SMP
        | CPU: 3 PID: 130 Comm: rmmod Not tainted 6.3.0-rc7 #6
        | Hardware name: FVP Base RevC (DT)
        | pstate: 63402809 (nZCv daif +PAN -UAO +TCO +DIT -SSBS BTYPE=-c)
        | pc : 0x0
        | lr : ffa_device_remove+0x20/0x2c
        | Call trace:
        |  0x0
        |  device_release_driver_internal+0x16c/0x260
        |  driver_detach+0x90/0xd0
        |  bus_remove_driver+0xdc/0x11c
        |  driver_unregister+0x30/0x54
        |  ffa_driver_unregister+0x14/0x20
        |  cleanup_module+0x18/0xeec
        |  __arm64_sys_delete_module+0x234/0x378
        |  invoke_syscall+0x40/0x108
        |  el0_svc_common+0xb4/0xf0
        |  do_el0_svc+0x30/0xa4
        |  el0_svc+0x2c/0x7c
        |  el0t_64_sync_handler+0x84/0xf0
        |  el0t_64_sync+0x190/0x194
      
      Fixes: 244f5d59 ("firmware: arm_ffa: Add missing remove callback to ffa_bus_type")
      Link: https://lore.kernel.org/r/20230419-ffa_fixes_6-4-v2-1-d9108e43a176@arm.com
      
      
      Signed-off-by: default avatarSudeep Holla <sudeep.holla@arm.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ad73dc72
    • Etienne Carriere's avatar
      optee: fix uninited async notif value · 06ec5be8
      Etienne Carriere authored
      
      
      commit 654d0310007146fae87b0c1a68f81e53ad519b14 upstream.
      
      Fixes an uninitialized variable in irq_handler() that could lead to
      unpredictable behavior in case OP-TEE fails to handle SMC function ID
      OPTEE_SMC_GET_ASYNC_NOTIF_VALUE. This change ensures that in that case
      get_async_notif_value() properly reports there are no notification
      event.
      
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Link: https://lore.kernel.org/r/202304200755.OoiuclDZ-lkp@intel.com/
      
      
      Reported-by: default avatarDan Carpenter <error27@gmail.com>
      Link: https://lore.kernel.org/all/d9b7f69b-c737-4cb3-8e74-79fe00c934f9@kili.mountain/
      Fixes: 6749e69c
      
       ("optee: add asynchronous notifications")
      Signed-off-by: default avatarEtienne Carriere <etienne.carriere@linaro.org>
      Reviewed-by: default avatarSumit Garg <sumit.garg@linaro.org>
      Signed-off-by: default avatarJens Wiklander <jens.wiklander@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      06ec5be8
    • Daisuke Nojiri's avatar
      power: supply: sbs-charger: Fix INHIBITED bit for Status reg · 9c744c6f
      Daisuke Nojiri authored
      commit b2f2a3c9800208b0db2c2e34b05323757117faa2 upstream.
      
      CHARGE_INHIBITED bit position of the ChargerStatus register is actually
      0 not 1. This patch corrects it.
      
      Fixes: feb583e3
      
       ("power: supply: add sbs-charger driver")
      Signed-off-by: default avatarDaisuke Nojiri <dnojiri@chromium.org>
      Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9c744c6f
    • Hans de Goede's avatar
      power: supply: bq24190: Call power_supply_changed() after updating input current · 71e60a58
      Hans de Goede authored
      commit 77c2a3097d7029441e8a91aa0de1b4e5464593da upstream.
      
      The bq24192 model relies on external charger-type detection and once
      that is done the bq24190_charger code will update the input current.
      
      In this case, when the initial power_supply_changed() call is made
      from the interrupt handler, the input settings are 5V/0.5A which
      on many devices is not enough power to charge (while the device is on).
      
      On many devices the fuel-gauge relies in its external_power_changed
      callback to timely signal userspace about charging <-> discharging
      status changes. Add a power_supply_changed() call after updating
      the input current. This allows the fuel-gauge driver to timely recheck
      if the battery is charging after the new input current has been applied
      and then it can immediately notify userspace about this.
      
      Fixes: 18f8e6f6
      
       ("power: supply: bq24190_charger: Get input_current_limit from our supplier")
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      71e60a58
    • Hans de Goede's avatar
      power: supply: bq25890: Call power_supply_changed() after updating input current or voltage · 1f02bfd5
      Hans de Goede authored
      commit ad3d9c779b1f09f3f3a6fefd07af407c7bc7c9a7 upstream.
      
      The bq25892 model relies on external charger-type detection and once
      that is done the bq25890_charger code will update the input current
      and if pumpexpress is used also the input voltage.
      
      In this case, when the initial power_supply_changed() call is made
      from the interrupt handler, the input settings are 5V/0.5A which
      on many devices is not enough power to charge (while the device is on).
      
      On many devices the fuel-gauge relies in its external_power_changed
      callback to timely signal userspace about charging <-> discharging
      status changes. Add a power_supply_changed() call after updating
      the input current or voltage. This allows the fuel-gauge driver
      to timely recheck if the battery is charging after the new input
      settings have been applied and then it can immediately notify
      userspace about this.
      
      Fixes: 48f45b09 ("power: supply: bq25890: Support higher charging voltages through Pump Express+ protocol")
      Fixes: eab25b4f
      
       ("power: supply: bq25890: On the bq25892 set the IINLIM based on external charger detection")
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1f02bfd5
    • Hans de Goede's avatar
      power: supply: bq27xxx: After charger plug in/out wait 0.5s for things to stabilize · 57842035
      Hans de Goede authored
      commit 59a99cd462fbdf71f4e845e09f37783035088b4f upstream.
      
      bq27xxx_external_power_changed() gets called when the charger is plugged
      in or out. Rather then immediately scheduling an update wait 0.5 seconds
      for things to stabilize, so that e.g. the (dis)charge current is stable
      when bq27xxx_battery_update() runs.
      
      Fixes: 740b755a
      
       ("bq27x00: Poll battery state")
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      57842035
    • Hans de Goede's avatar
      power: supply: bq27xxx: Ensure power_supply_changed() is called on current sign changes · 221f7cb1
      Hans de Goede authored
      commit 939a116142012926e25de0ea6b7e2f8d86a5f1b6 upstream.
      
      On gauges where the current register is signed, there is no charging
      flag in the flags register. So only checking flags will not result
      in power_supply_changed() getting called when e.g. a charger is plugged
      in and the current sign changes from negative (discharging) to
      positive (charging).
      
      This causes userspace's notion of the status to lag until userspace
      does a poll.
      
      And when a power_supply_leds.c LED trigger is used to indicate charging
      status with a LED, this LED will lag until the capacity percentage
      changes, which may take many minutes (because the LED trigger only is
      updated on power_supply_changed() calls).
      
      Fix this by calling bq27xxx_battery_current_and_status() on gauges with
      a signed current register and checking if the status has changed.
      
      Fixes: 297a533b
      
       ("bq27x00: Cache battery registers")
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      221f7cb1