diff --git a/hif/inc/hif.h b/hif/inc/hif.h index cd520d9fe5..813fa7677a 100644 --- a/hif/inc/hif.h +++ b/hif/inc/hif.h @@ -43,6 +43,9 @@ extern "C" { #ifdef HIF_USB #include #endif /* HIF_USB */ +#ifdef IPA_OFFLOAD +#include +#endif #define ENABLE_MBOX_DUMMY_SPACE_FEATURE 1 typedef struct htc_callbacks HTC_CALLBACKS; @@ -104,6 +107,11 @@ typedef void *hif_handle_t; #define TARGET_TYPE_QCA6290 21 #endif +#ifdef IPA_OFFLOAD +#define DMA_COHERENT_MASK_IPA_VER_3_AND_ABOVE 37 +#define DMA_COHERENT_MASK_BELOW_IPA_VER_3 32 +#endif + /* enum hif_ic_irq - enum defining integrated chip irq numbers * defining irq nubers that can be used by external modules like datapath */ @@ -695,6 +703,20 @@ void hif_vote_link_down(struct hif_opaque_softc *); void hif_vote_link_up(struct hif_opaque_softc *); bool hif_can_suspend_link(struct hif_opaque_softc *); +#ifdef IPA_OFFLOAD +/** + * hif_get_ipa_hw_type() - get IPA hw type + * + * This API return the IPA hw type. + * + * Return: IPA hw type + */ +static inline +enum ipa_hw_type hif_get_ipa_hw_type(void) +{ + return ipa_get_hw_type(); +} +#endif int hif_bus_resume(struct hif_opaque_softc *); int hif_bus_suspend(struct hif_opaque_softc *); int hif_bus_resume_noirq(struct hif_opaque_softc *); diff --git a/hif/src/snoc/if_snoc.c b/hif/src/snoc/if_snoc.c index 3b5e0f6ac5..afdcd22724 100644 --- a/hif/src/snoc/if_snoc.c +++ b/hif/src/snoc/if_snoc.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2016 The Linux Foundation. All rights reserved. + * Copyright (c) 2015-2017 The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * @@ -41,6 +41,9 @@ #include #include "pld_common.h" #include "qdf_util.h" +#ifdef IPA_OFFLOAD +#include +#endif /** * hif_disable_isr(): disable isr @@ -212,6 +215,25 @@ static inline int hif_snoc_get_target_type(struct hif_softc *ol_sc, return 0; } +#ifdef IPA_OFFLOAD +static int hif_set_dma_coherent_mask(struct device *dev) +{ + uint8_t addr_bits; + + if (hif_get_ipa_hw_type() < IPA_HW_v3_0) + addr_bits = DMA_COHERENT_MASK_BELOW_IPA_VER_3; + else + addr_bits = DMA_COHERENT_MASK_IPA_VER_3_AND_ABOVE; + + return qdf_set_dma_coherent_mask(dev, addr_bits); +} +#else +static int hif_set_dma_coherent_mask(struct device *dev) +{ + return qdf_set_dma_coherent_mask(dev, 37); +} +#endif + /** * hif_enable_bus(): hif_enable_bus * @dev: dev @@ -235,11 +257,7 @@ QDF_STATUS hif_snoc_enable_bus(struct hif_softc *ol_sc, return QDF_STATUS_E_NOMEM; } -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0) - ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(37)); -#else - ret = dma_set_coherent_mask(dev, DMA_BIT_MASK(37)); -#endif + ret = hif_set_dma_coherent_mask(dev); if (ret) { HIF_ERROR("%s: failed to set dma mask error = %d", __func__, ret); diff --git a/qdf/inc/qdf_util.h b/qdf/inc/qdf_util.h index 0e5f6065a8..8e8eda8de7 100644 --- a/qdf/inc/qdf_util.h +++ b/qdf/inc/qdf_util.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2016 The Linux Foundation. All rights reserved. + * Copyright (c) 2014-2017 The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * @@ -520,4 +520,19 @@ unsigned long qdf_rounddown_pow_of_two(unsigned long n) return __qdf_rounddown_pow_of_two(n); } +/** + * qdf_set_dma_coherent_mask() - set max number of bits allowed in dma addr + * @dev: device pointer + * @addr_bits: max number of bits allowed in dma address + * + * This API sets the maximum allowed number of bits in the dma address. + * + * Return: 0 - success, non zero - failure + */ +static inline +int qdf_set_dma_coherent_mask(struct device *dev, uint8_t addr_bits) +{ + return __qdf_set_dma_coherent_mask(dev, addr_bits); +} + #endif /*_QDF_UTIL_H*/ diff --git a/qdf/linux/src/i_qdf_util.h b/qdf/linux/src/i_qdf_util.h index b7c51dfc70..312010cd78 100644 --- a/qdf/linux/src/i_qdf_util.h +++ b/qdf/linux/src/i_qdf_util.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2016 The Linux Foundation. All rights reserved. + * Copyright (c) 2014-2017 The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * @@ -363,4 +363,39 @@ unsigned long __qdf_rounddown_pow_of_two(unsigned long n) return __rounddown_pow_of_two(n); } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0) + +/** + * __qdf_set_dma_coherent_mask() - set max number of bits allowed in dma addr + * @dev: device pointer + * @addr_bits: max number of bits allowed in dma address + * + * This API sets the maximum allowed number of bits in the dma address. + * + * Return: 0 - success, non zero - failure + */ +static inline +int __qdf_set_dma_coherent_mask(struct device *dev, uint8_t addr_bits) +{ + return dma_set_mask_and_coherent(dev, DMA_BIT_MASK(addr_bits)); +} + +#else + +/** + * __qdf_set_dma_coherent_mask() - set max number of bits allowed in dma addr + * @dev: device pointer + * @addr_bits: max number of bits allowed in dma address + * + * This API sets the maximum allowed number of bits in the dma address. + * + * Return: 0 - success, non zero - failure + */ +static inline +int __qdf_set_dma_coherent_mask(struct device *dev, uint8_t addr_bits) +{ + return dma_set_coherent_mask(dev, DMA_BIT_MASK(addr_bits)); +} +#endif + #endif /*_I_QDF_UTIL_H*/