18 Oct, 2019
1 commit
-
As platform_get_irq_by_name() now prints an error when the interrupt
does not exist, looping over possibly non-existing interrupts causes the
printing of scary messages like:sh_mtu2 fcff0000.timer: IRQ tgi1a not found
sh_mtu2 fcff0000.timer: IRQ tgi2a not foundFix this by using the platform_irq_count() helper, to avoid touching
non-existent interrupts. Limit the returned number of interrupts to the
maximum number of channels currently supported by the driver in a
future-proof way, i.e. using ARRAY_SIZE() instead of a hardcoded number.Fixes: 7723f4c5ecdb8d83 ("driver core: platform: Add an error message to platform_get_irq*()")
Signed-off-by: Geert Uytterhoeven
Signed-off-by: Daniel Lezcano
Link: https://lore.kernel.org/r/20191016143003.28561-1-geert+renesas@glider.be
03 Oct, 2018
1 commit
-
This patch updates license to use SPDX-License-Identifier instead of verbose
license text.Signed-off-by: Kuninori Morimoto
Reviewed-by: Simon Horman
Signed-off-by: Daniel Lezcano
13 Jun, 2018
1 commit
-
The kzalloc() function has a 2-factor argument form, kcalloc(). This
patch replaces cases of:kzalloc(a * b, gfp)
with:
kcalloc(a * b, gfp)as well as handling cases of:
kzalloc(a * b * c, gfp)
with:
kzalloc(array3_size(a, b, c), gfp)
as it's slightly less ugly than:
kzalloc_array(array_size(a, b), c, gfp)
This does, however, attempt to ignore constant size factors like:
kzalloc(4 * 1024, gfp)
though any constants defined via macros get caught up in the conversion.
Any factors with a sizeof() of "unsigned char", "char", and "u8" were
dropped, since they're redundant.The Coccinelle script used for this was:
// Fix redundant parens around sizeof().
@@
type TYPE;
expression THING, E;
@@(
kzalloc(
- (sizeof(TYPE)) * E
+ sizeof(TYPE) * E
, ...)
|
kzalloc(
- (sizeof(THING)) * E
+ sizeof(THING) * E
, ...)
)// Drop single-byte sizes and redundant parens.
@@
expression COUNT;
typedef u8;
typedef __u8;
@@(
kzalloc(
- sizeof(u8) * (COUNT)
+ COUNT
, ...)
|
kzalloc(
- sizeof(__u8) * (COUNT)
+ COUNT
, ...)
|
kzalloc(
- sizeof(char) * (COUNT)
+ COUNT
, ...)
|
kzalloc(
- sizeof(unsigned char) * (COUNT)
+ COUNT
, ...)
|
kzalloc(
- sizeof(u8) * COUNT
+ COUNT
, ...)
|
kzalloc(
- sizeof(__u8) * COUNT
+ COUNT
, ...)
|
kzalloc(
- sizeof(char) * COUNT
+ COUNT
, ...)
|
kzalloc(
- sizeof(unsigned char) * COUNT
+ COUNT
, ...)
)// 2-factor product with sizeof(type/expression) and identifier or constant.
@@
type TYPE;
expression THING;
identifier COUNT_ID;
constant COUNT_CONST;
@@(
- kzalloc
+ kcalloc
(
- sizeof(TYPE) * (COUNT_ID)
+ COUNT_ID, sizeof(TYPE)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(TYPE) * COUNT_ID
+ COUNT_ID, sizeof(TYPE)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(TYPE) * (COUNT_CONST)
+ COUNT_CONST, sizeof(TYPE)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(TYPE) * COUNT_CONST
+ COUNT_CONST, sizeof(TYPE)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(THING) * (COUNT_ID)
+ COUNT_ID, sizeof(THING)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(THING) * COUNT_ID
+ COUNT_ID, sizeof(THING)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(THING) * (COUNT_CONST)
+ COUNT_CONST, sizeof(THING)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(THING) * COUNT_CONST
+ COUNT_CONST, sizeof(THING)
, ...)
)// 2-factor product, only identifiers.
@@
identifier SIZE, COUNT;
@@- kzalloc
+ kcalloc
(
- SIZE * COUNT
+ COUNT, SIZE
, ...)// 3-factor product with 1 sizeof(type) or sizeof(expression), with
// redundant parens removed.
@@
expression THING;
identifier STRIDE, COUNT;
type TYPE;
@@(
kzalloc(
- sizeof(TYPE) * (COUNT) * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kzalloc(
- sizeof(TYPE) * (COUNT) * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kzalloc(
- sizeof(TYPE) * COUNT * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kzalloc(
- sizeof(TYPE) * COUNT * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kzalloc(
- sizeof(THING) * (COUNT) * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
kzalloc(
- sizeof(THING) * (COUNT) * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
kzalloc(
- sizeof(THING) * COUNT * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
kzalloc(
- sizeof(THING) * COUNT * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
)// 3-factor product with 2 sizeof(variable), with redundant parens removed.
@@
expression THING1, THING2;
identifier COUNT;
type TYPE1, TYPE2;
@@(
kzalloc(
- sizeof(TYPE1) * sizeof(TYPE2) * COUNT
+ array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
, ...)
|
kzalloc(
- sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
, ...)
|
kzalloc(
- sizeof(THING1) * sizeof(THING2) * COUNT
+ array3_size(COUNT, sizeof(THING1), sizeof(THING2))
, ...)
|
kzalloc(
- sizeof(THING1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(THING1), sizeof(THING2))
, ...)
|
kzalloc(
- sizeof(TYPE1) * sizeof(THING2) * COUNT
+ array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
, ...)
|
kzalloc(
- sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
, ...)
)// 3-factor product, only identifiers, with redundant parens removed.
@@
identifier STRIDE, SIZE, COUNT;
@@(
kzalloc(
- (COUNT) * STRIDE * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- COUNT * (STRIDE) * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- COUNT * STRIDE * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- (COUNT) * (STRIDE) * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- COUNT * (STRIDE) * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- (COUNT) * STRIDE * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- (COUNT) * (STRIDE) * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- COUNT * STRIDE * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
)// Any remaining multi-factor products, first at least 3-factor products,
// when they're not all constants...
@@
expression E1, E2, E3;
constant C1, C2, C3;
@@(
kzalloc(C1 * C2 * C3, ...)
|
kzalloc(
- (E1) * E2 * E3
+ array3_size(E1, E2, E3)
, ...)
|
kzalloc(
- (E1) * (E2) * E3
+ array3_size(E1, E2, E3)
, ...)
|
kzalloc(
- (E1) * (E2) * (E3)
+ array3_size(E1, E2, E3)
, ...)
|
kzalloc(
- E1 * E2 * E3
+ array3_size(E1, E2, E3)
, ...)
)// And then all remaining 2 factors products when they're not all constants,
// keeping sizeof() as the second factor argument.
@@
expression THING, E1, E2;
type TYPE;
constant C1, C2, C3;
@@(
kzalloc(sizeof(THING) * C2, ...)
|
kzalloc(sizeof(TYPE) * C2, ...)
|
kzalloc(C1 * C2 * C3, ...)
|
kzalloc(C1 * C2, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(TYPE) * (E2)
+ E2, sizeof(TYPE)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(TYPE) * E2
+ E2, sizeof(TYPE)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(THING) * (E2)
+ E2, sizeof(THING)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(THING) * E2
+ E2, sizeof(THING)
, ...)
|
- kzalloc
+ kcalloc
(
- (E1) * E2
+ E1, E2
, ...)
|
- kzalloc
+ kcalloc
(
- (E1) * (E2)
+ E1, E2
, ...)
|
- kzalloc
+ kcalloc
(
- E1 * E2
+ E1, E2
, ...)
)Signed-off-by: Kees Cook
28 Oct, 2015
1 commit
-
On the r7s72100 Genmai board the MTU2 driver currently triggers a common
clock framework WARN_ON(enable_count) when disabling the clock due to
the MTU2 driver after recent callback rework may call ->set_state_shutdown()
multiple times. A similar issue was spotted for the TMU driver and fixed in:
452b132 clocksource/drivers/sh_tmu: Fix traceback spotted in -nextOn r7s72100 Genmai v4.3-rc7 built with shmobile_defconfig spits out the
following during boot:sh_mtu2 fcff0000.timer: ch0: used for clock events
------------[ cut here ]------------
WARNING: CPU: 0 PID: 1 at drivers/clk/clk.c:675 clk_core_disable+0x2c/0x6c()
CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.3.0-rc7 #1
Hardware name: Generic R7S72100 (Flattened Device Tree)
Backtrace:
[] (dump_backtrace) from [] (show_stack+0x18/0x1c)
[] (show_stack) from [] (dump_stack+0x74/0x90)
[] (dump_stack) from [] (warn_slowpath_common+0x88/0xb4)
[] (warn_slowpath_common) from [] (warn_slowpath_null+0x24/0x2c)
[] (warn_slowpath_null) from [] (clk_core_disable+0x2c/0x6c)
[] (clk_core_disable) from [] (clk_disable+0x40/0x4c)
[] (clk_disable) from [] (sh_mtu2_disable+0x24/0x50)
[] (sh_mtu2_disable) from [] (sh_mtu2_clock_event_shutdown+0x14/0x1c)
[] (sh_mtu2_clock_event_shutdown) from [] (clockevents_switch_state+0xc8/0x114)
[] (clockevents_switch_state) from [] (clockevents_shutdown+0x18/0x28)
[] (clockevents_shutdown) from [] (clockevents_exchange_device+0x70/0x78)
[] (clockevents_exchange_device) from [] (tick_check_new_device+0x88/0xe0)
[] (tick_check_new_device) from [] (clockevents_register_device+0xac/0x120)
[] (clockevents_register_device) from [] (sh_mtu2_probe+0x230/0x350)
[] (sh_mtu2_probe) from [] (platform_drv_probe+0x50/0x98)Reported-by: Chris Brandt
Fixes: 19a9ffb ("clockevents/drivers/sh_mtu2: Migrate to new 'set-state' interface")
Cc: Viresh Kumar
Cc: Laurent Pinchart
Signed-off-by: Magnus Damm
Signed-off-by: Daniel Lezcano
Reviewed-by: Viresh Kumar
10 Aug, 2015
1 commit
-
Migrate sh_mtu2 driver to the new 'set-state' interface provided by
clockevents core, the earlier 'set-mode' interface is marked obsolete
now.This also enables us to implement callbacks for new states of clockevent
devices, for example: ONESHOT_STOPPED.Cc: Magnus Damm
Cc: Laurent Pinchart
Cc: Paul Mundt
Signed-off-by: Viresh Kumar
Signed-off-by: Daniel Lezcano
Acked-by: Laurent Pinchart
04 Jul, 2014
1 commit
-
Document DT bindings and parse them in the MTU2 driver.
Signed-off-by: Laurent Pinchart
Tested-by: Wolfram Sang
02 Jul, 2014
2 commits
-
The global spinlock is used to protect the shared start/stop register.
Now that all MTU2 channels are handled by a single device instance, use
a per-device spinlock.Signed-off-by: Laurent Pinchart
Tested-by: Wolfram Sang -
Now that all platforms have switched to the new-style platform data,
drop support for the legacy version.Signed-off-by: Laurent Pinchart
Tested-by: Wolfram Sang
23 May, 2014
1 commit
-
The site-specific OOM messages are unnecessary, because they
duplicate the MM subsystem generic OOM message.[dlezcano] : refreshed against latest modifications: kmalloc -> kzalloc
Signed-off-by: Jingoo Han
Signed-off-by: Daniel Lezcano
16 Apr, 2014
17 commits
-
This helps locating duplicates and inserting new headers.
Signed-off-by: Laurent Pinchart
Tested-by: Wolfram Sang -
Do not include the paragraph about writing to the Free Software
Foundation's mailing address from the sample GPL notice. The FSF has
changed addresses in the past, and may do so again. Linux already
includes a copy of the GPL.Signed-off-by: Laurent Pinchart
Tested-by: Wolfram Sang -
The sh_mtu2 driver gets the MTU2 functional clock using a connection ID
of "mtu2_fck". While all SH SoCs create clock lookup entries with a NULL
device ID and a "mtu2_fck" connection ID, the ARM SoCs use the device ID
only with a NULL connection ID. This works on legacy platforms but will
break on ARM with DT boot.Fix the situation by using a connection ID of "fck" in the non-legacy
platform data case. Clock lookup entries will be renamed to use the
device ID as well as the connection ID as platforms get moved to new
platform data. The legacy code will eventually be dropped, leaving us
with device ID based clock lookup, compatible with DT boot.Signed-off-by: Laurent Pinchart
Tested-by: Wolfram Sang -
MTU2 hardware devices can support multiple channels, with global
registers and per-channel registers. The sh_mtu2 driver currently models
the hardware with one Linux device per channel. This model makes it
difficult to handle global registers in a clean way.Add support for a new model that uses one Linux device per timer with
multiple channels per device. This requires changes to platform data,
add new channel configuration fields.Support for the legacy model is kept and will be removed after all
platforms switch to the new model.Signed-off-by: Laurent Pinchart
Tested-by: Wolfram Sang -
All boards use clock event ratings of 200 for the MTU2, hardcode it in
the driver.Signed-off-by: Laurent Pinchart
Tested-by: Wolfram Sang -
The MTU2 is not tied to CPU0, make it usable on any CPU.
Signed-off-by: Laurent Pinchart
Tested-by: Wolfram Sang -
Define symbolic macros for all used registers bits.
Signed-off-by: Laurent Pinchart
Tested-by: Wolfram Sang -
This prepares the driver for multi-channel support.
Signed-off-by: Laurent Pinchart
Tested-by: Wolfram Sang -
One kzalloc a day keeps the bugs away.
Signed-off-by: Laurent Pinchart
Tested-by: Wolfram Sang -
Use the index as the timer start/stop bit and when printing messages to
identify the channel.Signed-off-by: Laurent Pinchart
Tested-by: Wolfram Sang -
The channel memory base is channel-specific, add it to the channel
structure in preparation for support of multiple channels per device.Signed-off-by: Laurent Pinchart
Tested-by: Wolfram Sang -
The name argument is assigned to const structure fields only, constify
it.Signed-off-by: Laurent Pinchart
Tested-by: Wolfram Sang -
Move the channel setup code from sh_mtu2_setup to a new
sh_mtu2_setup_channel function and call it from sh_mtu2_setup.Signed-off-by: Laurent Pinchart
Tested-by: Wolfram Sang -
Channel data is private as well, rename priv to device to make the
distrinction between the core device and the channels clearer.Signed-off-by: Laurent Pinchart
Tested-by: Wolfram Sang -
Create a new sh_mtu2_channel structure to hold the channel-specific
fields in preparation for multiple channels per device support.Signed-off-by: Laurent Pinchart
Tested-by: Wolfram Sang -
The rate and periodic fields are used in a single function only, as
local variables. Remove them from the structure.Signed-off-by: Laurent Pinchart
Tested-by: Wolfram Sang -
The driver claims it needs to register an interrupt handler too early
for request_irq(). This might have been true in the past, but the only
meaningful difference between request_irq() and setup_irq() today is an
additional kzalloc() call in request_irq(). As the driver calls
kmalloc() itself we know that the slab allocator is available, we can
thus switch to request_irq().Signed-off-by: Laurent Pinchart
Tested-by: Wolfram Sang
14 Jan, 2014
1 commit
-
Pull clocksource/clockevent updates from Daniel Lezcano:
* Axel Lin removed an unused structure defining the ids for the
bcm kona driver.* Ezequiel Garcia enabled the timer divider only when the 25MHz
timer is not used for the armada 370 XP.* Jingoo Han removed a pointless platform data initialization for
the sh_mtu and sh_mtu2.* Laurent Pinchart added the clk_prepare/clk_unprepare for sh_cmt.
* Linus Walleij added a useful warning in clk_of when no clocks
are found while the old behavior was to silently hang at boot time.* Maxime Ripard added the high speed timer drivers for the
Allwinner SoCs (A10, A13, A20). He increased the rating, shared the
irq across all available cpus and fixed the clockevent's irq
initialization for the sun4i.* Michael Opdenacker removed the usage of the IRQF_DISABLED for the
all the timers driver located in drivers/clocksource.* Stephen Boyd switched to sched_clock_register for the
arm_global_timer, cadence_ttc, sun4i and orion timers.Conflicts:
drivers/clocksource/clksrc-of.cSigned-off-by: Ingo Molnar
11 Dec, 2013
2 commits
-
This patch removes the use of the IRQF_DISABLED flag
It's a NOOP since 2.6.35 and it will be removed one day.
[dlezcano] : slightly changed the changelog
Signed-off-by: Michael Opdenacker
Signed-off-by: Daniel Lezcano -
The driver core clears the driver data to NULL after device_release
or on probe failure. Thus, it is not needed to manually clear the
device driver data to NULL.Signed-off-by: Jingoo Han
Acked-by: Simon Horman
Signed-off-by: Daniel Lezcano
21 Nov, 2013
2 commits
-
Prepare the clock at probe time, as there is no other appropriate place
in the driver where we're allowed to sleep.Cc: Daniel Lezcano
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Laurent Pinchart
Acked-by: Simon Horman
Signed-off-by: Daniel Lezcano -
Fix the probe error path to release the clock resource when the
sh_mtu2_register() call fails.Cc: Daniel Lezcano
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Laurent Pinchart
Acked-by: Simon Horman
Signed-off-by: Daniel Lezcano
13 Mar, 2013
1 commit
-
The reason for this is to ensure that MTU2 is probed earlier
than with its previous initcall level, module init.This came up as a problem with using CMT as a clock source kzm9g-reference
which does not make use of early timers or devices. In that scenario
initialisation of SDHI and MMCIF both stall on msleep() calls due to the
absence of a initialised clock source.The purpose of this change is to keep the MTU2 code in sync with the CMT code
which has been modified in a similar manner..Compile tested only using se7206_defconfig.
I do not believe I have any boards that support the MTU2.Signed-off-by: Simon Horman
04 Jan, 2013
1 commit
-
CONFIG_HOTPLUG is going away as an option. As a result, the __dev*
markings need to be removed.This change removes the use of __devinit, __devexit_p, __devinitdata,
__devinitconst, and __devexit from these drivers.Based on patches originally written by Bill Pemberton, but redone by me
in order to handle some of the coding style issues better, by hand.Cc: Bill Pemberton
Cc: John Stultz
Cc: Thomas Gleixner
Signed-off-by: Greg Kroah-Hartman
04 Sep, 2012
4 commits
-
Modify the SH MTU2 clock event device driver to support runtime PM at
a basic level (i.e. device clocks can be disabled and enabled, but
domain power must be on, because the device has to be marked as
"irq safe").Signed-off-by: Rafael J. Wysocki
Acked-by: Magnus Damm -
The syscore device PM flag is used to mark the devices (belonging to
a PM domain) that should never be turned off, except for the system
core (syscore) suspend/hibernation and resume stages. That flag is
stored in the device's struct pm_subsys_data object whose address is
available from struct device. However, in some situations it may be
convenient to set that flag before the device is added to a PM
domain, so it is better to move it directly to the "power" member of
struct device. Then, it can be checked by the routines in
drivers/base/power/runtime.c and drivers/base/power/main.c, which is
more straightforward.This also reduces the number of dev_gpd_data() invocations in the
generic PM domains framework, so the overhead related to the syscore
flag is slightly smaller.Signed-off-by: Rafael J. Wysocki
Acked-by: Magnus Damm -
The always_on device flag is used to mark the devices (belonging to
a PM domain) that should never be turned off, except for the system
core (syscore) suspend/hibernation and resume stages. Change name
of that flag to "syscore" to better reflect its purpose.Signed-off-by: Rafael J. Wysocki
Acked-by: Magnus Damm -
Introduce suspend/resume routines for SH MTU2 clock event devices
such that if those devices belong to a PM domain, the generic PM
domains framework will be notified that the given domain may be
turned off (during system suspend) or that it has to be turned on
(during system resume).Signed-off-by: Rafael J. Wysocki
Acked-by: Magnus Damm
11 Jun, 2012
1 commit
-
Signed-off-by: Paul Mundt
17 Mar, 2012
1 commit
-
Make the MTU2 clocksource driver mark its device as "always on"
using pm_genpd_dev_always_on() to protect it from surprise power
removals.Signed-off-by: Rafael J. Wysocki
Tested-by: Simon Horman
Acked-by: Paul Mundt
Cc: stable@vger.kernel.org
01 Nov, 2011
1 commit
-
A pending cleanup will mean that module.h won't be implicitly
everywhere anymore. Make sure the modular drivers in clocksource
are actually calling out for explicitly in advance.Signed-off-by: Paul Gortmaker