20 Jan, 2021

5 commits

  • commit 2cb091f6293df898b47f4e0f2e54324e2bbaf816 upstream.

    When set_has_smi_cap() fails, multiport master cleanup is missed. Fix it
    by doing the correct error unwinding goto.

    Fixes: a989ea01cb10 ("RDMA/mlx5: Move SMI caps logic")
    Link: https://lore.kernel.org/r/20210113121703.559778-3-leon@kernel.org
    Signed-off-by: Parav Pandit
    Signed-off-by: Leon Romanovsky
    Signed-off-by: Jason Gunthorpe
    Signed-off-by: Greg Kroah-Hartman

    Parav Pandit
     
  • commit 1c3aa6bd0b823105c2030af85d92d158e815d669 upstream.

    If the allocation of the fast path blue flame register fails, the driver
    should free the regular blue flame register allocated a statement above,
    not the one that it just failed to allocate.

    Fixes: 16c1975f1032 ("IB/mlx5: Create profile infrastructure to add and remove stages")
    Link: https://lore.kernel.org/r/20210113121703.559778-6-leon@kernel.org
    Reported-by: Hans Petter Selasky
    Signed-off-by: Mark Bloch
    Signed-off-by: Leon Romanovsky
    Signed-off-by: Jason Gunthorpe
    Signed-off-by: Greg Kroah-Hartman

    Mark Bloch
     
  • commit a306aba9c8d869b1fdfc8ad9237f1ed718ea55e6 upstream.

    If usnic_ib_qp_grp_create() fails at the first call, dev_list
    will not be freed on error, which leads to memleak.

    Fixes: e3cf00d0a87f ("IB/usnic: Add Cisco VIC low-level hardware driver")
    Link: https://lore.kernel.org/r/20201226074248.2893-1-dinghao.liu@zju.edu.cn
    Signed-off-by: Dinghao Liu
    Reviewed-by: Leon Romanovsky
    Signed-off-by: Jason Gunthorpe
    Signed-off-by: Greg Kroah-Hartman

    Dinghao Liu
     
  • commit 3c638cdb8ecc0442552156e0fed8708dd2c7f35b upstream.

    xa_alloc_cyclic() call returns positive number if ID allocation
    succeeded but wrapped. It is not an error, so normalize the "ret"
    variable to zero as marker of not-an-error.

    drivers/infiniband/core/restrack.c:261 rdma_restrack_add()
    warn: 'ret' can be either negative or positive

    Fixes: fd47c2f99f04 ("RDMA/restrack: Convert internal DB from hash to XArray")
    Link: https://lore.kernel.org/r/20201216100753.1127638-1-leon@kernel.org
    Reported-by: Dan Carpenter
    Signed-off-by: Leon Romanovsky
    Signed-off-by: Jason Gunthorpe
    Signed-off-by: Greg Kroah-Hartman

    Leon Romanovsky
     
  • commit f2bc3af6353cb2a33dfa9d270d999d839eef54cb upstream.

    In ocrdma_dealloc_ucontext_pd() uctx->cntxt_pd is assigned to the variable
    pd and then after uctx->cntxt_pd is freed, the variable pd is passed to
    function _ocrdma_dealloc_pd() which dereferences pd directly or through
    its call to ocrdma_mbx_dealloc_pd().

    Reorder the free using the variable pd.

    Cc: stable@vger.kernel.org
    Fixes: 21a428a019c9 ("RDMA: Handle PD allocations by IB/core")
    Link: https://lore.kernel.org/r/20201230024653.1516495-1-trix@redhat.com
    Signed-off-by: Tom Rix
    Reviewed-by: Leon Romanovsky
    Signed-off-by: Jason Gunthorpe
    Signed-off-by: Greg Kroah-Hartman

    Tom Rix
     

17 Jan, 2021

1 commit

  • [ Upstream commit 94a8c4dfcdb2b4fcb3dfafc39c1033a0b4637c86 ]

    Only the low 12 bits of vlan_id is valid, and service level has been
    filled in Address Vector. So there is no need to fill sl in vlan_id in
    Address Vector.

    Fixes: 7406c0036f85 ("RDMA/hns: Only record vlan info for HIP08")
    Link: https://lore.kernel.org/r/1607650657-35992-5-git-send-email-liweihang@huawei.com
    Signed-off-by: Weihang Li
    Signed-off-by: Jason Gunthorpe
    Signed-off-by: Sasha Levin

    Weihang Li
     

09 Jan, 2021

