Commit Graph

62 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
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
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
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
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
Jack Pham 8c9c7eb18f usb: bam: Return usb_pipe_mem_type from get_bam2bam_connection_info()
Some functions may need to know the pipe memory type, whether it
is allocated memory or a private region of internal peripheral
memory. Add an extra parameter to the get_bam2bam_connection_info()
function to return this value based on the preconfigured BAM pipes.

For most functions this info is unneeded. For QDSS, use this value
to determine whether to pass MSM_INTERNAL_MEM to the SPS params
when running on a device that requires it.

Change-Id: Ia9f5630b08a90cb66489a11707919d1855c36ec9
Signed-off-by: Jack Pham <jackp@codeaurora.org>
2014-06-09 00:32:28 -07:00
Pratik Patel 94bec8c5bc coresight: stop copying etf contents when buffer size is reached
Currently we read the TMC ETF contents and copy them to DDR until
the end marker is seen. If for some reason HW doesn't provide the
end marker, this can result in memory corruption since the code
will end up in an infinite loop that keeps copying contents
beyond the TMC ETF buffer.

Add an additional check to stop copying TMC ETF contents to DDR
when buffer size is reached even if end marker is not seen due to
a potential HW misbehavior.

CRs-Fixed: 671604
Change-Id: I5a6ec1231371737b8e8c368ded75f5e73ac66095
Signed-off-by: Pratik Patel <pratikp@codeaurora.org>
2014-05-28 17:47:31 -07:00
Aparna Das dbfa7047b9 coresight: change magic number for memory dump v2
Memory dump v2 format uses magic number that is different from
what is used with earlier version. Add support for this change
so that the TMC ramdump can be correctly parsed.

Change-Id: Ib7f5478812e59a44c609fc433e8c742fe30488a9
Signed-off-by: Aparna Das <adas@codeaurora.org>
2014-04-16 09:47:07 -07:00
Xiaogang Cui 9f4d99f364 coresight: change flush input from pre_ares to flush_etr
Change flush input signal from pre_ares to flush_etr. For ETF
to be consistent with the usage model for both ETF and ETR.
Remove property reset-flush-race which is a workaround for
MSM8974v1.

Change-Id: I077f5215e75024e484abb3b68d67372ae6ccd154
Signed-off-by: Xiaogang Cui <xiaogang@codeaurora.org>
2014-04-09 11:23:48 +08:00
Sarangdhar Joshi b0ffec3d7d coresight: add support for byte counter for scatter gather feature
Byte counter interrupt feature provides an interface to set byte counter
value and collect continuous trace data stream from userspace. Add support
to read this trace data stream when scatter gather feature is enabled for
TMC ETR configuration.

Change-Id: Ic755b7ae14b4bf13f7f28897ec8827476366eaf7
Signed-off-by: Sarangdhar Joshi <spjoshi@codeaurora.org>
2014-03-28 18:02:17 -07:00
Sarangdhar Joshi fd7c7fc302 coresight: add driver support for scatter gather feature
Add driver support to enable scatter-gather feature with TMC configuration.
Scatter gather option for ETR DDR mode supports the use of a table of
locations of 4K blocks of physical memory. Since this memory is not
necessarily contiguous, user can increase the trace buffer size as long as
DDR memory is available.

Default memory option is "contig" for TMC ETR DDR configuration. User can
enable scatter gather feature dynamically.

Change-Id: I74136fb86fe751aa33607d3922dce5d572f0a4a2
Signed-off-by: Sarangdhar Joshi <spjoshi@codeaurora.org>
2014-03-26 18:13:14 -07:00
Sarangdhar Joshi 2365442aa8 coresight: enable scatter gather feature based on dt entry
Based on sg-enable DT entry, enable scatter gather feature
for TMC ETR configuration. Scatter gather feature is not supported
on all targets. sg-enable entry will help to enable this feature
only on those targets which supports this feature.

