Commit Graph

99 Commits

Author SHA1 Message Date
Thierry Reding
0fe88461a0 mailbox: Add Tegra HSP driver
This driver exposes a mailbox interface for interprocessor communication
using the Hardware Synchronization Primitives (HSP) module's doorbell
mechanism. There are multiple HSP instances and they provide additional
features such as shared mailboxes, shared and arbitrated semaphores.

A driver for a remote processor can use the mailbox client provided by
the HSP driver and build an IPC protocol on top of this synchronization
mechanism.

Based on work by Joseph Lo <josephl@nvidia.com>.

Acked-by: Jassi Brar <jaswinder.singh@linaro.org>
Signed-off-by: Thierry Reding <treding@nvidia.com>
2016-11-18 14:26:13 +01:00
Linus Torvalds
c6594fc6af Merge branch 'mailbox-for-next' of git://git.linaro.org/landing-teams/working/fujitsu/integration
Pull mailbox updates from Jussi Brar:
 "New driver and DT bindings for MHU controller integrated on Amlogic
  Meson platform"

* 'mailbox-for-next' of git://git.linaro.org/landing-teams/working/fujitsu/integration:
  dt-bindings: mailbox: Add Amlogic Meson MHU Bindings
  mailbox: Add Platform Message-Handling-Unit variant driver
2016-10-06 17:36:53 -07:00
Rafael J. Wysocki
0d573c6a01 Merge branches 'acpi-x86', 'acpi-cppc' and 'acpi-soc'
* acpi-x86:
  x86: ACPI: make variable names clearer in acpi_parse_madt_lapic_entries()
  x86: ACPI: remove extraneous white space after semicolon

* acpi-cppc:
  ACPI / CPPC: Support PCC with interrupt flag
  ACPI / CPPC: Add prefix cppc to cpudata structure name
  ACPI / CPPC: Add support for functional fixed hardware address
  ACPI / CPPC: Don't return on CPPC probe failure
  ACPI / CPPC: Allow build with ACPI_CPU_FREQ_PSS config
  ACPI / CPPC: check for error bit in PCC status field
  ACPI / CPPC: move all PCC related information into pcc_data
  ACPI / CPPC: add sysfs support to compute delivered performance
  ACPI / CPPC: set a non-zero value for transition_latency
  ACPI / CPPC: support for batching CPPC requests
  ACPI / CPPC: acquire pcc_lock only while accessing PCC subspace
  ACPI / CPPC: restructure read/writes for efficient sys mapped reg ops
  mailbox: pcc: Support HW-Reduced Communication Subspace type 2

* acpi-soc:
  ACPI / APD: constify local structures
  ACPI / APD: Add device HID for Vulcan SPI controller
2016-10-02 01:39:09 +02:00
Neil Armstrong
ad3a212c1d mailbox: Add Platform Message-Handling-Unit variant driver
Add Message-Handling-Unit driver for platform variants as mailbox controller.
Actually, only the Amlogic Meson GXBB SoC MHU is supported.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
2016-09-07 13:07:17 +05:30
hotran
aca314efb1 mailbox: pcc: Support HW-Reduced Communication Subspace type 2
ACPI 6.1 has a PCC HW-Reduced Communication Subspace type 2 intended for
use on HW-Reduce ACPI Platform, which requires read-modify-write sequence
to acknowledge doorbell interrupt. This patch provides the implementation
for the Communication Subspace Type 2.

Signed-off-by: Hoan Tran <hotran@apm.com>
Reviewed-by: Prashanth Prakash <pprakash@codeaurora.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2016-08-31 00:37:20 +02:00
Baoyou Xie
a75e4a85f4 fix📫bcm-pdc-mailbox:mark symbols static where possible
We get 2 warnings when biuld kernel with W=1:
drivers/mailbox/bcm-pdc-mailbox.c:472:6: warning: no previous prototype for 'pdc_setup_debugfs' [-Wmissing-prototypes]
drivers/mailbox/bcm-pdc-mailbox.c:488:6: warning: no previous prototype for 'pdc_free_debugfs' [-Wmissing-prototypes]