2 commits

  • [ Upstream commit a9d2e9ae953f0ddd0327479c81a085adaa76d903 ]

    This moves siw and rxe to be virtual devices in the device tree:

    lrwxrwxrwx 1 root root 0 Nov 6 13:55 /sys/class/infiniband/rxe0 -> ../../devices/virtual/infiniband/rxe0/

    Previously they were trying to parent themselves to the physical device of
    their attached netdev, which doesn't make alot of sense.

    My hope is this will solve some weird syzkaller hits related to sysfs as
    it could be possible that the parent of a netdev is another netdev, eg
    under bonding or some other syzkaller found netdev configuration.

    Nesting a ib_device under anything but a physical device is going to cause
    inconsistencies in sysfs during destructions.

    Link: https://lore.kernel.org/r/0-v1-dcbfc68c4b4a+d6-virtual_dev_jgg@nvidia.com
    Signed-off-by: Jason Gunthorpe
    Signed-off-by: Sasha Levin

    Jason Gunthorpe
     
  • [ Upstream commit 5a7a9e038b032137ae9c45d5429f18a2ffdf7d42 ]

    Use the ib_dma_* helpers to skip the DMA translation instead. This
    removes the last user if dma_virt_ops and keeps the weird layering
    violation inside the RDMA core instead of burderning the DMA mapping
    subsystems with it. This also means the software RDMA drivers now don't
    have to mess with DMA parameters that are not relevant to them at all, and
    that in the future we can use PCI P2P transfers even for software RDMA, as
    there is no first fake layer of DMA mapping that the P2P DMA support.

    Link: https://lore.kernel.org/r/20201106181941.1878556-8-hch@lst.de
    Signed-off-by: Christoph Hellwig
    Tested-by: Mike Marciniszyn
    Signed-off-by: Jason Gunthorpe
    Signed-off-by: Sasha Levin

    Christoph Hellwig
     

30 Dec, 2020

