Commit Graph

228 Commits

Author SHA1 Message Date
Joe Maples 353f0539b5 micro-optimization: Use DSTRLEN to remove incorrect strlen uses
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>
2019-08-26 13:31:43 +02:00
Saranya Chidura c31ee5c0ce coresight: tmc: Fix the unbalanced lock in tmc_read()
'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>
2017-10-12 19:43:50 -07:00
Saranya Chidura b73156e5a9 coresight: tmc: Fix use after free issue with tmc read
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
2017-10-12 19:43:48 -07:00
Sarangdhar Joshi 3afdc90b21 coresight: add tpda enable validation checks in sysfs show functions
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>
2015-05-04 22:45:10 -07:00
Sarangdhar Joshi bc55a64b3a coresight: use dt property to specify atid for tpda
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>
2015-02-09 15:38:38 -08:00
Sarangdhar Joshi 4a053c13ab coresight: add element size support for dataset types
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>
2015-02-05 08:27:11 -08:00
Sarangdhar Joshi 981437e636 coresight: add device attributes to support flush request
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>
2015-02-04 14:48:28 -08:00
Sarangdhar Joshi 29bf969f2a coresight: set only required bits in the bitmap
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>
2015-01-31 16:19:07 -08:00
Sarangdhar Joshi cd587cb95a coresight: vote for core clock before accessing tpdm register
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>
2015-01-28 15:28:40 -08:00
Sarangdhar Joshi f21ac4d352 coresight: add support for new fuse layout on thulium
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>
2015-01-21 13:30:07 -08:00
Linux Build Service Account fd2e03a244 Merge "coresight: use instance id from device tree" 2014-12-16 01:42:45 -08:00
Xiaogang Cui 0208cdf631 coresight: set etmdrvdata just before put_online_cpus
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>
2014-12-12 10:21:02 +08:00
Xiaogang Cui 51864eb3eb coresight: use instance id from device tree
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>
2014-12-08 11:16:33 +08:00
Pratik Patel d80f463610 coresight: add header meta data for every ost packet sent via stm
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>
2014-11-18 19:08:30 -08:00
Pratik Patel 52c3a5df57 coresight: add dsb sy barrier to stm data writes
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>
2014-11-05 11:12:20 -08:00
Sarangdhar Joshi 4608aacb30 coresight: modify frequency request device attribute name
Modify device attribute name for frequency request to make it more
intuitive.

Change-Id: I4fe3f8eeb1ab1abe0eae3bcb684cdc6c2bb6b034
Signed-off-by: Sarangdhar Joshi <spjoshi@codeaurora.org>
2014-10-31 15:01:55 -07:00
Sarangdhar Joshi 448bc9753a coresight: set the flag to request timestamp for freq packets
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>
2014-10-31 13:54:14 -07:00
Xiaogang Cui 1daf7a8fef coresight: add attributes to show available modes and mem-type options
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>
2014-10-21 13:53:36 -07:00
Pratik Patel 78ea56557a coresight: use correct mutex lock for cti show functions
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>
2014-10-13 21:43:12 -07:00
Pratik Patel 7490eb5e7f coresight: don't call clk apis from atomic context
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>
2014-10-13 21:43:11 -07:00
Linux Build Service Account cfb19d6189 Merge "coresight: remove an unnecessary if statement which validates cpu id" 2014-10-12 05:41:08 -07:00
Sarangdhar Joshi d5d3b94090 coresight: remove an unnecessary if statement which validates cpu id
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>
2014-10-09 16:08:17 -07:00
Pratik Patel 1bbccd2f87 coresight: add support for cti save disable
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>
2014-10-01 12:57:47 -07:00
Pratik Patel 2a9c456e8b coresight: check cpu node for cpu ctis independent of cti save
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>
2014-10-01 12:57:46 -07:00
Pratik Patel 08c003ea55 coresight: remove cti-ack-atomic support
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>
2014-10-01 12:57:46 -07:00
Pratik Patel cf06ad136c coresight: revert to map/unmap based clock usage for cti driver
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>
2014-10-01 12:57:45 -07:00
Pratik Patel 0cd7ef13fc defconfig: explicitly enable coresight cti on msm targets
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>
2014-10-01 12:57:45 -07:00
Xiaogang Cui 9ac709e17d coresight: enable SD only mode when hardware sensing is not enabled
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>
2014-09-29 10:37:29 +08:00
Linux Build Service Account 0136d91d63 Merge "coresight: add tpda and tpdm driver support" 2014-09-23 19:47:51 -07:00
Sarangdhar Joshi c3d8863ae0 coresight: add tpda and tpdm driver support
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>
2014-09-20 13:28:28 -07:00
Pratik Patel 9609f534ff coresight: use pr_err_ratelimited for coresight abort error
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>
2014-09-19 16:56:54 -07:00
Xiaogang Cui 567cd1b6bb coresight: add checks to avoid crash for coresight fuse
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>
2014-08-21 13:11:30 +08:00
Neeti Desai ddb78a2941 coresight: add checks to validate etm trace unit resource values
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>
2014-08-08 19:00:55 -07:00
Sarangdhar Joshi 719767d522 coresight: add spinlock across stm channel allocation
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>
2014-08-01 10:37:12 -07:00
Linux Build Service Account b2d1039d14 Merge "coresight: get etm funnel port for associated cpu" 2014-07-29 09:53:17 -07:00
Linux Build Service Account 64c9c7d17b Merge "coresight: make etm probe independent of core0" 2014-07-29 09:53:16 -07:00
Linux Build Service Account e4d4c8ea01 Merge "coresight: fix error check of coresight nidnt fuse" 2014-07-29 04:10:03 -07:00
Aparna Das 3e576089f2 coresight: get etm funnel port for associated cpu
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
2014-07-27 23:01:28 -07:00
Aparna Das bb6f7a9384 coresight: make etm probe independent of core0
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>
2014-07-28 11:37:27 +08:00
Linux Build Service Account 4be4575b9e Merge "jtagv8: prevent trace flush hang during power collapse" 2014-07-22 18:42:16 -07:00
Aparna Das 1d735525eb jtagv8: prevent trace flush hang during power collapse
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>
2014-07-21 15:34:20 -07:00
Xiaogang Cui ce8d97fe76 coresight: fix error check of coresight nidnt fuse
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>
2014-07-21 16:15:39 +08:00
Mitchel Humpherys 644cfae08a coresight: use %pa for printing physical address
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>
2014-07-18 13:30:51 -07:00
Mitchel Humpherys ca803c1ace coresight: fix uninitialized variable warning
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>
2014-07-18 13:30:51 -07:00
Linux Build Service Account 066e26412e Merge "coresight: add attr to show the logical cpu number" 2014-07-10 18:10:09 -07:00
Xiaogang Cui 629b67847e coresight: add attr to show the logical cpu number
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>
2014-07-10 11:28:54 +08:00
Xiaogang Cui e2845b570b coresight: fix the resource ctrl setting in etmv4
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>
2014-07-10 08:49:07 +08:00
Linux Build Service Account 379b290626 Merge "coresight: free sg table in case of memory alloc failure" 2014-07-08 01:05:32 -07:00
Sarangdhar Joshi 4f8b79b1bf coresight: free sg table in case of memory alloc failure
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>
2014-07-07 17:38:56 -07:00
Aparna Das f783462757 coresight: add memory dump v2 support for etmv4
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>
2014-06-30 13:52:01 -07:00