From nobody Tue Jul 26 19:30:51 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Lsn7w1BS9z4WwmV; Tue, 26 Jul 2022 19:30:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Lsn7w0YZbz42XV; Tue, 26 Jul 2022 19:30:52 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658863852; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=NGn/j1apEfkQTY6QlB08iWHzeeOFi5wq4JJ606nbcsY=; b=jGdayFf5EONz2kdQdC8GxCEFWiwuA1ii2W0BPauVAMEGP9ulZ9DT8hTsBUCVU398rhGj42 974Ct/dvCvNVq6iixVDsM12q0izdRY7bph/gdxudH3kcJcwYEoGA79gpKGWJf4YiXOKA9c fiDHpnCactJpNKPlGs556ehfB2aXoqdv/fp7JjmUJDCBSACAMQGrYbcNmTdgm9gisOibtA H1dqMK8ZVsFzH9HmQSW26fGzsuB5Onxi5UTEqNjh075Mz5vgkmeNT/HUvs/CQlfHj9NrDq G2HwPPHVp3XF0EtlRlMYqMMXoSvv9KZnNaEOm+ESrFHMSLsuC+jAGTFdFhf/pA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Lsn7v6lZwzpGY; Tue, 26 Jul 2022 19:30:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 26QJUpgh029614; Tue, 26 Jul 2022 19:30:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 26QJUpPf029613; Tue, 26 Jul 2022 19:30:51 GMT (envelope-from git) Date: Tue, 26 Jul 2022 19:30:51 GMT Message-Id: <202207261930.26QJUpPf029613@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Marcin Wojtas Subject: git: 609b1df672c2 - stable/13 - ena: Prevent LLQ initialization when membar isn't exposed List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mw X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 609b1df672c2c23a6ffbd2227c57fa1223b7bc48 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658863852; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=NGn/j1apEfkQTY6QlB08iWHzeeOFi5wq4JJ606nbcsY=; b=ehjrsFeeMbB6WXKLRBYtO/8Hyyq5+dgLZY4STMOegIvaF26rnEbMyN5WAM+U8IrstmfdXz vUd4GB3LXsfiEND3+bpI507b4fgO6/Olx98KyxAWNmRGzezF0e0hMmAHmzsVwFyQQGSsBT +EtmnndNYuxomYSSWCUi8ccxsGmS/YcvfigZ2xepgNAn1q6yCcZH4QNn5wemZaqUoiu9Bx snApHOLYjm7p9IxcSeNaeNtmi9oRR4UzwOYGAMYMfUBW1Rkc+NgKrp6+Z5jtCsRRAFdYYR 93ne0Kebrbrw9JEkn+r8Wawm/6b+W0J5LxAt7uwN+zTEd1Xe17z6CNfZBn0Weg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1658863852; a=rsa-sha256; cv=none; b=lZ7svFmaUWpR1OIzI58OfVsJceJSZUp6jEAqI/XP6is1dRvNT9GG/2gyVMUKyhg+PnWGwG jLrz1adZO/PFZTSTswCiahLSyI7Ujod/mGCLDGbuARzCcUoS4caRg7saozJaTspM/el5Rd hcOdP/T8DApN+nODyUisqXq0Jgf3vTd/BsWS7VD0FG+ZnI9Pzyd+vx9KSphONZrqUyAERG uVqCueGmLFJMkeNHuzUDiyN6HEDZ9kjcV5vF9fwGMT98bsb5y0WjE8mieUzXmgsTFpWQMB xvzJali2jPyPl68hjvWHu0hOI0grn9WS0bU3KSMa3E+El22ocOX02mD63jfu/g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mw: URL: https://cgit.FreeBSD.org/src/commit/?id=609b1df672c2c23a6ffbd2227c57fa1223b7bc48 commit 609b1df672c2c23a6ffbd2227c57fa1223b7bc48 Author: Dawid Gorecki AuthorDate: 2022-06-10 09:18:08 +0000 Commit: Marcin Wojtas CommitDate: 2022-07-26 19:30:14 +0000 ena: Prevent LLQ initialization when membar isn't exposed The ena_com_config_dev_mode() function performs many LLQ related calculations and sends an admin command to configure LLQ in the device. All the LLQ related operations are unnecessary if the driver fails to find LLQ memory bar. Move LLQ memory bar allocation to separate helper function ena_map_llq_mem_bar and execute this function before LLQ configuration. If the LLQ memory bar cannot be allocated, then LLQ configuration is skipped. Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc. (cherry picked from commit 90232d18ca4f7a5a3073a8279a9b9d3228df5f87) --- sys/dev/ena/ena.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/sys/dev/ena/ena.c b/sys/dev/ena/ena.c index 3e0b7e7a2339..d127f87ac8c6 100644 --- a/sys/dev/ena/ena.c +++ b/sys/dev/ena/ena.c @@ -155,6 +155,7 @@ static int ena_setup_ifnet(device_t, struct ena_adapter *, static int ena_enable_wc(device_t, struct resource *); static int ena_set_queues_placement_policy(device_t, struct ena_com_dev *, struct ena_admin_feature_llq_desc *, struct ena_llq_configurations *); +static int ena_map_llq_mem_bar(device_t, struct ena_com_dev *); static uint32_t ena_calc_max_io_queue_num(device_t, struct ena_com_dev *, struct ena_com_dev_get_features_ctx *); static int ena_calc_io_queue_size(struct ena_calc_queue_size_ctx *); @@ -2571,8 +2572,7 @@ ena_set_queues_placement_policy(device_t pdev, struct ena_com_dev *ena_dev, struct ena_admin_feature_llq_desc *llq, struct ena_llq_configurations *llq_default_configurations) { - struct ena_adapter *adapter = device_get_softc(pdev); - int rc, rid; + int rc; uint32_t llq_feature_mask; llq_feature_mask = 1 << ENA_ADMIN_LLQ; @@ -2583,17 +2583,28 @@ ena_set_queues_placement_policy(device_t pdev, struct ena_com_dev *ena_dev, return (0); } + if (ena_dev->mem_bar == NULL) { + ena_log(pdev, WARN, + "LLQ is advertised as supported but device doesn't expose mem bar.\n"); + ena_dev->tx_mem_queue_type = ENA_ADMIN_PLACEMENT_POLICY_HOST; + return (0); + } + rc = ena_com_config_dev_mode(ena_dev, llq, llq_default_configurations); if (unlikely(rc != 0)) { ena_log(pdev, WARN, "Failed to configure the device mode. " "Fallback to host mode policy.\n"); ena_dev->tx_mem_queue_type = ENA_ADMIN_PLACEMENT_POLICY_HOST; - return (0); } - /* Nothing to config, exit */ - if (ena_dev->tx_mem_queue_type == ENA_ADMIN_PLACEMENT_POLICY_HOST) - return (0); + return (0); +} + +static int +ena_map_llq_mem_bar(device_t pdev, struct ena_com_dev *ena_dev) +{ + struct ena_adapter *adapter = device_get_softc(pdev); + int rc, rid; /* Try to allocate resources for LLQ bar */ rid = PCIR_BAR(ENA_MEM_BAR); @@ -3595,6 +3606,12 @@ ena_attach(device_t pdev) set_default_llq_configurations(&llq_config, &get_feat_ctx.llq); + rc = ena_map_llq_mem_bar(pdev, ena_dev); + if (unlikely(rc != 0)) { + ena_log(pdev, ERR, "failed to map ENA mem bar"); + goto err_com_free; + } + rc = ena_set_queues_placement_policy(pdev, ena_dev, &get_feat_ctx.llq, &llq_config); if (unlikely(rc != 0)) {