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
723723 return -ENOMEM;
724724
725725 priv->client.dev = dev;
726− priv->client.receive_cb = NULL;
727726 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;
734727 priv->retry_counter = INVALID_RETRY_COUNTER;
728+ priv->max_retry = INVALID_RETRY_COUNTER;
735729 priv->dcmf_version.dcmf0 = INVALID_DCMF_VERSION;
736730 priv->dcmf_version.dcmf1 = INVALID_DCMF_VERSION;
737731 priv->dcmf_version.dcmf2 = INVALID_DCMF_VERSION;
@@ -740,11 +734,11 @@ static int stratix10_rsu_probe(struct platform_device *pdev) · 2 unmodified lines
740734 priv->dcmf_status.dcmf1 = INVALID_DCMF_STATUS;
741735 priv->dcmf_status.dcmf2 = INVALID_DCMF_STATUS;
742736 priv->dcmf_status.dcmf3 = INVALID_DCMF_STATUS;
743− priv->max_retry = INVALID_RETRY_COUNTER;
744− priv->spt0_address = INVALID_SPT_ADDRESS;
745− priv->spt1_address = INVALID_SPT_ADDRESS;
737+ /* spt0/1_address and status fields default to 0 from kzalloc */
746738
747739 mutex_init(&priv->lock);
740+ init_completion(&priv->completion);
741+
748742 priv->chan = stratix10_svc_request_channel_byname(&priv->client,
749743 SVC_CLIENT_RSU);
750744 if (IS_ERR(priv->chan)) {
@@ -756,11 +750,9 @@ static int stratix10_rsu_probe(struct platform_device *pdev) · 5 unmodified lines
756750 ret = stratix10_svc_add_async_client(priv->chan, false);
757751 if (ret) {
758752 dev_err(dev, "failed to add async client\n");
759− stratix10_svc_free_channel(priv->chan);
760− return ret;
753+ goto free_channel;
761754 }
762755
763− init_completion(&priv->completion);
764756 platform_set_drvdata(pdev, priv);
765757
766758 /* get the initial state from firmware */
@@ -768,41 +760,44 @@ static int stratix10_rsu_probe(struct platform_device *pdev) · 1 unmodified line
768760 rsu_async_status_callback);
769761 if (ret) {
770762 dev_err(dev, "Error, getting RSU status %i\n", ret);
771− stratix10_svc_remove_async_client(priv->chan);
772− stratix10_svc_free_channel(priv->chan);
773− return ret;
763+ goto remove_async_client;
774764 }
775765
776766 /* get DCMF version from firmware */
777− ret = rsu_send_msg(priv, COMMAND_RSU_DCMF_VERSION,
778− 0, rsu_dcmf_version_callback);
767+ ret = rsu_send_msg(priv, COMMAND_RSU_DCMF_VERSION, 0,
768+ rsu_dcmf_version_callback);
779769 if (ret) {
780770 dev_err(dev, "Error, getting DCMF version %i\n", ret);
781− stratix10_svc_free_channel(priv->chan);
771+ goto remove_async_client;
782772 }
783773
784− ret = rsu_send_msg(priv, COMMAND_RSU_DCMF_STATUS,
785− 0, rsu_dcmf_status_callback);
774+ ret = rsu_send_msg(priv, COMMAND_RSU_DCMF_STATUS, 0,
775+ rsu_dcmf_status_callback);
786776 if (ret) {
787777 dev_err(dev, "Error, getting DCMF status %i\n", ret);
788− stratix10_svc_free_channel(priv->chan);
778+ goto remove_async_client;
789779 }
790780
791781 ret = rsu_send_msg(priv, COMMAND_RSU_MAX_RETRY, 0,
792782 rsu_max_retry_callback);
793783 if (ret) {
794784 dev_err(dev, "Error, getting RSU max retry %i\n", ret);
795− stratix10_svc_free_channel(priv->chan);
785+ goto remove_async_client;
796786 }
797787
798−
799788 ret = rsu_send_async_msg(dev, priv, COMMAND_RSU_GET_SPT_TABLE, 0,
800789 rsu_async_get_spt_table_callback);
801790 if (ret) {
802791 dev_err(dev, "Error, getting SPT table %i\n", ret);
803− stratix10_svc_free_channel(priv->chan);
792+ goto remove_async_client;
804793 }
805794
795+ return 0;
796+
797+remove_async_client:
798+ stratix10_svc_remove_async_client(priv->chan);
799+free_channel:
800+ stratix10_svc_free_channel(priv->chan);
806801 return ret;
807802 }
808803
drivers/firmware/stratix10-svc.c+17−4
@@ -212,6 +212,7 @@ struct stratix10_async_chan { · 211 unmodified lines
212212 /**
213213 * struct stratix10_async_ctrl - Control structure for Stratix10
214214 * asynchronous operations
215+ * @supported: Flag indicating whether the system supports async operations
215216 * @initialized: Flag indicating whether the control structure has
216217 * been initialized
217218 * @invoke_fn: Function pointer for invoking Stratix10 service calls
@@ -228,6 +229,7 @@ struct stratix10_async_chan { · 10 unmodified lines
228229 */
229230
230231 struct stratix10_async_ctrl {
232+ bool supported;
231233 bool initialized;
232234 void (*invoke_fn)(struct stratix10_async_ctrl *actrl,
233235 const struct arm_smccc_1_2_regs *args,
@@ -1103,6 +1105,7 @@ EXPORT_SYMBOL_GPL(stratix10_svc_request_channel_byname); · 869 unmodified lines
11031105 * Return: 0 on success, or a negative error code on failure:
11041106 * -EINVAL if the channel is NULL or the async controller is
11051107 * not initialized.
1108+ * -EOPNOTSUPP if async operations are not supported.
11061109 * -EALREADY if the async channel is already allocated.
11071110 * -ENOMEM if memory allocation fails.
11081111 * 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
11211124 ctrl = chan->ctrl;
11221125 actrl = &ctrl->actrl;
11231126
1127+ if (!actrl->supported)
1128+ return -EOPNOTSUPP;
1129+
11241130 if (!actrl->initialized) {
11251131 dev_err(ctrl->dev, "Async controller not initialized\n");
11261132 return -EINVAL;
@@ -1562,6 +1568,7 @@ static inline void stratix10_smc_1_2(struct stratix10_async_ctrl *actrl, · 435 unmodified lines
15621568 * initialized, -ENOMEM if memory allocation fails,
15631569 * -EADDRINUSE if the client ID is already reserved, or other
15641570 * negative error codes on failure.
1571+ * -EOPNOTSUPP if system doesn't support async operations.
15651572 */
15661573 static int stratix10_svc_async_init(struct stratix10_svc_controller *controller)
15671574 {
@@ -1585,10 +1592,12 @@ static int stratix10_svc_async_init(struct stratix10_svc_controller *controller) · 17 unmodified lines
15851592 !(res.a1 > ASYNC_ATF_MINIMUM_MAJOR_VERSION ||
15861593 (res.a1 == ASYNC_ATF_MINIMUM_MAJOR_VERSION &&
15871594 res.a2 >= ASYNC_ATF_MINIMUM_MINOR_VERSION))) {
1588− dev_err(dev,
1589− "Intel Service Layer Driver: ATF version is not compatible for async operation\n");
1590− return -EINVAL;
1595+ dev_info(dev,
1596+ "Intel Service Layer Driver: ATF version is not compatible for async operation\n");
1597+ actrl->supported = false;
1598+ return -EOPNOTSUPP;
15911599 }
1600+ actrl->supported = true;
15921601
15931602 actrl->invoke_fn = stratix10_smc_1_2;
15941603
@@ -1952,10 +1961,14 @@ static int stratix10_svc_drv_probe(struct platform_device *pdev) · 357 unmodified lines
19521961 init_completion(&controller->complete_status);
19531962
19541963 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) {
19561967 dev_dbg(dev, "Intel Service Layer Driver: Error on stratix10_svc_async_init %d\n",
19571968 ret);
19581969 goto err_destroy_pool;
1970+ } else {
1971+ dev_info(dev, "Intel Service Layer Driver Initialized\n");
19591972 }
19601973
19611974 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
310310 spinlock_t lock;
311311 /* lock for allocations */
312312 struct mutex mutex;
313+ /* Reference count */
314+ struct kref refcount;
313315 };
314316
315317 /* Extract SMMU PA from consolidated IOVA */
@@ -386,7 +388,7 @@ static int fastrpc_map_get(struct fastrpc_map *map) · 70 unmodified lines
386388
387389
388390 static int fastrpc_map_lookup(struct fastrpc_user *fl, int fd,
389− struct fastrpc_map **ppmap)
391+ struct fastrpc_map **ppmap, bool take_ref)
390392 {
391393 struct fastrpc_map *map = NULL;
392394 struct dma_buf *buf;
@@ -401,6 +403,12 @@ static int fastrpc_map_lookup(struct fastrpc_user *fl, int fd, · 8 unmodified lines
401403 if (map->fd != fd || map->buf != buf)
402404 continue;
403405
406+ if (take_ref) {
407+ ret = fastrpc_map_get(map);
408+ if (ret)
409+ break;
410+ }
411+
404412 *ppmap = map;
405413 ret = 0;
406414 break;
@@ -497,15 +505,57 @@ static void fastrpc_channel_ctx_put(struct fastrpc_channel_ctx *cctx) · 90 unmodified lines
497505 kref_put(&cctx->refcount, fastrpc_channel_ctx_free);
498506 }
499507
508+static void fastrpc_context_put(struct fastrpc_invoke_ctx *ctx);
509+
510+static 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+
538+static void fastrpc_user_get(struct fastrpc_user *fl)
539+{
540+ kref_get(&fl->refcount);
541+}
542+
543+static void fastrpc_user_put(struct fastrpc_user *fl)
544+{
545+ kref_put(&fl->refcount, fastrpc_user_free);
546+}
547+
500548 static void fastrpc_context_free(struct kref *ref)
501549 {
502550 struct fastrpc_invoke_ctx *ctx;
503551 struct fastrpc_channel_ctx *cctx;
552+ struct fastrpc_user *fl;
504553 unsigned long flags;
505554 int i;
506555
507556 ctx = container_of(ref, struct fastrpc_invoke_ctx, refcount);
508557 cctx = ctx->cctx;
558+ fl = ctx->fl;
509559
510560 for (i = 0; i < ctx->nbufs; i++)
511561 fastrpc_map_put(ctx->maps[i]);
@@ -521,6 +571,8 @@ static void fastrpc_context_free(struct kref *ref) · 9 unmodified lines
521571 kfree(ctx->olaps);
522572 kfree(ctx);
523573
574+ /* Release the reference taken in fastrpc_context_alloc() */
575+ fastrpc_user_put(fl);
524576 fastrpc_channel_ctx_put(cctx);
525577 }
526578
@@ -628,6 +680,8 @@ static struct fastrpc_invoke_ctx *fastrpc_context_alloc( · 101 unmodified lines
628680
629681 /* Released in fastrpc_context_put() */
630682 fastrpc_channel_ctx_get(cctx);
683+ /* Take a reference to user, released in fastrpc_context_free() */
684+ fastrpc_user_get(user);
631685
632686 ctx->sc = sc;
633687 ctx->retval = -1;
@@ -658,6 +712,7 @@ err_idr: · 24 unmodified lines
658712 spin_lock(&user->lock);
659713 list_del(&ctx->node);
660714 spin_unlock(&user->lock);
715+ fastrpc_user_put(user);
661716 fastrpc_channel_ctx_put(cctx);
662717 kfree(ctx->maps);
663718 kfree(ctx->olaps);
@@ -871,19 +926,10 @@ get_err: · 207 unmodified lines
871926 static int fastrpc_map_create(struct fastrpc_user *fl, int fd,
872927 u64 len, u32 attr, struct fastrpc_map **ppmap)
873928 {
874− struct fastrpc_session_ctx *sess = fl->sctx;
875− int err = 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);
929+ if (!fastrpc_map_lookup(fl, fd, ppmap, true))
930+ return 0;
885931
886− return err;
932+ return fastrpc_map_attach(fl, fd, len, attr, ppmap);
887933 }
888934
889935 /*
@@ -1041,7 +1087,7 @@ static int fastrpc_get_args(u32 kernel, struct fastrpc_invoke_ctx *ctx) · 151 unmodified lines
10411087 pages[i].addr = ctx->maps[i]->dma_addr;
10421088
10431089 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);
10451091 if (vma)
10461092 pages[i].addr += (ctx->args[i].ptr & PAGE_MASK) -
10471093 vma->vm_start;
@@ -1153,7 +1199,7 @@ cleanup_fdlist: · 105 unmodified lines
11531199 for (i = 0; i < FASTRPC_MAX_FDLIST; i++) {
11541200 if (!fdlist[i])
11551201 break;
1156− if (!fastrpc_map_lookup(fl, (int)fdlist[i], &mmap))
1202+ if (!fastrpc_map_lookup(fl, (int)fdlist[i], &mmap, false))
11571203 fastrpc_map_put(mmap);
11581204 }
11591205
@@ -1579,9 +1625,6 @@ static int fastrpc_device_release(struct inode *inode, struct file *file) · 419 unmodified lines
15791625 {
15801626 struct fastrpc_user *fl = (struct fastrpc_user *)file->private_data;
15811627 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;
15851628 unsigned long flags;
15861629
15871630 fastrpc_release_current_dsp_process(fl);
@@ -1590,28 +1633,10 @@ static int fastrpc_device_release(struct inode *inode, struct file *file) · 2 unmodified lines
15901633 list_del(&fl->user);
15911634 spin_unlock_irqrestore(&cctx->lock, flags);
15921635
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−
16091636 fastrpc_session_free(cctx, fl->sctx);
1610− fastrpc_channel_ctx_put(cctx);
1611−
1612− mutex_destroy(&fl->mutex);
1613− kfree(fl);
16141637 file->private_data = NULL;
1638+ /* Release the reference taken in fastrpc_device_open */
1639+ fastrpc_user_put(fl);
16151640
16161641 return 0;
16171642 }
@@ -1655,6 +1680,7 @@ static int fastrpc_device_open(struct inode *inode, struct file *filp) · 37 unmodified lines
16551680 spin_lock_irqsave(&cctx->lock, flags);
16561681 list_add_tail(&fl->user, &cctx->users);
16571682 spin_unlock_irqrestore(&cctx->lock, flags);
1683+ kref_init(&fl->refcount);
16581684
16591685 return 0;
16601686 }
@@ -2431,7 +2457,6 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev) · 770 unmodified lines
24312457
24322458 kref_init(&data->refcount);
24332459
2434− dev_set_drvdata(&rpdev->dev, data);
24352460 rdev->dma_mask = &data->dma_mask;
24362461 dma_set_mask_and_coherent(rdev, DMA_BIT_MASK(32));
24372462 INIT_LIST_HEAD(&data->users);
@@ -2440,6 +2465,7 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev) · 2 unmodified lines
24402465 idr_init(&data->ctx_idr);
24412466 data->domain_id = domain_id;
24422467 data->rpdev = rpdev;
2468+ dev_set_drvdata(&rpdev->dev, data);
24432469
24442470 err = of_platform_populate(rdev->of_node, NULL, NULL, rdev);
24452471 if (err)
@@ -2513,6 +2539,9 @@ static int fastrpc_rpmsg_callback(struct rpmsg_device *rpdev, void *data, · 67 unmodified lines
25132539 if (len < sizeof(*rsp))
25142540 return -EINVAL;
25152541
2542+ if (!cctx)
2543+ return -ENODEV;
2544+
25162545 ctxid = ((rsp->ctx & FASTRPC_CTXID_MASK) >> 4);
25172546
25182547 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
14681468 cell_entry = nvmem_find_cell_entry_by_node(nvmem, cell_np);
14691469 of_node_put(cell_np);
14701470 if (!cell_entry) {
1471− __nvmem_device_put(nvmem);
14721471 nvmem_layout_module_put(nvmem);
1473− if (nvmem->layout)
1474− return ERR_PTR(-EPROBE_DEFER);
1475− else
1476− return ERR_PTR(-ENOENT);
1472+ ret = nvmem->layout ? -EPROBE_DEFER : -ENOENT;
1473+ __nvmem_device_put(nvmem);
1474+ return ERR_PTR(ret);
14771475 }
14781476
14791477 cell = nvmem_create_cell(cell_entry, id, cell_index);
14801478 if (IS_ERR(cell)) {
1481− __nvmem_device_put(nvmem);
14821479 nvmem_layout_module_put(nvmem);
1480+ __nvmem_device_put(nvmem);
14831481 }
14841482
14851483 return cell;
@@ -1593,8 +1591,8 @@ void nvmem_cell_put(struct nvmem_cell *cell) · 107 unmodified lines
15931591 kfree_const(cell->id);
15941592
15951593 kfree(cell);
1596− __nvmem_device_put(nvmem);
15971594 nvmem_layout_module_put(nvmem);
1595+ __nvmem_device_put(nvmem);
15981596 }
15991597 EXPORT_SYMBOL_GPL(nvmem_cell_put);
16001598
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
119119
120120 cell.name = onie_tlv_cell_name(tlv.type);
121121 if (!cell.name)
122− continue;
122+ goto next;
123123
124124 cell.offset = hdr_len + offset + sizeof(tlv.type) + sizeof(tlv.len);
125125 cell.bytes = tlv.len;
@@ -132,6 +132,7 @@ static int onie_tlv_add_cells(struct device *dev, struct nvmem_device *nvmem, · 6 unmodified lines
132132 return ret;
133133 }
134134
135+next:
135136 offset += sizeof(tlv) + tlv.len;
136137 }
137138
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
14711471 switch (action) {
14721472 case QCOM_SSR_BEFORE_SHUTDOWN:
14731473 case SERVREG_SERVICE_STATE_DOWN:
1474− /* Make sure the last dma xfer is finished */
1475− mutex_lock(&ctrl->tx_lock);
14761474 if (ctrl->state != QCOM_SLIM_NGD_CTRL_DOWN) {
14771475 pm_runtime_get_noresume(ctrl->ctrl.dev);
14781476 ctrl->state = QCOM_SLIM_NGD_CTRL_DOWN;
14791477 qcom_slim_ngd_down(ctrl);
14801478 qcom_slim_ngd_exit_dma(ctrl);
14811479 }
1482− mutex_unlock(&ctrl->tx_lock);
14831480 break;
14841481 case QCOM_SSR_AFTER_POWERUP:
14851482 case SERVREG_SERVICE_STATE_UP:
@@ -1542,7 +1539,7 @@ static int of_qcom_slim_ngd_register(struct device *parent, · 56 unmodified lines
15421539 kfree(ngd);
15431540 return ret;
15441541 }
1545− ngd->pdev->dev.of_node = node;
1542+ ngd->pdev->dev.of_node = of_node_get(node);
15461543 ctrl->ngd = ngd;
15471544
15481545 ret = platform_device_add(ngd->pdev);
@@ -1560,6 +1557,13 @@ static int of_qcom_slim_ngd_register(struct device *parent, · 11 unmodified lines
15601557 return -ENODEV;
15611558 }
15621559
1560+static 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+
15631567 static int qcom_slim_ngd_probe(struct platform_device *pdev)
15641568 {
15651569 struct device *dev = &pdev->dev;
@@ -1577,24 +1581,10 @@ static int qcom_slim_ngd_probe(struct platform_device *pdev) · 11 unmodified lines
15771581 ret = qcom_slim_ngd_qmi_svc_event_init(ctrl);
15781582 if (ret) {
15791583 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);
15811586 }
15821587
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;
1593−wq_err:
1594− qcom_slim_ngd_qmi_svc_event_deinit(&ctrl->qmi);
1595− if (ctrl->mwq)
1596− destroy_workqueue(ctrl->mwq);
1597−
15981588 return ret;
15991589 }
16001590
@@ -1602,6 +1592,7 @@ static int qcom_slim_ngd_ctrl_probe(struct platform_device *pdev) · 1 unmodified line
16021592 {
16031593 struct device *dev = &pdev->dev;
16041594 struct qcom_slim_ngd_ctrl *ctrl;
1595+ int irq;
16051596 int ret;
16061597 struct pdr_service *pds;
16071598
@@ -1615,20 +1606,16 @@ static int qcom_slim_ngd_ctrl_probe(struct platform_device *pdev) · 7 unmodified lines
16151606 if (IS_ERR(ctrl->base))
16161607 return PTR_ERR(ctrl->base);
16171608
1618− ret = platform_get_irq(pdev, 0);
1619− if (ret < 0)
1620− return ret;
1609+ irq = platform_get_irq(pdev, 0);
1610+ if (irq < 0)
1611+ return irq;
16211612
1622− ret = devm_request_irq(dev, ret, qcom_slim_ngd_interrupt,
1623− IRQF_TRIGGER_HIGH, "slim-ngd", ctrl);
1613+ ret = devm_request_irq(dev, irq, qcom_slim_ngd_interrupt,
1614+ IRQF_TRIGGER_HIGH | IRQF_NO_AUTOEN,
1615+ "slim-ngd", ctrl);
16241616 if (ret)
16251617 return dev_err_probe(&pdev->dev, ret, "request IRQ failed\n");
16261618
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−
16321619 ctrl->dev = dev;
16331620 ctrl->framer.rootfreq = SLIM_ROOT_FREQ >> 3;
16341621 ctrl->framer.superfreq =
@@ -1649,48 +1636,71 @@ static int qcom_slim_ngd_ctrl_probe(struct platform_device *pdev) · 14 unmodified lines
16491636 init_completion(&ctrl->qmi.qmi_comp);
16501637 init_completion(&ctrl->qmi_up);
16511638
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+
16521646 ctrl->pdr = pdr_handle_alloc(slim_pd_status, ctrl);
16531647 if (IS_ERR(ctrl->pdr)) {
1654− ret = dev_err_probe(dev, PTR_ERR(ctrl->pdr),
1655− "Failed to init PDR handle\n");
1656− goto err_pdr_alloc;
1648+ ret = dev_err_probe(dev, PTR_ERR(ctrl->pdr), "Failed to init PDR handle\n");
1649+ goto err_destroy_mwq;
16571650 }
16581651
1652+ ret = of_qcom_slim_ngd_register(dev, ctrl);
1653+ if (ret)
1654+ goto err_pdr_release;
1655+
16591656 pds = pdr_add_lookup(ctrl->pdr, "avs/audio", "msm/adsp/audio_pd");
16601657 if (IS_ERR(pds) && PTR_ERR(pds) != -EALREADY) {
16611658 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;
16631667 }
16641668
1665− platform_driver_register(&qcom_slim_ngd_driver);
1666− return of_qcom_slim_ngd_register(dev, ctrl);
1669+ enable_irq(irq);
16671670
1668−err_pdr_alloc:
1669− qcom_unregister_ssr_notifier(ctrl->notifier, &ctrl->nb);
1671+ return 0;
16701672
1671−err_pdr_lookup:
1673+err_unregister_ngd:
1674+ qcom_slim_ngd_unregister(ctrl);
1675+err_pdr_release:
16721676 pdr_handle_release(ctrl->pdr);
1677+err_destroy_mwq:
1678+ destroy_workqueue(ctrl->mwq);
16731679
16741680 return ret;
16751681 }
16761682
16771683 static void qcom_slim_ngd_ctrl_remove(struct platform_device *pdev)
16781684 {
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);
16801693 }
16811694
16821695 static void qcom_slim_ngd_remove(struct platform_device *pdev)
16831696 {
16841697 struct qcom_slim_ngd_ctrl *ctrl = platform_get_drvdata(pdev);
16851698
1699+ pm_runtime_dont_use_autosuspend(&pdev->dev);
16861700 pm_runtime_disable(&pdev->dev);
1687− pdr_handle_release(ctrl->pdr);
1688− qcom_unregister_ssr_notifier(ctrl->notifier, &ctrl->nb);
16891701 qcom_slim_ngd_enable(ctrl, false);
16901702 qcom_slim_ngd_exit_dma(ctrl);
16911703 qcom_slim_ngd_qmi_svc_event_deinit(&ctrl->qmi);
1692− if (ctrl->mwq)
1693− destroy_workqueue(ctrl->mwq);
16941704
16951705 kfree(ctrl->ngd);
16961706 ctrl->ngd = NULL;
@@ -1752,6 +1762,28 @@ static struct platform_driver qcom_slim_ngd_driver = { · 55 unmodified lines
17521762 },
17531763 };
17541764
1755−module_platform_driver(qcom_slim_ngd_ctrl_driver);
1765+static 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+
1780+static 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+
1786+module_init(qcom_slim_ngd_init);
1787+module_exit(qcom_slim_ngd_exit);
17561788 MODULE_LICENSE("GPL v2");
17571789 MODULE_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