Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1176993yba; Thu, 9 May 2019 12:02:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqxhyUuPfNeUVbr+UiqR1dqpsIo4sEWjD6ZIAChtoxYL8shbedDoqWyKVcmIU2JP3Ra9B1NP X-Received: by 2002:a62:4d03:: with SMTP id a3mr7898787pfb.2.1557428553410; Thu, 09 May 2019 12:02:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557428553; cv=none; d=google.com; s=arc-20160816; b=W1rLGfGY5qQyecFNX4cMcCpTwOspi7IY0+czYQzfnPG6nspiMgjoh+povzsZXysu/o 8FgYCnkCqMh3WxME0UHFEC6w3gcgbSscWcw3SRdAx5AbmQhWiJYbpC4D4aJNzQJBvrMh kBtNwcjtNe9aiIM7aqCDEhtwee+OE7JVaInMrXzRtGjlywlnQmmAIxmdC5jQjbSgAqfL a4RFmSo6bo2e2YZsQCw7olOlTUA6hwKSiEAAkB9jGo09VC+vxoiDb0BbEPFHuKf51b/X COKbbU2bIX2CKWbGgNsY3PCLE0remGYgW0PdrpffRBqMmGUz3aYkiscT7bWDDYMpnmyi CPJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9SV3a8MpXnKT5532UlPsiYImoD9DE4Qq2V+7+P5Q6EA=; b=NdvBC/kzJCAx4v5Gzkg1ee07q48rmTFsyMkt3GH9BzLLy0oosNbrJWQr6BAuYDHWAq POYqH0Z5YsWvzq2cc5anw/sA3fp00iOVQy6XTGvmGMCw9UtPxLZhwoUki0oXy0b7B8Im yBROupjvTZ3rhrtM1A1MipKjXHnH9wwTlEei43cqMi2BXlJeTlljePH6UyQeDu/RPnw4 xsVfcMC1gKPF80Ay3oR0ocBNXoA6bvEEAS8EXX3sjG4RNlsdITdTp1iavYidkuA24nHO /mv8Z7MPPdsYVOK4IBXhXv2dUcdLXVFeImPwGRMaaw8OkqQv9zHeOPf9ypinQkhnkNmC 390w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=t9Mk+pra; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r6si4224729pgp.466.2019.05.09.12.02.17; Thu, 09 May 2019 12:02:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=t9Mk+pra; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728547AbfEIS7r (ORCPT + 99 others); Thu, 9 May 2019 14:59:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:46252 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728156AbfEISwQ (ORCPT ); Thu, 9 May 2019 14:52:16 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 30E882183E; Thu, 9 May 2019 18:52:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557427935; bh=FIXdxNrE9/HrVfQLCvXe/WWdQ3EDi7cCuGjjZ40Gutw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t9Mk+pra+OJHxJTDKDosAnvSZqzLXoq7ZGCsErOpA6s8xhU3unHZGpAT9fy+frARM 9KrREo3OFK4RHX75PPtR1ttXr4BB9b9nEmLnylx1bQnsK3Lw7n/BTrZ80cXdQzoo/P 3O2T+LqtoiaB1QIMpAKs4d+jZkNyrR6KnNOs0wxo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mike Marciniszyn , "Michael J. Ruhl" , Kaike Wan , Dennis Dalessandro , Jason Gunthorpe , Sasha Levin Subject: [PATCH 5.0 32/95] IB/hfi1: Fix the allocation of RSM table Date: Thu, 9 May 2019 20:41:49 +0200 Message-Id: <20190509181311.548879047@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190509181309.180685671@linuxfoundation.org> References: <20190509181309.180685671@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit d0294344470e6b52d097aa7369173f32d11f2f52 ] The receive side mapping (RSM) on hfi1 hardware is a special matching mechanism to direct an incoming packet to a given hardware receive context. It has 4 instances of matching capabilities (RSM0 - RSM3) that share the same RSM table (RMT). The RMT has a total of 256 entries, each of which points to a receive context. Currently, three instances of RSM have been used: 1. RSM0 by QOS; 2. RSM1 by PSM FECN; 3. RSM2 by VNIC. Each RSM instance should reserve enough entries in RMT to function properly. Since both PSM and VNIC could allocate any receive context between dd->first_dyn_alloc_ctxt and dd->num_rcv_contexts, PSM FECN must reserve enough RMT entries to cover the entire receive context index range (dd->num_rcv_contexts - dd->first_dyn_alloc_ctxt) instead of only the user receive contexts allocated for PSM (dd->num_user_contexts). Consequently, the sizing of dd->num_user_contexts in set_up_context_variables is incorrect. Fixes: 2280740f01ae ("IB/hfi1: Virtual Network Interface Controller (VNIC) HW support") Reviewed-by: Mike Marciniszyn Reviewed-by: Michael J. Ruhl Signed-off-by: Kaike Wan Signed-off-by: Dennis Dalessandro Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- drivers/infiniband/hw/hfi1/chip.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/drivers/infiniband/hw/hfi1/chip.c b/drivers/infiniband/hw/hfi1/chip.c index b443642eac021..0ae05e9249b39 100644 --- a/drivers/infiniband/hw/hfi1/chip.c +++ b/drivers/infiniband/hw/hfi1/chip.c @@ -13219,7 +13219,7 @@ static int set_up_context_variables(struct hfi1_devdata *dd) int total_contexts; int ret; unsigned ngroups; - int qos_rmt_count; + int rmt_count; int user_rmt_reduced; u32 n_usr_ctxts; u32 send_contexts = chip_send_contexts(dd); @@ -13281,10 +13281,20 @@ static int set_up_context_variables(struct hfi1_devdata *dd) n_usr_ctxts = rcv_contexts - total_contexts; } - /* each user context requires an entry in the RMT */ - qos_rmt_count = qos_rmt_entries(dd, NULL, NULL); - if (qos_rmt_count + n_usr_ctxts > NUM_MAP_ENTRIES) { - user_rmt_reduced = NUM_MAP_ENTRIES - qos_rmt_count; + /* + * The RMT entries are currently allocated as shown below: + * 1. QOS (0 to 128 entries); + * 2. FECN for PSM (num_user_contexts + num_vnic_contexts); + * 3. VNIC (num_vnic_contexts). + * It should be noted that PSM FECN oversubscribe num_vnic_contexts + * entries of RMT because both VNIC and PSM could allocate any receive + * context between dd->first_dyn_alloc_text and dd->num_rcv_contexts, + * and PSM FECN must reserve an RMT entry for each possible PSM receive + * context. + */ + rmt_count = qos_rmt_entries(dd, NULL, NULL) + (num_vnic_contexts * 2); + if (rmt_count + n_usr_ctxts > NUM_MAP_ENTRIES) { + user_rmt_reduced = NUM_MAP_ENTRIES - rmt_count; dd_dev_err(dd, "RMT size is reducing the number of user receive contexts from %u to %d\n", n_usr_ctxts, @@ -14272,9 +14282,11 @@ static void init_user_fecn_handling(struct hfi1_devdata *dd, u64 reg; int i, idx, regoff, regidx; u8 offset; + u32 total_cnt; /* there needs to be enough room in the map table */ - if (rmt->used + dd->num_user_contexts >= NUM_MAP_ENTRIES) { + total_cnt = dd->num_rcv_contexts - dd->first_dyn_alloc_ctxt; + if (rmt->used + total_cnt >= NUM_MAP_ENTRIES) { dd_dev_err(dd, "User FECN handling disabled - too many user contexts allocated\n"); return; } @@ -14328,7 +14340,7 @@ static void init_user_fecn_handling(struct hfi1_devdata *dd, /* add rule 1 */ add_rsm_rule(dd, RSM_INS_FECN, &rrd); - rmt->used += dd->num_user_contexts; + rmt->used += total_cnt; } /* Initialize RSM for VNIC */ -- 2.20.1