diff mbox

[v3,4/4] RDMA, core and ULPs: Declare ib_post_send() and ib_post_recv() arguments const

Message ID 20180710182742.24702-5-bart.vanassche@wdc.com (mailing list archive)
State Changes Requested
Headers show

Commit Message

Bart Van Assche July 10, 2018, 6:27 p.m. UTC
Since neither ib_post_send() nor ib_post_recv() modify the data structure
their second argument points at, declare that argument const. This change
makes it necessary to declare the 'bad_wr' argument const too and also
to modify all ULPs that call ib_post_send(), ib_post_recv() or
ib_post_srq_recv(). This patch does not change any functionality.

To make this possible, only one cast had to be introduce that casts away
constness, namely in rpcrdma_post_recvs(). The only way I can think of
to avoid that cast is to change the data type of bad_wr from
struct ib_recv_wr ** into int (an index in the work request list). However,
that would require even more extensive changes than this patch.

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Cc: Ariel Elior <Ariel.Elior@cavium.com>
Cc: Dennis Dalessandro <dennis.dalessandro@intel.com>
Cc: Devesh Sharma <devesh.sharma@broadcom.com>
Cc: Faisal Latif <faisal.latif@intel.com>
Cc: Leon Romanovsky <leonro@mellanox.com>
Cc: Lijun Ou <oulijun@huawei.com>
Cc: Michal Kalderon <Michal.Kalderon@cavium.com>
Cc: Mike Marciniszyn <mike.marciniszyn@intel.com>
Cc: Moni Shoua <monis@mellanox.com>
Cc: Parav Pandit <parav@mellanox.com>
Cc: Selvin Xavier <selvin.xavier@broadcom.com>
Cc: Somnath Kotur <somnath.kotur@broadcom.com>
Cc: Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
Cc: Steve Wise <swise@chelsio.com>
Cc: Wei Hu(Xavier) <xavier.huwei@huawei.com>
Cc: Yishai Hadas <yishaih@mellanox.com>
Cc: Steve French <sfrench@samba.org>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Sagi Grimberg <sagi@grimberg.me>
Cc: Eric Van Hensbergen <ericvh@gmail.com>
Cc: Ron Minnich <rminnich@sandia.gov>
Cc: Latchesar Ionkov <lucho@ionkov.net>
Cc: Chuck Lever <chuck.lever@oracle.com>
Cc: J. Bruce Fields <bfields@redhat.com>
---
 drivers/infiniband/core/mad.c                 |  9 ++++---
 drivers/infiniband/core/rw.c                  |  3 ++-
 drivers/infiniband/core/uverbs_cmd.c          |  9 ++++---
 drivers/infiniband/core/verbs.c               |  5 ++--
 drivers/infiniband/hw/bnxt_re/ib_verbs.c      | 16 ++++++------
 drivers/infiniband/hw/bnxt_re/ib_verbs.h      | 12 ++++-----
 drivers/infiniband/hw/cxgb3/iwch_provider.h   |  8 +++---
 drivers/infiniband/hw/cxgb3/iwch_qp.c         | 12 ++++-----
 drivers/infiniband/hw/cxgb4/iw_cxgb4.h        |  8 +++---
 drivers/infiniband/hw/cxgb4/qp.c              | 21 ++++++++-------
 drivers/infiniband/hw/hns/hns_roce_device.h   |  8 +++---
 drivers/infiniband/hw/hns/hns_roce_hw_v1.c    | 13 ++++++----
 drivers/infiniband/hw/hns/hns_roce_hw_v2.c    | 12 +++++----
 drivers/infiniband/hw/i40iw/i40iw_verbs.c     |  9 +++----
 drivers/infiniband/hw/mlx4/mad.c              |  7 ++---
 drivers/infiniband/hw/mlx4/mlx4_ib.h          | 12 ++++-----
 drivers/infiniband/hw/mlx4/qp.c               | 21 ++++++++-------
 drivers/infiniband/hw/mlx4/srq.c              |  4 +--
 drivers/infiniband/hw/mlx5/gsi.c              |  8 +++---
 drivers/infiniband/hw/mlx5/mlx5_ib.h          | 20 +++++++-------
 drivers/infiniband/hw/mlx5/mr.c               |  2 +-
 drivers/infiniband/hw/mlx5/qp.c               | 21 ++++++++-------
 drivers/infiniband/hw/mlx5/srq.c              |  4 +--
 drivers/infiniband/hw/mthca/mthca_dev.h       | 24 ++++++++---------
 drivers/infiniband/hw/mthca/mthca_qp.c        | 16 ++++++------
 drivers/infiniband/hw/mthca/mthca_srq.c       |  8 +++---
 drivers/infiniband/hw/nes/nes_verbs.c         |  8 +++---
 drivers/infiniband/hw/ocrdma/ocrdma_verbs.c   | 16 ++++++------
 drivers/infiniband/hw/ocrdma/ocrdma_verbs.h   | 12 ++++-----
 drivers/infiniband/hw/qedr/qedr_roce_cm.c     |  8 +++---
 drivers/infiniband/hw/qedr/qedr_roce_cm.h     |  8 +++---
 drivers/infiniband/hw/qedr/verbs.c            | 26 +++++++++----------
 drivers/infiniband/hw/qedr/verbs.h            |  8 +++---
 drivers/infiniband/hw/usnic/usnic_ib_verbs.c  |  8 +++---
 drivers/infiniband/hw/usnic/usnic_ib_verbs.h  |  8 +++---
 drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c  |  8 +++---
 drivers/infiniband/hw/vmw_pvrdma/pvrdma_srq.c |  4 +--
 .../infiniband/hw/vmw_pvrdma/pvrdma_verbs.h   | 12 ++++-----
 drivers/infiniband/sw/rdmavt/qp.c             | 12 ++++-----
 drivers/infiniband/sw/rdmavt/qp.h             | 12 ++++-----
 drivers/infiniband/sw/rxe/rxe_verbs.c         | 18 ++++++-------
 drivers/infiniband/ulp/ipoib/ipoib_cm.c       | 11 ++++----
 drivers/infiniband/ulp/ipoib/ipoib_ib.c       |  4 +--
 drivers/infiniband/ulp/iser/iser_verbs.c      |  9 ++++---
 drivers/infiniband/ulp/isert/ib_isert.c       | 14 ++++++----
 drivers/infiniband/ulp/srp/ib_srp.c           | 10 ++++---
 drivers/infiniband/ulp/srpt/ib_srpt.c         | 11 +++++---
 drivers/nvme/host/rdma.c                      |  8 +++---
 drivers/nvme/target/rdma.c                    |  5 ++--
 fs/cifs/smbdirect.c                           | 14 ++++++----
 include/rdma/ib_verbs.h                       | 24 ++++++++---------
 net/9p/trans_rdma.c                           |  6 +++--
 net/rds/ib_frmr.c                             |  5 ++--
 net/rds/ib_recv.c                             |  4 +--
 net/rds/ib_send.c                             |  6 ++---
 net/smc/smc_tx.c                              |  2 +-
 net/smc/smc_wr.c                              |  4 +--
 net/smc/smc_wr.h                              |  2 +-
 net/sunrpc/xprtrdma/fmr_ops.c                 |  2 +-
 net/sunrpc/xprtrdma/frwr_ops.c                |  6 +++--
 net/sunrpc/xprtrdma/svc_rdma_recvfrom.c       |  2 +-
 net/sunrpc/xprtrdma/svc_rdma_rw.c             |  3 ++-
 net/sunrpc/xprtrdma/svc_rdma_sendto.c         |  2 +-
 net/sunrpc/xprtrdma/verbs.c                   |  6 +++--
 64 files changed, 331 insertions(+), 289 deletions(-)

Comments