In fact, these functions are only used in the file in which they are
declared and don't need a declaration, but can be made static.
so this patch marks these functions with 'static'.

Signed-off-by: Baoyou Xie <baoyou.xie@linaro.org>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
2016-08-29 18:43:39 +05:30
Dan Carpenter
068cf29eca mailbox: bcm-pdc: potential NULL dereference in pdc_shutdown()
We can't pass NULL pointers to pdc_ring_free() so I moved the check for
NULL.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
2016-08-29 18:41:15 +05:30
Rob Rice
e0c6fba45a mailbox: Add HAS_DMA Kconfig dependency to BCM_PDC_MBOX
Add HAS_DMA Kconfig dependency to BCM_PDC_MBOX to avoid link
error on some platforms.

Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Rob Rice <rrice@broadcom.com>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
2016-08-29 18:39:46 +05:30
Rob Rice
a68b216676 mailbox: Fix format and type mismatches in Broadcom PDC driver
Fix format and type mismatches in a couple debug prints in the
Broadcom PDC driver. Use %pad for dma_addr_t and %pa for
resource_size_t.

Signed-off-by: Rob Rice <rob.rice@broadcom.com>
Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
2016-07-28 21:27:31 +05:30
Rob Rice
a24532f8d1 mailbox: Add Broadcom PDC mailbox driver
The Broadcom PDC mailbox driver is a mailbox controller that
manages data transfers to and from one or more offload engines.

Signed-off-by: Rob Rice <rob.rice@broadcom.com>
Reviewed-by: Scott Branden <scott.branden@broadcom.com>
Reviewed-by: Ray Jui <ray.jui@broadcom.com>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
2016-07-28 09:34:47 +05:30
Ben Dooks
9ac3e85a5c mailbox: pl320: remove __raw IO
The use of __raw IO accesors is not endian safe and should be used
sparingly. The relaxed variants should be as lightweight and also
are endian safe.

Note, this has not been run-time tested.

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
2016-06-24 13:32:31 +05:30
Sudeep Holla
9ef3c51121 mailbox: mailbox-test: set tdev->signal to NULL after freeing
tdev->signal is not set NULL after it's freed. This will cause random
exceptions when the stale pointer is accessed after tdev->signal is
freed. Also, since tdev->signal allocation is skipped the next time
it's written, this leads to continuous fault finally leading to the
total death of the system.

Fixes: d1c2f87c9a ("mailbox: mailbox-test: Prevent memory leak")
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
2016-06-12 15:13:04 +05:30
Amitoj Kaur Chawla
c430cf376f mailbox: Fix devm_ioremap_resource error detection code
devm_ioremap_resource returns an ERR_PTR value, not NULL,
on failure.

The Coccinelle semantic patch used to make this change is
as follows:
@@
expression e,e1;
statement S;
@@

*e = devm_ioremap_resource(...);
if (!e1) S

Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
2016-05-08 22:44:46 +05:30
Suman Anna
dd28216528 mailbox/omap: kill omap_mbox_{save/restore}_ctx() functions
The omap_mbox_save_ctx() and omap_mbox_restore_ctx() API were
previously provided to OMAP mailbox clients to save and restore
the mailbox context during system suspend/resume. The save and
restore functionality is now implemented through System PM driver
callbacks, and there is no need for these functions, so kill these
API.

Signed-off-by: Suman Anna <s-anna@ti.com>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
2016-04-26 10:19:38 +05:30
Suman Anna
9f0cee984a mailbox/omap: check for any unread messages during suspend
The OMAP mailbox driver is used by clients to communicate with remote
processors in general. The mailbox clients are expected to have stopped
communicating with these remote processors during a system suspend. The
OMAP mailbox fifos are expected to not have any messages as such. Add a
check for any pending unprocessed messages in the suspend callback, to
detect any communication protocol issues of the mailbox clients. The
system suspend is aborted if any messages are found.