25 commits

  • [ Upstream commit e246b7c035d74abfb3507fa10082d0c42cc016c3 ]

    As part of the cma_dev release, that pointer will be set to NULL. In case
    it happens in rdma_bind_addr() (part of an error flow), the next call to
    addr_handler() will have a call to cma_acquire_dev_by_src_ip() which will
    overwrite sgid_attr without releasing it.

    WARNING: CPU: 2 PID: 108 at drivers/infiniband/core/cma.c:606 cma_bind_sgid_attr drivers/infiniband/core/cma.c:606 [inline]
    WARNING: CPU: 2 PID: 108 at drivers/infiniband/core/cma.c:606 cma_acquire_dev_by_src_ip+0x470/0x4b0 drivers/infiniband/core/cma.c:649
    CPU: 2 PID: 108 Comm: kworker/u8:1 Not tainted 5.10.0-rc6+ #257
    Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014
    Workqueue: ib_addr process_one_req
    RIP: 0010:cma_bind_sgid_attr drivers/infiniband/core/cma.c:606 [inline]
    RIP: 0010:cma_acquire_dev_by_src_ip+0x470/0x4b0 drivers/infiniband/core/cma.c:649
    Code: 66 d9 4a ff 4d 8b 6e 10 49 8d bd 1c 08 00 00 e8 b6 d6 4a ff 45 0f b6 bd 1c 08 00 00 41 83 e7 01 e9 49 fd ff ff e8 90 c5 29 ff 0b e9 80 fe ff ff e8 84 c5 29 ff 4c 89 f7 e8 2c d9 4a ff 4d 8b
    RSP: 0018:ffff8881047c7b40 EFLAGS: 00010293
    RAX: ffff888104789c80 RBX: 0000000000000001 RCX: ffffffff820b8ef8
    RDX: 0000000000000000 RSI: ffffffff820b9080 RDI: ffff88810cd4c998
    RBP: ffff8881047c7c08 R08: ffff888104789c80 R09: ffffed10209f4036
    R10: ffff888104fa01ab R11: ffffed10209f4035 R12: ffff88810cd4c800
    R13: ffff888105750e28 R14: ffff888108f0a100 R15: ffff88810cd4c998
    FS: 0000000000000000(0000) GS:ffff888119c00000(0000) knlGS:0000000000000000
    CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    CR2: 0000000000000000 CR3: 0000000104e60005 CR4: 0000000000370ea0
    DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
    DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
    Call Trace:
    addr_handler+0x266/0x350 drivers/infiniband/core/cma.c:3190
    process_one_req+0xa3/0x300 drivers/infiniband/core/addr.c:645
    process_one_work+0x54c/0x930 kernel/workqueue.c:2272
    worker_thread+0x82/0x830 kernel/workqueue.c:2418
    kthread+0x1ca/0x220 kernel/kthread.c:292
    ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:296

    Fixes: ff11c6cd521f ("RDMA/cma: Introduce and use cma_acquire_dev_by_src_ip()")
    Link: https://lore.kernel.org/r/20201213132940.345554-5-leon@kernel.org
    Signed-off-by: Leon Romanovsky
    Signed-off-by: Jason Gunthorpe
    Signed-off-by: Sasha Levin

    Leon Romanovsky
     
  • [ Upstream commit e89938902927a54abebccc9537991aca5237dfaf ]

    If the MR cache entry invalidation failed, then we detach this entry from
    the cache, therefore we must to free the memory as well.

    Allcation backtrace for the leaker:

    [] alloc_cache_mr+0x23/0xc0 [mlx5_ib]
    [] create_cache_mr+0x3f/0xf0 [mlx5_ib]
    [] mlx5_ib_alloc_implicit_mr+0x41/0×210 [mlx5_ib]
    [] mlx5_ib_reg_user_mr+0x9e/0×6e0 [mlx5_ib]
    [] create_qp+0x2fc/0xf00 [ib_uverbs]
    [] ib_uverbs_handler_UVERBS_METHOD_COUNTERS_READ+0x1d9/0×230 [ib_uverbs]
    [] rdma_alloc_commit_uobject+0xb5/0×120 [ib_uverbs]
    [] uverbs_alloc+0x2b/0xf0 [ib_uverbs]
    [] ksysioctl+0x234/0×7d0
    [] __x64_sys_ioctl+0x16/0×20
    [] do_syscall_64+0x59/0×2e0

    Fixes: 1769c4c57548 ("RDMA/mlx5: Always remove MRs from the cache before destroying them")
    Link: https://lore.kernel.org/r/20201213132940.345554-2-leon@kernel.org
    Signed-off-by: Maor Gottlieb
    Signed-off-by: Leon Romanovsky
    Signed-off-by: Jason Gunthorpe
    Signed-off-by: Sasha Levin

    Maor Gottlieb
     
  • [ Upstream commit 603bee935f38080a3674c763c50787751e387779 ]

    The high 6 bits of traffic class in GRH is DSCP (Differentiated Services
    Codepoint), the driver should shift it before the hardware gets it when
    using RoCEv2.

    Fixes: 606bf89e98ef ("RDMA/hns: Refactor for hns_roce_v2_modify_qp function")
    Fixes: fba429fcf9a5 ("RDMA/hns: Fix missing fields in address vector")
    Link: https://lore.kernel.org/r/1607650657-35992-4-git-send-email-liweihang@huawei.com
    Signed-off-by: Weihang Li
    Signed-off-by: Jason Gunthorpe
    Signed-off-by: Sasha Levin

    Weihang Li
     
  • [ Upstream commit 4ddeacf68a3dd05f346b63f4507e1032a15cc3cc ]

    Whether to enable the these features should better depend on the enable
    flags, not the value of related fields.

    Fixes: 5c1f167af112 ("RDMA/hns: Init SRQ table for hip08")
    Fixes: 3cb2c996c9dc ("RDMA/hns: Add support for SCCC in size of 64 Bytes")
    Link: https://lore.kernel.org/r/1607650657-35992-3-git-send-email-liweihang@huawei.com
    Signed-off-by: Wenpeng Liang
    Signed-off-by: Weihang Li
    Signed-off-by: Jason Gunthorpe
    Signed-off-by: Sasha Levin

    Wenpeng Liang
     
  • [ Upstream commit 1c0ca9cd1741687f529498ddb899805fc2c51caa ]

    For ib_copy_from_user(), the length of udata may not be the same as that
    of cmd. For ib_copy_to_user(), the length of udata may not be the same as
    that of resp. So limit the length to prevent out-of-bounds read and write
    operations from ib_copy_from_user() and ib_copy_to_user().

    Fixes: de77503a5940 ("RDMA/hns: RDMA/hns: Assign rq head pointer when enable rq record db")
    Fixes: 633fb4d9fdaa ("RDMA/hns: Use structs to describe the uABI instead of opencoding")
    Fixes: ae85bf92effc ("RDMA/hns: Optimize qp param setup flow")
    Fixes: 6fd610c5733d ("RDMA/hns: Support 0 hop addressing for SRQ buffer")
    Fixes: 9d9d4ff78884 ("RDMA/hns: Update the kernel header file of hns")
    Link: https://lore.kernel.org/r/1607650657-35992-2-git-send-email-liweihang@huawei.com
    Signed-off-by: Wenpeng Liang
    Signed-off-by: Weihang Li
    Signed-off-by: Jason Gunthorpe
    Signed-off-by: Sasha Levin

    Wenpeng Liang
     
  • [ Upstream commit e0da68994d16b46384cce7b86eb645f1ef7c51ef ]

    Fix incorrect type of max_entries in UVERBS_METHOD_QUERY_GID_TABLE -
    max_entries is of type size_t although it can take negative values.

    The following static check revealed it:

    drivers/infiniband/core/uverbs_std_types_device.c:338 ib_uverbs_handler_UVERBS_METHOD_QUERY_GID_TABLE() warn: 'max_entries' unsigned
    Signed-off-by: Avihai Horon
    Signed-off-by: Leon Romanovsky
    Signed-off-by: Jason Gunthorpe
    Signed-off-by: Sasha Levin

    Avihai Horon
     
  • [ Upstream commit 779e0bf47632c609c59f527f9711ecd3214dccb0 ]

    In procedure ib_register_device, procedure kobject_uevent is called
    (advertising that the device is ready for userspace usage) even when
    device_enable_and_get() returned an error.

    As a result, various RDMA modules attempted to register for the device
    even while the device driver was preparing to unregister the device.

    Fix this by advertising the device availability only after enabling the
    device succeeds.

    Fixes: e7a5b4aafd82 ("RDMA/device: Don't fire uevent before device is fully initialized")
    Link: https://lore.kernel.org/r/20201208073545.9723-3-leon@kernel.org
    Suggested-by: Leon Romanovsky
    Signed-off-by: Jack Morgenstein
    Signed-off-by: Leon Romanovsky
    Signed-off-by: Jason Gunthorpe
    Signed-off-by: Sasha Levin

    Jack Morgenstein
     
  • [ Upstream commit d34895c319faa1e0fc1a48c3b06bba6a8a39ba44 ]

    Page alignment is required when setting the number of extended sge
    according to the hardware's achivement. If the space of needed extended
    sge is greater than one page, the roundup_pow_of_two() can ensure
    that. But if the needed extended sge isn't 0 and can not be filled in a
    whole page, the driver should align it specifically.

    Fixes: 54d6638765b0 ("RDMA/hns: Optimize WQE buffer size calculating process")
    Link: https://lore.kernel.org/r/1606558959-48510-3-git-send-email-liweihang@huawei.com
    Signed-off-by: Yangyang Li
    Signed-off-by: Weihang Li
    Reviewed-by: Leon Romanovsky
    Signed-off-by: Jason Gunthorpe
    Signed-off-by: Sasha Levin

    Yangyang Li
     
  • [ Upstream commit 0fd0175e30e487f8d70ecb2cdd67fbb514fdf50f ]

    One RC SQ WQE can store 2 sges but UD can't, so ignore 2 valid sges of
    wr.sglist for RC which have been filled in WQE before setting extended
    sge. Either of RC and UD can not contain 0-length sges, so these 0-length
    sges should be skipped.

    Fixes: 54d6638765b0 ("RDMA/hns: Optimize WQE buffer size calculating process")
    Link: https://lore.kernel.org/r/1606558959-48510-2-git-send-email-liweihang@huawei.com
    Signed-off-by: Lang Cheng
    Signed-off-by: Weihang Li
    Reviewed-by: Leon Romanovsky
    Signed-off-by: Jason Gunthorpe
    Signed-off-by: Sasha Levin

    Lang Cheng
     
  • [ Upstream commit b47a98efa97889c5b16d17e77eed3dc4500674eb ]

    Device memory (DM) are registered as MR during initialization flow, these
    MRs were not tracked by resource tracker and had res->valid set as a
    false. Update the code to manage them too.

    Before this change:
    $ ibv_rc_pingpong -j &
    $ rdma res show mr
    Signed-off-by: Jason Gunthorpe
    Signed-off-by: Sasha Levin

    Leon Romanovsky
     
  • [ Upstream commit 3631dadfb118821236098a215e59fb5d3e1c30a8 ]

    The loopback flag will be set to 1 by the hardware when the source mac
    address is same as the destination mac address. So the driver don't need
    to compare them.

    Fixes: d6a3627e311c ("RDMA/hns: Optimize wqe buffer set flow for post send")
    Link: https://lore.kernel.org/r/1605526408-6936-4-git-send-email-liweihang@huawei.com
    Signed-off-by: Weihang Li
    Signed-off-by: Jason Gunthorpe
    Signed-off-by: Sasha Levin

    Weihang Li
     
  • [ Upstream commit fba429fcf9a5e0c4ec2523ecf4cf18bc0507fcbc ]

    Traffic class and hop limit in address vector is not assigned from GRH,
    but it will be filled into UD SQ WQE. So the hardware will get a wrong
    value.

    Fixes: 82e620d9c3a0 ("RDMA/hns: Modify the data structure of hns_roce_av")
    Link: https://lore.kernel.org/r/1605526408-6936-3-git-send-email-liweihang@huawei.com
    Signed-off-by: Weihang Li
    Signed-off-by: Jason Gunthorpe
    Signed-off-by: Sasha Levin

    Weihang Li
     
  • [ Upstream commit 7406c0036f851ee1cd93cb08349f24b051b4cbf8 ]

    Information about vlan is stored in GMV(GID/MAC/VLAN) table for HIP09, so
    there is no need to copy it to address vector.

    Link: https://lore.kernel.org/r/1605526408-6936-2-git-send-email-liweihang@huawei.com
    Signed-off-by: Weihang Li
    Signed-off-by: Jason Gunthorpe
    Signed-off-by: Sasha Levin

    Weihang Li
     
  • [ Upstream commit dd37d2f59eb839d51b988f6668ce5f0d533b23fd ]

    rdma_detroy_id() cannot be called under &lock - we must instead keep the
    error'd ID around until &lock can be released, then destroy it.

    This is complicated by the usual way listen IDs are destroyed through
    cma_process_remove() which can run at any time and will asynchronously
    destroy the same ID.

    Remove the ID from visiblity of cma_process_remove() before going down the
    destroy path outside the locking.

    Fixes: c80a0c52d85c ("RDMA/cma: Add missing error handling of listen_id")
    Link: https://lore.kernel.org/r/20201118133756.GK244516@ziepe.ca
    Reported-by: syzbot+1bc48bf7f78253f664a9@syzkaller.appspotmail.com
    Reviewed-by: Leon Romanovsky
    Signed-off-by: Jason Gunthorpe
    Signed-off-by: Sasha Levin

    Jason Gunthorpe
     
  • [ Upstream commit 6d8285e604e0221b67bd5db736921b7ddce37d00 ]

    Before create CQ, make sure that the requested number of CQEs is in the
    supported range.

    Fixes: cfdda9d76436 ("RDMA/cxgb4: Add driver for Chelsio T4 RNIC")
    Link: https://lore.kernel.org/r/20201108132007.67537-1-kamalheib1@gmail.com
    Signed-off-by: Kamal Heib
    Signed-off-by: Jason Gunthorpe
    Signed-off-by: Sasha Levin

    Kamal Heib
     
  • [ Upstream commit c80a0c52d85c49a910d0dc0e342e8d8898677dc0 ]

    Don't silently continue if rdma_listen() fails but destroy previously
    created CM_ID and return an error to the caller.

    Fixes: d02d1f5359e7 ("RDMA/cma: Fix deadlock destroying listen requests")
    Link: https://lore.kernel.org/r/20201104144008.3808124-5-leon@kernel.org
    Signed-off-by: Leon Romanovsky
    Signed-off-by: Jason Gunthorpe
    Signed-off-by: Sasha Levin

    Leon Romanovsky
     
  • [ Upstream commit fbb7dc5db6dee553b5a07c27e86364a5223e244c ]

    gcc points out a suspicious mixing of enum types in a function that
    converts from MTHCA_OPCODE_* values to IB_WC_* values:

    drivers/infiniband/hw/mthca/mthca_cq.c: In function 'mthca_poll_one':
    drivers/infiniband/hw/mthca/mthca_cq.c:607:21: warning: implicit conversion from 'enum ' to 'enum ib_wc_opcode' [-Wenum-conversion]
    607 | entry->opcode = MTHCA_OPCODE_INVALID;

    Nothing seems to ever check for MTHCA_OPCODE_INVALID again, no idea if
    this is meaningful, but it seems harmless as it deals with an invalid
    input.

    Remove MTHCA_OPCODE_INVALID and set the ib_wc_opcode to 0xFF, which is
    still bogus, but at least doesn't make compiler warnings.

    Fixes: 2a4443a69934 ("[PATCH] IB/mthca: fill in opcode field for send completions")
    Link: https://lore.kernel.org/r/20201026211311.3887003-1-arnd@kernel.org
    Signed-off-by: Arnd Bergmann
    Signed-off-by: Jason Gunthorpe
    Signed-off-by: Sasha Levin

    Arnd Bergmann
     
  • [ Upstream commit fc3325701a6353594083f08e297d4c1965c601aa ]

    reg_pages should always contain mr->npage since when the mr is finally
    de-reg'd it is always subtracted out.

    If there were any error exits then mlx5_ib_rereg_user_mr() would leave the
    reg_pages adjusted and this will cause it to be double subtracted
    eventually.

    The manipulation of reg_pages is inherently connected to the umem, so lift
    it out of set_mr_fields() and only adjust it around creating/destroying a
    umem.

    reg_pages is only used for diagnostics in sysfs.

    Fixes: 7d0cc6edcc70 ("IB/mlx5: Add MR cache for large UMR regions")
    Link: https://lore.kernel.org/r/20201026131936.1335664-3-leon@kernel.org
    Signed-off-by: Leon Romanovsky
    Signed-off-by: Jason Gunthorpe
    Signed-off-by: Sasha Levin

    Jason Gunthorpe
     
  • [ Upstream commit d715ff8acbd5876549ef2b21b755ed919f40dcc1 ]

    The purpose of srv_mutex is to protect srv_list as in put_srv, so no need
    to hold it when allocate memory for srv since it could be time consuming.

    Otherwise if one machine has limited memory, rsrv_close_work could be
    blocked for a longer time due to the mutex is held by get_or_create_srv
    since it can't get memory in time.

    INFO: task kworker/1:1:27478 blocked for more than 120 seconds.
    Tainted: G O 4.14.171-1-storage #4.14.171-1.3~deb9
    "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
    kworker/1:1 D 0 27478 2 0x80000000
    Workqueue: rtrs_server_wq rtrs_srv_close_work [rtrs_server]
    Call Trace:
    ? __schedule+0x38c/0x7e0
    schedule+0x32/0x80
    schedule_preempt_disabled+0xa/0x10
    __mutex_lock.isra.2+0x25e/0x4d0
    ? put_srv+0x44/0x100 [rtrs_server]
    put_srv+0x44/0x100 [rtrs_server]
    rtrs_srv_close_work+0x16c/0x280 [rtrs_server]
    process_one_work+0x1c5/0x3c0
    worker_thread+0x47/0x3e0
    kthread+0xfc/0x130
    ? trace_event_raw_event_workqueue_execute_start+0xa0/0xa0
    ? kthread_create_on_node+0x70/0x70
    ret_from_fork+0x1f/0x30

    Let's move all the logics from __find_srv_and_get and __alloc_srv to
    get_or_create_srv, and remove the two functions. Then it should be safe
    for multiple processes to access the same srv since it is protected with
    srv_mutex.

    And since we don't want to allocate chunks with srv_mutex held, let's
    check the srv->refcount after get srv because the chunks could not be
    allocated yet.

    Fixes: 9cb837480424 ("RDMA/rtrs: server: main functionality")
    Link: https://lore.kernel.org/r/20201023074353.21946-6-jinpu.wang@cloud.ionos.com
    Signed-off-by: Guoqing Jiang
    Signed-off-by: Jack Wang
    Signed-off-by: Jason Gunthorpe
    Signed-off-by: Sasha Levin

    Guoqing Jiang
     
  • [ Upstream commit f553e7601df9566ba7644541fc09152a3a81f793 ]

    When rtrs_rdma_conn_established returns error (non-zero value), the error
    value is stored in con->cm_err and it cannot trigger
    rtrs_rdma_error_recovery. Finally the error of rtrs_rdma_con_established
    will be forgot.

    Fixes: 6a98d71daea1 ("RDMA/rtrs: client: main functionality")
    Link: https://lore.kernel.org/r/20201023074353.21946-5-jinpu.wang@cloud.ionos.com
    Signed-off-by: Gioh Kim
    Signed-off-by: Jack Wang
    Signed-off-by: Jason Gunthorpe
    Signed-off-by: Sasha Levin

    Gioh Kim
     
  • [ Upstream commit 2b3062e4d997f201c1ad2bbde88b7271dd9ef35f ]

    We call destroy_con_cq_qp(con) in rtrs_rdma_addr_resolved() in case route
    couldn't be resolved and then again in create_cm() because nothing
    happens.

    Don't call destroy_con_cq_qp from rtrs_rdma_addr_resolved, create_cm()
    does the clean up already.

    Fixes: 6a98d71daea1 ("RDMA/rtrs: client: main functionality")
    Link: https://lore.kernel.org/r/20201023074353.21946-2-jinpu.wang@cloud.ionos.com
    Signed-off-by: Danil Kipnis
    Signed-off-by: Jack Wang
    Signed-off-by: Jason Gunthorpe
    Signed-off-by: Sasha Levin

    Danil Kipnis
     
  • [ Upstream commit bb3ab2979fd69db23328691cb10067861df89037 ]

    The code which limited the number of unacknowledged PSNs was incorrect.
    The PSNs are limited to 24 bits and wrap back to zero from 0x00ffffff.
    The test was computing a 32 bit value which wraps at 32 bits so that
    qp->req.psn can appear smaller than the limit when it is actually larger.

    Replace '>' test with psn_compare which is used for other PSN comparisons
    and correctly handles the 24 bit size.

    Fixes: 8700e3e7c485 ("Soft RoCE driver")
    Link: https://lore.kernel.org/r/20201013170741.3590-1-rpearson@hpe.com
    Signed-off-by: Bob Pearson
    Signed-off-by: Jason Gunthorpe
    Signed-off-by: Sasha Levin

    Bob Pearson
     
  • [ Upstream commit 5333499c6014224756e97fa1a1047dfa592d76d3 ]

    Fix to return error code PTR_ERR() from the error handling case instead of
    0.

    Fixes: 51aab12631dd ("RDMA/core: Get xmit slave for LAG")
    Link: https://lore.kernel.org/r/20201016075845.129562-1-jingxiangfeng@huawei.com
    Signed-off-by: Jing Xiangfeng
    Reviewed-by: Maor Gottlieb
    Signed-off-by: Jason Gunthorpe
    Signed-off-by: Sasha Levin

    Jing Xiangfeng
     
  • [ Upstream commit b898d5c50cab1f985e77d053eb5c4d2c4a7694ae ]

    Only static WQE is supported for SRQ. So always use the max supported SGEs
    while calculating SRQ entry size.

    Fixes: 2bb3c32c5c5f ("RDMA/bnxt_re: Change wr posting logic to accommodate variable wqes")
    Link: https://lore.kernel.org/r/1602569752-12745-1-git-send-email-selvin.xavier@broadcom.com
    Signed-off-by: Devesh Sharma
    Signed-off-by: Selvin Xavier
    Signed-off-by: Jason Gunthorpe
    Signed-off-by: Sasha Levin

    Selvin Xavier
     
  • [ Upstream commit 53839b51a7671eeb3fb44d479d541cf3a0f2dd45 ]

    The API for ib_query_qp requires the driver to set cur_qp_state on return,
    add the missing set.

    Fixes: 1ac5a4047975 ("RDMA/bnxt_re: Add bnxt_re RoCE driver")
    Link: https://lore.kernel.org/r/20201021114952.38876-1-kamalheib1@gmail.com
    Signed-off-by: Kamal Heib
    Acked-by: Selvin Xavier
    Signed-off-by: Jason Gunthorpe
    Signed-off-by: Sasha Levin

    Kamal Heib
     

