Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp2172605rwb; Thu, 27 Jul 2023 03:20:08 -0700 (PDT) X-Google-Smtp-Source: APBJJlHLxvW5jl9a6ZVVWUl+nlnwgeWzpdMVQw3kTOLzPwT5da253d1+CoGq/rf8r+43Vi9F6fmK X-Received: by 2002:a05:6a20:968c:b0:12d:23ea:9ccc with SMTP id hp12-20020a056a20968c00b0012d23ea9cccmr3603178pzc.39.1690453208221; Thu, 27 Jul 2023 03:20:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690453208; cv=none; d=google.com; s=arc-20160816; b=A2096RyqaQKWRpjTlpTEeb67sTDleDVAQau+yJfh4oVp7FVQ80daocnOHSXJ1mJFTO CAxiyZuK3srVqIueCgFCqtKW8ajuNhgpLxqLvwnEy+7oOkEhoFaN46g+2q1eYeFdWbqt OTJ3bMj9dYAncwEmerkxuK8NCoSGP4N6easVvkA+o1fgNrvtkzczjv2nzylHw+UKEibD l8a1a9neotxdplERb3jx6nOajFh8t3JHXl6fpsl+xl/ljES1MVyLgGTslN9wWHI/8Mnp AcJhuGJNWZ33VvQO+cxJxizMm4Px3MlOcWvDp0CG0Xh5ZQe7Gv6Zt2hZKixY3A59+/Nc qQKQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9fYUtjr48I9kyZpwoE70UVFTlzHeSoO6zvjLHvlK7Xs=; fh=d3YrhS+XW2ZvkQqinvugDj/c4x/RSFzdXYeNCXlHhfg=; b=yvNkXHNVHZmE1R3b8+051QExDHpLzjs71JZUD6cBouNw6A1OJVRy+Ezh2KvmQD5QuC tL3DnzW0zktzo1F1Po2+pt5Mf75BW3zu8suDBCM/d49OpNgXCYMMukBnicKvL9Z00CHu dRb7przVwi7t5xIfIAqYI7E0rQlU46hKaAkFuyiGwENYPlaem4486n7xQmIgIRaOTBWy mvTEmnRTnElQXJjWtoegGtmc7tlVvg0rHp6h8bYDZfSXmKv+zvZJy8OWqI7USdStjSXK xUmCf3NqVH2eZfEG5oHGYq7maGDL8C2rZEYhqe/mixaCwAuiFm0AJ3MDjabBoB4ibp5o IpKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ilna5U5A; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i4-20020a63bf44000000b0054ff0e193fesi245252pgo.225.2023.07.27.03.20.00; Thu, 27 Jul 2023 03:20:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ilna5U5A; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232432AbjG0KEi (ORCPT + 58 others); Thu, 27 Jul 2023 06:04:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232380AbjG0KEh (ORCPT ); Thu, 27 Jul 2023 06:04:37 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B284013D for ; Thu, 27 Jul 2023 03:04:36 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 487FC61E0E for ; Thu, 27 Jul 2023 10:04:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E2CAAC433C8; Thu, 27 Jul 2023 10:04:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690452275; bh=V9vzfxXb+UtRFxuUbKVHaWIUnGx1taxwRPcjnyO1bsI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ilna5U5AbNt4wvOthrNmi0RaUVcwQ2tILEGsDEAUc0Z5yzNRqNE3C0l2/N6ED/o8H O9n12rdTC9J3cnWDwq4cBPe21t1Ix6OKalUu+lwxp2ZkGzGeBBkMByyZ7xseqERUut 0MRjIvZm4Ov7Mimqqm+lBT/iRfRmzu9UigXdeaUJD+sarFZ428yYW74TVMz+mLXUPp HNtDcUL8nhBka/MIeubTYVABVWy2RZcnOjIToZRpAJwR5j5Sqon3ePB5dMWrq7hbAv Yy+ofRRsZGCQROqg+xZ9WXFd5fWVrsyuZE7+Vsq9mNHpFGy3rEiCHgIXI1sUUoOBmi tI6W8nHGumcgA== From: Kalle Valo To: mhi@lists.linux.dev Cc: ath11k@lists.infradead.org, linux-wireless@vger.kernel.org Subject: [PATCH v4 2/3] wifi: ath11k: qmi: refactor ath11k_qmi_m3_load() Date: Thu, 27 Jul 2023 13:04:29 +0300 Message-Id: <20230727100430.3603551-3-kvalo@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230727100430.3603551-1-kvalo@kernel.org> References: <20230727100430.3603551-1-kvalo@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Kalle Valo Simple refactoring to make it easier to add firmware-2.bin support in the following patch. Earlier ath11k_qmi_m3_load() supported changing m3.bin contents while ath11k is running. But that's not going to actually work, m3.bin is supposed to the be same during the lifetime of ath11k, for example we don't support changing the firmware capabilities on the fly. Due to this ath11k requests m3.bin firmware file first and only then checks m3_mem->vaddr, so we are basically requesting the firmware file even if it's not needed. Reverse the code so that m3_mem buffer is checked first, and only if it doesn't exist, then m3.bin is requested from user space. Checking for m3_mem->size is redundant when m3_mem->vaddr is NULL, we would not be able to use the buffer in that case. So remove the check for size. Simplify the exit handling and use 'goto out'. Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-03125-QCAHSPSWPL_V1_V2_SILICONZ_LITE-3.6510.9 Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath11k/qmi.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/qmi.c b/drivers/net/wireless/ath/ath11k/qmi.c index d4eaf7d2ba84..9b13628fa3c7 100644 --- a/drivers/net/wireless/ath/ath11k/qmi.c +++ b/drivers/net/wireless/ath/ath11k/qmi.c @@ -2506,6 +2506,10 @@ static int ath11k_qmi_m3_load(struct ath11k_base *ab) char path[100]; int ret; + if (m3_mem->vaddr) + /* m3 firmware buffer is already available in the DMA buffer */ + return 0; + fw = ath11k_core_firmware_request(ab, ATH11K_M3_FILE); if (IS_ERR(fw)) { ret = PTR_ERR(fw); @@ -2515,25 +2519,25 @@ static int ath11k_qmi_m3_load(struct ath11k_base *ab) return ret; } - if (m3_mem->vaddr || m3_mem->size) - goto skip_m3_alloc; - m3_mem->vaddr = dma_alloc_coherent(ab->dev, fw->size, &m3_mem->paddr, GFP_KERNEL); if (!m3_mem->vaddr) { ath11k_err(ab, "failed to allocate memory for M3 with size %zu\n", fw->size); - release_firmware(fw); - return -ENOMEM; + ret = -ENOMEM; + goto out; } -skip_m3_alloc: memcpy(m3_mem->vaddr, fw->data, fw->size); m3_mem->size = fw->size; + + ret = 0; + +out: release_firmware(fw); - return 0; + return ret; } static void ath11k_qmi_m3_free(struct ath11k_base *ab) -- 2.39.2