Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp5557256iob; Mon, 9 May 2022 20:37:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJziosP5ZnHwQp9mqMti04tkwbyZKz+mu2tA+VvnhHCTsBd24C9ZdtOuh/BYNw15JmioXOA4 X-Received: by 2002:a05:6402:329c:b0:428:a84b:682 with SMTP id f28-20020a056402329c00b00428a84b0682mr5140144eda.307.1652153865483; Mon, 09 May 2022 20:37:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652153865; cv=none; d=google.com; s=arc-20160816; b=YDPI7U5P1u3w2Qq1Cm6ryGs7frYnOdmRwviyLT0bP9VX1f2i35CzubG4e+LB/8NU25 1yIlmMEj4B2KeTs84yFYkOu9NByAL0lvhS/B+lxaELljZlKWYIZ5sO5WuuuLSZ4iUgwa aYMnbZC4BfX92NjAjyvbdLU+E4Sn0FmpmlJoehn9/9MXZSrDgt2iiDOtuWfGkaPwphIL Fl1vKDTbIXSUT1vMLrw51zXavl720jsmDE9FCGVFrXCryUMgHeAMVJm6L0BnbLv6hONO Guuw4aaLXA4Q2z4vL98ia0M2Dxd/HZnHiiY6CLsh+CV24NufyxvS6XO6zAroP1IR3oAW V3PQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=Wtvbdm5RoaA8oDIBKyDNKWt9MnB6vy/mwNf4axxFeBk=; b=migmTxGq0S6QOnylQj3KF37llxEnwDClptBZWOKcE3l3eilENGFVroScK9umTgFaDw ba/WFSg87GpU49sEWtX59bNOL5lu+KjQWHSptJncgbFPWCNoi1oao+xDEy8SG/43HlyK 68pdZHPJHAGMe5RuXFuZFIx8mLhH8IasP65E7l4CP7YyP+oSjuLyFPauuKz/N77jcQip +KDHZmBdjk5zGgLsvPKAu+pfV0XCzvvefyRjwG5XYpQATE7Bt4GigTYQfYlIuV9NDxfe GtfW8TYIoPiV++LplA/6pHYnLxEgPMgXZ+XKiZJe010XuCq0v7G2g1Bf291rLUbtOdrY jwEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=oItulGg9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ga15-20020a170906b84f00b006f3a56dbf9esi15264346ejb.839.2022.05.09.20.37.21; Mon, 09 May 2022 20:37:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@chromium.org header.s=google header.b=oItulGg9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234562AbiEJCWH (ORCPT + 99 others); Mon, 9 May 2022 22:22:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234583AbiEJCWF (ORCPT ); Mon, 9 May 2022 22:22:05 -0400 Received: from mail-il1-x136.google.com (mail-il1-x136.google.com [IPv6:2607:f8b0:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7057E293B49 for ; Mon, 9 May 2022 19:18:09 -0700 (PDT) Received: by mail-il1-x136.google.com with SMTP id i22so10507491ila.1 for ; Mon, 09 May 2022 19:18:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Wtvbdm5RoaA8oDIBKyDNKWt9MnB6vy/mwNf4axxFeBk=; b=oItulGg9BGZBdDyin3sZYsYFYznrZztbhi/KZysNi7IXJl/SGx49xwPpZsU0Vvl4fR 1uAv6SWUEBSbodqoCpeRYnpdZ5KKjGYIuJ02Iuh2T6hIkTFjUsh5PYSp3uaFkVcnzZJC hgWZO7FM5WGgzQP3UsTbb+RLTsrd9f0Af7wNs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Wtvbdm5RoaA8oDIBKyDNKWt9MnB6vy/mwNf4axxFeBk=; b=nxNgOGVHu/Uub7EzG9xWu/PQxM5E/HabU6nTi0YPLjyqm0NZ4Ry5jPnbL9i5xUW7T4 ZfK0YEPcbvnZL8jLF9zNlSqIhPIncFMpecCtXMziu8spirHwLmjcujA/dLw4vQAEtcAR dhhExs7whhJZVAtTj0Szcq/9t9+ctqJcP81R9mEwoFimrQeEHgupCdZwm2UgNZM9oNvF XmQDH9oVfqyWtdRdoPnHSv2hFKEkzAqEuExC9ngL4+35L218hoYqqQ5dp6o6eWq3dYPN 9kHGJG7hUGASxmKZ/26jVk4ImsPrx3A/W8tI+V4qmVdJf5QFLlrvrfKby9Vw9wmmk7AN 48SQ== X-Gm-Message-State: AOAM532HI1h7Lncc60ZH1VcKDg5JxI02Qk20SKdjLLhfZLNpKaTmN4Tz sHah2sUbIy3YTYru5fbcs8icWGJGNY6A00Dmhh2EnA== X-Received: by 2002:a92:c567:0:b0:2cf:592e:f8ed with SMTP id b7-20020a92c567000000b002cf592ef8edmr7569982ilj.205.1652149088768; Mon, 09 May 2022 19:18:08 -0700 (PDT) MIME-Version: 1.0 References: <20220509022618.v3.1.Ibfd52b9f0890fffe87f276fa84deaf6f1fb0055c@changeid> In-Reply-To: From: Abhishek Kumar Date: Mon, 9 May 2022 19:17:56 -0700 Message-ID: Subject: Re: [PATCH v3] ath10k: improve BDF search fallback strategy To: Abhishek Kumar Cc: Jeff Johnson , kvalo@kernel.org, netdev@vger.kernel.org, dianders@chromium.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, ath10k@lists.infradead.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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-kernel@vger.kernel.org Replying again ... Thanks for the review Jeff, I have replied below and will address these comments in next iteration. I will wait for a day more to get some more reviews and collectively make the change. On Mon, May 9, 2022 at 10:22 AM Jeff Johnson wrote: > > On 5/8/2022 7:26 PM, Abhishek Kumar wrote: > > Board data files wrapped inside board-2.bin files are > > identified based on a combination of bus architecture, > > chip-id, board-id or variants. Here is one such example > > of a BDF entry in board-2.bin file: > > bus=snoc,qmi-board-id=67,qmi-chip-id=320,variant=GO_XXXX > > It is possible for few platforms none of the combinations > > of bus,qmi-board,chip-id or variants match, e.g. if > > board-id is not programmed and thus reads board-id=0xff, > > there won't be any matching BDF to be found. In such > > situations, the wlan will fail to enumerate. > > > > Currently, to search for BDF, there are two fallback > > boardnames creates to search for BDFs in case the full BDF > > is not found. It is still possible that even the fallback > > boardnames do not match. > > > > As an improvement, search for BDF with full BDF combination > > and perform the fallback searches by stripping down the last > > elements until a BDF entry is found or none is found for all > > possible BDF combinations.e.g. > > Search for initial BDF first then followed by reduced BDF > > names as follows: > > bus=snoc,qmi-board-id=67,qmi-chip-id=320,variant=GO_XXXX > > bus=snoc,qmi-board-id=67,qmi-chip-id=320 > > bus=snoc,qmi-board-id=67 > > bus=snoc > > > > > > Tested-on: WCN3990/hw1.0 WLAN.HL.3.2.2.c10-00754-QCAHLSWMTPL-1 > > Signed-off-by: Abhishek Kumar > > --- > > > > Changes in v3: > > - As discussed, instead of adding support for default BDF in DT, added > > a method to drop the last elements from full BDF until a BDF is found. > > - Previous patch was "ath10k: search for default BDF name provided in DT" > > > > drivers/net/wireless/ath/ath10k/core.c | 65 +++++++++++++------------- > > 1 file changed, 32 insertions(+), 33 deletions(-) > > > > diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c > > index 688177453b07..ebb0d2a02c28 100644 > > --- a/drivers/net/wireless/ath/ath10k/core.c > > +++ b/drivers/net/wireless/ath/ath10k/core.c > > @@ -1426,15 +1426,31 @@ static int ath10k_core_search_bd(struct ath10k *ar, > > return ret; > > } > > > > +static bool ath10k_create_reduced_boardname(struct ath10k *ar, char *boardname) > > +{ > > + /* Find last BDF element */ > > + char *last_field = strrchr(boardname, ','); > > + > > + if (last_field) { > > + /* Drop the last BDF element */ > > + last_field[0] = '\0'; > > + ath10k_dbg(ar, ATH10K_DBG_BOOT, > > + "boardname =%s\n", boardname); > > nit: strange spacing in the message. i'd expect consistent spacing on > both side of "=", either one space on both sides or no space on both > sides. also the use of "=" here is inconsistent with the use of ":" in > a log later below Ack, will fix this in the next iteration. > > > > + return 0; > > + } > > + return -ENODATA; > > +} > > + > > static int ath10k_core_fetch_board_data_api_n(struct ath10k *ar, > > const char *boardname, > > - const char *fallback_boardname1, > > - const char *fallback_boardname2, > > const char *filename) > > { > > - size_t len, magic_len; > > + size_t len, magic_len, board_len; > > const u8 *data; > > int ret; > > + char temp_boardname[100]; > > + > > + board_len = 100 * sizeof(temp_boardname[0]); > > > > /* Skip if already fetched during board data download */ > > if (!ar->normal_mode_fw.board) > > @@ -1474,20 +1490,24 @@ static int ath10k_core_fetch_board_data_api_n(struct ath10k *ar, > > data += magic_len; > > len -= magic_len; > > > > - /* attempt to find boardname in the IE list */ > > - ret = ath10k_core_search_bd(ar, boardname, data, len); > > + memcpy(temp_boardname, boardname, board_len); > > + ath10k_dbg(ar, ATH10K_DBG_BOOT, "boardname :%s\n", boardname); > > nit: use of ":" inconsistent with use of "=" noted above. > also expect space after ":, not before: "boardname: %s\n" > Ack, will remove the extra space. > > > > > > - /* if we didn't find it and have a fallback name, try that */ > > - if (ret == -ENOENT && fallback_boardname1) > > - ret = ath10k_core_search_bd(ar, fallback_boardname1, data, len); > > +retry_search: > > + /* attempt to find boardname in the IE list */ > > + ret = ath10k_core_search_bd(ar, temp_boardname, data, len); > > > > - if (ret == -ENOENT && fallback_boardname2) > > - ret = ath10k_core_search_bd(ar, fallback_boardname2, data, len); > > + /* If the full BDF entry was not found then drop the last element and > > + * recheck until a BDF is found or until all options are exhausted. > > + */ > > + if (ret == -ENOENT) > > + if (!ath10k_create_reduced_boardname(ar, temp_boardname)) > > + goto retry_search; > > > > if (ret == -ENOENT) { > > note that ath10k_create_reduced_boardname() returns -ENODATA when > truncation fails and hence you won't log this error when that occurs Hmmm, I think it makes sense to log each failure to find as a debug log and log as err only if nothing matches (when ENODATA is returned). > > > > ath10k_err(ar, > > "failed to fetch board data for %s from %s/%s\n", > > - boardname, ar->hw_params.fw.dir, filename); > > + temp_boardname, ar->hw_params.fw.dir, filename); > > does it really make sense to log the last name tried, temp_boardname? or > does it make more sense to still log the original name, boardname? Thinking about it a bit more, it makes sense to log the original name rather than last name. > > > maybe log each failure in the loop, before calling > ath10k_create_reduced_boardname()? As mentioned above, it makes sense to log as debug for each failure to find and log as error if nothing matches, will make this change in the next iteration. > ret = -ENODATA; > } > > @@ -1566,7 +1586,7 @@ static int ath10k_core_create_eboard_name(struct ath10k *ar, char *name, > > int ath10k_core_fetch_board_file(struct ath10k *ar, int bd_ie_type) > { > - char boardname[100], fallback_boardname1[100], fallback_boardname2[100]; > + char boardname[100]; > int ret; > > if (bd_ie_type == ATH10K_BD_IE_BOARD) { > @@ -1579,25 +1599,6 @@ int ath10k_core_fetch_board_file(struct ath10k *ar, int bd_ie_type) > return ret; > } > > - /* Without variant and only chip-id */ > - ret = ath10k_core_create_board_name(ar, fallback_boardname1, > - sizeof(boardname), false, > - true); > - if (ret) { > - ath10k_err(ar, "failed to create 1st fallback board name: %d", > - ret); > - return ret; > - } > - > - /* Without variant and without chip-id */ > - ret = ath10k_core_create_board_name(ar, fallback_boardname2, > - sizeof(boardname), false, > - false); > - if (ret) { > - ath10k_err(ar, "failed to create 2nd fallback board name: %d", > - ret); > - return ret; > - } > } else if (bd_ie_type == ATH10K_BD_IE_BOARD_EXT) { > ret = ath10k_core_create_eboard_name(ar, boardname, > sizeof(boardname)); > @@ -1609,8 +1610,6 @@ int ath10k_core_fetch_board_file(struct ath10k *ar, int bd_ie_type) > > ar->bd_api = 2; > ret = ath10k_core_fetch_board_data_api_n(ar, boardname, > - fallback_boardname1, > - fallback_boardname2, > ATH10K_BOARD_API2_FILE); > if (!ret) > goto success; -Abhishek On Mon, May 9, 2022 at 7:04 PM Abhishek Kumar wrote: > > Thanks for the review Jeff, I have replied below and will address these comments in next iteration. I will wait for a day more to get some more reviews and collectively make the change. > > On Mon, May 9, 2022 at 10:22 AM Jeff Johnson wrote: >> >> On 5/8/2022 7:26 PM, Abhishek Kumar wrote: >> > Board data files wrapped inside board-2.bin files are >> > identified based on a combination of bus architecture, >> > chip-id, board-id or variants. Here is one such example >> > of a BDF entry in board-2.bin file: >> > bus=snoc,qmi-board-id=67,qmi-chip-id=320,variant=GO_XXXX >> > It is possible for few platforms none of the combinations >> > of bus,qmi-board,chip-id or variants match, e.g. if >> > board-id is not programmed and thus reads board-id=0xff, >> > there won't be any matching BDF to be found. In such >> > situations, the wlan will fail to enumerate. >> > >> > Currently, to search for BDF, there are two fallback >> > boardnames creates to search for BDFs in case the full BDF >> > is not found. It is still possible that even the fallback >> > boardnames do not match. >> > >> > As an improvement, search for BDF with full BDF combination >> > and perform the fallback searches by stripping down the last >> > elements until a BDF entry is found or none is found for all >> > possible BDF combinations.e.g. >> > Search for initial BDF first then followed by reduced BDF >> > names as follows: >> > bus=snoc,qmi-board-id=67,qmi-chip-id=320,variant=GO_XXXX >> > bus=snoc,qmi-board-id=67,qmi-chip-id=320 >> > bus=snoc,qmi-board-id=67 >> > bus=snoc >> > >> > >> > Tested-on: WCN3990/hw1.0 WLAN.HL.3.2.2.c10-00754-QCAHLSWMTPL-1 >> > Signed-off-by: Abhishek Kumar >> > --- >> > >> > Changes in v3: >> > - As discussed, instead of adding support for default BDF in DT, added >> > a method to drop the last elements from full BDF until a BDF is found. >> > - Previous patch was "ath10k: search for default BDF name provided in DT" >> > >> > drivers/net/wireless/ath/ath10k/core.c | 65 +++++++++++++------------- >> > 1 file changed, 32 insertions(+), 33 deletions(-) >> > >> > diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c >> > index 688177453b07..ebb0d2a02c28 100644 >> > --- a/drivers/net/wireless/ath/ath10k/core.c >> > +++ b/drivers/net/wireless/ath/ath10k/core.c >> > @@ -1426,15 +1426,31 @@ static int ath10k_core_search_bd(struct ath10k *ar, >> > return ret; >> > } >> > >> > +static bool ath10k_create_reduced_boardname(struct ath10k *ar, char *boardname) >> > +{ >> > + /* Find last BDF element */ >> > + char *last_field = strrchr(boardname, ','); >> > + >> > + if (last_field) { >> > + /* Drop the last BDF element */ >> > + last_field[0] = '\0'; >> > + ath10k_dbg(ar, ATH10K_DBG_BOOT, >> > + "boardname =%s\n", boardname); >> >> nit: strange spacing in the message. i'd expect consistent spacing on >> both side of "=", either one space on both sides or no space on both >> sides. also the use of "=" here is inconsistent with the use of ":" in >> a log later below > > Ack, will fix this in the next iteration. >> >> >> > + return 0; >> > + } >> > + return -ENODATA; >> > +} >> > + >> > static int ath10k_core_fetch_board_data_api_n(struct ath10k *ar, >> > const char *boardname, >> > - const char *fallback_boardname1, >> > - const char *fallback_boardname2, >> > const char *filename) >> > { >> > - size_t len, magic_len; >> > + size_t len, magic_len, board_len; >> > const u8 *data; >> > int ret; >> > + char temp_boardname[100]; >> > + >> > + board_len = 100 * sizeof(temp_boardname[0]); >> > >> > /* Skip if already fetched during board data download */ >> > if (!ar->normal_mode_fw.board) >> > @@ -1474,20 +1490,24 @@ static int ath10k_core_fetch_board_data_api_n(struct ath10k *ar, >> > data += magic_len; >> > len -= magic_len; >> > >> > - /* attempt to find boardname in the IE list */ >> > - ret = ath10k_core_search_bd(ar, boardname, data, len); >> > + memcpy(temp_boardname, boardname, board_len); >> > + ath10k_dbg(ar, ATH10K_DBG_BOOT, "boardname :%s\n", boardname); >> >> nit: use of ":" inconsistent with use of "=" noted above. >> also expect space after ":, not before: "boardname: %s\n" >> > Ack, will remove the extra space. >> >> >> > >> > - /* if we didn't find it and have a fallback name, try that */ >> > - if (ret == -ENOENT && fallback_boardname1) >> > - ret = ath10k_core_search_bd(ar, fallback_boardname1, data, len); >> > +retry_search: >> > + /* attempt to find boardname in the IE list */ >> > + ret = ath10k_core_search_bd(ar, temp_boardname, data, len); >> > >> > - if (ret == -ENOENT && fallback_boardname2) >> > - ret = ath10k_core_search_bd(ar, fallback_boardname2, data, len); >> > + /* If the full BDF entry was not found then drop the last element and >> > + * recheck until a BDF is found or until all options are exhausted. >> > + */ >> > + if (ret == -ENOENT) >> > + if (!ath10k_create_reduced_boardname(ar, temp_boardname)) >> > + goto retry_search; >> > >> > if (ret == -ENOENT) { >> >> note that ath10k_create_reduced_boardname() returns -ENODATA when >> truncation fails and hence you won't log this error when that occurs > > Hmmm, I think it makes sense to log each failure to find as a debug log and log as err only if nothing matches (when ENODATA is returned). >> >> >> > ath10k_err(ar, >> > "failed to fetch board data for %s from %s/%s\n", >> > - boardname, ar->hw_params.fw.dir, filename); >> > + temp_boardname, ar->hw_params.fw.dir, filename); >> >> does it really make sense to log the last name tried, temp_boardname? or >> does it make more sense to still log the original name, boardname? > > Thinking about it a bit more, it makes sense to log the original name rather than last name. >> >> >> maybe log each failure in the loop, before calling >> ath10k_create_reduced_boardname()? > > As mentioned above, it makes sense to log as debug for each failure to find and log as error if nothing matches, will make this change in next iteration. >> >> >> > ret = -ENODATA; >> > } >> > >> > @@ -1566,7 +1586,7 @@ static int ath10k_core_create_eboard_name(struct ath10k *ar, char *name, >> > >> > int ath10k_core_fetch_board_file(struct ath10k *ar, int bd_ie_type) >> > { >> > - char boardname[100], fallback_boardname1[100], fallback_boardname2[100]; >> > + char boardname[100]; >> > int ret; >> > >> > if (bd_ie_type == ATH10K_BD_IE_BOARD) { >> > @@ -1579,25 +1599,6 @@ int ath10k_core_fetch_board_file(struct ath10k *ar, int bd_ie_type) >> > return ret; >> > } >> > >> > - /* Without variant and only chip-id */ >> > - ret = ath10k_core_create_board_name(ar, fallback_boardname1, >> > - sizeof(boardname), false, >> > - true); >> > - if (ret) { >> > - ath10k_err(ar, "failed to create 1st fallback board name: %d", >> > - ret); >> > - return ret; >> > - } >> > - >> > - /* Without variant and without chip-id */ >> > - ret = ath10k_core_create_board_name(ar, fallback_boardname2, >> > - sizeof(boardname), false, >> > - false); >> > - if (ret) { >> > - ath10k_err(ar, "failed to create 2nd fallback board name: %d", >> > - ret); >> > - return ret; >> > - } >> > } else if (bd_ie_type == ATH10K_BD_IE_BOARD_EXT) { >> > ret = ath10k_core_create_eboard_name(ar, boardname, >> > sizeof(boardname)); >> > @@ -1609,8 +1610,6 @@ int ath10k_core_fetch_board_file(struct ath10k *ar, int bd_ie_type) >> > >> > ar->bd_api = 2; >> > ret = ath10k_core_fetch_board_data_api_n(ar, boardname, >> > - fallback_boardname1, >> > - fallback_boardname2, >> > ATH10K_BOARD_API2_FILE); >> > if (!ret) >> > goto success; > > -Abhishek