10 Dec, 2020

1 commit

  • If cm_create_timewait_info() fails, the timewait_info pointer will contain
    an error value and will be used in cm_remove_remote() later.

    general protection fault, probably for non-canonical address 0xdffffc0000000024: 0000 [#1] SMP KASAN PTI
    KASAN: null-ptr-deref in range [0×0000000000000120-0×0000000000000127]
    CPU: 2 PID: 12446 Comm: syz-executor.3 Not tainted 5.10.0-rc5-5d4c0742a60e #27
    Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014
    RIP: 0010:cm_remove_remote.isra.0+0x24/0×170 drivers/infiniband/core/cm.c:978
    Code: 84 00 00 00 00 00 41 54 55 53 48 89 fb 48 8d ab 2d 01 00 00 e8 7d bf 4b fe 48 89 ea 48 b8 00 00 00 00 00 fc ff df 48 c1 ea 03 b6 04 02 48 89 ea 83 e2 07 38 d0 7f 08 84 c0 0f 85 fc 00 00 00
    RSP: 0018:ffff888013127918 EFLAGS: 00010006
    RAX: dffffc0000000000 RBX: fffffffffffffff4 RCX: ffffc9000a18b000
    RDX: 0000000000000024 RSI: ffffffff82edc573 RDI: fffffffffffffff4
    RBP: 0000000000000121 R08: 0000000000000001 R09: ffffed1002624f1d
    R10: 0000000000000003 R11: ffffed1002624f1c R12: ffff888107760c70
    R13: ffff888107760c40 R14: fffffffffffffff4 R15: ffff888107760c9c
    FS: 00007fe1ffcc1700(0000) GS:ffff88811a600000(0000) knlGS:0000000000000000
    CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    CR2: 0000001b2ff21000 CR3: 000000010f504001 CR4: 0000000000370ee0
    DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
    DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
    Call Trace:
    cm_destroy_id+0x189/0×15b0 drivers/infiniband/core/cm.c:1155
    cma_connect_ib drivers/infiniband/core/cma.c:4029 [inline]
    rdma_connect_locked+0x1100/0×17c0 drivers/infiniband/core/cma.c:4107
    rdma_connect+0x2a/0×40 drivers/infiniband/core/cma.c:4140
    ucma_connect+0x277/0×340 drivers/infiniband/core/ucma.c:1069
    ucma_write+0x236/0×2f0 drivers/infiniband/core/ucma.c:1724
    vfs_write+0x220/0×830 fs/read_write.c:603
    ksys_write+0x1df/0×240 fs/read_write.c:658
    do_syscall_64+0x33/0×40 arch/x86/entry/common.c:46
    entry_SYSCALL_64_after_hwframe+0x44/0xa9

    Fixes: a977049dacde ("[PATCH] IB: Add the kernel CM implementation")
    Link: https://lore.kernel.org/r/20201204064205.145795-1-leon@kernel.org
    Reviewed-by: Maor Gottlieb
    Reported-by: Amit Matityahu
    Signed-off-by: Leon Romanovsky
    Signed-off-by: Jason Gunthorpe

    Leon Romanovsky
     

08 Dec, 2020

1 commit

  • The query_gid_table ioctl skips non IB/RoCE ports, which as a result
    returns an empty gid table for devices such as EFA which have a GID table,
    but are not IB/RoCE.

    Fixes: c4b4d548fabc ("RDMA/core: Introduce new GID table query API")
    Link: https://lore.kernel.org/r/20201206153238.34878-1-galpress@amazon.com
    Signed-off-by: Gal Pressman
    Signed-off-by: Jason Gunthorpe

    Gal Pressman
     

02 Dec, 2020

2 commits

  • The local variables cur_state and new_state hold the state that should be
    used for the modify QP operation instead of the ones in the ib_qp_attr
    struct.

    Fixes: 40909f664d27 ("RDMA/efa: Add EFA verbs implementation")
    Link: https://lore.kernel.org/r/20201201091724.37016-1-galpress@amazon.com
    Reviewed-by: Firas JahJah
    Reviewed-by: Yossi Leybovich
    Signed-off-by: Gal Pressman
    Signed-off-by: Jason Gunthorpe

    Gal Pressman
     
  • This patch fixes issue introduced by a previous commit where iWARP
    doorbell address wasn't initialized, causing call trace when any RDMA
    application wants to use this interface:

    Illegal doorbell address: 0000000000000000. Legal range for doorbell addresses is [0000000011431e08..00000000ec3799d3]
    WARNING: CPU: 11 PID: 11990 at drivers/net/ethernet/qlogic/qed/qed_dev.c:93 qed_db_rec_sanity.isra.12+0x48/0x70 [qed]
    ...
    hpsa scsi_transport_sas [last unloaded: crc8]
    CPU: 11 PID: 11990 Comm: rping Tainted: G S 5.10.0-rc1 #29
    Hardware name: HP ProLiant DL380 Gen9/ProLiant DL380 Gen9, BIOS P89 01/22/2018
    RIP: 0010:qed_db_rec_sanity.isra.12+0x48/0x70 [qed]
    ...
    RSP: 0018:ffffafc28458fa88 EFLAGS: 00010286
    RAX: 0000000000000000 RBX: ffff8d0d4c620000 RCX: 0000000000000000
    RDX: ffff8d10afde7d50 RSI: ffff8d10afdd8b40 RDI: ffff8d10afdd8b40
    RBP: ffffafc28458fe38 R08: 0000000000000003 R09: 0000000000007fff
    R10: 0000000000000001 R11: ffffafc28458f888 R12: 0000000000000000
    R13: 0000000000000000 R14: ffff8d0d43ccbbd0 R15: ffff8d0d48dae9c0
    FS: 00007fbd5267e740(0000) GS:ffff8d10afdc0000(0000) knlGS:0000000000000000
    CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    CR2: 00007fbd4f258fb8 CR3: 0000000108d96003 CR4: 00000000001706e0
    Call Trace:
    qed_db_recovery_add+0x6d/0x1f0 [qed]
    qedr_create_user_qp+0x57e/0xd30 [qedr]
    qedr_create_qp+0x5f3/0xab0 [qedr]
    ? lookup_get_idr_uobject.part.12+0x45/0x90 [ib_uverbs]
    create_qp+0x45d/0xb30 [ib_uverbs]
    ? ib_uverbs_cq_event_handler+0x30/0x30 [ib_uverbs]
    ib_uverbs_create_qp+0xb9/0xe0 [ib_uverbs]
    ib_uverbs_write+0x3f9/0x570 [ib_uverbs]
    ? security_mmap_file+0x62/0xe0
    vfs_write+0xb7/0x200
    ksys_write+0xaf/0xd0
    ? syscall_trace_enter.isra.25+0x152/0x200
    do_syscall_64+0x2d/0x40
    entry_SYSCALL_64_after_hwframe+0x44/0xa9

    Fixes: 06e8d1df46ed ("RDMA/qedr: Add support for user mode XRC-SRQ's")
    Link: https://lore.kernel.org/r/20201127163251.14533-1-palok@marvell.com
    Signed-off-by: Michal Kalderon
    Signed-off-by: Igor Russkikh
    Signed-off-by: Alok Prasad
    Signed-off-by: Jason Gunthorpe

    Alok Prasad
     

26 Nov, 2020

3 commits

  • When a memory window is bound to a memory region, the local write access
    should be set for its mtpt table.

    Fixes: c7c28191408b ("RDMA/hns: Add MW support for hip08")
    Link: https://lore.kernel.org/r/1606386372-21094-1-git-send-email-liweihang@huawei.com
    Signed-off-by: Yixian Liu
    Signed-off-by: Weihang Li
    Signed-off-by: Jason Gunthorpe

    Yixian Liu
     
  • The maximum number of retransmission should be returned when querying QP,
    not the value of retransmission counter.

    Fixes: 99fcf82521d9 ("RDMA/hns: Fix the wrong value of rnr_retry when querying qp")
    Fixes: 926a01dc000d ("RDMA/hns: Add QP operations support for hip08 SoC")
    Link: https://lore.kernel.org/r/1606382977-21431-1-git-send-email-liweihang@huawei.com
    Signed-off-by: Wenpeng Liang
    Signed-off-by: Weihang Li
    Signed-off-by: Jason Gunthorpe

    Wenpeng Liang
     
  • The SRQ capacity is got from the firmware, whose field should be ended at
    bit 19.

    Fixes: ba6bb7e97421 ("RDMA/hns: Add interfaces to get pf capabilities from firmware")
    Link: https://lore.kernel.org/r/1606382812-23636-1-git-send-email-liweihang@huawei.com
    Signed-off-by: Wenpeng Liang
    Signed-off-by: Weihang Li
    Signed-off-by: Jason Gunthorpe

    Wenpeng Liang