Skip to content

Commit fc7fed6

Browse files
james-c-linaroSuzuki K Poulose
authored andcommitted
coresight: Convert tag clear function to take a struct csdev_access
The self hosted claim tag will be reset on device probe in a later commit. We'll want to do this before coresight_register() is called so won't have a coresight_device and have to use csdev_access instead. Also make them public and create locked and unlocked versions for later use. These look functions look like they set the whole tags register as one value, but they only set and clear the self hosted bit using a SET/CLR bits mechanism so also rename the functions to reflect this better. Reviewed-by: Leo Yan <[email protected]> Reviewed-by: Yeoreum Yun <[email protected]> Signed-off-by: James Clark <[email protected]> Signed-off-by: Suzuki K Poulose <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent f6028ee commit fc7fed6

File tree

2 files changed

+24
-12
lines changed

2 files changed

+24
-12
lines changed

drivers/hwtracing/coresight/coresight-core.c

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -129,34 +129,45 @@ coresight_find_out_connection(struct coresight_device *csdev,
129129
return ERR_PTR(-ENODEV);
130130
}
131131

132-
static inline u32 coresight_read_claim_tags(struct coresight_device *csdev)
132+
static inline u32 coresight_read_claim_tags_unlocked(struct coresight_device *csdev)
133133
{
134134
return csdev_access_relaxed_read32(&csdev->access, CORESIGHT_CLAIMCLR);
135135
}
136136

137137
static inline bool coresight_is_claimed_self_hosted(struct coresight_device *csdev)
138138
{
139-
return coresight_read_claim_tags(csdev) == CORESIGHT_CLAIM_SELF_HOSTED;
139+
return coresight_read_claim_tags_unlocked(csdev) == CORESIGHT_CLAIM_SELF_HOSTED;
140140
}
141141

142142
static inline bool coresight_is_claimed_any(struct coresight_device *csdev)
143143
{
144-
return coresight_read_claim_tags(csdev) != 0;
144+
return coresight_read_claim_tags_unlocked(csdev) != 0;
145145
}
146146

147-
static inline void coresight_set_claim_tags(struct coresight_device *csdev)
147+
static inline void coresight_set_self_claim_tag_unlocked(struct coresight_device *csdev)
148148
{
149149
csdev_access_relaxed_write32(&csdev->access, CORESIGHT_CLAIM_SELF_HOSTED,
150150
CORESIGHT_CLAIMSET);
151151
isb();
152152
}
153153

154-
static inline void coresight_clear_claim_tags(struct coresight_device *csdev)
154+
void coresight_clear_self_claim_tag(struct csdev_access *csa)
155155
{
156-
csdev_access_relaxed_write32(&csdev->access, CORESIGHT_CLAIM_SELF_HOSTED,
156+
if (csa->io_mem)
157+
CS_UNLOCK(csa->base);
158+
coresight_clear_self_claim_tag_unlocked(csa);
159+
if (csa->io_mem)
160+
CS_LOCK(csa->base);
161+
}
162+
EXPORT_SYMBOL_GPL(coresight_clear_self_claim_tag);
163+
164+
void coresight_clear_self_claim_tag_unlocked(struct csdev_access *csa)
165+
{
166+
csdev_access_relaxed_write32(csa, CORESIGHT_CLAIM_SELF_HOSTED,
157167
CORESIGHT_CLAIMCLR);
158168
isb();
159169
}
170+
EXPORT_SYMBOL_GPL(coresight_clear_self_claim_tag_unlocked);
160171

161172
/*
162173
* coresight_claim_device_unlocked : Claim the device for self-hosted usage
@@ -176,11 +187,11 @@ int coresight_claim_device_unlocked(struct coresight_device *csdev)
176187
if (coresight_is_claimed_any(csdev))
177188
return -EBUSY;
178189

179-
coresight_set_claim_tags(csdev);
190+
coresight_set_self_claim_tag_unlocked(csdev);
180191
if (coresight_is_claimed_self_hosted(csdev))
181192
return 0;
182-
/* There was a race setting the tags, clean up and fail */
183-
coresight_clear_claim_tags(csdev);
193+
/* There was a race setting the tag, clean up and fail */
194+
coresight_clear_self_claim_tag_unlocked(&csdev->access);
184195
return -EBUSY;
185196
}
186197
EXPORT_SYMBOL_GPL(coresight_claim_device_unlocked);
@@ -201,7 +212,7 @@ int coresight_claim_device(struct coresight_device *csdev)
201212
EXPORT_SYMBOL_GPL(coresight_claim_device);
202213

203214
/*
204-
* coresight_disclaim_device_unlocked : Clear the claim tags for the device.
215+
* coresight_disclaim_device_unlocked : Clear the claim tag for the device.
205216
* Called with CS_UNLOCKed for the component.
206217
*/
207218
void coresight_disclaim_device_unlocked(struct coresight_device *csdev)
@@ -211,7 +222,7 @@ void coresight_disclaim_device_unlocked(struct coresight_device *csdev)
211222
return;
212223

213224
if (coresight_is_claimed_self_hosted(csdev))
214-
coresight_clear_claim_tags(csdev);
225+
coresight_clear_self_claim_tag_unlocked(&csdev->access);
215226
else
216227
/*
217228
* The external agent may have not honoured our claim

include/linux/coresight.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,8 @@ extern int coresight_timeout_action(struct csdev_access *csa, u32 offset,
685685

686686
extern int coresight_claim_device(struct coresight_device *csdev);
687687
extern int coresight_claim_device_unlocked(struct coresight_device *csdev);
688-
688+
void coresight_clear_self_claim_tag(struct csdev_access *csa);
689+
void coresight_clear_self_claim_tag_unlocked(struct csdev_access *csa);
689690
extern void coresight_disclaim_device(struct coresight_device *csdev);
690691
extern void coresight_disclaim_device_unlocked(struct coresight_device *csdev);
691692
extern char *coresight_alloc_device_name(struct coresight_dev_list *devs,

0 commit comments

Comments
 (0)