Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7f6a034a authored by Yue Ma's avatar Yue Ma
Browse files

cnss2: Expose PCIe window register lock related APIs



The register window needs to be configed properly before accessing
any larger than 4K range PCIe registers. Expose the lock to WLAN
driver to avoid race condition when both drivers try to config it.

Change-Id: I94ccd963d4fd0a9715330d2e5733346ccd993ae1
Signed-off-by: default avatarYue Ma <yuem@codeaurora.org>
parent aa28d2b1
Loading
Loading
Loading
Loading
+16 −6
Original line number Diff line number Diff line
@@ -391,7 +391,6 @@ static int cnss_pci_reg_read(struct cnss_pci_data *pci_priv,
			     u32 offset, u32 *val)
{
	int ret;
	unsigned long flags;

	ret = cnss_pci_check_link_status(pci_priv);
	if (ret)
@@ -403,12 +402,12 @@ static int cnss_pci_reg_read(struct cnss_pci_data *pci_priv,
		return 0;
	}

	spin_lock_irqsave(&pci_reg_window_lock, flags);
	spin_lock_bh(&pci_reg_window_lock);
	cnss_pci_select_window(pci_priv, offset);

	*val = readl_relaxed(pci_priv->bar + WINDOW_START +
			     (offset & WINDOW_RANGE_MASK));
	spin_unlock_irqrestore(&pci_reg_window_lock, flags);
	spin_unlock_bh(&pci_reg_window_lock);

	return 0;
}
@@ -417,7 +416,6 @@ static int cnss_pci_reg_write(struct cnss_pci_data *pci_priv, u32 offset,
			      u32 val)
{
	int ret;
	unsigned long flags;

	ret = cnss_pci_check_link_status(pci_priv);
	if (ret)
@@ -429,12 +427,12 @@ static int cnss_pci_reg_write(struct cnss_pci_data *pci_priv, u32 offset,
		return 0;
	}

	spin_lock_irqsave(&pci_reg_window_lock, flags);
	spin_lock_bh(&pci_reg_window_lock);
	cnss_pci_select_window(pci_priv, offset);

	writel_relaxed(val, pci_priv->bar + WINDOW_START +
		       (offset & WINDOW_RANGE_MASK));
	spin_unlock_irqrestore(&pci_reg_window_lock, flags);
	spin_unlock_bh(&pci_reg_window_lock);

	return 0;
}
@@ -805,6 +803,18 @@ int cnss_pci_is_device_down(struct device *dev)
}
EXPORT_SYMBOL(cnss_pci_is_device_down);

void cnss_pci_lock_reg_window(struct device *dev, unsigned long *flags)
{
	spin_lock_bh(&pci_reg_window_lock);
}
EXPORT_SYMBOL(cnss_pci_lock_reg_window);

void cnss_pci_unlock_reg_window(struct device *dev, unsigned long *flags)
{
	spin_unlock_bh(&pci_reg_window_lock);
}
EXPORT_SYMBOL(cnss_pci_unlock_reg_window);

static char *cnss_mhi_state_to_str(enum cnss_mhi_state mhi_state)
{
	switch (mhi_state) {
+3 −0
Original line number Diff line number Diff line
@@ -190,6 +190,9 @@ extern void cnss_request_pm_qos(struct device *dev, u32 qos_val);
extern void cnss_remove_pm_qos(struct device *dev);
extern void cnss_lock_pm_sem(struct device *dev);
extern void cnss_release_pm_sem(struct device *dev);
extern void cnss_pci_lock_reg_window(struct device *dev, unsigned long *flags);
extern void cnss_pci_unlock_reg_window(struct device *dev,
				       unsigned long *flags);
extern int cnss_wlan_pm_control(struct device *dev, bool vote);
extern int cnss_auto_suspend(struct device *dev);
extern int cnss_auto_resume(struct device *dev);