Sagi Grimberg July 11, 2018, 10:08 a.m. UTC | #1
Looks good to me,

Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Max Gurtovoy July 12, 2018, 9:12 a.m. UTC | #2
On 7/10/2018 9:27 PM, Bart Van Assche wrote:
> Since neither ib_post_send() nor ib_post_recv() modify the data structure
> their second argument points at, declare that argument const. This change
> makes it necessary to declare the 'bad_wr' argument const too and also
> to modify all ULPs that call ib_post_send(), ib_post_recv() or
> ib_post_srq_recv(). This patch does not change any functionality.
> 
> To make this possible, only one cast had to be introduce that casts away
> constness, namely in rpcrdma_post_recvs(). The only way I can think of
> to avoid that cast is to change the data type of bad_wr from
> struct ib_recv_wr ** into int (an index in the work request list). However,
> that would require even more extensive changes than this patch.
> 
> Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
> Cc: Ariel Elior <Ariel.Elior@cavium.com>
> Cc: Dennis Dalessandro <dennis.dalessandro@intel.com>
> Cc: Devesh Sharma <devesh.sharma@broadcom.com>
> Cc: Faisal Latif <faisal.latif@intel.com>
> Cc: Leon Romanovsky <leonro@mellanox.com>
> Cc: Lijun Ou <oulijun@huawei.com>
> Cc: Michal Kalderon <Michal.Kalderon@cavium.com>
> Cc: Mike Marciniszyn <mike.marciniszyn@intel.com>
> Cc: Moni Shoua <monis@mellanox.com>
> Cc: Parav Pandit <parav@mellanox.com>
> Cc: Selvin Xavier <selvin.xavier@broadcom.com>
> Cc: Somnath Kotur <somnath.kotur@broadcom.com>
> Cc: Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
> Cc: Steve Wise <swise@chelsio.com>
> Cc: Wei Hu(Xavier) <xavier.huwei@huawei.com>
> Cc: Yishai Hadas <yishaih@mellanox.com>
> Cc: Steve French <sfrench@samba.org>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Sagi Grimberg <sagi@grimberg.me>
> Cc: Eric Van Hensbergen <ericvh@gmail.com>
> Cc: Ron Minnich <rminnich@sandia.gov>
> Cc: Latchesar Ionkov <lucho@ionkov.net>
> Cc: Chuck Lever <chuck.lever@oracle.com>
> Cc: J. Bruce Fields <bfields@redhat.com>
> ---
>   drivers/infiniband/core/mad.c                 |  9 ++++---
>   drivers/infiniband/core/rw.c                  |  3 ++-
>   drivers/infiniband/core/uverbs_cmd.c          |  9 ++++---
>   drivers/infiniband/core/verbs.c               |  5 ++--
>   drivers/infiniband/hw/bnxt_re/ib_verbs.c      | 16 ++++++------
>   drivers/infiniband/hw/bnxt_re/ib_verbs.h      | 12 ++++-----
>   drivers/infiniband/hw/cxgb3/iwch_provider.h   |  8 +++---
>   drivers/infiniband/hw/cxgb3/iwch_qp.c         | 12 ++++-----
>   drivers/infiniband/hw/cxgb4/iw_cxgb4.h        |  8 +++---
>   drivers/infiniband/hw/cxgb4/qp.c              | 21 ++++++++-------
>   drivers/infiniband/hw/hns/hns_roce_device.h   |  8 +++---
>   drivers/infiniband/hw/hns/hns_roce_hw_v1.c    | 13 ++++++----
>   drivers/infiniband/hw/hns/hns_roce_hw_v2.c    | 12 +++++----
>   drivers/infiniband/hw/i40iw/i40iw_verbs.c     |  9 +++----
>   drivers/infiniband/hw/mlx4/mad.c              |  7 ++---
>   drivers/infiniband/hw/mlx4/mlx4_ib.h          | 12 ++++-----
>   drivers/infiniband/hw/mlx4/qp.c               | 21 ++++++++-------
>   drivers/infiniband/hw/mlx4/srq.c              |  4 +--
>   drivers/infiniband/hw/mlx5/gsi.c              |  8 +++---
>   drivers/infiniband/hw/mlx5/mlx5_ib.h          | 20 +++++++-------
>   drivers/infiniband/hw/mlx5/mr.c               |  2 +-
>   drivers/infiniband/hw/mlx5/qp.c               | 21 ++++++++-------
>   drivers/infiniband/hw/mlx5/srq.c              |  4 +--
>   drivers/infiniband/hw/mthca/mthca_dev.h       | 24 ++++++++---------
>   drivers/infiniband/hw/mthca/mthca_qp.c        | 16 ++++++------
>   drivers/infiniband/hw/mthca/mthca_srq.c       |  8 +++---
>   drivers/infiniband/hw/nes/nes_verbs.c         |  8 +++---
>   drivers/infiniband/hw/ocrdma/ocrdma_verbs.c   | 16 ++++++------
>   drivers/infiniband/hw/ocrdma/ocrdma_verbs.h   | 12 ++++-----
>   drivers/infiniband/hw/qedr/qedr_roce_cm.c     |  8 +++---
>   drivers/infiniband/hw/qedr/qedr_roce_cm.h     |  8 +++---
>   drivers/infiniband/hw/qedr/verbs.c            | 26 +++++++++----------
>   drivers/infiniband/hw/qedr/verbs.h            |  8 +++---
>   drivers/infiniband/hw/usnic/usnic_ib_verbs.c  |  8 +++---
>   drivers/infiniband/hw/usnic/usnic_ib_verbs.h  |  8 +++---
>   drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c  |  8 +++---
>   drivers/infiniband/hw/vmw_pvrdma/pvrdma_srq.c |  4 +--
>   .../infiniband/hw/vmw_pvrdma/pvrdma_verbs.h   | 12 ++++-----
>   drivers/infiniband/sw/rdmavt/qp.c             | 12 ++++-----
>   drivers/infiniband/sw/rdmavt/qp.h             | 12 ++++-----
>   drivers/infiniband/sw/rxe/rxe_verbs.c         | 18 ++++++-------
>   drivers/infiniband/ulp/ipoib/ipoib_cm.c       | 11 ++++----
>   drivers/infiniband/ulp/ipoib/ipoib_ib.c       |  4 +--
>   drivers/infiniband/ulp/iser/iser_verbs.c      |  9 ++++---
>   drivers/infiniband/ulp/isert/ib_isert.c       | 14 ++++++----
>   drivers/infiniband/ulp/srp/ib_srp.c           | 10 ++++---
>   drivers/infiniband/ulp/srpt/ib_srpt.c         | 11 +++++---
>   drivers/nvme/host/rdma.c                      |  8 +++---
>   drivers/nvme/target/rdma.c                    |  5 ++--
>   fs/cifs/smbdirect.c                           | 14 ++++++----
>   include/rdma/ib_verbs.h                       | 24 ++++++++---------
>   net/9p/trans_rdma.c                           |  6 +++--
>   net/rds/ib_frmr.c                             |  5 ++--
>   net/rds/ib_recv.c                             |  4 +--
>   net/rds/ib_send.c                             |  6 ++---
>   net/smc/smc_tx.c                              |  2 +-
>   net/smc/smc_wr.c                              |  4 +--
>   net/smc/smc_wr.h                              |  2 +-
>   net/sunrpc/xprtrdma/fmr_ops.c                 |  2 +-
>   net/sunrpc/xprtrdma/frwr_ops.c                |  6 +++--
>   net/sunrpc/xprtrdma/svc_rdma_recvfrom.c       |  2 +-
>   net/sunrpc/xprtrdma/svc_rdma_rw.c             |  3 ++-
>   net/sunrpc/xprtrdma/svc_rdma_sendto.c         |  2 +-
>   net/sunrpc/xprtrdma/verbs.c                   |  6 +++--
>   64 files changed, 331 insertions(+), 289 deletions(-)
> 
> diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c
> index 34e9b2768324..4d3571a0508b 100644
> --- a/drivers/infiniband/core/mad.c
> +++ b/drivers/infiniband/core/mad.c
> @@ -1181,7 +1181,7 @@ int ib_send_mad(struct ib_mad_send_wr_private *mad_send_wr)
>   {
>   	struct ib_mad_qp_info *qp_info;
>   	struct list_head *list;
> -	struct ib_send_wr *bad_send_wr;
> +	const struct ib_send_wr *bad_send_wr;
>   	struct ib_mad_agent *mad_agent;
>   	struct ib_sge *sge;
>   	unsigned long flags;
> @@ -2476,7 +2476,7 @@ static void ib_mad_send_done(struct ib_cq *cq, struct ib_wc *wc)
>   	struct ib_mad_send_wr_private	*mad_send_wr, *queued_send_wr;
>   	struct ib_mad_qp_info		*qp_info;
>   	struct ib_mad_queue		*send_queue;
> -	struct ib_send_wr		*bad_send_wr;
> +	const struct ib_send_wr		*bad_send_wr;
>   	struct ib_mad_send_wc		mad_send_wc;
>   	unsigned long flags;
>   	int ret;
> @@ -2571,7 +2571,7 @@ static bool ib_mad_send_error(struct ib_mad_port_private *port_priv,
>   	if (wc->status == IB_WC_WR_FLUSH_ERR) {
>   		if (mad_send_wr->retry) {
>   			/* Repost send */
> -			struct ib_send_wr *bad_send_wr;
> +			const struct ib_send_wr *bad_send_wr;
>   
>   			mad_send_wr->retry = 0;
>   			ret = ib_post_send(qp_info->qp, &mad_send_wr->send_wr.wr,
> @@ -2891,7 +2891,8 @@ static int ib_mad_post_receive_mads(struct ib_mad_qp_info *qp_info,
>   	int post, ret;
>   	struct ib_mad_private *mad_priv;
>   	struct ib_sge sg_list;
> -	struct ib_recv_wr recv_wr, *bad_recv_wr;
> +	struct ib_recv_wr recv_wr;
> +	const struct ib_recv_wr *bad_recv_wr;
>   	struct ib_mad_queue *recv_queue = &qp_info->recv_queue;
>   
>   	/* Initialize common scatter list fields */
> diff --git a/drivers/infiniband/core/rw.c b/drivers/infiniband/core/rw.c
> index 474d65297afc..50adbabde9fa 100644
> --- a/drivers/infiniband/core/rw.c
> +++ b/drivers/infiniband/core/rw.c
> @@ -564,7 +564,8 @@ EXPORT_SYMBOL(rdma_rw_ctx_wrs);
>   int rdma_rw_ctx_post(struct rdma_rw_ctx *ctx, struct ib_qp *qp, u8 port_num,
>   		struct ib_cqe *cqe, struct ib_send_wr *chain_wr)
>   {
> -	struct ib_send_wr *first_wr, *bad_wr;
> +	struct ib_send_wr *first_wr;
> +	const struct ib_send_wr *bad_wr;
>   
>   	first_wr = rdma_rw_ctx_wrs(ctx, qp, port_num, cqe, chain_wr);
>   	return ib_post_send(qp, first_wr, &bad_wr);
> diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
> index d048cabc4246..deaedd60bf24 100644
> --- a/drivers/infiniband/core/uverbs_cmd.c
> +++ b/drivers/infiniband/core/uverbs_cmd.c
> @@ -2137,7 +2137,8 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file,
>   	struct ib_uverbs_post_send      cmd;
>   	struct ib_uverbs_post_send_resp resp;
>   	struct ib_uverbs_send_wr       *user_wr;
> -	struct ib_send_wr              *wr = NULL, *last, *next, *bad_wr;
> +	struct ib_send_wr              *wr = NULL, *last, *next;
> +	const struct ib_send_wr	       *bad_wr;
>   	struct ib_qp                   *qp;
>   	int                             i, sg_ind;
>   	int				is_ud;
> @@ -2416,7 +2417,8 @@ ssize_t ib_uverbs_post_recv(struct ib_uverbs_file *file,
>   {
>   	struct ib_uverbs_post_recv      cmd;
>   	struct ib_uverbs_post_recv_resp resp;
> -	struct ib_recv_wr              *wr, *next, *bad_wr;
> +	struct ib_recv_wr              *wr, *next;
> +	const struct ib_recv_wr	       *bad_wr;
>   	struct ib_qp                   *qp;
>   	ssize_t                         ret = -EINVAL;
>   
> @@ -2465,7 +2467,8 @@ ssize_t ib_uverbs_post_srq_recv(struct ib_uverbs_file *file,
>   {
>   	struct ib_uverbs_post_srq_recv      cmd;
>   	struct ib_uverbs_post_srq_recv_resp resp;
> -	struct ib_recv_wr                  *wr, *next, *bad_wr;
> +	struct ib_recv_wr                  *wr, *next;
> +	const struct ib_recv_wr		   *bad_wr;
>   	struct ib_srq                      *srq;
>   	ssize_t                             ret = -EINVAL;
>   
> diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
> index 1bb6b6ff3341..226053a0f881 100644
> --- a/drivers/infiniband/core/verbs.c
> +++ b/drivers/infiniband/core/verbs.c
> @@ -2472,7 +2472,7 @@ static void __ib_drain_sq(struct ib_qp *qp)
>   	struct ib_cq *cq = qp->send_cq;
>   	struct ib_qp_attr attr = { .qp_state = IB_QPS_ERR };
>   	struct ib_drain_cqe sdrain;
> -	struct ib_send_wr *bad_swr;
> +	const struct ib_send_wr *bad_swr;
>   	struct ib_rdma_wr swr = {
>   		.wr = {
>   			.next = NULL,
> @@ -2512,7 +2512,8 @@ static void __ib_drain_rq(struct ib_qp *qp)
>   	struct ib_cq *cq = qp->recv_cq;
>   	struct ib_qp_attr attr = { .qp_state = IB_QPS_ERR };
>   	struct ib_drain_cqe rdrain;
> -	struct ib_recv_wr rwr = {}, *bad_rwr;
> +	struct ib_recv_wr rwr = {};
> +	const struct ib_recv_wr *bad_rwr;
>   	int ret;
>   
>   	ret = ib_modify_qp(qp, &attr, IB_QP_STATE);
> diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
> index 0711510ca7b0..7dcb4ffbde23 100644
> --- a/drivers/infiniband/hw/bnxt_re/ib_verbs.c
> +++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
> @@ -1519,8 +1519,8 @@ int bnxt_re_query_srq(struct ib_srq *ib_srq, struct ib_srq_attr *srq_attr)
>   	return 0;
>   }
>   
> -int bnxt_re_post_srq_recv(struct ib_srq *ib_srq, struct ib_recv_wr *wr,
> -			  struct ib_recv_wr **bad_wr)
> +int bnxt_re_post_srq_recv(struct ib_srq *ib_srq, const struct ib_recv_wr *wr,
> +			  const struct ib_recv_wr **bad_wr)

should **bad_wr be const here ?

>   {
>   	struct bnxt_re_srq *srq = container_of(ib_srq, struct bnxt_re_srq,
>   					       ib_srq);
> @@ -2048,7 +2048,7 @@ static int bnxt_re_build_qp1_send_v2(struct bnxt_re_qp *qp,
>    * and the MAD datagram out to the provided SGE.
>    */
>   static int bnxt_re_build_qp1_shadow_qp_recv(struct bnxt_re_qp *qp,
> -					    struct ib_recv_wr *wr,
> +					    const struct ib_recv_wr *wr,
>   					    struct bnxt_qplib_swqe *wqe,
>   					    int payload_size)
>   {
> @@ -2361,8 +2361,8 @@ static int bnxt_re_post_send_shadow_qp(struct bnxt_re_dev *rdev,
>   	return rc;
>   }
>   
> -int bnxt_re_post_send(struct ib_qp *ib_qp, struct ib_send_wr *wr,
> -		      struct ib_send_wr **bad_wr)
> +int bnxt_re_post_send(struct ib_qp *ib_qp, const struct ib_send_wr *wr,
> +		      const struct ib_send_wr **bad_wr)

and here ?

>   {
>   	struct bnxt_re_qp *qp = container_of(ib_qp, struct bnxt_re_qp, ib_qp);
>   	struct bnxt_qplib_swqe wqe;
> @@ -2461,7 +2461,7 @@ int bnxt_re_post_send(struct ib_qp *ib_qp, struct ib_send_wr *wr,
>   
>   static int bnxt_re_post_recv_shadow_qp(struct bnxt_re_dev *rdev,
>   				       struct bnxt_re_qp *qp,
> -				       struct ib_recv_wr *wr)
> +				       const struct ib_recv_wr *wr)
>   {
>   	struct bnxt_qplib_swqe wqe;
>   	int rc = 0;
> @@ -2494,8 +2494,8 @@ static int bnxt_re_post_recv_shadow_qp(struct bnxt_re_dev *rdev,
>   	return rc;
>   }
>   
> -int bnxt_re_post_recv(struct ib_qp *ib_qp, struct ib_recv_wr *wr,
> -		      struct ib_recv_wr **bad_wr)
> +int bnxt_re_post_recv(struct ib_qp *ib_qp, const struct ib_recv_wr *wr,
> +		      const struct ib_recv_wr **bad_wr)

and here ?

>   {
>   	struct bnxt_re_qp *qp = container_of(ib_qp, struct bnxt_re_qp, ib_qp);
>   	struct bnxt_qplib_swqe wqe;
> diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.h b/drivers/infiniband/hw/bnxt_re/ib_verbs.h
> index bd04d40d897a..aa33e7b82c84 100644
> --- a/drivers/infiniband/hw/bnxt_re/ib_verbs.h
> +++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.h
> @@ -181,8 +181,8 @@ int bnxt_re_modify_srq(struct ib_srq *srq, struct ib_srq_attr *srq_attr,
>   		       struct ib_udata *udata);
>   int bnxt_re_query_srq(struct ib_srq *srq, struct ib_srq_attr *srq_attr);
>   int bnxt_re_destroy_srq(struct ib_srq *srq);
> -int bnxt_re_post_srq_recv(struct ib_srq *srq, struct ib_recv_wr *recv_wr,
> -			  struct ib_recv_wr **bad_recv_wr);
> +int bnxt_re_post_srq_recv(struct ib_srq *srq, const struct ib_recv_wr *recv_wr,
> +			  const struct ib_recv_wr **bad_recv_wr);

?


>   struct ib_qp *bnxt_re_create_qp(struct ib_pd *pd,
>   				struct ib_qp_init_attr *qp_init_attr,
>   				struct ib_udata *udata);
> @@ -191,10 +191,10 @@ int bnxt_re_modify_qp(struct ib_qp *qp, struct ib_qp_attr *qp_attr,
>   int bnxt_re_query_qp(struct ib_qp *qp, struct ib_qp_attr *qp_attr,
>   		     int qp_attr_mask, struct ib_qp_init_attr *qp_init_attr);
>   int bnxt_re_destroy_qp(struct ib_qp *qp);
> -int bnxt_re_post_send(struct ib_qp *qp, struct ib_send_wr *send_wr,
> -		      struct ib_send_wr **bad_send_wr);
> -int bnxt_re_post_recv(struct ib_qp *qp, struct ib_recv_wr *recv_wr,
> -		      struct ib_recv_wr **bad_recv_wr);
> +int bnxt_re_post_send(struct ib_qp *qp, const struct ib_send_wr *send_wr,
> +		      const struct ib_send_wr **bad_send_wr);
> +int bnxt_re_post_recv(struct ib_qp *qp, const struct ib_recv_wr *recv_wr,
> +		      const struct ib_recv_wr **bad_recv_wr);
>   struct ib_cq *bnxt_re_create_cq(struct ib_device *ibdev,
>   				const struct ib_cq_init_attr *attr,
>   				struct ib_ucontext *context,
> diff --git a/drivers/infiniband/hw/cxgb3/iwch_provider.h b/drivers/infiniband/hw/cxgb3/iwch_provider.h
> index 2e38ddefea8a..8adbe9658935 100644
> --- a/drivers/infiniband/hw/cxgb3/iwch_provider.h
> +++ b/drivers/infiniband/hw/cxgb3/iwch_provider.h
> @@ -326,10 +326,10 @@ enum iwch_qp_query_flags {
>   };
>   
>   u16 iwch_rqes_posted(struct iwch_qp *qhp);
> -int iwch_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
> -		      struct ib_send_wr **bad_wr);
> -int iwch_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr,
> -		      struct ib_recv_wr **bad_wr);
> +int iwch_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
> +		   const struct ib_send_wr **bad_wr);
> +int iwch_post_receive(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
> +		      const struct ib_recv_wr **bad_wr);
>   int iwch_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc);
>   int iwch_post_terminate(struct iwch_qp *qhp, struct respQ_msg_t *rsp_msg);
>   int iwch_post_zb_read(struct iwch_ep *ep);
> diff --git a/drivers/infiniband/hw/cxgb3/iwch_qp.c b/drivers/infiniband/hw/cxgb3/iwch_qp.c
> index 29ab6910a004..c649faad63f9 100644
> --- a/drivers/infiniband/hw/cxgb3/iwch_qp.c
> +++ b/drivers/infiniband/hw/cxgb3/iwch_qp.c
> @@ -246,7 +246,7 @@ static int iwch_sgl2pbl_map(struct iwch_dev *rhp, struct ib_sge *sg_list,
>   }
>   
>   static int build_rdma_recv(struct iwch_qp *qhp, union t3_wr *wqe,
> -				struct ib_recv_wr *wr)
> +			   const struct ib_recv_wr *wr)
>   {
>   	int i, err = 0;
>   	u32 pbl_addr[T3_MAX_SGE];
> @@ -286,7 +286,7 @@ static int build_rdma_recv(struct iwch_qp *qhp, union t3_wr *wqe,
>   }
>   
>   static int build_zero_stag_recv(struct iwch_qp *qhp, union t3_wr *wqe,
> -				struct ib_recv_wr *wr)
> +				const struct ib_recv_wr *wr)
>   {
>   	int i;
>   	u32 pbl_addr;
> @@ -348,8 +348,8 @@ static int build_zero_stag_recv(struct iwch_qp *qhp, union t3_wr *wqe,
>   	return 0;
>   }
>   
> -int iwch_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
> -		      struct ib_send_wr **bad_wr)
> +int iwch_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
> +		   const struct ib_send_wr **bad_wr)
>   {
>   	int err = 0;
>   	u8 uninitialized_var(t3_wr_flit_cnt);
> @@ -463,8 +463,8 @@ int iwch_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
>   	return err;
>   }
>   
> -int iwch_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr,
> -		      struct ib_recv_wr **bad_wr)
> +int iwch_post_receive(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
> +		      const struct ib_recv_wr **bad_wr)
>   {
>   	int err = 0;
>   	struct iwch_qp *qhp;
> diff --git a/drivers/infiniband/hw/cxgb4/iw_cxgb4.h b/drivers/infiniband/hw/cxgb4/iw_cxgb4.h
> index 870649ff049c..0eb808549bb3 100644
> --- a/drivers/infiniband/hw/cxgb4/iw_cxgb4.h
> +++ b/drivers/infiniband/hw/cxgb4/iw_cxgb4.h
> @@ -1007,10 +1007,10 @@ void c4iw_release_dev_ucontext(struct c4iw_rdev *rdev,
>   void c4iw_init_dev_ucontext(struct c4iw_rdev *rdev,
>   			    struct c4iw_dev_ucontext *uctx);
>   int c4iw_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc);
> -int c4iw_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
> -		      struct ib_send_wr **bad_wr);
> -int c4iw_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr,
> -		      struct ib_recv_wr **bad_wr);
> +int c4iw_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
> +		   const struct ib_send_wr **bad_wr);
> +int c4iw_post_receive(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
> +		      const struct ib_recv_wr **bad_wr);
>   int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param);
>   int c4iw_create_listen(struct iw_cm_id *cm_id, int backlog);
>   int c4iw_destroy_listen(struct iw_cm_id *cm_id);
> diff --git a/drivers/infiniband/hw/cxgb4/qp.c b/drivers/infiniband/hw/cxgb4/qp.c
> index a2eedb19907d..2da17ec22ef8 100644
> --- a/drivers/infiniband/hw/cxgb4/qp.c
> +++ b/drivers/infiniband/hw/cxgb4/qp.c
> @@ -592,7 +592,7 @@ static int build_rdma_read(union t4_wr *wqe, const struct ib_send_wr *wr,
>   }
>   
>   static int build_rdma_recv(struct c4iw_qp *qhp, union t4_recv_wr *wqe,
> -			   struct ib_recv_wr *wr, u8 *len16)
> +			   const struct ib_recv_wr *wr, u8 *len16)
>   {
>   	int ret;
>   
> @@ -861,8 +861,9 @@ static int complete_sq_drain_wr(struct c4iw_qp *qhp,
>   	return 0;
>   }
>   
> -static int complete_sq_drain_wrs(struct c4iw_qp *qhp, struct ib_send_wr *wr,
> -				struct ib_send_wr **bad_wr)
> +static int complete_sq_drain_wrs(struct c4iw_qp *qhp,
> +				 const struct ib_send_wr *wr,
> +				 const struct ib_send_wr **bad_wr)
>   {
>   	int ret = 0;
>   
> @@ -877,7 +878,8 @@ static int complete_sq_drain_wrs(struct c4iw_qp *qhp, struct ib_send_wr *wr,
>   	return ret;
>   }
>   
> -static void complete_rq_drain_wr(struct c4iw_qp *qhp, struct ib_recv_wr *wr)
> +static void complete_rq_drain_wr(struct c4iw_qp *qhp,
> +				 const struct ib_recv_wr *wr)
>   {
>   	struct t4_cqe cqe = {};
>   	struct c4iw_cq *rchp;
> @@ -909,7 +911,8 @@ static void complete_rq_drain_wr(struct c4iw_qp *qhp, struct ib_recv_wr *wr)
>   	}
>   }
>   
> -static void complete_rq_drain_wrs(struct c4iw_qp *qhp, struct ib_recv_wr *wr)
> +static void complete_rq_drain_wrs(struct c4iw_qp *qhp,
> +				  const struct ib_recv_wr *wr)
>   {
>   	while (wr) {
>   		complete_rq_drain_wr(qhp, wr);
> @@ -917,8 +920,8 @@ static void complete_rq_drain_wrs(struct c4iw_qp *qhp, struct ib_recv_wr *wr)
>   	}
>   }
>   
> -int c4iw_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
> -		   struct ib_send_wr **bad_wr)
> +int c4iw_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
> +		   const struct ib_send_wr **bad_wr)
>   {
>   	int err = 0;
>   	u8 len16 = 0;
> @@ -1068,8 +1071,8 @@ int c4iw_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
>   	return err;
>   }
>   
> -int c4iw_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr,
> -		      struct ib_recv_wr **bad_wr)
> +int c4iw_post_receive(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
> +		      const struct ib_recv_wr **bad_wr)
>   {
>   	int err = 0;
>   	struct c4iw_qp *qhp;
> diff --git a/drivers/infiniband/hw/hns/hns_roce_device.h b/drivers/infiniband/hw/hns/hns_roce_device.h
> index c97d71f1730e..7e9b68383a60 100644
> --- a/drivers/infiniband/hw/hns/hns_roce_device.h
> +++ b/drivers/infiniband/hw/hns/hns_roce_device.h
> @@ -760,10 +760,10 @@ struct hns_roce_hw {
>   			 int attr_mask, enum ib_qp_state cur_state,
>   			 enum ib_qp_state new_state);
>   	int (*destroy_qp)(struct ib_qp *ibqp);
> -	int (*post_send)(struct ib_qp *ibqp, struct ib_send_wr *wr,
> -			 struct ib_send_wr **bad_wr);
> -	int (*post_recv)(struct ib_qp *qp, struct ib_recv_wr *recv_wr,
> -			 struct ib_recv_wr **bad_recv_wr);
> +	int (*post_send)(struct ib_qp *ibqp, const struct ib_send_wr *wr,
> +			 const struct ib_send_wr **bad_wr);
> +	int (*post_recv)(struct ib_qp *qp, const struct ib_recv_wr *recv_wr,
> +			 const struct ib_recv_wr **bad_recv_wr);
>   	int (*req_notify_cq)(struct ib_cq *ibcq, enum ib_cq_notify_flags flags);
>   	int (*poll_cq)(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc);
>   	int (*dereg_mr)(struct hns_roce_dev *hr_dev, struct hns_roce_mr *mr);
> diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
> index 235c67dfc6cb..6db8fdd44989 100644
> --- a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
> +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
> @@ -58,8 +58,9 @@ static void set_raddr_seg(struct hns_roce_wqe_raddr_seg *rseg, u64 remote_addr,
>   	rseg->len   = 0;
>   }
>   
> -static int hns_roce_v1_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
> -				 struct ib_send_wr **bad_wr)
> +static int hns_roce_v1_post_send(struct ib_qp *ibqp,
> +				 const struct ib_send_wr *wr,
> +				 const struct ib_send_wr **bad_wr)
>   {
>   	struct hns_roce_dev *hr_dev = to_hr_dev(ibqp->device);
>   	struct hns_roce_ah *ah = to_hr_ah(ud_wr(wr)->ah);
> @@ -342,8 +343,9 @@ static int hns_roce_v1_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
>   	return ret;
>   }
>   
> -static int hns_roce_v1_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
> -				 struct ib_recv_wr **bad_wr)
> +static int hns_roce_v1_post_recv(struct ib_qp *ibqp,
> +				 const struct ib_recv_wr *wr,
> +				 const struct ib_recv_wr **bad_wr)
>   {
>   	int ret = 0;
>   	int nreq = 0;
> @@ -969,7 +971,8 @@ static int hns_roce_v1_send_lp_wqe(struct hns_roce_qp *hr_qp)
>   {
>   	struct hns_roce_dev *hr_dev = to_hr_dev(hr_qp->ibqp.device);
>   	struct device *dev = &hr_dev->pdev->dev;
> -	struct ib_send_wr send_wr, *bad_wr;
> +	struct ib_send_wr send_wr;
> +	const struct ib_send_wr *bad_wr;
>   	int ret;
>   
>   	memset(&send_wr, 0, sizeof(send_wr));
> diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
> index 8a43c6ab811e..235a4bd454d8 100644
> --- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
> +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
> @@ -103,7 +103,7 @@ static void set_extend_sge(struct hns_roce_qp *qp, const struct ib_send_wr *wr,
>   static int set_rwqe_data_seg(struct ib_qp *ibqp, const struct ib_send_wr *wr,
>   			     struct hns_roce_v2_rc_send_wqe *rc_sq_wqe,
>   			     void *wqe, unsigned int *sge_ind,
> -			     struct ib_send_wr **bad_wr)
> +			     const struct ib_send_wr **bad_wr)
>   {
>   	struct hns_roce_dev *hr_dev = to_hr_dev(ibqp->device);
>   	struct hns_roce_v2_wqe_data_seg *dseg = wqe;
> @@ -164,8 +164,9 @@ static int set_rwqe_data_seg(struct ib_qp *ibqp, const struct ib_send_wr *wr,
>   	return 0;
>   }
>   
> -static int hns_roce_v2_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
> -				 struct ib_send_wr **bad_wr)
> +static int hns_roce_v2_post_send(struct ib_qp *ibqp,
> +				 const struct ib_send_wr *wr,
> +				 const struct ib_send_wr **bad_wr)
>   {
>   	struct hns_roce_dev *hr_dev = to_hr_dev(ibqp->device);
>   	struct hns_roce_ah *ah = to_hr_ah(ud_wr(wr)->ah);
> @@ -528,8 +529,9 @@ static int hns_roce_v2_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
>   	return ret;
>   }
>   
> -static int hns_roce_v2_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
> -				 struct ib_recv_wr **bad_wr)
> +static int hns_roce_v2_post_recv(struct ib_qp *ibqp,
> +				 const struct ib_recv_wr *wr,
> +				 const struct ib_recv_wr **bad_wr)
>   {
>   	struct hns_roce_dev *hr_dev = to_hr_dev(ibqp->device);
>   	struct hns_roce_qp *hr_qp = to_hr_qp(ibqp);
> diff --git a/drivers/infiniband/hw/i40iw/i40iw_verbs.c b/drivers/infiniband/hw/i40iw/i40iw_verbs.c
> index 7d85414742ff..e780454256df 100644
> --- a/drivers/infiniband/hw/i40iw/i40iw_verbs.c
> +++ b/drivers/infiniband/hw/i40iw/i40iw_verbs.c
> @@ -2201,8 +2201,8 @@ static void i40iw_copy_sg_list(struct i40iw_sge *sg_list, struct ib_sge *sgl, in
>    * @bad_wr: return of bad wr if err
>    */
>   static int i40iw_post_send(struct ib_qp *ibqp,
> -			   struct ib_send_wr *ib_wr,
> -			   struct ib_send_wr **bad_wr)
> +			   const struct ib_send_wr *ib_wr,
> +			   const struct ib_send_wr **bad_wr)
>   {
>   	struct i40iw_qp *iwqp;
>   	struct i40iw_qp_uk *ukqp;
> @@ -2377,9 +2377,8 @@ static int i40iw_post_send(struct ib_qp *ibqp,
>    * @ib_wr: work request for receive
>    * @bad_wr: bad wr caused an error
>    */
> -static int i40iw_post_recv(struct ib_qp *ibqp,
> -			   struct ib_recv_wr *ib_wr,
> -			   struct ib_recv_wr **bad_wr)
> +static int i40iw_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *ib_wr,
> +			   const struct ib_recv_wr **bad_wr)
>   {
>   	struct i40iw_qp *iwqp;
>   	struct i40iw_qp_uk *ukqp;
> diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
> index 8d730a69793d..e5466d786bb1 100644
> --- a/drivers/infiniband/hw/mlx4/mad.c
> +++ b/drivers/infiniband/hw/mlx4/mad.c
> @@ -506,7 +506,7 @@ int mlx4_ib_send_to_slave(struct mlx4_ib_dev *dev, int slave, u8 port,
>   {
>   	struct ib_sge list;
>   	struct ib_ud_wr wr;
> -	struct ib_send_wr *bad_wr;
> +	const struct ib_send_wr *bad_wr;
>   	struct mlx4_ib_demux_pv_ctx *tun_ctx;
>   	struct mlx4_ib_demux_pv_qp *tun_qp;
>   	struct mlx4_rcv_tunnel_mad *tun_mad;
> @@ -1310,7 +1310,8 @@ static int mlx4_ib_post_pv_qp_buf(struct mlx4_ib_demux_pv_ctx *ctx,
>   				  int index)
>   {
>   	struct ib_sge sg_list;
> -	struct ib_recv_wr recv_wr, *bad_recv_wr;
> +	struct ib_recv_wr recv_wr;
> +	const struct ib_recv_wr *bad_recv_wr;
>   	int size;
>   
>   	size = (tun_qp->qp->qp_type == IB_QPT_UD) ?
> @@ -1361,7 +1362,7 @@ int mlx4_ib_send_to_wire(struct mlx4_ib_dev *dev, int slave, u8 port,
>   {
>   	struct ib_sge list;
>   	struct ib_ud_wr wr;
> -	struct ib_send_wr *bad_wr;
> +	const struct ib_send_wr *bad_wr;
>   	struct mlx4_ib_demux_pv_ctx *sqp_ctx;
>   	struct mlx4_ib_demux_pv_qp *sqp;
>   	struct mlx4_mad_snd_buf *sqp_mad;
> diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
> index 1a0fad30633b..e817a2f55546 100644
> --- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
> +++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
> @@ -775,8 +775,8 @@ int mlx4_ib_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr,
>   int mlx4_ib_query_srq(struct ib_srq *srq, struct ib_srq_attr *srq_attr);
>   int mlx4_ib_destroy_srq(struct ib_srq *srq);
>   void mlx4_ib_free_srq_wqe(struct mlx4_ib_srq *srq, int wqe_index);
> -int mlx4_ib_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
> -			  struct ib_recv_wr **bad_wr);
> +int mlx4_ib_post_srq_recv(struct ib_srq *ibsrq, const struct ib_recv_wr *wr,
> +			  const struct ib_recv_wr **bad_wr);
>   
>   struct ib_qp *mlx4_ib_create_qp(struct ib_pd *pd,
>   				struct ib_qp_init_attr *init_attr,
> @@ -788,10 +788,10 @@ int mlx4_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
>   		      int attr_mask, struct ib_udata *udata);
>   int mlx4_ib_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr, int qp_attr_mask,
>   		     struct ib_qp_init_attr *qp_init_attr);
> -int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
> -		      struct ib_send_wr **bad_wr);
> -int mlx4_ib_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
> -		      struct ib_recv_wr **bad_wr);
> +int mlx4_ib_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
> +		      const struct ib_send_wr **bad_wr);
> +int mlx4_ib_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
> +		      const struct ib_recv_wr **bad_wr);
>   
>   int mlx4_MAD_IFC(struct mlx4_ib_dev *dev, int mad_ifc_flags,
>   		 int port, const struct ib_wc *in_wc, const struct ib_grh *in_grh,
> diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
> index 44fc684b5e3a..b431757d4668 100644
> --- a/drivers/infiniband/hw/mlx4/qp.c
> +++ b/drivers/infiniband/hw/mlx4/qp.c
> @@ -3569,8 +3569,8 @@ static void add_zero_len_inline(void *wqe)
>   	inl->byte_count = cpu_to_be32(1 << 31);
>   }
>   
> -static int _mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
> -			      struct ib_send_wr **bad_wr, bool drain)
> +static int _mlx4_ib_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
> +			      const struct ib_send_wr **bad_wr, bool drain)
>   {
>   	struct mlx4_ib_qp *qp = to_mqp(ibqp);
>   	void *wqe;
> @@ -3901,14 +3901,14 @@ static int _mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
>   	return err;
>   }
>   
> -int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
> -		      struct ib_send_wr **bad_wr)
> +int mlx4_ib_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
> +		      const struct ib_send_wr **bad_wr)
>   {
>   	return _mlx4_ib_post_send(ibqp, wr, bad_wr, false);
>   }
>   
> -static int _mlx4_ib_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
> -			      struct ib_recv_wr **bad_wr, bool drain)
> +static int _mlx4_ib_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
> +			      const struct ib_recv_wr **bad_wr, bool drain)
>   {
>   	struct mlx4_ib_qp *qp = to_mqp(ibqp);
>   	struct mlx4_wqe_data_seg *scat;
> @@ -3995,8 +3995,8 @@ static int _mlx4_ib_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
>   	return err;
>   }
>   
> -int mlx4_ib_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
> -		      struct ib_recv_wr **bad_wr)
> +int mlx4_ib_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
> +		      const struct ib_recv_wr **bad_wr)
>   {
>   	return _mlx4_ib_post_recv(ibqp, wr, bad_wr, false);
>   }
> @@ -4536,7 +4536,7 @@ void mlx4_ib_drain_sq(struct ib_qp *qp)
>   	struct ib_cq *cq = qp->send_cq;
>   	struct ib_qp_attr attr = { .qp_state = IB_QPS_ERR };
>   	struct mlx4_ib_drain_cqe sdrain;
> -	struct ib_send_wr *bad_swr;
> +	const struct ib_send_wr *bad_swr;
>   	struct ib_rdma_wr swr = {
>   		.wr = {
>   			.next = NULL,
> @@ -4571,7 +4571,8 @@ void mlx4_ib_drain_rq(struct ib_qp *qp)
>   	struct ib_cq *cq = qp->recv_cq;
>   	struct ib_qp_attr attr = { .qp_state = IB_QPS_ERR };
>   	struct mlx4_ib_drain_cqe rdrain;
> -	struct ib_recv_wr rwr = {}, *bad_rwr;
> +	struct ib_recv_wr rwr = {};
> +	const struct ib_recv_wr *bad_rwr;
>   	int ret;
>   	struct mlx4_ib_dev *dev = to_mdev(qp->device);
>   	struct mlx4_dev *mdev = dev->dev;
> diff --git a/drivers/infiniband/hw/mlx4/srq.c b/drivers/infiniband/hw/mlx4/srq.c
> index ebee56cbc0e2..3731b31c3653 100644
> --- a/drivers/infiniband/hw/mlx4/srq.c
> +++ b/drivers/infiniband/hw/mlx4/srq.c
> @@ -307,8 +307,8 @@ void mlx4_ib_free_srq_wqe(struct mlx4_ib_srq *srq, int wqe_index)
>   	spin_unlock(&srq->lock);
>   }
>   
> -int mlx4_ib_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
> -			  struct ib_recv_wr **bad_wr)
> +int mlx4_ib_post_srq_recv(struct ib_srq *ibsrq, const struct ib_recv_wr *wr,
> +			  const struct ib_recv_wr **bad_wr)
>   {
>   	struct mlx4_ib_srq *srq = to_msrq(ibsrq);
>   	struct mlx4_wqe_srq_next_seg *next;
> diff --git a/drivers/infiniband/hw/mlx5/gsi.c b/drivers/infiniband/hw/mlx5/gsi.c
> index 79e6309460dc..4950df3f71b6 100644
> --- a/drivers/infiniband/hw/mlx5/gsi.c
> +++ b/drivers/infiniband/hw/mlx5/gsi.c
> @@ -477,8 +477,8 @@ static struct ib_qp *get_tx_qp(struct mlx5_ib_gsi_qp *gsi, struct ib_ud_wr *wr)
>   	return gsi->tx_qps[qp_index];
>   }
>   
> -int mlx5_ib_gsi_post_send(struct ib_qp *qp, struct ib_send_wr *wr,
> -			  struct ib_send_wr **bad_wr)
> +int mlx5_ib_gsi_post_send(struct ib_qp *qp, const struct ib_send_wr *wr,
> +			  const struct ib_send_wr **bad_wr)
>   {
>   	struct mlx5_ib_gsi_qp *gsi = gsi_qp(qp);
>   	struct ib_qp *tx_qp;
> @@ -522,8 +522,8 @@ int mlx5_ib_gsi_post_send(struct ib_qp *qp, struct ib_send_wr *wr,
>   	return ret;
>   }
>   
> -int mlx5_ib_gsi_post_recv(struct ib_qp *qp, struct ib_recv_wr *wr,
> -			  struct ib_recv_wr **bad_wr)
> +int mlx5_ib_gsi_post_recv(struct ib_qp *qp, const struct ib_recv_wr *wr,
> +			  const struct ib_recv_wr **bad_wr)
>   {
>   	struct mlx5_ib_gsi_qp *gsi = gsi_qp(qp);
>   
> diff --git a/drivers/infiniband/hw/mlx5/mlx5_ib.h b/drivers/infiniband/hw/mlx5/mlx5_ib.h
> index b98143e5d9e1..59e6f1f61d81 100644
> --- a/drivers/infiniband/hw/mlx5/mlx5_ib.h
> +++ b/drivers/infiniband/hw/mlx5/mlx5_ib.h
> @@ -1006,8 +1006,8 @@ int mlx5_ib_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr,
>   		       enum ib_srq_attr_mask attr_mask, struct ib_udata *udata);
>   int mlx5_ib_query_srq(struct ib_srq *ibsrq, struct ib_srq_attr *srq_attr);
>   int mlx5_ib_destroy_srq(struct ib_srq *srq);
> -int mlx5_ib_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
> -			  struct ib_recv_wr **bad_wr);
> +int mlx5_ib_post_srq_recv(struct ib_srq *ibsrq, const struct ib_recv_wr *wr,
> +			  const struct ib_recv_wr **bad_wr);
>   struct ib_qp *mlx5_ib_create_qp(struct ib_pd *pd,
>   				struct ib_qp_init_attr *init_attr,
>   				struct ib_udata *udata);
> @@ -1018,10 +1018,10 @@ int mlx5_ib_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr, int qp_attr
>   int mlx5_ib_destroy_qp(struct ib_qp *qp);
>   void mlx5_ib_drain_sq(struct ib_qp *qp);
>   void mlx5_ib_drain_rq(struct ib_qp *qp);
> -int mlx5_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
> -		      struct ib_send_wr **bad_wr);
> -int mlx5_ib_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
> -		      struct ib_recv_wr **bad_wr);
> +int mlx5_ib_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
> +		      const struct ib_send_wr **bad_wr);
> +int mlx5_ib_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
> +		      const struct ib_recv_wr **bad_wr);
>   void *mlx5_get_send_wqe(struct mlx5_ib_qp *qp, int n);
>   int mlx5_ib_read_user_wqe(struct mlx5_ib_qp *qp, int send, int wqe_index,
>   			  void *buffer, u32 length,
> @@ -1202,10 +1202,10 @@ int mlx5_ib_gsi_modify_qp(struct ib_qp *qp, struct ib_qp_attr *attr,
>   int mlx5_ib_gsi_query_qp(struct ib_qp *qp, struct ib_qp_attr *qp_attr,
>   			 int qp_attr_mask,
>   			 struct ib_qp_init_attr *qp_init_attr);
> -int mlx5_ib_gsi_post_send(struct ib_qp *qp, struct ib_send_wr *wr,
> -			  struct ib_send_wr **bad_wr);
> -int mlx5_ib_gsi_post_recv(struct ib_qp *qp, struct ib_recv_wr *wr,
> -			  struct ib_recv_wr **bad_wr);
> +int mlx5_ib_gsi_post_send(struct ib_qp *qp, const struct ib_send_wr *wr,
> +			  const struct ib_send_wr **bad_wr);
> +int mlx5_ib_gsi_post_recv(struct ib_qp *qp, const struct ib_recv_wr *wr,
> +			  const struct ib_recv_wr **bad_wr);
>   void mlx5_ib_gsi_pkey_change(struct mlx5_ib_gsi_qp *gsi);
>   
>   int mlx5_ib_generate_wc(struct ib_cq *ibcq, struct ib_wc *wc);
> diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/mr.c
> index 308456d28afb..9fb1d9cb9401 100644
> --- a/drivers/infiniband/hw/mlx5/mr.c
> +++ b/drivers/infiniband/hw/mlx5/mr.c
> @@ -898,7 +898,7 @@ static int mlx5_ib_post_send_wait(struct mlx5_ib_dev *dev,
>   				  struct mlx5_umr_wr *umrwr)
>   {
>   	struct umr_common *umrc = &dev->umrc;
> -	struct ib_send_wr *bad;
> +	const struct ib_send_wr *bad;
>   	int err;
>   	struct mlx5_ib_umr_context umr_context;
>   
> diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c
> index 2fd6fe3fdd02..f60ccb6725b8 100644
> --- a/drivers/infiniband/hw/mlx5/qp.c
> +++ b/drivers/infiniband/hw/mlx5/qp.c
> @@ -4370,8 +4370,8 @@ static void finish_wqe(struct mlx5_ib_qp *qp,
>   	qp->sq.w_list[idx].next = qp->sq.cur_post;
>   }
>   
> -static int _mlx5_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
> -		      struct ib_send_wr **bad_wr, bool drain)
> +static int _mlx5_ib_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
> +			      const struct ib_send_wr **bad_wr, bool drain)
>   {
>   	struct mlx5_wqe_ctrl_seg *ctrl = NULL;  /* compiler warning */
>   	struct mlx5_ib_dev *dev = to_mdev(ibqp->device);
> @@ -4697,8 +4697,8 @@ static int _mlx5_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
>   	return err;
>   }
>   
> -int mlx5_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
> -		      struct ib_send_wr **bad_wr)
> +int mlx5_ib_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
> +		      const struct ib_send_wr **bad_wr)
>   {
>   	return _mlx5_ib_post_send(ibqp, wr, bad_wr, false);
>   }
> @@ -4708,8 +4708,8 @@ static void set_sig_seg(struct mlx5_rwqe_sig *sig, int size)
>   	sig->signature = calc_sig(sig, size);
>   }
>   
> -static int _mlx5_ib_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
> -		      struct ib_recv_wr **bad_wr, bool drain)
> +static int _mlx5_ib_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
> +		      const struct ib_recv_wr **bad_wr, bool drain)
>   {
>   	struct mlx5_ib_qp *qp = to_mqp(ibqp);
>   	struct mlx5_wqe_data_seg *scat;
> @@ -4789,8 +4789,8 @@ static int _mlx5_ib_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
>   	return err;
>   }
>   
> -int mlx5_ib_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
> -		      struct ib_recv_wr **bad_wr)
> +int mlx5_ib_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
> +		      const struct ib_recv_wr **bad_wr)
>   {
>   	return _mlx5_ib_post_recv(ibqp, wr, bad_wr, false);
>   }
> @@ -5786,7 +5786,7 @@ void mlx5_ib_drain_sq(struct ib_qp *qp)
>   	struct ib_cq *cq = qp->send_cq;
>   	struct ib_qp_attr attr = { .qp_state = IB_QPS_ERR };
>   	struct mlx5_ib_drain_cqe sdrain;
> -	struct ib_send_wr *bad_swr;
> +	const struct ib_send_wr *bad_swr;
>   	struct ib_rdma_wr swr = {
>   		.wr = {
>   			.next = NULL,
> @@ -5821,7 +5821,8 @@ void mlx5_ib_drain_rq(struct ib_qp *qp)
>   	struct ib_cq *cq = qp->recv_cq;
>   	struct ib_qp_attr attr = { .qp_state = IB_QPS_ERR };
>   	struct mlx5_ib_drain_cqe rdrain;
> -	struct ib_recv_wr rwr = {}, *bad_rwr;
> +	struct ib_recv_wr rwr = {};
> +	const struct ib_recv_wr *bad_rwr;
>   	int ret;
>   	struct mlx5_ib_dev *dev = to_mdev(qp->device);
>   	struct mlx5_core_dev *mdev = dev->mdev;
> diff --git a/drivers/infiniband/hw/mlx5/srq.c b/drivers/infiniband/hw/mlx5/srq.c
> index 0af7b7905550..f9dc2b79a51f 100644
> --- a/drivers/infiniband/hw/mlx5/srq.c
> +++ b/drivers/infiniband/hw/mlx5/srq.c
> @@ -440,8 +440,8 @@ void mlx5_ib_free_srq_wqe(struct mlx5_ib_srq *srq, int wqe_index)
>   	spin_unlock(&srq->lock);
>   }
>   
> -int mlx5_ib_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
> -			  struct ib_recv_wr **bad_wr)
> +int mlx5_ib_post_srq_recv(struct ib_srq *ibsrq, const struct ib_recv_wr *wr,
> +			  const struct ib_recv_wr **bad_wr)
>   {
>   	struct mlx5_ib_srq *srq = to_msrq(ibsrq);
>   	struct mlx5_wqe_srq_next_seg *next;
> diff --git a/drivers/infiniband/hw/mthca/mthca_dev.h b/drivers/infiniband/hw/mthca/mthca_dev.h
> index 5508afbf1c67..220a3e4717a3 100644
> --- a/drivers/infiniband/hw/mthca/mthca_dev.h
> +++ b/drivers/infiniband/hw/mthca/mthca_dev.h
> @@ -519,10 +519,10 @@ int mthca_max_srq_sge(struct mthca_dev *dev);
>   void mthca_srq_event(struct mthca_dev *dev, u32 srqn,
>   		     enum ib_event_type event_type);
>   void mthca_free_srq_wqe(struct mthca_srq *srq, u32 wqe_addr);
> -int mthca_tavor_post_srq_recv(struct ib_srq *srq, struct ib_recv_wr *wr,
> -			      struct ib_recv_wr **bad_wr);
> -int mthca_arbel_post_srq_recv(struct ib_srq *srq, struct ib_recv_wr *wr,
> -			      struct ib_recv_wr **bad_wr);
> +int mthca_tavor_post_srq_recv(struct ib_srq *srq, const struct ib_recv_wr *wr,
> +			      const struct ib_recv_wr **bad_wr);
> +int mthca_arbel_post_srq_recv(struct ib_srq *srq, const struct ib_recv_wr *wr,
> +			      const struct ib_recv_wr **bad_wr);
>   
>   void mthca_qp_event(struct mthca_dev *dev, u32 qpn,
>   		    enum ib_event_type event_type);
> @@ -530,14 +530,14 @@ int mthca_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr, int qp_attr_m
>   		   struct ib_qp_init_attr *qp_init_attr);
>   int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask,
>   		    struct ib_udata *udata);
> -int mthca_tavor_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
> -			  struct ib_send_wr **bad_wr);
> -int mthca_tavor_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr,
> -			     struct ib_recv_wr **bad_wr);
> -int mthca_arbel_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
> -			  struct ib_send_wr **bad_wr);
> -int mthca_arbel_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr,
> -			     struct ib_recv_wr **bad_wr);
> +int mthca_tavor_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
> +			  const struct ib_send_wr **bad_wr);
> +int mthca_tavor_post_receive(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
> +			     const struct ib_recv_wr **bad_wr);
> +int mthca_arbel_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
> +			  const struct ib_send_wr **bad_wr);
> +int mthca_arbel_post_receive(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
> +			     const struct ib_recv_wr **bad_wr);
>   void mthca_free_err_wqe(struct mthca_dev *dev, struct mthca_qp *qp, int is_send,
>   			int index, int *dbd, __be32 *new_wqe);
>   int mthca_alloc_qp(struct mthca_dev *dev,
> diff --git a/drivers/infiniband/hw/mthca/mthca_qp.c b/drivers/infiniband/hw/mthca/mthca_qp.c
> index 0e390f410b39..3d37f2373d63 100644
> --- a/drivers/infiniband/hw/mthca/mthca_qp.c
> +++ b/drivers/infiniband/hw/mthca/mthca_qp.c
> @@ -1611,8 +1611,8 @@ static void set_arbel_ud_seg(struct mthca_arbel_ud_seg *useg,
>   	useg->qkey = cpu_to_be32(wr->remote_qkey);
>   }
>   
> -int mthca_tavor_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
> -			  struct ib_send_wr **bad_wr)
> +int mthca_tavor_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
> +			  const struct ib_send_wr **bad_wr)
>   {
>   	struct mthca_dev *dev = to_mdev(ibqp->device);
>   	struct mthca_qp *qp = to_mqp(ibqp);
> @@ -1814,8 +1814,8 @@ int mthca_tavor_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
>   	return err;
>   }
>   
> -int mthca_tavor_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr,
> -			     struct ib_recv_wr **bad_wr)
> +int mthca_tavor_post_receive(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
> +			     const struct ib_recv_wr **bad_wr)
>   {
>   	struct mthca_dev *dev = to_mdev(ibqp->device);
>   	struct mthca_qp *qp = to_mqp(ibqp);
> @@ -1925,8 +1925,8 @@ int mthca_tavor_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr,
>   	return err;
>   }
>   
> -int mthca_arbel_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
> -			  struct ib_send_wr **bad_wr)
> +int mthca_arbel_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
> +			  const struct ib_send_wr **bad_wr)
>   {
>   	struct mthca_dev *dev = to_mdev(ibqp->device);
>   	struct mthca_qp *qp = to_mqp(ibqp);
> @@ -2165,8 +2165,8 @@ int mthca_arbel_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
>   	return err;
>   }
>   
> -int mthca_arbel_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr,
> -			     struct ib_recv_wr **bad_wr)
> +int mthca_arbel_post_receive(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
> +			     const struct ib_recv_wr **bad_wr)
>   {
>   	struct mthca_dev *dev = to_mdev(ibqp->device);
>   	struct mthca_qp *qp = to_mqp(ibqp);
> diff --git a/drivers/infiniband/hw/mthca/mthca_srq.c b/drivers/infiniband/hw/mthca/mthca_srq.c
> index f79732bc73b4..9a3fc6fb0d7e 100644
> --- a/drivers/infiniband/hw/mthca/mthca_srq.c
> +++ b/drivers/infiniband/hw/mthca/mthca_srq.c
> @@ -472,8 +472,8 @@ void mthca_free_srq_wqe(struct mthca_srq *srq, u32 wqe_addr)
>   	spin_unlock(&srq->lock);
>   }
>   
> -int mthca_tavor_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
> -			      struct ib_recv_wr **bad_wr)
> +int mthca_tavor_post_srq_recv(struct ib_srq *ibsrq, const struct ib_recv_wr *wr,
> +			      const struct ib_recv_wr **bad_wr)
>   {
>   	struct mthca_dev *dev = to_mdev(ibsrq->device);
>   	struct mthca_srq *srq = to_msrq(ibsrq);
> @@ -572,8 +572,8 @@ int mthca_tavor_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
>   	return err;
>   }
>   
> -int mthca_arbel_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
> -			      struct ib_recv_wr **bad_wr)
> +int mthca_arbel_post_srq_recv(struct ib_srq *ibsrq, const struct ib_recv_wr *wr,
> +			      const struct ib_recv_wr **bad_wr)
>   {
>   	struct mthca_dev *dev = to_mdev(ibsrq->device);
>   	struct mthca_srq *srq = to_msrq(ibsrq);
> diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
> index f55a1703cc3a..765ca9946579 100644
> --- a/drivers/infiniband/hw/nes/nes_verbs.c
> +++ b/drivers/infiniband/hw/nes/nes_verbs.c
> @@ -3067,8 +3067,8 @@ fill_wqe_sg_send(struct nes_hw_qp_wqe *wqe, const struct ib_send_wr *ib_wr,
>   /**
>    * nes_post_send
>    */
> -static int nes_post_send(struct ib_qp *ibqp, struct ib_send_wr *ib_wr,
> -		struct ib_send_wr **bad_wr)
> +static int nes_post_send(struct ib_qp *ibqp, const struct ib_send_wr *ib_wr,
> +			 const struct ib_send_wr **bad_wr)
>   {
>   	u64 u64temp;
>   	unsigned long flags = 0;
> @@ -3329,8 +3329,8 @@ static int nes_post_send(struct ib_qp *ibqp, struct ib_send_wr *ib_wr,
>   /**
>    * nes_post_recv
>    */
> -static int nes_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *ib_wr,
> -		struct ib_recv_wr **bad_wr)
> +static int nes_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *ib_wr,
> +			 const struct ib_recv_wr **bad_wr)
>   {
>   	u64 u64temp;
>   	unsigned long flags = 0;
> diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
> index d3ec2051278c..750a12acb71b 100644
> --- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
> +++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
> @@ -2167,8 +2167,8 @@ static void ocrdma_ring_sq_db(struct ocrdma_qp *qp)
>   	iowrite32(val, qp->sq_db);
>   }
>   
> -int ocrdma_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
> -		     struct ib_send_wr **bad_wr)
> +int ocrdma_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
> +		     const struct ib_send_wr **bad_wr)
>   {
>   	int status = 0;
>   	struct ocrdma_qp *qp = get_ocrdma_qp(ibqp);
> @@ -2279,8 +2279,8 @@ static void ocrdma_ring_rq_db(struct ocrdma_qp *qp)
>   	iowrite32(val, qp->rq_db);
>   }
>   
> -static void ocrdma_build_rqe(struct ocrdma_hdr_wqe *rqe, struct ib_recv_wr *wr,
> -			     u16 tag)
> +static void ocrdma_build_rqe(struct ocrdma_hdr_wqe *rqe,
> +			     const struct ib_recv_wr *wr, u16 tag)
>   {
>   	u32 wqe_size = 0;
>   	struct ocrdma_sge *sge;
> @@ -2300,8 +2300,8 @@ static void ocrdma_build_rqe(struct ocrdma_hdr_wqe *rqe, struct ib_recv_wr *wr,
>   	ocrdma_cpu_to_le32(rqe, wqe_size);
>   }
>   
> -int ocrdma_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
> -		     struct ib_recv_wr **bad_wr)
> +int ocrdma_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
> +		     const struct ib_recv_wr **bad_wr)
>   {
>   	int status = 0;
>   	unsigned long flags;
> @@ -2370,8 +2370,8 @@ static void ocrdma_ring_srq_db(struct ocrdma_srq *srq)
>   	iowrite32(val, srq->db + OCRDMA_DB_GEN2_SRQ_OFFSET);
>   }
>   
> -int ocrdma_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
> -			 struct ib_recv_wr **bad_wr)
> +int ocrdma_post_srq_recv(struct ib_srq *ibsrq, const struct ib_recv_wr *wr,
> +			 const struct ib_recv_wr **bad_wr)
>   {
>   	int status = 0;
>   	unsigned long flags;
> diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.h b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.h
> index 9a9971708646..b69cfdce7970 100644
> --- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.h
> +++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.h
> @@ -43,10 +43,10 @@
>   #ifndef __OCRDMA_VERBS_H__
>   #define __OCRDMA_VERBS_H__
>   
> -int ocrdma_post_send(struct ib_qp *, struct ib_send_wr *,
> -		     struct ib_send_wr **bad_wr);
> -int ocrdma_post_recv(struct ib_qp *, struct ib_recv_wr *,
> -		     struct ib_recv_wr **bad_wr);
> +int ocrdma_post_send(struct ib_qp *, const struct ib_send_wr *,
> +		     const struct ib_send_wr **bad_wr);
> +int ocrdma_post_recv(struct ib_qp *, const struct ib_recv_wr *,
> +		     const struct ib_recv_wr **bad_wr);
>   
>   int ocrdma_poll_cq(struct ib_cq *, int num_entries, struct ib_wc *wc);
>   int ocrdma_arm_cq(struct ib_cq *, enum ib_cq_notify_flags flags);
> @@ -100,8 +100,8 @@ int ocrdma_modify_srq(struct ib_srq *, struct ib_srq_attr *,
>   		      enum ib_srq_attr_mask, struct ib_udata *);
>   int ocrdma_query_srq(struct ib_srq *, struct ib_srq_attr *);
>   int ocrdma_destroy_srq(struct ib_srq *);
> -int ocrdma_post_srq_recv(struct ib_srq *, struct ib_recv_wr *,
> -			 struct ib_recv_wr **bad_recv_wr);
> +int ocrdma_post_srq_recv(struct ib_srq *, const struct ib_recv_wr *,
> +			 const struct ib_recv_wr **bad_recv_wr);
>   
>   int ocrdma_dereg_mr(struct ib_mr *);
>   struct ib_mr *ocrdma_get_dma_mr(struct ib_pd *, int acc);
> diff --git a/drivers/infiniband/hw/qedr/qedr_roce_cm.c b/drivers/infiniband/hw/qedr/qedr_roce_cm.c
> index b5d49740bf8a..85578887421b 100644
> --- a/drivers/infiniband/hw/qedr/qedr_roce_cm.c
> +++ b/drivers/infiniband/hw/qedr/qedr_roce_cm.c
> @@ -537,8 +537,8 @@ static inline int qedr_gsi_build_packet(struct qedr_dev *dev,
>   	return 0;
>   }
>   
> -int qedr_gsi_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
> -		       struct ib_send_wr **bad_wr)
> +int qedr_gsi_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
> +		       const struct ib_send_wr **bad_wr)
>   {
>   	struct qed_roce_ll2_packet *pkt = NULL;
>   	struct qedr_qp *qp = get_qedr_qp(ibqp);
> @@ -607,8 +607,8 @@ int qedr_gsi_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
>   	return rc;
>   }
>   
> -int qedr_gsi_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
> -		       struct ib_recv_wr **bad_wr)
> +int qedr_gsi_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
> +		       const struct ib_recv_wr **bad_wr)
>   {
>   	struct qedr_dev *dev = get_qedr_dev(ibqp->device);
>   	struct qedr_qp *qp = get_qedr_qp(ibqp);
> diff --git a/drivers/infiniband/hw/qedr/qedr_roce_cm.h b/drivers/infiniband/hw/qedr/qedr_roce_cm.h
> index a55916323ea9..d46dcd3f6424 100644
> --- a/drivers/infiniband/hw/qedr/qedr_roce_cm.h
> +++ b/drivers/infiniband/hw/qedr/qedr_roce_cm.h
> @@ -46,10 +46,10 @@ static inline u32 qedr_get_ipv4_from_gid(const u8 *gid)
>   
>   /* RDMA CM */
>   int qedr_gsi_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc);
> -int qedr_gsi_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
> -		       struct ib_recv_wr **bad_wr);
> -int qedr_gsi_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
> -		       struct ib_send_wr **bad_wr);
> +int qedr_gsi_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
> +		       const struct ib_recv_wr **bad_wr);
> +int qedr_gsi_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
> +		       const struct ib_send_wr **bad_wr);
>   struct ib_qp *qedr_create_gsi_qp(struct qedr_dev *dev,
>   				 struct ib_qp_init_attr *attrs,
>   				 struct qedr_qp *qp);
> diff --git a/drivers/infiniband/hw/qedr/verbs.c b/drivers/infiniband/hw/qedr/verbs.c
> index 278997975e37..0785a0a487f0 100644
> --- a/drivers/infiniband/hw/qedr/verbs.c
> +++ b/drivers/infiniband/hw/qedr/verbs.c
> @@ -2696,9 +2696,9 @@ static void swap_wqe_data64(u64 *p)
>   
>   static u32 qedr_prepare_sq_inline_data(struct qedr_dev *dev,
>   				       struct qedr_qp *qp, u8 *wqe_size,
> -				       struct ib_send_wr *wr,
> -				       struct ib_send_wr **bad_wr, u8 *bits,
> -				       u8 bit)
> +				       const struct ib_send_wr *wr,
> +				       const struct ib_send_wr **bad_wr,
> +				       u8 *bits, u8 bit)
>   {
>   	u32 data_size = sge_data_len(wr->sg_list, wr->num_sge);
>   	char *seg_prt, *wqe;
> @@ -2805,8 +2805,8 @@ static u32 qedr_prepare_sq_rdma_data(struct qedr_dev *dev,
>   				     struct qedr_qp *qp,
>   				     struct rdma_sq_rdma_wqe_1st *rwqe,
>   				     struct rdma_sq_rdma_wqe_2nd *rwqe2,
> -				     struct ib_send_wr *wr,
> -				     struct ib_send_wr **bad_wr)
> +				     const struct ib_send_wr *wr,
> +				     const struct ib_send_wr **bad_wr)
>   {
>   	rwqe2->r_key = cpu_to_le32(rdma_wr(wr)->rkey);
>   	DMA_REGPAIR_LE(rwqe2->remote_va, rdma_wr(wr)->remote_addr);
> @@ -2828,8 +2828,8 @@ static u32 qedr_prepare_sq_send_data(struct qedr_dev *dev,
>   				     struct qedr_qp *qp,
>   				     struct rdma_sq_send_wqe_1st *swqe,
>   				     struct rdma_sq_send_wqe_2st *swqe2,
> -				     struct ib_send_wr *wr,
> -				     struct ib_send_wr **bad_wr)
> +				     const struct ib_send_wr *wr,
> +				     const struct ib_send_wr **bad_wr)
>   {
>   	memset(swqe2, 0, sizeof(*swqe2));
>   	if (wr->send_flags & IB_SEND_INLINE) {
> @@ -2945,8 +2945,8 @@ static inline bool qedr_can_post_send(struct qedr_qp *qp,
>   	return true;
>   }
>   
> -static int __qedr_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
> -		     struct ib_send_wr **bad_wr)
> +static int __qedr_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
> +			    const struct ib_send_wr **bad_wr)
>   {
>   	struct qedr_dev *dev = get_qedr_dev(ibqp->device);
>   	struct qedr_qp *qp = get_qedr_qp(ibqp);
> @@ -3160,8 +3160,8 @@ static int __qedr_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
>   	return rc;
>   }
>   
> -int qedr_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
> -		   struct ib_send_wr **bad_wr)
> +int qedr_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
> +		   const struct ib_send_wr **bad_wr)
>   {
>   	struct qedr_dev *dev = get_qedr_dev(ibqp->device);
>   	struct qedr_qp *qp = get_qedr_qp(ibqp);
> @@ -3226,8 +3226,8 @@ int qedr_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
>   	return rc;
>   }
>   
> -int qedr_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
> -		   struct ib_recv_wr **bad_wr)
> +int qedr_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
> +		   const struct ib_recv_wr **bad_wr)
>   {
>   	struct qedr_qp *qp = get_qedr_qp(ibqp);
>   	struct qedr_dev *dev = qp->dev;
> diff --git a/drivers/infiniband/hw/qedr/verbs.h b/drivers/infiniband/hw/qedr/verbs.h
> index 2c57e4c592a6..087baf009864 100644
> --- a/drivers/infiniband/hw/qedr/verbs.h
> +++ b/drivers/infiniband/hw/qedr/verbs.h
> @@ -82,10 +82,10 @@ int qedr_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg,
>   struct ib_mr *qedr_alloc_mr(struct ib_pd *pd, enum ib_mr_type mr_type,
>   			    u32 max_num_sg);
>   int qedr_poll_cq(struct ib_cq *, int num_entries, struct ib_wc *wc);
> -int qedr_post_send(struct ib_qp *, struct ib_send_wr *,
> -		   struct ib_send_wr **bad_wr);
> -int qedr_post_recv(struct ib_qp *, struct ib_recv_wr *,
> -		   struct ib_recv_wr **bad_wr);
> +int qedr_post_send(struct ib_qp *, const struct ib_send_wr *,
> +		   const struct ib_send_wr **bad_wr);
> +int qedr_post_recv(struct ib_qp *, const struct ib_recv_wr *,
> +		   const struct ib_recv_wr **bad_wr);
>   int qedr_process_mad(struct ib_device *ibdev, int process_mad_flags,
>   		     u8 port_num, const struct ib_wc *in_wc,
>   		     const struct ib_grh *in_grh,
> diff --git a/drivers/infiniband/hw/usnic/usnic_ib_verbs.c b/drivers/infiniband/hw/usnic/usnic_ib_verbs.c
> index 9524524fade4..9973ac893635 100644
> --- a/drivers/infiniband/hw/usnic/usnic_ib_verbs.c
> +++ b/drivers/infiniband/hw/usnic/usnic_ib_verbs.c
> @@ -771,15 +771,15 @@ int usnic_ib_destroy_ah(struct ib_ah *ah)
>   	return -EINVAL;
>   }
>   
> -int usnic_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
> -				struct ib_send_wr **bad_wr)
> +int usnic_ib_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
> +		       const struct ib_send_wr **bad_wr)
>   {
>   	usnic_dbg("\n");
>   	return -EINVAL;
>   }
>   
> -int usnic_ib_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
> -				struct ib_recv_wr **bad_wr)
> +int usnic_ib_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
> +		       const struct ib_recv_wr **bad_wr)
>   {
>   	usnic_dbg("\n");
>   	return -EINVAL;
> diff --git a/drivers/infiniband/hw/usnic/usnic_ib_verbs.h b/drivers/infiniband/hw/usnic/usnic_ib_verbs.h
> index 1fda94425116..2a2c9beb715f 100644
> --- a/drivers/infiniband/hw/usnic/usnic_ib_verbs.h
> +++ b/drivers/infiniband/hw/usnic/usnic_ib_verbs.h
> @@ -80,10 +80,10 @@ struct ib_ah *usnic_ib_create_ah(struct ib_pd *pd,
>   				 struct ib_udata *udata);
>   
>   int usnic_ib_destroy_ah(struct ib_ah *ah);
> -int usnic_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
> -			struct ib_send_wr **bad_wr);
> -int usnic_ib_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
> -			struct ib_recv_wr **bad_wr);
> +int usnic_ib_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
> +			const struct ib_send_wr **bad_wr);
> +int usnic_ib_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
> +		       const struct ib_recv_wr **bad_wr);
>   int usnic_ib_poll_cq(struct ib_cq *ibcq, int num_entries,
>   			struct ib_wc *wc);
>   int usnic_ib_req_notify_cq(struct ib_cq *cq,
> diff --git a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c
> index 1864621ef942..60083c0363a5 100644
> --- a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c
> +++ b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c
> @@ -624,8 +624,8 @@ static int set_reg_seg(struct pvrdma_sq_wqe_hdr *wqe_hdr,
>    *
>    * @return: 0 on success, otherwise errno returned.
>    */
> -int pvrdma_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
> -		     struct ib_send_wr **bad_wr)
> +int pvrdma_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
> +		     const struct ib_send_wr **bad_wr)
>   {
>   	struct pvrdma_qp *qp = to_vqp(ibqp);
>   	struct pvrdma_dev *dev = to_vdev(ibqp->device);
> @@ -828,8 +828,8 @@ int pvrdma_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
>    *
>    * @return: 0 on success, otherwise errno returned.
>    */
> -int pvrdma_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
> -		     struct ib_recv_wr **bad_wr)
> +int pvrdma_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
> +		     const struct ib_recv_wr **bad_wr)
>   {
>   	struct pvrdma_dev *dev = to_vdev(ibqp->device);
>   	unsigned long flags;
> diff --git a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_srq.c b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_srq.c
> index af235967a9c2..a0a82731ea24 100644
> --- a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_srq.c
> +++ b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_srq.c
> @@ -52,8 +52,8 @@
>   
>   #include "pvrdma.h"
>   
> -int pvrdma_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
> -			 struct ib_recv_wr **bad_wr)
> +int pvrdma_post_srq_recv(struct ib_srq *ibsrq, const struct ib_recv_wr *wr,
> +			 const struct ib_recv_wr **bad_wr)
>   {
>   	/* No support for kernel clients. */
>   	return -EOPNOTSUPP;
> diff --git a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_verbs.h b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_verbs.h
> index b7b25728a7e5..6ebf3360ea12 100644
> --- a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_verbs.h
> +++ b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_verbs.h
> @@ -435,8 +435,8 @@ int pvrdma_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr,
>   		      enum ib_srq_attr_mask attr_mask, struct ib_udata *udata);
>   int pvrdma_query_srq(struct ib_srq *srq, struct ib_srq_attr *srq_attr);
>   int pvrdma_destroy_srq(struct ib_srq *srq);
> -int pvrdma_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
> -			 struct ib_recv_wr **bad_wr);
> +int pvrdma_post_srq_recv(struct ib_srq *ibsrq, const struct ib_recv_wr *wr,
> +			 const struct ib_recv_wr **bad_wr);
>   
>   struct ib_qp *pvrdma_create_qp(struct ib_pd *pd,
>   			       struct ib_qp_init_attr *init_attr,
> @@ -446,9 +446,9 @@ int pvrdma_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
>   int pvrdma_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr,
>   		    int qp_attr_mask, struct ib_qp_init_attr *qp_init_attr);
>   int pvrdma_destroy_qp(struct ib_qp *qp);
> -int pvrdma_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
> -		     struct ib_send_wr **bad_wr);
> -int pvrdma_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
> -		     struct ib_recv_wr **bad_wr);
> +int pvrdma_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
> +		     const struct ib_send_wr **bad_wr);
> +int pvrdma_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
> +		     const struct ib_recv_wr **bad_wr);
>   
>   #endif /* __PVRDMA_VERBS_H__ */
> diff --git a/drivers/infiniband/sw/rdmavt/qp.c b/drivers/infiniband/sw/rdmavt/qp.c
> index 858c992906c1..5ce403c6cddb 100644
> --- a/drivers/infiniband/sw/rdmavt/qp.c
> +++ b/drivers/infiniband/sw/rdmavt/qp.c
> @@ -1538,8 +1538,8 @@ int rvt_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
>    *
>    * Return: 0 on success otherwise errno
>    */
> -int rvt_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
> -		  struct ib_recv_wr **bad_wr)
> +int rvt_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
> +		  const struct ib_recv_wr **bad_wr)
>   {
>   	struct rvt_qp *qp = ibqp_to_rvtqp(ibqp);
>   	struct rvt_rwq *wq = qp->r_rq.wq;
> @@ -1891,8 +1891,8 @@ static int rvt_post_one_wr(struct rvt_qp *qp,
>    *
>    * Return: 0 on success else errno
>    */
> -int rvt_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
> -		  struct ib_send_wr **bad_wr)
> +int rvt_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
> +		  const struct ib_send_wr **bad_wr)
>   {
>   	struct rvt_qp *qp = ibqp_to_rvtqp(ibqp);
>   	struct rvt_dev_info *rdi = ib_to_rvt(ibqp->device);
> @@ -1948,8 +1948,8 @@ int rvt_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
>    *
>    * Return: 0 on success else errno
>    */
> -int rvt_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
> -		      struct ib_recv_wr **bad_wr)
> +int rvt_post_srq_recv(struct ib_srq *ibsrq, const struct ib_recv_wr *wr,
> +		      const struct ib_recv_wr **bad_wr)
>   {
>   	struct rvt_srq *srq = ibsrq_to_rvtsrq(ibsrq);
>   	struct rvt_rwq *wq;
> diff --git a/drivers/infiniband/sw/rdmavt/qp.h b/drivers/infiniband/sw/rdmavt/qp.h
> index 8409f80d5f25..264811fdc530 100644
> --- a/drivers/infiniband/sw/rdmavt/qp.h
> +++ b/drivers/infiniband/sw/rdmavt/qp.h
> @@ -60,10 +60,10 @@ int rvt_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
>   int rvt_destroy_qp(struct ib_qp *ibqp);
>   int rvt_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
>   		 int attr_mask, struct ib_qp_init_attr *init_attr);
> -int rvt_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
> -		  struct ib_recv_wr **bad_wr);
> -int rvt_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
> -		  struct ib_send_wr **bad_wr);
> -int rvt_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
> -		      struct ib_recv_wr **bad_wr);
> +int rvt_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
> +		  const struct ib_recv_wr **bad_wr);
> +int rvt_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
> +		  const struct ib_send_wr **bad_wr);
> +int rvt_post_srq_recv(struct ib_srq *ibsrq, const struct ib_recv_wr *wr,
> +		      const struct ib_recv_wr **bad_wr);
>   #endif          /* DEF_RVTQP_H */
> diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c
> index 0ea394554c8e..f5b1e0ad6142 100644
> --- a/drivers/infiniband/sw/rxe/rxe_verbs.c
> +++ b/drivers/infiniband/sw/rxe/rxe_verbs.c
> @@ -287,7 +287,7 @@ static int rxe_destroy_ah(struct ib_ah *ibah)
>   	return 0;
>   }
>   
> -static int post_one_recv(struct rxe_rq *rq, struct ib_recv_wr *ibwr)
> +static int post_one_recv(struct rxe_rq *rq, const struct ib_recv_wr *ibwr)
>   {
>   	int err;
>   	int i;
> @@ -438,8 +438,8 @@ static int rxe_destroy_srq(struct ib_srq *ibsrq)
>   	return 0;
>   }
>   
> -static int rxe_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
> -			     struct ib_recv_wr **bad_wr)
> +static int rxe_post_srq_recv(struct ib_srq *ibsrq, const struct ib_recv_wr *wr,
> +			     const struct ib_recv_wr **bad_wr)
>   {
>   	int err = 0;
>   	unsigned long flags;
> @@ -726,8 +726,8 @@ static int post_one_send(struct rxe_qp *qp, const struct ib_send_wr *ibwr,
>   	return err;
>   }
>   
> -static int rxe_post_send_kernel(struct rxe_qp *qp, struct ib_send_wr *wr,
> -				struct ib_send_wr **bad_wr)
> +static int rxe_post_send_kernel(struct rxe_qp *qp, const struct ib_send_wr *wr,
> +				const struct ib_send_wr **bad_wr)
>   {
>   	int err = 0;
>   	unsigned int mask;
> @@ -769,8 +769,8 @@ static int rxe_post_send_kernel(struct rxe_qp *qp, struct ib_send_wr *wr,
>   	return err;
>   }
>   
> -static int rxe_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
> -			 struct ib_send_wr **bad_wr)
> +static int rxe_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
> +			 const struct ib_send_wr **bad_wr)
>   {
>   	struct rxe_qp *qp = to_rqp(ibqp);
>   
> @@ -792,8 +792,8 @@ static int rxe_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
>   		return rxe_post_send_kernel(qp, wr, bad_wr);
>   }
>   
> -static int rxe_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
> -			 struct ib_recv_wr **bad_wr)
> +static int rxe_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
> +			 const struct ib_recv_wr **bad_wr)
>   {
>   	int err = 0;
>   	struct rxe_qp *qp = to_rqp(ibqp);
> diff --git a/drivers/infiniband/ulp/ipoib/ipoib_cm.c b/drivers/infiniband/ulp/ipoib/ipoib_cm.c
> index 582f199887b0..37579cd25a47 100644
> --- a/drivers/infiniband/ulp/ipoib/ipoib_cm.c
> +++ b/drivers/infiniband/ulp/ipoib/ipoib_cm.c
> @@ -94,7 +94,7 @@ static void ipoib_cm_dma_unmap_rx(struct ipoib_dev_priv *priv, int frags,
>   static int ipoib_cm_post_receive_srq(struct net_device *dev, int id)
>   {
>   	struct ipoib_dev_priv *priv = ipoib_priv(dev);
> -	struct ib_recv_wr *bad_wr;
> +	const struct ib_recv_wr *bad_wr;
>   	int i, ret;
>   
>   	priv->cm.rx_wr.wr_id = id | IPOIB_OP_CM | IPOIB_OP_RECV;
> @@ -120,7 +120,7 @@ static int ipoib_cm_post_receive_nonsrq(struct net_device *dev,
>   					struct ib_sge *sge, int id)
>   {
>   	struct ipoib_dev_priv *priv = ipoib_priv(dev);
> -	struct ib_recv_wr *bad_wr;
> +	const struct ib_recv_wr *bad_wr;
>   	int i, ret;
>   
>   	wr->wr_id = id | IPOIB_OP_CM | IPOIB_OP_RECV;
> @@ -212,7 +212,7 @@ static void ipoib_cm_free_rx_ring(struct net_device *dev,
>   
>   static void ipoib_cm_start_rx_drain(struct ipoib_dev_priv *priv)
>   {
> -	struct ib_send_wr *bad_wr;
> +	const struct ib_send_wr *bad_wr;
>   	struct ipoib_cm_rx *p;
>   
>   	/* We only reserved 1 extra slot in CQ for drain WRs, so
> @@ -328,8 +328,7 @@ static int ipoib_cm_modify_rx_qp(struct net_device *dev,
>   	return 0;
>   }
>   
> -static void ipoib_cm_init_rx_wr(struct net_device *dev,
> -				struct ib_recv_wr *wr,
> +static void ipoib_cm_init_rx_wr(struct net_device *dev, struct ib_recv_wr *wr,
>   				struct ib_sge *sge)
>   {
>   	struct ipoib_dev_priv *priv = ipoib_priv(dev);
> @@ -699,7 +698,7 @@ static inline int post_send(struct ipoib_dev_priv *priv,
>   			    unsigned int wr_id,
>   			    struct ipoib_tx_buf *tx_req)
>   {
> -	struct ib_send_wr *bad_wr;
> +	const struct ib_send_wr *bad_wr;
>   
>   	ipoib_build_sge(priv, tx_req);
>   
> diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ib.c b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
> index 5f5d42bad2ea..06a388773351 100644
> --- a/drivers/infiniband/ulp/ipoib/ipoib_ib.c
> +++ b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
> @@ -101,7 +101,7 @@ static void ipoib_ud_dma_unmap_rx(struct ipoib_dev_priv *priv,
>   static int ipoib_ib_post_receive(struct net_device *dev, int id)
>   {
>   	struct ipoib_dev_priv *priv = ipoib_priv(dev);
> -	struct ib_recv_wr *bad_wr;
> +	const struct ib_recv_wr *bad_wr;
>   	int ret;
>   
>   	priv->rx_wr.wr_id   = id | IPOIB_OP_RECV;
> @@ -542,7 +542,7 @@ static inline int post_send(struct ipoib_dev_priv *priv,
>   			    struct ipoib_tx_buf *tx_req,
>   			    void *head, int hlen)
>   {
> -	struct ib_send_wr *bad_wr;
> +	const struct ib_send_wr *bad_wr;
>   	struct sk_buff *skb = tx_req->skb;
>   
>   	ipoib_build_sge(priv, tx_req);
> diff --git a/drivers/infiniband/ulp/iser/iser_verbs.c b/drivers/infiniband/ulp/iser/iser_verbs.c
> index 616d978cbf2b..eef38c514cfc 100644
> --- a/drivers/infiniband/ulp/iser/iser_verbs.c
> +++ b/drivers/infiniband/ulp/iser/iser_verbs.c
> @@ -1022,7 +1022,8 @@ int iser_post_recvl(struct iser_conn *iser_conn)
>   {
>   	struct ib_conn *ib_conn = &iser_conn->ib_conn;
>   	struct iser_login_desc *desc = &iser_conn->login_desc;
> -	struct ib_recv_wr wr, *wr_failed;
> +	struct ib_recv_wr wr;
> +	const struct ib_recv_wr *wr_failed;
>   	int ib_ret;
>   
>   	desc->sge.addr = desc->rsp_dma;
> @@ -1050,7 +1051,8 @@ int iser_post_recvm(struct iser_conn *iser_conn, int count)
>   	struct ib_conn *ib_conn = &iser_conn->ib_conn;
>   	unsigned int my_rx_head = iser_conn->rx_desc_head;
>   	struct iser_rx_desc *rx_desc;
> -	struct ib_recv_wr *wr, *wr_failed;
> +	struct ib_recv_wr *wr;
> +	const struct ib_recv_wr *wr_failed;
>   	int i, ib_ret;
>   
>   	for (wr = ib_conn->rx_wr, i = 0; i < count; i++, wr++) {
> @@ -1086,7 +1088,8 @@ int iser_post_recvm(struct iser_conn *iser_conn, int count)
>   int iser_post_send(struct ib_conn *ib_conn, struct iser_tx_desc *tx_desc,
>   		   bool signal)
>   {
> -	struct ib_send_wr *bad_wr, *wr = iser_tx_next_wr(tx_desc);
> +	const struct ib_send_wr *bad_wr;
> +	struct ib_send_wr *wr = iser_tx_next_wr(tx_desc);
>   	int ib_ret;
>   
>   	ib_dma_sync_single_for_device(ib_conn->device->ib_device,
> diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c
> index 7e056f3c82a0..a96389fa38fb 100644
> --- a/drivers/infiniband/ulp/isert/ib_isert.c
> +++ b/drivers/infiniband/ulp/isert/ib_isert.c
> @@ -810,7 +810,8 @@ isert_cma_handler(struct rdma_cm_id *cma_id, struct rdma_cm_event *event)
>   static int
>   isert_post_recvm(struct isert_conn *isert_conn, u32 count)
>   {
> -	struct ib_recv_wr *rx_wr, *rx_wr_failed;
> +	struct ib_recv_wr *rx_wr;
> +	const struct ib_recv_wr *rx_wr_failed;
>   	int i, ret;
>   	struct iser_rx_desc *rx_desc;
>   
> @@ -837,7 +838,8 @@ isert_post_recvm(struct isert_conn *isert_conn, u32 count)
>   static int
>   isert_post_recv(struct isert_conn *isert_conn, struct iser_rx_desc *rx_desc)
>   {
> -	struct ib_recv_wr *rx_wr_failed, rx_wr;
> +	const struct ib_recv_wr *rx_wr_failed;
> +	struct ib_recv_wr rx_wr;
>   	int ret;
>   
>   	if (!rx_desc->in_use) {
> @@ -865,7 +867,8 @@ static int
>   isert_login_post_send(struct isert_conn *isert_conn, struct iser_tx_desc *tx_desc)
>   {
>   	struct ib_device *ib_dev = isert_conn->cm_id->device;
> -	struct ib_send_wr send_wr, *send_wr_failed;
> +	struct ib_send_wr send_wr;
> +	const struct ib_send_wr *send_wr_failed;
>   	int ret;
>   
>   	ib_dma_sync_single_for_device(ib_dev, tx_desc->dma_addr,
> @@ -968,7 +971,8 @@ isert_init_send_wr(struct isert_conn *isert_conn, struct isert_cmd *isert_cmd,
>   static int
>   isert_login_post_recv(struct isert_conn *isert_conn)
>   {
> -	struct ib_recv_wr rx_wr, *rx_wr_fail;
> +	struct ib_recv_wr rx_wr;
> +	const struct ib_recv_wr *rx_wr_fail;
>   	struct ib_sge sge;
>   	int ret;
>   
> @@ -1830,7 +1834,7 @@ isert_send_done(struct ib_cq *cq, struct ib_wc *wc)
>   static int
>   isert_post_response(struct isert_conn *isert_conn, struct isert_cmd *isert_cmd)
>   {
> -	struct ib_send_wr *wr_failed;
> +	const struct ib_send_wr *wr_failed;
>   	int ret;
>   
>   	ret = isert_post_recv(isert_conn, isert_cmd->rx_desc);
> diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
> index 117dc1082e58..6756f998949f 100644
> --- a/drivers/infiniband/ulp/srp/ib_srp.c
> +++ b/drivers/infiniband/ulp/srp/ib_srp.c
> @@ -1208,7 +1208,7 @@ static void srp_inv_rkey_err_done(struct ib_cq *cq, struct ib_wc *wc)
>   static int srp_inv_rkey(struct srp_request *req, struct srp_rdma_ch *ch,
>   		u32 rkey)
>   {
> -	struct ib_send_wr *bad_wr;
> +	const struct ib_send_wr *bad_wr;
>   	struct ib_send_wr wr = {
>   		.opcode		    = IB_WR_LOCAL_INV,
>   		.next		    = NULL,
> @@ -1500,7 +1500,7 @@ static int srp_map_finish_fr(struct srp_map_state *state,
>   {
>   	struct srp_target_port *target = ch->target;
>   	struct srp_device *dev = target->srp_host->srp_dev;
> -	struct ib_send_wr *bad_wr;
> +	const struct ib_send_wr *bad_wr;
>   	struct ib_reg_wr wr;
>   	struct srp_fr_desc *desc;
>   	u32 rkey;
> @@ -2015,7 +2015,8 @@ static int srp_post_send(struct srp_rdma_ch *ch, struct srp_iu *iu, int len)
>   {
>   	struct srp_target_port *target = ch->target;
>   	struct ib_sge list;
> -	struct ib_send_wr wr, *bad_wr;
> +	struct ib_send_wr wr;
> +	const struct ib_send_wr *bad_wr;
>   
>   	list.addr   = iu->dma;
>   	list.length = len;
> @@ -2036,7 +2037,8 @@ static int srp_post_send(struct srp_rdma_ch *ch, struct srp_iu *iu, int len)
>   static int srp_post_recv(struct srp_rdma_ch *ch, struct srp_iu *iu)
>   {
>   	struct srp_target_port *target = ch->target;
> -	struct ib_recv_wr wr, *bad_wr;
> +	struct ib_recv_wr wr;
> +	const struct ib_recv_wr *bad_wr;
>   	struct ib_sge list;
>   
>   	list.addr   = iu->dma;
> diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
> index 6ab5f50082da..705f6a992d82 100644
> --- a/drivers/infiniband/ulp/srpt/ib_srpt.c
> +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
> @@ -816,7 +816,8 @@ static int srpt_post_recv(struct srpt_device *sdev, struct srpt_rdma_ch *ch,
>   			  struct srpt_recv_ioctx *ioctx)
>   {
>   	struct ib_sge list;
> -	struct ib_recv_wr wr, *bad_wr;
> +	struct ib_recv_wr wr;
> +	const struct ib_recv_wr *bad_wr;
>   
>   	BUG_ON(!sdev);
>   	list.addr = ioctx->ioctx.dma;
> @@ -846,7 +847,7 @@ static int srpt_post_recv(struct srpt_device *sdev, struct srpt_rdma_ch *ch,
>    */
>   static int srpt_zerolength_write(struct srpt_rdma_ch *ch)
>   {
> -	struct ib_send_wr *bad_wr;
> +	const struct ib_send_wr *bad_wr;
>   	struct ib_rdma_wr wr = {
>   		.wr = {
>   			.next		= NULL,
> @@ -2625,7 +2626,8 @@ static int srpt_write_pending(struct se_cmd *se_cmd)
>   	struct srpt_send_ioctx *ioctx =
>   		container_of(se_cmd, struct srpt_send_ioctx, cmd);
>   	struct srpt_rdma_ch *ch = ioctx->ch;
> -	struct ib_send_wr *first_wr = NULL, *bad_wr;
> +	struct ib_send_wr *first_wr = NULL;
> +	const struct ib_send_wr *bad_wr;
>   	struct ib_cqe *cqe = &ioctx->rdma_cqe;
>   	enum srpt_command_state new_state;
>   	int ret, i;
> @@ -2687,7 +2689,8 @@ static void srpt_queue_response(struct se_cmd *cmd)
>   		container_of(cmd, struct srpt_send_ioctx, cmd);
>   	struct srpt_rdma_ch *ch = ioctx->ch;
>   	struct srpt_device *sdev = ch->sport->sdev;
> -	struct ib_send_wr send_wr, *first_wr = &send_wr, *bad_wr;
> +	struct ib_send_wr send_wr, *first_wr = &send_wr;
> +	const struct ib_send_wr *bad_wr;
>   	struct ib_sge sge;
>   	enum srpt_command_state state;
>   	int resp_len, ret, i;
> diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c
> index c9424da0d23e..89848f970908 100644
> --- a/drivers/nvme/host/rdma.c
> +++ b/drivers/nvme/host/rdma.c
> @@ -1038,7 +1038,7 @@ static void nvme_rdma_inv_rkey_done(struct ib_cq *cq, struct ib_wc *wc)
>   static int nvme_rdma_inv_rkey(struct nvme_rdma_queue *queue,
>   		struct nvme_rdma_request *req)
>   {
> -	struct ib_send_wr *bad_wr;
> +	const struct ib_send_wr *bad_wr;
>   	struct ib_send_wr wr = {
>   		.opcode		    = IB_WR_LOCAL_INV,
>   		.next		    = NULL,
> @@ -1244,7 +1244,8 @@ static int nvme_rdma_post_send(struct nvme_rdma_queue *queue,
>   		struct nvme_rdma_qe *qe, struct ib_sge *sge, u32 num_sge,
>   		struct ib_send_wr *first)
>   {
> -	struct ib_send_wr wr, *bad_wr;
> +	struct ib_send_wr wr;
> +	const struct ib_send_wr *bad_wr;
>   	int ret;
>   
>   	sge->addr   = qe->dma;
> @@ -1274,7 +1275,8 @@ static int nvme_rdma_post_send(struct nvme_rdma_queue *queue,
>   static int nvme_rdma_post_recv(struct nvme_rdma_queue *queue,
>   		struct nvme_rdma_qe *qe)
>   {
> -	struct ib_recv_wr wr, *bad_wr;
> +	struct ib_recv_wr wr;
> +	const struct ib_recv_wr *bad_wr;
>   	struct ib_sge list;
>   	int ret;
>   
> diff --git a/drivers/nvme/target/rdma.c b/drivers/nvme/target/rdma.c
> index 0d7f3d603f1d..dc294be2e81f 100644
> --- a/drivers/nvme/target/rdma.c
> +++ b/drivers/nvme/target/rdma.c
> @@ -382,7 +382,7 @@ static void nvmet_rdma_free_rsps(struct nvmet_rdma_queue *queue)
>   static int nvmet_rdma_post_recv(struct nvmet_rdma_device *ndev,
>   		struct nvmet_rdma_cmd *cmd)
>   {
> -	struct ib_recv_wr *bad_wr;
> +	const struct ib_recv_wr *bad_wr;
>   
>   	ib_dma_sync_single_for_device(ndev->device,
>   		cmd->sge[0].addr, cmd->sge[0].length,
> @@ -472,7 +472,8 @@ static void nvmet_rdma_queue_response(struct nvmet_req *req)
>   	struct nvmet_rdma_rsp *rsp =
>   		container_of(req, struct nvmet_rdma_rsp, req);
>   	struct rdma_cm_id *cm_id = rsp->queue->cm_id;
> -	struct ib_send_wr *first_wr, *bad_wr;
> +	struct ib_send_wr *first_wr;
> +	const struct ib_send_wr *bad_wr;
>   
>   	if (rsp->flags & NVMET_RDMA_REQ_INVALIDATE_RKEY) {
>   		rsp->send_wr.opcode = IB_WR_SEND_WITH_INV;
> diff --git a/fs/cifs/smbdirect.c b/fs/cifs/smbdirect.c
> index c5a1cddd8856..51cdfc31ff10 100644
> --- a/fs/cifs/smbdirect.c
> +++ b/fs/cifs/smbdirect.c
> @@ -801,7 +801,8 @@ static int smbd_ia_open(
>    */
>   static int smbd_post_send_negotiate_req(struct smbd_connection *info)
>   {
> -	struct ib_send_wr send_wr, *send_wr_fail;
> +	struct ib_send_wr send_wr;
> +	const struct ib_send_wr *send_wr_fail;
>   	int rc = -ENOMEM;
>   	struct smbd_request *request;
>   	struct smbd_negotiate_req *packet;
> @@ -1023,7 +1024,8 @@ static void smbd_destroy_header(struct smbd_connection *info,
>   static int smbd_post_send(struct smbd_connection *info,
>   		struct smbd_request *request, bool has_payload)
>   {
> -	struct ib_send_wr send_wr, *send_wr_fail;
> +	struct ib_send_wr send_wr;
> +	const struct ib_send_wr *send_wr_fail;
>   	int rc, i;
>   
>   	for (i = 0; i < request->num_sge; i++) {
> @@ -1183,7 +1185,8 @@ static int smbd_post_send_data(
>   static int smbd_post_recv(
>   		struct smbd_connection *info, struct smbd_response *response)
>   {
> -	struct ib_recv_wr recv_wr, *recv_wr_fail = NULL;
> +	struct ib_recv_wr recv_wr;
> +	const struct ib_recv_wr *recv_wr_fail = NULL;
>   	int rc = -EIO;
>   
>   	response->sge.addr = ib_dma_map_single(
> @@ -2488,7 +2491,7 @@ struct smbd_mr *smbd_register_mr(
>   	int rc, i;
>   	enum dma_data_direction dir;
>   	struct ib_reg_wr *reg_wr;
> -	struct ib_send_wr *bad_wr;
> +	const struct ib_send_wr *bad_wr;
>   
>   	if (num_pages > info->max_frmr_depth) {
>   		log_rdma_mr(ERR, "num_pages=%d max_frmr_depth=%d\n",
> @@ -2607,7 +2610,8 @@ static void local_inv_done(struct ib_cq *cq, struct ib_wc *wc)
>    */
>   int smbd_deregister_mr(struct smbd_mr *smbdirect_mr)
>   {
> -	struct ib_send_wr *wr, *bad_wr;
> +	struct ib_send_wr *wr;
> +	const struct ib_send_wr *bad_wr;
>   	struct smbd_connection *info = smbdirect_mr->conn;
>   	int rc = 0;
>   
> diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
> index e8cf479ad5df..1b9e882973ef 100644
> --- a/include/rdma/ib_verbs.h
> +++ b/include/rdma/ib_verbs.h
> @@ -2391,8 +2391,8 @@ struct ib_device {
>   						struct ib_srq_attr *srq_attr);
>   	int                        (*destroy_srq)(struct ib_srq *srq);
>   	int                        (*post_srq_recv)(struct ib_srq *srq,
> -						    struct ib_recv_wr *recv_wr,
> -						    struct ib_recv_wr **bad_recv_wr);
> +						    const struct ib_recv_wr *recv_wr,
> +						    const struct ib_recv_wr **bad_recv_wr);


according the documentation the **bad_wr "On an immediate failure, this 
parameter will reference the work request that failed to be posted on 
the QP."

can we constify it ?

>   	struct ib_qp *             (*create_qp)(struct ib_pd *pd,
>   						struct ib_qp_init_attr *qp_init_attr,
>   						struct ib_udata *udata);
> @@ -2406,11 +2406,11 @@ struct ib_device {
>   					       struct ib_qp_init_attr *qp_init_attr);
>   	int                        (*destroy_qp)(struct ib_qp *qp);
>   	int                        (*post_send)(struct ib_qp *qp,
> -						struct ib_send_wr *send_wr,
> -						struct ib_send_wr **bad_send_wr);
> +						const struct ib_send_wr *send_wr,
> +						const struct ib_send_wr **bad_send_wr);
>   	int                        (*post_recv)(struct ib_qp *qp,
> -						struct ib_recv_wr *recv_wr,
> -						struct ib_recv_wr **bad_recv_wr);
> +						const struct ib_recv_wr *recv_wr,
> +						const struct ib_recv_wr **bad_recv_wr);
>   	struct ib_cq *             (*create_cq)(struct ib_device *device,
>   						const struct ib_cq_init_attr *attr,
>   						struct ib_ucontext *context,
> @@ -3292,8 +3292,8 @@ int ib_destroy_srq(struct ib_srq *srq);
>    *   the work request that failed to be posted on the QP.
>    */
>   static inline int ib_post_srq_recv(struct ib_srq *srq,
> -				   struct ib_recv_wr *recv_wr,
> -				   struct ib_recv_wr **bad_recv_wr)
> +				   const struct ib_recv_wr *recv_wr,
> +				   const struct ib_recv_wr **bad_recv_wr)
>   {
>   	return srq->device->post_srq_recv(srq, recv_wr, bad_recv_wr);
>   }
> @@ -3393,8 +3393,8 @@ int ib_close_qp(struct ib_qp *qp);
>    * earlier work requests in the list.
>    */
>   static inline int ib_post_send(struct ib_qp *qp,
> -			       struct ib_send_wr *send_wr,
> -			       struct ib_send_wr **bad_send_wr)
> +			       const struct ib_send_wr *send_wr,
> +			       const struct ib_send_wr **bad_send_wr)
>   {
>   	return qp->device->post_send(qp, send_wr, bad_send_wr);
>   }
> @@ -3408,8 +3408,8 @@ static inline int ib_post_send(struct ib_qp *qp,
>    *   the work request that failed to be posted on the QP.
>    */
>   static inline int ib_post_recv(struct ib_qp *qp,
> -			       struct ib_recv_wr *recv_wr,
> -			       struct ib_recv_wr **bad_recv_wr)
> +			       const struct ib_recv_wr *recv_wr,
> +			       const struct ib_recv_wr **bad_recv_wr)
>   {
>   	return qp->device->post_recv(qp, recv_wr, bad_recv_wr);
>   }
> diff --git a/net/9p/trans_rdma.c b/net/9p/trans_rdma.c
> index 3d414acb7015..b00cdc47aded 100644
> --- a/net/9p/trans_rdma.c
> +++ b/net/9p/trans_rdma.c
> @@ -396,7 +396,8 @@ static int
>   post_recv(struct p9_client *client, struct p9_rdma_context *c)
>   {
>   	struct p9_trans_rdma *rdma = client->trans;
> -	struct ib_recv_wr wr, *bad_wr;
> +	struct ib_recv_wr wr;
> +	const struct ib_recv_wr *bad_wr;
>   	struct ib_sge sge;
>   
>   	c->busa = ib_dma_map_single(rdma->cm_id->device,
> @@ -425,7 +426,8 @@ post_recv(struct p9_client *client, struct p9_rdma_context *c)
>   static int rdma_request(struct p9_client *client, struct p9_req_t *req)
>   {
>   	struct p9_trans_rdma *rdma = client->trans;
> -	struct ib_send_wr wr, *bad_wr;
> +	struct ib_send_wr wr;
> +	const struct ib_send_wr *bad_wr;
>   	struct ib_sge sge;
>   	int err = 0;
>   	unsigned long flags;
> diff --git a/net/rds/ib_frmr.c b/net/rds/ib_frmr.c
> index 48332a6ed738..26700294ac6a 100644
> --- a/net/rds/ib_frmr.c
> +++ b/net/rds/ib_frmr.c
> @@ -102,7 +102,7 @@ static void rds_ib_free_frmr(struct rds_ib_mr *ibmr, bool drop)
>   static int rds_ib_post_reg_frmr(struct rds_ib_mr *ibmr)
>   {
>   	struct rds_ib_frmr *frmr = &ibmr->u.frmr;
> -	struct ib_send_wr *failed_wr;
> +	const struct ib_send_wr *failed_wr;
>   	struct ib_reg_wr reg_wr;
>   	int ret, off = 0;
>   
> @@ -230,7 +230,8 @@ static int rds_ib_map_frmr(struct rds_ib_device *rds_ibdev,
>   
>   static int rds_ib_post_inv(struct rds_ib_mr *ibmr)
>   {
> -	struct ib_send_wr *s_wr, *failed_wr;
> +	struct ib_send_wr *s_wr;
> +	const struct ib_send_wr *failed_wr;
>   	struct rds_ib_frmr *frmr = &ibmr->u.frmr;
>   	struct rdma_cm_id *i_cm_id = ibmr->ic->i_cm_id;
>   	int ret = -EINVAL;
> diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
> index b4e421aa9727..8b19d29f2869 100644
> --- a/net/rds/ib_recv.c
> +++ b/net/rds/ib_recv.c
> @@ -383,7 +383,7 @@ void rds_ib_recv_refill(struct rds_connection *conn, int prefill, gfp_t gfp)
>   {
>   	struct rds_ib_connection *ic = conn->c_transport_data;
>   	struct rds_ib_recv_work *recv;
> -	struct ib_recv_wr *failed_wr;
> +	const struct ib_recv_wr *failed_wr;
>   	unsigned int posted = 0;
>   	int ret = 0;
>   	bool can_wait = !!(gfp & __GFP_DIRECT_RECLAIM);
> @@ -650,7 +650,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
>   static void rds_ib_send_ack(struct rds_ib_connection *ic, unsigned int adv_credits)
>   {
>   	struct rds_header *hdr = ic->i_ack;
> -	struct ib_send_wr *failed_wr;
> +	const struct ib_send_wr *failed_wr;
>   	u64 seq;
>   	int ret;
>   
> diff --git a/net/rds/ib_send.c b/net/rds/ib_send.c
> index 8557a1cae041..8ac80c1b051e 100644
> --- a/net/rds/ib_send.c
> +++ b/net/rds/ib_send.c
> @@ -492,7 +492,7 @@ int rds_ib_xmit(struct rds_connection *conn, struct rds_message *rm,
>   	struct rds_ib_send_work *send = NULL;
>   	struct rds_ib_send_work *first;
>   	struct rds_ib_send_work *prev;
> -	struct ib_send_wr *failed_wr;
> +	const struct ib_send_wr *failed_wr;
>   	struct scatterlist *scat;
>   	u32 pos;
>   	u32 i;
> @@ -758,7 +758,7 @@ int rds_ib_xmit_atomic(struct rds_connection *conn, struct rm_atomic_op *op)
>   {
>   	struct rds_ib_connection *ic = conn->c_transport_data;
>   	struct rds_ib_send_work *send = NULL;
> -	struct ib_send_wr *failed_wr;
> +	const struct ib_send_wr *failed_wr;
>   	struct rds_ib_device *rds_ibdev;
>   	u32 pos;
>   	u32 work_alloc;
> @@ -849,7 +849,7 @@ int rds_ib_xmit_rdma(struct rds_connection *conn, struct rm_rdma_op *op)
>   	struct rds_ib_send_work *send = NULL;
>   	struct rds_ib_send_work *first;
>   	struct rds_ib_send_work *prev;
> -	struct ib_send_wr *failed_wr;
> +	const struct ib_send_wr *failed_wr;
>   	struct scatterlist *scat;
>   	unsigned long len;
>   	u64 remote_addr = op->op_remote_addr;
> diff --git a/net/smc/smc_tx.c b/net/smc/smc_tx.c
> index cee666400752..cb6a7fc8a219 100644
> --- a/net/smc/smc_tx.c
> +++ b/net/smc/smc_tx.c
> @@ -255,7 +255,7 @@ static int smc_tx_rdma_write(struct smc_connection *conn, int peer_rmbe_offset,
>   			     int num_sges, struct ib_sge sges[])
>   {
>   	struct smc_link_group *lgr = conn->lgr;
> -	struct ib_send_wr *failed_wr = NULL;
> +	const struct ib_send_wr *failed_wr = NULL;
>   	struct ib_rdma_wr rdma_wr;
>   	struct smc_link *link;
>   	int rc;
> diff --git a/net/smc/smc_wr.c b/net/smc/smc_wr.c
> index dbd2605d1962..91e9d98918a0 100644
> --- a/net/smc/smc_wr.c
> +++ b/net/smc/smc_wr.c
> @@ -240,7 +240,7 @@ int smc_wr_tx_put_slot(struct smc_link *link,
>    */
>   int smc_wr_tx_send(struct smc_link *link, struct smc_wr_tx_pend_priv *priv)
>   {
> -	struct ib_send_wr *failed_wr = NULL;
> +	const struct ib_send_wr *failed_wr = NULL;
>   	struct smc_wr_tx_pend *pend;
>   	int rc;
>   
> @@ -263,7 +263,7 @@ int smc_wr_tx_send(struct smc_link *link, struct smc_wr_tx_pend_priv *priv)
>   /* Register a memory region and wait for result. */
>   int smc_wr_reg_send(struct smc_link *link, struct ib_mr *mr)
>   {
> -	struct ib_send_wr *failed_wr = NULL;
> +	const struct ib_send_wr *failed_wr = NULL;
>   	int rc;
>   
>   	ib_req_notify_cq(link->smcibdev->roce_cq_send,
> diff --git a/net/smc/smc_wr.h b/net/smc/smc_wr.h
> index 210bec3c3ebe..df4070447ef9 100644
> --- a/net/smc/smc_wr.h
> +++ b/net/smc/smc_wr.h
> @@ -63,7 +63,7 @@ static inline void smc_wr_tx_set_wr_id(atomic_long_t *wr_tx_id, long val)
>   /* post a new receive work request to fill a completed old work request entry */
>   static inline int smc_wr_rx_post(struct smc_link *link)
>   {
> -	struct ib_recv_wr *bad_recv_wr = NULL;
> +	const struct ib_recv_wr *bad_recv_wr = NULL;
>   	int rc;
>   	u64 wr_id, temp_wr_id;
>   	u32 index;
> diff --git a/net/sunrpc/xprtrdma/fmr_ops.c b/net/sunrpc/xprtrdma/fmr_ops.c
> index 17fb1e025654..777678d11efd 100644
> --- a/net/sunrpc/xprtrdma/fmr_ops.c
> +++ b/net/sunrpc/xprtrdma/fmr_ops.c
> @@ -279,7 +279,7 @@ fmr_op_map(struct rpcrdma_xprt *r_xprt, struct rpcrdma_mr_seg *seg,
>   static int
>   fmr_op_send(struct rpcrdma_ia *ia, struct rpcrdma_req *req)
>   {
> -	struct ib_send_wr *bad_wr;
> +	const struct ib_send_wr *bad_wr;
>   
>   	return ib_post_send(ia->ri_id->qp, &req->rl_sendctx->sc_wr, &bad_wr);
>   }
> diff --git a/net/sunrpc/xprtrdma/frwr_ops.c b/net/sunrpc/xprtrdma/frwr_ops.c
> index c040de196e13..c7688e4a1ef4 100644
> --- a/net/sunrpc/xprtrdma/frwr_ops.c
> +++ b/net/sunrpc/xprtrdma/frwr_ops.c
> @@ -464,7 +464,8 @@ frwr_op_map(struct rpcrdma_xprt *r_xprt, struct rpcrdma_mr_seg *seg,
>   static int
>   frwr_op_send(struct rpcrdma_ia *ia, struct rpcrdma_req *req)
>   {
> -	struct ib_send_wr *post_wr, *bad_wr;
> +	struct ib_send_wr *post_wr;
> +	const struct ib_send_wr *bad_wr;
>   	struct rpcrdma_mr *mr;
>   
>   	post_wr = &req->rl_sendctx->sc_wr;
> @@ -517,7 +518,8 @@ frwr_op_reminv(struct rpcrdma_rep *rep, struct list_head *mrs)
>   static void
>   frwr_op_unmap_sync(struct rpcrdma_xprt *r_xprt, struct list_head *mrs)
>   {
> -	struct ib_send_wr *first, **prev, *last, *bad_wr;
> +	struct ib_send_wr *first, **prev, *last;
> +	const struct ib_send_wr *bad_wr;
>   	struct rpcrdma_ia *ia = &r_xprt->rx_ia;
>   	struct rpcrdma_frwr *frwr;
>   	struct rpcrdma_mr *mr;
> diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
> index 841fca143804..d4dbd853e75e 100644
> --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
> +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
> @@ -229,7 +229,7 @@ void svc_rdma_recv_ctxt_put(struct svcxprt_rdma *rdma,
>   static int __svc_rdma_post_recv(struct svcxprt_rdma *rdma,
>   				struct svc_rdma_recv_ctxt *ctxt)
>   {
> -	struct ib_recv_wr *bad_recv_wr;
> +	const struct ib_recv_wr *bad_recv_wr;
>   	int ret;
>   
>   	svc_xprt_get(&rdma->sc_xprt);
> diff --git a/net/sunrpc/xprtrdma/svc_rdma_rw.c b/net/sunrpc/xprtrdma/svc_rdma_rw.c
> index ce3ea8419704..04cb3363172a 100644
> --- a/net/sunrpc/xprtrdma/svc_rdma_rw.c
> +++ b/net/sunrpc/xprtrdma/svc_rdma_rw.c
> @@ -307,7 +307,8 @@ static int svc_rdma_post_chunk_ctxt(struct svc_rdma_chunk_ctxt *cc)
>   {
>   	struct svcxprt_rdma *rdma = cc->cc_rdma;
>   	struct svc_xprt *xprt = &rdma->sc_xprt;
> -	struct ib_send_wr *first_wr, *bad_wr;
> +	struct ib_send_wr *first_wr;
> +	const struct ib_send_wr *bad_wr;
>   	struct list_head *tmp;
>   	struct ib_cqe *cqe;
>   	int ret;
> diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
> index 4a3efaea277c..7676053f2df9 100644
> --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
> +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
> @@ -291,7 +291,7 @@ static void svc_rdma_wc_send(struct ib_cq *cq, struct ib_wc *wc)
>    */
>   int svc_rdma_send(struct svcxprt_rdma *rdma, struct ib_send_wr *wr)
>   {
> -	struct ib_send_wr *bad_wr;
> +	const struct ib_send_wr *bad_wr;
>   	int ret;
>   
>   	might_sleep();
> diff --git a/net/sunrpc/xprtrdma/verbs.c b/net/sunrpc/xprtrdma/verbs.c
> index 112a15abc4a4..02d8fdad12ff 100644
> --- a/net/sunrpc/xprtrdma/verbs.c
> +++ b/net/sunrpc/xprtrdma/verbs.c
> @@ -1516,7 +1516,8 @@ void
>   rpcrdma_post_recvs(struct rpcrdma_xprt *r_xprt, bool temp)
>   {
>   	struct rpcrdma_buffer *buf = &r_xprt->rx_buf;
> -	struct ib_recv_wr *wr, *bad_wr;
> +	struct ib_recv_wr *wr;
> +	struct ib_recv_wr *bad_wr;

const ?

>   	int needed, count, rc;
>   
>   	needed = buf->rb_credits + (buf->rb_bc_srv_max_requests << 1);
> @@ -1559,7 +1560,8 @@ rpcrdma_post_recvs(struct rpcrdma_xprt *r_xprt, bool temp)
>   	if (!count)
>   		return;
>   
> -	rc = ib_post_recv(r_xprt->rx_ia.ri_id->qp, wr, &bad_wr);
> +	rc = ib_post_recv(r_xprt->rx_ia.ri_id->qp, wr,
> +			  (const struct ib_recv_wr **)&bad_wr);

is this cast needed ?

>   	if (rc) {
>   		for (wr = bad_wr; wr; wr = wr->next) {
>   			struct rpcrdma_rep *rep;
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Chuck Lever III July 12, 2018, 2:30 p.m. UTC | #3
Hi Bart!


> On Jul 12, 2018, at 5:12 AM, Max Gurtovoy <maxg@mellanox.com> wrote:
> 
> 
> 
> On 7/10/2018 9:27 PM, Bart Van Assche wrote:
>> Since neither ib_post_send() nor ib_post_recv() modify the data structure
>> their second argument points at, declare that argument const.

That's the mechanics of it, but I'd like this patch description to
justify why this is a wise change.


>> This change
>> makes it necessary to declare the 'bad_wr' argument const too and also
>> to modify all ULPs that call ib_post_send(), ib_post_recv() or
>> ib_post_srq_recv().

It's probably my own personal bias, but API contracts are less
readable when an output parameter is declared as a const. Adding
"const" in all the callers is also more cluttered, IMO.

Instead, can a typecast be done inside ib_post_send/recv where
bad_wr is set after an error? Just a (perhaps bad) thought.


>> This patch does not change any functionality.
>> To make this possible, only one cast had to be introduce that casts away
>> constness, namely in rpcrdma_post_recvs(). The only way I can think of
>> to avoid that cast is to change the data type of bad_wr from
>> struct ib_recv_wr ** into int (an index in the work request list). However,
>> that would require even more extensive changes than this patch.

An int would be an index into an array. The WR chain is a list.
Returning an index seems awkward to me for both the drivers and
the ULPs.

Jason has previously suggested that because it is the common case
that callers pass a dummy third argument, the primary post APIs
should drop the third parameter. Maybe that can help simplify this
situation.


>> Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>

[ ... snipped ... ]


>> diff --git a/net/sunrpc/xprtrdma/verbs.c b/net/sunrpc/xprtrdma/verbs.c
>> index 112a15abc4a4..02d8fdad12ff 100644
>> --- a/net/sunrpc/xprtrdma/verbs.c
>> +++ b/net/sunrpc/xprtrdma/verbs.c
>> @@ -1516,7 +1516,8 @@ void
>>  rpcrdma_post_recvs(struct rpcrdma_xprt *r_xprt, bool temp)
>>  {
>>  	struct rpcrdma_buffer *buf = &r_xprt->rx_buf;
>> -	struct ib_recv_wr *wr, *bad_wr;
>> +	struct ib_recv_wr *wr;
>> +	struct ib_recv_wr *bad_wr;
> 
> const ?

If no type qualifier change is needed here, then perhaps this hunk
can be dropped.


>>  	int needed, count, rc;
>>    	needed = buf->rb_credits + (buf->rb_bc_srv_max_requests << 1);
>> @@ -1559,7 +1560,8 @@ rpcrdma_post_recvs(struct rpcrdma_xprt *r_xprt, bool temp)
>>  	if (!count)
>>  		return;
>>  -	rc = ib_post_recv(r_xprt->rx_ia.ri_id->qp, wr, &bad_wr);
>> +	rc = ib_post_recv(r_xprt->rx_ia.ri_id->qp, wr,
>> +			  (const struct ib_recv_wr **)&bad_wr);
> 
> is this cast needed ?
> 
>>  	if (rc) {
>>  		for (wr = bad_wr; wr; wr = wr->next) {
>>  			struct rpcrdma_rep *rep;

--
Chuck Lever



--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Bart Van Assche July 12, 2018, 3:12 p.m. UTC | #4
On Thu, 2018-07-12 at 12:12 +0300, Max Gurtovoy wrote:
> On 7/10/2018 9:27 PM, Bart Van Assche wrote:

> > -int bnxt_re_post_srq_recv(struct ib_srq *ib_srq, struct ib_recv_wr *wr,

> > -			  struct ib_recv_wr **bad_wr)

> > +int bnxt_re_post_srq_recv(struct ib_srq *ib_srq, const struct ib_recv_wr *wr,

> > +			  const struct ib_recv_wr **bad_wr)

> 

> should **bad_wr be const here ?


Hello Max,

When replying to a large e-mail, please trim the e-mail you are replying to.
Otherwise it's hard to find the replies.

Regarding your question: since *wr is const and since wr is one of the possible
values that can be assigned to *bad_wr, **bad_wr has to be declared const too.

> > diff --git a/net/sunrpc/xprtrdma/verbs.c b/net/sunrpc/xprtrdma/verbs.c

> > index 112a15abc4a4..02d8fdad12ff 100644

> > --- a/net/sunrpc/xprtrdma/verbs.c

> > +++ b/net/sunrpc/xprtrdma/verbs.c

> > @@ -1516,7 +1516,8 @@ void

> >   rpcrdma_post_recvs(struct rpcrdma_xprt *r_xprt, bool temp)

> >   {

> >   	struct rpcrdma_buffer *buf = &r_xprt->rx_buf;

> > -	struct ib_recv_wr *wr, *bad_wr;

> > +	struct ib_recv_wr *wr;

> > +	struct ib_recv_wr *bad_wr;

> 

> const ?


In this case it is on purpose that bad_wr was not declared const.

> > -	rc = ib_post_recv(r_xprt->rx_ia.ri_id->qp, wr, &bad_wr);

> > +	rc = ib_post_recv(r_xprt->rx_ia.ri_id->qp, wr,

> > +			  (const struct ib_recv_wr **)&bad_wr);

> 

> is this cast needed ?


Yes, because of the following loop:

> >  		for (wr = bad_wr; wr; wr = wr->next) {

> >   			struct rpcrdma_rep *rep;


Bart.
Bart Van Assche July 12, 2018, 8:28 p.m. UTC | #5
On Thu, 2018-07-12 at 10:30 -0400, Chuck Lever wrote:
> Jason has previously suggested that because it is the common case

> that callers pass a dummy third argument, the primary post APIs

> should drop the third parameter. Maybe that can help simplify this

> situation.


Thanks for the reminder. I will look further into this.

> > > diff --git a/net/sunrpc/xprtrdma/verbs.c b/net/sunrpc/xprtrdma/verbs.c

> > > index 112a15abc4a4..02d8fdad12ff 100644

> > > --- a/net/sunrpc/xprtrdma/verbs.c

> > > +++ b/net/sunrpc/xprtrdma/verbs.c

> > > @@ -1516,7 +1516,8 @@ void

> > >  rpcrdma_post_recvs(struct rpcrdma_xprt *r_xprt, bool temp)

> > >  {

> > >  	struct rpcrdma_buffer *buf = &r_xprt->rx_buf;

> > > -	struct ib_recv_wr *wr, *bad_wr;

> > > +	struct ib_recv_wr *wr;

> > > +	struct ib_recv_wr *bad_wr;

> 

> If no type qualifier change is needed here, then perhaps this hunk

> can be dropped.


You are right, I will drop this hunk.

Thanks,

Bart.
diff mbox

Patch

diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c
index 34e9b2768324..4d3571a0508b 100644
--- a/drivers/infiniband/core/mad.c
+++ b/drivers/infiniband/core/mad.c
@@ -1181,7 +1181,7 @@  int ib_send_mad(struct ib_mad_send_wr_private *mad_send_wr)
 {
 	struct ib_mad_qp_info *qp_info;
 	struct list_head *list;
-	struct ib_send_wr *bad_send_wr;
+	const struct ib_send_wr *bad_send_wr;
 	struct ib_mad_agent *mad_agent;
 	struct ib_sge *sge;
 	unsigned long flags;
@@ -2476,7 +2476,7 @@  static void ib_mad_send_done(struct ib_cq *cq, struct ib_wc *wc)
 	struct ib_mad_send_wr_private	*mad_send_wr, *queued_send_wr;
 	struct ib_mad_qp_info		*qp_info;
 	struct ib_mad_queue		*send_queue;
-	struct ib_send_wr		*bad_send_wr;
+	const struct ib_send_wr		*bad_send_wr;
 	struct ib_mad_send_wc		mad_send_wc;
 	unsigned long flags;
 	int ret;
@@ -2571,7 +2571,7 @@  static bool ib_mad_send_error(struct ib_mad_port_private *port_priv,
 	if (wc->status == IB_WC_WR_FLUSH_ERR) {
 		if (mad_send_wr->retry) {
 			/* Repost send */
-			struct ib_send_wr *bad_send_wr;
+			const struct ib_send_wr *bad_send_wr;
 
 			mad_send_wr->retry = 0;
 			ret = ib_post_send(qp_info->qp, &mad_send_wr->send_wr.wr,
@@ -2891,7 +2891,8 @@  static int ib_mad_post_receive_mads(struct ib_mad_qp_info *qp_info,
 	int post, ret;
 	struct ib_mad_private *mad_priv;
 	struct ib_sge sg_list;
-	struct ib_recv_wr recv_wr, *bad_recv_wr;
+	struct ib_recv_wr recv_wr;
+	const struct ib_recv_wr *bad_recv_wr;
 	struct ib_mad_queue *recv_queue = &qp_info->recv_queue;
 
 	/* Initialize common scatter list fields */
diff --git a/drivers/infiniband/core/rw.c b/drivers/infiniband/core/rw.c
index 474d65297afc..50adbabde9fa 100644
--- a/drivers/infiniband/core/rw.c
+++ b/drivers/infiniband/core/rw.c
@@ -564,7 +564,8 @@  EXPORT_SYMBOL(rdma_rw_ctx_wrs);
 int rdma_rw_ctx_post(struct rdma_rw_ctx *ctx, struct ib_qp *qp, u8 port_num,
 		struct ib_cqe *cqe, struct ib_send_wr *chain_wr)
 {
-	struct ib_send_wr *first_wr, *bad_wr;
+	struct ib_send_wr *first_wr;
+	const struct ib_send_wr *bad_wr;
 
 	first_wr = rdma_rw_ctx_wrs(ctx, qp, port_num, cqe, chain_wr);
 	return ib_post_send(qp, first_wr, &bad_wr);
diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
index d048cabc4246..deaedd60bf24 100644
--- a/drivers/infiniband/core/uverbs_cmd.c
+++ b/drivers/infiniband/core/uverbs_cmd.c
@@ -2137,7 +2137,8 @@  ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file,
 	struct ib_uverbs_post_send      cmd;
 	struct ib_uverbs_post_send_resp resp;
 	struct ib_uverbs_send_wr       *user_wr;
-	struct ib_send_wr              *wr = NULL, *last, *next, *bad_wr;
+	struct ib_send_wr              *wr = NULL, *last, *next;
+	const struct ib_send_wr	       *bad_wr;
 	struct ib_qp                   *qp;
 	int                             i, sg_ind;
 	int				is_ud;
@@ -2416,7 +2417,8 @@  ssize_t ib_uverbs_post_recv(struct ib_uverbs_file *file,
 {
 	struct ib_uverbs_post_recv      cmd;
 	struct ib_uverbs_post_recv_resp resp;
-	struct ib_recv_wr              *wr, *next, *bad_wr;
+	struct ib_recv_wr              *wr, *next;
+	const struct ib_recv_wr	       *bad_wr;
 	struct ib_qp                   *qp;
 	ssize_t                         ret = -EINVAL;
 
@@ -2465,7 +2467,8 @@  ssize_t ib_uverbs_post_srq_recv(struct ib_uverbs_file *file,
 {
 	struct ib_uverbs_post_srq_recv      cmd;
 	struct ib_uverbs_post_srq_recv_resp resp;
-	struct ib_recv_wr                  *wr, *next, *bad_wr;
+	struct ib_recv_wr                  *wr, *next;
+	const struct ib_recv_wr		   *bad_wr;
 	struct ib_srq                      *srq;
 	ssize_t                             ret = -EINVAL;
 
diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
index 1bb6b6ff3341..226053a0f881 100644
--- a/drivers/infiniband/core/verbs.c
+++ b/drivers/infiniband/core/verbs.c
@@ -2472,7 +2472,7 @@  static void __ib_drain_sq(struct ib_qp *qp)
 	struct ib_cq *cq = qp->send_cq;
 	struct ib_qp_attr attr = { .qp_state = IB_QPS_ERR };
 	struct ib_drain_cqe sdrain;
-	struct ib_send_wr *bad_swr;
+	const struct ib_send_wr *bad_swr;
 	struct ib_rdma_wr swr = {
 		.wr = {
 			.next = NULL,
@@ -2512,7 +2512,8 @@  static void __ib_drain_rq(struct ib_qp *qp)
 	struct ib_cq *cq = qp->recv_cq;
 	struct ib_qp_attr attr = { .qp_state = IB_QPS_ERR };
 	struct ib_drain_cqe rdrain;
-	struct ib_recv_wr rwr = {}, *bad_rwr;
+	struct ib_recv_wr rwr = {};
+	const struct ib_recv_wr *bad_rwr;
 	int ret;
 
 	ret = ib_modify_qp(qp, &attr, IB_QP_STATE);
diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
index 0711510ca7b0..7dcb4ffbde23 100644
--- a/drivers/infiniband/hw/bnxt_re/ib_verbs.c
+++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
@@ -1519,8 +1519,8 @@  int bnxt_re_query_srq(struct ib_srq *ib_srq, struct ib_srq_attr *srq_attr)
 	return 0;
 }
 
-int bnxt_re_post_srq_recv(struct ib_srq *ib_srq, struct ib_recv_wr *wr,
-			  struct ib_recv_wr **bad_wr)
+int bnxt_re_post_srq_recv(struct ib_srq *ib_srq, const struct ib_recv_wr *wr,
+			  const struct ib_recv_wr **bad_wr)
 {
 	struct bnxt_re_srq *srq = container_of(ib_srq, struct bnxt_re_srq,
 					       ib_srq);
@@ -2048,7 +2048,7 @@  static int bnxt_re_build_qp1_send_v2(struct bnxt_re_qp *qp,
  * and the MAD datagram out to the provided SGE.
  */
 static int bnxt_re_build_qp1_shadow_qp_recv(struct bnxt_re_qp *qp,
-					    struct ib_recv_wr *wr,
+					    const struct ib_recv_wr *wr,
 					    struct bnxt_qplib_swqe *wqe,
 					    int payload_size)
 {
@@ -2361,8 +2361,8 @@  static int bnxt_re_post_send_shadow_qp(struct bnxt_re_dev *rdev,
 	return rc;
 }
 
-int bnxt_re_post_send(struct ib_qp *ib_qp, struct ib_send_wr *wr,
-		      struct ib_send_wr **bad_wr)
+int bnxt_re_post_send(struct ib_qp *ib_qp, const struct ib_send_wr *wr,
+		      const struct ib_send_wr **bad_wr)
 {
 	struct bnxt_re_qp *qp = container_of(ib_qp, struct bnxt_re_qp, ib_qp);
 	struct bnxt_qplib_swqe wqe;
@@ -2461,7 +2461,7 @@  int bnxt_re_post_send(struct ib_qp *ib_qp, struct ib_send_wr *wr,
 
 static int bnxt_re_post_recv_shadow_qp(struct bnxt_re_dev *rdev,
 				       struct bnxt_re_qp *qp,
-				       struct ib_recv_wr *wr)
+				       const struct ib_recv_wr *wr)
 {
 	struct bnxt_qplib_swqe wqe;
 	int rc = 0;
@@ -2494,8 +2494,8 @@  static int bnxt_re_post_recv_shadow_qp(struct bnxt_re_dev *rdev,
 	return rc;
 }
 
-int bnxt_re_post_recv(struct ib_qp *ib_qp, struct ib_recv_wr *wr,
-		      struct ib_recv_wr **bad_wr)
+int bnxt_re_post_recv(struct ib_qp *ib_qp, const struct ib_recv_wr *wr,
+		      const struct ib_recv_wr **bad_wr)
 {
 	struct bnxt_re_qp *qp = container_of(ib_qp, struct bnxt_re_qp, ib_qp);
 	struct bnxt_qplib_swqe wqe;
diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.h b/drivers/infiniband/hw/bnxt_re/ib_verbs.h
index bd04d40d897a..aa33e7b82c84 100644
--- a/drivers/infiniband/hw/bnxt_re/ib_verbs.h
+++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.h
@@ -181,8 +181,8 @@  int bnxt_re_modify_srq(struct ib_srq *srq, struct ib_srq_attr *srq_attr,
 		       struct ib_udata *udata);
 int bnxt_re_query_srq(struct ib_srq *srq, struct ib_srq_attr *srq_attr);
 int bnxt_re_destroy_srq(struct ib_srq *srq);
-int bnxt_re_post_srq_recv(struct ib_srq *srq, struct ib_recv_wr *recv_wr,
-			  struct ib_recv_wr **bad_recv_wr);
+int bnxt_re_post_srq_recv(struct ib_srq *srq, const struct ib_recv_wr *recv_wr,
+			  const struct ib_recv_wr **bad_recv_wr);
 struct ib_qp *bnxt_re_create_qp(struct ib_pd *pd,
 				struct ib_qp_init_attr *qp_init_attr,
 				struct ib_udata *udata);
@@ -191,10 +191,10 @@  int bnxt_re_modify_qp(struct ib_qp *qp, struct ib_qp_attr *qp_attr,
 int bnxt_re_query_qp(struct ib_qp *qp, struct ib_qp_attr *qp_attr,
 		     int qp_attr_mask, struct ib_qp_init_attr *qp_init_attr);
 int bnxt_re_destroy_qp(struct ib_qp *qp);
-int bnxt_re_post_send(struct ib_qp *qp, struct ib_send_wr *send_wr,
-		      struct ib_send_wr **bad_send_wr);
-int bnxt_re_post_recv(struct ib_qp *qp, struct ib_recv_wr *recv_wr,
-		      struct ib_recv_wr **bad_recv_wr);
+int bnxt_re_post_send(struct ib_qp *qp, const struct ib_send_wr *send_wr,
+		      const struct ib_send_wr **bad_send_wr);
+int bnxt_re_post_recv(struct ib_qp *qp, const struct ib_recv_wr *recv_wr,
+		      const struct ib_recv_wr **bad_recv_wr);
 struct ib_cq *bnxt_re_create_cq(struct ib_device *ibdev,
 				const struct ib_cq_init_attr *attr,
 				struct ib_ucontext *context,
diff --git a/drivers/infiniband/hw/cxgb3/iwch_provider.h b/drivers/infiniband/hw/cxgb3/iwch_provider.h
index 2e38ddefea8a..8adbe9658935 100644
--- a/drivers/infiniband/hw/cxgb3/iwch_provider.h
+++ b/drivers/infiniband/hw/cxgb3/iwch_provider.h
@@ -326,10 +326,10 @@  enum iwch_qp_query_flags {
 };
 
 u16 iwch_rqes_posted(struct iwch_qp *qhp);
-int iwch_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
-		      struct ib_send_wr **bad_wr);
-int iwch_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr,
-		      struct ib_recv_wr **bad_wr);
+int iwch_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
+		   const struct ib_send_wr **bad_wr);
+int iwch_post_receive(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
+		      const struct ib_recv_wr **bad_wr);
 int iwch_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc);
 int iwch_post_terminate(struct iwch_qp *qhp, struct respQ_msg_t *rsp_msg);
 int iwch_post_zb_read(struct iwch_ep *ep);
diff --git a/drivers/infiniband/hw/cxgb3/iwch_qp.c b/drivers/infiniband/hw/cxgb3/iwch_qp.c
index 29ab6910a004..c649faad63f9 100644
--- a/drivers/infiniband/hw/cxgb3/iwch_qp.c
+++ b/drivers/infiniband/hw/cxgb3/iwch_qp.c
@@ -246,7 +246,7 @@  static int iwch_sgl2pbl_map(struct iwch_dev *rhp, struct ib_sge *sg_list,
 }
 
 static int build_rdma_recv(struct iwch_qp *qhp, union t3_wr *wqe,
-				struct ib_recv_wr *wr)
+			   const struct ib_recv_wr *wr)
 {
 	int i, err = 0;
 	u32 pbl_addr[T3_MAX_SGE];
@@ -286,7 +286,7 @@  static int build_rdma_recv(struct iwch_qp *qhp, union t3_wr *wqe,
 }
 
 static int build_zero_stag_recv(struct iwch_qp *qhp, union t3_wr *wqe,
-				struct ib_recv_wr *wr)
+				const struct ib_recv_wr *wr)
 {
 	int i;
 	u32 pbl_addr;
@@ -348,8 +348,8 @@  static int build_zero_stag_recv(struct iwch_qp *qhp, union t3_wr *wqe,
 	return 0;
 }
 
-int iwch_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
-		      struct ib_send_wr **bad_wr)
+int iwch_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
+		   const struct ib_send_wr **bad_wr)
 {
 	int err = 0;
 	u8 uninitialized_var(t3_wr_flit_cnt);
@@ -463,8 +463,8 @@  int iwch_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
 	return err;
 }
 
-int iwch_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr,
-		      struct ib_recv_wr **bad_wr)
+int iwch_post_receive(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
+		      const struct ib_recv_wr **bad_wr)
 {
 	int err = 0;
 	struct iwch_qp *qhp;
diff --git a/drivers/infiniband/hw/cxgb4/iw_cxgb4.h b/drivers/infiniband/hw/cxgb4/iw_cxgb4.h
index 870649ff049c..0eb808549bb3 100644
--- a/drivers/infiniband/hw/cxgb4/iw_cxgb4.h
+++ b/drivers/infiniband/hw/cxgb4/iw_cxgb4.h
@@ -1007,10 +1007,10 @@  void c4iw_release_dev_ucontext(struct c4iw_rdev *rdev,
 void c4iw_init_dev_ucontext(struct c4iw_rdev *rdev,
 			    struct c4iw_dev_ucontext *uctx);
 int c4iw_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc);
-int c4iw_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
-		      struct ib_send_wr **bad_wr);
-int c4iw_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr,
-		      struct ib_recv_wr **bad_wr);
+int c4iw_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
+		   const struct ib_send_wr **bad_wr);
+int c4iw_post_receive(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
+		      const struct ib_recv_wr **bad_wr);
 int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param);
 int c4iw_create_listen(struct iw_cm_id *cm_id, int backlog);
 int c4iw_destroy_listen(struct iw_cm_id *cm_id);
diff --git a/drivers/infiniband/hw/cxgb4/qp.c b/drivers/infiniband/hw/cxgb4/qp.c
index a2eedb19907d..2da17ec22ef8 100644
--- a/drivers/infiniband/hw/cxgb4/qp.c
+++ b/drivers/infiniband/hw/cxgb4/qp.c
@@ -592,7 +592,7 @@  static int build_rdma_read(union t4_wr *wqe, const struct ib_send_wr *wr,
 }
 
 static int build_rdma_recv(struct c4iw_qp *qhp, union t4_recv_wr *wqe,
-			   struct ib_recv_wr *wr, u8 *len16)
+			   const struct ib_recv_wr *wr, u8 *len16)
 {
 	int ret;
 
@@ -861,8 +861,9 @@  static int complete_sq_drain_wr(struct c4iw_qp *qhp,
 	return 0;
 }
 
-static int complete_sq_drain_wrs(struct c4iw_qp *qhp, struct ib_send_wr *wr,
-				struct ib_send_wr **bad_wr)
+static int complete_sq_drain_wrs(struct c4iw_qp *qhp,
+				 const struct ib_send_wr *wr,
+				 const struct ib_send_wr **bad_wr)
 {
 	int ret = 0;
 
@@ -877,7 +878,8 @@  static int complete_sq_drain_wrs(struct c4iw_qp *qhp, struct ib_send_wr *wr,
 	return ret;
 }
 
-static void complete_rq_drain_wr(struct c4iw_qp *qhp, struct ib_recv_wr *wr)
+static void complete_rq_drain_wr(struct c4iw_qp *qhp,
+				 const struct ib_recv_wr *wr)
 {
 	struct t4_cqe cqe = {};
 	struct c4iw_cq *rchp;
@@ -909,7 +911,8 @@  static void complete_rq_drain_wr(struct c4iw_qp *qhp, struct ib_recv_wr *wr)
 	}
 }
 
-static void complete_rq_drain_wrs(struct c4iw_qp *qhp, struct ib_recv_wr *wr)
+static void complete_rq_drain_wrs(struct c4iw_qp *qhp,
+				  const struct ib_recv_wr *wr)
 {
 	while (wr) {
 		complete_rq_drain_wr(qhp, wr);
@@ -917,8 +920,8 @@  static void complete_rq_drain_wrs(struct c4iw_qp *qhp, struct ib_recv_wr *wr)
 	}
 }
 
-int c4iw_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
-		   struct ib_send_wr **bad_wr)
+int c4iw_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
+		   const struct ib_send_wr **bad_wr)
 {
 	int err = 0;
 	u8 len16 = 0;
@@ -1068,8 +1071,8 @@  int c4iw_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
 	return err;
 }
 
-int c4iw_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr,
-		      struct ib_recv_wr **bad_wr)
+int c4iw_post_receive(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
+		      const struct ib_recv_wr **bad_wr)
 {
 	int err = 0;
 	struct c4iw_qp *qhp;
diff --git a/drivers/infiniband/hw/hns/hns_roce_device.h b/drivers/infiniband/hw/hns/hns_roce_device.h
index c97d71f1730e..7e9b68383a60 100644
--- a/drivers/infiniband/hw/hns/hns_roce_device.h
+++ b/drivers/infiniband/hw/hns/hns_roce_device.h
@@ -760,10 +760,10 @@  struct hns_roce_hw {
 			 int attr_mask, enum ib_qp_state cur_state,
 			 enum ib_qp_state new_state);
 	int (*destroy_qp)(struct ib_qp *ibqp);
-	int (*post_send)(struct ib_qp *ibqp, struct ib_send_wr *wr,
-			 struct ib_send_wr **bad_wr);
-	int (*post_recv)(struct ib_qp *qp, struct ib_recv_wr *recv_wr,
-			 struct ib_recv_wr **bad_recv_wr);
+	int (*post_send)(struct ib_qp *ibqp, const struct ib_send_wr *wr,
+			 const struct ib_send_wr **bad_wr);
+	int (*post_recv)(struct ib_qp *qp, const struct ib_recv_wr *recv_wr,
+			 const struct ib_recv_wr **bad_recv_wr);
 	int (*req_notify_cq)(struct ib_cq *ibcq, enum ib_cq_notify_flags flags);
 	int (*poll_cq)(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc);
 	int (*dereg_mr)(struct hns_roce_dev *hr_dev, struct hns_roce_mr *mr);
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
index 235c67dfc6cb..6db8fdd44989 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
@@ -58,8 +58,9 @@  static void set_raddr_seg(struct hns_roce_wqe_raddr_seg *rseg, u64 remote_addr,
 	rseg->len   = 0;
 }
 
-static int hns_roce_v1_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
-				 struct ib_send_wr **bad_wr)
+static int hns_roce_v1_post_send(struct ib_qp *ibqp,
+				 const struct ib_send_wr *wr,
+				 const struct ib_send_wr **bad_wr)
 {
 	struct hns_roce_dev *hr_dev = to_hr_dev(ibqp->device);
 	struct hns_roce_ah *ah = to_hr_ah(ud_wr(wr)->ah);
@@ -342,8 +343,9 @@  static int hns_roce_v1_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
 	return ret;
 }
 
-static int hns_roce_v1_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
-				 struct ib_recv_wr **bad_wr)
+static int hns_roce_v1_post_recv(struct ib_qp *ibqp,
+				 const struct ib_recv_wr *wr,
+				 const struct ib_recv_wr **bad_wr)
 {
 	int ret = 0;
 	int nreq = 0;
@@ -969,7 +971,8 @@  static int hns_roce_v1_send_lp_wqe(struct hns_roce_qp *hr_qp)
 {
 	struct hns_roce_dev *hr_dev = to_hr_dev(hr_qp->ibqp.device);
 	struct device *dev = &hr_dev->pdev->dev;
-	struct ib_send_wr send_wr, *bad_wr;
+	struct ib_send_wr send_wr;
+	const struct ib_send_wr *bad_wr;
 	int ret;
 
 	memset(&send_wr, 0, sizeof(send_wr));
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
index 8a43c6ab811e..235a4bd454d8 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
@@ -103,7 +103,7 @@  static void set_extend_sge(struct hns_roce_qp *qp, const struct ib_send_wr *wr,
 static int set_rwqe_data_seg(struct ib_qp *ibqp, const struct ib_send_wr *wr,
 			     struct hns_roce_v2_rc_send_wqe *rc_sq_wqe,
 			     void *wqe, unsigned int *sge_ind,
-			     struct ib_send_wr **bad_wr)
+			     const struct ib_send_wr **bad_wr)
 {
 	struct hns_roce_dev *hr_dev = to_hr_dev(ibqp->device);
 	struct hns_roce_v2_wqe_data_seg *dseg = wqe;
@@ -164,8 +164,9 @@  static int set_rwqe_data_seg(struct ib_qp *ibqp, const struct ib_send_wr *wr,
 	return 0;
 }
 
-static int hns_roce_v2_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
-				 struct ib_send_wr **bad_wr)
+static int hns_roce_v2_post_send(struct ib_qp *ibqp,
+				 const struct ib_send_wr *wr,
+				 const struct ib_send_wr **bad_wr)
 {
 	struct hns_roce_dev *hr_dev = to_hr_dev(ibqp->device);
 	struct hns_roce_ah *ah = to_hr_ah(ud_wr(wr)->ah);
@@ -528,8 +529,9 @@  static int hns_roce_v2_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
 	return ret;
 }
 
-static int hns_roce_v2_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
-				 struct ib_recv_wr **bad_wr)
+static int hns_roce_v2_post_recv(struct ib_qp *ibqp,
+				 const struct ib_recv_wr *wr,
+				 const struct ib_recv_wr **bad_wr)
 {
 	struct hns_roce_dev *hr_dev = to_hr_dev(ibqp->device);
 	struct hns_roce_qp *hr_qp = to_hr_qp(ibqp);
diff --git a/drivers/infiniband/hw/i40iw/i40iw_verbs.c b/drivers/infiniband/hw/i40iw/i40iw_verbs.c
index 7d85414742ff..e780454256df 100644
--- a/drivers/infiniband/hw/i40iw/i40iw_verbs.c
+++ b/drivers/infiniband/hw/i40iw/i40iw_verbs.c
@@ -2201,8 +2201,8 @@  static void i40iw_copy_sg_list(struct i40iw_sge *sg_list, struct ib_sge *sgl, in
  * @bad_wr: return of bad wr if err
  */
 static int i40iw_post_send(struct ib_qp *ibqp,
-			   struct ib_send_wr *ib_wr,
-			   struct ib_send_wr **bad_wr)
+			   const struct ib_send_wr *ib_wr,
+			   const struct ib_send_wr **bad_wr)
 {
 	struct i40iw_qp *iwqp;
 	struct i40iw_qp_uk *ukqp;
@@ -2377,9 +2377,8 @@  static int i40iw_post_send(struct ib_qp *ibqp,
  * @ib_wr: work request for receive
  * @bad_wr: bad wr caused an error
  */
-static int i40iw_post_recv(struct ib_qp *ibqp,
-			   struct ib_recv_wr *ib_wr,
-			   struct ib_recv_wr **bad_wr)
+static int i40iw_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *ib_wr,
+			   const struct ib_recv_wr **bad_wr)
 {
 	struct i40iw_qp *iwqp;
 	struct i40iw_qp_uk *ukqp;
diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index 8d730a69793d..e5466d786bb1 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -506,7 +506,7 @@  int mlx4_ib_send_to_slave(struct mlx4_ib_dev *dev, int slave, u8 port,
 {
 	struct ib_sge list;
 	struct ib_ud_wr wr;
-	struct ib_send_wr *bad_wr;
+	const struct ib_send_wr *bad_wr;
 	struct mlx4_ib_demux_pv_ctx *tun_ctx;
 	struct mlx4_ib_demux_pv_qp *tun_qp;
 	struct mlx4_rcv_tunnel_mad *tun_mad;
@@ -1310,7 +1310,8 @@  static int mlx4_ib_post_pv_qp_buf(struct mlx4_ib_demux_pv_ctx *ctx,
 				  int index)
 {
 	struct ib_sge sg_list;
-	struct ib_recv_wr recv_wr, *bad_recv_wr;
+	struct ib_recv_wr recv_wr;
+	const struct ib_recv_wr *bad_recv_wr;
 	int size;
 
 	size = (tun_qp->qp->qp_type == IB_QPT_UD) ?
@@ -1361,7 +1362,7 @@  int mlx4_ib_send_to_wire(struct mlx4_ib_dev *dev, int slave, u8 port,
 {
 	struct ib_sge list;
 	struct ib_ud_wr wr;
-	struct ib_send_wr *bad_wr;
+	const struct ib_send_wr *bad_wr;
 	struct mlx4_ib_demux_pv_ctx *sqp_ctx;
 	struct mlx4_ib_demux_pv_qp *sqp;
 	struct mlx4_mad_snd_buf *sqp_mad;
diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
index 1a0fad30633b..e817a2f55546 100644
--- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
+++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
@@ -775,8 +775,8 @@  int mlx4_ib_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr,
 int mlx4_ib_query_srq(struct ib_srq *srq, struct ib_srq_attr *srq_attr);
 int mlx4_ib_destroy_srq(struct ib_srq *srq);
 void mlx4_ib_free_srq_wqe(struct mlx4_ib_srq *srq, int wqe_index);
-int mlx4_ib_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
-			  struct ib_recv_wr **bad_wr);
+int mlx4_ib_post_srq_recv(struct ib_srq *ibsrq, const struct ib_recv_wr *wr,
+			  const struct ib_recv_wr **bad_wr);
 
 struct ib_qp *mlx4_ib_create_qp(struct ib_pd *pd,
 				struct ib_qp_init_attr *init_attr,
@@ -788,10 +788,10 @@  int mlx4_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
 		      int attr_mask, struct ib_udata *udata);
 int mlx4_ib_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr, int qp_attr_mask,
 		     struct ib_qp_init_attr *qp_init_attr);
-int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
-		      struct ib_send_wr **bad_wr);
-int mlx4_ib_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
-		      struct ib_recv_wr **bad_wr);
+int mlx4_ib_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
+		      const struct ib_send_wr **bad_wr);
+int mlx4_ib_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
+		      const struct ib_recv_wr **bad_wr);
 
 int mlx4_MAD_IFC(struct mlx4_ib_dev *dev, int mad_ifc_flags,
 		 int port, const struct ib_wc *in_wc, const struct ib_grh *in_grh,
diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
index 44fc684b5e3a..b431757d4668 100644
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -3569,8 +3569,8 @@  static void add_zero_len_inline(void *wqe)
 	inl->byte_count = cpu_to_be32(1 << 31);
 }
 
-static int _mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
-			      struct ib_send_wr **bad_wr, bool drain)
+static int _mlx4_ib_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
+			      const struct ib_send_wr **bad_wr, bool drain)
 {
 	struct mlx4_ib_qp *qp = to_mqp(ibqp);
 	void *wqe;
@@ -3901,14 +3901,14 @@  static int _mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
 	return err;
 }
 
-int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
-		      struct ib_send_wr **bad_wr)
+int mlx4_ib_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
+		      const struct ib_send_wr **bad_wr)
 {
 	return _mlx4_ib_post_send(ibqp, wr, bad_wr, false);
 }
 
-static int _mlx4_ib_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
-			      struct ib_recv_wr **bad_wr, bool drain)
+static int _mlx4_ib_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
+			      const struct ib_recv_wr **bad_wr, bool drain)
 {
 	struct mlx4_ib_qp *qp = to_mqp(ibqp);
 	struct mlx4_wqe_data_seg *scat;
@@ -3995,8 +3995,8 @@  static int _mlx4_ib_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
 	return err;
 }
 
-int mlx4_ib_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
-		      struct ib_recv_wr **bad_wr)
+int mlx4_ib_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
+		      const struct ib_recv_wr **bad_wr)
 {
 	return _mlx4_ib_post_recv(ibqp, wr, bad_wr, false);
 }
@@ -4536,7 +4536,7 @@  void mlx4_ib_drain_sq(struct ib_qp *qp)
 	struct ib_cq *cq = qp->send_cq;
 	struct ib_qp_attr attr = { .qp_state = IB_QPS_ERR };
 	struct mlx4_ib_drain_cqe sdrain;
-	struct ib_send_wr *bad_swr;
+	const struct ib_send_wr *bad_swr;
 	struct ib_rdma_wr swr = {
 		.wr = {
 			.next = NULL,
@@ -4571,7 +4571,8 @@  void mlx4_ib_drain_rq(struct ib_qp *qp)
 	struct ib_cq *cq = qp->recv_cq;
 	struct ib_qp_attr attr = { .qp_state = IB_QPS_ERR };
 	struct mlx4_ib_drain_cqe rdrain;
-	struct ib_recv_wr rwr = {}, *bad_rwr;
+	struct ib_recv_wr rwr = {};
+	const struct ib_recv_wr *bad_rwr;
 	int ret;
 	struct mlx4_ib_dev *dev = to_mdev(qp->device);
 	struct mlx4_dev *mdev = dev->dev;
diff --git a/drivers/infiniband/hw/mlx4/srq.c b/drivers/infiniband/hw/mlx4/srq.c
index ebee56cbc0e2..3731b31c3653 100644
--- a/drivers/infiniband/hw/mlx4/srq.c
+++ b/drivers/infiniband/hw/mlx4/srq.c
@@ -307,8 +307,8 @@  void mlx4_ib_free_srq_wqe(struct mlx4_ib_srq *srq, int wqe_index)
 	spin_unlock(&srq->lock);
 }
 
-int mlx4_ib_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
-			  struct ib_recv_wr **bad_wr)
+int mlx4_ib_post_srq_recv(struct ib_srq *ibsrq, const struct ib_recv_wr *wr,
+			  const struct ib_recv_wr **bad_wr)
 {
 	struct mlx4_ib_srq *srq = to_msrq(ibsrq);
 	struct mlx4_wqe_srq_next_seg *next;
diff --git a/drivers/infiniband/hw/mlx5/gsi.c b/drivers/infiniband/hw/mlx5/gsi.c
index 79e6309460dc..4950df3f71b6 100644
--- a/drivers/infiniband/hw/mlx5/gsi.c
+++ b/drivers/infiniband/hw/mlx5/gsi.c
@@ -477,8 +477,8 @@  static struct ib_qp *get_tx_qp(struct mlx5_ib_gsi_qp *gsi, struct ib_ud_wr *wr)
 	return gsi->tx_qps[qp_index];
 }
 
-int mlx5_ib_gsi_post_send(struct ib_qp *qp, struct ib_send_wr *wr,
-			  struct ib_send_wr **bad_wr)
+int mlx5_ib_gsi_post_send(struct ib_qp *qp, const struct ib_send_wr *wr,
+			  const struct ib_send_wr **bad_wr)
 {
 	struct mlx5_ib_gsi_qp *gsi = gsi_qp(qp);
 	struct ib_qp *tx_qp;
@@ -522,8 +522,8 @@  int mlx5_ib_gsi_post_send(struct ib_qp *qp, struct ib_send_wr *wr,
 	return ret;
 }
 
-int mlx5_ib_gsi_post_recv(struct ib_qp *qp, struct ib_recv_wr *wr,
-			  struct ib_recv_wr **bad_wr)
+int mlx5_ib_gsi_post_recv(struct ib_qp *qp, const struct ib_recv_wr *wr,
+			  const struct ib_recv_wr **bad_wr)
 {
 	struct mlx5_ib_gsi_qp *gsi = gsi_qp(qp);
 
diff --git a/drivers/infiniband/hw/mlx5/mlx5_ib.h b/drivers/infiniband/hw/mlx5/mlx5_ib.h
index b98143e5d9e1..59e6f1f61d81 100644
--- a/drivers/infiniband/hw/mlx5/mlx5_ib.h
+++ b/drivers/infiniband/hw/mlx5/mlx5_ib.h
@@ -1006,8 +1006,8 @@  int mlx5_ib_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr,
 		       enum ib_srq_attr_mask attr_mask, struct ib_udata *udata);
 int mlx5_ib_query_srq(struct ib_srq *ibsrq, struct ib_srq_attr *srq_attr);
 int mlx5_ib_destroy_srq(struct ib_srq *srq);
-int mlx5_ib_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
-			  struct ib_recv_wr **bad_wr);
+int mlx5_ib_post_srq_recv(struct ib_srq *ibsrq, const struct ib_recv_wr *wr,
+			  const struct ib_recv_wr **bad_wr);
 struct ib_qp *mlx5_ib_create_qp(struct ib_pd *pd,
 				struct ib_qp_init_attr *init_attr,
 				struct ib_udata *udata);
@@ -1018,10 +1018,10 @@  int mlx5_ib_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr, int qp_attr
 int mlx5_ib_destroy_qp(struct ib_qp *qp);
 void mlx5_ib_drain_sq(struct ib_qp *qp);
 void mlx5_ib_drain_rq(struct ib_qp *qp);
-int mlx5_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
-		      struct ib_send_wr **bad_wr);
-int mlx5_ib_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
-		      struct ib_recv_wr **bad_wr);
+int mlx5_ib_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
+		      const struct ib_send_wr **bad_wr);
+int mlx5_ib_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
+		      const struct ib_recv_wr **bad_wr);
 void *mlx5_get_send_wqe(struct mlx5_ib_qp *qp, int n);
 int mlx5_ib_read_user_wqe(struct mlx5_ib_qp *qp, int send, int wqe_index,
 			  void *buffer, u32 length,
@@ -1202,10 +1202,10 @@  int mlx5_ib_gsi_modify_qp(struct ib_qp *qp, struct ib_qp_attr *attr,
 int mlx5_ib_gsi_query_qp(struct ib_qp *qp, struct ib_qp_attr *qp_attr,
 			 int qp_attr_mask,
 			 struct ib_qp_init_attr *qp_init_attr);
-int mlx5_ib_gsi_post_send(struct ib_qp *qp, struct ib_send_wr *wr,
-			  struct ib_send_wr **bad_wr);
-int mlx5_ib_gsi_post_recv(struct ib_qp *qp, struct ib_recv_wr *wr,
-			  struct ib_recv_wr **bad_wr);
+int mlx5_ib_gsi_post_send(struct ib_qp *qp, const struct ib_send_wr *wr,
+			  const struct ib_send_wr **bad_wr);
+int mlx5_ib_gsi_post_recv(struct ib_qp *qp, const struct ib_recv_wr *wr,
+			  const struct ib_recv_wr **bad_wr);
 void mlx5_ib_gsi_pkey_change(struct mlx5_ib_gsi_qp *gsi);
 
 int mlx5_ib_generate_wc(struct ib_cq *ibcq, struct ib_wc *wc);
diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/mr.c
index 308456d28afb..9fb1d9cb9401 100644
--- a/drivers/infiniband/hw/mlx5/mr.c
+++ b/drivers/infiniband/hw/mlx5/mr.c
@@ -898,7 +898,7 @@  static int mlx5_ib_post_send_wait(struct mlx5_ib_dev *dev,
 				  struct mlx5_umr_wr *umrwr)
 {
 	struct umr_common *umrc = &dev->umrc;
-	struct ib_send_wr *bad;
+	const struct ib_send_wr *bad;
 	int err;
 	struct mlx5_ib_umr_context umr_context;
 
diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c
index 2fd6fe3fdd02..f60ccb6725b8 100644
--- a/drivers/infiniband/hw/mlx5/qp.c
+++ b/drivers/infiniband/hw/mlx5/qp.c
@@ -4370,8 +4370,8 @@  static void finish_wqe(struct mlx5_ib_qp *qp,
 	qp->sq.w_list[idx].next = qp->sq.cur_post;
 }
 
-static int _mlx5_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
-		      struct ib_send_wr **bad_wr, bool drain)
+static int _mlx5_ib_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
+			      const struct ib_send_wr **bad_wr, bool drain)
 {
 	struct mlx5_wqe_ctrl_seg *ctrl = NULL;  /* compiler warning */
 	struct mlx5_ib_dev *dev = to_mdev(ibqp->device);
@@ -4697,8 +4697,8 @@  static int _mlx5_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
 	return err;
 }
 
-int mlx5_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
-		      struct ib_send_wr **bad_wr)
+int mlx5_ib_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
+		      const struct ib_send_wr **bad_wr)
 {
 	return _mlx5_ib_post_send(ibqp, wr, bad_wr, false);
 }
@@ -4708,8 +4708,8 @@  static void set_sig_seg(struct mlx5_rwqe_sig *sig, int size)
 	sig->signature = calc_sig(sig, size);
 }
 
-static int _mlx5_ib_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
-		      struct ib_recv_wr **bad_wr, bool drain)
+static int _mlx5_ib_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
+		      const struct ib_recv_wr **bad_wr, bool drain)
 {
 	struct mlx5_ib_qp *qp = to_mqp(ibqp);
 	struct mlx5_wqe_data_seg *scat;
@@ -4789,8 +4789,8 @@  static int _mlx5_ib_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
 	return err;
 }
 
-int mlx5_ib_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
-		      struct ib_recv_wr **bad_wr)
+int mlx5_ib_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
+		      const struct ib_recv_wr **bad_wr)
 {
 	return _mlx5_ib_post_recv(ibqp, wr, bad_wr, false);
 }
@@ -5786,7 +5786,7 @@  void mlx5_ib_drain_sq(struct ib_qp *qp)
 	struct ib_cq *cq = qp->send_cq;
 	struct ib_qp_attr attr = { .qp_state = IB_QPS_ERR };
 	struct mlx5_ib_drain_cqe sdrain;
-	struct ib_send_wr *bad_swr;
+	const struct ib_send_wr *bad_swr;
 	struct ib_rdma_wr swr = {
 		.wr = {
 			.next = NULL,
@@ -5821,7 +5821,8 @@  void mlx5_ib_drain_rq(struct ib_qp *qp)
 	struct ib_cq *cq = qp->recv_cq;
 	struct ib_qp_attr attr = { .qp_state = IB_QPS_ERR };
 	struct mlx5_ib_drain_cqe rdrain;
-	struct ib_recv_wr rwr = {}, *bad_rwr;
+	struct ib_recv_wr rwr = {};
+	const struct ib_recv_wr *bad_rwr;
 	int ret;
 	struct mlx5_ib_dev *dev = to_mdev(qp->device);
 	struct mlx5_core_dev *mdev = dev->mdev;
diff --git a/drivers/infiniband/hw/mlx5/srq.c b/drivers/infiniband/hw/mlx5/srq.c
index 0af7b7905550..f9dc2b79a51f 100644
--- a/drivers/infiniband/hw/mlx5/srq.c
+++ b/drivers/infiniband/hw/mlx5/srq.c
@@ -440,8 +440,8 @@  void mlx5_ib_free_srq_wqe(struct mlx5_ib_srq *srq, int wqe_index)
 	spin_unlock(&srq->lock);
 }
 
-int mlx5_ib_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
-			  struct ib_recv_wr **bad_wr)
+int mlx5_ib_post_srq_recv(struct ib_srq *ibsrq, const struct ib_recv_wr *wr,
+			  const struct ib_recv_wr **bad_wr)
 {
 	struct mlx5_ib_srq *srq = to_msrq(ibsrq);
 	struct mlx5_wqe_srq_next_seg *next;
diff --git a/drivers/infiniband/hw/mthca/mthca_dev.h b/drivers/infiniband/hw/mthca/mthca_dev.h
index 5508afbf1c67..220a3e4717a3 100644
--- a/drivers/infiniband/hw/mthca/mthca_dev.h
+++ b/drivers/infiniband/hw/mthca/mthca_dev.h
@@ -519,10 +519,10 @@  int mthca_max_srq_sge(struct mthca_dev *dev);
 void mthca_srq_event(struct mthca_dev *dev, u32 srqn,
 		     enum ib_event_type event_type);
 void mthca_free_srq_wqe(struct mthca_srq *srq, u32 wqe_addr);
-int mthca_tavor_post_srq_recv(struct ib_srq *srq, struct ib_recv_wr *wr,
-			      struct ib_recv_wr **bad_wr);
-int mthca_arbel_post_srq_recv(struct ib_srq *srq, struct ib_recv_wr *wr,
-			      struct ib_recv_wr **bad_wr);
+int mthca_tavor_post_srq_recv(struct ib_srq *srq, const struct ib_recv_wr *wr,
+			      const struct ib_recv_wr **bad_wr);
+int mthca_arbel_post_srq_recv(struct ib_srq *srq, const struct ib_recv_wr *wr,
+			      const struct ib_recv_wr **bad_wr);
 
 void mthca_qp_event(struct mthca_dev *dev, u32 qpn,
 		    enum ib_event_type event_type);
@@ -530,14 +530,14 @@  int mthca_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr, int qp_attr_m
 		   struct ib_qp_init_attr *qp_init_attr);
 int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask,
 		    struct ib_udata *udata);
-int mthca_tavor_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
-			  struct ib_send_wr **bad_wr);
-int mthca_tavor_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr,
-			     struct ib_recv_wr **bad_wr);
-int mthca_arbel_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
-			  struct ib_send_wr **bad_wr);
-int mthca_arbel_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr,
-			     struct ib_recv_wr **bad_wr);
+int mthca_tavor_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
+			  const struct ib_send_wr **bad_wr);
+int mthca_tavor_post_receive(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
+			     const struct ib_recv_wr **bad_wr);
+int mthca_arbel_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
+			  const struct ib_send_wr **bad_wr);
+int mthca_arbel_post_receive(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
+			     const struct ib_recv_wr **bad_wr);
 void mthca_free_err_wqe(struct mthca_dev *dev, struct mthca_qp *qp, int is_send,
 			int index, int *dbd, __be32 *new_wqe);
 int mthca_alloc_qp(struct mthca_dev *dev,
diff --git a/drivers/infiniband/hw/mthca/mthca_qp.c b/drivers/infiniband/hw/mthca/mthca_qp.c
index 0e390f410b39..3d37f2373d63 100644
--- a/drivers/infiniband/hw/mthca/mthca_qp.c
+++ b/drivers/infiniband/hw/mthca/mthca_qp.c
@@ -1611,8 +1611,8 @@  static void set_arbel_ud_seg(struct mthca_arbel_ud_seg *useg,
 	useg->qkey = cpu_to_be32(wr->remote_qkey);
 }
 
-int mthca_tavor_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
-			  struct ib_send_wr **bad_wr)
+int mthca_tavor_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
+			  const struct ib_send_wr **bad_wr)
 {
 	struct mthca_dev *dev = to_mdev(ibqp->device);
 	struct mthca_qp *qp = to_mqp(ibqp);
@@ -1814,8 +1814,8 @@  int mthca_tavor_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
 	return err;
 }
 
-int mthca_tavor_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr,
-			     struct ib_recv_wr **bad_wr)
+int mthca_tavor_post_receive(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
+			     const struct ib_recv_wr **bad_wr)
 {
 	struct mthca_dev *dev = to_mdev(ibqp->device);
 	struct mthca_qp *qp = to_mqp(ibqp);
@@ -1925,8 +1925,8 @@  int mthca_tavor_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr,
 	return err;
 }
 
-int mthca_arbel_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
-			  struct ib_send_wr **bad_wr)
+int mthca_arbel_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
+			  const struct ib_send_wr **bad_wr)
 {
 	struct mthca_dev *dev = to_mdev(ibqp->device);
 	struct mthca_qp *qp = to_mqp(ibqp);
@@ -2165,8 +2165,8 @@  int mthca_arbel_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
 	return err;
 }
 
-int mthca_arbel_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr,
-			     struct ib_recv_wr **bad_wr)
+int mthca_arbel_post_receive(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
+			     const struct ib_recv_wr **bad_wr)
 {
 	struct mthca_dev *dev = to_mdev(ibqp->device);
 	struct mthca_qp *qp = to_mqp(ibqp);
diff --git a/drivers/infiniband/hw/mthca/mthca_srq.c b/drivers/infiniband/hw/mthca/mthca_srq.c
index f79732bc73b4..9a3fc6fb0d7e 100644
--- a/drivers/infiniband/hw/mthca/mthca_srq.c
+++ b/drivers/infiniband/hw/mthca/mthca_srq.c
@@ -472,8 +472,8 @@  void mthca_free_srq_wqe(struct mthca_srq *srq, u32 wqe_addr)
 	spin_unlock(&srq->lock);
 }
 
-int mthca_tavor_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
-			      struct ib_recv_wr **bad_wr)
+int mthca_tavor_post_srq_recv(struct ib_srq *ibsrq, const struct ib_recv_wr *wr,
+			      const struct ib_recv_wr **bad_wr)
 {
 	struct mthca_dev *dev = to_mdev(ibsrq->device);
 	struct mthca_srq *srq = to_msrq(ibsrq);
@@ -572,8 +572,8 @@  int mthca_tavor_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
 	return err;
 }
 
-int mthca_arbel_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
-			      struct ib_recv_wr **bad_wr)
+int mthca_arbel_post_srq_recv(struct ib_srq *ibsrq, const struct ib_recv_wr *wr,
+			      const struct ib_recv_wr **bad_wr)
 {
 	struct mthca_dev *dev = to_mdev(ibsrq->device);
 	struct mthca_srq *srq = to_msrq(ibsrq);
diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
index f55a1703cc3a..765ca9946579 100644
--- a/drivers/infiniband/hw/nes/nes_verbs.c
+++ b/drivers/infiniband/hw/nes/nes_verbs.c
@@ -3067,8 +3067,8 @@  fill_wqe_sg_send(struct nes_hw_qp_wqe *wqe, const struct ib_send_wr *ib_wr,
 /**
  * nes_post_send
  */
-static int nes_post_send(struct ib_qp *ibqp, struct ib_send_wr *ib_wr,
-		struct ib_send_wr **bad_wr)
+static int nes_post_send(struct ib_qp *ibqp, const struct ib_send_wr *ib_wr,
+			 const struct ib_send_wr **bad_wr)
 {
 	u64 u64temp;
 	unsigned long flags = 0;
@@ -3329,8 +3329,8 @@  static int nes_post_send(struct ib_qp *ibqp, struct ib_send_wr *ib_wr,
 /**
  * nes_post_recv
  */
-static int nes_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *ib_wr,
-		struct ib_recv_wr **bad_wr)
+static int nes_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *ib_wr,
+			 const struct ib_recv_wr **bad_wr)
 {
 	u64 u64temp;
 	unsigned long flags = 0;
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
index d3ec2051278c..750a12acb71b 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
@@ -2167,8 +2167,8 @@  static void ocrdma_ring_sq_db(struct ocrdma_qp *qp)
 	iowrite32(val, qp->sq_db);
 }
 
-int ocrdma_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
-		     struct ib_send_wr **bad_wr)
+int ocrdma_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
+		     const struct ib_send_wr **bad_wr)
 {
 	int status = 0;
 	struct ocrdma_qp *qp = get_ocrdma_qp(ibqp);
@@ -2279,8 +2279,8 @@  static void ocrdma_ring_rq_db(struct ocrdma_qp *qp)
 	iowrite32(val, qp->rq_db);
 }
 
-static void ocrdma_build_rqe(struct ocrdma_hdr_wqe *rqe, struct ib_recv_wr *wr,
-			     u16 tag)
+static void ocrdma_build_rqe(struct ocrdma_hdr_wqe *rqe,
+			     const struct ib_recv_wr *wr, u16 tag)
 {
 	u32 wqe_size = 0;
 	struct ocrdma_sge *sge;
@@ -2300,8 +2300,8 @@  static void ocrdma_build_rqe(struct ocrdma_hdr_wqe *rqe, struct ib_recv_wr *wr,
 	ocrdma_cpu_to_le32(rqe, wqe_size);
 }
 
-int ocrdma_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
-		     struct ib_recv_wr **bad_wr)
+int ocrdma_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
+		     const struct ib_recv_wr **bad_wr)
 {
 	int status = 0;
 	unsigned long flags;
@@ -2370,8 +2370,8 @@  static void ocrdma_ring_srq_db(struct ocrdma_srq *srq)
 	iowrite32(val, srq->db + OCRDMA_DB_GEN2_SRQ_OFFSET);
 }
 
-int ocrdma_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
-			 struct ib_recv_wr **bad_wr)
+int ocrdma_post_srq_recv(struct ib_srq *ibsrq, const struct ib_recv_wr *wr,
+			 const struct ib_recv_wr **bad_wr)
 {
 	int status = 0;
 	unsigned long flags;
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.h b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.h
index 9a9971708646..b69cfdce7970 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.h
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.h
@@ -43,10 +43,10 @@ 
 #ifndef __OCRDMA_VERBS_H__
 #define __OCRDMA_VERBS_H__
 
-int ocrdma_post_send(struct ib_qp *, struct ib_send_wr *,
-		     struct ib_send_wr **bad_wr);
-int ocrdma_post_recv(struct ib_qp *, struct ib_recv_wr *,
-		     struct ib_recv_wr **bad_wr);
+int ocrdma_post_send(struct ib_qp *, const struct ib_send_wr *,
+		     const struct ib_send_wr **bad_wr);
+int ocrdma_post_recv(struct ib_qp *, const struct ib_recv_wr *,
+		     const struct ib_recv_wr **bad_wr);
 
 int ocrdma_poll_cq(struct ib_cq *, int num_entries, struct ib_wc *wc);
 int ocrdma_arm_cq(struct ib_cq *, enum ib_cq_notify_flags flags);
@@ -100,8 +100,8 @@  int ocrdma_modify_srq(struct ib_srq *, struct ib_srq_attr *,
 		      enum ib_srq_attr_mask, struct ib_udata *);
 int ocrdma_query_srq(struct ib_srq *, struct ib_srq_attr *);
 int ocrdma_destroy_srq(struct ib_srq *);
-int ocrdma_post_srq_recv(struct ib_srq *, struct ib_recv_wr *,
-			 struct ib_recv_wr **bad_recv_wr);
+int ocrdma_post_srq_recv(struct ib_srq *, const struct ib_recv_wr *,
+			 const struct ib_recv_wr **bad_recv_wr);
 
 int ocrdma_dereg_mr(struct ib_mr *);
 struct ib_mr *ocrdma_get_dma_mr(struct ib_pd *, int acc);
diff --git a/drivers/infiniband/hw/qedr/qedr_roce_cm.c b/drivers/infiniband/hw/qedr/qedr_roce_cm.c
index b5d49740bf8a..85578887421b 100644
--- a/drivers/infiniband/hw/qedr/qedr_roce_cm.c
+++ b/drivers/infiniband/hw/qedr/qedr_roce_cm.c
@@ -537,8 +537,8 @@  static inline int qedr_gsi_build_packet(struct qedr_dev *dev,
 	return 0;
 }
 
-int qedr_gsi_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
-		       struct ib_send_wr **bad_wr)
+int qedr_gsi_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
+		       const struct ib_send_wr **bad_wr)
 {
 	struct qed_roce_ll2_packet *pkt = NULL;
 	struct qedr_qp *qp = get_qedr_qp(ibqp);
@@ -607,8 +607,8 @@  int qedr_gsi_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
 	return rc;
 }
 
-int qedr_gsi_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
-		       struct ib_recv_wr **bad_wr)
+int qedr_gsi_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
+		       const struct ib_recv_wr **bad_wr)
 {
 	struct qedr_dev *dev = get_qedr_dev(ibqp->device);
 	struct qedr_qp *qp = get_qedr_qp(ibqp);
diff --git a/drivers/infiniband/hw/qedr/qedr_roce_cm.h b/drivers/infiniband/hw/qedr/qedr_roce_cm.h
index a55916323ea9..d46dcd3f6424 100644
--- a/drivers/infiniband/hw/qedr/qedr_roce_cm.h
+++ b/drivers/infiniband/hw/qedr/qedr_roce_cm.h
@@ -46,10 +46,10 @@  static inline u32 qedr_get_ipv4_from_gid(const u8 *gid)
 
 /* RDMA CM */
 int qedr_gsi_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc);
-int qedr_gsi_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
-		       struct ib_recv_wr **bad_wr);
-int qedr_gsi_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
-		       struct ib_send_wr **bad_wr);
+int qedr_gsi_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
+		       const struct ib_recv_wr **bad_wr);
+int qedr_gsi_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
+		       const struct ib_send_wr **bad_wr);
 struct ib_qp *qedr_create_gsi_qp(struct qedr_dev *dev,
 				 struct ib_qp_init_attr *attrs,
 				 struct qedr_qp *qp);
diff --git a/drivers/infiniband/hw/qedr/verbs.c b/drivers/infiniband/hw/qedr/verbs.c
index 278997975e37..0785a0a487f0 100644
--- a/drivers/infiniband/hw/qedr/verbs.c
+++ b/drivers/infiniband/hw/qedr/verbs.c
@@ -2696,9 +2696,9 @@  static void swap_wqe_data64(u64 *p)
 
 static u32 qedr_prepare_sq_inline_data(struct qedr_dev *dev,
 				       struct qedr_qp *qp, u8 *wqe_size,
-				       struct ib_send_wr *wr,
-				       struct ib_send_wr **bad_wr, u8 *bits,
-				       u8 bit)
+				       const struct ib_send_wr *wr,
+				       const struct ib_send_wr **bad_wr,
+				       u8 *bits, u8 bit)
 {
 	u32 data_size = sge_data_len(wr->sg_list, wr->num_sge);
 	char *seg_prt, *wqe;
@@ -2805,8 +2805,8 @@  static u32 qedr_prepare_sq_rdma_data(struct qedr_dev *dev,
 				     struct qedr_qp *qp,
 				     struct rdma_sq_rdma_wqe_1st *rwqe,
 				     struct rdma_sq_rdma_wqe_2nd *rwqe2,
-				     struct ib_send_wr *wr,
-				     struct ib_send_wr **bad_wr)
+				     const struct ib_send_wr *wr,
+				     const struct ib_send_wr **bad_wr)
 {
 	rwqe2->r_key = cpu_to_le32(rdma_wr(wr)->rkey);
 	DMA_REGPAIR_LE(rwqe2->remote_va, rdma_wr(wr)->remote_addr);
@@ -2828,8 +2828,8 @@  static u32 qedr_prepare_sq_send_data(struct qedr_dev *dev,
 				     struct qedr_qp *qp,
 				     struct rdma_sq_send_wqe_1st *swqe,
 				     struct rdma_sq_send_wqe_2st *swqe2,
-				     struct ib_send_wr *wr,
-				     struct ib_send_wr **bad_wr)
+				     const struct ib_send_wr *wr,
+				     const struct ib_send_wr **bad_wr)
 {
 	memset(swqe2, 0, sizeof(*swqe2));
 	if (wr->send_flags & IB_SEND_INLINE) {
@@ -2945,8 +2945,8 @@  static inline bool qedr_can_post_send(struct qedr_qp *qp,
 	return true;
 }
 
-static int __qedr_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
-		     struct ib_send_wr **bad_wr)
+static int __qedr_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
+			    const struct ib_send_wr **bad_wr)
 {
 	struct qedr_dev *dev = get_qedr_dev(ibqp->device);
 	struct qedr_qp *qp = get_qedr_qp(ibqp);
@@ -3160,8 +3160,8 @@  static int __qedr_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
 	return rc;
 }
 
-int qedr_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
-		   struct ib_send_wr **bad_wr)
+int qedr_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
+		   const struct ib_send_wr **bad_wr)
 {
 	struct qedr_dev *dev = get_qedr_dev(ibqp->device);
 	struct qedr_qp *qp = get_qedr_qp(ibqp);
@@ -3226,8 +3226,8 @@  int qedr_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
 	return rc;
 }
 
-int qedr_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
-		   struct ib_recv_wr **bad_wr)
+int qedr_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
+		   const struct ib_recv_wr **bad_wr)
 {
 	struct qedr_qp *qp = get_qedr_qp(ibqp);
 	struct qedr_dev *dev = qp->dev;
diff --git a/drivers/infiniband/hw/qedr/verbs.h b/drivers/infiniband/hw/qedr/verbs.h
index 2c57e4c592a6..087baf009864 100644
--- a/drivers/infiniband/hw/qedr/verbs.h
+++ b/drivers/infiniband/hw/qedr/verbs.h
@@ -82,10 +82,10 @@  int qedr_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg,
 struct ib_mr *qedr_alloc_mr(struct ib_pd *pd, enum ib_mr_type mr_type,
 			    u32 max_num_sg);
 int qedr_poll_cq(struct ib_cq *, int num_entries, struct ib_wc *wc);
-int qedr_post_send(struct ib_qp *, struct ib_send_wr *,
-		   struct ib_send_wr **bad_wr);
-int qedr_post_recv(struct ib_qp *, struct ib_recv_wr *,
-		   struct ib_recv_wr **bad_wr);
+int qedr_post_send(struct ib_qp *, const struct ib_send_wr *,
+		   const struct ib_send_wr **bad_wr);
+int qedr_post_recv(struct ib_qp *, const struct ib_recv_wr *,
+		   const struct ib_recv_wr **bad_wr);
 int qedr_process_mad(struct ib_device *ibdev, int process_mad_flags,
 		     u8 port_num, const struct ib_wc *in_wc,
 		     const struct ib_grh *in_grh,
diff --git a/drivers/infiniband/hw/usnic/usnic_ib_verbs.c b/drivers/infiniband/hw/usnic/usnic_ib_verbs.c
index 9524524fade4..9973ac893635 100644
--- a/drivers/infiniband/hw/usnic/usnic_ib_verbs.c
+++ b/drivers/infiniband/hw/usnic/usnic_ib_verbs.c
@@ -771,15 +771,15 @@  int usnic_ib_destroy_ah(struct ib_ah *ah)
 	return -EINVAL;
 }
 
-int usnic_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
-				struct ib_send_wr **bad_wr)
+int usnic_ib_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
+		       const struct ib_send_wr **bad_wr)
 {
 	usnic_dbg("\n");
 	return -EINVAL;
 }
 
-int usnic_ib_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
-				struct ib_recv_wr **bad_wr)
+int usnic_ib_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
+		       const struct ib_recv_wr **bad_wr)
 {
 	usnic_dbg("\n");
 	return -EINVAL;
diff --git a/drivers/infiniband/hw/usnic/usnic_ib_verbs.h b/drivers/infiniband/hw/usnic/usnic_ib_verbs.h
index 1fda94425116..2a2c9beb715f 100644
--- a/drivers/infiniband/hw/usnic/usnic_ib_verbs.h
+++ b/drivers/infiniband/hw/usnic/usnic_ib_verbs.h
@@ -80,10 +80,10 @@  struct ib_ah *usnic_ib_create_ah(struct ib_pd *pd,
 				 struct ib_udata *udata);
 
 int usnic_ib_destroy_ah(struct ib_ah *ah);
-int usnic_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
-			struct ib_send_wr **bad_wr);
-int usnic_ib_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
-			struct ib_recv_wr **bad_wr);
+int usnic_ib_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
+			const struct ib_send_wr **bad_wr);
+int usnic_ib_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
+		       const struct ib_recv_wr **bad_wr);
 int usnic_ib_poll_cq(struct ib_cq *ibcq, int num_entries,
 			struct ib_wc *wc);
 int usnic_ib_req_notify_cq(struct ib_cq *cq,
diff --git a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c
index 1864621ef942..60083c0363a5 100644
--- a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c
+++ b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c
@@ -624,8 +624,8 @@  static int set_reg_seg(struct pvrdma_sq_wqe_hdr *wqe_hdr,
  *
  * @return: 0 on success, otherwise errno returned.
  */
-int pvrdma_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
-		     struct ib_send_wr **bad_wr)
+int pvrdma_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
+		     const struct ib_send_wr **bad_wr)
 {
 	struct pvrdma_qp *qp = to_vqp(ibqp);
 	struct pvrdma_dev *dev = to_vdev(ibqp->device);
@@ -828,8 +828,8 @@  int pvrdma_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
  *
  * @return: 0 on success, otherwise errno returned.
  */
-int pvrdma_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
-		     struct ib_recv_wr **bad_wr)
+int pvrdma_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
+		     const struct ib_recv_wr **bad_wr)
 {
 	struct pvrdma_dev *dev = to_vdev(ibqp->device);
 	unsigned long flags;
diff --git a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_srq.c b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_srq.c
index af235967a9c2..a0a82731ea24 100644
--- a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_srq.c
+++ b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_srq.c
@@ -52,8 +52,8 @@ 
 
 #include "pvrdma.h"
 
-int pvrdma_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
-			 struct ib_recv_wr **bad_wr)
+int pvrdma_post_srq_recv(struct ib_srq *ibsrq, const struct ib_recv_wr *wr,
+			 const struct ib_recv_wr **bad_wr)
 {
 	/* No support for kernel clients. */
 	return -EOPNOTSUPP;
diff --git a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_verbs.h b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_verbs.h
index b7b25728a7e5..6ebf3360ea12 100644
--- a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_verbs.h
+++ b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_verbs.h
@@ -435,8 +435,8 @@  int pvrdma_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr,
 		      enum ib_srq_attr_mask attr_mask, struct ib_udata *udata);
 int pvrdma_query_srq(struct ib_srq *srq, struct ib_srq_attr *srq_attr);
 int pvrdma_destroy_srq(struct ib_srq *srq);
-int pvrdma_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
-			 struct ib_recv_wr **bad_wr);
+int pvrdma_post_srq_recv(struct ib_srq *ibsrq, const struct ib_recv_wr *wr,
+			 const struct ib_recv_wr **bad_wr);
 
 struct ib_qp *pvrdma_create_qp(struct ib_pd *pd,
 			       struct ib_qp_init_attr *init_attr,
@@ -446,9 +446,9 @@  int pvrdma_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
 int pvrdma_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr,
 		    int qp_attr_mask, struct ib_qp_init_attr *qp_init_attr);
 int pvrdma_destroy_qp(struct ib_qp *qp);
-int pvrdma_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
-		     struct ib_send_wr **bad_wr);
-int pvrdma_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
-		     struct ib_recv_wr **bad_wr);
+int pvrdma_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
+		     const struct ib_send_wr **bad_wr);
+int pvrdma_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
+		     const struct ib_recv_wr **bad_wr);
 
 #endif /* __PVRDMA_VERBS_H__ */
diff --git a/drivers/infiniband/sw/rdmavt/qp.c b/drivers/infiniband/sw/rdmavt/qp.c
index 858c992906c1..5ce403c6cddb 100644
--- a/drivers/infiniband/sw/rdmavt/qp.c
+++ b/drivers/infiniband/sw/rdmavt/qp.c
@@ -1538,8 +1538,8 @@  int rvt_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
  *
  * Return: 0 on success otherwise errno
  */
-int rvt_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
-		  struct ib_recv_wr **bad_wr)
+int rvt_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
+		  const struct ib_recv_wr **bad_wr)
 {
 	struct rvt_qp *qp = ibqp_to_rvtqp(ibqp);
 	struct rvt_rwq *wq = qp->r_rq.wq;
@@ -1891,8 +1891,8 @@  static int rvt_post_one_wr(struct rvt_qp *qp,
  *
  * Return: 0 on success else errno
  */
-int rvt_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
-		  struct ib_send_wr **bad_wr)
+int rvt_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
+		  const struct ib_send_wr **bad_wr)
 {
 	struct rvt_qp *qp = ibqp_to_rvtqp(ibqp);
 	struct rvt_dev_info *rdi = ib_to_rvt(ibqp->device);
@@ -1948,8 +1948,8 @@  int rvt_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
  *
  * Return: 0 on success else errno
  */
-int rvt_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
-		      struct ib_recv_wr **bad_wr)
+int rvt_post_srq_recv(struct ib_srq *ibsrq, const struct ib_recv_wr *wr,
+		      const struct ib_recv_wr **bad_wr)
 {
 	struct rvt_srq *srq = ibsrq_to_rvtsrq(ibsrq);
 	struct rvt_rwq *wq;
diff --git a/drivers/infiniband/sw/rdmavt/qp.h b/drivers/infiniband/sw/rdmavt/qp.h
index 8409f80d5f25..264811fdc530 100644
--- a/drivers/infiniband/sw/rdmavt/qp.h
+++ b/drivers/infiniband/sw/rdmavt/qp.h
@@ -60,10 +60,10 @@  int rvt_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
 int rvt_destroy_qp(struct ib_qp *ibqp);
 int rvt_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
 		 int attr_mask, struct ib_qp_init_attr *init_attr);
-int rvt_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
-		  struct ib_recv_wr **bad_wr);
-int rvt_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
-		  struct ib_send_wr **bad_wr);
-int rvt_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
-		      struct ib_recv_wr **bad_wr);
+int rvt_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
+		  const struct ib_recv_wr **bad_wr);
+int rvt_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
+		  const struct ib_send_wr **bad_wr);
+int rvt_post_srq_recv(struct ib_srq *ibsrq, const struct ib_recv_wr *wr,
+		      const struct ib_recv_wr **bad_wr);
 #endif          /* DEF_RVTQP_H */
diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c
index 0ea394554c8e..f5b1e0ad6142 100644
--- a/drivers/infiniband/sw/rxe/rxe_verbs.c
+++ b/drivers/infiniband/sw/rxe/rxe_verbs.c
@@ -287,7 +287,7 @@  static int rxe_destroy_ah(struct ib_ah *ibah)
 	return 0;
 }
 
-static int post_one_recv(struct rxe_rq *rq, struct ib_recv_wr *ibwr)
+static int post_one_recv(struct rxe_rq *rq, const struct ib_recv_wr *ibwr)
 {
 	int err;
 	int i;
@@ -438,8 +438,8 @@  static int rxe_destroy_srq(struct ib_srq *ibsrq)
 	return 0;
 }
 
-static int rxe_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
-			     struct ib_recv_wr **bad_wr)
+static int rxe_post_srq_recv(struct ib_srq *ibsrq, const struct ib_recv_wr *wr,
+			     const struct ib_recv_wr **bad_wr)
 {
 	int err = 0;
 	unsigned long flags;
@@ -726,8 +726,8 @@  static int post_one_send(struct rxe_qp *qp, const struct ib_send_wr *ibwr,
 	return err;
 }
 
-static int rxe_post_send_kernel(struct rxe_qp *qp, struct ib_send_wr *wr,
-				struct ib_send_wr **bad_wr)
+static int rxe_post_send_kernel(struct rxe_qp *qp, const struct ib_send_wr *wr,
+				const struct ib_send_wr **bad_wr)
 {
 	int err = 0;
 	unsigned int mask;
@@ -769,8 +769,8 @@  static int rxe_post_send_kernel(struct rxe_qp *qp, struct ib_send_wr *wr,
 	return err;
 }
 
-static int rxe_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
-			 struct ib_send_wr **bad_wr)
+static int rxe_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
+			 const struct ib_send_wr **bad_wr)
 {
 	struct rxe_qp *qp = to_rqp(ibqp);
 
@@ -792,8 +792,8 @@  static int rxe_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
 		return rxe_post_send_kernel(qp, wr, bad_wr);
 }
 
