netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Rahul Verma <Rahul.Verma@cavium.com>,
	Rahul Verma <rahul.verma@cavium.com>,
	Ariel Elior <ariel.elior@cavium.com>,
	"David S . Miller" <davem@davemloft.net>,
	Sasha Levin <sashal@kernel.org>,
	netdev@vger.kernel.org
Subject: [PATCH AUTOSEL 4.14 026/150] qed: Align local and global PTT to propagate through the APIs.
Date: Sat, 16 Nov 2019 10:45:24 -0500	[thread overview]
Message-ID: <20191116154729.9573-26-sashal@kernel.org> (raw)
In-Reply-To: <20191116154729.9573-1-sashal@kernel.org>

From: Rahul Verma <Rahul.Verma@cavium.com>

[ Upstream commit 706d08913d1f68610c32b4a001026aa989878dd9 ]

    Align the use of local PTT to propagate through the qed_mcp* API's.
    Global ptt should not be used.

    Register access should be done through layers. Register address is
    mapped into a PTT, PF translation table. Several interface functions
    require a PTT to direct read/write into register. There is a pool of
    PTT maintained, and several PTT are used simultaneously to access
    device registers in different flows. Same PTT should not be used in
    flows that can run concurrently.
    To avoid running out of PTT resources, too many PTT should not be
    acquired without releasing them. Every PF has a global PTT, which is
    used throughout the life of PF, in most important flows for register
    access. Generic functions acquire the PTT locally and release after
    the use. This patch aligns the use of Global PTT and Local PTT
    accordingly.

Signed-off-by: Rahul Verma <rahul.verma@cavium.com>
Signed-off-by: Ariel Elior <ariel.elior@cavium.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/ethernet/qlogic/qed/qed.h      |  2 +-
 drivers/net/ethernet/qlogic/qed/qed_main.c | 22 ++++++++++++++----
 drivers/net/ethernet/qlogic/qed/qed_mcp.c  | 27 ++++++++++------------
 drivers/net/ethernet/qlogic/qed/qed_mcp.h  |  5 ++--
 drivers/net/ethernet/qlogic/qed/qed_vf.c   |  2 +-
 5 files changed, 35 insertions(+), 23 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qed/qed.h b/drivers/net/ethernet/qlogic/qed/qed.h
index 91003bc6f00bd..6c4714a8b54ce 100644
--- a/drivers/net/ethernet/qlogic/qed/qed.h
+++ b/drivers/net/ethernet/qlogic/qed/qed.h
@@ -829,7 +829,7 @@ u16 qed_get_cm_pq_idx_vf(struct qed_hwfn *p_hwfn, u16 vf);
 /* Prototypes */
 int qed_fill_dev_info(struct qed_dev *cdev,
 		      struct qed_dev_info *dev_info);
-void qed_link_update(struct qed_hwfn *hwfn);
+void qed_link_update(struct qed_hwfn *hwfn, struct qed_ptt *ptt);
 u32 qed_unzip_data(struct qed_hwfn *p_hwfn,
 		   u32 input_len, u8 *input_buf,
 		   u32 max_size, u8 *unzip_buf);
diff --git a/drivers/net/ethernet/qlogic/qed/qed_main.c b/drivers/net/ethernet/qlogic/qed/qed_main.c
index 557332f1f886c..52e747fd9c839 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_main.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_main.c
@@ -1389,6 +1389,7 @@ static int qed_get_link_data(struct qed_hwfn *hwfn,
 }
 
 static void qed_fill_link(struct qed_hwfn *hwfn,
+			  struct qed_ptt *ptt,
 			  struct qed_link_output *if_link)
 {
 	struct qed_mcp_link_params params;
@@ -1469,7 +1470,7 @@ static void qed_fill_link(struct qed_hwfn *hwfn,
 
 	/* TODO - fill duplex properly */
 	if_link->duplex = DUPLEX_FULL;
-	qed_mcp_get_media_type(hwfn->cdev, &media_type);
+	qed_mcp_get_media_type(hwfn, ptt, &media_type);
 	if_link->port = qed_get_port_type(media_type);
 
 	if_link->autoneg = params.speed.autoneg;
@@ -1525,21 +1526,34 @@ static void qed_fill_link(struct qed_hwfn *hwfn,
 static void qed_get_current_link(struct qed_dev *cdev,
 				 struct qed_link_output *if_link)
 {
+	struct qed_hwfn *hwfn;
+	struct qed_ptt *ptt;
 	int i;
 
-	qed_fill_link(&cdev->hwfns[0], if_link);
+	hwfn = &cdev->hwfns[0];
+	if (IS_PF(cdev)) {
+		ptt = qed_ptt_acquire(hwfn);
+		if (ptt) {
+			qed_fill_link(hwfn, ptt, if_link);
+			qed_ptt_release(hwfn, ptt);
+		} else {
+			DP_NOTICE(hwfn, "Failed to fill link; No PTT\n");
+		}
+	} else {
+		qed_fill_link(hwfn, NULL, if_link);
+	}
 
 	for_each_hwfn(cdev, i)
 		qed_inform_vf_link_state(&cdev->hwfns[i]);
 }
 
-void qed_link_update(struct qed_hwfn *hwfn)
+void qed_link_update(struct qed_hwfn *hwfn, struct qed_ptt *ptt)
 {
 	void *cookie = hwfn->cdev->ops_cookie;
 	struct qed_common_cb_ops *op = hwfn->cdev->protocol_ops.common;
 	struct qed_link_output if_link;
 
-	qed_fill_link(hwfn, &if_link);
+	qed_fill_link(hwfn, ptt, &if_link);
 	qed_inform_vf_link_state(hwfn);
 
 	if (IS_LEAD_HWFN(hwfn) && cookie)
diff --git a/drivers/net/ethernet/qlogic/qed/qed_mcp.c b/drivers/net/ethernet/qlogic/qed/qed_mcp.c
index 7938abe9a3010..ef17ca09d3038 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_mcp.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_mcp.c
@@ -1352,7 +1352,7 @@ static void qed_mcp_handle_link_change(struct qed_hwfn *p_hwfn,
 	if (p_hwfn->mcp_info->capabilities & FW_MB_PARAM_FEATURE_SUPPORT_EEE)
 		qed_mcp_read_eee_config(p_hwfn, p_ptt, p_link);
 
-	qed_link_update(p_hwfn);
+	qed_link_update(p_hwfn, p_ptt);
 out:
 	spin_unlock_bh(&p_hwfn->mcp_info->link_lock);
 }
@@ -1722,12 +1722,10 @@ int qed_mcp_get_mbi_ver(struct qed_hwfn *p_hwfn,
 	return 0;
 }
 
-int qed_mcp_get_media_type(struct qed_dev *cdev, u32 *p_media_type)
+int qed_mcp_get_media_type(struct qed_hwfn *p_hwfn,
+			   struct qed_ptt *p_ptt, u32 *p_media_type)
 {
-	struct qed_hwfn *p_hwfn = &cdev->hwfns[0];
-	struct qed_ptt  *p_ptt;
-
-	if (IS_VF(cdev))
+	if (IS_VF(p_hwfn->cdev))
 		return -EINVAL;
 
 	if (!qed_mcp_is_init(p_hwfn)) {
@@ -1735,16 +1733,15 @@ int qed_mcp_get_media_type(struct qed_dev *cdev, u32 *p_media_type)
 		return -EBUSY;
 	}
 
-	*p_media_type = MEDIA_UNSPECIFIED;
-
-	p_ptt = qed_ptt_acquire(p_hwfn);
-	if (!p_ptt)
-		return -EBUSY;
-
-	*p_media_type = qed_rd(p_hwfn, p_ptt, p_hwfn->mcp_info->port_addr +
-			       offsetof(struct public_port, media_type));
+	if (!p_ptt) {
+		*p_media_type = MEDIA_UNSPECIFIED;
+		return -EINVAL;
+	}
 
-	qed_ptt_release(p_hwfn, p_ptt);
+	*p_media_type = qed_rd(p_hwfn, p_ptt,
+			       p_hwfn->mcp_info->port_addr +
+			       offsetof(struct public_port,
+					media_type));
 
 	return 0;
 }
diff --git a/drivers/net/ethernet/qlogic/qed/qed_mcp.h b/drivers/net/ethernet/qlogic/qed/qed_mcp.h
index f1fe5e3427ea5..8fcdb2c3e5dba 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_mcp.h
+++ b/drivers/net/ethernet/qlogic/qed/qed_mcp.h
@@ -284,14 +284,15 @@ int qed_mcp_get_mbi_ver(struct qed_hwfn *p_hwfn,
  * @brief Get media type value of the port.
  *
  * @param cdev      - qed dev pointer
+ * @param p_ptt
  * @param mfw_ver    - media type value
  *
  * @return int -
  *      0 - Operation was successul.
  *      -EBUSY - Operation failed
  */
-int qed_mcp_get_media_type(struct qed_dev      *cdev,
-			   u32                  *media_type);
+int qed_mcp_get_media_type(struct qed_hwfn *p_hwfn,
+			   struct qed_ptt *p_ptt, u32 *media_type);
 
 /**
  * @brief General function for sending commands to the MCP
diff --git a/drivers/net/ethernet/qlogic/qed/qed_vf.c b/drivers/net/ethernet/qlogic/qed/qed_vf.c
index 3220086f99dea..a2a9921b467b1 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_vf.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_vf.c
@@ -1669,7 +1669,7 @@ static void qed_handle_bulletin_change(struct qed_hwfn *hwfn)
 	ops->ports_update(cookie, vxlan_port, geneve_port);
 
 	/* Always update link configuration according to bulletin */
-	qed_link_update(hwfn);
+	qed_link_update(hwfn, NULL);
 }
 
 void qed_iov_vf_task(struct work_struct *work)
-- 
2.20.1


  parent reply	other threads:[~2019-11-16 16:13 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20191116154729.9573-1-sashal@kernel.org>
2019-11-16 15:45 ` [PATCH AUTOSEL 4.14 010/150] brcmsmac: AP mode: update beacon when TIM changes Sasha Levin
2019-11-16 15:45 ` [PATCH AUTOSEL 4.14 011/150] ath10k: allocate small size dma memory in ath10k_pci_diag_write_mem Sasha Levin
2019-11-16 15:45 ` Sasha Levin [this message]
2019-11-16 15:45 ` [PATCH AUTOSEL 4.14 041/150] net: dsa: mv88e6xxx: Fix 88E6141/6341 2500mbps SERDES speed Sasha Levin
2019-11-16 15:45 ` [PATCH AUTOSEL 4.14 042/150] net: fix warning in af_unix Sasha Levin
2019-11-16 15:45 ` [PATCH AUTOSEL 4.14 043/150] net: ena: Fix Kconfig dependency on X86 Sasha Levin
2019-11-16 15:45 ` [PATCH AUTOSEL 4.14 053/150] SUNRPC: Fix a compile warning for cmpxchg64() Sasha Levin
2019-11-16 15:45 ` [PATCH AUTOSEL 4.14 054/150] sunrpc: safely reallow resvport min/max inversion Sasha Levin
2019-11-16 15:45 ` [PATCH AUTOSEL 4.14 055/150] atm: zatm: Fix empty body Clang warnings Sasha Levin
2019-11-16 15:45 ` [PATCH AUTOSEL 4.14 061/150] libceph: don't consume a ref on pagelist in ceph_msg_data_add_pagelist() Sasha Levin
2019-11-16 15:46 ` [PATCH AUTOSEL 4.14 064/150] mISDN: Fix type of switch control variable in ctrl_teimanager Sasha Levin
2019-11-16 15:46 ` [PATCH AUTOSEL 4.14 065/150] qlcnic: fix a return in qlcnic_dcb_get_capability() Sasha Levin
2019-11-16 15:46 ` [PATCH AUTOSEL 4.14 066/150] net: ethernet: ti: cpsw: unsync mcast entries while switch promisc mode Sasha Levin
2019-11-16 15:46 ` [PATCH AUTOSEL 4.14 075/150] bpf: devmap: fix wrong interface selection in notifier_call Sasha Levin
2019-11-16 15:46 ` [PATCH AUTOSEL 4.14 077/150] sparc64: Rework xchg() definition to avoid warnings Sasha Levin
2019-11-16 15:46 ` [PATCH AUTOSEL 4.14 081/150] macsec: update operstate when lower device changes Sasha Levin
2019-11-16 15:46 ` [PATCH AUTOSEL 4.14 082/150] macsec: let the administrator set UP state even if lowerdev is down Sasha Levin
2019-11-16 15:46 ` [PATCH AUTOSEL 4.14 105/150] igb: shorten maximum PHC timecounter update interval Sasha Levin
2019-11-16 15:46 ` [PATCH AUTOSEL 4.14 106/150] net: hns3: bugfix for buffer not free problem during resetting Sasha Levin
2019-11-16 15:46 ` [PATCH AUTOSEL 4.14 107/150] ntb_netdev: fix sleep time mismatch Sasha Levin
2019-11-16 15:46 ` [PATCH AUTOSEL 4.14 113/150] net: do not abort bulk send on BQL status Sasha Levin
2019-11-16 15:46 ` [PATCH AUTOSEL 4.14 116/150] openvswitch: fix linking without CONFIG_NF_CONNTRACK_LABELS Sasha Levin
2019-11-16 15:46 ` [PATCH AUTOSEL 4.14 120/150] wil6210: fix locking in wmi_call Sasha Levin
2019-11-16 15:46 ` [PATCH AUTOSEL 4.14 121/150] wlcore: Fix the return value in case of error in 'wlcore_vendor_cmd_smart_config_start()' Sasha Levin
2019-11-16 15:47 ` [PATCH AUTOSEL 4.14 122/150] rtl8xxxu: Fix missing break in switch Sasha Levin
2019-11-16 15:47 ` [PATCH AUTOSEL 4.14 123/150] brcmsmac: never log "tid x is not agg'able" by default Sasha Levin
2019-11-16 15:47 ` [PATCH AUTOSEL 4.14 124/150] wireless: airo: potential buffer overflow in sprintf() Sasha Levin
2019-11-16 15:47 ` [PATCH AUTOSEL 4.14 125/150] rtlwifi: rtl8192de: Fix misleading REG_MCUFWDL information Sasha Levin
2019-11-16 15:47 ` [PATCH AUTOSEL 4.14 126/150] net: dsa: bcm_sf2: Turn on PHY to allow successful registration Sasha Levin
2019-11-16 15:47 ` [PATCH AUTOSEL 4.14 136/150] vrf: mark skb for multicast or link-local as enslaved to VRF Sasha Levin
2019-11-16 15:47 ` [PATCH AUTOSEL 4.14 138/150] net: bcmgenet: return correct value 'ret' from bcmgenet_power_down Sasha Levin
2019-11-16 15:47 ` [PATCH AUTOSEL 4.14 139/150] sock: Reset dst when changing sk_mark via setsockopt Sasha Levin
2019-11-16 15:47 ` [PATCH AUTOSEL 4.14 141/150] cfg80211: Prevent regulatory restore during STA disconnect in concurrent interfaces Sasha Levin
2019-11-16 15:47 ` [PATCH AUTOSEL 4.14 149/150] ipv6: Fix handling of LLA with VRF and sockets bound to VRF Sasha Levin
2019-11-16 15:47 ` [PATCH AUTOSEL 4.14 150/150] cfg80211: call disconnect_wk when AP stops Sasha Levin

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=20191116154729.9573-26-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=Rahul.Verma@cavium.com \
    --cc=ariel.elior@cavium.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
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;
as well as URLs for NNTP newsgroup(s).