public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Michael Chan <michael.chan@broadcom•com>
To: davem@davemloft•net
Cc: netdev@vger•kernel.org, edumazet@google•com, kuba@kernel•org,
	pabeni@redhat•com, gospo@broadcom•com,
	Kalesh AP <kalesh-anakkur.purayil@broadcom•com>,
	Somnath Kotur <somnath.kotur@broadcom•com>
Subject: [PATCH net-next v2 2/9] bnxt_en: Enhance hwmon temperature reporting
Date: Tue, 26 Sep 2023 20:57:27 -0700	[thread overview]
Message-ID: <20230927035734.42816-3-michael.chan@broadcom.com> (raw)
In-Reply-To: <20230927035734.42816-1-michael.chan@broadcom.com>

[-- Attachment #1: Type: text/plain, Size: 3039 bytes --]

From: Kalesh AP <kalesh-anakkur.purayil@broadcom•com>

Driver currently does hwmon device register and unregister
in open and close() respectively. As a result, user will not
be able to query hwmon temperature when interface is in
ifdown state.

Enhance it by moving the hwmon register/unregister to the
probe/remove functions.

Reviewed-by: Somnath Kotur <somnath.kotur@broadcom•com>
Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom•com>
Signed-off-by: Michael Chan <michael.chan@broadcom•com>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 7551aa8068f8..785084147994 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -10280,7 +10280,7 @@ static struct attribute *bnxt_attrs[] = {
 };
 ATTRIBUTE_GROUPS(bnxt);
 
-static void bnxt_hwmon_close(struct bnxt *bp)
+static void bnxt_hwmon_uninit(struct bnxt *bp)
 {
 	if (bp->hwmon_dev) {
 		hwmon_device_unregister(bp->hwmon_dev);
@@ -10288,7 +10288,7 @@ static void bnxt_hwmon_close(struct bnxt *bp)
 	}
 }
 
-static void bnxt_hwmon_open(struct bnxt *bp)
+static void bnxt_hwmon_init(struct bnxt *bp)
 {
 	struct hwrm_temp_monitor_query_input *req;
 	struct pci_dev *pdev = bp->pdev;
@@ -10298,7 +10298,7 @@ static void bnxt_hwmon_open(struct bnxt *bp)
 	if (!rc)
 		rc = hwrm_req_send_silent(bp, req);
 	if (rc == -EACCES || rc == -EOPNOTSUPP) {
-		bnxt_hwmon_close(bp);
+		bnxt_hwmon_uninit(bp);
 		return;
 	}
 
@@ -10314,11 +10314,11 @@ static void bnxt_hwmon_open(struct bnxt *bp)
 	}
 }
 #else
-static void bnxt_hwmon_close(struct bnxt *bp)
+static void bnxt_hwmon_uninit(struct bnxt *bp)
 {
 }
 
-static void bnxt_hwmon_open(struct bnxt *bp)
+static void bnxt_hwmon_init(struct bnxt *bp)
 {
 }
 #endif
@@ -10651,7 +10651,6 @@ static int bnxt_open(struct net_device *dev)
 				bnxt_reenable_sriov(bp);
 			}
 		}
-		bnxt_hwmon_open(bp);
 	}
 
 	return rc;
@@ -10736,7 +10735,6 @@ static int bnxt_close(struct net_device *dev)
 {
 	struct bnxt *bp = netdev_priv(dev);
 
-	bnxt_hwmon_close(bp);
 	bnxt_close_nic(bp, true, true);
 	bnxt_hwrm_shutdown_link(bp);
 	bnxt_hwrm_if_change(bp, false);
@@ -12300,6 +12298,7 @@ static int bnxt_fw_init_one_p2(struct bnxt *bp)
 	if (bp->fw_cap & BNXT_FW_CAP_PTP)
 		__bnxt_hwrm_ptp_qcfg(bp);
 	bnxt_dcb_init(bp);
+	bnxt_hwmon_init(bp);
 	return 0;
 }
 
@@ -13205,6 +13204,7 @@ static void bnxt_remove_one(struct pci_dev *pdev)
 	bnxt_clear_int_mode(bp);
 	bnxt_hwrm_func_drv_unrgtr(bp);
 	bnxt_free_hwrm_resources(bp);
+	bnxt_hwmon_uninit(bp);
 	bnxt_ethtool_free(bp);
 	bnxt_dcb_free(bp);
 	kfree(bp->ptp_cfg);
@@ -13801,6 +13801,7 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 init_err_pci_clean:
 	bnxt_hwrm_func_drv_unrgtr(bp);
 	bnxt_free_hwrm_resources(bp);
+	bnxt_hwmon_uninit(bp);
 	bnxt_ethtool_free(bp);
 	bnxt_ptp_clear(bp);
 	kfree(bp->ptp_cfg);
-- 
2.30.1


[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4209 bytes --]

  parent reply	other threads:[~2023-09-27  3:58 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-27  3:57 [PATCH net-next v2 0/9] bnxt_en: hwmon and SRIOV updates Michael Chan
2023-09-27  3:57 ` [PATCH net-next v2 1/9] bnxt_en: Update firmware interface to 1.10.2.171 Michael Chan
2023-09-27 12:34   ` Andrew Lunn
2023-09-27 17:20     ` Michael Chan
2023-09-27  3:57 ` Michael Chan [this message]
2023-09-27  3:57 ` [PATCH net-next v2 3/9] bnxt_en: Move hwmon functions into a dedicated file Michael Chan
2023-09-27 13:55   ` Guenter Roeck
2023-09-27  3:57 ` [PATCH net-next v2 4/9] bnxt_en: Modify the driver to use hwmon_device_register_with_info Michael Chan
2023-09-27 13:56   ` Guenter Roeck
2023-09-27  3:57 ` [PATCH net-next v2 5/9] bnxt_en: Expose threshold temperatures through hwmon Michael Chan
2023-09-27 14:04   ` Guenter Roeck
2023-09-27  3:57 ` [PATCH net-next v2 6/9] bnxt_en: Use non-standard attribute to expose shutdown temperature Michael Chan
2023-09-27  3:57 ` [PATCH net-next v2 7/9] bnxt_en: Event handler for Thermal event Michael Chan
2023-09-27 14:05   ` Guenter Roeck
2023-09-27  3:57 ` [PATCH net-next v2 8/9] bnxt_en: Support QOS and TPID settings for the SRIOV VLAN Michael Chan
2023-10-04 18:22   ` Jakub Kicinski
2023-09-27  3:57 ` [PATCH net-next v2 9/9] bnxt_en: Update VNIC resource calculation for VFs Michael Chan
2023-10-03  9:11 ` [PATCH net-next v2 0/9] bnxt_en: hwmon and SRIOV updates Simon Horman
2023-10-04 10:30 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230927035734.42816-3-michael.chan@broadcom.com \
    --to=michael.chan@broadcom$(echo .)com \
    --cc=davem@davemloft$(echo .)net \
    --cc=edumazet@google$(echo .)com \
    --cc=gospo@broadcom$(echo .)com \
    --cc=kalesh-anakkur.purayil@broadcom$(echo .)com \
    --cc=kuba@kernel$(echo .)org \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=pabeni@redhat$(echo .)com \
    --cc=somnath.kotur@broadcom$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox