Commit 8a4bc4f1 authored by Suzuki K Poulose's avatar Suzuki K Poulose Committed by Greg Kroah-Hartman

coresight: tmc-etr: Check if non-secure access is enabled

CoreSight TMC-ETR must have the non-secure invasive debug access
enabled for use by self-hosted tracing. Without it, there is no
point in enabling the ETR. So, let us check it in the TMC_AUTHSTATUS
register and fail the probe if it is disabled.

Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: default avatarSuzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
Link: https://lore.kernel.org/r/20190829202842.580-7-mathieu.poirier@linaro.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent f52ff9b7
...@@ -236,6 +236,7 @@ coresight_tmc_reg(ffcr, TMC_FFCR); ...@@ -236,6 +236,7 @@ coresight_tmc_reg(ffcr, TMC_FFCR);
coresight_tmc_reg(mode, TMC_MODE); coresight_tmc_reg(mode, TMC_MODE);
coresight_tmc_reg(pscr, TMC_PSCR); coresight_tmc_reg(pscr, TMC_PSCR);
coresight_tmc_reg(axictl, TMC_AXICTL); coresight_tmc_reg(axictl, TMC_AXICTL);
coresight_tmc_reg(authstatus, TMC_AUTHSTATUS);
coresight_tmc_reg(devid, CORESIGHT_DEVID); coresight_tmc_reg(devid, CORESIGHT_DEVID);
coresight_tmc_reg64(rrp, TMC_RRP, TMC_RRPHI); coresight_tmc_reg64(rrp, TMC_RRP, TMC_RRPHI);
coresight_tmc_reg64(rwp, TMC_RWP, TMC_RWPHI); coresight_tmc_reg64(rwp, TMC_RWP, TMC_RWPHI);
...@@ -255,6 +256,7 @@ static struct attribute *coresight_tmc_mgmt_attrs[] = { ...@@ -255,6 +256,7 @@ static struct attribute *coresight_tmc_mgmt_attrs[] = {
&dev_attr_devid.attr, &dev_attr_devid.attr,
&dev_attr_dba.attr, &dev_attr_dba.attr,
&dev_attr_axictl.attr, &dev_attr_axictl.attr,
&dev_attr_authstatus.attr,
NULL, NULL,
}; };
...@@ -342,6 +344,13 @@ static inline bool tmc_etr_can_use_sg(struct device *dev) ...@@ -342,6 +344,13 @@ static inline bool tmc_etr_can_use_sg(struct device *dev)
return fwnode_property_present(dev->fwnode, "arm,scatter-gather"); return fwnode_property_present(dev->fwnode, "arm,scatter-gather");
} }
static inline bool tmc_etr_has_non_secure_access(struct tmc_drvdata *drvdata)
{
u32 auth = readl_relaxed(drvdata->base + TMC_AUTHSTATUS);
return (auth & TMC_AUTH_NSID_MASK) == 0x3;
}
/* Detect and initialise the capabilities of a TMC ETR */ /* Detect and initialise the capabilities of a TMC ETR */
static int tmc_etr_setup_caps(struct device *parent, u32 devid, void *dev_caps) static int tmc_etr_setup_caps(struct device *parent, u32 devid, void *dev_caps)
{ {
...@@ -349,6 +358,9 @@ static int tmc_etr_setup_caps(struct device *parent, u32 devid, void *dev_caps) ...@@ -349,6 +358,9 @@ static int tmc_etr_setup_caps(struct device *parent, u32 devid, void *dev_caps)
u32 dma_mask = 0; u32 dma_mask = 0;
struct tmc_drvdata *drvdata = dev_get_drvdata(parent); struct tmc_drvdata *drvdata = dev_get_drvdata(parent);
if (!tmc_etr_has_non_secure_access(drvdata))
return -EACCES;
/* Set the unadvertised capabilities */ /* Set the unadvertised capabilities */
tmc_etr_init_caps(drvdata, (u32)(unsigned long)dev_caps); tmc_etr_init_caps(drvdata, (u32)(unsigned long)dev_caps);
......
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#define TMC_ITATBCTR2 0xef0 #define TMC_ITATBCTR2 0xef0
#define TMC_ITATBCTR1 0xef4 #define TMC_ITATBCTR1 0xef4
#define TMC_ITATBCTR0 0xef8 #define TMC_ITATBCTR0 0xef8
#define TMC_AUTHSTATUS 0xfb8
/* register description */ /* register description */
/* TMC_CTL - 0x020 */ /* TMC_CTL - 0x020 */
...@@ -90,6 +91,8 @@ ...@@ -90,6 +91,8 @@
#define TMC_DEVID_AXIAW_SHIFT 17 #define TMC_DEVID_AXIAW_SHIFT 17
#define TMC_DEVID_AXIAW_MASK 0x7f #define TMC_DEVID_AXIAW_MASK 0x7f
#define TMC_AUTH_NSID_MASK GENMASK(1, 0)
enum tmc_config_type { enum tmc_config_type {
TMC_CONFIG_TYPE_ETB, TMC_CONFIG_TYPE_ETB,
TMC_CONFIG_TYPE_ETR, TMC_CONFIG_TYPE_ETR,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment