From patchwork Fri Aug 3 11:03:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 10554961 X-Patchwork-Delegate: idosch@idosch.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 047B815A6 for ; Fri, 3 Aug 2018 11:06:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E2B972BD93 for ; Fri, 3 Aug 2018 11:06:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D6B662C23F; Fri, 3 Aug 2018 11:06:49 +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=-2.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4FBAB2BD93 for ; Fri, 3 Aug 2018 11:06:48 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41hkkr20XGzF1mh for ; Fri, 3 Aug 2018 21:06:44 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=resnulli.us Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=resnulli-us.20150623.gappssmtp.com header.i=@resnulli-us.20150623.gappssmtp.com header.b="l/BNPQr4"; dkim-atps=neutral X-Original-To: linux-mlxsw@lists.ozlabs.org Delivered-To: linux-mlxsw@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=resnulli.us (client-ip=2a00:1450:400c:c09::243; helo=mail-wm0-x243.google.com; envelope-from=jiri@resnulli.us; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=resnulli.us Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=resnulli-us.20150623.gappssmtp.com header.i=@resnulli-us.20150623.gappssmtp.com header.b="l/BNPQr4"; dkim-atps=neutral Received: from mail-wm0-x243.google.com (mail-wm0-x243.google.com [IPv6:2a00:1450:400c:c09::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41hkkj3ykKzF12N for ; Fri, 3 Aug 2018 21:06:34 +1000 (AEST) Received: by mail-wm0-x243.google.com with SMTP id w24-v6so5977207wmc.1 for ; Fri, 03 Aug 2018 04:06:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=765q0loSwgT3yPZ4NIsgjh0xhPBvIv4W93+qhwgnhJo=; b=l/BNPQr4S8HPCq3rneZu/iQkZlc3HfiOzD/jE+WYucaU/0OZoDlQr88B9K0pMtrCh8 0ILkeOQSPkVgQSZgJEnIwqHPWDqz8ULx9IkjKtdEgpzjCir45gQsTAWgtWE5oy0W/K3U VvdttUKEkQhUPjA6odAE7Uhpb2oERs+DlEF+dBLesBjYqKONr8nVFZUkXzQu9/y5NPlY q7JftEbeHPIGdwFN8v4uqqlJ3eGxcoZV8FYpx6ns13BACk3vdmWZ5GM8GzWMq6LuNV+G HSr7alAm1D0eNvJZsSACUz8b/hOHgGCJQdzRYecILHAnC+zTMpuSuHjqbT0hdFOPzWtZ IXTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=765q0loSwgT3yPZ4NIsgjh0xhPBvIv4W93+qhwgnhJo=; b=jjP3FwK0JBhJSFNXk3DmWwOlO6au4CnRo/nR9fx3LIW03WW2VDya6jyjt77hLha6al rll/cWlm/pvI60MJN5v8Zg0aUn99COlKDVBh+snWNcRCnpwYUxAWgY96ypUNu2CFM/y1 jl8QKTfIrFrR4WziaoMN4LFtGkDaAfxlCnnv8vy56mO2Yxiv88Nva6OuVKr0fB9M28v4 L2ti1nonjTsVmBn5Szmto+OxYRASLifKBIF6aOqh36loXpMEEk690opmlDbpF0D/km+8 RFn5MXHqk/d+7rJTnvyBgi0q6lmqRfM1sQRfnyVciaGUjnTBjLthdK2VB8eSE1e2wPXb qlFg== X-Gm-Message-State: AOUpUlEG9braDX+sL6Q3rLDekOskjoyASkQqwIu08lHAi0ZkX6QlqzfP WVPZyNdK9BJTxbxgfYmlvtcP+Q== X-Google-Smtp-Source: AAOMgpcDb9OPQWZfTbTKqifn7rfns1jNVreWBw0DEGAsE4xhfmiqXTpmkWKTns3AFizAhDunlaJRbw== X-Received: by 2002:a1c:7d47:: with SMTP id y68-v6mr4401257wmc.62.1533294391943; Fri, 03 Aug 2018 04:06:31 -0700 (PDT) Received: from localhost (static-cl188134168102.unet.cz. [188.134.168.102]) by smtp.gmail.com with ESMTPSA id n14-v6sm4053533wmc.14.2018.08.03.04.06.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 03 Aug 2018 04:06:31 -0700 (PDT) From: Jiri Pirko To: linux-internal@mellanox.com Subject: [patch net-next/mlxsw internal v2] mlxsw: spectrum: Reset FW after flash Date: Fri, 3 Aug 2018 13:03:42 +0200 Message-Id: <20180803110342.3875-1-jiri@resnulli.us> X-Mailer: git-send-email 2.14.4 X-BeenThere: linux-mlxsw@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: mlxsw driver development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linux-mlxsw-bounces+patchwork-linux-mlxsw=patchwork.kernel.org@lists.ozlabs.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jiri Pirko Recent FW fixes a bug and allows to load newly flashed FW image after reset. So make sure the reset happens after flash. Indicate the need down to PCI layer by -EAGAIN. Signed-off-by: Jiri Pirko v1->v2: - can_reset rename - can_reset is put to per-asic req struct - fixed description (s/Current/recent/) --- drivers/net/ethernet/mellanox/mlxsw/core.h | 1 + drivers/net/ethernet/mellanox/mlxsw/pci.c | 11 ++++++++++- drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 17 +++++++++++++---- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.h b/drivers/net/ethernet/mellanox/mlxsw/core.h index 1ff058d79668..655ddd204ab2 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core.h +++ b/drivers/net/ethernet/mellanox/mlxsw/core.h @@ -329,6 +329,7 @@ struct mlxsw_fw_rev { u16 major; u16 minor; u16 subminor; + u16 can_reset_minor; }; struct mlxsw_bus_info { diff --git a/drivers/net/ethernet/mellanox/mlxsw/pci.c b/drivers/net/ethernet/mellanox/mlxsw/pci.c index 8c1857fdd583..4bec4f6b80ca 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/pci.c +++ b/drivers/net/ethernet/mellanox/mlxsw/pci.c @@ -1719,6 +1719,7 @@ static int mlxsw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) { const char *driver_name = pdev->driver->name; struct mlxsw_pci *mlxsw_pci; + bool called_again = false; int err; mlxsw_pci = kzalloc(sizeof(*mlxsw_pci), GFP_KERNEL); @@ -1775,10 +1776,18 @@ static int mlxsw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) mlxsw_pci->bus_info.dev = &pdev->dev; mlxsw_pci->id = id; +again: err = mlxsw_core_bus_device_register(&mlxsw_pci->bus_info, &mlxsw_pci_bus, mlxsw_pci, false, NULL); - if (err) { + /* -EAGAIN is returned in case the FW was updated. FW needs + * a reset, so lets try to call mlxsw_core_bus_device_register() + * again. + */ + if (err == -EAGAIN && !called_again) { + called_again = true; + goto again; + } else if (err) { dev_err(&pdev->dev, "cannot register bus device\n"); goto err_bus_device_register; } diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c index e0aa0e5c65b2..073f923b08d1 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c @@ -46,11 +46,13 @@ #define MLXSW_SP1_FWREV_MAJOR 13 #define MLXSW_SP1_FWREV_MINOR 1620 #define MLXSW_SP1_FWREV_SUBMINOR 192 +#define MLXSW_SP1_FWREV_CAN_RESET_MINOR 1702 static const struct mlxsw_fw_rev mlxsw_sp1_fw_rev = { .major = MLXSW_SP1_FWREV_MAJOR, .minor = MLXSW_SP1_FWREV_MINOR, .subminor = MLXSW_SP1_FWREV_SUBMINOR, + .can_reset_minor = MLXSW_SP1_FWREV_CAN_RESET_MINOR, }; #define MLXSW_SP1_FW_FILENAME \ @@ -347,7 +349,16 @@ static int mlxsw_sp_fw_rev_validate(struct mlxsw_sp *mlxsw_sp) err = mlxsw_sp_firmware_flash(mlxsw_sp, firmware); release_firmware(firmware); - return err; + if (err) + dev_err(mlxsw_sp->bus_info->dev, "Could not upgrade firmware\n"); + + /* On FW flash success, tell the caller FW reset is needed + * if current FW supports it. + */ + if (rev->minor >= req_rev->can_reset_minor) + return err ? err : -EAGAIN; + else + return 0; } int mlxsw_sp_flow_counter_get(struct mlxsw_sp *mlxsw_sp, @@ -3701,10 +3712,8 @@ static int mlxsw_sp_init(struct mlxsw_core *mlxsw_core, mlxsw_sp->bus_info = mlxsw_bus_info; err = mlxsw_sp_fw_rev_validate(mlxsw_sp); - if (err) { - dev_err(mlxsw_sp->bus_info->dev, "Could not upgrade firmware\n"); + if (err) return err; - } err = mlxsw_sp_base_mac_get(mlxsw_sp); if (err) {