Change-Id: I66fe50c653ad9646104b9dc0d77a0fa6f82503dd
Signed-off-by: Sarangdhar Joshi <spjoshi@codeaurora.org>
2014-03-24 10:52:01 -07:00
Linux Build Service Account 13807cea1a Merge "coresight: use dev_err_ratelimited for byte counter overflow message" 2014-03-15 10:09:18 -07:00
Linux Build Service Account eaf32dcae4 Merge "coresight: add device attribute for etr ddr mem type" 2014-03-15 10:08:52 -07:00
Sarang Joshi 9094a9bf20 coresight: add device attribute for etr ddr mem type
Add device attribute for memory type option with TMC ETR DDR configuration.
This is in preparation for scatter gather feature with TMC ETR
configuration.

Change-Id: If72078f89442e9c58e09392fbced362126dd15e7
Signed-off-by: Sarang Joshi <spjoshi@codeaurora.org>
2014-03-13 17:14:03 -07:00
Pratik Patel 689346a4bf soc: qcom: memory_dump_v2: add client support for memory dump v2
Add client support to register with the memory dump v2 driver to
take advantage of the new enhanced memory dump format.

Change-Id: I8b05d92b3e9f4d1dcaa6dffec8fe05401d72a7ee
Signed-off-by: Pratik Patel <pratikp@codeaurora.org>
2014-03-13 14:29:05 -07:00
Pratik Patel 1ec292845e soc: qcom: memory_dump: cleanup in preparation for memory dump v2
General cleanup to avoid global name space clashes. This is in
preparation for the memory dump v2 driver.

Change-Id: I884ff3a06c74166dc0cd9004085ab9b43646ef6a
Signed-off-by: Pratik Patel <pratikp@codeaurora.org>
2014-03-13 14:29:05 -07:00
Sarang Joshi a748e7052d coresight: use dev_err_ratelimited for byte counter overflow message
When byte counter feature is enabled, if the rate at which we receive IRQs
is so high that userspace is unable to read the data fast enough, we
throw byte counter overflow error message. However these messages can cause
log spew resulting in watchdog bark/bite. Limit byte counter overflow
message spew by using rate limited function.

Change-Id: I714323893330368965f70a137aaef7ef7cd4029d
Signed-off-by: Sarang Joshi <spjoshi@codeaurora.org>
2014-03-12 15:27:40 -07:00
Sujeet Kumar 2d9e27fa48 USB: usb_bam: Change the bam handle to ulong
Change the bam handle data type from u32 to
unsigned long to match sps connect source
and destination.

Change-Id: I55ce477a40e4ab3d1306f8afd1acf491c22874e9
Signed-off-by: Sujeet Kumar <ksujeet@codeaurora.org>
2014-03-08 05:22:15 +05:30
Sarang Joshi b155399efd coresight: allocate etr ddr memory dynamically
Dynamically allocate ETR DDR memory so that user can specify
trace buffer size at runtime.

Change-Id: I081b017fa147d7c87789cc504cd9b61b7365c79f
Signed-off-by: Sarang Joshi <spjoshi@codeaurora.org>
2014-02-28 13:09:09 -08:00
Linux Build Service Account 59acb37c59 Merge "coresight: add device attribute for etr ddr mem size" 2014-02-26 21:28:12 -08:00
Sujeet Kumar af110c4d33 USB: mach: Move the mach headers to common location
As part of moving the headers from mach directory
to a common location compilation issues are arising.

Make the changes which are relevant for USB with
its own header files and also dependent header
files.

Change-Id: Ieef7d04ffdfda249f434e0676fec6da8d8b9cf2c
Signed-off-by: Sujeet Kumar <ksujeet@codeaurora.org>
2014-02-25 05:53:32 +05:30
Sarang Joshi 441ff248c2 coresight: add device attribute for etr ddr mem size
Add device attribute to control ETR DDR memory size dynamically
for TMC configuration. This will help users to specify DDR trace
buffer size at runtime.

