strlen is often used incorectly to get the length of strings
defined at compile time. In these cases, the behavior can be
replicated with sizeof(X) - 1, which is calculated at compile
time rather than runtime, reducing overhead. I've created a
simple macro to replace these instances and applied it to all
the files compiled into the angler kernel.
Signed-off-by: Joe Maples <joe@frap129.org>
'commit 734aabed17090: ("coresight: tmc: Fix use after free issue
with tmc read")' adds lock in tmc_read() to fix race condition seen in
reading tmc buffer and enabling the device.But commit has unbalanced
lock. This patch fixes the lock.
Bug: 64453422
Change-Id: Iaf3ecd83ef5af346725885ea2c84c4185f1a1c50
Signed-off-by: Saranya Chidura <schidura@codeaurora.org>
Fix race condition seen between reading tmc buffer and enabling
the device. The race condition can result in a use after free
issue if the buffer is released while a read is in progress.
Bug: 64453422
Signed-off-by: Saranya Chidura <schidura@codeaurora.org>
Change-Id: I9908fa78acbf3152ee791c63fef525f09a9a23d5
TPDA clocks are voted during TPDA enable and un-voted during TPDA
disable. Read TPDA registers only when TPDA is enabled to avoid
any unclocked access. Add TPDA enable validation checks before
reading TPDA flush registers via sysfs show functions. These validation
checks are already present in sysfs store functions used for making TPDA
flush request.
CRs-Fixed: 819721
Change-Id: Icbb530d9a1c1aad516f137c3faaf4c7d0373265c
Signed-off-by: Sarangdhar Joshi <spjoshi@codeaurora.org>
Add support to use device tree property to specify ATID value required
for supporting multiple TPDAs.
Change-Id: Id032a7cb3ceab35763f81155d1b8c50bb513be7b
Signed-off-by: Sarangdhar Joshi <spjoshi@codeaurora.org>
Add support for setting up the element size value per TPDA port for various
dataset types as this is necessary for TPDA functionality.
Change-Id: I36e7d849634d1576b5591337479cc92b77b3f395
Signed-off-by: Sarangdhar Joshi <spjoshi@codeaurora.org>
TPDA supports global and per port flush request options. Add device
attributes in TPDA driver to honor these options.
Change-Id: I5d6cbde775375b78fd0aae0734244b3753dee426
Signed-off-by: Sarangdhar Joshi <spjoshi@codeaurora.org>
Register value passed to the bitmap_fill was incorrectly setting
unnecessary extra bits in bitmap. Set only required bits in the bitmap.
Change-Id: I00630d1fd0c4ef759f45cd13efa121baa3e4df11
Signed-off-by: Sarangdhar Joshi <spjoshi@codeaurora.org>
TPDM register accesses need core clock to be ON. Vote for core clock
before accessing TPDM register.
Change-Id: I329f45d00eee486a9aa4eb005aed1ac9bec3ea56
Signed-off-by: Sarangdhar Joshi <spjoshi@codeaurora.org>
CoreSight fuse layout has changed for thulium. Add support in driver to
honor the new fuse layout.
Change-Id: I2b5b0e7a417ec01067942689f6e22e54ec56782d
Signed-off-by: Sarangdhar Joshi <spjoshi@codeaurora.org>
Due to race conditions, ETM initialization can fail if cpu hotplug
occurs while ETM probe is ongoing. Move etmdrvdata initialization
just before put_online_cpus() to prevent this race condition.
Change-Id: Iac943e5498d30554f5cb8bca4a9fe8e32bdf4030
Signed-off-by: Xiaogang Cui <xiaogang@codeaurora.org>
Move instance id to device tree to support multiple remote ETM
devices with different instance ids.
Change-Id: Ief6487df417403727dd78bb404aee5fceac54ced
Signed-off-by: Xiaogang Cui <xiaogang@codeaurora.org>
Add header meta data carrying useful info like version, magic,
task name, cpu and kernel timestamp with every OST packet sent
using STM.
This will help provide additional info that can be used for STM
log analysis.
Change-Id: I8902f5529d62417ee8b4d6a21f3801c06edce972
Signed-off-by: Pratik Patel <pratikp@codeaurora.org>
Add dsb sy barrier to stm data writes to avoid getting into a
situation where many writes are outstanding due to stm logging.
This helps avoid a cpu errata condition that gets triggerred with
heavy stm logging.
Change-Id: I7664fa3ccfcd8ac05514eb5e4db9441db9d809a2
Signed-off-by: Pratik Patel <pratikp@codeaurora.org>
Modify device attribute name for frequency request to make it more
intuitive.
Change-Id: I4fe3f8eeb1ab1abe0eae3bcb684cdc6c2bb6b034
Signed-off-by: Sarangdhar Joshi <spjoshi@codeaurora.org>
Set the flag to request timestamp by default for frequency packets. User
can clear the flag if timestamp is not required for frequency packets.
Change-Id: Iabddf7eaedeef2cd1d264a7db9c99f6bdf43bfd9
Signed-off-by: Sarangdhar Joshi <spjoshi@codeaurora.org>
Add available_out_modes and available_mem_types device attributes to
provide information on available out modes and memory type options
supported for TPIU and TMC configurations.
Change-Id: Iec02c42877aa75f024590bf112d1c33eb4ad5e46
Signed-off-by: Xiaogang Cui <xiaogang@codeaurora.org>
Use the correct mutex lock for CTI show functions to ensure
proper mutual exclusion while referencing refcnt.
Change-Id: I8c5b69526bbd46630f5f9d5a3c4b4542b065da11
Signed-off-by: Pratik Patel <pratikp@codeaurora.org>
Rearrange CTI clock voting to avoid calling clk_prepare_enable
and clk_disable_unprepare apis from atomic context. This will
prevent scheduling while in atomic context.
Change-Id: I0b8a484cb38d67255dc6f0ba7c6162252d1f0c8e
Signed-off-by: Pratik Patel <pratikp@codeaurora.org>
CPU id returned by raw_smp_processor_id() is guaranteed to be less than
NR_CPUS. So etmdrvdata array will never do out of bound accesses. Remove an
unnecessary if statement which validates this.
Change-Id: I4a46f488ba8583cfbc5bc44c7679fb93a6f6b09b
Signed-off-by: Sarangdhar Joshi <spjoshi@codeaurora.org>
Add support to disable CTI save and restore to avoid voting for
CTI clock during probe as well as the associated save and restore
latency at the cost of breaking cpu CTI support on targets where
cpu CTIs have to be preserved across power collapse.
This allows for low overhead CTI support where cpu CTI usage is
not required but the target requires cpu CTIs to be preserved
across power collapse.
Change-Id: I0545d3442d1d6b2f707da7f56d029a7df2f7cae9
Signed-off-by: Pratik Patel <pratikp@codeaurora.org>
Validate cpu node for cpu CTIs independent of cti save being set
for the respective cpu CTI. This allows for failing the probe if
the cpu node for cpu CTI does not match with one of the cpus in
the cpu possible mask irrespective of whether the target requires
cpu CTI save and restore across power collapse.
Change-Id: I1ebabedf9b14c15f376e06389c22cb71caf851af
Signed-off-by: Pratik Patel <pratikp@codeaurora.org>
Remove cti-ack-atomic dt property usage since CTI clock is now
guaranteed to be enabled as long as a mapping exist on the CTI.
This removes the need to explicitly vote for CTI clock based on
the property during probe and it is neither required to skip the
clock enablement in coresight_cti_ack_trig() since CTI clock
enablement in coresight_cti_ack_trig() is not need and is
removed.
Change-Id: I74335b6f124f4cbaadcc58fca10cf3e54f2f39fb
Signed-off-by: Pratik Patel <pratikp@codeaurora.org>
This reverts commit 8b4b8afff7 with
merge conflict resolutions.
CTI clock is required to be on for the CTI to pass the cross
trigger events and hence the revert to voting for clocks as part
of the first map on a CTI and unvoting the clocks as part of the
last unmap on a CTI.
Change-Id: I98901443c6526e223853403e2ff1a0eea2adbf83
Signed-off-by: Pratik Patel <pratikp@codeaurora.org>
Remove implicit selection of CoreSight CTI driver from Kconfig
and instead explicitly enable it in various msm defconfigs. This
gives the flexibility to selectively enable or disable CTI driver
on a defconfig for a particular target.
Change-Id: I328aa53cdcaade0bbb6bf1b0d7f4f221a5e31518
Signed-off-by: Pratik Patel <pratikp@codeaurora.org>
cd_gpio is floating on some devices, then there is a possiblity
that a false CARD_DETECT toggle is created when software starts to
resume SD card from power collapse at the same time. SD driver resume
will fail due to collision.
Change-Id: I5b33da09fe8d71ea2fa381f98f1dd79286d28399
Signed-off-by: Xiaogang Cui <xiaogang@codeaurora.org>
Add TPDA and TPDM driver support required for trace, profiling & diagnostic
data collection and retrieval. Monitors are responsible for data set
collection and aggregators are useful for pulling the datasets from one or
more attached monitors and pushing the resultant data out.
Change-Id: I15097a62ca1c100f38409abc4bf92793e8187d70
Signed-off-by: Sarangdhar Joshi <spjoshi@codeaurora.org>
Switch to using pr_err_ratelimited so as to not flood the logs if
coresight_abort gets called repeatedly from panic while the
semaphore is acquired but not released.
Change-Id: Ife180795be0e605c587b117eb0441081b154da5e
Signed-off-by: Pratik Patel <pratikp@codeaurora.org>
Add more checks for coresight fuse driver to avoid device crash
when coresight fuse driver is enabled but dt node is missing.
Change-Id: Ib18feec45ec81ae4aa64b94e1691364fea56a826
Signed-off-by: Xiaogang Cui <xiaogang@codeaurora.org>
Hardware sets the register values to indicate how many resources the trace
unit supports. Add checks to validate these values to avoid any out of
bounds access.
Change-Id: I5f19a1351af3bc727f6fb7743a258727fa80fc06
Signed-off-by: Neeti Desai <neetid@codeaurora.org>
Signed-off-by: Sarangdhar Joshi <spjoshi@codeaurora.org>
There appears to be a race condition during stm channel allocation where
two processes running in parallel get same channel. Fix this by adding a
spinlock across channel allocation logic until we figure out a root cause
of this issue.
Change-Id: Ifcc655957adae3c58d8b329d8cd5c0551a26d5c6
Signed-off-by: Sarangdhar Joshi <spjoshi@codeaurora.org>
Add support to retrieve CoreSight ETM funnel port for the CPU
associated with the ETM device to allow enabling and disabling
the correct funnel port to prevent trace flush hang during power
collapse.
Signed-off-by: Aparna Das <adas@codeaurora.org>
Change-Id: I880881b5d4de4bf1947e5316eb1ad624176516dd
Modify CoreSight drivers probe to remove dependency on ETM0
device to enable successful probe of other ETM devices even
when core0 is hotplugged off during boot.
Change-Id: I3a544d1e937719f1a1861aef37c2580aa2fb6b7d
Signed-off-by: Aparna Das <adas@codeaurora.org>
Signed-off-by: Xiaogang Cui <xiaogang@codeaurora.org>
Add support to prevent trace flush hang during power collapse
by ensuring trace data is flushed and funnel port is disabled
before CPU is powered down.
Change-Id: I78907c40bcb9e237b6fa4e319013d478751f55da
Signed-off-by: Aparna Das <adas@codeaurora.org>
Handle error condition when checking for CoreSight NIDnT fuse
to be able to return gracefully in case of error.
Change-Id: I34eff8ad20fc06e0fff384e8f2295e6730a74898
Signed-off-by: Xiaogang Cui <xiaogang@codeaurora.org>
We should be using %pa when printing physical addresses. There is an
instance in the coresight code where we're casting a physical address to
a (void *) and printing that with %p. That doesn't work with LPAE since
virtual addresses are only 32-bits and physical addresses are
64-bits. Fix this.
This fixes the following warning:
In file included from kernel/drivers/coresight/coresight-tmc.c:17:0:
kernel/drivers/coresight/coresight-tmc.c: In function \
‘tmc_etr_sg_compute_read’:
kernel/drivers/coresight/coresight-tmc.c:1473:21: warning: cast to \
pointer from integer of different size [-Wint-to-pointer-cast]
error, forbidden warning: coresight-tmc.c:1473
Change-Id: I749a7650534c8cfcba45ffd49caf96d30494009b
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
The compiler thinks that phys_pte could be used uninitialized (if
sg_tbl_num == 0). Fix this.
The specific warning being fixed is:
drivers/coresight/coresight-tmc.c: In function 'tmc_read':
drivers/coresight/coresight-tmc.c:1411:14: warning: 'phys_pte' may \
be used uninitialized in this function [-Wuninitialized]
error, forbidden warning: coresight-tmc.c:1411
Change-Id: Id26d5ccc8230dc5409c53dc14925ec9067d3dd02
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
Add a new attribute to show the paired cpu number of ETM.
This will be useful information for the user and can be
used for eg. to determine which logical cpu to online for
a particular ETM.
Change-Id: I3ace88606b93f93de47e1f1351d6ff5a7cd04cb4
Signed-off-by: Xiaogang Cui <xiaogang@codeaurora.org>
correct resource control parameter to be able to program
resource control for CoreSight ETMv4 trace.
Change-Id: If31a5bb045a84fc8d48023062fb30ed746512239
Signed-off-by: Xiaogang Cui <xiaogang@codeaurora.org>
Free the entire scatter gather table if buffer allocation fails for any
entry while populating scatter gather table.
Change-Id: Ifa1135b6475bd54300536d9f46f10fb9f3681f2f
Signed-off-by: Sarangdhar Joshi <spjoshi@codeaurora.org>
Add support to CoreSight ETMv4 driver to register for v2 meomory
dump which allows dumping ETMv4 registers in case of device crash
and subsequently parsing their contents from ramdumps.
Change-Id: Ia4af28e0dbe212367796f298d4434265a1433672
Signed-off-by: Aparna Das <adas@codeaurora.org>