Signed-off-by: Suman Anna <s-anna@ti.com>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
2016-04-26 10:19:38 +05:30
Suman Anna
af1d2f5cb9 mailbox/omap: add support for suspend/resume
Support has been added to the OMAP mailbox driver to allow it
to work across a system suspend/resume. The OMAP mailbox driver
requires only the interrupt configuration registers to be saved
and restored, and this is done in the suspend/resume callbacks.
The registers need to be saved only if there are active clients
at the time of suspend. The enabling and disabling of the mailbox
clocks is done automatically by the omap_device layer.

Signed-off-by: Suman Anna <s-anna@ti.com>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
2016-04-26 10:19:38 +05:30
Suman Anna
2240f8aefc mailbox/omap: store mailbox interrupt type in omap_mbox_device
The interrupt type used for identifying the layout of the interrupt
configuration registers between OMAP4+ SoCs and older SoCs is stored
only in the sub-mailbox structures for easier access. Store this type
in the the omap_mbox_device structure as well along with the other
global variables. This is being done to facilitate the context save
and restore of appropriate registers during system suspend/resume.

Signed-off-by: Suman Anna <s-anna@ti.com>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
2016-04-26 10:19:38 +05:30
Suman Anna
2665a4c1d4 mailbox/omap: add blank lines after declarations
Fix couple of checkpatch warnings of the type,
"WARNING: Missing a blank line after declarations"

Also, fixed a warning about a space after a typecast
while at this.

Signed-off-by: Suman Anna <s-anna@ti.com>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
2016-04-26 10:19:37 +05:30
Suman Anna
0196fa3945 mailbox/omap: remove FSF mailing address paragraph
Remove the paragraph about writing to the Free Software
Foundation's mailing address from the GPL license header
as this address can change. This fixes the corresponding
checkpatch warning.

Signed-off-by: Suman Anna <s-anna@ti.com>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
2016-04-26 10:19:37 +05:30
Suman Anna
86f6f5e2e2 mailbox/omap: use variable name for sizeof() operator
Fix the code formatting to use the kernel preferred style
of using the actual variables to determize the size using
the sizeof() operator. This fixes the corresponding checkpatch
warning as well.

Signed-off-by: Suman Anna <s-anna@ti.com>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
2016-04-26 10:19:37 +05:30
Suman Anna
4899f78a3d mailbox/omap: drop legacy platform device support
OMAP mailbox devices can no longer be created in legacy non-DT
mode, all the relevant code has been cleaned up. The OMAP mailbox
driver will only support devices created from DT going forward,
so drop the legacy platform device support from the driver.

Signed-off-by: Suman Anna <s-anna@ti.com>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
2016-04-26 10:19:37 +05:30
Linus Torvalds
a7109a2ca7 Merge branch 'mailbox-devel' of git://git.linaro.org/landing-teams/working/fujitsu/integration
Pull mailbox fixes from Jussi Brar:
 "Misc fixes:

  mailbox-test driver:
   - prevent memory leak and another cosmetic change

  mailbox:
   - change the returned error code

  Xgene driver:
   - return -ENOMEM instead of PTR_ERR for failed devm_kzalloc"

* 'mailbox-devel' of git://git.linaro.org/landing-teams/working/fujitsu/integration:
  mailbox: Stop using ENOSYS for anything other than unimplemented syscalls
  mailbox: mailbox-test: Prevent memory leak
  mailbox: mailbox-test: Use more consistent format for calling copy_from_user()
  mailbox: xgene-slimpro: Fix wrong test for devm_kzalloc
2016-04-14 18:40:47 -07:00
Lee Jones
0c44d7896c mailbox: Stop using ENOSYS for anything other than unimplemented syscalls
In accordance with e15f431fe2 ("errno.h: Improve ENOSYS's comment") and
91c9afaf97 ("checkpatch.pl: new instances of ENOSYS are errors") we're
converting from the old meaning of: ENOSYS "Function not implemented" to
a more standard EINVAL.

