From: Mathieu Poirier <mathieu.poirier@linaro.org>
To: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: coresight@lists.linaro.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, mike.leach@linaro.org
Subject: Re: [PATCH v3 10/26] coresight: Convert claim/disclaim operations to use access wrappers
Date: Tue, 3 Nov 2020 11:36:25 -0700 [thread overview]
Message-ID: <20201103183625.GD2855763@xps15> (raw)
In-Reply-To: <20201028220945.3826358-12-suzuki.poulose@arm.com>
On Wed, Oct 28, 2020 at 10:09:29PM +0000, Suzuki K Poulose wrote:
> Convert the generic CLAIM tag management APIs to use the
> device access layer abstraction.
>
> Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
> Cc: Mike Leach <mike.leach@linaro.org>
> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
> ---
> drivers/hwtracing/coresight/coresight-catu.c | 6 +-
> drivers/hwtracing/coresight/coresight-core.c | 66 +++++++++++--------
> .../hwtracing/coresight/coresight-cti-core.c | 17 +++--
> drivers/hwtracing/coresight/coresight-etb10.c | 4 +-
> .../coresight/coresight-etm3x-core.c | 8 ++-
> .../coresight/coresight-etm4x-core.c | 4 +-
> .../hwtracing/coresight/coresight-funnel.c | 6 +-
> .../coresight/coresight-replicator.c | 16 +++--
> .../hwtracing/coresight/coresight-tmc-etf.c | 10 +--
> .../hwtracing/coresight/coresight-tmc-etr.c | 4 +-
> include/linux/coresight.h | 16 ++---
> 11 files changed, 95 insertions(+), 62 deletions(-)
>
> diff --git a/drivers/hwtracing/coresight/coresight-catu.c b/drivers/hwtracing/coresight/coresight-catu.c
> index 34c74b05c542..438063523463 100644
> --- a/drivers/hwtracing/coresight/coresight-catu.c
> +++ b/drivers/hwtracing/coresight/coresight-catu.c
> @@ -412,6 +412,7 @@ static int catu_enable_hw(struct catu_drvdata *drvdata, void *data)
> u32 control, mode;
> struct etr_buf *etr_buf = data;
> struct device *dev = &drvdata->csdev->dev;
> + struct coresight_device *csdev = drvdata->csdev;
>
> if (catu_wait_for_ready(drvdata))
> dev_warn(dev, "Timeout while waiting for READY\n");
> @@ -422,7 +423,7 @@ static int catu_enable_hw(struct catu_drvdata *drvdata, void *data)
> return -EBUSY;
> }
>
> - rc = coresight_claim_device_unlocked(drvdata->base);
> + rc = coresight_claim_device_unlocked(csdev);
> if (rc)
> return rc;
>
> @@ -466,9 +467,10 @@ static int catu_disable_hw(struct catu_drvdata *drvdata)
> {
> int rc = 0;
> struct device *dev = &drvdata->csdev->dev;
> + struct coresight_device *csdev = drvdata->csdev;
>
> catu_write_control(drvdata, 0);
> - coresight_disclaim_device_unlocked(drvdata->base);
> + coresight_disclaim_device_unlocked(csdev);
> if (catu_wait_for_ready(drvdata)) {
> dev_info(dev, "Timeout while waiting for READY\n");
> rc = -EAGAIN;
> diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c
> index 42ba989a6b5e..4e7dd5941046 100644
> --- a/drivers/hwtracing/coresight/coresight-core.c
> +++ b/drivers/hwtracing/coresight/coresight-core.c
> @@ -145,30 +145,32 @@ static int coresight_find_link_outport(struct coresight_device *csdev,
> return -ENODEV;
> }
>
> -static inline u32 coresight_read_claim_tags(void __iomem *base)
> +static inline u32 coresight_read_claim_tags(struct coresight_device *csdev)
> {
> - return readl_relaxed(base + CORESIGHT_CLAIMCLR);
> + return csdev_access_relaxed_read32(&csdev->access, CORESIGHT_CLAIMCLR);
> }
>
> -static inline bool coresight_is_claimed_self_hosted(void __iomem *base)
> +static inline bool coresight_is_claimed_self_hosted(struct coresight_device *csdev)
> {
> - return coresight_read_claim_tags(base) == CORESIGHT_CLAIM_SELF_HOSTED;
> + return coresight_read_claim_tags(csdev) == CORESIGHT_CLAIM_SELF_HOSTED;
> }
>
> -static inline bool coresight_is_claimed_any(void __iomem *base)
> +static inline bool coresight_is_claimed_any(struct coresight_device *csdev)
> {
> - return coresight_read_claim_tags(base) != 0;
> + return coresight_read_claim_tags(csdev) != 0;
> }
>
> -static inline void coresight_set_claim_tags(void __iomem *base)
> +static inline void coresight_set_claim_tags(struct coresight_device *csdev)
> {
> - writel_relaxed(CORESIGHT_CLAIM_SELF_HOSTED, base + CORESIGHT_CLAIMSET);
> + csdev_access_relaxed_write32(&csdev->access, CORESIGHT_CLAIM_SELF_HOSTED,
> + CORESIGHT_CLAIMSET);
Indentation
> isb();
> }
>
> -static inline void coresight_clear_claim_tags(void __iomem *base)
> +static inline void coresight_clear_claim_tags(struct coresight_device *csdev)
> {
> - writel_relaxed(CORESIGHT_CLAIM_SELF_HOSTED, base + CORESIGHT_CLAIMCLR);
> + csdev_access_relaxed_write32(&csdev->access, CORESIGHT_CLAIM_SELF_HOSTED,
> + CORESIGHT_CLAIMCLR);
Indentation
> isb();
> }
>
> @@ -182,27 +184,33 @@ static inline void coresight_clear_claim_tags(void __iomem *base)
> * Called with CS_UNLOCKed for the component.
> * Returns : 0 on success
> */
> -int coresight_claim_device_unlocked(void __iomem *base)
> +int coresight_claim_device_unlocked(struct coresight_device *csdev)
> {
> - if (coresight_is_claimed_any(base))
> + if (WARN_ON(!csdev))
> + return -EINVAL;
> +
> + if (coresight_is_claimed_any(csdev))
> return -EBUSY;
>
> - coresight_set_claim_tags(base);
> - if (coresight_is_claimed_self_hosted(base))
> + coresight_set_claim_tags(csdev);
> + if (coresight_is_claimed_self_hosted(csdev))
> return 0;
> /* There was a race setting the tags, clean up and fail */
> - coresight_clear_claim_tags(base);
> + coresight_clear_claim_tags(csdev);
> return -EBUSY;
> }
> EXPORT_SYMBOL_GPL(coresight_claim_device_unlocked);
>
> -int coresight_claim_device(void __iomem *base)
> +int coresight_claim_device(struct coresight_device *csdev)
> {
> int rc;
>
> - CS_UNLOCK(base);
> - rc = coresight_claim_device_unlocked(base);
> - CS_LOCK(base);
> + if (WARN_ON(!csdev))
> + return -EINVAL;
> +
> + CS_UNLOCK(csdev->access.base);
> + rc = coresight_claim_device_unlocked(csdev);
> + CS_LOCK(csdev->access.base);
>
> return rc;
> }
> @@ -212,11 +220,14 @@ EXPORT_SYMBOL_GPL(coresight_claim_device);
> * coresight_disclaim_device_unlocked : Clear the claim tags for the device.
> * Called with CS_UNLOCKed for the component.
> */
> -void coresight_disclaim_device_unlocked(void __iomem *base)
> +void coresight_disclaim_device_unlocked(struct coresight_device *csdev)
> {
>
> - if (coresight_is_claimed_self_hosted(base))
> - coresight_clear_claim_tags(base);
> + if (WARN_ON(!csdev))
> + return;
> +
> + if (coresight_is_claimed_self_hosted(csdev))
> + coresight_clear_claim_tags(csdev);
> else
> /*
> * The external agent may have not honoured our claim
> @@ -227,11 +238,14 @@ void coresight_disclaim_device_unlocked(void __iomem *base)
> }
> EXPORT_SYMBOL_GPL(coresight_disclaim_device_unlocked);
>
> -void coresight_disclaim_device(void __iomem *base)
> +void coresight_disclaim_device(struct coresight_device *csdev)
> {
> - CS_UNLOCK(base);
> - coresight_disclaim_device_unlocked(base);
> - CS_LOCK(base);
> + if (WARN_ON(!csdev))
> + return;
> +
> + CS_UNLOCK(csdev->access.base);
> + coresight_disclaim_device_unlocked(csdev);
> + CS_LOCK(csdev->access.base);
> }
> EXPORT_SYMBOL_GPL(coresight_disclaim_device);
>
> diff --git a/drivers/hwtracing/coresight/coresight-cti-core.c b/drivers/hwtracing/coresight/coresight-cti-core.c
> index 3bb0de97d66e..5651d7f61a70 100644
> --- a/drivers/hwtracing/coresight/coresight-cti-core.c
> +++ b/drivers/hwtracing/coresight/coresight-cti-core.c
> @@ -102,7 +102,7 @@ static int cti_enable_hw(struct cti_drvdata *drvdata)
> goto cti_state_unchanged;
>
> /* claim the device */
> - rc = coresight_claim_device(drvdata->base);
> + rc = coresight_claim_device(drvdata->csdev);
> if (rc)
> goto cti_err_not_enabled;
>
> @@ -136,7 +136,7 @@ static void cti_cpuhp_enable_hw(struct cti_drvdata *drvdata)
> goto cti_hp_not_enabled;
>
> /* try to claim the device */
> - if (coresight_claim_device(drvdata->base))
> + if (coresight_claim_device(drvdata->csdev))
> goto cti_hp_not_enabled;
>
> cti_write_all_hw_regs(drvdata);
> @@ -154,6 +154,7 @@ static int cti_disable_hw(struct cti_drvdata *drvdata)
> {
> struct cti_config *config = &drvdata->config;
> struct device *dev = &drvdata->csdev->dev;
> + struct coresight_device *csdev = drvdata->csdev;
>
> spin_lock(&drvdata->spinlock);
>
> @@ -171,7 +172,7 @@ static int cti_disable_hw(struct cti_drvdata *drvdata)
> writel_relaxed(0, drvdata->base + CTICONTROL);
> config->hw_enabled = false;
>
> - coresight_disclaim_device_unlocked(drvdata->base);
> + coresight_disclaim_device_unlocked(csdev);
> CS_LOCK(drvdata->base);
> spin_unlock(&drvdata->spinlock);
> pm_runtime_put(dev);
> @@ -655,6 +656,7 @@ static int cti_cpu_pm_notify(struct notifier_block *nb, unsigned long cmd,
> void *v)
> {
> struct cti_drvdata *drvdata;
> + struct coresight_device *csdev;
> unsigned int cpu = smp_processor_id();
> int notify_res = NOTIFY_OK;
>
> @@ -662,6 +664,7 @@ static int cti_cpu_pm_notify(struct notifier_block *nb, unsigned long cmd,
> return NOTIFY_OK;
>
> drvdata = cti_cpu_drvdata[cpu];
> + csdev = drvdata->csdev;
>
> if (WARN_ON_ONCE(drvdata->ctidev.cpu != cpu))
> return NOTIFY_BAD;
> @@ -673,13 +676,13 @@ static int cti_cpu_pm_notify(struct notifier_block *nb, unsigned long cmd,
> /* CTI regs all static - we have a copy & nothing to save */
> drvdata->config.hw_powered = false;
> if (drvdata->config.hw_enabled)
> - coresight_disclaim_device(drvdata->base);
> + coresight_disclaim_device(csdev);
> break;
>
> case CPU_PM_ENTER_FAILED:
> drvdata->config.hw_powered = true;
> if (drvdata->config.hw_enabled) {
> - if (coresight_claim_device(drvdata->base))
> + if (coresight_claim_device(csdev))
> drvdata->config.hw_enabled = false;
> }
> break;
> @@ -692,7 +695,7 @@ static int cti_cpu_pm_notify(struct notifier_block *nb, unsigned long cmd,
> /* check enable reference count to enable HW */
> if (atomic_read(&drvdata->config.enable_req_count)) {
> /* check we can claim the device as we re-power */
> - if (coresight_claim_device(drvdata->base))
> + if (coresight_claim_device(csdev))
> goto cti_notify_exit;
>
> drvdata->config.hw_enabled = true;
> @@ -736,7 +739,7 @@ static int cti_dying_cpu(unsigned int cpu)
> spin_lock(&drvdata->spinlock);
> drvdata->config.hw_powered = false;
> if (drvdata->config.hw_enabled)
> - coresight_disclaim_device(drvdata->base);
> + coresight_disclaim_device(drvdata->csdev);
> spin_unlock(&drvdata->spinlock);
> return 0;
> }
> diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c
> index f994a22876d9..0a416883e012 100644
> --- a/drivers/hwtracing/coresight/coresight-etb10.c
> +++ b/drivers/hwtracing/coresight/coresight-etb10.c
> @@ -132,7 +132,7 @@ static void __etb_enable_hw(struct etb_drvdata *drvdata)
>
> static int etb_enable_hw(struct etb_drvdata *drvdata)
> {
> - int rc = coresight_claim_device(drvdata->base);
> + int rc = coresight_claim_device(drvdata->csdev);
>
> if (rc)
> return rc;
> @@ -344,7 +344,7 @@ static void etb_disable_hw(struct etb_drvdata *drvdata)
> {
> __etb_disable_hw(drvdata);
> etb_dump_hw(drvdata);
> - coresight_disclaim_device(drvdata->base);
> + coresight_disclaim_device(drvdata->csdev);
> }
>
> static int etb_disable(struct coresight_device *csdev)
> diff --git a/drivers/hwtracing/coresight/coresight-etm3x-core.c b/drivers/hwtracing/coresight/coresight-etm3x-core.c
> index 36c5b0ae1b43..70d6d809cb47 100644
> --- a/drivers/hwtracing/coresight/coresight-etm3x-core.c
> +++ b/drivers/hwtracing/coresight/coresight-etm3x-core.c
> @@ -358,10 +358,11 @@ static int etm_enable_hw(struct etm_drvdata *drvdata)
> int i, rc;
> u32 etmcr;
> struct etm_config *config = &drvdata->config;
> + struct coresight_device *csdev = drvdata->csdev;
>
> CS_UNLOCK(drvdata->base);
>
> - rc = coresight_claim_device_unlocked(drvdata->base);
> + rc = coresight_claim_device_unlocked(csdev);
> if (rc)
> goto done;
>
> @@ -566,6 +567,7 @@ static void etm_disable_hw(void *info)
> int i;
> struct etm_drvdata *drvdata = info;
> struct etm_config *config = &drvdata->config;
> + struct coresight_device *csdev = drvdata->csdev;
>
> CS_UNLOCK(drvdata->base);
> etm_set_prog(drvdata);
> @@ -577,7 +579,7 @@ static void etm_disable_hw(void *info)
> config->cntr_val[i] = etm_readl(drvdata, ETMCNTVRn(i));
>
> etm_set_pwrdwn(drvdata);
> - coresight_disclaim_device_unlocked(drvdata->base);
> + coresight_disclaim_device_unlocked(csdev);
>
> CS_LOCK(drvdata->base);
>
> @@ -602,7 +604,7 @@ static void etm_disable_perf(struct coresight_device *csdev)
> * power down the tracer.
> */
> etm_set_pwrdwn(drvdata);
> - coresight_disclaim_device_unlocked(drvdata->base);
> + coresight_disclaim_device_unlocked(csdev);
>
> CS_LOCK(drvdata->base);
> }
> diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c
> index 2744aadaa5ec..4f1bcf98fefe 100644
> --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c
> +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c
> @@ -115,7 +115,7 @@ static int etm4_enable_hw(struct etmv4_drvdata *drvdata)
>
> etm4_os_unlock(drvdata);
>
> - rc = coresight_claim_device_unlocked(drvdata->base);
> + rc = coresight_claim_device_unlocked(csdev);
> if (rc)
> goto done;
>
> @@ -523,7 +523,7 @@ static void etm4_disable_hw(void *info)
> readl_relaxed(drvdata->base + TRCCNTVRn(i));
> }
>
> - coresight_disclaim_device_unlocked(drvdata->base);
> + coresight_disclaim_device_unlocked(csdev);
>
> CS_LOCK(drvdata->base);
>
> diff --git a/drivers/hwtracing/coresight/coresight-funnel.c b/drivers/hwtracing/coresight/coresight-funnel.c
> index f77466aea26f..2f8675c527bf 100644
> --- a/drivers/hwtracing/coresight/coresight-funnel.c
> +++ b/drivers/hwtracing/coresight/coresight-funnel.c
> @@ -52,13 +52,14 @@ static int dynamic_funnel_enable_hw(struct funnel_drvdata *drvdata, int port)
> {
> u32 functl;
> int rc = 0;
> + struct coresight_device *csdev = drvdata->csdev;
>
> CS_UNLOCK(drvdata->base);
>
> functl = readl_relaxed(drvdata->base + FUNNEL_FUNCTL);
> /* Claim the device only when we enable the first slave */
> if (!(functl & FUNNEL_ENSx_MASK)) {
> - rc = coresight_claim_device_unlocked(drvdata->base);
> + rc = coresight_claim_device_unlocked(csdev);
> if (rc)
> goto done;
> }
> @@ -101,6 +102,7 @@ static void dynamic_funnel_disable_hw(struct funnel_drvdata *drvdata,
> int inport)
> {
> u32 functl;
> + struct coresight_device *csdev = drvdata->csdev;
>
> CS_UNLOCK(drvdata->base);
>
> @@ -110,7 +112,7 @@ static void dynamic_funnel_disable_hw(struct funnel_drvdata *drvdata,
>
> /* Disclaim the device if none of the slaves are now active */
> if (!(functl & FUNNEL_ENSx_MASK))
> - coresight_disclaim_device_unlocked(drvdata->base);
> + coresight_disclaim_device_unlocked(csdev);
>
> CS_LOCK(drvdata->base);
> }
> diff --git a/drivers/hwtracing/coresight/coresight-replicator.c b/drivers/hwtracing/coresight/coresight-replicator.c
> index fcf25740116c..e35d79e74e30 100644
> --- a/drivers/hwtracing/coresight/coresight-replicator.c
> +++ b/drivers/hwtracing/coresight/coresight-replicator.c
> @@ -45,12 +45,18 @@ struct replicator_drvdata {
>
> static void dynamic_replicator_reset(struct replicator_drvdata *drvdata)
> {
> + struct coresight_device *csdev = drvdata->csdev;
> CS_UNLOCK(drvdata->base);
>
> - if (!coresight_claim_device_unlocked(drvdata->base)) {
> + if (WARN_ON(!csdev))
> + return;
I don't see a need for this check. Function replicator_reset() is called from
probe() where the validity of drvdata->csdev is checked just before.
> +
> + CS_UNLOCK(drvdata->base);
> +
> + if (!coresight_claim_device_unlocked(csdev)) {
> writel_relaxed(0xff, drvdata->base + REPLICATOR_IDFILTER0);
> writel_relaxed(0xff, drvdata->base + REPLICATOR_IDFILTER1);
> - coresight_disclaim_device_unlocked(drvdata->base);
> + coresight_disclaim_device_unlocked(csdev);
> }
>
> CS_LOCK(drvdata->base);
> @@ -70,6 +76,7 @@ static int dynamic_replicator_enable(struct replicator_drvdata *drvdata,
> {
> int rc = 0;
> u32 id0val, id1val;
> + struct coresight_device *csdev = drvdata->csdev;
>
> CS_UNLOCK(drvdata->base);
>
> @@ -84,7 +91,7 @@ static int dynamic_replicator_enable(struct replicator_drvdata *drvdata,
> id0val = id1val = 0xff;
>
> if (id0val == 0xff && id1val == 0xff)
> - rc = coresight_claim_device_unlocked(drvdata->base);
> + rc = coresight_claim_device_unlocked(csdev);
>
> if (!rc) {
> switch (outport) {
> @@ -140,6 +147,7 @@ static void dynamic_replicator_disable(struct replicator_drvdata *drvdata,
> int inport, int outport)
> {
> u32 reg;
> + struct coresight_device *csdev = drvdata->csdev;
>
> switch (outport) {
> case 0:
> @@ -160,7 +168,7 @@ static void dynamic_replicator_disable(struct replicator_drvdata *drvdata,
>
> if ((readl_relaxed(drvdata->base + REPLICATOR_IDFILTER0) == 0xff) &&
> (readl_relaxed(drvdata->base + REPLICATOR_IDFILTER1) == 0xff))
> - coresight_disclaim_device_unlocked(drvdata->base);
> + coresight_disclaim_device_unlocked(csdev);
> CS_LOCK(drvdata->base);
> }
>
> diff --git a/drivers/hwtracing/coresight/coresight-tmc-etf.c b/drivers/hwtracing/coresight/coresight-tmc-etf.c
> index 44402d413ebb..3a5605eda68f 100644
> --- a/drivers/hwtracing/coresight/coresight-tmc-etf.c
> +++ b/drivers/hwtracing/coresight/coresight-tmc-etf.c
> @@ -37,7 +37,7 @@ static void __tmc_etb_enable_hw(struct tmc_drvdata *drvdata)
>
> static int tmc_etb_enable_hw(struct tmc_drvdata *drvdata)
> {
> - int rc = coresight_claim_device(drvdata->base);
> + int rc = coresight_claim_device(drvdata->csdev);
>
> if (rc)
> return rc;
> @@ -88,7 +88,7 @@ static void __tmc_etb_disable_hw(struct tmc_drvdata *drvdata)
> static void tmc_etb_disable_hw(struct tmc_drvdata *drvdata)
> {
> __tmc_etb_disable_hw(drvdata);
> - coresight_disclaim_device(drvdata->base);
> + coresight_disclaim_device(drvdata->csdev);
> }
>
> static void __tmc_etf_enable_hw(struct tmc_drvdata *drvdata)
> @@ -109,7 +109,7 @@ static void __tmc_etf_enable_hw(struct tmc_drvdata *drvdata)
>
> static int tmc_etf_enable_hw(struct tmc_drvdata *drvdata)
> {
> - int rc = coresight_claim_device(drvdata->base);
> + int rc = coresight_claim_device(drvdata->csdev);
>
> if (rc)
> return rc;
> @@ -120,11 +120,13 @@ static int tmc_etf_enable_hw(struct tmc_drvdata *drvdata)
>
> static void tmc_etf_disable_hw(struct tmc_drvdata *drvdata)
> {
> + struct coresight_device *csdev = drvdata->csdev;
> +
> CS_UNLOCK(drvdata->base);
>
> tmc_flush_and_stop(drvdata);
> tmc_disable_hw(drvdata);
> - coresight_disclaim_device_unlocked(drvdata->base);
> + coresight_disclaim_device_unlocked(csdev);
> CS_LOCK(drvdata->base);
> }
>
> diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c
> index 714f9e867e5f..a8b1c49761c7 100644
> --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c
> +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c
> @@ -1038,7 +1038,7 @@ static int tmc_etr_enable_hw(struct tmc_drvdata *drvdata,
> rc = tmc_etr_enable_catu(drvdata, etr_buf);
> if (rc)
> return rc;
> - rc = coresight_claim_device(drvdata->base);
> + rc = coresight_claim_device(drvdata->csdev);
> if (!rc) {
> drvdata->etr_buf = etr_buf;
> __tmc_etr_enable_hw(drvdata);
> @@ -1132,7 +1132,7 @@ void tmc_etr_disable_hw(struct tmc_drvdata *drvdata)
> __tmc_etr_disable_hw(drvdata);
> /* Disable CATU device if this ETR is connected to one */
> tmc_etr_disable_catu(drvdata);
> - coresight_disclaim_device(drvdata->base);
> + coresight_disclaim_device(drvdata->csdev);
> /* Reset the ETR buf used by hardware */
> drvdata->etr_buf = NULL;
> }
> diff --git a/include/linux/coresight.h b/include/linux/coresight.h
> index cefc8fe239e6..c2d0a2aea45f 100644
> --- a/include/linux/coresight.h
> +++ b/include/linux/coresight.h
> @@ -474,11 +474,11 @@ extern int coresight_timeout(struct csdev_access *csa,
> int position,
> int value);
>
> -extern int coresight_claim_device(void __iomem *base);
> -extern int coresight_claim_device_unlocked(void __iomem *base);
> +extern int coresight_claim_device(struct coresight_device *csdev);
> +extern int coresight_claim_device_unlocked(struct coresight_device *csdev);
>
> -extern void coresight_disclaim_device(void __iomem *base);
> -extern void coresight_disclaim_device_unlocked(void __iomem *base);
> +extern void coresight_disclaim_device(struct coresight_device *csdev);
> +extern void coresight_disclaim_device_unlocked(struct coresight_device *csdev);
> extern char *coresight_alloc_device_name(struct coresight_dev_list *devs,
> struct device *dev);
>
> @@ -513,18 +513,18 @@ static inline int coresight_timeout(struct csdev_access *csa,
> return 1;
> }
>
> -static inline int coresight_claim_device_unlocked(void __iomem *base)
> +static inline int coresight_claim_device_unlocked(struct coresight_device *csdev)
> {
> return -EINVAL;
> }
>
> -static inline int coresight_claim_device(void __iomem *base)
> +static inline int coresight_claim_device(struct coresight_device *csdev)
> {
> return -EINVAL;
> }
>
> -static inline void coresight_disclaim_device(void __iomem *base) {}
> -static inline void coresight_disclaim_device_unlocked(void __iomem *base) {}
> +static inline void coresight_disclaim_device(struct coresight_device *csdev) {}
> +static inline void coresight_disclaim_device_unlocked(struct coresight_device *csdev) {}
>
> static inline bool coresight_loses_context_with_cpu(struct device *dev)
> {
> --
> 2.24.1
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
WARNING: multiple messages have this Message-ID (diff)
From: Mathieu Poirier <mathieu.poirier@linaro.org>
To: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: linux-arm-kernel@lists.infradead.org, mike.leach@linaro.org,
coresight@lists.linaro.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 10/26] coresight: Convert claim/disclaim operations to use access wrappers
Date: Tue, 3 Nov 2020 11:36:25 -0700 [thread overview]
Message-ID: <20201103183625.GD2855763@xps15> (raw)
In-Reply-To: <20201028220945.3826358-12-suzuki.poulose@arm.com>
On Wed, Oct 28, 2020 at 10:09:29PM +0000, Suzuki K Poulose wrote:
> Convert the generic CLAIM tag management APIs to use the
> device access layer abstraction.
>
> Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
> Cc: Mike Leach <mike.leach@linaro.org>
> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
> ---
> drivers/hwtracing/coresight/coresight-catu.c | 6 +-
> drivers/hwtracing/coresight/coresight-core.c | 66 +++++++++++--------
> .../hwtracing/coresight/coresight-cti-core.c | 17 +++--
> drivers/hwtracing/coresight/coresight-etb10.c | 4 +-
> .../coresight/coresight-etm3x-core.c | 8 ++-
> .../coresight/coresight-etm4x-core.c | 4 +-
> .../hwtracing/coresight/coresight-funnel.c | 6 +-
> .../coresight/coresight-replicator.c | 16 +++--
> .../hwtracing/coresight/coresight-tmc-etf.c | 10 +--
> .../hwtracing/coresight/coresight-tmc-etr.c | 4 +-
> include/linux/coresight.h | 16 ++---
> 11 files changed, 95 insertions(+), 62 deletions(-)
>
> diff --git a/drivers/hwtracing/coresight/coresight-catu.c b/drivers/hwtracing/coresight/coresight-catu.c
> index 34c74b05c542..438063523463 100644
> --- a/drivers/hwtracing/coresight/coresight-catu.c
> +++ b/drivers/hwtracing/coresight/coresight-catu.c
> @@ -412,6 +412,7 @@ static int catu_enable_hw(struct catu_drvdata *drvdata, void *data)
> u32 control, mode;
> struct etr_buf *etr_buf = data;
> struct device *dev = &drvdata->csdev->dev;
> + struct coresight_device *csdev = drvdata->csdev;
>
> if (catu_wait_for_ready(drvdata))
> dev_warn(dev, "Timeout while waiting for READY\n");
> @@ -422,7 +423,7 @@ static int catu_enable_hw(struct catu_drvdata *drvdata, void *data)
> return -EBUSY;
> }
>
> - rc = coresight_claim_device_unlocked(drvdata->base);
> + rc = coresight_claim_device_unlocked(csdev);
> if (rc)
> return rc;
>
> @@ -466,9 +467,10 @@ static int catu_disable_hw(struct catu_drvdata *drvdata)
> {
> int rc = 0;
> struct device *dev = &drvdata->csdev->dev;
> + struct coresight_device *csdev = drvdata->csdev;
>
> catu_write_control(drvdata, 0);
> - coresight_disclaim_device_unlocked(drvdata->base);
> + coresight_disclaim_device_unlocked(csdev);
> if (catu_wait_for_ready(drvdata)) {
> dev_info(dev, "Timeout while waiting for READY\n");
> rc = -EAGAIN;
> diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c
> index 42ba989a6b5e..4e7dd5941046 100644
> --- a/drivers/hwtracing/coresight/coresight-core.c
> +++ b/drivers/hwtracing/coresight/coresight-core.c
> @@ -145,30 +145,32 @@ static int coresight_find_link_outport(struct coresight_device *csdev,
> return -ENODEV;
> }
>
> -static inline u32 coresight_read_claim_tags(void __iomem *base)
> +static inline u32 coresight_read_claim_tags(struct coresight_device *csdev)
> {
> - return readl_relaxed(base + CORESIGHT_CLAIMCLR);
> + return csdev_access_relaxed_read32(&csdev->access, CORESIGHT_CLAIMCLR);
> }
>
> -static inline bool coresight_is_claimed_self_hosted(void __iomem *base)
> +static inline bool coresight_is_claimed_self_hosted(struct coresight_device *csdev)
> {
> - return coresight_read_claim_tags(base) == CORESIGHT_CLAIM_SELF_HOSTED;
> + return coresight_read_claim_tags(csdev) == CORESIGHT_CLAIM_SELF_HOSTED;
> }
>
> -static inline bool coresight_is_claimed_any(void __iomem *base)
> +static inline bool coresight_is_claimed_any(struct coresight_device *csdev)
> {
> - return coresight_read_claim_tags(base) != 0;
> + return coresight_read_claim_tags(csdev) != 0;
> }
>
> -static inline void coresight_set_claim_tags(void __iomem *base)
> +static inline void coresight_set_claim_tags(struct coresight_device *csdev)
> {
> - writel_relaxed(CORESIGHT_CLAIM_SELF_HOSTED, base + CORESIGHT_CLAIMSET);
> + csdev_access_relaxed_write32(&csdev->access, CORESIGHT_CLAIM_SELF_HOSTED,
> + CORESIGHT_CLAIMSET);
Indentation
> isb();
> }
>
> -static inline void coresight_clear_claim_tags(void __iomem *base)
> +static inline void coresight_clear_claim_tags(struct coresight_device *csdev)
> {
> - writel_relaxed(CORESIGHT_CLAIM_SELF_HOSTED, base + CORESIGHT_CLAIMCLR);
> + csdev_access_relaxed_write32(&csdev->access, CORESIGHT_CLAIM_SELF_HOSTED,
> + CORESIGHT_CLAIMCLR);
Indentation
> isb();
> }
>
> @@ -182,27 +184,33 @@ static inline void coresight_clear_claim_tags(void __iomem *base)
> * Called with CS_UNLOCKed for the component.
> * Returns : 0 on success
> */
> -int coresight_claim_device_unlocked(void __iomem *base)
> +int coresight_claim_device_unlocked(struct coresight_device *csdev)
> {
> - if (coresight_is_claimed_any(base))
> + if (WARN_ON(!csdev))
> + return -EINVAL;
> +
> + if (coresight_is_claimed_any(csdev))
> return -EBUSY;
>
> - coresight_set_claim_tags(base);
> - if (coresight_is_claimed_self_hosted(base))
> + coresight_set_claim_tags(csdev);
> + if (coresight_is_claimed_self_hosted(csdev))
> return 0;
> /* There was a race setting the tags, clean up and fail */
> - coresight_clear_claim_tags(base);
> + coresight_clear_claim_tags(csdev);
> return -EBUSY;
> }
> EXPORT_SYMBOL_GPL(coresight_claim_device_unlocked);
>
> -int coresight_claim_device(void __iomem *base)
> +int coresight_claim_device(struct coresight_device *csdev)
> {
> int rc;
>
> - CS_UNLOCK(base);
> - rc = coresight_claim_device_unlocked(base);
> - CS_LOCK(base);
> + if (WARN_ON(!csdev))
> + return -EINVAL;
> +
> + CS_UNLOCK(csdev->access.base);
> + rc = coresight_claim_device_unlocked(csdev);
> + CS_LOCK(csdev->access.base);
>
> return rc;
> }
> @@ -212,11 +220,14 @@ EXPORT_SYMBOL_GPL(coresight_claim_device);
> * coresight_disclaim_device_unlocked : Clear the claim tags for the device.
> * Called with CS_UNLOCKed for the component.
> */
> -void coresight_disclaim_device_unlocked(void __iomem *base)
> +void coresight_disclaim_device_unlocked(struct coresight_device *csdev)
> {
>
> - if (coresight_is_claimed_self_hosted(base))
> - coresight_clear_claim_tags(base);
> + if (WARN_ON(!csdev))
> + return;
> +
> + if (coresight_is_claimed_self_hosted(csdev))
> + coresight_clear_claim_tags(csdev);
> else
> /*
> * The external agent may have not honoured our claim
> @@ -227,11 +238,14 @@ void coresight_disclaim_device_unlocked(void __iomem *base)
> }
> EXPORT_SYMBOL_GPL(coresight_disclaim_device_unlocked);
>
> -void coresight_disclaim_device(void __iomem *base)
> +void coresight_disclaim_device(struct coresight_device *csdev)
> {
> - CS_UNLOCK(base);
> - coresight_disclaim_device_unlocked(base);
> - CS_LOCK(base);
> + if (WARN_ON(!csdev))
> + return;
> +
> + CS_UNLOCK(csdev->access.base);
> + coresight_disclaim_device_unlocked(csdev);
> + CS_LOCK(csdev->access.base);
> }
> EXPORT_SYMBOL_GPL(coresight_disclaim_device);
>
> diff --git a/drivers/hwtracing/coresight/coresight-cti-core.c b/drivers/hwtracing/coresight/coresight-cti-core.c
> index 3bb0de97d66e..5651d7f61a70 100644
> --- a/drivers/hwtracing/coresight/coresight-cti-core.c
> +++ b/drivers/hwtracing/coresight/coresight-cti-core.c
> @@ -102,7 +102,7 @@ static int cti_enable_hw(struct cti_drvdata *drvdata)
> goto cti_state_unchanged;
>
> /* claim the device */
> - rc = coresight_claim_device(drvdata->base);
> + rc = coresight_claim_device(drvdata->csdev);
> if (rc)
> goto cti_err_not_enabled;
>
> @@ -136,7 +136,7 @@ static void cti_cpuhp_enable_hw(struct cti_drvdata *drvdata)
> goto cti_hp_not_enabled;
>
> /* try to claim the device */
> - if (coresight_claim_device(drvdata->base))
> + if (coresight_claim_device(drvdata->csdev))
> goto cti_hp_not_enabled;
>
> cti_write_all_hw_regs(drvdata);
> @@ -154,6 +154,7 @@ static int cti_disable_hw(struct cti_drvdata *drvdata)
> {
> struct cti_config *config = &drvdata->config;
> struct device *dev = &drvdata->csdev->dev;
> + struct coresight_device *csdev = drvdata->csdev;
>
> spin_lock(&drvdata->spinlock);
>
> @@ -171,7 +172,7 @@ static int cti_disable_hw(struct cti_drvdata *drvdata)
> writel_relaxed(0, drvdata->base + CTICONTROL);
> config->hw_enabled = false;
>
> - coresight_disclaim_device_unlocked(drvdata->base);
> + coresight_disclaim_device_unlocked(csdev);
> CS_LOCK(drvdata->base);
> spin_unlock(&drvdata->spinlock);
> pm_runtime_put(dev);
> @@ -655,6 +656,7 @@ static int cti_cpu_pm_notify(struct notifier_block *nb, unsigned long cmd,
> void *v)
> {
> struct cti_drvdata *drvdata;
> + struct coresight_device *csdev;
> unsigned int cpu = smp_processor_id();
> int notify_res = NOTIFY_OK;
>
> @@ -662,6 +664,7 @@ static int cti_cpu_pm_notify(struct notifier_block *nb, unsigned long cmd,
> return NOTIFY_OK;
>
> drvdata = cti_cpu_drvdata[cpu];
> + csdev = drvdata->csdev;
>
> if (WARN_ON_ONCE(drvdata->ctidev.cpu != cpu))
> return NOTIFY_BAD;
> @@ -673,13 +676,13 @@ static int cti_cpu_pm_notify(struct notifier_block *nb, unsigned long cmd,
> /* CTI regs all static - we have a copy & nothing to save */
> drvdata->config.hw_powered = false;
> if (drvdata->config.hw_enabled)
> - coresight_disclaim_device(drvdata->base);
> + coresight_disclaim_device(csdev);
> break;
>
> case CPU_PM_ENTER_FAILED:
> drvdata->config.hw_powered = true;
> if (drvdata->config.hw_enabled) {
> - if (coresight_claim_device(drvdata->base))
> + if (coresight_claim_device(csdev))
> drvdata->config.hw_enabled = false;
> }
> break;
> @@ -692,7 +695,7 @@ static int cti_cpu_pm_notify(struct notifier_block *nb, unsigned long cmd,
> /* check enable reference count to enable HW */
> if (atomic_read(&drvdata->config.enable_req_count)) {
> /* check we can claim the device as we re-power */
> - if (coresight_claim_device(drvdata->base))
> + if (coresight_claim_device(csdev))
> goto cti_notify_exit;
>
> drvdata->config.hw_enabled = true;
> @@ -736,7 +739,7 @@ static int cti_dying_cpu(unsigned int cpu)
> spin_lock(&drvdata->spinlock);
> drvdata->config.hw_powered = false;
> if (drvdata->config.hw_enabled)
> - coresight_disclaim_device(drvdata->base);
> + coresight_disclaim_device(drvdata->csdev);
> spin_unlock(&drvdata->spinlock);
> return 0;
> }
> diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c
> index f994a22876d9..0a416883e012 100644
> --- a/drivers/hwtracing/coresight/coresight-etb10.c
> +++ b/drivers/hwtracing/coresight/coresight-etb10.c
> @@ -132,7 +132,7 @@ static void __etb_enable_hw(struct etb_drvdata *drvdata)
>
> static int etb_enable_hw(struct etb_drvdata *drvdata)
> {
> - int rc = coresight_claim_device(drvdata->base);
> + int rc = coresight_claim_device(drvdata->csdev);
>
> if (rc)
> return rc;
> @@ -344,7 +344,7 @@ static void etb_disable_hw(struct etb_drvdata *drvdata)
> {
> __etb_disable_hw(drvdata);
> etb_dump_hw(drvdata);
> - coresight_disclaim_device(drvdata->base);
> + coresight_disclaim_device(drvdata->csdev);
> }
>
> static int etb_disable(struct coresight_device *csdev)
> diff --git a/drivers/hwtracing/coresight/coresight-etm3x-core.c b/drivers/hwtracing/coresight/coresight-etm3x-core.c
> index 36c5b0ae1b43..70d6d809cb47 100644
> --- a/drivers/hwtracing/coresight/coresight-etm3x-core.c
> +++ b/drivers/hwtracing/coresight/coresight-etm3x-core.c
> @@ -358,10 +358,11 @@ static int etm_enable_hw(struct etm_drvdata *drvdata)
> int i, rc;
> u32 etmcr;
> struct etm_config *config = &drvdata->config;
> + struct coresight_device *csdev = drvdata->csdev;
>
> CS_UNLOCK(drvdata->base);
>
> - rc = coresight_claim_device_unlocked(drvdata->base);
> + rc = coresight_claim_device_unlocked(csdev);
> if (rc)
> goto done;
>
> @@ -566,6 +567,7 @@ static void etm_disable_hw(void *info)
> int i;
> struct etm_drvdata *drvdata = info;
> struct etm_config *config = &drvdata->config;
> + struct coresight_device *csdev = drvdata->csdev;
>
> CS_UNLOCK(drvdata->base);
> etm_set_prog(drvdata);
> @@ -577,7 +579,7 @@ static void etm_disable_hw(void *info)
> config->cntr_val[i] = etm_readl(drvdata, ETMCNTVRn(i));
>
> etm_set_pwrdwn(drvdata);
> - coresight_disclaim_device_unlocked(drvdata->base);
> + coresight_disclaim_device_unlocked(csdev);
>
> CS_LOCK(drvdata->base);
>
> @@ -602,7 +604,7 @@ static void etm_disable_perf(struct coresight_device *csdev)
> * power down the tracer.
> */
> etm_set_pwrdwn(drvdata);
> - coresight_disclaim_device_unlocked(drvdata->base);
> + coresight_disclaim_device_unlocked(csdev);
>
> CS_LOCK(drvdata->base);
> }
> diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c
> index 2744aadaa5ec..4f1bcf98fefe 100644
> --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c
> +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c
> @@ -115,7 +115,7 @@ static int etm4_enable_hw(struct etmv4_drvdata *drvdata)
>
> etm4_os_unlock(drvdata);
>
> - rc = coresight_claim_device_unlocked(drvdata->base);
> + rc = coresight_claim_device_unlocked(csdev);
> if (rc)
> goto done;
>
> @@ -523,7 +523,7 @@ static void etm4_disable_hw(void *info)
> readl_relaxed(drvdata->base + TRCCNTVRn(i));
> }
>
> - coresight_disclaim_device_unlocked(drvdata->base);
> + coresight_disclaim_device_unlocked(csdev);
>
> CS_LOCK(drvdata->base);
>
> diff --git a/drivers/hwtracing/coresight/coresight-funnel.c b/drivers/hwtracing/coresight/coresight-funnel.c
> index f77466aea26f..2f8675c527bf 100644
> --- a/drivers/hwtracing/coresight/coresight-funnel.c
> +++ b/drivers/hwtracing/coresight/coresight-funnel.c
> @@ -52,13 +52,14 @@ static int dynamic_funnel_enable_hw(struct funnel_drvdata *drvdata, int port)
> {
> u32 functl;
> int rc = 0;
> + struct coresight_device *csdev = drvdata->csdev;
>
> CS_UNLOCK(drvdata->base);
>
> functl = readl_relaxed(drvdata->base + FUNNEL_FUNCTL);
> /* Claim the device only when we enable the first slave */
> if (!(functl & FUNNEL_ENSx_MASK)) {
> - rc = coresight_claim_device_unlocked(drvdata->base);
> + rc = coresight_claim_device_unlocked(csdev);
> if (rc)
> goto done;
> }
> @@ -101,6 +102,7 @@ static void dynamic_funnel_disable_hw(struct funnel_drvdata *drvdata,
> int inport)
> {
> u32 functl;
> + struct coresight_device *csdev = drvdata->csdev;
>
> CS_UNLOCK(drvdata->base);
>
> @@ -110,7 +112,7 @@ static void dynamic_funnel_disable_hw(struct funnel_drvdata *drvdata,
>
> /* Disclaim the device if none of the slaves are now active */
> if (!(functl & FUNNEL_ENSx_MASK))
> - coresight_disclaim_device_unlocked(drvdata->base);
> + coresight_disclaim_device_unlocked(csdev);
>
> CS_LOCK(drvdata->base);
> }
> diff --git a/drivers/hwtracing/coresight/coresight-replicator.c b/drivers/hwtracing/coresight/coresight-replicator.c
> index fcf25740116c..e35d79e74e30 100644
> --- a/drivers/hwtracing/coresight/coresight-replicator.c
> +++ b/drivers/hwtracing/coresight/coresight-replicator.c
> @@ -45,12 +45,18 @@ struct replicator_drvdata {
>
> static void dynamic_replicator_reset(struct replicator_drvdata *drvdata)
> {
> + struct coresight_device *csdev = drvdata->csdev;
> CS_UNLOCK(drvdata->base);
>
> - if (!coresight_claim_device_unlocked(drvdata->base)) {
> + if (WARN_ON(!csdev))
> + return;
I don't see a need for this check. Function replicator_reset() is called from
probe() where the validity of drvdata->csdev is checked just before.
> +
> + CS_UNLOCK(drvdata->base);
> +
> + if (!coresight_claim_device_unlocked(csdev)) {
> writel_relaxed(0xff, drvdata->base + REPLICATOR_IDFILTER0);
> writel_relaxed(0xff, drvdata->base + REPLICATOR_IDFILTER1);
> - coresight_disclaim_device_unlocked(drvdata->base);
> + coresight_disclaim_device_unlocked(csdev);
> }
>
> CS_LOCK(drvdata->base);
> @@ -70,6 +76,7 @@ static int dynamic_replicator_enable(struct replicator_drvdata *drvdata,
> {
> int rc = 0;
> u32 id0val, id1val;
> + struct coresight_device *csdev = drvdata->csdev;
>
> CS_UNLOCK(drvdata->base);
>
> @@ -84,7 +91,7 @@ static int dynamic_replicator_enable(struct replicator_drvdata *drvdata,
> id0val = id1val = 0xff;
>
> if (id0val == 0xff && id1val == 0xff)
> - rc = coresight_claim_device_unlocked(drvdata->base);
> + rc = coresight_claim_device_unlocked(csdev);
>
> if (!rc) {
> switch (outport) {
> @@ -140,6 +147,7 @@ static void dynamic_replicator_disable(struct replicator_drvdata *drvdata,
> int inport, int outport)
> {
> u32 reg;
> + struct coresight_device *csdev = drvdata->csdev;
>
> switch (outport) {
> case 0:
> @@ -160,7 +168,7 @@ static void dynamic_replicator_disable(struct replicator_drvdata *drvdata,
>
> if ((readl_relaxed(drvdata->base + REPLICATOR_IDFILTER0) == 0xff) &&
> (readl_relaxed(drvdata->base + REPLICATOR_IDFILTER1) == 0xff))
> - coresight_disclaim_device_unlocked(drvdata->base);
> + coresight_disclaim_device_unlocked(csdev);
> CS_LOCK(drvdata->base);
> }
>
> diff --git a/drivers/hwtracing/coresight/coresight-tmc-etf.c b/drivers/hwtracing/coresight/coresight-tmc-etf.c
> index 44402d413ebb..3a5605eda68f 100644
> --- a/drivers/hwtracing/coresight/coresight-tmc-etf.c
> +++ b/drivers/hwtracing/coresight/coresight-tmc-etf.c
> @@ -37,7 +37,7 @@ static void __tmc_etb_enable_hw(struct tmc_drvdata *drvdata)
>
> static int tmc_etb_enable_hw(struct tmc_drvdata *drvdata)
> {
> - int rc = coresight_claim_device(drvdata->base);
> + int rc = coresight_claim_device(drvdata->csdev);
>
> if (rc)
> return rc;
> @@ -88,7 +88,7 @@ static void __tmc_etb_disable_hw(struct tmc_drvdata *drvdata)
> static void tmc_etb_disable_hw(struct tmc_drvdata *drvdata)
> {
> __tmc_etb_disable_hw(drvdata);
> - coresight_disclaim_device(drvdata->base);
> + coresight_disclaim_device(drvdata->csdev);
> }
>
> static void __tmc_etf_enable_hw(struct tmc_drvdata *drvdata)
> @@ -109,7 +109,7 @@ static void __tmc_etf_enable_hw(struct tmc_drvdata *drvdata)
>
> static int tmc_etf_enable_hw(struct tmc_drvdata *drvdata)
> {
> - int rc = coresight_claim_device(drvdata->base);
> + int rc = coresight_claim_device(drvdata->csdev);
>
> if (rc)
> return rc;
> @@ -120,11 +120,13 @@ static int tmc_etf_enable_hw(struct tmc_drvdata *drvdata)
>
> static void tmc_etf_disable_hw(struct tmc_drvdata *drvdata)
> {
> + struct coresight_device *csdev = drvdata->csdev;
> +
> CS_UNLOCK(drvdata->base);
>
> tmc_flush_and_stop(drvdata);
> tmc_disable_hw(drvdata);
> - coresight_disclaim_device_unlocked(drvdata->base);
> + coresight_disclaim_device_unlocked(csdev);
> CS_LOCK(drvdata->base);
> }
>
> diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c
> index 714f9e867e5f..a8b1c49761c7 100644
> --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c
> +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c
> @@ -1038,7 +1038,7 @@ static int tmc_etr_enable_hw(struct tmc_drvdata *drvdata,
> rc = tmc_etr_enable_catu(drvdata, etr_buf);
> if (rc)
> return rc;
> - rc = coresight_claim_device(drvdata->base);
> + rc = coresight_claim_device(drvdata->csdev);
> if (!rc) {
> drvdata->etr_buf = etr_buf;
> __tmc_etr_enable_hw(drvdata);
> @@ -1132,7 +1132,7 @@ void tmc_etr_disable_hw(struct tmc_drvdata *drvdata)
> __tmc_etr_disable_hw(drvdata);
> /* Disable CATU device if this ETR is connected to one */
> tmc_etr_disable_catu(drvdata);
> - coresight_disclaim_device(drvdata->base);
> + coresight_disclaim_device(drvdata->csdev);
> /* Reset the ETR buf used by hardware */
> drvdata->etr_buf = NULL;
> }
> diff --git a/include/linux/coresight.h b/include/linux/coresight.h
> index cefc8fe239e6..c2d0a2aea45f 100644
> --- a/include/linux/coresight.h
> +++ b/include/linux/coresight.h
> @@ -474,11 +474,11 @@ extern int coresight_timeout(struct csdev_access *csa,
> int position,
> int value);
>
> -extern int coresight_claim_device(void __iomem *base);
> -extern int coresight_claim_device_unlocked(void __iomem *base);
> +extern int coresight_claim_device(struct coresight_device *csdev);
> +extern int coresight_claim_device_unlocked(struct coresight_device *csdev);
>
> -extern void coresight_disclaim_device(void __iomem *base);
> -extern void coresight_disclaim_device_unlocked(void __iomem *base);
> +extern void coresight_disclaim_device(struct coresight_device *csdev);
> +extern void coresight_disclaim_device_unlocked(struct coresight_device *csdev);
> extern char *coresight_alloc_device_name(struct coresight_dev_list *devs,
> struct device *dev);
>
> @@ -513,18 +513,18 @@ static inline int coresight_timeout(struct csdev_access *csa,
> return 1;
> }
>
> -static inline int coresight_claim_device_unlocked(void __iomem *base)
> +static inline int coresight_claim_device_unlocked(struct coresight_device *csdev)
> {
> return -EINVAL;
> }
>
> -static inline int coresight_claim_device(void __iomem *base)
> +static inline int coresight_claim_device(struct coresight_device *csdev)
> {
> return -EINVAL;
> }
>
> -static inline void coresight_disclaim_device(void __iomem *base) {}
> -static inline void coresight_disclaim_device_unlocked(void __iomem *base) {}
> +static inline void coresight_disclaim_device(struct coresight_device *csdev) {}
> +static inline void coresight_disclaim_device_unlocked(struct coresight_device *csdev) {}
>
> static inline bool coresight_loses_context_with_cpu(struct device *dev)
> {
> --
> 2.24.1
>
next prev parent reply other threads:[~2020-11-03 18:37 UTC|newest]
Thread overview: 154+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-28 22:09 [PATCH v3 00/26] coresight: Support for ETM system instructions Suzuki K Poulose
2020-10-28 22:09 ` Suzuki K Poulose
2020-10-28 22:09 ` Suzuki K Poulose
2020-10-28 22:09 ` Suzuki K Poulose
2020-10-28 22:09 ` [PATCH v3 01/26] coresight: etm4x: Fix accesses to TRCVMIDCTLR1 Suzuki K Poulose
2020-10-28 22:09 ` Suzuki K Poulose
2020-10-28 22:09 ` [PATCH v3 02/26] coresight: etm4x: Fix accesses to TRCCIDCTLR1 Suzuki K Poulose
2020-10-28 22:09 ` Suzuki K Poulose
2020-10-28 22:09 ` [PATCH v3 03/26] coresight: etm4x: Update TRCIDR3.NUMPROCS handling to match v4.2 Suzuki K Poulose
2020-10-28 22:09 ` Suzuki K Poulose
2020-10-28 22:09 ` [PATCH v3 04/26] coresight: etm4x: Fix accesses to TRCPROCSELR Suzuki K Poulose
2020-10-28 22:09 ` Suzuki K Poulose
2020-10-28 22:09 ` [PATCH v3 05/26] coresight: etm4x: Handle TRCVIPCSSCTLR accesses Suzuki K Poulose
2020-10-28 22:09 ` Suzuki K Poulose
2020-10-28 22:09 ` [PATCH v3 06/26] coresight: etm4x: Handle access to TRCSSPCICRn Suzuki K Poulose
2020-10-28 22:09 ` Suzuki K Poulose
2020-11-02 21:46 ` Mathieu Poirier
2020-11-02 21:46 ` Mathieu Poirier
2020-11-02 22:04 ` Suzuki K Poulose
2020-11-02 22:04 ` Suzuki K Poulose
2020-10-28 22:09 ` [PATCH v3 07/26] coresight: Introduce device access abstraction Suzuki K Poulose
2020-10-28 22:09 ` Suzuki K Poulose
2020-11-03 17:14 ` Mathieu Poirier
2020-11-03 17:14 ` Mathieu Poirier
2020-11-03 17:25 ` Mathieu Poirier
2020-11-03 17:25 ` Mathieu Poirier
2020-11-04 10:07 ` Suzuki K Poulose
2020-11-04 10:07 ` Suzuki K Poulose
2020-11-09 21:00 ` Mathieu Poirier
2020-11-09 21:00 ` Mathieu Poirier
2020-11-10 9:24 ` Suzuki K Poulose
2020-11-10 9:24 ` Suzuki K Poulose
2020-11-10 17:02 ` Mathieu Poirier
2020-11-10 17:02 ` Mathieu Poirier
2020-10-28 22:09 ` [PATCH v3 08/26] coresight: tpiu: Prepare for using coresight " Suzuki K Poulose
2020-10-28 22:09 ` Suzuki K Poulose
2020-11-03 18:03 ` Mathieu Poirier
2020-11-03 18:03 ` Mathieu Poirier
2020-10-28 22:09 ` [PATCH v3 09/26] coresight: Convert coresight_timeout to use " Suzuki K Poulose
2020-10-28 22:09 ` Suzuki K Poulose
2020-11-03 18:03 ` Mathieu Poirier
2020-11-03 18:03 ` Mathieu Poirier
2020-11-04 10:42 ` Suzuki K Poulose
2020-11-04 10:42 ` Suzuki K Poulose
2020-10-28 22:09 ` [PATCH v3 10/26] coresight: Convert claim/disclaim operations to use access wrappers Suzuki K Poulose
2020-10-28 22:09 ` Suzuki K Poulose
2020-11-03 18:36 ` Mathieu Poirier [this message]
2020-11-03 18:36 ` Mathieu Poirier
2020-11-04 10:54 ` Suzuki K Poulose
2020-11-04 10:54 ` Suzuki K Poulose
2020-10-28 22:09 ` [PATCH v3 11/26] coresight: etm4x: Always read the registers on the host CPU Suzuki K Poulose
2020-10-28 22:09 ` Suzuki K Poulose
2020-10-28 22:09 ` [PATCH v3 12/26] coresight: etm4x: Convert all register accesses Suzuki K Poulose
2020-10-28 22:09 ` Suzuki K Poulose
2020-11-03 18:53 ` Mathieu Poirier
2020-11-03 18:53 ` Mathieu Poirier
2020-10-28 22:09 ` [PATCH v3 13/26] coresight: etm4x: Add commentary on the registers Suzuki K Poulose
2020-10-28 22:09 ` Suzuki K Poulose
2020-11-03 19:03 ` Mathieu Poirier
2020-11-03 19:03 ` Mathieu Poirier
2020-11-03 19:04 ` Mathieu Poirier
2020-11-03 19:04 ` Mathieu Poirier
2020-10-28 22:09 ` [PATCH v3 14/26] coresight: etm4x: Add sysreg access helpers Suzuki K Poulose
2020-10-28 22:09 ` Suzuki K Poulose
2020-10-29 15:26 ` Suzuki K Poulose
2020-10-29 15:26 ` Suzuki K Poulose
2020-11-05 20:52 ` Mathieu Poirier
2020-11-05 20:52 ` Mathieu Poirier
2020-11-05 22:47 ` Suzuki K Poulose
2020-11-05 22:47 ` Suzuki K Poulose
2020-10-28 22:09 ` [PATCH v3 15/26] coresight: etm4x: Define DEVARCH register fields Suzuki K Poulose
2020-10-28 22:09 ` Suzuki K Poulose
2020-10-28 22:09 ` [PATCH v3 16/26] coresight: etm4x: Check for Software Lock Suzuki K Poulose
2020-10-28 22:09 ` Suzuki K Poulose
2020-11-05 21:50 ` Mathieu Poirier
2020-11-05 21:50 ` Mathieu Poirier
2020-10-28 22:09 ` [PATCH v3 17/26] coresight: etm4x: Cleanup secure exception level masks Suzuki K Poulose
2020-10-28 22:09 ` Suzuki K Poulose
2020-11-05 21:55 ` Mathieu Poirier
2020-11-05 21:55 ` Mathieu Poirier
2020-11-09 9:40 ` Suzuki K Poulose
2020-11-09 9:40 ` Suzuki K Poulose
2020-11-09 17:42 ` Mathieu Poirier
2020-11-09 17:42 ` Mathieu Poirier
2020-10-28 22:09 ` [PATCH v3 18/26] coresight: etm4x: Clean up " Suzuki K Poulose
2020-10-28 22:09 ` Suzuki K Poulose
2020-11-06 18:52 ` Mathieu Poirier
2020-11-06 18:52 ` Mathieu Poirier
2020-11-09 9:44 ` Suzuki K Poulose
2020-11-09 9:44 ` Suzuki K Poulose
2020-11-10 23:15 ` Suzuki K Poulose
2020-11-10 23:15 ` Suzuki K Poulose
2020-10-28 22:09 ` [PATCH v3 19/26] coresight: etm4x: Detect access early on the target CPU Suzuki K Poulose
2020-10-28 22:09 ` Suzuki K Poulose
2020-11-06 20:34 ` Mathieu Poirier
2020-11-06 20:34 ` Mathieu Poirier
2020-11-09 9:48 ` Suzuki K Poulose
2020-11-09 9:48 ` Suzuki K Poulose
2020-11-09 17:48 ` Mathieu Poirier
2020-11-09 17:48 ` Mathieu Poirier
2020-11-06 20:46 ` Mathieu Poirier
2020-11-06 20:46 ` Mathieu Poirier
2020-11-10 10:47 ` Suzuki K Poulose
2020-11-10 10:47 ` Suzuki K Poulose
2020-10-28 22:09 ` [PATCH v3 20/26] coresight: etm4x: Handle ETM architecture version Suzuki K Poulose
2020-10-28 22:09 ` Suzuki K Poulose
2020-11-06 21:11 ` Mathieu Poirier
2020-11-06 21:11 ` Mathieu Poirier
2020-11-09 9:51 ` Suzuki K Poulose
2020-11-09 9:51 ` Suzuki K Poulose
2020-10-28 22:09 ` [PATCH v3 21/26] coresight: etm4x: Use TRCDEVARCH for component discovery Suzuki K Poulose
2020-10-28 22:09 ` Suzuki K Poulose
2020-11-06 21:42 ` Mathieu Poirier
2020-11-06 21:42 ` Mathieu Poirier
2020-10-28 22:09 ` [PATCH v3 22/26] coresight: etm4x: Add necessary synchronization for sysreg access Suzuki K Poulose
2020-10-28 22:09 ` Suzuki K Poulose
2020-11-09 18:32 ` Mathieu Poirier
2020-11-09 18:32 ` Mathieu Poirier
2020-11-10 10:11 ` Suzuki K Poulose
2020-11-10 10:11 ` Suzuki K Poulose
2020-11-10 11:40 ` John Horley
2020-11-10 11:40 ` John Horley
2020-11-10 17:35 ` Mathieu Poirier
2020-11-10 17:35 ` Mathieu Poirier
2020-10-28 22:09 ` [PATCH v3 23/26] coresight: etm4x: Detect system instructions support Suzuki K Poulose
2020-10-28 22:09 ` Suzuki K Poulose
2020-11-09 20:22 ` Mathieu Poirier
2020-11-09 20:22 ` Mathieu Poirier
2020-11-10 9:31 ` Suzuki K Poulose
2020-11-10 9:31 ` Suzuki K Poulose
2020-11-10 17:33 ` Mathieu Poirier
2020-11-10 17:33 ` Mathieu Poirier
2020-10-28 22:09 ` [PATCH v3 24/26] coresight: etm4x: Refactor probing routine Suzuki K Poulose
2020-10-28 22:09 ` Suzuki K Poulose
2020-11-09 20:43 ` Mathieu Poirier
2020-11-09 20:43 ` Mathieu Poirier
2020-10-28 22:09 ` [PATCH v3 25/26] coresight: etm4x: Add support for sysreg only devices Suzuki K Poulose
2020-10-28 22:09 ` Suzuki K Poulose
2020-11-09 20:46 ` Mathieu Poirier
2020-11-09 20:46 ` Mathieu Poirier
2020-11-10 10:50 ` Suzuki K Poulose
2020-11-10 10:50 ` Suzuki K Poulose
2020-10-28 22:09 ` [PATCH v3 26/26] dts: bindings: coresight: ETM system register access only units Suzuki K Poulose
2020-10-28 22:09 ` Suzuki K Poulose
2020-11-02 15:31 ` Rob Herring
2020-11-02 15:31 ` Rob Herring
2020-11-09 20:50 ` Mathieu Poirier
2020-11-09 20:50 ` Mathieu Poirier
2020-11-10 10:51 ` Suzuki K Poulose
2020-11-10 10:51 ` Suzuki K Poulose
2020-10-29 7:53 ` [PATCH v3 00/26] coresight: Support for ETM system instructions Mike Leach
2020-10-29 7:53 ` Mike Leach
2020-10-29 15:45 ` Suzuki K Poulose
2020-10-29 15:45 ` Suzuki K Poulose
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=20201103183625.GD2855763@xps15 \
--to=mathieu.poirier@linaro.org \
--cc=coresight@lists.linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mike.leach@linaro.org \
--cc=suzuki.poulose@arm.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.