Skip to content

Commit 2aba322

Browse files
committed
Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
Pull crypto fix from Herbert Xu: "This fixes a crash on resume in the ccree driver" * 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: crypto: ccree - fix resume race condition on init
2 parents 6e7bd3b + 1358c13 commit 2aba322

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

drivers/crypto/ccree/cc_driver.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ static int init_cc_resources(struct platform_device *plat_dev)
380380
rc = cc_ivgen_init(new_drvdata);
381381
if (rc) {
382382
dev_err(dev, "cc_ivgen_init failed\n");
383-
goto post_power_mgr_err;
383+
goto post_buf_mgr_err;
384384
}
385385

386386
/* Allocate crypto algs */
@@ -403,6 +403,9 @@ static int init_cc_resources(struct platform_device *plat_dev)
403403
goto post_hash_err;
404404
}
405405

406+
/* All set, we can allow autosuspend */
407+
cc_pm_go(new_drvdata);
408+
406409
/* If we got here and FIPS mode is enabled
407410
* it means all FIPS test passed, so let TEE
408411
* know we're good.
@@ -417,8 +420,6 @@ static int init_cc_resources(struct platform_device *plat_dev)
417420
cc_cipher_free(new_drvdata);
418421
post_ivgen_err:
419422
cc_ivgen_fini(new_drvdata);
420-
post_power_mgr_err:
421-
cc_pm_fini(new_drvdata);
422423
post_buf_mgr_err:
423424
cc_buffer_mgr_fini(new_drvdata);
424425
post_req_mgr_err:

drivers/crypto/ccree/cc_pm.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,20 +100,19 @@ int cc_pm_put_suspend(struct device *dev)
100100

101101
int cc_pm_init(struct cc_drvdata *drvdata)
102102
{
103-
int rc = 0;
104103
struct device *dev = drvdata_to_dev(drvdata);
105104

106105
/* must be before the enabling to avoid resdundent suspending */
107106
pm_runtime_set_autosuspend_delay(dev, CC_SUSPEND_TIMEOUT);
108107
pm_runtime_use_autosuspend(dev);
109108
/* activate the PM module */
110-
rc = pm_runtime_set_active(dev);
111-
if (rc)
112-
return rc;
113-
/* enable the PM module*/
114-
pm_runtime_enable(dev);
109+
return pm_runtime_set_active(dev);
110+
}
115111

116-
return rc;
112+
/* enable the PM module*/
113+
void cc_pm_go(struct cc_drvdata *drvdata)
114+
{
115+
pm_runtime_enable(drvdata_to_dev(drvdata));
117116
}
118117

119118
void cc_pm_fini(struct cc_drvdata *drvdata)

drivers/crypto/ccree/cc_pm.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
extern const struct dev_pm_ops ccree_pm;
1717

1818
int cc_pm_init(struct cc_drvdata *drvdata);
19+
void cc_pm_go(struct cc_drvdata *drvdata);
1920
void cc_pm_fini(struct cc_drvdata *drvdata);
2021
int cc_pm_suspend(struct device *dev);
2122
int cc_pm_resume(struct device *dev);
@@ -29,6 +30,8 @@ static inline int cc_pm_init(struct cc_drvdata *drvdata)
2930
return 0;
3031
}
3132

33+
static void cc_pm_go(struct cc_drvdata *drvdata) {}
34+
3235
static inline void cc_pm_fini(struct cc_drvdata *drvdata) {}
3336

3437
static inline int cc_pm_suspend(struct device *dev)

0 commit comments

Comments
 (0)