Reported-by: Seraphin Bonnaffe <seraphin.bonnaffe@st.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
2016-04-12 13:28:32 +05:30
Lee Jones
d1c2f87c9a mailbox: mailbox-test: Prevent memory leak
If we set the Signal twice or more, without using it as part of a message,
memory will be re-allocated and the pointer over-written.  Prevent this
potential leak by only allocating memory when there isn't any already.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
2016-04-12 13:28:30 +05:30
Lee Jones
17f5f28ffa mailbox: mailbox-test: Use more consistent format for calling copy_from_user()
While we're at it, ensure copy-to location is NULL'ed in the error path.

Suggested-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
2016-04-12 13:28:20 +05:30
Rafael J. Wysocki
fa81e66ec8 Merge branches 'pm-cpufreq', 'pm-cpuidle' and 'acpi-cppc'
* pm-cpufreq:
  cpufreq: dt: Drop stale comment
  cpufreq: intel_pstate: Documenation for structures
  cpufreq: intel_pstate: fix inconsistency in setting policy limits
  intel_pstate: Avoid extra invocation of intel_pstate_sample()
  intel_pstate: Do not set utilization update hook too early

* pm-cpuidle:
  intel_idle: Add KBL support
  intel_idle: Add SKX support
  intel_idle: Clean up all registered devices on exit.
  intel_idle: Propagate hot plug errors.
  intel_idle: Don't overreact to a cpuidle registration failure.
  intel_idle: Setup the timer broadcast only on successful driver load.
  intel_idle: Avoid a double free of the per-CPU data.
  intel_idle: Fix dangling registration on error path.
  intel_idle: Fix deallocation order on the driver exit path.
  intel_idle: Remove redundant initialization calls.
  intel_idle: Fix a helper function's return value.
  intel_idle: remove useless return from void function.

* acpi-cppc:
  mailbox: pcc: Don't access an unmapped memory address space
2016-04-08 21:46:05 +02:00
Axel Lin
a61b37ead5 mailbox: xgene-slimpro: Fix wrong test for devm_kzalloc
devm_kzalloc() returns NULL on failure.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
2016-04-08 09:30:11 +05:30
Shanker Donthineni
169b38373f mailbox: pcc: Don't access an unmapped memory address space
The acpi_pcc_probe() may end up accessing memory outside of the PCCT
table space causing the kernel panic(). Increment the pcct_entry
pointer after parsing 'HW-reduced Communications Subspace' to fix
the problem. This change also enables the parsing of subtable at
index 0.

Signed-off-by: Shanker Donthineni <shankerd@codeaurora.org>
Acked-by: Ashwin Chaugule <ashwin.chaugule@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2016-04-07 01:25:28 +02:00
Linus Torvalds
988faa7312 Merge branch 'mailbox-for-next' of git://git.linaro.org/landing-teams/working/fujitsu/integration
Pull more mailbox updates from Jassi Brar:
 "Device tree bindings and driver for TI's Message-Manager controller.

  Due to some last minute cosmetic changes, the driver was not included
  in the first pull request, otherwise the driver has been reviewed
  twice"

* 'mailbox-for-next' of git://git.linaro.org/landing-teams/working/fujitsu/integration:
  mailbox: Introduce TI message manager driver
  Documentation: dt: mailbox: Add TI Message Manager
2016-03-23 06:09:15 -07:00
Nishanth Menon
aace66b170 mailbox: Introduce TI message manager driver
Support for TI Message Manager Module. This hardware block manages a
bunch of hardware queues meant for communication between processor
entities.

Clients sitting on top of this would manage the required protocol
for communicating with the counterpart entities.

For more details on TI Message Manager hardware block, see documentation
that will is available here: http://www.ti.com/lit/ug/spruhy8/spruhy8.pdf
Chapter 8.1(Message Manager)

