Blame SOURCES/0000-rdma-core-v22.1-to-stable-v22-update.patch

81ae37
commit 098d4238d9b9e584aaf4b9adb533defa6d310481
81ae37
Author: Mark Haywood <mark.haywood@oracle.com>
81ae37
Date:   Fri Apr 26 17:56:19 2019 +0200
81ae37
81ae37
    ibacm: fix double hint.ai_family assignment in ib_acm_connect_open()
81ae37
    
81ae37
    [ Upstream commit 08843dc99669ae50c5ba204db644d5423fe8e910 ]
81ae37
    
81ae37
    It appears that a previous fix accidentally introduced a double
81ae37
    assignment to hint.ai_family and, in the process, accidentally removed
81ae37
    the assignment to hint.ai_protocol. This patch will fix both
81ae37
    assignments.
81ae37
    
81ae37
    Fixes: 579b6bf8 ("ibacm: Adding new configuration option 'server_mode'")
81ae37
    
81ae37
    Signed-off-by: Mark Haywood <mark.haywood@oracle.com>
81ae37
    Signed-off-by: Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.com>
81ae37
81ae37
commit 6c7d8a5152fccc0d17e7470318f925faed322b57
81ae37
Author: Mark Haywood <mark.haywood@oracle.com>
81ae37
Date:   Fri Apr 26 17:09:28 2019 +0200
81ae37
81ae37
    ibacm: acme does not work if server_mode != unix
81ae37
    
81ae37
    [ Upstream commit 75ce9310735f7bcfc93e2bf442f0e5d268e0c5ab ]
81ae37
    
81ae37
    Running the ibacm server in mode loopback or open and then trying to run
81ae37
    ib_acme against it, fails:
81ae37
    
81ae37
    $ ib_acme -S 127.0.0.1 -v -f i -s 10.196.100.60 -d 10.196.1.60
