Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dmaengine: cppi41: More PM runtime fixes

Fix use of u32 instead of int for checking for negative errors values
as pointed out by Dan Carpenter <dan.carpenter@oracle.com>.

And while testing the PM runtime error path by randomly returning
failed values in runtime resume, I noticed two more places that need
fixing:

- If pm_runtime_get_sync() fails in probe, we still need to do
pm_runtime_put_sync() to keep the use count happy. We could call
pm_runtime_put_noidle() on the error path, but we're just going
to call pm_runtime_disable() after that so pm_runtime_put_sync()
will do what we want

- We should print an error if pm_runtime_get_sync() fails in
cppi41_dma_alloc_chan_resources() so we know where it happens

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Fixes: 740b4be3f742 ("dmaengine: cpp41: Fix handling of error path")
Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>

authored by

Tony Lindgren and committed by
Vinod Koul
d5afc1b6 740b4be3

+7 -4
+7 -4
drivers/dma/cppi41.c
··· 317 317 318 318 while (val) { 319 319 u32 desc, len; 320 + int error; 320 321 321 - status = pm_runtime_get(cdd->ddev.dev); 322 - if (status < 0) 322 + error = pm_runtime_get(cdd->ddev.dev); 323 + if (error < 0) 323 324 dev_err(cdd->ddev.dev, "%s pm runtime get: %i\n", 324 - __func__, status); 325 + __func__, error); 325 326 326 327 q_num = __fls(val); 327 328 val &= ~(1 << q_num); ··· 368 367 369 368 error = pm_runtime_get_sync(cdd->ddev.dev); 370 369 if (error < 0) { 370 + dev_err(cdd->ddev.dev, "%s pm runtime get: %i\n", 371 + __func__, error); 371 372 pm_runtime_put_noidle(cdd->ddev.dev); 372 373 373 374 return error; ··· 1075 1072 deinit_cppi41(dev, cdd); 1076 1073 err_init_cppi: 1077 1074 pm_runtime_dont_use_autosuspend(dev); 1078 - pm_runtime_put_sync(dev); 1079 1075 err_get_sync: 1076 + pm_runtime_put_sync(dev); 1080 1077 pm_runtime_disable(dev); 1081 1078 iounmap(cdd->usbss_mem); 1082 1079 iounmap(cdd->ctrl_mem);