Skip to content

Commit b73b5c4

Browse files
Magnus Dammpmundt
authored andcommitted
ARM: mach-shmobile: cpuidle single/global and last_state fixes
The following commits break cpuidle on SH-Mobile ARM: 46bcfad cpuidle: Single/Global registration of idle states e978aa7 cpuidle: Move dev->last_residency update to driver enter routine; remove dev->last_state This patch remedies these issues by up-porting the SH-Mobile code to fit with the above introduced framework changes. It is worth noting that the new code becomes significantly cleaner, so these framework changes are very welcome. At the same time this breakage could probably have been avoided by grepping for "last_state" and "cpuidle_register_driver". Signed-off-by: Magnus Damm <damm@opensource.se> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
1 parent 9b49139 commit b73b5c4

3 files changed

Lines changed: 30 additions & 40 deletions

File tree

‎arch/arm/mach-shmobile/cpuidle.c‎

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -26,65 +26,59 @@ void (*shmobile_cpuidle_modes[CPUIDLE_STATE_MAX])(void) = {
2626
};
2727

2828
static int shmobile_cpuidle_enter(struct cpuidle_device *dev,
29-
struct cpuidle_state *state)
29+
struct cpuidle_driver *drv,
30+
int index)
3031
{
3132
ktime_t before, after;
32-
int requested_state = state - &dev->states[0];
3333

34-
dev->last_state = &dev->states[requested_state];
3534
before = ktime_get();
3635

3736
local_irq_disable();
3837
local_fiq_disable();
3938

40-
shmobile_cpuidle_modes[requested_state]();
39+
shmobile_cpuidle_modes[index]();
4140

4241
local_irq_enable();
4342
local_fiq_enable();
4443

4544
after = ktime_get();
46-
return ktime_to_ns(ktime_sub(after, before)) >> 10;
45+
dev->last_residency = ktime_to_ns(ktime_sub(after, before)) >> 10;
46+
47+
return index;
4748
}
4849

4950
static struct cpuidle_device shmobile_cpuidle_dev;
5051
static struct cpuidle_driver shmobile_cpuidle_driver = {
5152
.name = "shmobile_cpuidle",
5253
.owner = THIS_MODULE,
54+
.states[0] = {
55+
.name = "C1",
56+
.desc = "WFI",
57+
.exit_latency = 1,
58+
.target_residency = 1 * 2,
59+
.flags = CPUIDLE_FLAG_TIME_VALID,
60+
},
61+
.safe_state_index = 0, /* C1 */
62+
.state_count = 1,
5363
};
5464

55-
void (*shmobile_cpuidle_setup)(struct cpuidle_device *dev);
65+
void (*shmobile_cpuidle_setup)(struct cpuidle_driver *drv);
5666

5767
static int shmobile_cpuidle_init(void)
5868
{
5969
struct cpuidle_device *dev = &shmobile_cpuidle_dev;
60-
struct cpuidle_state *state;
70+
struct cpuidle_driver *drv = &shmobile_cpuidle_driver;
6171
int i;
6272

63-
cpuidle_register_driver(&shmobile_cpuidle_driver);
64-
65-
for (i = 0; i < CPUIDLE_STATE_MAX; i++) {
66-
dev->states[i].name[0] = '\0';
67-
dev->states[i].desc[0] = '\0';
68-
dev->states[i].enter = shmobile_cpuidle_enter;
69-
}
70-
71-
i = CPUIDLE_DRIVER_STATE_START;
72-
73-
state = &dev->states[i++];
74-
snprintf(state->name, CPUIDLE_NAME_LEN, "C1");
75-
strncpy(state->desc, "WFI", CPUIDLE_DESC_LEN);
76-
state->exit_latency = 1;
77-
state->target_residency = 1 * 2;
78-
state->power_usage = 3;
79-
state->flags = 0;
80-
state->flags |= CPUIDLE_FLAG_TIME_VALID;
81-
82-
dev->safe_state = state;
83-
dev->state_count = i;
73+
for (i = 0; i < CPUIDLE_STATE_MAX; i++)
74+
drv->states[i].enter = shmobile_cpuidle_enter;
8475

8576
if (shmobile_cpuidle_setup)
86-
shmobile_cpuidle_setup(dev);
77+
shmobile_cpuidle_setup(drv);
78+
79+
cpuidle_register_driver(drv);
8780

81+
dev->state_count = drv->state_count;
8882
cpuidle_register_device(dev);
8983

9084
return 0;

‎arch/arm/mach-shmobile/include/mach/common.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ extern int clk_init(void);
99
extern void shmobile_handle_irq_intc(struct pt_regs *);
1010
extern void shmobile_handle_irq_gic(struct pt_regs *);
1111
extern struct platform_suspend_ops shmobile_suspend_ops;
12-
struct cpuidle_device;
12+
struct cpuidle_driver;
1313
extern void (*shmobile_cpuidle_modes[])(void);
14-
extern void (*shmobile_cpuidle_setup)(struct cpuidle_device *dev);
14+
extern void (*shmobile_cpuidle_setup)(struct cpuidle_driver *drv);
1515

1616
extern void sh7367_init_irq(void);
1717
extern void sh7367_add_early_devices(void);

‎arch/arm/mach-shmobile/pm-sh7372.c‎

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -402,22 +402,18 @@ static void sh7372_setup_a3sm(unsigned long msk, unsigned long msk2)
402402

403403
#ifdef CONFIG_CPU_IDLE
404404

405-
static void sh7372_cpuidle_setup(struct cpuidle_device *dev)
405+
static void sh7372_cpuidle_setup(struct cpuidle_driver *drv)
406406
{
407-
struct cpuidle_state *state;
408-
int i = dev->state_count;
407+
struct cpuidle_state *state = &drv->states[drv->state_count];
409408

410-
state = &dev->states[i];
411409
snprintf(state->name, CPUIDLE_NAME_LEN, "C2");
412410
strncpy(state->desc, "Core Standby Mode", CPUIDLE_DESC_LEN);
413411
state->exit_latency = 10;
414412
state->target_residency = 20 + 10;
415-
state->power_usage = 1; /* perhaps not */
416-
state->flags = 0;
417-
state->flags |= CPUIDLE_FLAG_TIME_VALID;
418-
shmobile_cpuidle_modes[i] = sh7372_enter_core_standby;
413+
state->flags = CPUIDLE_FLAG_TIME_VALID;
414+
shmobile_cpuidle_modes[drv->state_count] = sh7372_enter_core_standby;
419415

420-
dev->state_count = i + 1;
416+
drv->state_count++;
421417
}
422418

423419
static void sh7372_cpuidle_init(void)

0 commit comments

Comments
 (0)