1
0
Fork 0
Commit Graph

150 Commits (redonkable)

Author SHA1 Message Date
Richard Zhu 7697c3f6f0 MLK-20446 rpmsg: imx: only use the timeout by the first notify
To make sure that the message wound't be discarded when
M4 is running normally or in the suspend mode. Only use
the timeout mechanism by the first notify when the vdev
is registered.

Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com>
(cherry picked from commit aaf42a6c2c224aa9bd88b13abcf8f848f2eab073)
2018-11-23 11:06:01 +08:00
Richard Zhu 797008e87e MLK-19864 rpmsg: imx: fix the kernel panic during tty rpmsg demo
Fix the kernel panic during tty rpmsg str echo demo.
Root cause: The driver name may be flushed.
Use the kasprintf to setup the rpmsg tty driver name to
fix this issue.
[   35.494361] Unable to handle kernel paging request at virtual address
ffff000021b4ba40
[   35.502321] Mem abort info:
[   35.505117]   Exception class = DABT (current EL), IL = 32 bits
[   35.511099]   SET = 0, FnV = 0
[   35.514188]   EA = 0, S1PTW = 0
[   35.517328] Data abort info:
[   35.520255]   ISV = 0, ISS = 0x00000007
[   35.524130]   CM = 0, WnR = 0
[   35.527140] swapper pgtable: 4k pages, 48-bit VAs, pgd =
ffff0000096dd000
[   35.533964] [ffff000021b4ba40] *pgd=000000097fffe803,
*pud=000000097fffd803, *pmd=0000000973d20003, *pte=0000000000000000
[   35.544976] Internal error: Oops: 96000007 [#1] PREEMPT SMP
[   35.550553] Modules linked in: imx_rpmsg_tty
[   35.554843] CPU: 2 PID: 3911 Comm: sh Not tainted
4.14.62-05098-gcff652e-dirty #41
[   35.562419] Hardware name: Freescale i.MX8QM MEK (DT)
[   35.567479] task: ffff8008f3950000 task.stack: ffff000021b10000
[   35.573413] PC is at string+0x28/0x98
[   35.577080] LR is at vsnprintf+0x3c0/0x688
[   35.581177] pc : [<ffff000008d5f1a0>] lr : [<ffff000008d61c70>]
pstate: a0000145
[   35.588577] sp : ffff000021b13970
[   35.591894] x29: ffff000021b13970 x28: ffff80097365f56f
[   35.597219] x27: ffff0000092cf03a x26: ffff0000092cf03a
[   35.602544] x25: ffff000021b13a80 x24: ffff8008f365f570
[   35.607869] x23: 00000000ffffffd8 x22: ffff000008fc08dc
[   35.613195] x21: 000000007fffffff x20: ffff000008fc08cc
[   35.618512] x19: ffff8008f365f570 x18: 0000000000000000
[   35.623827] x17: 0000ffffbec93588 x16: ffff00000820b2c0
[   35.629144] x15: 0000000000000000 x14: ffffffffffffffff
[   35.634461] x13: 0000000000000018 x12: 0101010101010101
[   35.639777] x11: 0000000000000000 x10: ffff000021b13a80
[   35.645085] x9 : ffff000021b13a80 x8 : ffff000021b13a80
[   35.650402] x7 : ffff8008f365f570 x6 : fffffffffffffffe
[   35.655718] x5 : 00000000ffffffd0 x4 : ffff000021b4ba40
[   35.661035] x3 : ffff0a00ffffff04 x2 : ffff80097365f56f
[   35.666354] x1 : ffff80097365f56f x0 : ffffffffffffffff
[   35.671672] Process sh (pid: 3911, stack limit = 0xffff000021b10000)
[   35.678022] Call trace:
[   35.680465] Exception stack(0xffff000021b13830 to 0xffff000021b13970)
[   35.686911] 3820:                                   ffffffffffffffff
ffff80097365f56f
[   35.694748] 3840: ffff80097365f56f ffff0a00ffffff04 ffff000021b4ba40
00000000ffffffd0
[   35.702581] 3860: fffffffffffffffe ffff8008f365f570 ffff000021b13a80
ffff000021b13a80
[   35.710409] 3880: ffff000021b13a80 0000000000000000 0101010101010101
0000000000000018
[   35.718245] 38a0: ffffffffffffffff 0000000000000000 ffff00000820b2c0
0000ffffbec93588
[   35.726081] 38c0: 0000000000000000 ffff8008f365f570 ffff000008fc08cc
000000007fffffff
[   35.733908] 38e0: ffff000008fc08dc 00000000ffffffd8 ffff8008f365f570
ffff000021b13a80
[   35.741744] 3900: ffff0000092cf03a ffff0000092cf03a ffff80097365f56f
ffff000021b13970
[   35.749583] 3920: ffff000008d61c70 ffff000021b13970 ffff000008d5f1a0
00000000a0000145
[   35.757417] 3940: ffff8008fff5fb00 0000000000001c00 0000ffffffffffff
ffff000008d61930
[   35.765254] 3960: ffff000021b13970 ffff000008d5f1a0
[   35.770129] [<ffff000008d5f1a0>] string+0x28/0x98
[   35.774837] [<ffff000008d61c70>] vsnprintf+0x3c0/0x688
[   35.779980] [<ffff000008d620e4>] sprintf+0x4c/0x58

Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com>
Reviewed-by: Fugang Duan <fugang.duan@nxp.com>
2018-10-29 11:10:38 +08:00
Richard Zhu 76bc2c5c62 MLK-19588-1 imx: rpmsg: use timeout for MU_SendMessage function
- Add the timeout mu msg send api.
- Use the timeout mu send message function to do the
notification when multi-vdev is enabled on one channel.

Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com>
2018-10-29 11:10:38 +08:00
Richard Zhu 0421359b30 MLK-18660-4 rpmsg: imx: add the pm ops
Add the power management operations into imx
rpmsg driver.

Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com>
2018-10-29 11:10:38 +08:00
Robin Gong 46220b58fa MLK-18308-1: rpmsg: imx_rpmsg: initialize spinlock before using
Initialize spinlock before using, otherwise the below oops triggered if
CONFIG_DEBUG_SPINLOCK enabled.

BUG: spinlock bad magic on CPU#0, kthreadd/2
 lock: imx_rpmsg_vprocs+0x1240/0x24a0, .magic: 00000000, .owner: <none>/-1, .ow0
CPU: 0 PID: 2 Comm: kthreadd Not tainted 4.9.88-04946-gf984c92 #324
Hardware name: Freescale i.MX7ULP (Device Tree)
[<8010ea64>] (unwind_backtrace) from [<8010b184>] (show_stack+0x10/0x14)
[<8010b184>] (show_stack) from [<803c3a8c>] (dump_stack+0x78/0x8c)
[<803c3a8c>] (dump_stack) from [<8016a744>] (do_raw_spin_lock+0xc4/0x120)
[<8016a744>] (do_raw_spin_lock) from [<809f7448>] (_raw_spin_lock_irqsave+0x20/)
[<809f7448>] (_raw_spin_lock_irqsave) from [<807bcdc8>] (imx_mu_rpmsg_isr+0x38/)
[<807bcdc8>] (imx_mu_rpmsg_isr) from [<801722d8>] (__handle_irq_event_percpu+0x)
[<801722d8>] (__handle_irq_event_percpu) from [<8017237c>] (handle_irq_event_pe)
[<8017237c>] (handle_irq_event_percpu) from [<801723f0>] (handle_irq_event+0x38)
[<801723f0>] (handle_irq_event) from [<801757f4>] (handle_fasteoi_irq+0xd0/0x1a)
[<801757f4>] (handle_fasteoi_irq) from [<80171594>] (generic_handle_irq+0x24/0x)
[<80171594>] (generic_handle_irq) from [<80171abc>] (__handle_domain_irq+0x7c/0)
[<80171abc>] (__handle_domain_irq) from [<801014e8>] (gic_handle_irq+0x48/0x8c)
[<801014e8>] (gic_handle_irq) from [<8010bb8c>] (__irq_svc+0x6c/0xa8)

Signed-off-by: Robin Gong <yibin.gong@nxp.com>
2018-10-29 11:10:38 +08:00
Anup Patel 61822724a1 MLK-18113: rpmsg: virtio_rpmsg_bus: fix rpmsg_probe() for virtio-mmio transport
This patch was cherry picked from
https://patchwork.kernel.org/patch/10155143/

When virtio-rpmsg device is provided via virtio-mmio transport, the
dma_alloc_coherent() (called by rpmsg_probe()) fails on ARM/ARM64
systems because "vdev->dev.parent->parent" device is used as parameter
to dma_alloc_coherent().

The "vdev->dev.parent->parent" device represents underlying remoteproc
platform device when virtio-rpmsg device is provided via
virtio-remoteproc
transport. When virtio-rpmsg device is provided via virtio-mmio
transport,
the "vdev->dev.parent->parent" device represents the parent device of
virtio-mmio platform device and dma_alloc_coherent() fails for this
device
because generally there is no corresponding platform device and dma_ops
are not setup for "vdev->dev.parent->parent".

This patch fixes dma_alloc_coherent() usage in rpmsg_probe() by trying
dma_alloc_coherent() with "vdev->dev.parent" device when it fails with
"vdev->dev.parent->parent" device.

Fixes: b5ab5e24e9 ("remoteproc: maintain a generic child device for

Signed-off-by: Anup Patel <anup@brainfault.org>
Signed-off-by: Adriana Reus <adriana.reus@nxp.com>
2018-10-29 11:10:38 +08:00
Fugang Duan 14eecf0006 MLK-17837-01 input: misc: rpmsg_input: add rpmsg virtual sensor driver
NXP i.MX7ULP EVK boards all sensors connect with M4 core, A core
has to conmunicate with sensors by virtual io bus like rpmsg bus.
The driver implement the virtual sensor input driver to configure
sensors active/idle/delay actions and report the sensors' event to
user space.

Supply below sysfs for user to enable/disable detector and counter,
set poll delay:
	/sys/class/misc/step_counter/enable
	/sys/class/misc/step_detector/enable
	/sys/class/misc/step_counter/poll_delay

Reviewed-by: Elven Wang <elven.wang@nxp.com>
Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
2018-10-29 11:10:38 +08:00
Richard Zhu 7297a35987 MLK-16595 rpmsg: imx: enable multi-core string demo
Because that there are two M4 cores on iMX8QM.
Enable the multi-core string echo support.

BuildInfo:
- SCFW a6fd9a48, IMX-MKIMAGE 0, ATF 0
- U-Boot 2017.03-imx_v2017.03_4.9.11_imx8_alpha+g258936c

Reviewed-by: Frank Li <frank.li@nxp.com>
Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com>
2018-10-29 11:10:38 +08:00
Richard Zhu 5c502621b1 MLK-16586-3 rpmsg: imx: enable multi-core rpmsg
- Init multi-core mu power and clk.
- enable the multi-core rpmsg support

BuildInfo:
- SCFW a6fd9a48, IMX-MKIMAGE 0, ATF 0
- U-Boot 2017.03-imx_v2017.03_4.9.11_imx8_alpha+g258936c

Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com>
Reviewed-by: Robin Gong <yibin.gong@nxp.com>
Tested-by: Andy Duan <fugang.duan@nxp.com>
2018-10-29 11:10:38 +08:00
Fugang Duan 715e587619 MLK-16564-01 gpio: imx-rpmsg: add rpmsg virtual gpio driver
Add rpmsg virtual gpio driver support.
i.MX7ULP GPIO PTA and PTB resource are managed by M4 core, setup one
simple protocol with M4 core based on RPMSG virtual IO to let A core
access such GPIOs that is what the driver do.

Reviewed-by: Richard Zhu <hongxing.zhu@nxp.com>
Reviewed-by: Robin Gong <yibin.gong@nxp.com>
Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
2018-10-29 11:10:38 +08:00
Richard Zhu e9d2a097c7 MLK-16530-3 rpmsg: imx: init mu and limit the pingpong cycles
- Init mu power and clk.
- Change the cycles of the pingpong demot refer to
the limitation of M4 side.
When the received data larger than 100, the
pingpong of M4 side would be finished.
BuildInfo: SCFW 9e9f6ec6, IMX-MKIMAGE 0, ATF 0

Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com>
2018-10-29 11:10:38 +08:00
Richard Zhu 2e0540391e MLK-16371-2 rpmsg: imx: add the rpmsg for imx8qxp
Add rpmsg support for imx8qxp.
The pingpong demo had been verified on 8qxp platforms.
Use memset_io replace memset, because that
the memory type of rpvq->addr is strong order type.
There would be kernel dump when memset is used
on imx8qxp.

Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com>
2018-10-29 11:10:38 +08:00
Frank Li 8fb853fed5 MLK-16114: RPMSG: Fixed ulp can't boot after e12586
Need call MU_Init before call other function

Signed-off-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Shenwei Wang <shenwei.wang@nxp.com>
2018-10-29 11:10:38 +08:00
Octavian Purdila acd81841bf MLK-14659 rpmsg: imx: tty: restore support for imx7d
Commit 2a596c353234 ("MLK-13981-2 rpmsg: imx: enable rpmsg virt tty")
enabled support for imx7ulp but it broke support for imx7d since the
currently distributed M4 image for imx7d still uses the old
"rpmsg-openamp-demo-channel" naming.

While we could change the channel name in the M4 image it is better to
maintain backwards compatibility, so add the old naming back to the id
table.

Signed-off-by: Octavian Purdila <octavian.purdila@nxp.com>
2018-10-29 11:10:38 +08:00
Robin Gong 64a1bb9125 MLK-14619 input: keyboard: rpmsg-keys: add rpmsg-keys driver
Add rpmsg-keys driver on i.mx7ulp-evk board since vol+/vol- keys
are connected on m4 side and have to get the status of keys by
rpmsg.

Signed-off-by: Robin Gong <yibin.gong@nxp.com>
[Irina: updated for 4.9 APIs]
Signed-off-by: Irina Tirdea <irina.tirdea@nxp.com>
2018-10-29 11:10:38 +08:00
Richard Zhu 0b2659775b MLK-14487-2 rpmsg: imx: validate the rpmsg on imx7ulp
- add the .data into the imx_rpmsg_dt_ids table, thus
the driver can distinguish the different platforms.

Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com>
Tested-by: Daniel Baluta <daniel.baluta@nxp.com>
2018-10-29 11:10:38 +08:00
Richard Zhu 4c92752d09 MLK-14487-1 rpmsg: imx: validate the rpmsg on imx7ulp
- change the module_init to subsys_initcall.
Otherwise, the pf1550-rpmsg would be invoked before
the rpmsg bus driver on imx7ulp.
Then, sdhc wouldn't be powered up properly if pf1550
isn't functional.
- remove the no longer used imc_rpmsg_exit.
- pass the real device id if the shared irq is requested.

Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com>
Tested-by: Daniel Baluta <daniel.baluta@nxp.com>
2018-10-29 11:10:38 +08:00
Richard Zhu b45749f61a MLK-14439-3 rpmsg: imx: setup the imx rpmsg driver
- move imx_rpmsg from arch/arm/ to drivers/rpmsg.
- use the new MU generic APIs in the rpmsg implementation.
- Validated the pingpong test on both imx6sx and imx7d sdb boards.

Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com>
2018-10-29 11:10:38 +08:00
Richard Zhu 41f1ce523e MLK-13981-2 rpmsg: imx: enable rpmsg virt tty
Message can be transferred between remote
device and iMX7ULP M4.
Then the message can be transferred between A7
and M4 by rpmsg channel.
demo howto:
- insmode the imx_rpmsg_tty.ko module after
login A7/Linux.
- Receive messages. Used the following command
to dump out the msg from the virtual tty.
./unit_tests/mxc_mcc_tty_test.out /dev/ttyRPMSG 115200 R 100 1000 &
- Send: use the following command to send the
message to M4.
echo <your string message> /dev/ttyRPMSG

Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com>
2018-10-29 11:10:38 +08:00
Richard Zhu 8d9ab3fae3 MLK-12265 rpmsg: imx: set the imx rpmsg tests be module
Set the imx rpmsg tests to be module in defaut.

Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com>
(cherry picked from commit 20adce35ef6abfd6b0a52207febe069c7f09a1be)
2018-10-29 11:10:38 +08:00
Richard Zhu 1580c375a7 MLK-11498 rpmsg: imx: tell remote process about the channel
send a message to our remote processor, and tell remote
processor about this channel

Signed-off-by: Richard Zhu <Richard.Zhu@freescale.com>
(cherry picked from commit 2708c004a60c5b6da020803ee9291b83984d4a65)
2018-10-29 11:10:38 +08:00
Richard Zhu 21570a0ed7 MLK-11286-3 rpmsg: imx: enable rpmsg tests on imx
enable the rpmsg pingpong and tty string echo tests
on imx amp socs
- pingpong test howto
insmod imx_rpmsg_pingpong.ko

- tty string echo test howto
  - step 1, load the imx_rpmsg_tty.ko
  insmod imx_rpmsg_tty.ko
  - step 2, lanunch the mxc_mcc_tty_test.out in backend
  ./mxc_mcc_tty_test.out /dev/ttyRPMSG 115200 R 512 512 &
  - step 3, issue the echo command
  echo <string> > /dev/ttyRPMSG

Signed-off-by: Richard Zhu <Richard.Zhu@freescale.com>
2018-10-29 11:10:38 +08:00
Greg Kroah-Hartman 13d216167d Revert "rpmsg: core: add support to power domains for devices"
This reverts commit 1ed3a93072 which is
commit fe782affd0 upstream

Rafael reports that this patch causes problems:
	> -rc2 looks good. There is a problem on dragonboard during boot that was
	> introduced in v4.14.71 that I didn't notice last week. We'll bisect it
	> and report back later this week. dragonboard on the other branches (4.9,
	> 4.18, mainline) looks fine.

	As Dan pointed out, during validation, we have bisected this issue on
	a dragonboard 410c (can't find root device) to the following commit
	for v4.14:

	[1ed3a93072] rpmsg: core: add support to power domains for devices

	There is an on-going discussion on "[PATCH] rpmsg: core: add support
	to power domains for devices" about this patch having other
	dependencies and breaking something else on v4.14 as well.

so drop it.

Reported-by: Rafael Tinoco <rafael.tinoco@linaro.org>
Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
Cc: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-29 03:06:04 -07:00
Srinivas Kandagatla 1ed3a93072 rpmsg: core: add support to power domains for devices
[ Upstream commit fe782affd0 ]

Some of the rpmsg devices need to switch on power domains to communicate
with remote processor. For example on Qualcomm DB820c platform LPASS
power domain needs to switched on for any kind of audio services.
This patch adds the missing power domain support in rpmsg core.

Without this patch attempting to play audio via QDSP on DB820c would
reboot the system.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-19 22:43:41 +02:00
Srinivas Kandagatla db04f92b65 rpmsg: smd: do not use mananged resources for endpoints and channels
commit 4a2e84c6ed upstream.

All the managed resources would be freed by the time release function
is invoked. Handling such memory in qcom_smd_edge_release() would do
bad things.

Found this issue while testing Audio usecase where the dsp is started up
and shutdown in a loop.

This patch fixes this issue by using simple kzalloc for allocating
channel->name and channel which is then freed in qcom_smd_edge_release().

Without this patch restarting a remoteproc would crash the system.
Fixes: 53e2822e56 ("rpmsg: Introduce Qualcomm SMD backend")
Cc: <stable@vger.kernel.org>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-03 11:24:59 +02:00
Ramon Fried d803d94a3f rpmsg: added MODULE_ALIAS for rpmsg_char
[ Upstream commit 93dd4e73c0 ]

Added "rpmsg:rpmsg_chrdev" MODULE_ALIAS to autoload
rpmg_chrdev module automatically.

Signed-off-by: Ramon Fried <rfried@codeaurora.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-21 04:02:48 +09:00
Arun Kumar Neelakantam 81309f8b9b rpmsg: glink: Initialize the "intent_req_comp" completion variable
[ Upstream commit 2394facb17 ]

The "intent_req_comp" variable is used without initialization which
results in NULL pointer dereference in qcom_glink_request_intent().

we need to initialize the completion variable before using it.

Fixes: 27b9c5b66b ("rpmsg: glink: Request for intents when unavailable")
Signed-off-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-20 10:10:29 +01:00
Bjorn Andersson 99bff8f6d1 rpmsg: glink: Add missing MODULE_LICENSE
commit 1e0d5615bb upstream.

The qcom_glink_native driver is missing a MODULE_LICENSE(), correct
this.

Fixes: 835764ddd9 ("rpmsg: glink: Move the common glink protocol implementation to glink_native.c")
Reported-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-21 09:49:23 +01:00
Greg Kroah-Hartman b24413180f License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.

By default all files without license information are under the default
license of the kernel, which is GPL version 2.

Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier.  The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.

This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.

How this work was done:

Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
 - file had no licensing information it it.
 - file was a */uapi/* one with no licensing information in it,
 - file was a */uapi/* one with existing licensing information,

Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.

The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne.  Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.

The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed.  Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.

Criteria used to select files for SPDX license identifier tagging was:
 - Files considered eligible had to be source code files.
 - Make and config files were included as candidates if they contained >5
   lines of source
 - File already had some variant of a license header in it (even if <5
   lines).

All documentation files were explicitly excluded.

The following heuristics were used to determine which SPDX license
identifiers to apply.

 - when both scanners couldn't find any license traces, file was
   considered to have no license information in it, and the top level
   COPYING file license applied.

   For non */uapi/* files that summary was:

   SPDX license identifier                            # files
   ---------------------------------------------------|-------
   GPL-2.0                                              11139

   and resulted in the first patch in this series.

   If that file was a */uapi/* path one, it was "GPL-2.0 WITH
   Linux-syscall-note" otherwise it was "GPL-2.0".  Results of that was:

   SPDX license identifier                            # files
   ---------------------------------------------------|-------
   GPL-2.0 WITH Linux-syscall-note                        930

   and resulted in the second patch in this series.

 - if a file had some form of licensing information in it, and was one
   of the */uapi/* ones, it was denoted with the Linux-syscall-note if
   any GPL family license was found in the file or had no licensing in
   it (per prior point).  Results summary:

   SPDX license identifier                            # files
   ---------------------------------------------------|------
   GPL-2.0 WITH Linux-syscall-note                       270
   GPL-2.0+ WITH Linux-syscall-note                      169
   ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause)    21
   ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)    17
   LGPL-2.1+ WITH Linux-syscall-note                      15
   GPL-1.0+ WITH Linux-syscall-note                       14
   ((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause)    5
   LGPL-2.0+ WITH Linux-syscall-note                       4
   LGPL-2.1 WITH Linux-syscall-note                        3
   ((GPL-2.0 WITH Linux-syscall-note) OR MIT)              3
   ((GPL-2.0 WITH Linux-syscall-note) AND MIT)             1

   and that resulted in the third patch in this series.

 - when the two scanners agreed on the detected license(s), that became
   the concluded license(s).

 - when there was disagreement between the two scanners (one detected a
   license but the other didn't, or they both detected different
   licenses) a manual inspection of the file occurred.

 - In most cases a manual inspection of the information in the file
   resulted in a clear resolution of the license that should apply (and
   which scanner probably needed to revisit its heuristics).

 - When it was not immediately clear, the license identifier was
   confirmed with lawyers working with the Linux Foundation.

 - If there was any question as to the appropriate license identifier,
   the file was flagged for further research and to be revisited later
   in time.

In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.

Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights.  The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.

Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.

In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.

Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
 - a full scancode scan run, collecting the matched texts, detected
   license ids and scores
 - reviewing anything where there was a license detected (about 500+
   files) to ensure that the applied SPDX license was correct
 - reviewing anything where there was no detection but the patch license
   was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
   SPDX license was correct

This produced a worksheet with 20 files needing minor correction.  This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.

These .csv files were then reviewed by Greg.  Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected.  This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.)  Finally Greg ran the script using the .csv files to
generate the patches.

Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-02 11:10:55 +01:00
Dan Carpenter b775d15853 rpmsg: glink: Fix memory leak in qcom_glink_alloc_intent()
We need to free "intent" and "intent->data" on a couple error paths.

Fixes: 933b45da5d ("rpmsg: glink: Add support for TX intents")
Acked-by: Sricharan R <sricharan@codeaurora.org>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-10-10 11:22:09 -07:00
Dan Carpenter 0a7480bd32 rpmsg: glink: Unlock on error in qcom_glink_request_intent()
If qcom_glink_tx() fails, then we need to unlock before returning the
error code.

Fixes: 27b9c5b66b ("rpmsg: glink: Request for intents when unavailable")
Acked-by: Sricharan R <sricharan@codeaurora.org>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-10-10 11:22:09 -07:00
Colin Ian King ed43d098f9 rpmsg: glink: initialize ret to zero to ensure error status check is correct
The new switch cases for RPM_CMD_RX_DONE, RPM_CMD_RX_DONE_W_REUSE,
RPM_CMD_RX_INTENT_REQ_ACK, RPM_CMD_INTENT and RPM_CMD_RX_INTENT_REQ from
4 recent commits are not setting ret and so a later non-zero check on ret
is testing on a garbage value in ret. Fix this by initializing ret to zero.

Detected by CoverityScan CID#1455249 ("Uninitialized scalar variable")

Fixes: 933b45da5d ("rpmsg: glink: Add support for TX intents)
Fixes: dacbb35e93 ("glink: Receive and store the remote intent buffers")
Fixes: 27b9c5b66b ("rpmsg: glink: Request for intents when unavailable")
Fixes: 88c6060f5a ("rpmsg: glink: Handle remote rx done command")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-09-04 10:52:30 -07:00
Colin Ian King 906cf29cfa rpmsg: glink: fix null pointer dereference on a null intent
In the case where glink->intentless is true and the call
to qcom_glink_tx fails then we have a condition where ret is
non-zero and intent is null, causing a null pointer deference
when setting intent->in_use to false.  Add an extra check to
only dereference intent if intent is non-null.

Detected by: CoverityScan CID#1455247 ("Explicit null dereferenced")

Fixes: 88c6060f5a ("rpmsg: glink: Handle remote rx done command")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-09-04 10:51:49 -07:00
Bjorn Andersson f8ff9777ec rpmsg: glink: Export symbols from common code
The common code needs to export the probe and remove symbols in order
for the SMEM and RPM drivers to access them when compiled as a module.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-08-31 17:10:40 -07:00
Bjorn Andersson 5f5423ffa2 rpmsg: glink: Release idr lock before returning on error
The idr_lock should be released in the case that we don't find the given
channel.

Fixes: 44f6df922a ("rpmsg: glink: Fix idr_lock from mutex to spinlock")
Reported-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-08-30 16:26:23 -07:00
Sricharan R 88c6060f5a rpmsg: glink: Handle remote rx done command
Once the remote side sends a rx done ack, check for the intent reuse
information from it and suitably discard or reuse the remote passed
intent buffers.

Acked-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
Signed-off-by: Sricharan R <sricharan@codeaurora.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-08-29 20:34:16 -07:00
Sricharan R 27b9c5b66b rpmsg: glink: Request for intents when unavailable
While sending data, we search for suitable sized intent to map and
simply fail if a intent is not found. Instead request for a intent of
required size and wait till one is alloted.

Acked-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
Signed-off-by: Sricharan R <sricharan@codeaurora.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-08-29 20:34:15 -07:00
Sricharan R 11cb45a7f8 rpmsg: glink: Use the intents passed by remote
While sending data, use the remote intent id buffer of suitable size
that was passed by remote previously.

Acked-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
Signed-off-by: Sricharan R <sricharan@codeaurora.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-08-29 20:34:15 -07:00
Sricharan R dacbb35e93 rpmsg: glink: Receive and store the remote intent buffers
Just like we allocating and sending intent ids to remote, remote side
allocates and sends us the intents as well.  So save the intent ids and
use it later while sending data targeting the appropriate intents based
on the size.

Acked-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
Signed-off-by: Sricharan R <sricharan@codeaurora.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-08-29 20:34:15 -07:00
Sricharan R 6bf68cbdf7 rpmsg: glink: Add announce_create ops and preallocate intents
Preallocate local intent buffers and pass the intent ids to the remote.
This way there are some default intents available  for the remote to
start sending data without having to wait by sending intent requests. Do
this by adding the rpmsg announce_create ops, which gets called right
after the rpmsg device gets probed.

Acked-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
Signed-off-by: Sricharan R <sricharan@codeaurora.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-08-29 20:34:14 -07:00
Sricharan R 1d2ea36eea rpmsg: glink: Add rx done command
Send RX data receive ack to remote and also inform that local intent
buffer is used and freed. This informs the remote to request for next
set of intent buffers before doing a send operation.

Acked-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
Signed-off-by: Sricharan R <sricharan@codeaurora.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-08-29 20:34:14 -07:00
Bjorn Andersson b88eee975a rpmsg: glink: Make RX FIFO peak accessor to take an offset
To fully read the received rx data from FIFO both the command and data
has to be read. Currently we read command, data separately and process
them. By adding an offset parameter to RX FIFO peak accessor, command
and data can be read together, simplifying things.  So introduce this.

Acked-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
Signed-off-by: Sricharan R <sricharan@codeaurora.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-08-29 20:34:13 -07:00
Sricharan R 64f95f8792 rpmsg: glink: Use the local intents when receiving data
So previously on request from remote side, we allocated local intent
buffers and passed the ids to the remote. Now when we receive data
buffers from remote directed to that intent id, copy the data to the
corresponding preallocated intent buffer.

Acked-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
Signed-off-by: Sricharan R <sricharan@codeaurora.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-08-29 20:34:13 -07:00
Sricharan R 933b45da5d rpmsg: glink: Add support for TX intents
Intents are nothing but pre-allocated buffers of appropriate size that
are allocated on the local side and communicated to the remote side and
the remote stores the list of intent ids that it is informed.

Later when remote side is intenting to send data, it picks up a right
intent (based on the size) and sends the data buffer and the intent id.
Local side receives the data and copies it to the local intent buffer.

The whole idea is to avoid stalls on the transport for allocating
memory, used for copy based transports.

When the remote request to allocate buffers using CMD_RX_INTENT_REQ, we
allocate buffers of requested size, store the buffer id locally and also
communicate the intent id to the remote.

Acked-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
Signed-off-by: Sricharan R <sricharan@codeaurora.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-08-29 20:34:13 -07:00
Sricharan R 44f6df922a rpmsg: glink: Fix idr_lock from mutex to spinlock
The channel members lcids, rcids synchronised using the idr_lock is
accessed in both atomic/non-atomic contexts. The readers are not
currently synchronised.  That no correct, so add the readers as well
under the lock and use a spinlock.

Acked-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
Signed-off-by: Sricharan R <sricharan@codeaurora.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-08-29 20:34:12 -07:00
Sricharan R d31ad615f6 rpmsg: glink: Add support for transport version negotiation
G-link supports a version number and feature flags for each transport.
A combination of the version number and feature flags enable/disable:

 (*) G-Link software updates for each edge
 (*) Individual features for each edge

Endpoints negotiate both the version and the supported flags when
the transport is opened and they cannot be changed after negotiation has
been completed.

Each full implementation of G-Link must support a minimum of the current
version, the previous version, and the base negotiation version called v0.

Acked-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
Signed-off-by: Sricharan R <sricharan@codeaurora.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-08-29 20:34:12 -07:00
Bjorn Andersson caf989c350 rpmsg: glink: Introduce glink smem based transport
The glink protocol supports different types of transports (shared
memory). With the core protocol remaining the same, the way the
transport's memory is probed and accessed is different. So add support
for glink's smem based transports.

Adding a new smem transport register function and the fifo accessors for
the same.

Acked-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
Signed-off-by: Sricharan R <sricharan@codeaurora.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-08-29 20:33:57 -07:00
Sricharan R 76cf110514 rpmsg: glink: Do a mbox_free_channel in remove
mbox_request_channel is done in probe, so free the channel in remove.

Acked-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
Signed-off-by: Sricharan R <sricharan@codeaurora.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-08-29 14:29:33 -07:00
Sricharan R a7df9dfcfd rpmsg: glink: Return -EAGAIN when there is no FIFO space
The TX FIFO can be full, if the remote client has not read enough data
(or) reading it slowly. So its nessecary to return -EAGAIN to the local
client to enable retry.

Acked-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
Signed-off-by: Sricharan R <sricharan@codeaurora.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-08-29 14:29:33 -07:00
Bjorn Andersson 7339859da8 rpmsg: glink: Allow unaligned data access
Glink protocol requires that each message is aligned on a 8 byte offset.
This is purely a restriction from glink, so in order to support clients
which do not adher to this, allow data packets of any size, but align
the head index accordingly, effectively removing the alignment
restriction.

Acked-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
Signed-off-by: Sricharan R <sricharan@codeaurora.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-08-29 14:29:33 -07:00