Skip to content

Commit 1901300

Browse files
committed
Merge tag 'ti-driver-soc-for-v5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/ti/linux into arm/drivers
TI Driver updates for v5.19 * wkup_m3: io isolation, voltage scaling, vtt regulator and a debug option to stop m3 in suspend. * tisci: support for polled mode for system suspend, reset driver is now enabled for COMPILE_TEST * knav, dma.. misc cleanups for IS_ERR, pm_run_time*, and various other fixups. * tag 'ti-driver-soc-for-v5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/ti/linux: soc: ti: wkup_m3_ipc: Add debug option to halt m3 in suspend soc: ti: wkup_m3_ipc: Add support for i2c voltage scaling soc: ti: wkup_m3_ipc: Add support for IO Isolation soc: ti: knav_qmss_queue: Use IS_ERR instead of IS_ERR_OR_NULL when checking knav_queue_open() result soc: ti: pm33xx: using pm_runtime_resume_and_get instead of pm_runtime_get_sync firmware: ti_sci: Switch transport to polled mode during system suspend soc: ti: wkup_m3_ipc: Add support for toggling VTT regulator soc: ti: knav_qmss_queue: Use pm_runtime_resume_and_get instead of pm_runtime_get_sync soc: ti: knav_dma: Use pm_runtime_resume_and_get instead of pm_runtime_get_sync reset: ti-sci: Allow building under COMPILE_TEST soc: ti: ti_sci_pm_domains: Check for null return of devm_kcalloc soc: ti: omap_prm: Use of_device_get_match_data() soc: ti: pruss: using pm_runtime_resume_and_get instead of pm_runtime_get_sync soc: ti: replace usage of found with dedicated list iterator variable soc: ti: wkup_m3_ipc: fix platform_get_irq.cocci warning Link: https://lore.kernel.org/r/20220507163424.pvqnwrxpoo73lmp2@debtless Signed-off-by: Arnd Bergmann <[email protected]>
2 parents 68edb53 + 2a21f9e commit 1901300

File tree

10 files changed

+302
-52
lines changed

10 files changed

+302
-52
lines changed

drivers/firmware/ti_sci.c

Lines changed: 55 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/*
33
* Texas Instruments System Control Interface Protocol Driver
44
*
5-
* Copyright (C) 2015-2016 Texas Instruments Incorporated - https://www.ti.com/
5+
* Copyright (C) 2015-2022 Texas Instruments Incorporated - https://www.ti.com/
66
* Nishanth Menon
77
*/
88

