History

Merge tag 'char-misc-7.1-final' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc

Pull char/misc driver fixes from Greg KH: "Here are some small driver fixes for 7.1-final to resolve some reported issues. Included in here are: - slimbus qcom driver bugfixes - nvmem driver bugfixes - fastrpc driver bugfixes - stratix10 firmware driver bugfixes All of these have been in linux-next for over a week with no reported issues" * tag 'char-misc-7.1-final' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: misc: fastrpc: fix use-after-free race in fastrpc_map_create misc: fastrpc: Fix NULL pointer dereference in rpmsg callback misc: fastrpc: fix DMA address corruption due to find_vma misuse misc: fastrpc: fix use-after-free of fastrpc_user in workqueue context slimbus: qcom-ngd-ctrl: Avoid ABBA on tx_lock/ctrl->lock slimbus: qcom-ngd-ctrl: Balance pm_runtime enablement for NGD slimbus: qcom-ngd-ctrl: Initialize controller resources in controller slimbus: qcom-ngd-ctrl: Register callbacks after creating the ngd slimbus: qcom-ngd-ctrl: Correct PDR and SSR cleanup ownership slimbus: qcom-ngd-ctrl: Fix probe error path ordering slimbus: qcom-ngd-ctrl: Fix up platform_driver registration slimbus: qcom-ngd-ctrl: fix OF node refcount nvmem: core: fix use-after-free bugs in error paths nvmem: layouts: onie-tlv: fix hang on unknown types firmware: stratix10-rsu: Fix NULL deref on rsu_send_msg() timeout in probe firmware: stratix10-svc: Don't fail probe when async ops unsupported firmware: stratix10-svc: Return -EOPNOTSUPP when ATF async unsupported

Linus Torvalds committed 5 months ago

Commit 9a837ef2 parents 1dadb7e 07ebe876 files · +189 −121Browse files

Unified · Split

6 files
  1. drivers/firmware/stratix10-rsu.c +20 −25
  2. drivers/firmware/stratix10-svc.c +17 −4
  3. drivers/misc/fastrpc.c +68 −39
  4. drivers/nvmem/core.c +5 −7
  5. drivers/nvmem/layouts/onie-tlv.c +2 −1
  6. drivers/slimbus/qcom-ngd-ctrl.c +77 −45