Change-Id: Ie1edef7f972435193c96dafb8a94fd6cce97ce6c
Signed-off-by: Sarang Joshi <spjoshi@codeaurora.org>
2014-02-18 23:27:02 -08:00
Linux Build Service Account 0791dcb389 Merge "msm: memory_dump: move memory dump driver to drivers/soc/qcom" 2014-02-07 23:19:41 -08:00
Xiaogang Cui cd76c0793d msm: memory_dump: move memory dump driver to drivers/soc/qcom
Architectural changes in the ARM Linux kernel tree mandate
the eventual removal of the mach-* directories. Move the
memory dump driver to drivers/soc/qcom and the memory dump header
to include/soc/qcom to support that removal.

Change-Id: If04f6a4fcd30c864321ac0ff8c6691fc20707cc1
Signed-off-by: Xiaogang Cui <xiaogang@codeaurora.org>
Signed-off-by: Aparna Das <adas@codeaurora.org>
2014-02-05 18:32:30 -08:00
Dipen Parmar 7f918cb5c7 msm: sps: remove sps header file
Remove the sps header file from older location as sps
driver and clients need to use new header file from
new location include/linux.

Resolve the warnings/errors from client drivers due to
new sps header changes.

Change-Id: I1cdb87756abf3425a9bb5d8bf89cd1aa03a01716
Signed-off-by: Dipen Parmar <dipenp@codeaurora.org>
2014-02-05 15:31:11 -08:00
Xiaogang Cui c4bad5cccc coresight: Fix compile errors for gcc-4.8
Fix compilation errors to support gcc-4.8

There is compilation warnning when use '%d" to print a argument
which type is size_t.

In file included from kernel/include/linux/kernel.h:14:0,
	from kernel/drivers/coresight/coresight-tmc.c:13:
kernel/drivers/coresight/coresight-tmc.c: In function 'tmc_read':
kernel/include/linux/dynamic_debug.h:64:16: warning:
	format '%d' expects argument of type 'int', but argument 5 has type
	'size_t' [-Wformat=] error, forbidden warning: dynamic_debug.h:64

Change format '%d' to '%zu' to fix this compilation error

Change-Id: Ia746033b76df7f06e860031ed8d3e249facbe2b5
Signed-off-by: Xiaogang Cui <xiaogang@codeaurora.org>
2014-02-05 09:33:47 -08:00
Aparna Das 6f78c21df0 coresight: remove request for memory reservation using export_compat
The TMC driver now uses dma_alloc_coherent api to allocate contiguous
memory instead of allocate_contiguous_ebi when configured for ETR. This
eliminates the need for EXPORT_COMPAT support in the TMC driver.

Change-Id: I79550d2ff490c02329e4b860b8aa8816d4890d50
Signed-off-by: Aparna Das <adas@codeaurora.org>
2014-02-03 14:49:04 -08:00
Sarang Joshi 2d5f553dc4 coresight: take lock before modifying byte cntr value
Byte counter overflow is computed based on byte counter value during
byte counter start routine. Two different threads running in parallel
can cause synchronization issue where one thread modifies overflow
based on byte counter value and other thread modifies byte counter
value at the same time. Take respective lock before setting byte
counter value.

Change-Id: I923a34bf918abe4d5e3b0d30ed4887a38db6f427
Signed-off-by: Sarang Joshi <spjoshi@codeaurora.org>
2013-12-17 15:08:49 -08:00
Pratik Patel 2d85f9a856 coresight: initialize waitqueue before devm_request_irq
Initialize waitqueue before devm_request_irq to make static
analysis tools happy.

Change-Id: Iec85520453a4191a6e2e2abb0d4db8dc27b11533
Signed-off-by: Pratik Patel <pratikp@codeaurora.org>
2013-12-02 15:18:46 -08:00
Pratik Patel 12f1c666d5 coresight: fix error checks for byte counter init code
Fix error checks for byte counter initialization functions that
are called during probe to avoid null pointer accesses.

CRs-Fixed: 562303
Change-Id: I8f7de6fc4b0658cf649e472d12a00ea5733a8b0a
Signed-off-by: Pratik Patel <pratikp@codeaurora.org>
2013-10-23 17:34:51 -07:00
Pratik Patel 234885a545 coresight: use no log version of readl while dumping etf
During kernel panic, coresight_abort is first called to stop
tracing to the default ETF (circular buffer mode) sink. This is
followed by stopping RTB as part of the panic handler.