@@ -12,6 +12,7 @@
1212
#include <linux/debugfs.h>
1313
#include <linux/export.h>
1414
#include <linux/io.h>
15+
#include <linux/iopoll.h>
1516
#include <linux/kernel.h>
1617
#include <linux/mailbox_client.h>
1718
#include <linux/module.h>
@@ -96,6 +97,7 @@ struct ti_sci_desc {
9697
* @node: list head
9798
* @host_id: Host ID
9899
* @users: Number of users of this instance
100+
* @is_suspending: Flag set to indicate in suspend path.
99101
*/
100102
struct ti_sci_info {
101103
struct device *dev;
@@ -114,7 +116,7 @@ struct ti_sci_info {
114116
u8 host_id;
115117
/* protected by ti_sci_list_mutex */
116118
int users;
117-
119+
bool is_suspending;
118120
};
119121

120122
#define cl_to_ti_sci_info(c) container_of(c, struct ti_sci_info, cl)
@@ -349,6 +351,8 @@ static struct ti_sci_xfer *ti_sci_get_one_xfer(struct ti_sci_info *info,
349351

350352
hdr = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;
351353
xfer->tx_message.len = tx_message_size;
354+
xfer->tx_message.chan_rx = info->chan_rx;
355+
xfer->tx_message.timeout_rx_ms = info->desc->max_rx_timeout_ms;
352356
xfer->rx_len = (u8)rx_message_size;
353357

354358
reinit_completion(&xfer->done);
@@ -406,20 +410,35 @@ static inline int ti_sci_do_xfer(struct ti_sci_info *info,
406410
int ret;
407411
int timeout;
408412
struct device *dev = info->dev;
413+
bool done_state = true;
409414

410415
ret = mbox_send_message(info->chan_tx, &xfer->tx_message);
411416
if (ret < 0)
412417
return ret;
413418

414419
ret = 0;
415420

416-
/* And we wait for the response. */
417-
timeout = msecs_to_jiffies(info->desc->max_rx_timeout_ms);
418-
if (!wait_for_completion_timeout(&xfer->done, timeout)) {
421+
if (!info->is_suspending) {
422+
/* And we wait for the response. */
423+
timeout = msecs_to_jiffies(info->desc->max_rx_timeout_ms);
424+
if (!wait_for_completion_timeout(&xfer->done, timeout))
425+
ret = -ETIMEDOUT;
426+
} else {
427+
/*
428+
* If we are suspending, we cannot use wait_for_completion_timeout
429+
* during noirq phase, so we must manually poll the completion.
430+
*/
431+
ret = read_poll_timeout_atomic(try_wait_for_completion, done_state,
432+
true, 1,
433+
info->desc->max_rx_timeout_ms * 1000,
434+
false, &xfer->done);
435+
}
436+
437+
if (ret == -ETIMEDOUT || !done_state) {
419438
dev_err(dev, "Mbox timedout in resp(caller: %pS)\n",
420439
(void *)_RET_IP_);
421-
ret = -ETIMEDOUT;
422440
}
441+
423442
/*
424443
* NOTE: we might prefer not to need the mailbox ticker to manage the
425444
* transfer queueing since the protocol layer queues things by itself.
@@ -3264,6 +3283,35 @@ static int tisci_reboot_handler(struct notifier_block *nb, unsigned long mode,
32643283
return NOTIFY_BAD;
32653284
}
32663285

3286+
static void ti_sci_set_is_suspending(struct ti_sci_info *info, bool is_suspending)
3287+
{
3288+
info->is_suspending = is_suspending;
3289+
}
3290+
3291+
static int ti_sci_suspend(struct device *dev)
3292+
{
3293+
struct ti_sci_info *info = dev_get_drvdata(dev);
3294+
/*
3295+
* We must switch operation to polled mode now as drivers and the genpd
3296+
* layer may make late TI SCI calls to change clock and device states
3297+
* from the noirq phase of suspend.
3298+
*/
3299+
ti_sci_set_is_suspending(info, true);
3300+
3301+
return 0;
3302+
}
3303+
3304+
static int ti_sci_resume(struct device *dev)
3305+
{
3306+
struct ti_sci_info *info = dev_get_drvdata(dev);
3307+
3308+
ti_sci_set_is_suspending(info, false);
3309+
3310+
return 0;
3311+
}
3312+
3313+
static DEFINE_SIMPLE_DEV_PM_OPS(ti_sci_pm_ops, ti_sci_suspend, ti_sci_resume);
3314+
32673315
/* Description for K2G */
32683316
static const struct ti_sci_desc ti_sci_pmmc_k2g_desc = {
32693317
.default_host_id = 2,
@@ -3472,6 +3520,7 @@ static struct platform_driver ti_sci_driver = {
34723520
.driver = {
34733521
.name = "ti-sci",
34743522
.of_match_table = of_match_ptr(ti_sci_of_match),
3523+
.pm = &ti_sci_pm_ops,
34753524
},
34763525
};
34773526
module_platform_driver(ti_sci_driver);

drivers/reset/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ config RESET_SUNXI
240240

241241
config RESET_TI_SCI
242242
tristate "TI System Control Interface (TI-SCI) reset driver"
243-
depends on TI_SCI_PROTOCOL
243+
depends on TI_SCI_PROTOCOL || COMPILE_TEST
244244
help
245245
This enables the reset driver support over TI System Control Interface
246246
available on some new TI's SoCs. If you wish to use reset resources

drivers/soc/ti/knav_dma.c

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -415,9 +415,8 @@ static int of_channel_match_helper(struct device_node *np, const char *name,
415415
void *knav_dma_open_channel(struct device *dev, const char *name,
416416
struct knav_dma_cfg *config)
417417
{
418-
struct knav_dma_chan *chan;
419-
struct knav_dma_device *dma;
420-
bool found = false;
418+
struct knav_dma_device *dma = NULL, *iter1;
419+
struct knav_dma_chan *chan = NULL, *iter2;
421420
int chan_num = -1;
422421
const char *instance;
423422

@@ -444,33 +443,32 @@ void *knav_dma_open_channel(struct device *dev, const char *name,
444443
}
445444

446445
/* Look for correct dma instance */
447-
list_for_each_entry(dma, &kdev->list, list) {
448-
if (!strcmp(dma->name, instance)) {
449-
found = true;
446+
list_for_each_entry(iter1, &kdev->list, list) {
447+
if (!strcmp(iter1->name, instance)) {
448+
dma = iter1;
450449
break;
451450
}
452451
}
453-
if (!found) {
452+
if (!dma) {
454453
dev_err(kdev->dev, "No DMA instance with name %s\n", instance);
455454
return (void *)-EINVAL;
456455
}
457456

458457
/* Look for correct dma channel from dma instance */
459-
found = false;
460-
list_for_each_entry(chan, &dma->chan_list, list) {
458+
list_for_each_entry(iter2, &dma->chan_list, list) {
461459
if (config->direction == DMA_MEM_TO_DEV) {
462-
if (chan->channel == chan_num) {
463-
found = true;
460+
if (iter2->channel == chan_num) {
461+
chan = iter2;
464462
break;
465463
}
466464
} else {
467-
if (chan->flow == chan_num) {
468-
found = true;
465+
if (iter2->flow == chan_num) {
466+
chan = iter2;
469467
break;
470468
}
471469
}
472470
}
473-
if (!found) {
471+
if (!chan) {
474472
dev_err(kdev->dev, "channel %d is not in DMA %s\n",
475473
chan_num, instance);
476474
return (void *)-EINVAL;
@@ -747,9 +745,8 @@ static int knav_dma_probe(struct platform_device *pdev)
747745
INIT_LIST_HEAD(&kdev->list);
748746

749747
pm_runtime_enable(kdev->dev);
750-
ret = pm_runtime_get_sync(kdev->dev);
748+
ret = pm_runtime_resume_and_get(kdev->dev);
751749
if (ret < 0) {
752-
pm_runtime_put_noidle(kdev->dev);
753750
dev_err(kdev->dev, "unable to enable pktdma, err %d\n", ret);
754751
goto err_pm_disable;
755752
}

drivers/soc/ti/knav_qmss_queue.c

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -758,10 +758,9 @@ void *knav_pool_create(const char *name,
758758
int num_desc, int region_id)
759759
{
760760
struct knav_region *reg_itr, *region = NULL;
761-
struct knav_pool *pool, *pi;
761+
struct knav_pool *pool, *pi = NULL, *iter;
762762
struct list_head *node;
763763
unsigned last_offset;
764-
bool slot_found;
765764
int ret;
766765

767766
if (!kdev)
@@ -790,7 +789,7 @@ void *knav_pool_create(const char *name,
790789
}
791790

792791
pool->queue = knav_queue_open(name, KNAV_QUEUE_GP, 0);
793-
if (IS_ERR_OR_NULL(pool->queue)) {
792+
if (IS_ERR(pool->queue)) {
794793
dev_err(kdev->dev,
795794
"failed to open queue for pool(%s), error %ld\n",
796795
name, PTR_ERR(pool->queue));
@@ -816,18 +815,17 @@ void *knav_pool_create(const char *name,
816815
* the request
817816
*/
818817
last_offset = 0;
819-
slot_found = false;
820818
node = &region->pools;
821-
list_for_each_entry(pi, &region->pools, region_inst) {
822-
if ((pi->region_offset - last_offset) >= num_desc) {
823-
slot_found = true;
819+
list_for_each_entry(iter, &region->pools, region_inst) {
820+
if ((iter->region_offset - last_offset) >= num_desc) {
821+
pi = iter;
824822
break;
825823
}
826-
last_offset = pi->region_offset + pi->num_desc;
824+
last_offset = iter->region_offset + iter->num_desc;
827825
}
828-
node = &pi->region_inst;
829826

830-
if (slot_found) {
827+
if (pi) {
828+
node = &pi->region_inst;
831829
pool->region = region;
832830
pool->num_desc = num_desc;
833831
pool->region_offset = last_offset;
@@ -1785,9 +1783,8 @@ static int knav_queue_probe(struct platform_device *pdev)
17851783
INIT_LIST_HEAD(&kdev->pdsps);
17861784

17871785
pm_runtime_enable(&pdev->dev);
1788-
ret = pm_runtime_get_sync(&pdev->dev);
1786+
ret = pm_runtime_resume_and_get(&pdev->dev);
17891787
if (ret < 0) {
1790-
pm_runtime_put_noidle(&pdev->dev);
17911788
dev_err(dev, "Failed to enable QMSS\n");
17921789
return ret;
17931790
}

drivers/soc/ti/omap_prm.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -941,23 +941,20 @@ static int omap_prm_probe(struct platform_device *pdev)
941941
struct resource *res;
942942
const struct omap_prm_data *data;
943943
struct omap_prm *prm;
944-
const struct of_device_id *match;
945944
int ret;
946945

947946
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
948947
if (!res)
949948
return -ENODEV;
950949

951-
match = of_match_device(omap_prm_id_table, &pdev->dev);
952-
if (!match)
950+
data = of_device_get_match_data(&pdev->dev);
951+
if (!data)
953952
return -ENOTSUPP;
954953

955954
prm = devm_kzalloc(&pdev->dev, sizeof(*prm), GFP_KERNEL);
956955
if (!prm)
957956
return -ENOMEM;
958957

959-
data = match->data;
960-
961958
while (data->base != res->start) {
962959
if (!data->base)
963960
return -EINVAL;

drivers/soc/ti/pm33xx.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -555,11 +555,9 @@ static int am33xx_pm_probe(struct platform_device *pdev)
555555
#endif /* CONFIG_SUSPEND */
556556

557557
pm_runtime_enable(dev);
558-
ret = pm_runtime_get_sync(dev);
559-
if (ret < 0) {
560-
pm_runtime_put_noidle(dev);
558+
ret = pm_runtime_resume_and_get(dev);
559+
if (ret < 0)
561560
goto err_pm_runtime_disable;
562-
}
563561

564562
ret = pm_ops->init(am33xx_do_sram_idle);
565563
if (ret) {

drivers/soc/ti/pruss.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,10 +279,9 @@ static int pruss_probe(struct platform_device *pdev)
279279
platform_set_drvdata(pdev, pruss);
280280

281281
pm_runtime_enable(dev);
282-
ret = pm_runtime_get_sync(dev);
282+
ret = pm_runtime_resume_and_get(dev);
283283
if (ret < 0) {
284284
dev_err(dev, "couldn't enable module\n");
285-
pm_runtime_put_noidle(dev);
286285
goto rpm_disable;
287286
}
288287

drivers/soc/ti/ti_sci_pm_domains.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ static int ti_sci_pm_domain_probe(struct platform_device *pdev)
183183
devm_kcalloc(dev, max_id + 1,
184184
sizeof(*pd_provider->data.domains),
185185
GFP_KERNEL);
186+
if (!pd_provider->data.domains)
187+
return -ENOMEM;
186188

187189
pd_provider->data.num_domains = max_id + 1;
188190
pd_provider->data.xlate = ti_sci_pd_xlate;

0 commit comments

Comments
 (0)