From patchwork Fri Feb 10 12:26:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalle Valo X-Patchwork-Id: 9566667 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7D21660572 for ; Fri, 10 Feb 2017 12:27:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 668811FF73 for ; Fri, 10 Feb 2017 12:27:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5970228556; Fri, 10 Feb 2017 12:27:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DF30B1FF73 for ; Fri, 10 Feb 2017 12:27:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:To:From:Subject:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=hfwXt9YMtgnv8tjgq4VOqTdVK45UmYkLmO6eArACMY8=; b=SMbHF4JDEVHmRs SNyExu7xdS1OGQS69SOmFHU2OhCI0n+CER0OTn59RnZr+ZFNGk4GQWm2j0agBWqWLBYbjrm3ZUHal 1EqfaWwn1WFo91G44qvNDmXGgadmHKMCiaES0pcxmXLrZnW0iDhP+EqkWVfMPzjld8PIKRSoPY00c g2injOHTlG7UoPsB40OdA3RhGUS7y7zZiy7MikTpTgIdbXG+P3pTRwYzauzkrOHvgZwRIGZC8tVNw i/Q20I//UCDC9/Q7PK6fokaucE0iXzmJFloQtTNw89R1xFz0KIUOTkeq5tyh7uzWpVINOthBNaVJT +zOCpvXSMcutt8BGLZvQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1ccAIf-0007FM-MV; Fri, 10 Feb 2017 12:27:41 +0000 Received: from wolverine01.qualcomm.com ([199.106.114.254]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1ccAIP-0006sk-JS for ath10k@lists.infradead.org; Fri, 10 Feb 2017 12:27:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=qca.qualcomm.com; i=@qca.qualcomm.com; q=dns/txt; s=qcdkim; t=1486729645; x=1518265645; h=subject:from:to:cc:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2vu32gSwOhSfoHrj9wvst5qjAEh6trV07lUDcfIooaU=; b=q+/Qjx/aaNUTfZGTt0VbJ8xYKTFRJ8neUQVga9aDIkwPMbAbN+2fGSTc 8bLNX6z5InGnuDNty37tUB+Pdbmzn1njGz1CGjNPCxLrEtc/wND8PiFw7 2IvV2jenTHnvG+Nq+7hYovxrZrCjvW7RmWduoOw9xti2OHgxLHz9YYPZq c=; X-IronPort-AV: E=Sophos;i="5.35,141,1484035200"; d="scan'208";a="261806245" Received: from unknown (HELO ironmsg02-L.qualcomm.com) ([10.53.140.109]) by wolverine01.qualcomm.com with ESMTP; 10 Feb 2017 04:27:05 -0800 X-IronPort-AV: E=McAfee;i="5800,7501,8434"; a="864296222" Received: from nasanexm02e.na.qualcomm.com ([10.85.0.86]) by ironmsg02-L.qualcomm.com with ESMTP/TLS/RC4-SHA; 10 Feb 2017 04:27:05 -0800 Received: from eusanexr01a.eu.qualcomm.com (10.85.0.97) by nasanexm02e.na.qualcomm.com (10.85.0.86) with Microsoft SMTP Server (TLS) id 15.0.1178.4; Fri, 10 Feb 2017 04:27:05 -0800 Received: from potku.adurom.net (10.80.80.8) by eusanexr01a.eu.qualcomm.com (10.85.0.97) with Microsoft SMTP Server (TLS) id 15.0.1178.4; Fri, 10 Feb 2017 04:27:02 -0800 Subject: [PATCH v2 1/4] ath10k: fetch firmware images in a loop From: Kalle Valo To: Date: Fri, 10 Feb 2017 14:26:32 +0200 Message-ID: <148672959257.8556.14481306395015426550.stgit@potku.adurom.net> In-Reply-To: <148672934198.8556.5588600166627442652.stgit@potku.adurom.net> References: <148672934198.8556.5588600166627442652.stgit@potku.adurom.net> User-Agent: StGit/0.17.1-17-ge4e0 MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: NASANEXM01C.na.qualcomm.com (10.85.0.83) To eusanexr01a.eu.qualcomm.com (10.85.0.97) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170210_042726_306781_815AC820 X-CRM114-Status: GOOD ( 11.33 ) X-BeenThere: ath10k@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-wireless@vger.kernel.org Sender: "ath10k" Errors-To: ath10k-bounces+patchwork-ath10k=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Erik Stromdahl To make it easier to handle minimum and maximum firmware API numbers convert the firmware fetch functionality to a loop. If no firmware image is found print an error with minimum and maximum API numbers and the name of firmware directory. This is needed when we switch to using request_firmware_direct() which doesn't print any errors anymore. Also add a new function for creating the fw file name dynamically which makes it easier to add new bus support, for example SDIO and USB, later. Signed-off-by: Erik Stromdahl [kvalo@qca.qualcomm.com: remove sdio/usb part, new error message, clarify commit log] Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath10k/core.c | 51 ++++++++++++++------------------ drivers/net/wireless/ath/ath10k/hw.h | 4 +++ 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c index c27e7ea38a65..9674c08464ab 100644 --- a/drivers/net/wireless/ath/ath10k/core.c +++ b/drivers/net/wireless/ath/ath10k/core.c @@ -1358,44 +1358,39 @@ int ath10k_core_fetch_firmware_api_n(struct ath10k *ar, const char *name, return ret; } +static void ath10k_core_get_fw_name(struct ath10k *ar, char *fw_name, + size_t fw_name_len, int fw_api) +{ + scnprintf(fw_name, fw_name_len, "%s-%d.bin", ATH10K_FW_FILE_BASE, fw_api); +} + static int ath10k_core_fetch_firmware_files(struct ath10k *ar) { - int ret; + int ret, i; + char fw_name[100]; /* calibration file is optional, don't check for any errors */ ath10k_fetch_cal_file(ar); - ar->fw_api = 5; - ath10k_dbg(ar, ATH10K_DBG_BOOT, "trying fw api %d\n", ar->fw_api); - - ret = ath10k_core_fetch_firmware_api_n(ar, ATH10K_FW_API5_FILE, - &ar->normal_mode_fw.fw_file); - if (ret == 0) - goto success; - - ar->fw_api = 4; - ath10k_dbg(ar, ATH10K_DBG_BOOT, "trying fw api %d\n", ar->fw_api); - - ret = ath10k_core_fetch_firmware_api_n(ar, ATH10K_FW_API4_FILE, - &ar->normal_mode_fw.fw_file); - if (ret == 0) - goto success; + for (i = ATH10K_FW_API_MAX; i >= ATH10K_FW_API_MIN; i--) { + ar->fw_api = i; + ath10k_dbg(ar, ATH10K_DBG_BOOT, "trying fw api %d\n", + ar->fw_api); - ar->fw_api = 3; - ath10k_dbg(ar, ATH10K_DBG_BOOT, "trying fw api %d\n", ar->fw_api); + ath10k_core_get_fw_name(ar, fw_name, sizeof(fw_name), ar->fw_api); + ret = ath10k_core_fetch_firmware_api_n(ar, fw_name, + &ar->normal_mode_fw.fw_file); + if (!ret) + goto success; + } - ret = ath10k_core_fetch_firmware_api_n(ar, ATH10K_FW_API3_FILE, - &ar->normal_mode_fw.fw_file); - if (ret == 0) - goto success; + /* we end up here if we couldn't fetch any firmware */ - ar->fw_api = 2; - ath10k_dbg(ar, ATH10K_DBG_BOOT, "trying fw api %d\n", ar->fw_api); + ath10k_err(ar, "Failed to find firmware-N.bin (N between %d and %d) from %s: %d", + ATH10K_FW_API_MIN, ATH10K_FW_API_MAX, ar->hw_params.fw.dir, + ret); - ret = ath10k_core_fetch_firmware_api_n(ar, ATH10K_FW_API2_FILE, - &ar->normal_mode_fw.fw_file); - if (ret) - return ret; + return ret; success: ath10k_dbg(ar, ATH10K_DBG_BOOT, "using fw api %d\n", ar->fw_api); diff --git a/drivers/net/wireless/ath/ath10k/hw.h b/drivers/net/wireless/ath/ath10k/hw.h index 38aa7c95732e..f0fda0f2b3b4 100644 --- a/drivers/net/wireless/ath/ath10k/hw.h +++ b/drivers/net/wireless/ath/ath10k/hw.h @@ -128,6 +128,10 @@ enum qca9377_chip_id_rev { #define QCA4019_HW_1_0_BOARD_DATA_FILE "board.bin" #define QCA4019_HW_1_0_PATCH_LOAD_ADDR 0x1234 +#define ATH10K_FW_FILE_BASE "firmware" +#define ATH10K_FW_API_MAX 5 +#define ATH10K_FW_API_MIN 2 + #define ATH10K_FW_API2_FILE "firmware-2.bin" #define ATH10K_FW_API3_FILE "firmware-3.bin"