Use no log version of readl while dumping ETF in circular buffer
mode to avoid polluting RTB logs with readls responsible for
dumping ETF during kernel panic.

Change-Id: I282516be458c8b38af20cb372803cdff9eb9e8f0
Signed-off-by: Pratik Patel <pratikp@codeaurora.org>
2013-09-04 17:23:11 -07:00
Aparna Das 878e4c2b2b coresight: use dma_alloc_coherent for allocating tmc-etr memory
The CoreSight TMC driver when configured for ETR requires uncached
memory in RAM to which it routes trace data. In order to allocate
this memory replace existing allocate_contiguous_ebi api with
dma_alloc_coherent api which is the linux standard of allocating
memory.

Change-Id: I59f88009f2abed95fd9b81ea92a7d484b9d6b833
Signed-off-by: Aparna Das <adas@codeaurora.org>
2013-09-04 17:21:50 -07:00
Pratik Patel 126b76f777 coresight: enable flush-on-flushin for periodic flush to usb
Periodic flushing for ETR to USB uses ETR flush-on-FLUSHIN
external input. Hence, enable flush-on-FLUSHIN by default when
enabling ETR to USB transfers and work around the manual flush
failure by skipping it during ETR to USB disable. Adjust the
periodic flush threshold to the maximum value in order to
reduce the overhead when there is no data to be transferred.

CRs-Fixed: 461885
Change-Id: Ie3a1bbc80e017f187af56fcfdfb52297ba9aa72d
Signed-off-by: Pratik Patel <pratikp@codeaurora.org>
2013-09-04 17:21:38 -07:00
Pushkar Joshi 0d311f9f8d coresight: add lpae support for coresight tmc driver
Modify the CoreSight TMC driver for LPAE so that it can support
ETR physical addresses greater than 32 bits when LPAE is enabled.

Change-Id: I6db2c98c4db70262ab45f7ff11fe2a6846259f8a
Signed-off-by: Pushkar Joshi <pushkarj@codeaurora.org>
2013-09-04 17:21:05 -07:00
Pushkar Joshi 652e5255d4 coresight: disable byte counter if byte counter initialization fails
The byte counter feature is enabled only if all the components it relies
on can be succesfully enabled.

Change-Id: I09e9b78c21af66d8cfc7c94d286f5b61adb7f7d6
Signed-off-by: Pushkar Joshi <pushkarj@codeaurora.org>
2013-09-04 17:19:11 -07:00
Pushkar Joshi 73389e5ed3 coresight: perform byte counter value check only for non-zero values
A check for the byte counter interrupt value being such that it
divides the memory reserved into equal size blocks is necessary
only when a non-zero value is specified.

Change-Id: I424c09322f2ee82917359d871f0916b3fb50b0be
Signed-off-by: Pushkar Joshi <pushkarj@codeaurora.org>
2013-09-04 17:17:25 -07:00
Pushkar Joshi 0c95f352e5 coresight: Add support for byte counter interrupt feature
The CoreSight block can produce an interrupt on transfer of
programmed number of bytes to ETR-memory. Use this feature
to provide an interface to manage the byte counter value and
to collect a continuous data stream from userspace.

Change-Id: Ic00c9b19483be566d0f05005936b4a6ff7ab52f1
Signed-off-by: Pushkar Joshi <pushkarj@codeaurora.org>
2013-09-04 17:12:34 -07:00
Pratik Patel 108dc514ac coresight: add coresight fuse state query
Add support to query CoreSight fuse state and fail the probe
if any of the required fuse(s) are disabled. This enables
a single image with CoreSight drivers compiled in to be run on
both Hardware that has CoreSight functionality disabled via fuse
or left enabled for use.

Change-Id: Ib770cc7f76e2b0644bda9600c92fc3a26823452d
Signed-off-by: Pratik Patel <pratikp@codeaurora.org>
2013-09-04 17:06:21 -07:00
Pratik Patel 51d355115b coresight: use trigin 2 for cti reset trigger for tmc-etr
Flush ETR is mapped to TRIGIN[2] and so switch to using it in
order to cause a CTI trigger for TMC-ETR flush during wdog reset.

