From patchwork Fri Dec 4 15:19:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: You-Sheng Yang X-Patchwork-Id: 1411072 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CnbxY6MRSz9sWR; Sat, 5 Dec 2020 02:20:33 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1klCso-0005ar-Ka; Fri, 04 Dec 2020 15:20:30 +0000 Received: from mail-pg1-f196.google.com ([209.85.215.196]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1klCsm-0005Yv-5j for kernel-team@lists.ubuntu.com; Fri, 04 Dec 2020 15:20:28 +0000 Received: by mail-pg1-f196.google.com with SMTP id n10so3676687pgv.8 for ; Fri, 04 Dec 2020 07:20:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WCrbVeN3T2W6k4r+2EmPXcYC+ovi+JJjeoCk0Tb7+ZU=; b=mSw1Fywh6/DVmWYKVDZI9jVeRmtQuj8undtTKbB/fkodBVz4fp0TTkDchOxEDcM02t 7HQ79n0EB1T3fq7LCVMKhCqnfLV50HVVaE7d1GtQ6m0mvqimac+mJSULzCvlEvoYOe1c XYIWoHA5EhcllCzfmt5lO9aoQ6TdxXv6BQNNG2WwCdp+sIgJJGIh1ROfNBEom3AJk60W 8zckE0GZqB+aAN2ZGc+egPDlTcrXbW242rvLKpTMHQzQU44goYF1cYhAxSJSZNEfJzaK 4+TqphsKCtcUxWhkcU2j37YD/avewFlaeVIERMTBxjv7gWubTjNZfI9oG3nZlQ1cs+z0 2/wA== X-Gm-Message-State: AOAM5330ET1bSNrvFoaKto+IcHAh7TP8h8KFnTCLJWO3M4HMLgDrpezS q8hyrLO6cQ04XBkZfbR37xGtkYiYhSEydg== X-Google-Smtp-Source: ABdhPJwP0C5uMOag/wi8FHMhsBJD77JRRmeQtKeXnGkVmesLO+kHxzoZpBcL/nHp5Wma8ZpcI/darQ== X-Received: by 2002:a05:6a00:ac5:b029:19d:97c2:d3a7 with SMTP id c5-20020a056a000ac5b029019d97c2d3a7mr4328837pfl.61.1607095225725; Fri, 04 Dec 2020 07:20:25 -0800 (PST) Received: from localhost (61-220-137-37.HINET-IP.hinet.net. [61.220.137.37]) by smtp.gmail.com with ESMTPSA id a10sm5208993pfi.168.2020.12.04.07.20.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2020 07:20:25 -0800 (PST) From: You-Sheng Yang To: kernel-team@lists.ubuntu.com Subject: [PATCH 03/26][SRU][U/OEM-5.10] UBUNTU: SAUCE: ath11k: try to allocate big block of dma memory firstly Date: Fri, 4 Dec 2020 23:19:49 +0800 Message-Id: <20201204152013.195139-4-vicamo.yang@canonical.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201204152013.195139-1-vicamo.yang@canonical.com> References: <20201204152013.195139-1-vicamo.yang@canonical.com> MIME-Version: 1.0 Received-SPF: pass client-ip=209.85.215.196; envelope-from=vicamo@gmail.com; helo=mail-pg1-f196.google.com X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Carl Huang BugLink: https://bugs.launchpad.net/bugs/1879633 With this change, ath11k will try to allocate big block of dma memory fistly. If the allocation fails, it will let firmware request mulitple blocks of dma memory with small size. This patch also changes the log outputted when allocation fails and firmware sends response with error code. Tested-on: QCA6390 hw2.0 PCI WLAN.HST.1.0.1-01740-QCAHSTSWPLZ_V2_TO_X86-1 Signed-off-by: Carl Huang Signed-off-by: Kalle Valo (cherry picked from commit 0d8b0aff6b77ea5a8d715ba5d0089f9dffbabf21 https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git) Signed-off-by: You-Sheng Yang --- drivers/net/wireless/ath/ath11k/qmi.c | 23 ++++++++++++++++++++--- drivers/net/wireless/ath/ath11k/qmi.h | 1 + 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/qmi.c b/drivers/net/wireless/ath/ath11k/qmi.c index c2b165158225..6cf4021ef293 100644 --- a/drivers/net/wireless/ath/ath11k/qmi.c +++ b/drivers/net/wireless/ath/ath11k/qmi.c @@ -1652,6 +1652,7 @@ static int ath11k_qmi_respond_fw_mem_request(struct ath11k_base *ab) struct qmi_wlanfw_respond_mem_resp_msg_v01 resp; struct qmi_txn txn = {}; int ret = 0, i; + bool delayed = false; req = kzalloc(sizeof(*req), GFP_KERNEL); if (!req) @@ -1664,7 +1665,8 @@ static int ath11k_qmi_respond_fw_mem_request(struct ath11k_base *ab) * failure to FW and FW will then request mulitple blocks of small * chunk size memory. */ - if (!ab->bus_params.fixed_mem_region && ab->qmi.mem_seg_count <= 2) { + if (!ab->bus_params.fixed_mem_region && ab->qmi.target_mem_delayed) { + delayed = true; ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi delays mem_request %d\n", ab->qmi.mem_seg_count); memset(req, 0, sizeof(*req)); @@ -1700,10 +1702,15 @@ static int ath11k_qmi_respond_fw_mem_request(struct ath11k_base *ab) } if (resp.resp.result != QMI_RESULT_SUCCESS_V01) { + /* the error response is expected when + * target_mem_delayed is true. + */ + if (delayed && resp.resp.error == 0) + goto out; + ath11k_warn(ab, "Respond mem req failed, result: %d, err: %d\n", resp.resp.result, resp.resp.error); ret = -EINVAL; - goto out; } out: kfree(req); @@ -1734,6 +1741,7 @@ static int ath11k_qmi_alloc_target_mem_chunk(struct ath11k_base *ab) int i; struct target_mem_chunk *chunk; + ab->qmi.target_mem_delayed = false; for (i = 0; i < ab->qmi.mem_seg_count; i++) { chunk = &ab->qmi.target_mem[i]; chunk->vaddr = dma_alloc_coherent(ab->dev, @@ -1741,10 +1749,19 @@ static int ath11k_qmi_alloc_target_mem_chunk(struct ath11k_base *ab) &chunk->paddr, GFP_KERNEL); if (!chunk->vaddr) { + if (ab->qmi.mem_seg_count <= 2) { + ath11k_info(ab, "too big size: 0x%x, type:%u, will try later with small size.\n", + chunk->size, + chunk->type); + ath11k_qmi_free_target_mem_chunk(ab); + ab->qmi.target_mem_delayed = true; + return 0; + } ath11k_err(ab, "failed to alloc memory, size: 0x%x, type: %u\n", chunk->size, chunk->type); return -EINVAL; + } } @@ -2465,7 +2482,7 @@ static void ath11k_qmi_msg_mem_request_cb(struct qmi_handle *qmi_hdl, ret); return; } - } else if (msg->mem_seg_len > 2) { + } else { ret = ath11k_qmi_alloc_target_mem_chunk(ab); if (ret) { ath11k_warn(ab, "qmi failed to alloc target memory: %d\n", diff --git a/drivers/net/wireless/ath/ath11k/qmi.h b/drivers/net/wireless/ath/ath11k/qmi.h index b0a818f0401b..59f1452b3544 100644 --- a/drivers/net/wireless/ath/ath11k/qmi.h +++ b/drivers/net/wireless/ath/ath11k/qmi.h @@ -121,6 +121,7 @@ struct ath11k_qmi { struct target_mem_chunk target_mem[ATH11K_QMI_WLANFW_MAX_NUM_MEM_SEG_V01]; u32 mem_seg_count; u32 target_mem_mode; + bool target_mem_delayed; u8 cal_done; struct target_info target; struct m3_mem_region m3_mem;