]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
IB/core: add debugging prints to explain -EINVAL in ib_uverbs_reg_mr
authorMajd Dibbiny <majd@mellanox.com>
Mon, 16 Jun 2014 07:18:41 +0000 (10:18 +0300)
committerMukesh Kacker <mukesh.kacker@oracle.com>
Tue, 7 Jul 2015 21:45:20 +0000 (14:45 -0700)
Understanding why -EINVAL is returned from uverbs is difficult
as there are multiple code paths that can cause the value to be
returned. This patch adds some explainations as pr_debug prints.

Signed-off-by: Haggai Eran <haggaie@mellanox.com>
Signed-off-by: Majd Dibbiny <majd@mellanox.com>
(Ported from Mellanox OFED 2.4)

Signed-off-by: Mukesh Kacker <mukesh.kacker@oracle.com>
drivers/infiniband/core/uverbs_cmd.c
include/rdma/ib_verbs.h

index 9d73aa5ec8fbe85769d61c13e47f6164ec225ff9..29947353379683346b6f35ecbae103f816a14263 100644 (file)
@@ -944,8 +944,10 @@ ssize_t ib_uverbs_reg_mr(struct ib_uverbs_file *file,
        struct ib_mr                *mr;
        int                          ret;
 
-       if (out_len < sizeof resp)
+       if (out_len < sizeof(resp)) {
+               pr_debug("ib_uverbs_reg_mr: command output length too short\n");
                return -ENOSPC;
+       }
 
        if (copy_from_user(&cmd, buf, sizeof cmd))
                return -EFAULT;
@@ -954,8 +956,10 @@ ssize_t ib_uverbs_reg_mr(struct ib_uverbs_file *file,
                   (unsigned long) cmd.response + sizeof resp,
                   in_len - sizeof cmd, out_len - sizeof resp);
 
-       if ((cmd.start & ~PAGE_MASK) != (cmd.hca_va & ~PAGE_MASK))
+       if ((cmd.start & ~PAGE_MASK) != (cmd.hca_va & ~PAGE_MASK)) {
+               pr_debug("ib_uverbs_reg_mr: HCA virtual address doesn't match host address\n");
                return -EINVAL;
+       }
 
        ret = ib_check_mr_access(cmd.access_flags);
        if (ret)
@@ -970,6 +974,7 @@ ssize_t ib_uverbs_reg_mr(struct ib_uverbs_file *file,
 
        pd = idr_read_pd(cmd.pd_handle, file->ucontext);
        if (!pd) {
+               pr_debug("ib_uverbs_reg_mr: invalid PD\n");
                ret = -EINVAL;
                goto err_free;
        }
index 65994a19e84055e7b4f4d8cde83a07eb41c1a69a..907f3cde870fcce59cde9fc942c1f2d154cb3a3e 100644 (file)
 #if !defined(IB_VERBS_H)
 #define IB_VERBS_H
 
+#ifdef pr_fmt
+#undef pr_fmt
+#endif
+#define pr_fmt(fmt) fmt
+
 #include <linux/types.h>
 #include <linux/device.h>
 #include <linux/mm.h>
@@ -2647,8 +2652,11 @@ static inline int ib_check_mr_access(int flags)
         * remote atomic permission is also requested.
         */
        if (flags & (IB_ACCESS_REMOTE_ATOMIC | IB_ACCESS_REMOTE_WRITE) &&
-           !(flags & IB_ACCESS_LOCAL_WRITE))
+           !(flags & IB_ACCESS_LOCAL_WRITE)) {
+               pr_debug("ib_check_mr_access: MR must have local write permission if remote write is allowed. flags=0x%x\n"
+                        , flags);
                return -EINVAL;
+       }
 
        return 0;
 }