From nobody Tue Jul 26 19:33:22 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 4LsnBq5MrWz4WxWJ; Tue, 26 Jul 2022 19:33:23 +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 4LsnBq2LDrz47WC; Tue, 26 Jul 2022 19:33:23 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658864003; 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=M+1G+tz+Kxn8IybE4k0kL9/PMN+IWoKE6PUCe8Wgwrw=; b=E/KcXHaqM3pgXoEKh4kEBB8dCBQsgpgNLvvqAixvDkdpnbDG2HXXTc+IcnjnYyRVvX7nGS oLeKrIsCPJ73laJtuJnkWsY03fchXvBHnaB0eGxVmUp4oMbEBp0IJ1BGwYF1SkaOJ8uO51 U9zTx9Bc9cP3Uv/BQVeTZU2kFSpZdAIEwkH1/V1mHoxeeoJropPHIhgDjQ8k4tbeASlHYK Nxjezc36pe5cgO1hFT0kZdu7FG9r0cgX9kLWUy0fuOHgWx9pxG/z2jHdEbY7HGHwNhzQSP j5BErUQ3FADrzlWXhcOn+Z7K1V0ObXpG9oKLHPl1BsNvPzII0DMnnTku/wBp5Q== 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 4LsnBq0gJMzpj1; Tue, 26 Jul 2022 19:33:23 +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 26QJXMLZ033779; Tue, 26 Jul 2022 19:33:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 26QJXM5u033778; Tue, 26 Jul 2022 19:33:22 GMT (envelope-from git) Date: Tue, 26 Jul 2022 19:33:22 GMT Message-Id: <202207261933.26QJXM5u033778@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: bb98012e39ac - stable/12 - 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/12 X-Git-Reftype: branch X-Git-Commit: bb98012e39ac55ed2d9a93b90404dfc3d2e77f7f Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658864003; 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=M+1G+tz+Kxn8IybE4k0kL9/PMN+IWoKE6PUCe8Wgwrw=; b=E02UDCiFP+EtHbGhqPuRC31q5B7EsQR+zwbYAWY2Kv9kTnKNhrqYaatyd70FZrqcONWmZ/ f6vjwoPhuTMf2FRIM9lrRVR65Re3kVdL+muAuKRuXiDhk2ONT38oQQZiQ86hBG26rBp2B1 g7l/D2bdXEfhY03DB1nlSneZfg3wKa6FHzCUrucblSV6bTAf9QS31rCXQ0ZsNCsHMTmD0q ltC2MeaUcdR/miMD4ganqPxzQc9IuCYZgIjw76zqC4x7DmuNPwBkk/YmkAcKdtoI0dO66+ R/GeSPHj/G6fEyey1RI37fegI0npeqb+meaManScy3dqocBkbVOvNqdPAOEMQg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1658864003; a=rsa-sha256; cv=none; b=fZiSsLtt9z5kDaz/cDX9DFjTXaOPhGZb9nlFRt+aFl6L6c5SQ7mrQaiSRX33xYn4nCaEyd whl4pTBMizQH9Ubr+BUj7mPb4lVXlND9oe7Utw5vmMIrjsltUTZKRDzaVur7N9rrzLAI2f Y1DdTxYFLkGciLfBLOtczyUj+inzkV1rLb7y7gzG8rIFQgh3GlyJnJZLyybOM9BbTcQeu8 c4pEdMi7ExCQgGSjzNwjh1YMBb6xLt5rk5QSdfM8f03Vhsd3NIHIJ6YB5hTB7BK/r4K57j NunE781tFroatSbtV31ePYqUONvhiIrlBOP2JmmQL2vIcT5YP2uhxUi5nMd1ZQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by mw: URL: https://cgit.FreeBSD.org/src/commit/?id=bb98012e39ac55ed2d9a93b90404dfc3d2e77f7f commit bb98012e39ac55ed2d9a93b90404dfc3d2e77f7f Author: Dawid Gorecki AuthorDate: 2022-06-10 09:18:08 +0000 Commit: Marcin Wojtas CommitDate: 2022-07-26 19:33:03 +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 e21f7bbcc2b0..64066896907e 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 *); @@ -2575,8 +2576,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; @@ -2587,17 +2587,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); @@ -3599,6 +3610,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)) {