Signed-off-by: Nishanth Menon <nm@ti.com>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
2016-03-21 20:33:15 +05:30
Linus Torvalds
2b2f72d8ce Merge branch 'mailbox-for-next' of git://git.linaro.org/landing-teams/working/fujitsu/integration
Pull mailbox updates from Jassi Brar:

 - mailbox bindings and drivers for
     * APM X-Gene
     * Hisilicon Hi6220
     * Rockchip RK3368
   platforms

 - minor fixes to the above three drivers.

 - misc cleanups of mailbox-test driver.

* 'mailbox-for-next' of git://git.linaro.org/landing-teams/working/fujitsu/integration:
  mailbox: rockchip: avoid 64-bit division
  mailbox: rockchip: Add Rockchip mailbox driver
  dt-bindings: rockchip-mailbox: Add mailbox controller document on Rockchip SoCs
  mailbox/xgene-slimpro: Checking for IS_ERR instead of NULL
  mailbox: Hi6220: add mailbox driver
  dt-bindings: mailbox: Document Hi6220 mailbox driver
  mailbox: mailbox-test: add support for separate tx/rx buffer with single channel
  mailbox: mailbox-test: use print_hex_dump_bytes to allow dynamic printk
  mailbox: mailbox-test: fix the compatible string
  mailbox: mailbox-test: rename driver as generic test driver
  Documentation: mailbox: Add APM X-Gene SLIMpro mailbox dts documentation
  mailbox: Add support for APM X-Gene platform mailbox driver
2016-03-20 12:58:32 -07:00
Arnd Bergmann
c5a9d1f30c mailbox: rockchip: avoid 64-bit division
The newly added rockchip mailbox driver causes a bug in
the ARM allyesconfig build because of a division of a resource_size_t
variable that may be 64 bit wide:

drivers/mailbox/built-in.o: In function `rockchip_mbox_probe':
:(.text+0x6614): undefined reference to `__aeabi_uldivmod'

This adds a cast to size_t, which turns it into a 32-bit division
in this case. This is safe because we know that we cannot possibly
map a resource that is longer than what a pointer contains, and
in practice it will be very short instead.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
2016-03-16 09:18:15 +05:30
Rafael J. Wysocki
6a8ccb1dfd Merge branches 'acpi-processor' and 'acpi-cppc'
* acpi-processor:
  ACPI / sleep: move acpi_processor_sleep to sleep.c
  ACPI / processor : add support for ACPI0010 processor container
  ACPI / processor_idle: replace PREFIX with pr_fmt

* acpi-cppc:
  ACPI / CPPC: use MRTT/MPAR to decide if/when a req can be sent
  ACPI / CPPC: replace writeX/readX to PCC with relaxed version
  mailbox: pcc: optimized pcc_send_data
  ACPI / CPPC: optimized cpc_read and cpc_write
  ACPI / CPPC: Optimize PCC Read Write operations
2016-03-14 14:20:33 +01:00
Caesar Wang
f70ed3b5dc mailbox: rockchip: Add Rockchip mailbox driver
This driver is found on RK3368 SoCs.

The Mailbox module is a simple APB peripheral that allows both
the Cortex-A53 MCU system to communicate by writing operation to
generate interrupt.
The registers are accessible by both CPU via APB interface.

The Mailbox has the following main features:

1) Support dual-core system: Cortex-A53 and MCU.
2) Support APB interface.
3) Support four mailbox elements, each element includes one data word,
   one command word register and one flag bit that can represent
   one interrupt.
4) Four interrupts to Cortex-A53.
5) Four interrupts to MCU.
6) Provide 32 lock registers for software to use to indicate whether
   mailbox is occupied.

[Jassi: Removed unused variable buf_base]

Signed-off-by: Caesar Wang <wxt@rock-chips.com>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
2016-03-11 10:40:06 +07:00
Prakash, Prashanth
8b0f578898 mailbox: pcc: optimized pcc_send_data
pcc_send_data() can be invoked during the execution of performance
critical code as in cppc_cpufreq driver. With acpi_* APIs, the
doorbell register accessed in pcc_send_data() if present in system
memory will be searched (in cached virt to phys addr mapping),
mapped, read/written and then unmapped. These operations take
significant amount of time.

