Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp3963430pxb; Mon, 4 Oct 2021 13:50:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxmgxT+DvevE8ysk6BNpjiWlAkdEgAe01T9H2VCv1GDdukeKbuTlPo8EbGW92m9cIximhxl X-Received: by 2002:aa7:dcc5:: with SMTP id w5mr3667613edu.169.1633380614380; Mon, 04 Oct 2021 13:50:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633380614; cv=none; d=google.com; s=arc-20160816; b=t//I3Z1OJIdPPiBkZPGt3/TzPZnF8THd53U0Rum+Sc+lSa8NSvvYWyxT0rcNjGBT0V zrYHZeEEfncKZ5PsvdMV9oW+yr5OvVccR49SvgaGALKlnOikQ/fqPqjyYT5ON6J8aocc jgONaM9Bkz8ymiFOXN3qiLgRf6sWFFsoI84Uc4eJUn7DGpfSDnOPAcc7fWqCV6N3a3Rw BRVE9SmY3OXoy4eE6ZydBWRuSS2vnO6daXqZG0f52VC+RQVBj7EjGgCd8T1mMYYXgsSa q7X3HpOOvKMUOGrgF6Pg292ZuMmLv7qDNRf5SKleH7YGuEv/+fYOttCcAa4fOEzjARbc WlXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vRrZbUOqwMblFMrB2lJ3mqpJrEZiFVKMM8NUebiUEGY=; b=Hbo4+faD3nFNGjhH6c1Zyz5CZPoIDyA2+7sQySv0d18bbE17tT75HmypHC+PJCPELy 0Uw+1YPdTwiU5GiAPnxrZDQI8S5YDwQHyuhV0AAPJ3gnVDUM6iLjMN9kt7xj7CMWqFHn TEzBHsRGb9J/rWgDYBuDy/5fwAFgyafU9DRPUqnyJZfaK+xWZgAH1Xs/NRrEjce8uSOT NmeQFV4b2nt1DRFFBFZXrovayY+NMZewU5AlU3gyiZdVJIl8aXpfso1x3D02eLvFAUKL DlKEQKahaw3ntUo7W3bqsRmbYqzppUtUw+1zcIREqTdSuomMUixwbbwpimhIMAPPce1p M+yA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ZbuHFIUC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g14si17610528ejj.426.2021.10.04.13.49.49; Mon, 04 Oct 2021 13:50:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ZbuHFIUC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238307AbhJDNkO (ORCPT + 99 others); Mon, 4 Oct 2021 09:40:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:51592 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238392AbhJDNi2 (ORCPT ); Mon, 4 Oct 2021 09:38:28 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 89C1C61452; Mon, 4 Oct 2021 13:17:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1633353446; bh=Ko+dduaZiB2EhbGu7/niHXZHWa8H/muRU8/PhXJN4hM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZbuHFIUCbNSCI2e23UWx14LER2V8dyftogEiTk7AG32yDsIuZF38c1pFgcf3Hf+bj cvBeoA2aiEc4eNwbUjZsvM+gXpqi+ZCb0XnkjN/gSGj/GXxuEgbBc1IP+WTP5LpkOz TId6jQDUYQpbXn1t5TmGowX7rRIeHbeAB/nkCR4A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Geert Uytterhoeven , Jason Gunthorpe , Sasha Levin Subject: [PATCH 5.14 098/172] RDMA/hns: Work around broken constant propagation in gcc 8 Date: Mon, 4 Oct 2021 14:52:28 +0200 Message-Id: <20211004125048.149741508@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211004125044.945314266@linuxfoundation.org> References: <20211004125044.945314266@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jason Gunthorpe [ Upstream commit 14351f08ed5c8b888cdd95651152db7e096ee27f ] gcc 8.3 and 5.4 throw this: In function 'modify_qp_init_to_rtr', ././include/linux/compiler_types.h:322:38: error: call to '__compiletime_assert_1859' declared with attribute error: FIELD_PREP: value too large for the field _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__) [..] drivers/infiniband/hw/hns/hns_roce_common.h:91:52: note: in expansion of macro 'FIELD_PREP' *((__le32 *)ptr + (field_h) / 32) |= cpu_to_le32(FIELD_PREP( \ ^~~~~~~~~~ drivers/infiniband/hw/hns/hns_roce_common.h:95:39: note: in expansion of macro '_hr_reg_write' #define hr_reg_write(ptr, field, val) _hr_reg_write(ptr, field, val) ^~~~~~~~~~~~~ drivers/infiniband/hw/hns/hns_roce_hw_v2.c:4412:2: note: in expansion of macro 'hr_reg_write' hr_reg_write(context, QPC_LP_PKTN_INI, lp_pktn_ini); Because gcc has miscalculated the constantness of lp_pktn_ini: mtu = ib_mtu_enum_to_int(ib_mtu); if (WARN_ON(mtu < 0)) [..] lp_pktn_ini = ilog2(MAX_LP_MSG_LEN / mtu); Since mtu is limited to {256,512,1024,2048,4096} lp_pktn_ini is between 4 and 8 which is compatible with the 4 bit field in the FIELD_PREP. Work around this broken compiler by adding a 'can never be true' constraint on lp_pktn_ini's value which clears out the problem. Fixes: f0cb411aad23 ("RDMA/hns: Use new interface to modify QP context") Link: https://lore.kernel.org/r/0-v1-c773ecb137bc+11f-hns_gcc8_jgg@nvidia.com Reported-by: Geert Uytterhoeven Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c index c320891c8763..6cb4a4e10837 100644 --- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c @@ -4411,7 +4411,12 @@ static int modify_qp_init_to_rtr(struct ib_qp *ibqp, hr_qp->path_mtu = ib_mtu; mtu = ib_mtu_enum_to_int(ib_mtu); - if (WARN_ON(mtu < 0)) + if (WARN_ON(mtu <= 0)) + return -EINVAL; +#define MAX_LP_MSG_LEN 65536 + /* MTU * (2 ^ LP_PKTN_INI) shouldn't be bigger than 64KB */ + lp_pktn_ini = ilog2(MAX_LP_MSG_LEN / mtu); + if (WARN_ON(lp_pktn_ini >= 0xF)) return -EINVAL; if (attr_mask & IB_QP_PATH_MTU) { @@ -4419,10 +4424,6 @@ static int modify_qp_init_to_rtr(struct ib_qp *ibqp, hr_reg_clear(qpc_mask, QPC_MTU); } -#define MAX_LP_MSG_LEN 65536 - /* MTU * (2 ^ LP_PKTN_INI) shouldn't be bigger than 64KB */ - lp_pktn_ini = ilog2(MAX_LP_MSG_LEN / mtu); - hr_reg_write(context, QPC_LP_PKTN_INI, lp_pktn_ini); hr_reg_clear(qpc_mask, QPC_LP_PKTN_INI); -- 2.33.0