-static int rxe_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
-			 struct ib_recv_wr **bad_wr)
+static int rxe_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
+			 const struct ib_recv_wr **bad_wr)
 {
 	int err = 0;
 	struct rxe_qp *qp = to_rqp(ibqp);
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_cm.c b/drivers/infiniband/ulp/ipoib/ipoib_cm.c
index 582f199887b0..37579cd25a47 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_cm.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_cm.c
@@ -94,7 +94,7 @@  static void ipoib_cm_dma_unmap_rx(struct ipoib_dev_priv *priv, int frags,
 static int ipoib_cm_post_receive_srq(struct net_device *dev, int id)
 {
 	struct ipoib_dev_priv *priv = ipoib_priv(dev);
-	struct ib_recv_wr *bad_wr;
+	const struct ib_recv_wr *bad_wr;
 	int i, ret;
 
 	priv->cm.rx_wr.wr_id = id | IPOIB_OP_CM | IPOIB_OP_RECV;
@@ -120,7 +120,7 @@  static int ipoib_cm_post_receive_nonsrq(struct net_device *dev,
 					struct ib_sge *sge, int id)
 {
 	struct ipoib_dev_priv *priv = ipoib_priv(dev);
-	struct ib_recv_wr *bad_wr;
+	const struct ib_recv_wr *bad_wr;
 	int i, ret;
 
 	wr->wr_id = id | IPOIB_OP_CM | IPOIB_OP_RECV;
@@ -212,7 +212,7 @@  static void ipoib_cm_free_rx_ring(struct net_device *dev,
 
 static void ipoib_cm_start_rx_drain(struct ipoib_dev_priv *priv)
 {
-	struct ib_send_wr *bad_wr;
+	const struct ib_send_wr *bad_wr;
 	struct ipoib_cm_rx *p;
 
 	/* We only reserved 1 extra slot in CQ for drain WRs, so
@@ -328,8 +328,7 @@  static int ipoib_cm_modify_rx_qp(struct net_device *dev,
 	return 0;
 }
 
-static void ipoib_cm_init_rx_wr(struct net_device *dev,
-				struct ib_recv_wr *wr,
+static void ipoib_cm_init_rx_wr(struct net_device *dev, struct ib_recv_wr *wr,
 				struct ib_sge *sge)
 {
 	struct ipoib_dev_priv *priv = ipoib_priv(dev);
@@ -699,7 +698,7 @@  static inline int post_send(struct ipoib_dev_priv *priv,
 			    unsigned int wr_id,
 			    struct ipoib_tx_buf *tx_req)
 {
-	struct ib_send_wr *bad_wr;
+	const struct ib_send_wr *bad_wr;
 
 	ipoib_build_sge(priv, tx_req);
 
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ib.c b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
index 5f5d42bad2ea..06a388773351 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_ib.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
@@ -101,7 +101,7 @@  static void ipoib_ud_dma_unmap_rx(struct ipoib_dev_priv *priv,
 static int ipoib_ib_post_receive(struct net_device *dev, int id)
 {
 	struct ipoib_dev_priv *priv = ipoib_priv(dev);
-	struct ib_recv_wr *bad_wr;
+	const struct ib_recv_wr *bad_wr;
 	int ret;
 
 	priv->rx_wr.wr_id   = id | IPOIB_OP_RECV;
@@ -542,7 +542,7 @@  static inline int post_send(struct ipoib_dev_priv *priv,
 			    struct ipoib_tx_buf *tx_req,
 			    void *head, int hlen)
 {
-	struct ib_send_wr *bad_wr;
+	const struct ib_send_wr *bad_wr;
 	struct sk_buff *skb = tx_req->skb;
 
 	ipoib_build_sge(priv, tx_req);
diff --git a/drivers/infiniband/ulp/iser/iser_verbs.c b/drivers/infiniband/ulp/iser/iser_verbs.c
index 616d978cbf2b..eef38c514cfc 100644
--- a/drivers/infiniband/ulp/iser/iser_verbs.c
+++ b/drivers/infiniband/ulp/iser/iser_verbs.c
@@ -1022,7 +1022,8 @@  int iser_post_recvl(struct iser_conn *iser_conn)
 {
 	struct ib_conn *ib_conn = &iser_conn->ib_conn;
 	struct iser_login_desc *desc = &iser_conn->login_desc;
-	struct ib_recv_wr wr, *wr_failed;
+	struct ib_recv_wr wr;
+	const struct ib_recv_wr *wr_failed;
 	int ib_ret;
 
 	desc->sge.addr = desc->rsp_dma;
@@ -1050,7 +1051,8 @@  int iser_post_recvm(struct iser_conn *iser_conn, int count)
 	struct ib_conn *ib_conn = &iser_conn->ib_conn;
 	unsigned int my_rx_head = iser_conn->rx_desc_head;
 	struct iser_rx_desc *rx_desc;
-	struct ib_recv_wr *wr, *wr_failed;
+	struct ib_recv_wr *wr;
+	const struct ib_recv_wr *wr_failed;
 	int i, ib_ret;
 
 	for (wr = ib_conn->rx_wr, i = 0; i < count; i++, wr++) {
@@ -1086,7 +1088,8 @@  int iser_post_recvm(struct iser_conn *iser_conn, int count)
 int iser_post_send(struct ib_conn *ib_conn, struct iser_tx_desc *tx_desc,
 		   bool signal)
 {
-	struct ib_send_wr *bad_wr, *wr = iser_tx_next_wr(tx_desc);
+	const struct ib_send_wr *bad_wr;
+	struct ib_send_wr *wr = iser_tx_next_wr(tx_desc);
 	int ib_ret;
 
 	ib_dma_sync_single_for_device(ib_conn->device->ib_device,
diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c
index 7e056f3c82a0..a96389fa38fb 100644
--- a/drivers/infiniband/ulp/isert/ib_isert.c
+++ b/drivers/infiniband/ulp/isert/ib_isert.c
@@ -810,7 +810,8 @@  isert_cma_handler(struct rdma_cm_id *cma_id, struct rdma_cm_event *event)
 static int
 isert_post_recvm(struct isert_conn *isert_conn, u32 count)
 {
-	struct ib_recv_wr *rx_wr, *rx_wr_failed;
+	struct ib_recv_wr *rx_wr;
+	const struct ib_recv_wr *rx_wr_failed;
 	int i, ret;
 	struct iser_rx_desc *rx_desc;
 
@@ -837,7 +838,8 @@  isert_post_recvm(struct isert_conn *isert_conn, u32 count)
 static int
 isert_post_recv(struct isert_conn *isert_conn, struct iser_rx_desc *rx_desc)
 {
-	struct ib_recv_wr *rx_wr_failed, rx_wr;
+	const struct ib_recv_wr *rx_wr_failed;
+	struct ib_recv_wr rx_wr;
 	int ret;
 
 	if (!rx_desc->in_use) {
@@ -865,7 +867,8 @@  static int
 isert_login_post_send(struct isert_conn *isert_conn, struct iser_tx_desc *tx_desc)
 {
 	struct ib_device *ib_dev = isert_conn->cm_id->device;
-	struct ib_send_wr send_wr, *send_wr_failed;
+	struct ib_send_wr send_wr;
+	const struct ib_send_wr *send_wr_failed;
 	int ret;
 
 	ib_dma_sync_single_for_device(ib_dev, tx_desc->dma_addr,
@@ -968,7 +971,8 @@  isert_init_send_wr(struct isert_conn *isert_conn, struct isert_cmd *isert_cmd,
 static int
 isert_login_post_recv(struct isert_conn *isert_conn)
 {
-	struct ib_recv_wr rx_wr, *rx_wr_fail;
+	struct ib_recv_wr rx_wr;
+	const struct ib_recv_wr *rx_wr_fail;
 	struct ib_sge sge;
 	int ret;
 
@@ -1830,7 +1834,7 @@  isert_send_done(struct ib_cq *cq, struct ib_wc *wc)
 static int
 isert_post_response(struct isert_conn *isert_conn, struct isert_cmd *isert_cmd)
 {
-	struct ib_send_wr *wr_failed;
+	const struct ib_send_wr *wr_failed;
 	int ret;
 
 	ret = isert_post_recv(isert_conn, isert_cmd->rx_desc);
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index 117dc1082e58..6756f998949f 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -1208,7 +1208,7 @@  static void srp_inv_rkey_err_done(struct ib_cq *cq, struct ib_wc *wc)
 static int srp_inv_rkey(struct srp_request *req, struct srp_rdma_ch *ch,
 		u32 rkey)
 {
-	struct ib_send_wr *bad_wr;
+	const struct ib_send_wr *bad_wr;
 	struct ib_send_wr wr = {
 		.opcode		    = IB_WR_LOCAL_INV,
 		.next		    = NULL,
@@ -1500,7 +1500,7 @@  static int srp_map_finish_fr(struct srp_map_state *state,
 {
 	struct srp_target_port *target = ch->target;
 	struct srp_device *dev = target->srp_host->srp_dev;
-	struct ib_send_wr *bad_wr;
+	const struct ib_send_wr *bad_wr;
 	struct ib_reg_wr wr;
 	struct srp_fr_desc *desc;
 	u32 rkey;
@@ -2015,7 +2015,8 @@  static int srp_post_send(struct srp_rdma_ch *ch, struct srp_iu *iu, int len)
 {
 	struct srp_target_port *target = ch->target;
 	struct ib_sge list;
-	struct ib_send_wr wr, *bad_wr;
+	struct ib_send_wr wr;
+	const struct ib_send_wr *bad_wr;
 
 	list.addr   = iu->dma;
 	list.length = len;
@@ -2036,7 +2037,8 @@  static int srp_post_send(struct srp_rdma_ch *ch, struct srp_iu *iu, int len)
 static int srp_post_recv(struct srp_rdma_ch *ch, struct srp_iu *iu)
 {
 	struct srp_target_port *target = ch->target;
-	struct ib_recv_wr wr, *bad_wr;
+	struct ib_recv_wr wr;
+	const struct ib_recv_wr *bad_wr;
 	struct ib_sge list;
 
 	list.addr   = iu->dma;
diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
index 6ab5f50082da..705f6a992d82 100644
--- a/drivers/infiniband/ulp/srpt/ib_srpt.c
+++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
@@ -816,7 +816,8 @@  static int srpt_post_recv(struct srpt_device *sdev, struct srpt_rdma_ch *ch,
 			  struct srpt_recv_ioctx *ioctx)
 {
 	struct ib_sge list;
-	struct ib_recv_wr wr, *bad_wr;
+	struct ib_recv_wr wr;
+	const struct ib_recv_wr *bad_wr;
 
 	BUG_ON(!sdev);
 	list.addr = ioctx->ioctx.dma;
@@ -846,7 +847,7 @@  static int srpt_post_recv(struct srpt_device *sdev, struct srpt_rdma_ch *ch,
  */
 static int srpt_zerolength_write(struct srpt_rdma_ch *ch)
 {
-	struct ib_send_wr *bad_wr;
+	const struct ib_send_wr *bad_wr;
 	struct ib_rdma_wr wr = {
 		.wr = {
 			.next		= NULL,
@@ -2625,7 +2626,8 @@  static int srpt_write_pending(struct se_cmd *se_cmd)
 	struct srpt_send_ioctx *ioctx =
 		container_of(se_cmd, struct srpt_send_ioctx, cmd);
 	struct srpt_rdma_ch *ch = ioctx->ch;
-	struct ib_send_wr *first_wr = NULL, *bad_wr;
+	struct ib_send_wr *first_wr = NULL;
+	const struct ib_send_wr *bad_wr;
 	struct ib_cqe *cqe = &ioctx->rdma_cqe;
 	enum srpt_command_state new_state;
 	int ret, i;
@@ -2687,7 +2689,8 @@  static void srpt_queue_response(struct se_cmd *cmd)
 		container_of(cmd, struct srpt_send_ioctx, cmd);
 	struct srpt_rdma_ch *ch = ioctx->ch;
 	struct srpt_device *sdev = ch->sport->sdev;
-	struct ib_send_wr send_wr, *first_wr = &send_wr, *bad_wr;
+	struct ib_send_wr send_wr, *first_wr = &send_wr;
+	const struct ib_send_wr *bad_wr;
 	struct ib_sge sge;
 	enum srpt_command_state state;
 	int resp_len, ret, i;
diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c
index c9424da0d23e..89848f970908 100644
--- a/drivers/nvme/host/rdma.c
+++ b/drivers/nvme/host/rdma.c
@@ -1038,7 +1038,7 @@  static void nvme_rdma_inv_rkey_done(struct ib_cq *cq, struct ib_wc *wc)
 static int nvme_rdma_inv_rkey(struct nvme_rdma_queue *queue,
 		struct nvme_rdma_request *req)
 {
-	struct ib_send_wr *bad_wr;
+	const struct ib_send_wr *bad_wr;
 	struct ib_send_wr wr = {
 		.opcode		    = IB_WR_LOCAL_INV,
 		.next		    = NULL,
@@ -1244,7 +1244,8 @@  static int nvme_rdma_post_send(struct nvme_rdma_queue *queue,
 		struct nvme_rdma_qe *qe, struct ib_sge *sge, u32 num_sge,
 		struct ib_send_wr *first)
 {
-	struct ib_send_wr wr, *bad_wr;
+	struct ib_send_wr wr;
+	const struct ib_send_wr *bad_wr;
 	int ret;
 
 	sge->addr   = qe->dma;
@@ -1274,7 +1275,8 @@  static int nvme_rdma_post_send(struct nvme_rdma_queue *queue,
 static int nvme_rdma_post_recv(struct nvme_rdma_queue *queue,
 		struct nvme_rdma_qe *qe)
 {
-	struct ib_recv_wr wr, *bad_wr;
+	struct ib_recv_wr wr;
+	const struct ib_recv_wr *bad_wr;
 	struct ib_sge list;
 	int ret;
 
diff --git a/drivers/nvme/target/rdma.c b/drivers/nvme/target/rdma.c
index 0d7f3d603f1d..dc294be2e81f 100644
--- a/drivers/nvme/target/rdma.c
+++ b/drivers/nvme/target/rdma.c
@@ -382,7 +382,7 @@  static void nvmet_rdma_free_rsps(struct nvmet_rdma_queue *queue)
 static int nvmet_rdma_post_recv(struct nvmet_rdma_device *ndev,
 		struct nvmet_rdma_cmd *cmd)
 {
-	struct ib_recv_wr *bad_wr;
+	const struct ib_recv_wr *bad_wr;
 
 	ib_dma_sync_single_for_device(ndev->device,
 		cmd->sge[0].addr, cmd->sge[0].length,
@@ -472,7 +472,8 @@  static void nvmet_rdma_queue_response(struct nvmet_req *req)
 	struct nvmet_rdma_rsp *rsp =
 		container_of(req, struct nvmet_rdma_rsp, req);
 	struct rdma_cm_id *cm_id = rsp->queue->cm_id;
-	struct ib_send_wr *first_wr, *bad_wr;
+	struct ib_send_wr *first_wr;
+	const struct ib_send_wr *bad_wr;
 
 	if (rsp->flags & NVMET_RDMA_REQ_INVALIDATE_RKEY) {
 		rsp->send_wr.opcode = IB_WR_SEND_WITH_INV;
diff --git a/fs/cifs/smbdirect.c b/fs/cifs/smbdirect.c
index c5a1cddd8856..51cdfc31ff10 100644
--- a/fs/cifs/smbdirect.c
+++ b/fs/cifs/smbdirect.c
@@ -801,7 +801,8 @@  static int smbd_ia_open(
  */
 static int smbd_post_send_negotiate_req(struct smbd_connection *info)
 {
-	struct ib_send_wr send_wr, *send_wr_fail;
+	struct ib_send_wr send_wr;
+	const struct ib_send_wr *send_wr_fail;
 	int rc = -ENOMEM;
 	struct smbd_request *request;
 	struct smbd_negotiate_req *packet;
@@ -1023,7 +1024,8 @@  static void smbd_destroy_header(struct smbd_connection *info,
 static int smbd_post_send(struct smbd_connection *info,
 		struct smbd_request *request, bool has_payload)
 {
-	struct ib_send_wr send_wr, *send_wr_fail;
+	struct ib_send_wr send_wr;
+	const struct ib_send_wr *send_wr_fail;
 	int rc, i;
 
 	for (i = 0; i < request->num_sge; i++) {
@@ -1183,7 +1185,8 @@  static int smbd_post_send_data(
 static int smbd_post_recv(
 		struct smbd_connection *info, struct smbd_response *response)
 {
-	struct ib_recv_wr recv_wr, *recv_wr_fail = NULL;
+	struct ib_recv_wr recv_wr;
+	const struct ib_recv_wr *recv_wr_fail = NULL;
 	int rc = -EIO;
 
 	response->sge.addr = ib_dma_map_single(
@@ -2488,7 +2491,7 @@  struct smbd_mr *smbd_register_mr(
 	int rc, i;
 	enum dma_data_direction dir;
 	struct ib_reg_wr *reg_wr;
-	struct ib_send_wr *bad_wr;
+	const struct ib_send_wr *bad_wr;
 
 	if (num_pages > info->max_frmr_depth) {
 		log_rdma_mr(ERR, "num_pages=%d max_frmr_depth=%d\n",
@@ -2607,7 +2610,8 @@  static void local_inv_done(struct ib_cq *cq, struct ib_wc *wc)
  */
 int smbd_deregister_mr(struct smbd_mr *smbdirect_mr)
 {
-	struct ib_send_wr *wr, *bad_wr;
+	struct ib_send_wr *wr;
+	const struct ib_send_wr *bad_wr;
 	struct smbd_connection *info = smbdirect_mr->conn;
 	int rc = 0;
 
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index e8cf479ad5df..1b9e882973ef 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -2391,8 +2391,8 @@  struct ib_device {
 						struct ib_srq_attr *srq_attr);
 	int                        (*destroy_srq)(struct ib_srq *srq);
 	int                        (*post_srq_recv)(struct ib_srq *srq,
-						    struct ib_recv_wr *recv_wr,
-						    struct ib_recv_wr **bad_recv_wr);
+						    const struct ib_recv_wr *recv_wr,
+						    const struct ib_recv_wr **bad_recv_wr);
 	struct ib_qp *             (*create_qp)(struct ib_pd *pd,
 						struct ib_qp_init_attr *qp_init_attr,
 						struct ib_udata *udata);
@@ -2406,11 +2406,11 @@  struct ib_device {
 					       struct ib_qp_init_attr *qp_init_attr);
 	int                        (*destroy_qp)(struct ib_qp *qp);
 	int                        (*post_send)(struct ib_qp *qp,
-						struct ib_send_wr *send_wr,
-						struct ib_send_wr **bad_send_wr);
+						const struct ib_send_wr *send_wr,
+						const struct ib_send_wr **bad_send_wr);
 	int                        (*post_recv)(struct ib_qp *qp,
-						struct ib_recv_wr *recv_wr,
-						struct ib_recv_wr **bad_recv_wr);
+						const struct ib_recv_wr *recv_wr,
+						const struct ib_recv_wr **bad_recv_wr);
 	struct ib_cq *             (*create_cq)(struct ib_device *device,
 						const struct ib_cq_init_attr *attr,
 						struct ib_ucontext *context,
@@ -3292,8 +3292,8 @@  int ib_destroy_srq(struct ib_srq *srq);
  *   the work request that failed to be posted on the QP.
  */
 static inline int ib_post_srq_recv(struct ib_srq *srq,
-				   struct ib_recv_wr *recv_wr,
-				   struct ib_recv_wr **bad_recv_wr)
+				   const struct ib_recv_wr *recv_wr,
+				   const struct ib_recv_wr **bad_recv_wr)
 {
 	return srq->device->post_srq_recv(srq, recv_wr, bad_recv_wr);
 }
@@ -3393,8 +3393,8 @@  int ib_close_qp(struct ib_qp *qp);
  * earlier work requests in the list.
  */
 static inline int ib_post_send(struct ib_qp *qp,
-			       struct ib_send_wr *send_wr,
-			       struct ib_send_wr **bad_send_wr)
+			       const struct ib_send_wr *send_wr,
+			       const struct ib_send_wr **bad_send_wr)
 {
 	return qp->device->post_send(qp, send_wr, bad_send_wr);
 }
@@ -3408,8 +3408,8 @@  static inline int ib_post_send(struct ib_qp *qp,
  *   the work request that failed to be posted on the QP.
  */
 static inline int ib_post_recv(struct ib_qp *qp,
-			       struct ib_recv_wr *recv_wr,
-			       struct ib_recv_wr **bad_recv_wr)
+			       const struct ib_recv_wr *recv_wr,
+			       const struct ib_recv_wr **bad_recv_wr)
 {
 	return qp->device->post_recv(qp, recv_wr, bad_recv_wr);
 }
diff --git a/net/9p/trans_rdma.c b/net/9p/trans_rdma.c
index 3d414acb7015..b00cdc47aded 100644
--- a/net/9p/trans_rdma.c
+++ b/net/9p/trans_rdma.c
@@ -396,7 +396,8 @@  static int
 post_recv(struct p9_client *client, struct p9_rdma_context *c)
 {
 	struct p9_trans_rdma *rdma = client->trans;
-	struct ib_recv_wr wr, *bad_wr;
+	struct ib_recv_wr wr;
+	const struct ib_recv_wr *bad_wr;
 	struct ib_sge sge;
 
 	c->busa = ib_dma_map_single(rdma->cm_id->device,
@@ -425,7 +426,8 @@  post_recv(struct p9_client *client, struct p9_rdma_context *c)
 static int rdma_request(struct p9_client *client, struct p9_req_t *req)
 {
 	struct p9_trans_rdma *rdma = client->trans;
-	struct ib_send_wr wr, *bad_wr;
+	struct ib_send_wr wr;
+	const struct ib_send_wr *bad_wr;
 	struct ib_sge sge;
 	int err = 0;
 	unsigned long flags;
diff --git a/net/rds/ib_frmr.c b/net/rds/ib_frmr.c
index 48332a6ed738..26700294ac6a 100644
--- a/net/rds/ib_frmr.c
+++ b/net/rds/ib_frmr.c
@@ -102,7 +102,7 @@  static void rds_ib_free_frmr(struct rds_ib_mr *ibmr, bool drop)
 static int rds_ib_post_reg_frmr(struct rds_ib_mr *ibmr)
 {
 	struct rds_ib_frmr *frmr = &ibmr->u.frmr;
-	struct ib_send_wr *failed_wr;
+	const struct ib_send_wr *failed_wr;
 	struct ib_reg_wr reg_wr;
 	int ret, off = 0;
 
@@ -230,7 +230,8 @@  static int rds_ib_map_frmr(struct rds_ib_device *rds_ibdev,
 
 static int rds_ib_post_inv(struct rds_ib_mr *ibmr)
 {
-	struct ib_send_wr *s_wr, *failed_wr;
+	struct ib_send_wr *s_wr;
+	const struct ib_send_wr *failed_wr;
 	struct rds_ib_frmr *frmr = &ibmr->u.frmr;
 	struct rdma_cm_id *i_cm_id = ibmr->ic->i_cm_id;
 	int ret = -EINVAL;
diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
index b4e421aa9727..8b19d29f2869 100644
--- a/net/rds/ib_recv.c
+++ b/net/rds/ib_recv.c
@@ -383,7 +383,7 @@  void rds_ib_recv_refill(struct rds_connection *conn, int prefill, gfp_t gfp)
 {
 	struct rds_ib_connection *ic = conn->c_transport_data;
 	struct rds_ib_recv_work *recv;
-	struct ib_recv_wr *failed_wr;
+	const struct ib_recv_wr *failed_wr;
 	unsigned int posted = 0;
 	int ret = 0;
 	bool can_wait = !!(gfp & __GFP_DIRECT_RECLAIM);
@@ -650,7 +650,7 @@  static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
 static void rds_ib_send_ack(struct rds_ib_connection *ic, unsigned int adv_credits)
 {
 	struct rds_header *hdr = ic->i_ack;
-	struct ib_send_wr *failed_wr;
+	const struct ib_send_wr *failed_wr;
 	u64 seq;
 	int ret;
 
diff --git a/net/rds/ib_send.c b/net/rds/ib_send.c
index 8557a1cae041..8ac80c1b051e 100644
--- a/net/rds/ib_send.c
+++ b/net/rds/ib_send.c
@@ -492,7 +492,7 @@  int rds_ib_xmit(struct rds_connection *conn, struct rds_message *rm,
 	struct rds_ib_send_work *send = NULL;
 	struct rds_ib_send_work *first;
 	struct rds_ib_send_work *prev;
-	struct ib_send_wr *failed_wr;
+	const struct ib_send_wr *failed_wr;
 	struct scatterlist *scat;
 	u32 pos;
 	u32 i;
@@ -758,7 +758,7 @@  int rds_ib_xmit_atomic(struct rds_connection *conn, struct rm_atomic_op *op)
 {
 	struct rds_ib_connection *ic = conn->c_transport_data;
 	struct rds_ib_send_work *send = NULL;
-	struct ib_send_wr *failed_wr;
+	const struct ib_send_wr *failed_wr;
 	struct rds_ib_device *rds_ibdev;
 	u32 pos;
 	u32 work_alloc;
@@ -849,7 +849,7 @@  int rds_ib_xmit_rdma(struct rds_connection *conn, struct rm_rdma_op *op)
 	struct rds_ib_send_work *send = NULL;
 	struct rds_ib_send_work *first;
 	struct rds_ib_send_work *prev;
-	struct ib_send_wr *failed_wr;
+	const struct ib_send_wr *failed_wr;
 	struct scatterlist *scat;
 	unsigned long len;
 	u64 remote_addr = op->op_remote_addr;
diff --git a/net/smc/smc_tx.c b/net/smc/smc_tx.c
index cee666400752..cb6a7fc8a219 100644
--- a/net/smc/smc_tx.c
+++ b/net/smc/smc_tx.c
@@ -255,7 +255,7 @@  static int smc_tx_rdma_write(struct smc_connection *conn, int peer_rmbe_offset,
 			     int num_sges, struct ib_sge sges[])
 {
 	struct smc_link_group *lgr = conn->lgr;
-	struct ib_send_wr *failed_wr = NULL;
+	const struct ib_send_wr *failed_wr = NULL;
 	struct ib_rdma_wr rdma_wr;
 	struct smc_link *link;
 	int rc;
diff --git a/net/smc/smc_wr.c b/net/smc/smc_wr.c
index dbd2605d1962..91e9d98918a0 100644
--- a/net/smc/smc_wr.c
+++ b/net/smc/smc_wr.c
@@ -240,7 +240,7 @@  int smc_wr_tx_put_slot(struct smc_link *link,
  */
 int smc_wr_tx_send(struct smc_link *link, struct smc_wr_tx_pend_priv *priv)
 {
-	struct ib_send_wr *failed_wr = NULL;
+	const struct ib_send_wr *failed_wr = NULL;
 	struct smc_wr_tx_pend *pend;
 	int rc;
 
@@ -263,7 +263,7 @@  int smc_wr_tx_send(struct smc_link *link, struct smc_wr_tx_pend_priv *priv)
 /* Register a memory region and wait for result. */
 int smc_wr_reg_send(struct smc_link *link, struct ib_mr *mr)
 {
-	struct ib_send_wr *failed_wr = NULL;
+	const struct ib_send_wr *failed_wr = NULL;
 	int rc;
 
 	ib_req_notify_cq(link->smcibdev->roce_cq_send,
diff --git a/net/smc/smc_wr.h b/net/smc/smc_wr.h
index 210bec3c3ebe..df4070447ef9 100644
--- a/net/smc/smc_wr.h
+++ b/net/smc/smc_wr.h
@@ -63,7 +63,7 @@  static inline void smc_wr_tx_set_wr_id(atomic_long_t *wr_tx_id, long val)
 /* post a new receive work request to fill a completed old work request entry */
 static inline int smc_wr_rx_post(struct smc_link *link)
 {
-	struct ib_recv_wr *bad_recv_wr = NULL;
+	const struct ib_recv_wr *bad_recv_wr = NULL;
 	int rc;
 	u64 wr_id, temp_wr_id;
 	u32 index;
diff --git a/net/sunrpc/xprtrdma/fmr_ops.c b/net/sunrpc/xprtrdma/fmr_ops.c
index 17fb1e025654..777678d11efd 100644
--- a/net/sunrpc/xprtrdma/fmr_ops.c
+++ b/net/sunrpc/xprtrdma/fmr_ops.c
@@ -279,7 +279,7 @@  fmr_op_map(struct rpcrdma_xprt *r_xprt, struct rpcrdma_mr_seg *seg,
 static int
 fmr_op_send(struct rpcrdma_ia *ia, struct rpcrdma_req *req)
 {
-	struct ib_send_wr *bad_wr;
+	const struct ib_send_wr *bad_wr;
 
 	return ib_post_send(ia->ri_id->qp, &req->rl_sendctx->sc_wr, &bad_wr);
 }
diff --git a/net/sunrpc/xprtrdma/frwr_ops.c b/net/sunrpc/xprtrdma/frwr_ops.c
index c040de196e13..c7688e4a1ef4 100644
--- a/net/sunrpc/xprtrdma/frwr_ops.c
+++ b/net/sunrpc/xprtrdma/frwr_ops.c
@@ -464,7 +464,8 @@  frwr_op_map(struct rpcrdma_xprt *r_xprt, struct rpcrdma_mr_seg *seg,
 static int
 frwr_op_send(struct rpcrdma_ia *ia, struct rpcrdma_req *req)
 {
-	struct ib_send_wr *post_wr, *bad_wr;
+	struct ib_send_wr *post_wr;
+	const struct ib_send_wr *bad_wr;
 	struct rpcrdma_mr *mr;
 
 	post_wr = &req->rl_sendctx->sc_wr;
@@ -517,7 +518,8 @@  frwr_op_reminv(struct rpcrdma_rep *rep, struct list_head *mrs)
 static void
 frwr_op_unmap_sync(struct rpcrdma_xprt *r_xprt, struct list_head *mrs)
 {
-	struct ib_send_wr *first, **prev, *last, *bad_wr;
+	struct ib_send_wr *first, **prev, *last;
+	const struct ib_send_wr *bad_wr;
 	struct rpcrdma_ia *ia = &r_xprt->rx_ia;
 	struct rpcrdma_frwr *frwr;
 	struct rpcrdma_mr *mr;
diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
index 841fca143804..d4dbd853e75e 100644
--- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
+++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
@@ -229,7 +229,7 @@  void svc_rdma_recv_ctxt_put(struct svcxprt_rdma *rdma,
 static int __svc_rdma_post_recv(struct svcxprt_rdma *rdma,
 				struct svc_rdma_recv_ctxt *ctxt)
 {
-	struct ib_recv_wr *bad_recv_wr;
+	const struct ib_recv_wr *bad_recv_wr;
 	int ret;
 
 	svc_xprt_get(&rdma->sc_xprt);
diff --git a/net/sunrpc/xprtrdma/svc_rdma_rw.c b/net/sunrpc/xprtrdma/svc_rdma_rw.c
index ce3ea8419704..04cb3363172a 100644
--- a/net/sunrpc/xprtrdma/svc_rdma_rw.c
+++ b/net/sunrpc/xprtrdma/svc_rdma_rw.c
@@ -307,7 +307,8 @@  static int svc_rdma_post_chunk_ctxt(struct svc_rdma_chunk_ctxt *cc)
 {
 	struct svcxprt_rdma *rdma = cc->cc_rdma;
 	struct svc_xprt *xprt = &rdma->sc_xprt;
-	struct ib_send_wr *first_wr, *bad_wr;
+	struct ib_send_wr *first_wr;
+	const struct ib_send_wr *bad_wr;
 	struct list_head *tmp;
 	struct ib_cqe *cqe;
 	int ret;
diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
index 4a3efaea277c..7676053f2df9 100644
--- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
+++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
@@ -291,7 +291,7 @@  static void svc_rdma_wc_send(struct ib_cq *cq, struct ib_wc *wc)
  */
 int svc_rdma_send(struct svcxprt_rdma *rdma, struct ib_send_wr *wr)
 {
-	struct ib_send_wr *bad_wr;
+	const struct ib_send_wr *bad_wr;
 	int ret;
 
 	might_sleep();
diff --git a/net/sunrpc/xprtrdma/verbs.c b/net/sunrpc/xprtrdma/verbs.c
index 112a15abc4a4..02d8fdad12ff 100644
--- a/net/sunrpc/xprtrdma/verbs.c
+++ b/net/sunrpc/xprtrdma/verbs.c
@@ -1516,7 +1516,8 @@  void
 rpcrdma_post_recvs(struct rpcrdma_xprt *r_xprt, bool temp)
 {
 	struct rpcrdma_buffer *buf = &r_xprt->rx_buf;
-	struct ib_recv_wr *wr, *bad_wr;
+	struct ib_recv_wr *wr;
+	struct ib_recv_wr *bad_wr;
 	int needed, count, rc;
 
 	needed = buf->rb_credits + (buf->rb_bc_srv_max_requests << 1);
@@ -1559,7 +1560,8 @@  rpcrdma_post_recvs(struct rpcrdma_xprt *r_xprt, bool temp)
 	if (!count)
 		return;
 
-	rc = ib_post_recv(r_xprt->rx_ia.ri_id->qp, wr, &bad_wr);
+	rc = ib_post_recv(r_xprt->rx_ia.ri_id->qp, wr,
+			  (const struct ib_recv_wr **)&bad_wr);
 	if (rc) {
 		for (wr = bad_wr; wr; wr = wr->next) {
 			struct rpcrdma_rep *rep;