This patch maps the performance critical doorbell register
during init and then reads/writes to it directly using the
mapped virtual address. This patch + similar changes to CPPC
acpi driver reduce the time per freq. transition from around
200us to about 20us for the CPPC cpufreq driver

Signed-off-by: Prashanth Prakash <pprakash@codeaurora.org>
Acked-by: Ashwin Chaugule <ashwin.chaugule@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2016-03-09 23:35:29 +01:00
Dan Carpenter
14d653af4e mailbox/xgene-slimpro: Checking for IS_ERR instead of NULL
devm_ioremap() returns NULL, it never returns an ERR_PTR.

Fixes: f700e84f41 ('mailbox: Add support for APM X-Gene platform mailbox driver')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
2016-03-04 12:32:20 +05:30
Leo Yan
9c384189f5 mailbox: Hi6220: add mailbox driver
Add driver for Hi6220 mailbox, the mailbox communicates with MCU; for
sending data, it can support two methods for low level implementation:
one is to use interrupt as acknowledge, another is automatic mode which
without any acknowledge. These two methods have been supported in the
driver. For receiving data, it will depend on the interrupt to notify
the channel has incoming message.

Now mailbox driver is used to send message to MCU to control dynamic
voltage and frequency scaling for CPU, GPU and DDR.

Signed-off-by: Leo Yan <leo.yan@linaro.org>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
2016-03-04 12:32:20 +05:30
Sudeep Holla
2d74ffdc91 mailbox: mailbox-test: add support for separate tx/rx buffer with single channel
This patch adds support for different MMIO region for Tx and Rx paths.
If only one region is specified, it's assumed to be shared between Rx
and Tx, thereby retaining backward compatibility.

Also in order to support single channel dealing with both Tx and Rx with
dedicated MMIO regions, Tx channel itself is assigned to Rx if MMIO
regions are different and Rx is not specified.

Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
2016-03-04 12:32:19 +05:30
Sudeep Holla
27fa680f7f mailbox: mailbox-test: use print_hex_dump_bytes to allow dynamic printk
Reduce the logging from info to debug. Also use print_hex_dump_bytes
instead as it has support for dynamic printk providing options to
conditionally enable/disable these logs.

Cc: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
2016-03-04 12:32:19 +05:30
Sudeep Holla
c428013783 mailbox: mailbox-test: fix the compatible string
Underscores are usually forbidden in the compatible strings. So lets
remove it before the first users of this is seen.

Acked-by: Rob Herring <robh@kernel.org>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
2016-03-04 12:32:18 +05:30
Sudeep Holla
adf06ba9b3 mailbox: mailbox-test: rename driver as generic test driver
This mailbox-test driver was designed to be generic, so let's remove ST
tag on it and make it generic.

Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
2016-03-04 12:32:13 +05:30
Duc Dang
f700e84f41 mailbox: Add support for APM X-Gene platform mailbox driver
X-Gene mailbox controller provides 8 mailbox channels, with
each channel has a dedicated interrupt line.

Signed-off-by: Feng Kan <fkan@apm.com>
Signed-off-by: Duc Dang <dhdang@apm.com>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
2016-02-15 13:20:03 +05:30
Richard Weinberger
65d3b04a81 mailbox: Fix dependencies for !HAS_IOMEM archs
Not every arch has io memory.
So, unbreak the build by fixing the dependencies.

Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
2016-02-02 16:47:14 +05:30
Alexey Klimov
e9c8dc8ba9 mailbox: pcc: fix channel calculation in get_pcc_channel()
This patch fixes the calculation of pcc_chan for non-zero id.
After the compiler ignores the (unsigned long) cast the
pcc_mbox_channels pointer is type-cast and then the type-cast
offset is added which results in address outside of the range
leading to the kernel crashing.

We might add braces and make it:

