pm_runtime_irq_safe increases the parents runtime usage
counter effectively keeping the OMAP SoC from idling.
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Acked-by: Tony Lindgren <tony@atomide.com>
Tested-by: Pavel Machek <pavel@ucw.cz>
Instead of immediately sending the SSI module to
sleep, wait some time in case of new incoming or
outgoing traffic.
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Tested-by: Pavel Machek <pavel@ucw.cz>
msg->complete() should always be called from process context once
irq_safe runtime pm flag is no longer set for omap-ssi.
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Tested-by: Pavel Machek <pavel@ucw.cz>
ensure, that clocks remain enabled, when a transfer is started.
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Tested-by: Pavel Machek <pavel@ucw.cz>
There is no need to wait for hardware to really reach idle states,
so just release runtime PM asynchronously.
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Tested-by: Pavel Machek <pavel@ucw.cz>
runtime_pm_*_sync can block when irq_safe flag is removed
from omap-ssi driver, so it may not be called while a
spinlock is held.
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Tested-by: Pavel Machek <pavel@ucw.cz>
These functions may be called from atomic context,
so avoid synchronous runtime pm calls.
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Tested-by: Pavel Machek <pavel@ucw.cz>
Move pio interrupt handler from tasklet into thread to
allow runtime_pm_get_sync calls without irq_safe being
set.
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Tested-by: Pavel Machek <pavel@ucw.cz>
We may not call pm_runtime_get_sync() from tasklet, since
it can block once pm_runtime_irq_safe is removed for omap-ssi.
Since irq can should only be created for a running device,
we assume, that the device is already running and use non-
synchronous API instead.
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Tested-by: Pavel Machek <pavel@ucw.cz>
There is no need to disable the device synchronously, so
don't do it.
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Tested-by: Pavel Machek <pavel@ucw.cz>
ssi_start_tx and ssi_stop_tx may be called from atomic context. Once
pm_runtime_irq_safe() is removed for omap-ssi, this will fail, due
to blocking pm_runtime_*_sync() calls.
This fixes ssi_stop_tx by using non-sync API and ssi_start_tx by
using a worker thread.
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Tested-by: Pavel Machek <pavel@ucw.cz>
port events should be sent from process context after
irq_safe runtime pm flag is removed in omap-ssi.
Signed-off-By: Sebastian Reichel <sre@kernel.org>
Tested-by: Pavel Machek <pavel@ucw.cz>
This simplifies the code and avoids holding a spin_lock when
runtime pm calls are made. Once the irq_safe flag is removed
for omap_ssi's runtime pm, pm_runtime_get/put_sync can sleep,
which is a no-go while holding a spin_lock.
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Tested-by: Pavel Machek <pavel@ucw.cz>
Convert cawake interrupt handler from tasklet to
threaded interrupt handler in preparation of
blocking runtime_pm calls.
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Tested-by: Pavel Machek <pavel@ucw.cz>
ssip_xmit should be called from process context,
since it calls hsi_async_write.
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Tested-by: Pavel Machek <pavel@ucw.cz>
To avoid setting irq_safe runtime pm flag in omap-ssi, multiple calls
will be moved to process context. This also affects ssi-protocol, so
use the safer spin_lock_bh instead of a simple spin_lock.
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Tested-by: Pavel Machek <pavel@ucw.cz>
This avoids calling ssi_waketest(), while a spinlock is
being hold, since ssi_waketest may sleep once irq_safe
runtime pm is disabled.
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Tested-by: Pavel Machek <pavel@ucw.cz>
module reset and power management rule setup
is already done by hwmod. Remove this cruft,
which predates hwmod.
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Acked-by: Tony Lindgren <tony@atomide.com>
Tested-by: Pavel Machek <pavel@ucw.cz>
If the HSI core is built as a module hsi_boardinfo may still
be built-in as its Kconfig type is bool, which can cause build
issues. Fix this by building this code into the HSI core when
enabled.
Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Release &hi->lock before calling `cs_hsi_control_read_error' to avoid deadlock.
The bug was found using EBA (https://github.com/models-team/eba), which reported
the following:
Double lock
first at drivers/hsi/clients/cmt_speech.c:443
second at drivers/hsi/clients/cmt_speech.c:447
In cs_hsi_read_on_control_complete defined at drivers/hsi/clients/cmt_speech.c:438:
(!) drivers/hsi/clients/cmt_speech.c:443: spin_lock(& hi->lock);
(?) drivers/hsi/clients/cmt_speech.c:445: msg->status == 4 -> true
(!) drivers/hsi/clients/cmt_speech.c:447: cs_hsi_control_read_error(hi, msg);
(!) drivers/hsi/clients/cmt_speech.c:407: __cs_hsi_error_pre(hi, msg, "control read",
& hi->control_state);
(!) drivers/hsi/clients/cmt_speech.c:382: spin_lock(& hi->lock);
Signed-off-by: Iago Abal <mail@iagoabal.eu>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Use kmemdup when some other buffer is immediately copied into allocated
region. It replaces call to allocation followed by memcpy, by a single
call to kmemdup.
Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Replace explicit computation of vma page count by a call to
vma_pages()
Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
After the clk change support, the ssi omap ssi core driver
now calls into the port driver to change fclk. This function
was previously inside of an #ifdef, because it was only used
when CONFIG_PM is enabled. Now it also gets used without
power management support:
drivers/hsi/built-in.o: In function `ssi_clk_event':
omap_ssi_port.c:(.text+0x1bf8): undefined reference to `omap_ssi_port_update_fclk'
This moves the function outside of the CONFIG_PM guard.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: 4bcf741452 ("HSI: omap-ssi: add clk change support")
Signed-off-by: Sebastian Reichel <sre@kernel.org>
The driver now uses some pinctrl functions, but fails
to build if PINCTRL is disabled because the respective
header files are only included indirectly:
drivers/hsi/controllers/omap_ssi_core.c: In function 'ssi_clk_event':
drivers/hsi/controllers/omap_ssi_core.c:317:4: error: implicit declaration of function 'pinctrl_pm_select_idle_state' [-Werror=implicit-function-declaration]
drivers/hsi/controllers/omap_ssi_core.c:339:4: error: implicit declaration of function 'pinctrl_pm_select_default_state' [-Werror=implicit-function-declaration]
drivers/hsi/controllers/omap_ssi_port.c: In function 'ssi_flush':
drivers/hsi/controllers/omap_ssi_port.c:520:2: error: implicit declaration of function 'pinctrl_pm_select_idle_state' [-Werror=implicit-function-declaration]
This includes the headers from the files that call the functions,
which works even if pinctrl is turned off.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: 4bcf741452 ("HSI: omap-ssi: add clk change support")
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Enabling the omap ssi driver without COMMON_CLK results in a build failure:
drivers/hsi/controllers/omap_ssi_core.c: In function 'ssi_clk_event':
drivers/hsi/controllers/omap_ssi_core.c:304:7: error: 'PRE_RATE_CHANGE' undeclared (first use in this function)
This adds a Kconfig dependency to avoid the invalid configuration.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: 4bcf741452 ("HSI: omap-ssi: add clk change support")
Signed-off-by: Sebastian Reichel <sre@kernel.org>
This adds support for frequency changes of the SSI
functional clock, which may occur due to DVFS.
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-By: Sebastian Reichel <sre@kernel.org>
Merge omap_ssi and omap_ssi_port into one module. This
fixes problems with module cycle dependencies introduced
by future patches.
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
This avoids removal of the HSI port device when
only the platform port device should be removed
and clears the POPULATED bit in the DT node, so
that a new platform device is created when the
driver is probed again.
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Removal of ssi controller debugfs directory must
happen after the clients have been removed from
it.
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
When using the ssi-protocol driver with the Nokia N950, the
following error is thrown during modem powered up sequence.
[13852.274993] port0: SSI error: 0x01
[13852.279205] ssi-protocol ssi-protocol: RX error detected
[13852.284820] ssi-protocol ssi-protocol: Main state: 1
[13852.290069] ssi-protocol ssi-protocol: Recv state: 0
[13852.295288] ssi-protocol ssi-protocol: Send state: 0
[13852.300537] ssi-protocol ssi-protocol: CMT Offline
[13852.305603] ssi-protocol ssi-protocol: Wake test 1
[13852.310638] ssi-protocol ssi-protocol: Data RX id: 0
[13852.315887] ssi-protocol ssi-protocol: Data TX id: 0
[13856.001464] ssi-protocol ssi-protocol: Watchdog trigerred
[13856.007293] ssi-protocol ssi-protocol: Main state: 1
[13856.012542] ssi-protocol ssi-protocol: Recv state: 0
[13856.017761] ssi-protocol ssi-protocol: Send state: 0
[13856.023010] ssi-protocol ssi-protocol: CMT Offline
[13856.028045] ssi-protocol ssi-protocol: Wake test 0
[13856.033111] ssi-protocol ssi-protocol: Data RX id: 0
[13856.038330] ssi-protocol ssi-protocol: Data TX id: 0
This patch fixes the issue by using the handshake setup from
the Nokia N950 kernel. The new handshake sequence also works
with the N900, so there is no need to differentiate between
both modems.
Tested-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
The Nokia N950 and Nokia N9 also have a SSI connected
modem, which use the same protocols as the Nokia N900,
but with increased link speed (96000 kbps instead of
55000 kbps) and with less GPIOs.
Since it's unclear, if the N950 and the N9 use exactly
the same modem, each of them gets their own compatible
string.
Acked-by: Rob Herring <robh@kernel.org>
Tested-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
The function can return negative value.
The problem has been detected using proposed semantic patch
scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci [1].
[1]: http://permalink.gmane.org/gmane.linux.kernel/2038576
Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
The function can return negative value.
The problem has been detected using proposed semantic patch
scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci [1].
[1]: http://permalink.gmane.org/gmane.linux.kernel/2038576
Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Use devm_ioremap_resource() in order to make the code simpler,
and remove redundant return value check of platform_get_resource()
because this value is alreadytaken care by devm_ioremap_resource()
Signed-off-by: Sanjeev Sharma <sanjeev_sharma@mentor.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Since kzalloc can be failed in memory pressure,
its return value should be checked and handled.
Signed-off-by: Insu Yun <wuninsu@gmail.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
When device_register() fails, kfree() is called in hsi_client_release(),
hence there is no need to call kfree in err3 again.
Fixes: a2aa24734d ("HSI: Add common DT binding for HSI client devices")
Signed-off-by: Geliang Tang <geliangtang@163.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
With two exceptions (drm/qxl and drm/radeon) all vm_operations_struct
structs should be constant.
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Reviewed-by: Oleg Nesterov <oleg@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
iQIcBAABAgAGBQJVkO2uAAoJEOvOhAQsB9HWOT0P/jvFrpj2iuWqdMcvBuMdlx6K
/9qiMsOStbxmbmjj3RsbFCkeHJMUBCI0ZVrIosdEyeZWx33fHkZJisvN1i1PMA63
qppcZtkGxSmCOi6+e9k+qZNBvKBWy2oCXyLx7zaUKkWuR7wGe9488+9dqd9x+/gu
i/HTvf8Omrukwko2a0omWUSmUimhveb/hQ7Vxc/M9lbxFeO3jMabV5ZzgfnoTTrh
Rd2zo4kGbhj8nxonCUHgamnk6hoTE3KYhBPvqohzTDSTALmZVxhCwaQzQWzq+kdl
oSLa+tik508/csh98tN9dlMkJReHlDNdJIbfazQ1vHI00T5PsQELexFT02iKBhS7
5mdHSPp5P1TgGB6Fk3lN+hVO6Ja0S/vmJUi72M2y5DPd55lnvOaCVuqzWIJTYOoN
tqllBH4WIz27hsJWiMLgkJQaDxfBFYx104tOq56s5SeOthBluSE2xoNDrzZGyvRh
NeVza4ccgxIj0p2xfgeErx89r4GSCNk/LakpcMJReaT7ri23mTCDZJNLMcVW7BYm
2MW6M3LF748eN3P2YyNnU+TeQNpIho4whuwfOV+uR4tpdd5MtMaObWimwxBN7URM
LeW3gIwsZFHxYU9NLeZoQZVi6gDmaVe7ma82AbHXaV/mQVYsSP9M6gCO+FASCTGt
Rz6Nyl4/Ns8rdXUoOud8
=qotW
-----END PGP SIGNATURE-----
Merge tag 'module-implicit-v4.1-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/paulg/linux
Pull implicit module.h fixes from Paul Gortmaker:
"Fix up implicit <module.h> users that will break later.
The files changed here are simply modular source files that are
implicitly relying on <module.h> being present. We fix them up now,
so that we can decouple some of the module related init code from the
core init code in the future.
The addition of the module.h include to several files here is also a
no-op from a code generation point of view, else there would already
be compile issues with these files today.
There may be lots more implicit includes of <module.h> in tree, but
these are the ones that extensive build test coverage has shown that
must be fixed in order to avoid build breakage fallout for the pending
module.h <---> init.h code relocation we desire to complete"
* tag 'module-implicit-v4.1-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/paulg/linux:
frv: add module.h to mb93090-mb00/flash.c to avoid compile fail
drivers/cpufreq: include <module.h> for modular exynos-cpufreq.c code
drivers/staging: include <module.h> for modular android tegra_ion code
crypto/asymmetric_keys: pkcs7_key_type needs module.h
sh: mach-highlander/psw.c is tristate and should use module.h
drivers/regulator: include <module.h> for modular max77802 code
drivers/pcmcia: include <module.h> for modular xxs1500_ss code
drivers/hsi: include <module.h> for modular omap_ssi code
drivers/gpu: include <module.h> for modular rockchip code
drivers/gpio: include <module.h> for modular crystalcove code
drivers/clk: include <module.h> for clk-max77xxx modular code
Since 39b2bbe3d7 (gpio: add flags argument to gpiod_get*() functions)
which appeared in v3.17-rc1, the gpiod_get* functions take an additional
parameter that allows to specify direction and initial value for output.
Use this to simplify the driver. Furthermore this is one caller less
that stops us making the flags argument to gpiod_get*() mandatory.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Reduce message priority from dev_err to dev_dbg for missing cmt-speech
or ssi-protocol drivers, since they will be probed again and it may
result in spamming the boot log.
Reported-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
The user interface for timestamps in the new cmt_speech
driver is broken in multiple ways:
- The layout is incompatible between 32-bit and 64-bit user
space, because of the size differences in 'struct timespec'.
This means that the driver can not work when used with 32-bit
user space on a 64-bit kernel.
- As there are plans to change 32-bit user space to use
a 64-bit time_t type in the future, it will also be
incompatible with new 32-bit user space.
- It is using ktime_get_ts under it's deprecated alias
(do_posix_clock_monotonic_gettime).
To keep support for the user space tools written for this driver (which
have lived many years out-of-tree), the interface has been hardened to
unsigned 32-bit values.
Reported-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
These files are built off of a tristate Kconfig option and also contain
modular function calls so they should explicitly include module.h to
avoid compile breakage during header shuffles done in the future.
We change the one header file wich gives us coverage on both files:
drivers/hsi/controllers/omap_ssi.c
drivers/hsi/controllers/omap_ssi_port.c
Cc: Sebastian Reichel <sre@kernel.org>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Return a negative error code on failure.
A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)
// <smpl>
@@
identifier ret; expression e1,e2;
@@
(
if (\(ret < 0\|ret != 0\))
{ ... return ret; }
|
ret = 0
)
... when != ret = e1
when != &ret
*if(...)
{
... when != ret = e2
when forall
return ret;
}
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Register cmt-speech driver in nokia-modem driver and forward
hsi channel information.
Acked-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Tested-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Introduces the cmt-speech driver, which implements
a character device interface for transferring speech
data frames over HSI/SSI.
The driver is used to exchange voice/speech data between
the Nokia N900/N950/N9's modem and its cpu.
Signed-off-by: Kai Vehmanen <kai.vehmanen@nokia.com>
Signed-off-by: Carlos Chinea <carlos.chinea@nokia.com>
Signed-off-by: Joni Lapilainen <joni.lapilainen@gmail.com>
Since the original driver has been written for 2.6.28 some
build fixes and general cleanups have been added by me:
* fix build for 4.0 kernel
* replace GFP_ATOMIC with GFP_KERNEL in cs_alloc_cmds()
* add sanity check for CS_SET_WAKELINE ioctl
* cleanup driver initialisation
* rename driver to cmt-speech to be consistent with
ssi-protocol driver
* move cs-protocol.h to include/uapi/linux/hsi, since
it describes a userspace API
* replace hardcoded channels numbers with values provided
via the HSI framework (e.g. coming from DT)
Acked-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Tested-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Sebastian Reichel <sre@kernel.org>