81ae37
    *** Error in `ib_acme': double free or corruption (fasttop): 0x000000000177c380 ***
81ae37
    ======= Backtrace: =========
81ae37
    /lib64/libc.so.6(+0x7c619)[0x7f540121d619]
81ae37
    /lib64/libc.so.6(freeaddrinfo+0x28)[0x7f5401282fe8]
81ae37
    ib_acme[0x4049eb]
81ae37
    ib_acme[0x401841]
81ae37
    /lib64/libc.so.6(__libc_start_main+0xf5)[0x7f54011c2c05]
81ae37
    ib_acme[0x40315b]
81ae37
    
81ae37
    In ib_acm_connect_open(), there is a double freeaddrinfo() that needs
81ae37
    to be fixed. And the socket close() should only be called if connect()
81ae37
    fails.
81ae37
    
81ae37
    Afterwards:
81ae37
    
81ae37
    $ ib_acme -S 127.0.0.1 -v -f i -s 10.196.100.60 -d 10.196.1.60
81ae37
    Service: 127.0.0.1
81ae37
    Destination: 10.196.1.60
81ae37
    Source: 10.196.100.60
81ae37
    Path information
81ae37
      dgid: fe80::10:e000:128:d021
81ae37
      sgid: fe80::10:e000:128:d021
81ae37
      dlid: 19
81ae37
      slid: 19
81ae37
      flow label: 0x0
81ae37
      hop limit: 0
81ae37
      tclass: 0
81ae37
      reversible: 1
81ae37
      pkey: 0xffff
81ae37
      sl: 0
81ae37
      mtu: 4
81ae37
      rate: 7
81ae37
      packet lifetime: 0
81ae37
    SA verification: success
81ae37
    
81ae37
    return status 0x0
81ae37
    
81ae37
    Fixes: 579b6bf8 ("ibacm: Adding new configuration option 'server_mode'")
81ae37
    
81ae37
    Signed-off-by: Mark Haywood <mark.haywood@oracle.com>
81ae37
    Signed-off-by: Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.com>
81ae37
81ae37
commit d26a969c00c7743c25e0d3083aa3c1b926bd05cb
81ae37
Author: Mark Haywood <mark.haywood@oracle.com>
81ae37
Date:   Fri Apr 26 16:40:14 2019 +0200
81ae37
81ae37
    ibacm: ib_acm_connect() is doing too much
81ae37
    
81ae37
    [ Upstream commit c58daf0f1e6c71945907339afec17a350c0d49a6 ]
81ae37
    
81ae37
    The ib_acm_connect() function is performing multiple functions. It
81ae37
    handles setting up the connections for the three server modes, "unix",
81ae37
    "open" and "loop". The "open" and "loop" mode logic should share one
81ae37
    function. The "linux" mode logic should have its own function.
81ae37
    And ib_acm_connect() can call the appropriate helper function.
81ae37
    
81ae37
    Signed-off-by: Mark Haywood <mark.haywood@oracle.com>
81ae37
    Signed-off-by: Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.com>
81ae37
81ae37
commit aaba94df0afb6b3cf61f23a030410395f137c974
81ae37
Author: Mark Haywood <mark.haywood@oracle.com>
81ae37
Date:   Mon Apr 15 22:43:01 2019 +0200
81ae37
81ae37
    verbs: The ibv_xsrq_pingpong "-c" option is broken
81ae37
    
81ae37
    [ Upstream commit 2bdfa37f61bb3899e0afcee497432e0b34c14a35 ]
81ae37
    
81ae37
    $ ibv_xsrq_pingpong -c 2
81ae37
    Segmentation fault
81ae37
    
81ae37
    The getopt_long() optstring was modifed by 257470c2 to remove ':' from
81ae37
    the string leaving an optstring of "p:d:i:s:m:q:r:n:l:eg:c". The
81ae37
    explanation for this change in 257470c2 is:
81ae37
    
81ae37
    "Also, The buffer validation option doesn't require an extra parameter,
81ae37
    remove the extra ':' from all ibv_*_pingpong examples."
81ae37
    
81ae37
    In other ibv_*_pingpong examples, the "-c" option refers to the chk
81ae37
    (buffer validation) option. So, it made sense to make the change in
81ae37
    those example programs, but not in ibv_xsrq_pingpong.
81ae37
    
81ae37
    Fixes: 257470c2 ("verbs: Fix pingpong buffer validation")
81ae37
    
81ae37
    Signed-off-by: Mark Haywood <mark.haywood@oracle.com>
81ae37
    Signed-off-by: Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.com>
81ae37
81ae37
commit 17cb113341bd4933ea785c5aac0197b0fa836a1e
81ae37
Author: Michael Guralnik <michaelgur@mellanox.com>
81ae37
Date:   Mon Apr 15 17:08:42 2019 +0300
81ae37
81ae37
    mlx5: Fix masking service level in mlx5_create_ah
81ae37
    
81ae37
    [ Upstream commit 30978598c761a3f5b0e0cc4337107d91e897cf2e ]
81ae37
    
81ae37
    Fix masking of service level when creating AH to 4 bits in case of IB
81ae37
    link layer to match PRM definition.
81ae37
    
81ae37
    Fixes: 4e0c23429839 ("mlx5: Fix SL to Ethernet priority conversion")
81ae37
    Signed-off-by: Michael Guralnik <michaelgur@mellanox.com>
81ae37
    Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
81ae37
    Signed-off-by: Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.com>
81ae37
81ae37
commit 4ef38020957e478f8b5d1df0dea7fd60a25c7a9e
81ae37
Author: Leon Romanovsky <leonro@mellanox.com>
81ae37
Date:   Wed Apr 17 16:46:36 2019 +0300
81ae37
81ae37
    cmake: Explicitly convert build type to be STRING
81ae37
    
81ae37
    [ Upstream commit 10998b0068bd1503ed1c3c213c5450faf194e5cf ]
81ae37
    
81ae37
    The build type was declared As "String" instead of "STRING" and it
81ae37
    produced the following warning while rdma-core was built.
81ae37
    
81ae37
    CMake Warning (dev) at buildlib/RDMA_BuildType.cmake:11 (set):
81ae37
      implicitly converting 'String' to 'STRING' type.
81ae37
    Call Stack (most recent call first):
81ae37
      CMakeLists.txt:170 (RDMA_BuildType)
81ae37
    This warning is for project developers.  Use -Wno-dev to suppress it.
81ae37
    
81ae37
    Fixes: 7cb1daa8d9e6 ("Be consistent about defining NDEBUG")
81ae37
    Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
81ae37
    Signed-off-by: Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.com>
81ae37
81ae37
commit d05900db873f1a4ab6af1159ee87e50a15296352
81ae37
Author: Lijun Ou <oulijun@huawei.com>
81ae37
Date:   Sat Mar 23 10:05:09 2019 +0800
81ae37
81ae37
    libhns: Bugfix for filtering zero length sge
81ae37
    
81ae37
    [ Upstream commit 1c2def4817f31c15342669144ef6bb894bd9616d ]
81ae37
    
81ae37
    When user posts a wqe with n sges, the driver needs to
81ae37
    determine to if each sge is valid and filter the invalid
81ae37
    sge, fill the number of valid sges into sq wqe. Hip08
81ae37
    hardware allocates the correct memory location for each
81ae37
    valid sge based on the number of valid sge. For exmaple,
81ae37
    when posts a wqe with 3 sges. if 3 sge is valid, the first
81ae37
    and second sges will be filled into the wqe and the last
81ae37
    sge will fill the indpendent memory location which the
81ae37
    hardware allocated additionally. However, it will happen
81ae37
    error if the first and the second sges is invalid.
81ae37
    Because the driver will filter the first two sge and fill
81ae37
    the last sge into hardware. But the valid sge will be
81ae37
    stored in the extended memory and the correct way
81ae37
    should be stored in wqe.
81ae37
    
81ae37
    The other situation example as follows:
81ae37
    Posting five sge and have two invalid sge.
81ae37
     ________________________________________
81ae37
    |___0____|__1____|___0____|__1___|___1__|
81ae37
    
81ae37
    the 0 express the sge is invalid, the 1 express the sge is valid.
81ae37
    Based on the above situation. the hardware will store the second
81ae37
    and the fourth sge into sq wqe. The last sge will be stored in
81ae37
    the extend memory location. the number of valid sge is 3.
81ae37
    
81ae37
    Fixes: 29ef2625c4e1 ("libhns: Filter for zero length of sge in hip08 userspace")
81ae37
    Signed-off-by: Lijun Ou <oulijun@huawei.com>
81ae37
    Signed-off-by: Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.com>
81ae37
81ae37
commit f3bb8968d3c1b622d586b51b6782ea26d4362489
81ae37
Author: Guy Levi <guyle@mellanox.com>
81ae37
Date:   Tue Mar 19 12:45:00 2019 +0200
81ae37
81ae37
    buildlib: Ensure stanza is properly sorted
81ae37
    
81ae37
    [ Upstream commit 7d9a24f18372587608bcbfc42c3251d7697ea6ef ]
81ae37
    
81ae37
    A sanity check which verifies that the stanza version is the newest,
81ae37
    triggers a false alarm due to wrong sorting method. For example, a new
81ae37
    version tagged by 1.10 was sorted as older than 1.2 tag. Replacing the
81ae37
    sort method by LooseVersion from distutils fixes the issue.
81ae37
    
81ae37
    Fixes: 7cff8245374c ("Have travis check shared library filenames")
81ae37
    Signed-off-by: Guy Levi <guyle@mellanox.com>
81ae37
    Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
81ae37
    Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
81ae37
    Signed-off-by: Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.com>
81ae37
81ae37
commit e02238eae4901cb2f0570b887c88f05824d76d47
81ae37
Author: Tzafrir Cohen <tzafrirc@mellanox.com>
81ae37
Date:   Wed Mar 13 21:46:52 2019 +0200
81ae37
81ae37
    debian: Create empty pyverbs package for builds without pyverbs
81ae37
    
81ae37
    [ Upstream commit ae52ee74cefcff13ebc6786a28740a881c38b2f0 ]
81ae37
    
81ae37
    Other parts of the standard Debian build toolchain (specifically:
81ae37
    dpkg-genchangelog, but possibly others) expect a package to exist.
81ae37
    
81ae37
    dpkg-genchanges: error: cannot fstat file
81ae37
    ../python3-pyverbs_23.0~201903120844+git272bb55~ubuntu16.04.1_amd64.deb: No such file or directory
81ae37
    dpkg-buildpackage: error: dpkg-genchanges gave error exit status 2
81ae37
    
81ae37
    Link: https://launchpadlibrarian.net/414799420/buildlog_ubuntu-xenial-amd64.rdma-core_23.0~201903120844+git272bb55~ubuntu16.04.1_BUILDING.txt.gz
81ae37
    Fixes: 841c9f041f0af ("debian: Add pyverbs to Debian package")
81ae37
    Signed-off-by: Tzafrir Cohen <tzafrirc@mellanox.com>
81ae37
    Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
81ae37
    Signed-off-by: Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.com>
81ae37
81ae37
commit 90886054afbb91fdeb7df3fc7e6424eaec72fdea
81ae37
Author: Artemy Kovalyov <artemyko@mellanox.com>
81ae37
Date:   Sat Feb 23 16:40:17 2019 +0200
81ae37
81ae37
    verbs: Fix attribute returning
81ae37
    
81ae37
    [ Upstream commit 888c598db4df509dfb2d44a151df7490450a118e ]
81ae37
    
81ae37
    Fix copying of returned attributes to chained buffers.
81ae37
    
81ae37
    Fixes: 776003b23f51 ("verbs: Allow all commands to be invoked by ioctl")
81ae37
    Fixes: a93098a32fdf ("verbs: Fix attribute preparation")
81ae37
    Signed-off-by: Artemy Kovalyov <artemyko@mellanox.com>
81ae37
    Reviewed-by: Jason Gunthorpe <jgg@mellanox.com>
81ae37
    Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
81ae37
    Signed-off-by: Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.com>
81ae37
81ae37
commit c7c842a3cc4e0e7cca10613dc7e74e73fbbdf6f1
81ae37
Author: Tzafrir Cohen <tzafrirc@mellanox.com>
81ae37
Date:   Thu Feb 28 15:19:06 2019 +0200
81ae37
81ae37
    build: Fix pyverbs build issues on Debian
81ae37
    
81ae37
    [ Upstream commit ea5d6a50e76f3f6c88ac2db0b7143496d827100f ]
81ae37
    
81ae37
    Cython is used to build pyverbs, which is only supported in Python3.
81ae37
    Don't try to look for Cython if we don't have Python3.
81ae37
    Also update debian/rules file:
81ae37
    - configure: Check if Python3 is supported instead of relying on
81ae37
      EXTRA_CMAKE_FLAGS which is not set at this point.
81ae37
    - install: Add pyverbs to ignored missing packages if it wasn't built
81ae37
      (this decision will be taken by cmake at this point).
81ae37
    - build: Ignore pyverbs if it wasn't built.
81ae37
    
81ae37
    Fixes: 1ce4a3e8 ('pyverbs: Update cmake to include pyverbs package')
81ae37
    Signed-off-by: Tzafrir Cohen <tzafrirc@mellanox.com>
81ae37
    Signed-off-by: Noa Osherovich <noaos@mellanox.com>
81ae37
    Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
81ae37
    Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
81ae37
    Signed-off-by: Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.com>
81ae37
81ae37
commit 8043035f921f79ee723b764947f99398e580bc86
81ae37
Author: Leon Romanovsky <leonro@mellanox.com>
81ae37
Date:   Thu Mar 7 20:22:06 2019 +0200
81ae37
81ae37
    travis: Change SuSE package target due to Travis CI failures
81ae37
    
81ae37
    [ Upstream commit b65dbb91bd80119065eaefb8c9bee773b8f347ec ]
81ae37
    
81ae37
    Change SuSE package target to leap due to random sigfaults while
81ae37
    running zypper command in tumbleweed under Travis CI environment.
81ae37
    
81ae37
    Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
81ae37
    Signed-off-by: Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.com>
81ae37
81ae37
commit a4bbfc338f631648c65e02149f91da9939c21e2f
81ae37
Author: Ariel Levkovich <lariel@mellanox.com>
81ae37
Date:   Mon Jan 21 22:09:00 2019 +0200
81ae37
81ae37
    verbs: Avoid inline send when using device memory in rc_pingpong
81ae37
    
81ae37
    [ Upstream commit 9548325b725e1eb37b8f3553d54d27fac6cf1a92 ]
81ae37
    
81ae37
    Fix rc_pingpong example to avoid setting the inline send flag when using
81ae37
    device memory.
81ae37
    
81ae37
    When using device memory, posting send with inline data is not supported
81ae37
    since the device memory address is zero based and accessing it to copy
81ae37
    data will cause segmentation fault.
81ae37
    
81ae37
    Fixes: f06164d5ea8d ("verbs: Add device memory support in rc_pingpong example")
81ae37
    Signed-off-by: Ariel Levkovich <lariel@mellanox.com>
81ae37
    Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
81ae37
    Signed-off-by: Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.com>
81ae37
81ae37
commit 4b38d3cdfb939800976ad63fedaf8971439b6fa3
81ae37
Author: Ariel Levkovich <lariel@mellanox.com>
81ae37
Date:   Wed Feb 6 00:48:38 2019 +0200
81ae37
81ae37
    mlx5: Use copy loop to read from device memory
81ae37
    
81ae37
    [ Upstream commit e84d7117aa0cbf47695dd0a663f6f1cb1d273e28 ]
81ae37
    
81ae37
    Revise the flow of copying data from device memory buffer to use a 4
81ae37
    byte load loop since memcpy may use SSE instructions while the device
81ae37
    memory is an uncachable, IO mapped memory.
81ae37
    
81ae37
    Fixes: 9bb70e385874 ("mlx5: Device memory support")
81ae37
    Signed-off-by: Ariel Levkovich <lariel@mellanox.com>
81ae37
    Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
81ae37
    Signed-off-by: Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.com>
81ae37
81ae37
commit d38817ea554a9fd140e56414a7c74e7eef444c50
81ae37
Author: Mark Bloch <markb@mellanox.com>
81ae37
Date:   Wed Feb 20 20:00:45 2019 +0000
81ae37
81ae37
    verbs: clear cmd buffer when creating indirection table
81ae37
    
81ae37
    [ Upstream commit 34225464c1d165f63ffd462364810cc9f374109d ]
81ae37
    
81ae37
    Make sure we clear the cmd buffer, not doing so will make the kernel to
81ae37
    fail the command.
81ae37
    
81ae37
    Fixes: 75c65bbcadcd ("verbs: Consolidate duplicate code in create_rwq_ind_table")
81ae37
    Signed-off-by: Mark Bloch <markb@mellanox.com>
81ae37
    Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
81ae37
    Signed-off-by: Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.com>
81ae37
81ae37
commit 9dcfa6cd2e0b84fcf74218198e98e18c04ec374f
81ae37
Author: Lijun Ou <oulijun@huawei.com>
81ae37
Date:   Thu Feb 21 10:40:43 2019 +0800
81ae37
81ae37
    libhns: Bugfix for using buffer length
81ae37
    
81ae37
    [ Upstream commit e25684538c95e0286de7bfd96a643c7b2d34deda ]
81ae37
    
81ae37
    We should use the length of buffer after aligned according the
81ae37
    input size for ibv_dontfork_range function.
81ae37
    
81ae37
    Fixes: c24583975044 ("libhns: Add verbs of qp support")
81ae37
    Signed-off-by: Lijun Ou <oulijun@huawei.com>
81ae37
    Signed-off-by: Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.com>
81ae37
81ae37
commit 23e3a5dac44f9ec81ee5402c5e45009715aee241
81ae37
Author: Bodong Wang <bodong@mellanox.com>
81ae37
Date:   Thu Sep 27 15:32:27 2018 -0500
81ae37
81ae37
    mlx5: Fix incorrect error handling when SQ wqe count is 0
81ae37
    
81ae37
    [ Upstream commit 37bd67876947fb600f4d1691391796778af89843 ]
81ae37
    
81ae37
    Driver allocates memory based on wqe count and checks whether the memory
81ae37
    allocation succeeded. However, this memory check should not be performed
81ae37
    when wqe count is 0.
81ae37
    
81ae37
    Fixes: 8c4791ae2395 ("libmlx5: First version of libmlx5")
81ae37
    Signed-off-by: Bodong Wang <bodong@mellanox.com>
81ae37
    Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
81ae37
    Signed-off-by: Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.com>
81ae37
diff --git a/CMakeLists.txt b/CMakeLists.txt
81ae37
index 8310ec6c..0a8ad522 100644
81ae37
--- a/CMakeLists.txt
81ae37
+++ b/CMakeLists.txt
81ae37
@@ -360,23 +360,23 @@ else()
81ae37
   set(HAVE_FULL_SYMBOL_VERSIONS 1)
81ae37
 endif()
81ae37
 
81ae37
-if (${NO_PYVERBS})
81ae37
-  set(CYTHON_EXECUTABLE "")
81ae37
-else ()
81ae37
-  # Look for Python. We prefer some variant of python 3 if the system has it.
81ae37
-  FIND_PACKAGE(PythonInterp 3 QUIET)
81ae37
-  if (NOT ${PythonInterp_FOUND})
81ae37
-    FIND_PACKAGE(PythonInterp REQUIRED)
81ae37
-  endif()
81ae37
-  FIND_PACKAGE(cython)
81ae37
-endif()
81ae37
-
81ae37
 # Look for Python. We prefer some variant of python 3 if the system has it.
81ae37
 FIND_PACKAGE(PythonInterp 3 QUIET)
81ae37
-if (NOT ${PythonInterp_FOUND})
81ae37
+if (PythonInterp_FOUND)
81ae37
+  # pyverbs can only use python3:
81ae37
+  if (NO_PYVERBS)
81ae37
+    set(CYTHON_EXECUTABLE "")
81ae37
+  else()
81ae37
+    FIND_PACKAGE(cython)
81ae37
+  endif()
81ae37
+else()
81ae37
+  # But we still must have python (be it 2) for the build process:
81ae37
   FIND_PACKAGE(PythonInterp REQUIRED)
81ae37
+  set(CYTHON_EXECUTABLE "")
81ae37
 endif()
81ae37
+
81ae37
 # A cython & python-devel installation that matches our selected interpreter.
81ae37
+
81ae37
 if (CYTHON_EXECUTABLE)
81ae37
  # cmake has really bad logic here, if PythonIterp has been run it tries to
81ae37
  # find a matching -devel installation but will happily return a non-matching
81ae37
diff --git a/buildlib/RDMA_BuildType.cmake b/buildlib/RDMA_BuildType.cmake
81ae37
index 0951edad..17206f51 100644
81ae37
--- a/buildlib/RDMA_BuildType.cmake
81ae37
+++ b/buildlib/RDMA_BuildType.cmake
81ae37
@@ -8,7 +8,7 @@ function(RDMA_BuildType)
81ae37
   # in performance contexts it doesn't make much sense to have the default build
81ae37
   # turn off the optimizer.
81ae37
   if(NOT CMAKE_BUILD_TYPE)
81ae37
-    set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE String
81ae37
+	  set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
81ae37
       "Options are ${build_types}"
81ae37
       FORCE
81ae37
       )
81ae37
diff --git a/buildlib/cbuild b/buildlib/cbuild
81ae37
index 9ced0de6..15095d0c 100755
81ae37
--- a/buildlib/cbuild
81ae37
+++ b/buildlib/cbuild
81ae37
@@ -641,10 +641,6 @@ def run_deb_build(args,env):
81ae37
             "-e","DEB_BUILD_OPTIONS=parallel=%u"%(multiprocessing.cpu_count()),
81ae37
         ];
81ae37
 
81ae37
-        if not env.build_pyverbs:
81ae37
-            opts.append("-e");
81ae37
-            opts.append("EXTRA_CMAKE_FLAGS=%s"%(' '.join(["-DNO_PYVERBS=1"])));
81ae37
-
81ae37
         # Create a go.py that will let us run the compilation as the user and
81ae37
         # then switch to root only for the packaging step.
81ae37
         with open(os.path.join(tmpdir,"go.py"),"w") as F:
81ae37
diff --git a/buildlib/check-build b/buildlib/check-build
81ae37
index 5ae0cc1c..348b0590 100755
81ae37
--- a/buildlib/check-build
81ae37
+++ b/buildlib/check-build
81ae37
@@ -14,6 +14,7 @@ import copy
81ae37
 import shlex
81ae37
 import pipes
81ae37
 from contextlib import contextmanager;
81ae37
+from distutils.version import LooseVersion;
81ae37
 
81ae37
 def get_src_dir():
81ae37
     """Get the source directory using git"""
81ae37
@@ -106,7 +107,7 @@ def check_lib_symver(args,fn):
81ae37
                 private,args.PACKAGE_VERSION));
81ae37
 
81ae37
     syms = list(syms - private);
81ae37
-    syms.sort(key=lambda x:re.split('[._]',x));
81ae37
+    syms.sort(key=LooseVersion)
81ae37
     if newest_symver != syms[-1]:
81ae37
         raise ValueError("Symbol version %r implied by filename %r not the newest in ELF (%r)"%(
81ae37
             newest_symver,fn,syms));
81ae37
diff --git a/buildlib/package-build-test b/buildlib/package-build-test
81ae37
index 46a1cf6f..29c17838 100755
81ae37
--- a/buildlib/package-build-test
81ae37
+++ b/buildlib/package-build-test
81ae37
@@ -11,7 +11,7 @@ if [ -e "/.dockerenv" ] || (grep -q docker /proc/self/cgroup &>/dev/null); then
81ae37
        exit 0
81ae37
 fi
81ae37
 
81ae37
-for OS in centos7 tumbleweed
81ae37
+for OS in centos7 leap
81ae37
 do
81ae37
 	echo
81ae37
 	echo "Checking package build for ${OS} ...."
81ae37
diff --git a/debian/rules b/debian/rules
81ae37
index dceb6352..2d5b2670 100755
81ae37
--- a/debian/rules
81ae37
+++ b/debian/rules
81ae37
@@ -37,14 +37,15 @@ DH_AUTO_CONFIGURE := "--" \
81ae37
 		     $(EXTRA_CMAKE_FLAGS)
81ae37
 
81ae37
 override_dh_auto_configure:
81ae37
-ifeq ($(EXTRA_CMAKE_FLAGS), -DNO_PYVERBS=1)
81ae37
-	dh_auto_configure $(DH_AUTO_CONFIGURE)
81ae37
-else
81ae37
-	dh_auto_configure $(DH_AUTO_CONFIGURE) \
81ae37
-		        -DNO_PYVERBS=0 \
81ae37
-			-DPYTHON_EXECUTABLE:PATH=/usr/bin/python3 \
81ae37
-			-DCMAKE_INSTALL_PYTHON_ARCH_LIB:PATH=/usr/lib/python3/dist-packages
81ae37
-endif
81ae37
+	if [ -e /usr/bin/python3 ]; then \
81ae37
+		dh_auto_configure $(DH_AUTO_CONFIGURE) \
81ae37
+				-DPYTHON_EXECUTABLE:PATH=/usr/bin/python3 \
81ae37
+				-DCMAKE_INSTALL_PYTHON_ARCH_LIB:PATH=/usr/lib/python3/dist-packages; \
81ae37
+	else \
81ae37
+		dh_auto_configure $(DH_AUTO_CONFIGURE) \
81ae37
+			        -DNO_PYVERBS=1; \
81ae37
+	fi
81ae37
+
81ae37
 
81ae37
 override_dh_auto_build:
81ae37
 	ninja -C build-deb -v
81ae37
@@ -72,7 +73,11 @@ ifeq ($(EXTRA_CMAKE_FLAGS), -DNO_PYVERBS=1)
81ae37
 endif
81ae37
 INST_EXCLUDE := $(addprefix -X,$(INST_EXCLUDE))
81ae37
 override_dh_install:
81ae37
-	dh_install --fail-missing $(INST_EXCLUDE)
81ae37
+	if [ -e build-deb/python/pyverbs/__init__.py ]; then \
81ae37
+		dh_install --fail-missing $(INST_EXCLUDE); \
81ae37
+	else \
81ae37
+		dh_install -Npython3-pyverbs --fail-missing $(INST_EXCLUDE) --remaining-packages; \
81ae37
+	fi
81ae37
 
81ae37
 # cmake installs the correct init scripts in the correct place, just setup the
81ae37
 # pre-postrms
81ae37
@@ -99,13 +104,6 @@ override_dh_strip:
81ae37
 	dh_strip -plibrdmacm1 --dbg-package=librdmacm1-dbg
81ae37
 	dh_strip --remaining-packages
81ae37
 
81ae37
-override_dh_builddeb:
81ae37
-ifeq ($(EXTRA_CMAKE_FLAGS), -DNO_PYVERBS=1)
81ae37
-	dh_builddeb -Npython3-pyverbs --remaining-packages
81ae37
-else
81ae37
-	dh_builddeb --remaining-package
81ae37
-endif
81ae37
-
81ae37
 # Upstream encourages the use of 'build' as the developer build output
81ae37
 # directory, allow that directory to be present and still allow dh to work.
81ae37
 .PHONY: build
81ae37
diff --git a/ibacm/src/libacm.c b/ibacm/src/libacm.c
81ae37
index 1d9d7145..e50fbf43 100644
81ae37
--- a/ibacm/src/libacm.c
81ae37
+++ b/ibacm/src/libacm.c
81ae37
@@ -56,7 +56,7 @@ static void acm_set_server_port(void)
81ae37
 	}
81ae37
 }
81ae37
 
81ae37
-int ib_acm_connect(char *dest)
81ae37
+static int ib_acm_connect_open(char *dest)
81ae37
 {
81ae37
 	struct addrinfo hint, *res;
81ae37
 	int ret;
81ae37
@@ -64,67 +64,72 @@ int ib_acm_connect(char *dest)
81ae37
 	acm_set_server_port();
81ae37
 	memset(&hint, 0, sizeof hint);
81ae37
 
81ae37
-	if (dest && *dest != '/') {
81ae37
-		hint.ai_family = AF_INET;
81ae37
-		hint.ai_family = AF_UNSPEC;
81ae37
-
81ae37
-		ret = getaddrinfo(dest, NULL, &hint, &res;;
81ae37
-		if (ret)
81ae37
-			return ret;
81ae37
-
81ae37
-		sock = socket(res->ai_family, res->ai_socktype,
81ae37
-			      res->ai_protocol);
81ae37
-		if (sock == -1) {
81ae37
-			ret = errno;
81ae37
-			goto err1;
81ae37
-		}
81ae37
+	hint.ai_family = AF_UNSPEC;
81ae37
+	hint.ai_protocol = IPPROTO_TCP;
81ae37
 
81ae37
-		((struct sockaddr_in *) res->ai_addr)->sin_port =
81ae37
-			htobe16(server_port);
81ae37
-		ret = connect(sock, res->ai_addr, res->ai_addrlen);
81ae37
-		if (ret)
81ae37
-			goto err2;
81ae37
+	ret = getaddrinfo(dest, NULL, &hint, &res;;
81ae37
+	if (ret)
81ae37
+		return ret;
81ae37
 
81ae37
-		freeaddrinfo(res);
81ae37
+	sock = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
81ae37
+	if (sock == -1) {
81ae37
+		ret = errno;
81ae37
+		goto freeaddr;
81ae37
+	}
81ae37
 
81ae37
-err2:
81ae37
+	((struct sockaddr_in *) res->ai_addr)->sin_port = htobe16(server_port);
81ae37
+	ret = connect(sock, res->ai_addr, res->ai_addrlen);
81ae37
+	if (ret) {
81ae37
 		close(sock);
81ae37
 		sock = -1;
81ae37
-err1:
81ae37
-		freeaddrinfo(res);
81ae37
-	} else {
81ae37
-		struct sockaddr_un addr;
81ae37
-
81ae37
-		addr.sun_family = AF_UNIX;
81ae37
-		if (dest) {
81ae37
-			if (snprintf(addr.sun_path, sizeof(addr.sun_path),
81ae37
-				     "%s", dest) >= sizeof(addr.sun_path)) {
81ae37
-				errno = ENAMETOOLONG;
81ae37
-				return errno;
81ae37
-			}
81ae37
-		} else {
81ae37
-			BUILD_ASSERT(sizeof(IBACM_IBACME_SERVER_PATH) <=
81ae37
-				     sizeof(addr.sun_path));
81ae37
-			strcpy(addr.sun_path, IBACM_IBACME_SERVER_PATH);
81ae37
-		}
81ae37
+	}
81ae37
 
81ae37
-		sock = socket(AF_UNIX, SOCK_STREAM, 0);
81ae37
-		if (sock < 0)
81ae37
-			return errno;
81ae37
+freeaddr:
81ae37
+	freeaddrinfo(res);
81ae37
+	return ret;
81ae37
+}
81ae37
 
81ae37
-		if (connect(sock,
81ae37
-			    (struct sockaddr *)&addr, sizeof(addr)) != 0) {
81ae37
-			ret = errno;
81ae37
-			close(sock);
81ae37
-			sock = -1;
81ae37
-			errno = ret;
81ae37
-			return ret;
81ae37
+static int ib_acm_connect_unix(char *dest)
81ae37
+{
81ae37
+	struct sockaddr_un addr;
81ae37
+	int ret;
81ae37
+
81ae37
+	addr.sun_family = AF_UNIX;
81ae37
+	if (dest) {
81ae37
+		if (snprintf(addr.sun_path, sizeof(addr.sun_path),
81ae37
+			     "%s", dest) >= sizeof(addr.sun_path)) {
81ae37
+			errno = ENAMETOOLONG;
81ae37
+			return errno;
81ae37
 		}
81ae37
+	} else {
81ae37
+		BUILD_ASSERT(sizeof(IBACM_IBACME_SERVER_PATH) <=
81ae37
+			     sizeof(addr.sun_path));
81ae37
+		strcpy(addr.sun_path, IBACM_IBACME_SERVER_PATH);
81ae37
+	}
81ae37
+
81ae37
+	sock = socket(AF_UNIX, SOCK_STREAM, 0);
81ae37
+	if (sock < 0)
81ae37
+		return errno;
81ae37
+
81ae37
+	if (connect(sock, (struct sockaddr *)&addr, sizeof(addr)) != 0) {
81ae37
+		ret = errno;
81ae37
+		close(sock);
81ae37
+		sock = -1;
81ae37
+		errno = ret;
81ae37
+		return ret;
81ae37
 	}
81ae37
 
81ae37
 	return 0;
81ae37
 }
81ae37
 
81ae37
+int ib_acm_connect(char *dest)
81ae37
+{
81ae37
+	if (dest && *dest == '/')
81ae37
+		return ib_acm_connect_unix(dest);
81ae37
+
81ae37
+	return ib_acm_connect_open(dest);
81ae37
+}
81ae37
+
81ae37
 void ib_acm_disconnect(void)
81ae37
 {
81ae37
 	if (sock != -1) {
81ae37
diff --git a/libibverbs/cmd.c b/libibverbs/cmd.c
81ae37
index 34c71e56..5817c598 100644
81ae37
--- a/libibverbs/cmd.c
81ae37
+++ b/libibverbs/cmd.c
81ae37
@@ -1854,6 +1854,7 @@ int ibv_cmd_create_rwq_ind_table(struct ibv_context *context,
81ae37
 	cmd_size = sizeof(*cmd) + num_tbl_entries * sizeof(cmd->wq_handles[0]);
81ae37
 	cmd_size = (cmd_size + 7) / 8 * 8;
81ae37
 	cmd = alloca(cmd_size);
81ae37
+	memset(cmd, 0, cmd_size);
81ae37
 
81ae37
 	for (i = 0; i < num_tbl_entries; i++)
81ae37
 		cmd->wq_handles[i] = init_attr->ind_tbl[i]->handle;
81ae37
diff --git a/libibverbs/cmd_ioctl.c b/libibverbs/cmd_ioctl.c
81ae37
index 82ef2cd7..2a46c49c 100644
81ae37
--- a/libibverbs/cmd_ioctl.c
81ae37
+++ b/libibverbs/cmd_ioctl.c
81ae37
@@ -79,7 +79,6 @@ static void prepare_attrs(struct ibv_command_buffer *cmd)
81ae37
 	}
81ae37
 
81ae37
 	cmd->hdr.num_attrs = end - cmd->hdr.attrs;
81ae37
-	cmd->last_attr = end;
81ae37
 
81ae37
 	/*
81ae37
 	 * We keep the in UHW uninlined until directly before sending to
81ae37
@@ -113,7 +112,7 @@ static void finalize_attrs(struct ibv_command_buffer *cmd)
81ae37
 	struct ibv_command_buffer *link;
81ae37
 	struct ib_uverbs_attr *end;
81ae37
 
81ae37
-	for (end = cmd->hdr.attrs; end != cmd->last_attr; end++)
81ae37
+	for (end = cmd->hdr.attrs; end != cmd->next_attr; end++)
81ae37
 		finalize_attr(end);
81ae37
 
81ae37
 	for (link = cmd->next; link; link = link->next) {
81ae37
diff --git a/libibverbs/examples/rc_pingpong.c b/libibverbs/examples/rc_pingpong.c
81ae37
index 8b2253d5..0f37f5df 100644
81ae37
--- a/libibverbs/examples/rc_pingpong.c
81ae37
+++ b/libibverbs/examples/rc_pingpong.c
81ae37
@@ -488,9 +488,8 @@ static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev, int size,
81ae37
 		}
81ae37
 
81ae37
 		ibv_query_qp(ctx->qp, &attr, IBV_QP_CAP, &init_attr);
81ae37
-		if (init_attr.cap.max_inline_data >= size) {
81ae37
+		if (init_attr.cap.max_inline_data >= size && !use_dm)
81ae37
 			ctx->send_flags |= IBV_SEND_INLINE;
81ae37
-		}
81ae37
 	}
81ae37
 
81ae37
 	{
81ae37
diff --git a/libibverbs/examples/xsrq_pingpong.c b/libibverbs/examples/xsrq_pingpong.c
81ae37
index 4c0d825f..cfd3c34a 100644
81ae37
--- a/libibverbs/examples/xsrq_pingpong.c
81ae37
+++ b/libibverbs/examples/xsrq_pingpong.c
81ae37
@@ -876,7 +876,7 @@ int main(int argc, char *argv[])
81ae37
 			{}
81ae37
 		};
81ae37
 
81ae37
-		c = getopt_long(argc, argv, "p:d:i:s:m:n:l:eg:c", long_options,
81ae37
+		c = getopt_long(argc, argv, "p:d:i:s:m:n:l:eg:c:", long_options,
81ae37
 				NULL);
81ae37
 		if (c == -1)
81ae37
 			break;
81ae37
diff --git a/providers/hns/hns_roce_u_buf.c b/providers/hns/hns_roce_u_buf.c
81ae37
index f92ea651..27ed90c2 100644
81ae37
--- a/providers/hns/hns_roce_u_buf.c
81ae37
+++ b/providers/hns/hns_roce_u_buf.c
81ae37
@@ -46,7 +46,7 @@ int hns_roce_alloc_buf(struct hns_roce_buf *buf, unsigned int size,
81ae37
 	if (buf->buf == MAP_FAILED)
81ae37
 		return errno;
81ae37
 
81ae37
-	ret = ibv_dontfork_range(buf->buf, size);
81ae37
+	ret = ibv_dontfork_range(buf->buf, buf->length);
81ae37
 	if (ret)
81ae37
 		munmap(buf->buf, buf->length);
81ae37
 
81ae37
diff --git a/providers/hns/hns_roce_u_hw_v2.c b/providers/hns/hns_roce_u_hw_v2.c
81ae37
index af3bab1f..dd71fb14 100644
81ae37
--- a/providers/hns/hns_roce_u_hw_v2.c
81ae37
+++ b/providers/hns/hns_roce_u_hw_v2.c
81ae37
@@ -555,7 +555,6 @@ int hns_roce_u_v2_post_send(struct ibv_qp *ibvqp, struct ibv_send_wr *wr,
81ae37
 	unsigned int ind_sge;
81ae37
 	unsigned int ind;
81ae37
 	int nreq;
81ae37
-	int i;
81ae37
 	void *wqe;
81ae37
 	int ret = 0;
81ae37
 	struct hns_roce_qp *qp = to_hr_qp(ibvqp);
81ae37
@@ -563,7 +562,10 @@ int hns_roce_u_v2_post_send(struct ibv_qp *ibvqp, struct ibv_send_wr *wr,
81ae37
 	struct hns_roce_rc_sq_wqe *rc_sq_wqe;
81ae37
 	struct hns_roce_v2_wqe_data_seg *dseg;
81ae37
 	struct ibv_qp_attr attr;
81ae37
+	int valid_num_sge;
81ae37
 	int attr_mask;
81ae37
+	int j;
81ae37
+	int i;
81ae37
 
81ae37
 	pthread_spin_lock(&qp->sq.lock);
81ae37
 
81ae37
@@ -598,17 +600,25 @@ int hns_roce_u_v2_post_send(struct ibv_qp *ibvqp, struct ibv_send_wr *wr,
81ae37
 		memset(rc_sq_wqe, 0, sizeof(struct hns_roce_rc_sq_wqe));
81ae37
 
81ae37
 		qp->sq.wrid[ind & (qp->sq.wqe_cnt - 1)] = wr->wr_id;
81ae37
-		for (i = 0; i < wr->num_sge; i++)
81ae37
+
81ae37
+		valid_num_sge = wr->num_sge;
81ae37
+		j = 0;
81ae37
+
81ae37
+		for (i = 0; i < wr->num_sge; i++) {
81ae37
+			if (unlikely(!wr->sg_list[i].length))
81ae37
+				valid_num_sge--;
81ae37
+
81ae37
 			rc_sq_wqe->msg_len =
81ae37
 					htole32(le32toh(rc_sq_wqe->msg_len) +
81ae37
 							wr->sg_list[i].length);
81ae37
+		}
81ae37
 
81ae37
 		if (wr->opcode == IBV_WR_SEND_WITH_IMM ||
81ae37
 		    wr->opcode == IBV_WR_RDMA_WRITE_WITH_IMM)
81ae37
 			rc_sq_wqe->immtdata = htole32(be32toh(wr->imm_data));
81ae37
 
81ae37
 		roce_set_field(rc_sq_wqe->byte_16, RC_SQ_WQE_BYTE_16_SGE_NUM_M,
81ae37
-			       RC_SQ_WQE_BYTE_16_SGE_NUM_S, wr->num_sge);
81ae37
+			       RC_SQ_WQE_BYTE_16_SGE_NUM_S, valid_num_sge);
81ae37
 
81ae37
 		roce_set_field(rc_sq_wqe->byte_20,
81ae37
 			       RC_SQ_WQE_BYTE_20_MSG_START_SGE_IDX_S,
81ae37
@@ -774,7 +784,7 @@ int hns_roce_u_v2_post_send(struct ibv_qp *ibvqp, struct ibv_send_wr *wr,
81ae37
 			set_data_seg_v2(dseg, wr->sg_list);
81ae37
 			wqe += sizeof(struct hns_roce_v2_wqe_data_seg);
81ae37
 			set_atomic_seg(wqe, wr);
81ae37
-		} else if (wr->send_flags & IBV_SEND_INLINE && wr->num_sge) {
81ae37
+		} else if (wr->send_flags & IBV_SEND_INLINE && valid_num_sge) {
81ae37
 			if (le32toh(rc_sq_wqe->msg_len) > qp->max_inline_data) {
81ae37
 				ret = EINVAL;
81ae37
 				*bad_wr = wr;
81ae37
@@ -801,7 +811,7 @@ int hns_roce_u_v2_post_send(struct ibv_qp *ibvqp, struct ibv_send_wr *wr,
81ae37
 				     RC_SQ_WQE_BYTE_4_INLINE_S, 1);
81ae37
 		} else {
81ae37
 			/* set sge */
81ae37
-			if (wr->num_sge <= 2) {
81ae37
+			if (valid_num_sge <= 2) {
81ae37
 				for (i = 0; i < wr->num_sge; i++)
81ae37
 					if (likely(wr->sg_list[i].length)) {
81ae37
 						set_data_seg_v2(dseg,
81ae37
@@ -814,7 +824,7 @@ int hns_roce_u_v2_post_send(struct ibv_qp *ibvqp, struct ibv_send_wr *wr,
81ae37
 					RC_SQ_WQE_BYTE_20_MSG_START_SGE_IDX_S,
81ae37
 					ind_sge & (qp->sge.sge_cnt - 1));
81ae37
 
81ae37
-				for (i = 0; i < 2; i++)
81ae37
+				for (i = 0; i < wr->num_sge && j < 2; i++)
81ae37
 					if (likely(wr->sg_list[i].length)) {
81ae37
 						set_data_seg_v2(dseg,
81ae37
 							       wr->sg_list + i);
81ae37
@@ -824,10 +834,10 @@ int hns_roce_u_v2_post_send(struct ibv_qp *ibvqp, struct ibv_send_wr *wr,
81ae37
 				dseg = get_send_sge_ex(qp, ind_sge &
81ae37
 						    (qp->sge.sge_cnt - 1));
81ae37
 
81ae37
-				for (i = 0; i < wr->num_sge - 2; i++) {
81ae37
-					if (likely(wr->sg_list[i + 2].length)) {
81ae37
+				for (; i < wr->num_sge; i++) {
81ae37
+					if (likely(wr->sg_list[i].length)) {
81ae37
 						set_data_seg_v2(dseg,
81ae37
-							   wr->sg_list + 2 + i);
81ae37
+							   wr->sg_list + i);
81ae37
 						dseg++;
81ae37
 						ind_sge++;
81ae37
 					}
81ae37
diff --git a/providers/mlx5/verbs.c b/providers/mlx5/verbs.c
81ae37
index bab675f6..890ed980 100644
81ae37
--- a/providers/mlx5/verbs.c
81ae37
+++ b/providers/mlx5/verbs.c
81ae37
@@ -1452,13 +1452,13 @@ static int mlx5_alloc_qp_buf(struct ibv_context *context,
81ae37
 			err = -1;
81ae37
 			goto ex_wrid;
81ae37
 		}
81ae37
-	}
81ae37
 
81ae37
-	qp->sq.wqe_head = malloc(qp->sq.wqe_cnt * sizeof(*qp->sq.wqe_head));
81ae37
-	if (!qp->sq.wqe_head) {
81ae37
-		errno = ENOMEM;
81ae37
-		err = -1;
81ae37
+		qp->sq.wqe_head = malloc(qp->sq.wqe_cnt * sizeof(*qp->sq.wqe_head));
81ae37
+		if (!qp->sq.wqe_head) {
81ae37
+			errno = ENOMEM;
81ae37
+			err = -1;
81ae37
 			goto ex_wrid;
81ae37
+		}
81ae37
 	}
81ae37
 
81ae37
 	if (qp->rq.wqe_cnt) {
81ae37
@@ -2432,7 +2432,7 @@ struct ibv_ah *mlx5_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr)
81ae37
 		ah->av.fl_mlid = attr->src_path_bits & 0x7f;
81ae37
 		ah->av.rlid = htobe16(attr->dlid);
81ae37
 		grh = 1;
81ae37
-		ah->av.stat_rate_sl = (static_rate << 4) | (attr->sl & 0x7);
81ae37
+		ah->av.stat_rate_sl = (static_rate << 4) | (attr->sl & 0xf);
81ae37
 	}
81ae37
 	if (attr->is_global) {
81ae37
 		ah->av.tclass = attr->grh.traffic_class;
81ae37
@@ -3494,13 +3494,14 @@ int mlx5_destroy_flow_action(struct ibv_flow_action *action)
81ae37
 	return ret;
81ae37
 }
81ae37
 
81ae37
-static inline int mlx5_memcpy_to_dm(struct ibv_dm *ibdm, uint64_t dm_offset,
81ae37
-				    const void *host_addr, size_t length)
81ae37
+static inline int mlx5_access_dm(struct ibv_dm *ibdm, uint64_t dm_offset,
81ae37
+				 void *host_addr, size_t length,
81ae37
+				 uint32_t read)
81ae37
 {
81ae37
 	struct mlx5_dm *dm = to_mdm(ibdm);
81ae37
 	atomic_uint32_t *dm_ptr =
81ae37
 		(atomic_uint32_t *)dm->start_va + dm_offset / 4;
81ae37
-	const uint32_t *host_ptr = host_addr;
81ae37
+	uint32_t *host_ptr = host_addr;
81ae37
 	const uint32_t *host_end = host_ptr + length / 4;
81ae37
 
81ae37
 	if (dm_offset + length > dm->length)
81ae37
@@ -3515,31 +3516,34 @@ static inline int mlx5_memcpy_to_dm(struct ibv_dm *ibdm, uint64_t dm_offset,
81ae37
 	/* Copy granularity should be 4 Bytes since we enforce copy size to be
81ae37
 	 * a multiple of 4 bytes.
81ae37
 	 */
81ae37
-	while (host_ptr != host_end) {
81ae37
-		atomic_store_explicit(dm_ptr, *host_ptr, memory_order_relaxed);
81ae37
-		host_ptr++;
81ae37
-		dm_ptr++;
81ae37
+	if (read) {
81ae37
+		while (host_ptr != host_end) {
81ae37
+			*host_ptr = atomic_load_explicit(dm_ptr,
81ae37
+							 memory_order_relaxed);
81ae37
+			host_ptr++;
81ae37
+			dm_ptr++;
81ae37
+		}
81ae37
+	} else {
81ae37
+		while (host_ptr != host_end) {
81ae37
+			atomic_store_explicit(dm_ptr, *host_ptr,
81ae37
+					      memory_order_relaxed);
81ae37
+			host_ptr++;
81ae37
+			dm_ptr++;
81ae37
+		}
81ae37
 	}
81ae37
 
81ae37
 	return 0;
81ae37
 }
81ae37
+static inline int mlx5_memcpy_to_dm(struct ibv_dm *ibdm, uint64_t dm_offset,
81ae37
+				    const void *host_addr, size_t length)
81ae37
+{
81ae37
+	return mlx5_access_dm(ibdm, dm_offset, (void *)host_addr, length, 0);
81ae37
+}
81ae37
 
81ae37
 static inline int mlx5_memcpy_from_dm(void *host_addr, struct ibv_dm *ibdm,
81ae37
 				      uint64_t dm_offset, size_t length)
81ae37
 {
81ae37
-	struct mlx5_dm *dm = to_mdm(ibdm);
81ae37
-	void *dm_va = dm->start_va + dm_offset;
81ae37
-
81ae37
-	if (dm_offset + length > dm->length)
81ae37
-		return EFAULT;
81ae37
-
81ae37
-	/* DM access address must be aligned to 4 bytes */
81ae37
-	if (dm_offset & 3)
81ae37
-		return EINVAL;
81ae37
-
81ae37
-	memcpy(host_addr, dm_va, length);
81ae37
-
81ae37
-	return 0;
81ae37
+	return mlx5_access_dm(ibdm, dm_offset, host_addr, length, 1);
81ae37
 }
81ae37
 
81ae37
 struct ibv_dm *mlx5_alloc_dm(struct ibv_context *context,