pcc_chan = (struct mbox_chan *)
		((unsigned long) pcc_mbox_channels +
		(id * sizeof(*pcc_chan)));

but let's go with array approach here and use id as index.

Tested on Juno board.

Signed-off-by: Alexey Klimov <alexey.klimov@arm.com>
Acked-by: Sudeep Holla <sudeep.holla@arm.com>
Acked-by: Ashwin Chaugule <ashwin.chaugule@linaro.org>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
2016-02-02 16:39:13 +05:30
Julia Lawall
bfbcfa770b mailbox: constify mbox_chan_ops structure
This mbox_chan_ops structure is never modified, so declare it as const,
like all the other mbox_chan_ops structures.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
2015-11-30 21:12:05 +05:30
Jassi Brar
cb1ca0b3bb mailbox: mailbox-test: avoid reading iomem twice
Don't pass mmio region as source to print_hex_dump() and then
again to memcpy_fromio(). Do it once and give print_hex_dump()
the buffer we just read the data in.

Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
2015-11-04 14:03:04 +05:30
Dan Carpenter
c3ac54a6f5 mailbox: Off by one in mbox_test_message_read()
We need to leave space for the NUL char.

Fixes: 8ea4484d0c ('mailbox: Add generic mechanism for testing Mailbox Controllers')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
2015-10-27 21:27:25 +05:30
Dave Gerlach
8e3c595214 mailbox/omap: Add ti,mbox-send-noirq quirk to fix AM33xx CPU Idle
The mailbox framework controls the transmission queue and requires
either its controller implementations or clients to run the state
machine for the Tx queue. The OMAP mailbox controller uses a Tx-ready
interrupt as the equivalent of a Tx-done interrupt to run this Tx
queue state-machine.

The WkupM3 processor on AM33xx and AM43xx SoCs is used to offload
certain PM tasks, like doing the necessary operations for Device
PM suspend/resume or for entering lower c-states during cpuidle.

The CPUIdle on AM33xx requires the messages to be sent without
having to trigger the Tx-ready interrupts, as the interrupt
would immediately terminate the CPUIdle operation. Support for
this has been added by introducing a DT quirk, "ti,mbox-send-noirq"
and using it to modify the normal OMAP mailbox controller behavior
on the sub-mailboxes used to communicate with the WkupM3 remote
processor. This also requires the wkup_m3_ipc driver to adjust
its mailbox usage logic to run the Tx state machine.

NOTE:
- AM43xx does not communicate with WkupM3 for CPU Idle, so is
  not affected by this behavior. But, it uses the same IPC driver
  for PM suspend/resume functionality, so requires the quirk as
  well, because of changes to the common wkup_m3_ipc driver.

Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
[s-anna@ti.com: revise logic and update comments/patch description]
Signed-off-by: Suman Anna <s-anna@ti.com>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
2015-10-23 11:19:27 +05:30
Lee Jones
a133f8b65d mailbox: mailbox-test: Correctly repair Sparse warnings
Kbuild test robot reported some Sparse warnings to the tune of:

  sparse: incorrect type in argument 6 (different address spaces)
    expected void const *buf
    got void [noderef] <asn:2>*mmio

This was due to passing variables tagged with the Sparse cookie
'__iomem' through into memcpy() and print_hex_dump() without
adequate protection or casting.  These issues were fixed in a
previous patch suppressing the warnings, but the issue is indeed
still present.

This patch fixes the warnings in the correct way, i.e. by using
the purposely authored memcpy_{from,to}io() derivatives in the
memcpy() case and casting the memory address to (void *) and
forcing Sparse to ignore to ignore it in the print_hex_dump()
case [NB: This is also what the memcpy() derivatives do].

Reported-by: Peter Griffin <peter.griffin@linaro.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
2015-10-23 11:19:21 +05:30
Lee Jones
6c03663f98 mailbox: Fix a couple of trivial static checker issues
This patch deals with a few spelling, white space and type
warnings reported by Intel's Kbuild Test Robot.

Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
2015-10-17 10:36:56 +05:30