Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2836431pxv; Mon, 12 Jul 2021 03:09:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwIrIhCocS6AjIiJx0Pk2y9tKqg0A7bXi88uu9jGbhHW6S8fMgxgcJwpxpZGbj+Smpg6AI0 X-Received: by 2002:a02:c806:: with SMTP id p6mr30654255jao.19.1626084541632; Mon, 12 Jul 2021 03:09:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626084541; cv=none; d=google.com; s=arc-20160816; b=BVZVXG+0idaiLZrfwQsTfDk30uVkuxA5iPRK2ipCF97MTpJY+3TgExrN4gPFTL/j9S y24JsvbqWhwtV35rkfCj+ffRQR9xVlHPUsRWAF1jjtf328vn2Mdk1hLbRcx3yTEsP5Zp CEKIwEZhWPWLjcRDCqxGA6/42XHezmt1aM/pbXL2qc8xLTb9Tfgp/833oZKnk3QNcNvd 24DONlYr3X0rq/feo/Ys7uGDp6T8ewh5bJxcA/GtT28w2p5yqJ8NIoKCibImzMToijng rrKbqtrSsQyN133MVYKE2iPXZbGgnLaKkQIGprCdKgbNNt9bAaRWZc8utZ58iM9fu8SR Gmpw== 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=jnYlwGeOgyV+2XpnWDIGwzdfDpUfVLbqcAixD13OMYM=; b=eC4+8ndHFJ55p50Uroqfw47aDxkdOeZ406m7SJETLnpLnJwW2xT5wCaTV7bqDXtON2 be5LpbbmTGtmeM7kYMYl26iylN+QFJx4Q2Wtt/ZUezxCHZx+Ob08nuH6oKrFuU0d2zlT 8Px+Uo4e3utg9JU/soo0LHrLNl93nPdeXIInQ6Ops4TwZCKbDepLY0uIWUKXpomiOapP RPzsYIUIoLcokjzcmv6HEHhXiV355slxHKHcAAv0G5/u3XH3j33TJBFe1TGDkM0DWkWa 1x+U/d9tFqnNlwX3bTzzquSxOIOolg4vA1ZNjl7LS9uSNaiRwKuSXJ7vmL4Ca7DW9TY9 F75w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=w8iVbJRz; 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 i11si17201618jaj.16.2021.07.12.03.08.50; Mon, 12 Jul 2021 03:09:01 -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=w8iVbJRz; 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 S1348418AbhGLHzh (ORCPT + 99 others); Mon, 12 Jul 2021 03:55:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:56246 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244940AbhGLHTP (ORCPT ); Mon, 12 Jul 2021 03:19:15 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 452AD610A6; Mon, 12 Jul 2021 07:16:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626074187; bh=JAP3cuzghKjeXSy/byvWtbu3KZU0skWbKJ6bO9HiEEM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=w8iVbJRzJYHnEF9yaz9MkDtmaXovfeOCWqvZlveqvnkqCeZrUWVPIoUgghOxGdLTF 2f/HWvaNPw2CK2ANMiTf2GmvSm1+eh8JdCHJstGw4PxUzsEhE0Qic1Z+7vOyaeznHz O/HAhSXtEUgUWmcUs+r/tQXB80QPH6XDdcycA9f4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?H=C3=A5kon=20Bugge?= , Leon Romanovsky , Jason Gunthorpe , Sasha Levin Subject: [PATCH 5.12 495/700] RDMA/cma: Fix incorrect Packet Lifetime calculation Date: Mon, 12 Jul 2021 08:09:38 +0200 Message-Id: <20210712061029.175960474@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060924.797321836@linuxfoundation.org> References: <20210712060924.797321836@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: Håkon Bugge [ Upstream commit e84045eab69c625bc0b0bf24d8e05bc65da1eed1 ] An approximation for the PacketLifeTime is half the local ACK timeout. The encoding for both timers are logarithmic. If the local ACK timeout is set, but zero, it means the timer is disabled. In this case, we choose the CMA_IBOE_PACKET_LIFETIME value, since 50% of infinite makes no sense. Before this commit, the PacketLifeTime became 255 if local ACK timeout was zero (not running). Fixed by explicitly testing for timeout being zero. Fixes: e1ee1e62bec4 ("RDMA/cma: Use ACK timeout for RoCE packetLifeTime") Link: https://lore.kernel.org/r/1624371207-26710-1-git-send-email-haakon.bugge@oracle.com Signed-off-by: Håkon Bugge Reviewed-by: Leon Romanovsky Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- drivers/infiniband/core/cma.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 2f5f384987a2..68bbcecb0a6a 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -3060,8 +3060,10 @@ static int cma_resolve_iboe_route(struct rdma_id_private *id_priv) * as a reasonable approximation for RoCE networks. */ mutex_lock(&id_priv->qp_mutex); - route->path_rec->packet_life_time = id_priv->timeout_set ? - id_priv->timeout - 1 : CMA_IBOE_PACKET_LIFETIME; + if (id_priv->timeout_set && id_priv->timeout) + route->path_rec->packet_life_time = id_priv->timeout - 1; + else + route->path_rec->packet_life_time = CMA_IBOE_PACKET_LIFETIME; mutex_unlock(&id_priv->qp_mutex); if (!route->path_rec->mtu) { -- 2.30.2