From: Dan Carpenter <dan.carpenter@oracle.com>
To: ming.qian@nxp.com
Cc: linux-media@vger.kernel.org
Subject: [bug report] media: amphion: add vpu core driver
Date: Wed, 9 Mar 2022 13:43:37 +0300 [thread overview]
Message-ID: <20220309104337.GA29869@kili> (raw)
Hello Ming Qian,
The patch 9f599f351e86: "media: amphion: add vpu core driver" from
Feb 24, 2022, leads to the following Smatch static checker warning:
drivers/media/platform/amphion/vpu_core.c:654 vpu_core_probe()
warn: pm_runtime_get_sync() also returns 1 on success
drivers/media/platform/amphion/vpu_core.c
577 static int vpu_core_probe(struct platform_device *pdev)
578 {
579 struct device *dev = &pdev->dev;
580 struct vpu_core *core;
581 struct vpu_dev *vpu = dev_get_drvdata(dev->parent);
582 struct vpu_shared_addr *iface;
583 u32 iface_data_size;
584 int ret;
585
586 dev_dbg(dev, "probe\n");
587 if (!vpu)
588 return -EINVAL;
589 core = devm_kzalloc(dev, sizeof(*core), GFP_KERNEL);
590 if (!core)
591 return -ENOMEM;
592
593 core->pdev = pdev;
594 core->dev = dev;
595 platform_set_drvdata(pdev, core);
596 core->vpu = vpu;
597 INIT_LIST_HEAD(&core->instances);
598 mutex_init(&core->lock);
599 mutex_init(&core->cmd_lock);
600 init_completion(&core->cmp);
601 init_waitqueue_head(&core->ack_wq);
602 core->state = VPU_CORE_DEINIT;
603
604 core->res = of_device_get_match_data(dev);
605 if (!core->res)
606 return -ENODEV;
607
608 core->type = core->res->type;
609 core->id = of_alias_get_id(dev->of_node, "vpu_core");
610 if (core->id < 0) {
611 dev_err(dev, "can't get vpu core id\n");
612 return core->id;
613 }
614 dev_info(core->dev, "[%d] = %s\n", core->id, vpu_core_type_desc(core->type));
615 ret = vpu_core_parse_dt(core, dev->of_node);
616 if (ret)
617 return ret;
618
619 core->base = devm_platform_ioremap_resource(pdev, 0);
620 if (IS_ERR(core->base))
621 return PTR_ERR(core->base);
622
623 if (!vpu_iface_check_codec(core)) {
624 dev_err(core->dev, "is not supported\n");
625 return -EINVAL;
626 }
627
628 ret = vpu_mbox_init(core);
629 if (ret)
630 return ret;
631
632 iface = devm_kzalloc(dev, sizeof(*iface), GFP_KERNEL);
633 if (!iface)
634 return -ENOMEM;
635
636 iface_data_size = vpu_iface_get_data_size(core);
637 if (iface_data_size) {
638 iface->priv = devm_kzalloc(dev, iface_data_size, GFP_KERNEL);
639 if (!iface->priv)
640 return -ENOMEM;
641 }
642
643 ret = vpu_iface_init(core, iface, &core->rpc, core->fw.phys);
644 if (ret) {
645 dev_err(core->dev, "init iface fail, ret = %d\n", ret);
646 return ret;
647 }
648
649 vpu_iface_config_system(core, vpu->res->mreg_base, vpu->base);
650 vpu_iface_set_log_buf(core, &core->log);
651
652 pm_runtime_enable(dev);
653 ret = pm_runtime_get_sync(dev);
--> 654 if (ret) {
^^^
This isn't right.
655 pm_runtime_put_noidle(dev);
656 pm_runtime_set_suspended(dev);
657 goto err_runtime_disable;
658 }
The documentation for pm_runtime_get_sync() suggests using
pm_runtime_resume_and_get() instead. I think you can just do
ret = pm_runtime_resume_and_get(dev);
if (ret)
goto err_runtime_disable;
659
660 ret = vpu_core_register(dev->parent, core);
661 if (ret)
662 goto err_core_register;
663 core->parent = dev->parent;
664
665 pm_runtime_put_sync(dev);
666 vpu_core_create_dbgfs_file(core);
667
668 return 0;
669
670 err_core_register:
671 pm_runtime_put_sync(dev);
672 err_runtime_disable:
673 pm_runtime_disable(dev);
674
675 return ret;
676 }
regards,
dan carpenter
next reply other threads:[~2022-03-09 10:44 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-09 10:43 Dan Carpenter [this message]
2022-03-09 10:45 ` [bug report] media: amphion: add vpu core driver Dan Carpenter
2022-03-09 13:33 ` Hans Verkuil
2022-03-09 15:20 ` Dan Carpenter
2022-03-09 15:43 ` Hans Verkuil
2022-03-10 1:54 ` [EXT] " Ming Qian
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220309104337.GA29869@kili \
--to=dan.carpenter@oracle.com \
--cc=linux-media@vger.kernel.org \
--cc=ming.qian@nxp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.