qcacmn: move runtime_pm related code to common section

Move all the Runtime PM related HIF code changes to the
common section, from if_pci.
So that, could be leveraged for other HIF interfaces
like if_ipci to use.

Change-Id: Id8303acd519ab07f307311971fb55c45476f30bf
CRs-Fixed: 2699419
This commit is contained in:
Vevek Venkatesan 2020-05-15 15:05:03 +05:30 • committed by nshrivas
commit f6f4cfc6f2
9 changed files with 1968 additions and 1685 deletions

View file

@ -267,6 +267,18 @@ void hif_disable_bus(struct hif_softc *hif_sc)
hif_sc->bus_ops.hif_disable_bus(hif_sc);
}
#ifdef FEATURE_RUNTIME_PM
struct hif_runtime_pm_ctx *hif_bus_get_rpm_ctx(struct hif_softc *hif_sc)
{
return hif_sc->bus_ops.hif_bus_get_rpm_ctx(hif_sc);
}
struct device *hif_bus_get_dev(struct hif_softc *hif_sc)
{
return hif_sc->bus_ops.hif_bus_get_dev(hif_sc);
}
#endif
int hif_bus_configure(struct hif_softc *hif_sc)
{
return hif_sc->bus_ops.hif_bus_configure(hif_sc);

View file

@ -48,6 +48,11 @@ struct hif_bus_ops {
const struct hif_bus_id *bid,
enum hif_enable_type type);
void (*hif_disable_bus)(struct hif_softc *hif_sc);
#ifdef FEATURE_RUNTIME_PM
struct hif_runtime_pm_ctx *(*hif_bus_get_rpm_ctx)(
struct hif_softc *hif_sc);
struct device *(*hif_bus_get_dev)(struct hif_softc *hif_sc);
#endif
int (*hif_bus_configure)(struct hif_softc *hif_sc);
QDF_STATUS (*hif_get_config_item)(struct hif_softc *hif_sc,
int opcode, void *config, uint32_t config_len);

View file

@ -56,6 +56,10 @@ QDF_STATUS hif_initialize_pci_ops(struct hif_softc *hif_sc)
bus_ops->hif_nointrs = &hif_pci_nointrs;
bus_ops->hif_enable_bus = &hif_pci_enable_bus;
bus_ops->hif_disable_bus = &hif_pci_disable_bus;
#ifdef FEATURE_RUNTIME_PM
bus_ops->hif_bus_get_rpm_ctx = &hif_pci_get_rpm_ctx;
bus_ops->hif_bus_get_dev = &hif_pci_get_dev;
#endif
bus_ops->hif_bus_configure = &hif_pci_bus_configure;
bus_ops->hif_get_config_item = &hif_dummy_get_config_item;
bus_ops->hif_set_mailbox_swap = &hif_dummy_set_mailbox_swap;

View file

@ -39,6 +39,10 @@ QDF_STATUS hif_pci_enable_bus(struct hif_softc *scn,
const struct hif_bus_id *bid,
enum hif_enable_type type);
void hif_pci_disable_bus(struct hif_softc *scn);
#ifdef FEATURE_RUNTIME_PM
struct hif_runtime_pm_ctx *hif_pci_get_rpm_ctx(struct hif_softc *hif_sc);
struct device *hif_pci_get_dev(struct hif_softc *hif_sc);
#endif
int hif_pci_bus_configure(struct hif_softc *scn);
void hif_pci_irq_disable(struct hif_softc *scn, int ce_id);
void hif_pci_irq_enable(struct hif_softc *scn, int ce_id);

View file

@ -347,6 +347,10 @@ QDF_STATUS hif_bus_open(struct hif_softc *ol_sc,
QDF_STATUS hif_enable_bus(struct hif_softc *ol_sc, struct device *dev,
void *bdev, const struct hif_bus_id *bid, enum hif_enable_type type);
void hif_disable_bus(struct hif_softc *scn);
#ifdef FEATURE_RUNTIME_PM
struct hif_runtime_pm_ctx *hif_bus_get_rpm_ctx(struct hif_softc *hif_sc);
struct device *hif_bus_get_dev(struct hif_softc *hif_sc);
#endif
void hif_bus_prevent_linkdown(struct hif_softc *scn, bool flag);
int hif_bus_get_context_size(enum qdf_bus_type bus_type);
void hif_read_phy_mem_base(struct hif_softc *scn, qdf_dma_addr_t *bar_value);

1760
hif/src/hif_runtime_pm.c Normal file

File diff suppressed because it is too large Load diff

123
hif/src/hif_runtime_pm.h Normal file
View file

@ -0,0 +1,123 @@
/*
* Copyright (c) 2013-2020 The Linux Foundation. All rights reserved.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef __HIF_RUNTIME_PM_H__
#define __HIF_RUNTIME_PM_H__
#ifdef FEATURE_RUNTIME_PM
/**
* enum hif_pm_runtime_state - Driver States for Runtime Power Management
* HIF_PM_RUNTIME_STATE_NONE: runtime pm is off
* HIF_PM_RUNTIME_STATE_ON: runtime pm is active and link is active
* HIF_PM_RUNTIME_STATE_RESUMING: a runtime resume is in progress
* HIF_PM_RUNTIME_STATE_SUSPENDING: a runtime suspend is in progress
* HIF_PM_RUNTIME_STATE_SUSPENDED: the driver is runtime suspended
*/
enum hif_pm_runtime_state {
HIF_PM_RUNTIME_STATE_NONE,
HIF_PM_RUNTIME_STATE_ON,
HIF_PM_RUNTIME_STATE_RESUMING,
HIF_PM_RUNTIME_STATE_SUSPENDING,
HIF_PM_RUNTIME_STATE_SUSPENDED,
};
/**
* struct hif_pm_runtime_lock - data structure for preventing runtime suspend
* @list - global list of runtime locks
* @active - true if this lock is preventing suspend
* @name - character string for tracking this lock
*/
struct hif_pm_runtime_lock {
struct list_head list;
bool active;
uint32_t timeout;
const char *name;
};
/* Debugging stats for Runtime PM */
struct hif_pci_pm_stats {
u32 suspended;
u32 suspend_err;
u32 resumed;
atomic_t runtime_get;
atomic_t runtime_put;
atomic_t runtime_get_dbgid[RTPM_ID_MAX];
atomic_t runtime_put_dbgid[RTPM_ID_MAX];
uint64_t runtime_get_timestamp_dbgid[RTPM_ID_MAX];
uint64_t runtime_put_timestamp_dbgid[RTPM_ID_MAX];
u32 request_resume;
atomic_t allow_suspend;
atomic_t prevent_suspend;
u32 prevent_suspend_timeout;
u32 allow_suspend_timeout;
u32 runtime_get_err;
void *last_resume_caller;
void *last_busy_marker;
qdf_time_t last_busy_timestamp;
unsigned long suspend_jiffies;
};
struct hif_runtime_pm_ctx {
atomic_t pm_state;
atomic_t monitor_wake_intr;
uint32_t prevent_suspend_cnt;
struct hif_pci_pm_stats pm_stats;
struct work_struct pm_work;
spinlock_t runtime_lock; /* Generic spinlock for Runtime PM */
qdf_timer_t runtime_timer;
struct list_head prevent_suspend_list;
unsigned long runtime_timer_expires;
qdf_runtime_lock_t prevent_linkdown_lock;
atomic_t pm_dp_rx_busy;
qdf_time_t dp_last_busy_timestamp;
#ifdef WLAN_OPEN_SOURCE
struct dentry *pm_dentry;
#endif
};
#include <linux/pm_runtime.h>
static inline int hif_pm_request_resume(struct device *dev)
{
return pm_request_resume(dev);
}
static inline int __hif_pm_runtime_get(struct device *dev)
{
return pm_runtime_get(dev);
}
static inline int hif_pm_runtime_put_auto(struct device *dev)
{
return pm_runtime_put_autosuspend(dev);
}
void hif_pm_runtime_open(struct hif_softc *scn);
void hif_pm_runtime_start(struct hif_softc *scn);
void hif_pm_runtime_stop(struct hif_softc *scn);
void hif_pm_runtime_close(struct hif_softc *scn);
void hif_runtime_prevent_linkdown(struct hif_softc *scn, bool flag);
#else
static inline void hif_pm_runtime_open(struct hif_softc *scn) {}
static inline void hif_pm_runtime_start(struct hif_softc *scn) {}
static inline void hif_pm_runtime_stop(struct hif_softc *scn) {}
static inline void hif_pm_runtime_close(struct hif_softc *scn) {}
static inline void hif_runtime_prevent_linkdown(struct hif_softc *scn,
bool flag) {}
#endif /* FEATURE_RUNTIME_PM */
#endif /* __HIF_RUNTIME_PM_H__ */

File diff suppressed because it is too large Load diff

View file

@ -26,6 +26,7 @@
#define ATH_DBG_DEFAULT 0
#define DRAM_SIZE 0x000a8000
#include "hif.h"
#include "hif_runtime_pm.h"
#include "cepci.h"
#include "ce_main.h"
@ -56,61 +57,6 @@ struct hif_tasklet_entry {
void *hif_handler; /* struct hif_pci_softc */
};
/**
* enum hif_pm_runtime_state - Driver States for Runtime Power Management
* HIF_PM_RUNTIME_STATE_NONE: runtime pm is off
* HIF_PM_RUNTIME_STATE_ON: runtime pm is active and link is active
* HIF_PM_RUNTIME_STATE_RESUMING: a runtime resume is in progress
* HIF_PM_RUNTIME_STATE_SUSPENDING: a runtime suspend is in progress
* HIF_PM_RUNTIME_STATE_SUSPENDED: the driver is runtime suspended
*/
enum hif_pm_runtime_state {
HIF_PM_RUNTIME_STATE_NONE,
HIF_PM_RUNTIME_STATE_ON,
HIF_PM_RUNTIME_STATE_RESUMING,
HIF_PM_RUNTIME_STATE_SUSPENDING,
HIF_PM_RUNTIME_STATE_SUSPENDED,
};
#ifdef FEATURE_RUNTIME_PM
/**
* struct hif_pm_runtime_lock - data structure for preventing runtime suspend
* @list - global list of runtime locks
* @active - true if this lock is preventing suspend
* @name - character string for tracking this lock
*/
struct hif_pm_runtime_lock {
struct list_head list;
bool active;
uint32_t timeout;
const char *name;
};
/* Debugging stats for Runtime PM */
struct hif_pci_pm_stats {
u32 suspended;
u32 suspend_err;
u32 resumed;
atomic_t runtime_get;
atomic_t runtime_put;
atomic_t runtime_get_dbgid[RTPM_ID_MAX];
atomic_t runtime_put_dbgid[RTPM_ID_MAX];
uint64_t runtime_get_timestamp_dbgid[RTPM_ID_MAX];
uint64_t runtime_put_timestamp_dbgid[RTPM_ID_MAX];
u32 request_resume;
atomic_t allow_suspend;
atomic_t prevent_suspend;
u32 prevent_suspend_timeout;
u32 allow_suspend_timeout;
u32 runtime_get_err;
void *last_resume_caller;
void *last_busy_marker;
qdf_time_t last_busy_timestamp;
unsigned long suspend_jiffies;
};
#endif
/**
* struct hif_msi_info - Structure to hold msi info
* @magic: cookie
@ -174,21 +120,7 @@ struct hif_pci_softc {
qdf_work_t reschedule_tasklet_work;
uint32_t lcr_val;
#ifdef FEATURE_RUNTIME_PM
atomic_t pm_state;
atomic_t monitor_wake_intr;
uint32_t prevent_suspend_cnt;
struct hif_pci_pm_stats pm_stats;
struct work_struct pm_work;
spinlock_t runtime_lock;
qdf_timer_t runtime_timer;
struct list_head prevent_suspend_list;
unsigned long runtime_timer_expires;
qdf_runtime_lock_t prevent_linkdown_lock;
atomic_t pm_dp_rx_busy;
qdf_time_t dp_last_busy_timestamp;
#ifdef WLAN_OPEN_SOURCE
struct dentry *pm_dentry;
#endif
struct hif_runtime_pm_ctx rpm_ctx;
#endif
int (*hif_enable_pci)(struct hif_pci_softc *sc, struct pci_dev *pdev,
const struct pci_device_id *id);
@ -254,24 +186,4 @@ void hif_print_pci_stats(struct hif_pci_softc *pci_scn)
{
}
#endif /* FORCE_WAKE */
#ifdef FEATURE_RUNTIME_PM
#include <linux/pm_runtime.h>
static inline int hif_pm_request_resume(struct device *dev)
{
return pm_request_resume(dev);
}
static inline int __hif_pm_runtime_get(struct device *dev)
{
return pm_runtime_get(dev);
}
static inline int hif_pm_runtime_put_auto(struct device *dev)
{
return pm_runtime_put_autosuspend(dev);
}
#endif /* FEATURE_RUNTIME_PM */
#endif /* __ATH_PCI_H__ */