drivers/firmware/stratix10-rsu.c+20−25
@@ -723,15 +723,9 @@ static int stratix10_rsu_probe(struct platform_device *pdev) · 722 unmodified lines
723 return -ENOMEM;723 return -ENOMEM;
724 724
725 priv->client.dev = dev;725 priv->client.dev = dev;
726 priv->client.receive_cb = NULL;
727 priv->client.priv = priv;726 priv->client.priv = priv;
728 priv->status.current_image = 0;
729 priv->status.fail_image = 0;
730 priv->status.error_location = 0;
731 priv->status.error_details = 0;
732 priv->status.version = 0;
733 priv->status.state = 0;
734 priv->retry_counter = INVALID_RETRY_COUNTER;727 priv->retry_counter = INVALID_RETRY_COUNTER;
728 priv->max_retry = INVALID_RETRY_COUNTER;
735 priv->dcmf_version.dcmf0 = INVALID_DCMF_VERSION;729 priv->dcmf_version.dcmf0 = INVALID_DCMF_VERSION;
736 priv->dcmf_version.dcmf1 = INVALID_DCMF_VERSION;730 priv->dcmf_version.dcmf1 = INVALID_DCMF_VERSION;
737 priv->dcmf_version.dcmf2 = INVALID_DCMF_VERSION;731 priv->dcmf_version.dcmf2 = INVALID_DCMF_VERSION;
@@ -740,11 +734,11 @@ static int stratix10_rsu_probe(struct platform_device *pdev) · 2 unmodified lines
740 priv->dcmf_status.dcmf1 = INVALID_DCMF_STATUS;734 priv->dcmf_status.dcmf1 = INVALID_DCMF_STATUS;
741 priv->dcmf_status.dcmf2 = INVALID_DCMF_STATUS;735 priv->dcmf_status.dcmf2 = INVALID_DCMF_STATUS;
742 priv->dcmf_status.dcmf3 = INVALID_DCMF_STATUS;736 priv->dcmf_status.dcmf3 = INVALID_DCMF_STATUS;
743 priv->max_retry = INVALID_RETRY_COUNTER;737 /* spt0/1_address and status fields default to 0 from kzalloc */
744 priv->spt0_address = INVALID_SPT_ADDRESS;
745 priv->spt1_address = INVALID_SPT_ADDRESS;
746 738
747 mutex_init(&priv->lock);739 mutex_init(&priv->lock);
740 init_completion(&priv->completion);
741
748 priv->chan = stratix10_svc_request_channel_byname(&priv->client,742 priv->chan = stratix10_svc_request_channel_byname(&priv->client,
749 SVC_CLIENT_RSU);743 SVC_CLIENT_RSU);
750 if (IS_ERR(priv->chan)) {744 if (IS_ERR(priv->chan)) {
@@ -756,11 +750,9 @@ static int stratix10_rsu_probe(struct platform_device *pdev) · 5 unmodified lines
756 ret = stratix10_svc_add_async_client(priv->chan, false);750 ret = stratix10_svc_add_async_client(priv->chan, false);
757 if (ret) {751 if (ret) {
758 dev_err(dev, "failed to add async client\n");752 dev_err(dev, "failed to add async client\n");
759 stratix10_svc_free_channel(priv->chan);753 goto free_channel;
760 return ret;
761 }754 }
762 755
763 init_completion(&priv->completion);
764 platform_set_drvdata(pdev, priv);756 platform_set_drvdata(pdev, priv);
765 757
766 /* get the initial state from firmware */758 /* get the initial state from firmware */
@@ -768,41 +760,44 @@ static int stratix10_rsu_probe(struct platform_device *pdev) · 1 unmodified line
768 rsu_async_status_callback);760 rsu_async_status_callback);
769 if (ret) {761 if (ret) {
770 dev_err(dev, "Error, getting RSU status %i\n", ret);762 dev_err(dev, "Error, getting RSU status %i\n", ret);
771 stratix10_svc_remove_async_client(priv->chan);763 goto remove_async_client;
772 stratix10_svc_free_channel(priv->chan);
773 return ret;
774 }764 }
775 765
776 /* get DCMF version from firmware */766 /* get DCMF version from firmware */
777 ret = rsu_send_msg(priv, COMMAND_RSU_DCMF_VERSION,767 ret = rsu_send_msg(priv, COMMAND_RSU_DCMF_VERSION, 0,
778 0, rsu_dcmf_version_callback);768 rsu_dcmf_version_callback);
779 if (ret) {769 if (ret) {
780 dev_err(dev, "Error, getting DCMF version %i\n", ret);770 dev_err(dev, "Error, getting DCMF version %i\n", ret);
781 stratix10_svc_free_channel(priv->chan);771 goto remove_async_client;
782 }772 }
783 773
784 ret = rsu_send_msg(priv, COMMAND_RSU_DCMF_STATUS,774 ret = rsu_send_msg(priv, COMMAND_RSU_DCMF_STATUS, 0,
785 0, rsu_dcmf_status_callback);775 rsu_dcmf_status_callback);
786 if (ret) {776 if (ret) {
787 dev_err(dev, "Error, getting DCMF status %i\n", ret);777 dev_err(dev, "Error, getting DCMF status %i\n", ret);
788 stratix10_svc_free_channel(priv->chan);778 goto remove_async_client;
789 }779 }
790 780
791 ret = rsu_send_msg(priv, COMMAND_RSU_MAX_RETRY, 0,781 ret = rsu_send_msg(priv, COMMAND_RSU_MAX_RETRY, 0,
792 rsu_max_retry_callback);782 rsu_max_retry_callback);
793 if (ret) {783 if (ret) {
794 dev_err(dev, "Error, getting RSU max retry %i\n", ret);784 dev_err(dev, "Error, getting RSU max retry %i\n", ret);
795 stratix10_svc_free_channel(priv->chan);785 goto remove_async_client;
796 }786 }
797 787
798
799 ret = rsu_send_async_msg(dev, priv, COMMAND_RSU_GET_SPT_TABLE, 0,788 ret = rsu_send_async_msg(dev, priv, COMMAND_RSU_GET_SPT_TABLE, 0,
800 rsu_async_get_spt_table_callback);789 rsu_async_get_spt_table_callback);
801 if (ret) {790 if (ret) {
802 dev_err(dev, "Error, getting SPT table %i\n", ret);791 dev_err(dev, "Error, getting SPT table %i\n", ret);
803 stratix10_svc_free_channel(priv->chan);792 goto remove_async_client;
804 }793 }
805 794
795 return 0;
796
797remove_async_client:
798 stratix10_svc_remove_async_client(priv->chan);
799free_channel:
800 stratix10_svc_free_channel(priv->chan);
806 return ret;801 return ret;
807}802}
808 803
drivers/firmware/stratix10-svc.c+17−4
@@ -212,6 +212,7 @@ struct stratix10_async_chan { · 211 unmodified lines
212/**212/**
213 * struct stratix10_async_ctrl - Control structure for Stratix10213 * struct stratix10_async_ctrl - Control structure for Stratix10
214 * asynchronous operations214 * asynchronous operations
215 * @supported: Flag indicating whether the system supports async operations
215 * @initialized: Flag indicating whether the control structure has216 * @initialized: Flag indicating whether the control structure has
216 * been initialized217 * been initialized
217 * @invoke_fn: Function pointer for invoking Stratix10 service calls218 * @invoke_fn: Function pointer for invoking Stratix10 service calls
@@ -228,6 +229,7 @@ struct stratix10_async_chan { · 10 unmodified lines
228 */229 */
229 230
230struct stratix10_async_ctrl {231struct stratix10_async_ctrl {
232 bool supported;
231 bool initialized;233 bool initialized;
232 void (*invoke_fn)(struct stratix10_async_ctrl *actrl,234 void (*invoke_fn)(struct stratix10_async_ctrl *actrl,
233 const struct arm_smccc_1_2_regs *args,235 const struct arm_smccc_1_2_regs *args,
@@ -1103,6 +1105,7 @@ EXPORT_SYMBOL_GPL(stratix10_svc_request_channel_byname); · 869 unmodified lines
1103 * Return: 0 on success, or a negative error code on failure:1105 * Return: 0 on success, or a negative error code on failure:
1104 * -EINVAL if the channel is NULL or the async controller is1106 * -EINVAL if the channel is NULL or the async controller is
1105 * not initialized.1107 * not initialized.
1108 * -EOPNOTSUPP if async operations are not supported.
1106 * -EALREADY if the async channel is already allocated.1109 * -EALREADY if the async channel is already allocated.
1107 * -ENOMEM if memory allocation fails.1110 * -ENOMEM if memory allocation fails.
1108 * Other negative values if ID allocation fails.1111 * Other negative values if ID allocation fails.
@@ -1121,6 +1124,9 @@ int stratix10_svc_add_async_client(struct stratix10_svc_chan *chan, · 12 unmodified lines
1121 ctrl = chan->ctrl;1124 ctrl = chan->ctrl;
1122 actrl = &ctrl->actrl;1125 actrl = &ctrl->actrl;
1123 1126
1127 if (!actrl->supported)
1128 return -EOPNOTSUPP;
1129
1124 if (!actrl->initialized) {1130 if (!actrl->initialized) {
1125 dev_err(ctrl->dev, "Async controller not initialized\n");1131 dev_err(ctrl->dev, "Async controller not initialized\n");
1126 return -EINVAL;1132 return -EINVAL;
@@ -1562,6 +1568,7 @@ static inline void stratix10_smc_1_2(struct stratix10_async_ctrl *actrl, · 435 unmodified lines
1562 * initialized, -ENOMEM if memory allocation fails,1568 * initialized, -ENOMEM if memory allocation fails,
1563 * -EADDRINUSE if the client ID is already reserved, or other1569 * -EADDRINUSE if the client ID is already reserved, or other
1564 * negative error codes on failure.1570 * negative error codes on failure.
1571 * -EOPNOTSUPP if system doesn't support async operations.
1565 */1572 */
1566static int stratix10_svc_async_init(struct stratix10_svc_controller *controller)1573static int stratix10_svc_async_init(struct stratix10_svc_controller *controller)
1567{1574{
@@ -1585,10 +1592,12 @@ static int stratix10_svc_async_init(struct stratix10_svc_controller *controller) · 17 unmodified lines
1585 !(res.a1 > ASYNC_ATF_MINIMUM_MAJOR_VERSION ||1592 !(res.a1 > ASYNC_ATF_MINIMUM_MAJOR_VERSION ||
1586 (res.a1 == ASYNC_ATF_MINIMUM_MAJOR_VERSION &&1593 (res.a1 == ASYNC_ATF_MINIMUM_MAJOR_VERSION &&
1587 res.a2 >= ASYNC_ATF_MINIMUM_MINOR_VERSION))) {1594 res.a2 >= ASYNC_ATF_MINIMUM_MINOR_VERSION))) {
1588 dev_err(dev,1595 dev_info(dev,
1589 "Intel Service Layer Driver: ATF version is not compatible for async operation\n");1596 "Intel Service Layer Driver: ATF version is not compatible for async operation\n");
1590 return -EINVAL;1597 actrl->supported = false;
1598 return -EOPNOTSUPP;
1591 }1599 }
1600 actrl->supported = true;
1592 1601
1593 actrl->invoke_fn = stratix10_smc_1_2;1602 actrl->invoke_fn = stratix10_smc_1_2;
1594 1603
@@ -1952,10 +1961,14 @@ static int stratix10_svc_drv_probe(struct platform_device *pdev) · 357 unmodified lines
1952 init_completion(&controller->complete_status);1961 init_completion(&controller->complete_status);
1953 1962
1954 ret = stratix10_svc_async_init(controller);1963 ret = stratix10_svc_async_init(controller);
1955 if (ret) {1964 if (ret == -EOPNOTSUPP) {
1965 dev_info(dev, "Intel Service Layer Driver Initialized (sync-only mode)\n");
1966 } else if (ret) {
1956 dev_dbg(dev, "Intel Service Layer Driver: Error on stratix10_svc_async_init %d\n",1967 dev_dbg(dev, "Intel Service Layer Driver: Error on stratix10_svc_async_init %d\n",
1957 ret);1968 ret);
1958 goto err_destroy_pool;1969 goto err_destroy_pool;
1970 } else {
1971 dev_info(dev, "Intel Service Layer Driver Initialized\n");
1959 }1972 }
1960 1973
1961 fifo_size = sizeof(struct stratix10_svc_data) * SVC_NUM_DATA_IN_FIFO;1974 fifo_size = sizeof(struct stratix10_svc_data) * SVC_NUM_DATA_IN_FIFO;
drivers/misc/fastrpc.c+68−39
@@ -310,6 +310,8 @@ struct fastrpc_user { · 309 unmodified lines
310 spinlock_t lock;310 spinlock_t lock;
311 /* lock for allocations */311 /* lock for allocations */
312 struct mutex mutex;312 struct mutex mutex;
313 /* Reference count */
314 struct kref refcount;
313};315};
314 316
315/* Extract SMMU PA from consolidated IOVA */317/* Extract SMMU PA from consolidated IOVA */
@@ -386,7 +388,7 @@ static int fastrpc_map_get(struct fastrpc_map *map) · 70 unmodified lines
386 388
387 389
388static int fastrpc_map_lookup(struct fastrpc_user *fl, int fd,390static int fastrpc_map_lookup(struct fastrpc_user *fl, int fd,
389 struct fastrpc_map **ppmap)391 struct fastrpc_map **ppmap, bool take_ref)
390{392{
391 struct fastrpc_map *map = NULL;393 struct fastrpc_map *map = NULL;
392 struct dma_buf *buf;394 struct dma_buf *buf;
@@ -401,6 +403,12 @@ static int fastrpc_map_lookup(struct fastrpc_user *fl, int fd, · 8 unmodified lines
401 if (map->fd != fd || map->buf != buf)403 if (map->fd != fd || map->buf != buf)
402 continue;404 continue;
403 405
406 if (take_ref) {
407 ret = fastrpc_map_get(map);
408 if (ret)
409 break;
410 }
411
404 *ppmap = map;412 *ppmap = map;
405 ret = 0;413 ret = 0;
406 break;414 break;
@@ -497,15 +505,57 @@ static void fastrpc_channel_ctx_put(struct fastrpc_channel_ctx *cctx) · 90 unmodified lines
497 kref_put(&cctx->refcount, fastrpc_channel_ctx_free);505 kref_put(&cctx->refcount, fastrpc_channel_ctx_free);
498}506}
499 507
508static void fastrpc_context_put(struct fastrpc_invoke_ctx *ctx);
509
510static void fastrpc_user_free(struct kref *ref)
511{
512 struct fastrpc_user *fl = container_of(ref, struct fastrpc_user, refcount);
513 struct fastrpc_invoke_ctx *ctx, *n;
514 struct fastrpc_map *map, *m;
515 struct fastrpc_buf *buf, *b;
516
517 if (fl->init_mem)
518 fastrpc_buf_free(fl->init_mem);
519
520 list_for_each_entry_safe(ctx, n, &fl->pending, node) {
521 list_del(&ctx->node);
522 fastrpc_context_put(ctx);
523 }
524
525 list_for_each_entry_safe(map, m, &fl->maps, node)
526 fastrpc_map_put(map);
527
528 list_for_each_entry_safe(buf, b, &fl->mmaps, node) {
529 list_del(&buf->node);
530 fastrpc_buf_free(buf);
531 }
532
533 fastrpc_channel_ctx_put(fl->cctx);
534 mutex_destroy(&fl->mutex);
535 kfree(fl);
536}
537
538static void fastrpc_user_get(struct fastrpc_user *fl)
539{
540 kref_get(&fl->refcount);
541}
542
543static void fastrpc_user_put(struct fastrpc_user *fl)
544{
545 kref_put(&fl->refcount, fastrpc_user_free);
546}
547
500static void fastrpc_context_free(struct kref *ref)548static void fastrpc_context_free(struct kref *ref)
501{549{
502 struct fastrpc_invoke_ctx *ctx;550 struct fastrpc_invoke_ctx *ctx;
503 struct fastrpc_channel_ctx *cctx;551 struct fastrpc_channel_ctx *cctx;
552 struct fastrpc_user *fl;
504 unsigned long flags;553 unsigned long flags;
505 int i;554 int i;
506 555
507 ctx = container_of(ref, struct fastrpc_invoke_ctx, refcount);556 ctx = container_of(ref, struct fastrpc_invoke_ctx, refcount);
508 cctx = ctx->cctx;557 cctx = ctx->cctx;
558 fl = ctx->fl;
509 559
510 for (i = 0; i < ctx->nbufs; i++)560 for (i = 0; i < ctx->nbufs; i++)
511 fastrpc_map_put(ctx->maps[i]);561 fastrpc_map_put(ctx->maps[i]);
@@ -521,6 +571,8 @@ static void fastrpc_context_free(struct kref *ref) · 9 unmodified lines
521 kfree(ctx->olaps);571 kfree(ctx->olaps);
522 kfree(ctx);572 kfree(ctx);
523 573
574 /* Release the reference taken in fastrpc_context_alloc() */
575 fastrpc_user_put(fl);
524 fastrpc_channel_ctx_put(cctx);576 fastrpc_channel_ctx_put(cctx);
525}577}
526 578
@@ -628,6 +680,8 @@ static struct fastrpc_invoke_ctx *fastrpc_context_alloc( · 101 unmodified lines
628 680
629 /* Released in fastrpc_context_put() */681 /* Released in fastrpc_context_put() */
630 fastrpc_channel_ctx_get(cctx);682 fastrpc_channel_ctx_get(cctx);
683 /* Take a reference to user, released in fastrpc_context_free() */
684 fastrpc_user_get(user);
631 685
632 ctx->sc = sc;686 ctx->sc = sc;
633 ctx->retval = -1;687 ctx->retval = -1;
@@ -658,6 +712,7 @@ err_idr: · 24 unmodified lines
658 spin_lock(&user->lock);712 spin_lock(&user->lock);
659 list_del(&ctx->node);713 list_del(&ctx->node);
660 spin_unlock(&user->lock);714 spin_unlock(&user->lock);
715 fastrpc_user_put(user);
661 fastrpc_channel_ctx_put(cctx);716 fastrpc_channel_ctx_put(cctx);
662 kfree(ctx->maps);717 kfree(ctx->maps);
663 kfree(ctx->olaps);718 kfree(ctx->olaps);
@@ -871,19 +926,10 @@ get_err: · 207 unmodified lines
871static int fastrpc_map_create(struct fastrpc_user *fl, int fd,926static int fastrpc_map_create(struct fastrpc_user *fl, int fd,
872 u64 len, u32 attr, struct fastrpc_map **ppmap)927 u64 len, u32 attr, struct fastrpc_map **ppmap)
873{928{
874 struct fastrpc_session_ctx *sess = fl->sctx;929 if (!fastrpc_map_lookup(fl, fd, ppmap, true))
875 int err = 0;930 return 0;
876
877 if (!fastrpc_map_lookup(fl, fd, ppmap)) {
878 if (!fastrpc_map_get(*ppmap))
879 return 0;
880 dev_dbg(sess->dev, "%s: Failed to get map fd=%d\n",
881 __func__, fd);
882 }
883
884 err = fastrpc_map_attach(fl, fd, len, attr, ppmap);
885 931
886 return err;932 return fastrpc_map_attach(fl, fd, len, attr, ppmap);
887}933}
888 934
889/*935/*
@@ -1041,7 +1087,7 @@ static int fastrpc_get_args(u32 kernel, struct fastrpc_invoke_ctx *ctx) · 151 unmodified lines
1041 pages[i].addr = ctx->maps[i]->dma_addr;1087 pages[i].addr = ctx->maps[i]->dma_addr;
1042 1088
1043 mmap_read_lock(current->mm);1089 mmap_read_lock(current->mm);
1044 vma = find_vma(current->mm, ctx->args[i].ptr);1090 vma = vma_lookup(current->mm, ctx->args[i].ptr);
1045 if (vma)1091 if (vma)
1046 pages[i].addr += (ctx->args[i].ptr & PAGE_MASK) -1092 pages[i].addr += (ctx->args[i].ptr & PAGE_MASK) -
1047 vma->vm_start;1093 vma->vm_start;
@@ -1153,7 +1199,7 @@ cleanup_fdlist: · 105 unmodified lines
1153 for (i = 0; i < FASTRPC_MAX_FDLIST; i++) {1199 for (i = 0; i < FASTRPC_MAX_FDLIST; i++) {
1154 if (!fdlist[i])1200 if (!fdlist[i])
1155 break;1201 break;
1156 if (!fastrpc_map_lookup(fl, (int)fdlist[i], &mmap))1202 if (!fastrpc_map_lookup(fl, (int)fdlist[i], &mmap, false))
1157 fastrpc_map_put(mmap);1203 fastrpc_map_put(mmap);
1158 }1204 }
1159 1205
@@ -1579,9 +1625,6 @@ static int fastrpc_device_release(struct inode *inode, struct file *file) · 419 unmodified lines
1579{1625{
1580 struct fastrpc_user *fl = (struct fastrpc_user *)file->private_data;1626 struct fastrpc_user *fl = (struct fastrpc_user *)file->private_data;
1581 struct fastrpc_channel_ctx *cctx = fl->cctx;1627 struct fastrpc_channel_ctx *cctx = fl->cctx;
1582 struct fastrpc_invoke_ctx *ctx, *n;
1583 struct fastrpc_map *map, *m;
1584 struct fastrpc_buf *buf, *b;
1585 unsigned long flags;1628 unsigned long flags;
1586 1629
1587 fastrpc_release_current_dsp_process(fl);1630 fastrpc_release_current_dsp_process(fl);
@@ -1590,28 +1633,10 @@ static int fastrpc_device_release(struct inode *inode, struct file *file) · 2 unmodified lines
1590 list_del(&fl->user);1633 list_del(&fl->user);
1591 spin_unlock_irqrestore(&cctx->lock, flags);1634 spin_unlock_irqrestore(&cctx->lock, flags);
1592 1635
1593 if (fl->init_mem)
1594 fastrpc_buf_free(fl->init_mem);
1595
1596 list_for_each_entry_safe(ctx, n, &fl->pending, node) {
1597 list_del(&ctx->node);
1598 fastrpc_context_put(ctx);
1599 }
1600
1601 list_for_each_entry_safe(map, m, &fl->maps, node)
1602 fastrpc_map_put(map);
1603
1604 list_for_each_entry_safe(buf, b, &fl->mmaps, node) {
1605 list_del(&buf->node);
1606 fastrpc_buf_free(buf);
1607 }
1608
1609 fastrpc_session_free(cctx, fl->sctx);1636 fastrpc_session_free(cctx, fl->sctx);
1610 fastrpc_channel_ctx_put(cctx);
1611
1612 mutex_destroy(&fl->mutex);
1613 kfree(fl);
1614 file->private_data = NULL;1637 file->private_data = NULL;
1638 /* Release the reference taken in fastrpc_device_open */
1639 fastrpc_user_put(fl);
1615 1640
1616 return 0;1641 return 0;
1617}1642}
@@ -1655,6 +1680,7 @@ static int fastrpc_device_open(struct inode *inode, struct file *filp) · 37 unmodified lines
1655 spin_lock_irqsave(&cctx->lock, flags);1680 spin_lock_irqsave(&cctx->lock, flags);
1656 list_add_tail(&fl->user, &cctx->users);1681 list_add_tail(&fl->user, &cctx->users);
1657 spin_unlock_irqrestore(&cctx->lock, flags);1682 spin_unlock_irqrestore(&cctx->lock, flags);
1683 kref_init(&fl->refcount);
1658 1684
1659 return 0;1685 return 0;
1660}1686}
@@ -2431,7 +2457,6 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev) · 770 unmodified lines
2431 2457
2432 kref_init(&data->refcount);2458 kref_init(&data->refcount);
2433 2459
2434 dev_set_drvdata(&rpdev->dev, data);
2435 rdev->dma_mask = &data->dma_mask;2460 rdev->dma_mask = &data->dma_mask;
2436 dma_set_mask_and_coherent(rdev, DMA_BIT_MASK(32));2461 dma_set_mask_and_coherent(rdev, DMA_BIT_MASK(32));
2437 INIT_LIST_HEAD(&data->users);2462 INIT_LIST_HEAD(&data->users);
@@ -2440,6 +2465,7 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev) · 2 unmodified lines
2440 idr_init(&data->ctx_idr);2465 idr_init(&data->ctx_idr);
2441 data->domain_id = domain_id;2466 data->domain_id = domain_id;
2442 data->rpdev = rpdev;2467 data->rpdev = rpdev;
2468 dev_set_drvdata(&rpdev->dev, data);
2443 2469
2444 err = of_platform_populate(rdev->of_node, NULL, NULL, rdev);2470 err = of_platform_populate(rdev->of_node, NULL, NULL, rdev);
2445 if (err)2471 if (err)
@@ -2513,6 +2539,9 @@ static int fastrpc_rpmsg_callback(struct rpmsg_device *rpdev, void *data, · 67 unmodified lines
2513 if (len < sizeof(*rsp))2539 if (len < sizeof(*rsp))
2514 return -EINVAL;2540 return -EINVAL;
2515 2541
2542 if (!cctx)
2543 return -ENODEV;
2544
2516 ctxid = ((rsp->ctx & FASTRPC_CTXID_MASK) >> 4);2545 ctxid = ((rsp->ctx & FASTRPC_CTXID_MASK) >> 4);
2517 2546
2518 spin_lock_irqsave(&cctx->lock, flags);2547 spin_lock_irqsave(&cctx->lock, flags);
drivers/nvmem/core.c+5−7
@@ -1468,18 +1468,16 @@ struct nvmem_cell *of_nvmem_cell_get(struct device_node *np, const char *id) · 1467 unmodified lines
1468 cell_entry = nvmem_find_cell_entry_by_node(nvmem, cell_np);1468 cell_entry = nvmem_find_cell_entry_by_node(nvmem, cell_np);
1469 of_node_put(cell_np);1469 of_node_put(cell_np);
1470 if (!cell_entry) {1470 if (!cell_entry) {
1471 __nvmem_device_put(nvmem);
1472 nvmem_layout_module_put(nvmem);1471 nvmem_layout_module_put(nvmem);
1473 if (nvmem->layout)1472 ret = nvmem->layout ? -EPROBE_DEFER : -ENOENT;
1474 return ERR_PTR(-EPROBE_DEFER);1473 __nvmem_device_put(nvmem);
1475 else1474 return ERR_PTR(ret);
1476 return ERR_PTR(-ENOENT);
1477 }1475 }
1478 1476
1479 cell = nvmem_create_cell(cell_entry, id, cell_index);1477 cell = nvmem_create_cell(cell_entry, id, cell_index);
1480 if (IS_ERR(cell)) {1478 if (IS_ERR(cell)) {
1481 __nvmem_device_put(nvmem);
1482 nvmem_layout_module_put(nvmem);1479 nvmem_layout_module_put(nvmem);
1480 __nvmem_device_put(nvmem);
1483 }1481 }
1484 1482
1485 return cell;1483 return cell;
@@ -1593,8 +1591,8 @@ void nvmem_cell_put(struct nvmem_cell *cell) · 107 unmodified lines
1593 kfree_const(cell->id);1591 kfree_const(cell->id);
1594 1592
1595 kfree(cell);1593 kfree(cell);
1596 __nvmem_device_put(nvmem);
1597 nvmem_layout_module_put(nvmem);1594 nvmem_layout_module_put(nvmem);
1595 __nvmem_device_put(nvmem);
1598}1596}
1599EXPORT_SYMBOL_GPL(nvmem_cell_put);1597EXPORT_SYMBOL_GPL(nvmem_cell_put);
1600 1598
drivers/nvmem/layouts/onie-tlv.c+2−1
@@ -119,7 +119,7 @@ static int onie_tlv_add_cells(struct device *dev, struct nvmem_device *nvmem, · 118 unmodified lines
119 119
120 cell.name = onie_tlv_cell_name(tlv.type);120 cell.name = onie_tlv_cell_name(tlv.type);
121 if (!cell.name)121 if (!cell.name)
122 continue;122 goto next;
123 123
124 cell.offset = hdr_len + offset + sizeof(tlv.type) + sizeof(tlv.len);124 cell.offset = hdr_len + offset + sizeof(tlv.type) + sizeof(tlv.len);
125 cell.bytes = tlv.len;125 cell.bytes = tlv.len;
@@ -132,6 +132,7 @@ static int onie_tlv_add_cells(struct device *dev, struct nvmem_device *nvmem, · 6 unmodified lines
132 return ret;132 return ret;
133 }133 }
134 134
135next:
135 offset += sizeof(tlv) + tlv.len;136 offset += sizeof(tlv) + tlv.len;
136 }137 }
137 138
drivers/slimbus/qcom-ngd-ctrl.c+77−45
@@ -1471,15 +1471,12 @@ static int qcom_slim_ngd_ssr_pdr_notify(struct qcom_slim_ngd_ctrl *ctrl, · 1470 unmodified lines
1471 switch (action) {1471 switch (action) {
1472 case QCOM_SSR_BEFORE_SHUTDOWN:1472 case QCOM_SSR_BEFORE_SHUTDOWN:
1473 case SERVREG_SERVICE_STATE_DOWN:1473 case SERVREG_SERVICE_STATE_DOWN:
1474 /* Make sure the last dma xfer is finished */
1475 mutex_lock(&ctrl->tx_lock);
1476 if (ctrl->state != QCOM_SLIM_NGD_CTRL_DOWN) {1474 if (ctrl->state != QCOM_SLIM_NGD_CTRL_DOWN) {
1477 pm_runtime_get_noresume(ctrl->ctrl.dev);1475 pm_runtime_get_noresume(ctrl->ctrl.dev);
1478 ctrl->state = QCOM_SLIM_NGD_CTRL_DOWN;1476 ctrl->state = QCOM_SLIM_NGD_CTRL_DOWN;
1479 qcom_slim_ngd_down(ctrl);1477 qcom_slim_ngd_down(ctrl);
1480 qcom_slim_ngd_exit_dma(ctrl);1478 qcom_slim_ngd_exit_dma(ctrl);
1481 }1479 }
1482 mutex_unlock(&ctrl->tx_lock);
1483 break;1480 break;
1484 case QCOM_SSR_AFTER_POWERUP:1481 case QCOM_SSR_AFTER_POWERUP:
1485 case SERVREG_SERVICE_STATE_UP:1482 case SERVREG_SERVICE_STATE_UP:
@@ -1542,7 +1539,7 @@ static int of_qcom_slim_ngd_register(struct device *parent, · 56 unmodified lines
1542 kfree(ngd);1539 kfree(ngd);
1543 return ret;1540 return ret;
1544 }1541 }
1545 ngd->pdev->dev.of_node = node;1542 ngd->pdev->dev.of_node = of_node_get(node);
1546 ctrl->ngd = ngd;1543 ctrl->ngd = ngd;
1547 1544
1548 ret = platform_device_add(ngd->pdev);1545 ret = platform_device_add(ngd->pdev);
@@ -1560,6 +1557,13 @@ static int of_qcom_slim_ngd_register(struct device *parent, · 11 unmodified lines
1560 return -ENODEV;1557 return -ENODEV;
1561}1558}
1562 1559
1560static void qcom_slim_ngd_unregister(struct qcom_slim_ngd_ctrl *ctrl)
1561{
1562 struct qcom_slim_ngd *ngd = ctrl->ngd;
1563
1564 platform_device_del(ngd->pdev);
1565}
1566
1563static int qcom_slim_ngd_probe(struct platform_device *pdev)1567static int qcom_slim_ngd_probe(struct platform_device *pdev)
1564{1568{
1565 struct device *dev = &pdev->dev;1569 struct device *dev = &pdev->dev;
@@ -1577,24 +1581,10 @@ static int qcom_slim_ngd_probe(struct platform_device *pdev) · 11 unmodified lines
1577 ret = qcom_slim_ngd_qmi_svc_event_init(ctrl);1581 ret = qcom_slim_ngd_qmi_svc_event_init(ctrl);
1578 if (ret) {1582 if (ret) {
1579 dev_err(&pdev->dev, "QMI service registration failed:%d", ret);1583 dev_err(&pdev->dev, "QMI service registration failed:%d", ret);
1580 return ret;1584 pm_runtime_dont_use_autosuspend(dev);
1585 pm_runtime_disable(dev);
1581 }1586 }
1582 1587
1583 INIT_WORK(&ctrl->m_work, qcom_slim_ngd_master_worker);
1584 INIT_WORK(&ctrl->ngd_up_work, qcom_slim_ngd_up_worker);
1585 ctrl->mwq = create_singlethread_workqueue("ngd_master");
1586 if (!ctrl->mwq) {
1587 dev_err(&pdev->dev, "Failed to start master worker\n");
1588 ret = -ENOMEM;
1589 goto wq_err;
1590 }
1591
1592 return 0;
1593wq_err:
1594 qcom_slim_ngd_qmi_svc_event_deinit(&ctrl->qmi);
1595 if (ctrl->mwq)
1596 destroy_workqueue(ctrl->mwq);
1597
1598 return ret;1588 return ret;
1599}1589}
1600 1590
@@ -1602,6 +1592,7 @@ static int qcom_slim_ngd_ctrl_probe(struct platform_device *pdev) · 1 unmodified line
1602{1592{
1603 struct device *dev = &pdev->dev;1593 struct device *dev = &pdev->dev;
1604 struct qcom_slim_ngd_ctrl *ctrl;1594 struct qcom_slim_ngd_ctrl *ctrl;
1595 int irq;
1605 int ret;1596 int ret;
1606 struct pdr_service *pds;1597 struct pdr_service *pds;
1607 1598
@@ -1615,20 +1606,16 @@ static int qcom_slim_ngd_ctrl_probe(struct platform_device *pdev) · 7 unmodified lines
1615 if (IS_ERR(ctrl->base))1606 if (IS_ERR(ctrl->base))
1616 return PTR_ERR(ctrl->base);1607 return PTR_ERR(ctrl->base);
1617 1608
1618 ret = platform_get_irq(pdev, 0);1609 irq = platform_get_irq(pdev, 0);
1619 if (ret < 0)1610 if (irq < 0)
1620 return ret;1611 return irq;
1621 1612
1622 ret = devm_request_irq(dev, ret, qcom_slim_ngd_interrupt,1613 ret = devm_request_irq(dev, irq, qcom_slim_ngd_interrupt,
1623 IRQF_TRIGGER_HIGH, "slim-ngd", ctrl);1614 IRQF_TRIGGER_HIGH | IRQF_NO_AUTOEN,
1615 "slim-ngd", ctrl);
1624 if (ret)1616 if (ret)
1625 return dev_err_probe(&pdev->dev, ret, "request IRQ failed\n");1617 return dev_err_probe(&pdev->dev, ret, "request IRQ failed\n");
1626 1618
1627 ctrl->nb.notifier_call = qcom_slim_ngd_ssr_notify;
1628 ctrl->notifier = qcom_register_ssr_notifier("lpass", &ctrl->nb);
1629 if (IS_ERR(ctrl->notifier))
1630 return PTR_ERR(ctrl->notifier);
1631
1632 ctrl->dev = dev;1619 ctrl->dev = dev;
1633 ctrl->framer.rootfreq = SLIM_ROOT_FREQ >> 3;1620 ctrl->framer.rootfreq = SLIM_ROOT_FREQ >> 3;
1634 ctrl->framer.superfreq =1621 ctrl->framer.superfreq =
@@ -1649,48 +1636,71 @@ static int qcom_slim_ngd_ctrl_probe(struct platform_device *pdev) · 14 unmodified lines
1649 init_completion(&ctrl->qmi.qmi_comp);1636 init_completion(&ctrl->qmi.qmi_comp);
1650 init_completion(&ctrl->qmi_up);1637 init_completion(&ctrl->qmi_up);
1651 1638
1639 INIT_WORK(&ctrl->m_work, qcom_slim_ngd_master_worker);
1640 INIT_WORK(&ctrl->ngd_up_work, qcom_slim_ngd_up_worker);
1641
1642 ctrl->mwq = create_singlethread_workqueue("ngd_master");
1643 if (!ctrl->mwq)
1644 return dev_err_probe(dev, -ENOMEM, "Failed to start master worker\n");
1645
1652 ctrl->pdr = pdr_handle_alloc(slim_pd_status, ctrl);1646 ctrl->pdr = pdr_handle_alloc(slim_pd_status, ctrl);
1653 if (IS_ERR(ctrl->pdr)) {1647 if (IS_ERR(ctrl->pdr)) {
1654 ret = dev_err_probe(dev, PTR_ERR(ctrl->pdr),1648 ret = dev_err_probe(dev, PTR_ERR(ctrl->pdr), "Failed to init PDR handle\n");
1655 "Failed to init PDR handle\n");1649 goto err_destroy_mwq;
1656 goto err_pdr_alloc;
1657 }1650 }
1658 1651
1652 ret = of_qcom_slim_ngd_register(dev, ctrl);
1653 if (ret)
1654 goto err_pdr_release;
1655
1659 pds = pdr_add_lookup(ctrl->pdr, "avs/audio", "msm/adsp/audio_pd");1656 pds = pdr_add_lookup(ctrl->pdr, "avs/audio", "msm/adsp/audio_pd");
1660 if (IS_ERR(pds) && PTR_ERR(pds) != -EALREADY) {1657 if (IS_ERR(pds) && PTR_ERR(pds) != -EALREADY) {
1661 ret = dev_err_probe(dev, PTR_ERR(pds), "pdr add lookup failed\n");1658 ret = dev_err_probe(dev, PTR_ERR(pds), "pdr add lookup failed\n");
1662 goto err_pdr_lookup;1659 goto err_unregister_ngd;
1660 }
1661
1662 ctrl->nb.notifier_call = qcom_slim_ngd_ssr_notify;
1663 ctrl->notifier = qcom_register_ssr_notifier("lpass", &ctrl->nb);
1664 if (IS_ERR(ctrl->notifier)) {
1665 ret = PTR_ERR(ctrl->notifier);
1666 goto err_unregister_ngd;
1663 }1667 }
1664 1668
1665 platform_driver_register(&qcom_slim_ngd_driver);1669 enable_irq(irq);
1666 return of_qcom_slim_ngd_register(dev, ctrl);
1667 1670
1668err_pdr_alloc:1671 return 0;
1669 qcom_unregister_ssr_notifier(ctrl->notifier, &ctrl->nb);
1670 1672
1671err_pdr_lookup:1673err_unregister_ngd:
1674 qcom_slim_ngd_unregister(ctrl);
1675err_pdr_release:
1672 pdr_handle_release(ctrl->pdr);1676 pdr_handle_release(ctrl->pdr);
1677err_destroy_mwq:
1678 destroy_workqueue(ctrl->mwq);
1673 1679
1674 return ret;1680 return ret;
1675}1681}
1676 1682
1677static void qcom_slim_ngd_ctrl_remove(struct platform_device *pdev)1683static void qcom_slim_ngd_ctrl_remove(struct platform_device *pdev)
1678{1684{
1679 platform_driver_unregister(&qcom_slim_ngd_driver);1685 struct qcom_slim_ngd_ctrl *ctrl = platform_get_drvdata(pdev);
1686
1687 pdr_handle_release(ctrl->pdr);
1688 qcom_unregister_ssr_notifier(ctrl->notifier, &ctrl->nb);
1689
1690 qcom_slim_ngd_unregister(ctrl);
1691
1692 destroy_workqueue(ctrl->mwq);
1680}1693}
1681 1694
1682static void qcom_slim_ngd_remove(struct platform_device *pdev)1695static void qcom_slim_ngd_remove(struct platform_device *pdev)
1683{1696{
1684 struct qcom_slim_ngd_ctrl *ctrl = platform_get_drvdata(pdev);1697 struct qcom_slim_ngd_ctrl *ctrl = platform_get_drvdata(pdev);
1685 1698
1699 pm_runtime_dont_use_autosuspend(&pdev->dev);
1686 pm_runtime_disable(&pdev->dev);1700 pm_runtime_disable(&pdev->dev);
1687 pdr_handle_release(ctrl->pdr);
1688 qcom_unregister_ssr_notifier(ctrl->notifier, &ctrl->nb);
1689 qcom_slim_ngd_enable(ctrl, false);1701 qcom_slim_ngd_enable(ctrl, false);
1690 qcom_slim_ngd_exit_dma(ctrl);1702 qcom_slim_ngd_exit_dma(ctrl);
1691 qcom_slim_ngd_qmi_svc_event_deinit(&ctrl->qmi);1703 qcom_slim_ngd_qmi_svc_event_deinit(&ctrl->qmi);
1692 if (ctrl->mwq)
1693 destroy_workqueue(ctrl->mwq);
1694 1704
1695 kfree(ctrl->ngd);1705 kfree(ctrl->ngd);
1696 ctrl->ngd = NULL;1706 ctrl->ngd = NULL;
@@ -1752,6 +1762,28 @@ static struct platform_driver qcom_slim_ngd_driver = { · 55 unmodified lines
1752 },1762 },
1753};1763};
1754 1764
1755module_platform_driver(qcom_slim_ngd_ctrl_driver);1765static int qcom_slim_ngd_init(void)
1766{
1767 int ret;
1768
1769 ret = platform_driver_register(&qcom_slim_ngd_driver);
1770 if (ret)
1771 return ret;
1772
1773 ret = platform_driver_register(&qcom_slim_ngd_ctrl_driver);
1774 if (ret)
1775 platform_driver_unregister(&qcom_slim_ngd_driver);
1776
1777 return ret;
1778}
1779
1780static void qcom_slim_ngd_exit(void)
1781{
1782 platform_driver_unregister(&qcom_slim_ngd_ctrl_driver);
1783 platform_driver_unregister(&qcom_slim_ngd_driver);
1784}
1785
1786module_init(qcom_slim_ngd_init);
1787module_exit(qcom_slim_ngd_exit);
1756MODULE_LICENSE("GPL v2");1788MODULE_LICENSE("GPL v2");
1757MODULE_DESCRIPTION("Qualcomm SLIMBus NGD controller");1789MODULE_DESCRIPTION("Qualcomm SLIMBus NGD controller");

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t