This avoids any race between TMC-ETR flush to memory and DDR
being put into self-refresh.

CRs-Fixed: 491986
Change-Id: Ia5e643121e040bd9c57c89a4b762b794bc8ddf62
Signed-off-by: Pratik Patel <pratikp@codeaurora.org>
2013-09-04 16:54:28 -07:00
Aparna Das 23a951523e coresight: modify coresight drivers to use reg-names property
Modify coresight drivers to perform resource lookup by name. The
coresight drivers now use the reg-names property specified in dt
nodes to lookup for resources.

Change-Id: I986f9687be81706d2424e288b9875c3a93e12d11
Signed-off-by: Aparna Das <adas@codeaurora.org>
2013-09-04 16:13:53 -07:00
Shimrit Malichi 78ea2d8b19 usb: usb_bam: Add support for multi USB BAMs
This change add the support for activating more than
one usb core in the system in bam to bam mode.
Potentially, we can have up to three usb cores in
the system: HSUSB, HSIC and DWC3.
This change simplify the USB BAM driver design, such that
we can easily define bam to bam paths for more than one usb
core concurrently with flexible peer BAMs configuration.

Change-Id: Ie5acb68f29e30cb6c14d2afd957ac8e21cc7beba
Signed-off-by: Shimrit Malichi <smalichi@codeaurora.org>
2013-09-04 16:09:29 -07:00
Pratik Patel 06d43e8c44 coresight: disable tmc-etr to bam traffic during coresight abort
Add support for disabling TMC-ETR to USB BAM traffic (which can be
safely done in atomic context) as part of coresight_abort when
TMC-ETR-usb is the current sink.

Change-Id: I13f8989b3807cda89f81144a38be429ddaeb3d76
Signed-off-by: Pratik Patel <pratikp@codeaurora.org>
2013-09-04 16:03:42 -07:00
Pratik Patel 3dec2bd30c coresight: enable & disable flush on wdog reset using cti for tmc-etr
Program TMC-ETR to stop on flush by default and dynamically
enable flush on watchdog reset using CTI when TMC-ETR-mem is
enabled and disable flush on watchdog reset when TMC-ETR-mem is
disabled.

This will help flush out pending data when a crash causes a
watchdog reset ensuring that most recent data gets captured in
the TMC-ETR-mem.

The need to dynamically enable and disable flush on watchdog
reset based on current sink state arises from ARM recommendation
to have CTI flush enabled only for one sink at a time.

CRs-Fixed: 455170
Change-Id: If780fe4709098b74860d4b32ab2d151e861cf10d
Signed-off-by: Pratik Patel <pratikp@codeaurora.org>
2013-09-04 16:03:41 -07:00
Pratik Patel 714032754c coresight: enable & disable flush on wdog reset using cti for tmc-etf
Program TMC-ETF to stop on flush by default and dynamically
enable flush on watchdog reset using CTI when TMC-ETF (in circular
buffer mode) is enabled and disable flush on watchdog reset when
TMC-ETF (in circular buffer mode) is disabled.

This will help flush out pending data when a crash causes a
watchdog reset ensuring that most recent data gets captured in
the TMC-ETF.

The need to dynamically enable and disable flush on watchdog
reset based on current sink state arises from ARM recommendation
to have CTI flush enabled only for one sink at a time.

Change-Id: Ib1a57122802e335da776c008da20da68e8527b00
Signed-off-by: Pratik Patel <pratikp@codeaurora.org>
2013-09-04 16:03:09 -07:00
Pratik Patel 49c4e95b90 coresight: implement new tmc etr to usb flush procedure
Recommended ETR to usb flush procedure changed. This implements
the new recommended procedure.

CRs-Fixed: 443106
Change-Id: I18a6d457686905cbee75ce081ee4c6b4f6fdc62c
Signed-off-by: Pratik Patel <pratikp@codeaurora.org>
2013-09-04 15:55:07 -07:00