Re: [PATCH for-next 02/12] IB/hfi1: Convert the macro AHG_HEADER_SET into an inline function

Leon Romanovsky
2017-09-27T15:21:18Z

[-- Attachment #1: Type: text/plain, Size: 1996 bytes --]

On Tue, Sep 26, 2017 at 07:00:11AM -0700, Dennis Dalessandro wrote:
> From: Harish Chegondi <harish.chegondi-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
>
> AHG_HEADER_SET macro doesn't conform to the coding standards as it can
> affect the control flow. Convert the macro AHG_HEADER_SET into an inline
> function ahg_header_set().
>
> Cc: Leon Romanovsky <leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
> Reviewed-by: Mike Marciniszyn <mike.marciniszyn-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Signed-off-by: Harish Chegondi <harish.chegondi-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Signed-off-by: Dennis Dalessandro <dennis.dalessandro-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> ---
> drivers/infiniband/hw/hfi1/user_sdma.c | 58 ++++++++++++++++++++++----------
> drivers/infiniband/hw/hfi1/user_sdma.h | 29 +++++++++++-----
> 2 files changed, 59 insertions(+), 28 deletions(-)
>
> diff --git a/drivers/infiniband/hw/hfi1/user_sdma.c b/drivers/infiniband/hw/hfi1/user_sdma.c
> index c0c0e04..4ea29ed 100644
> --- a/drivers/infiniband/hw/hfi1/user_sdma.c
> +++ b/drivers/infiniband/hw/hfi1/user_sdma.c
> @@ -1254,20 +1254,25 @@ static int set_txreq_header_ahg(struct user_sdma_request *req,
> struct user_sdma_txreq *tx, u32 datalen)
> {
> u32 ahg[AHG_KDETH_ARRAY_SIZE];
> - int diff = 0;
> + int idx = 0;
> u8 omfactor; /* KDETH.OM */
> struct hfi1_user_sdma_pkt_q *pq = req->pq;
> struct hfi1_pkt_header *hdr = &req->hdr;
> u16 pbclen = le16_to_cpu(hdr->pbc[0]);
> u32 val32, tidval = 0, lrhlen = get_lrh_len(*hdr, pad_len(datalen));
> + size_t array_size = ARRAY_SIZE(ahg);
>
> if (PBC2LRH(pbclen) != lrhlen) {
> /* PBC.PbcLengthDWs */
> - AHG_HEADER_SET(ahg, diff, 0, 0, 12,
> - cpu_to_le16(LRH2PBC(lrhlen)));
> + idx = ahg_header_set(ahg, idx, array_size, 0, 0, 12,
> + (__force u16)cpu_to_le16(LRH2PBC(lrhlen)));

This "__force" looks suspicious to me and I think you have an error here by
using cpu_to_le16 instead of cpu_to_be16.

Thanks

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]