From patchwork Tue Aug 30 19:27:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhaktipriya Shridhar X-Patchwork-Id: 9306117 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B42A060756 for ; Tue, 30 Aug 2016 21:38:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9ED6F28D1F for ; Tue, 30 Aug 2016 21:38:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 93B2428D89; Tue, 30 Aug 2016 21:38:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=no version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC07028D1F for ; Tue, 30 Aug 2016 21:38:45 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id B2C4F266F5F; Tue, 30 Aug 2016 23:38:42 +0200 (CEST) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id A53B0267064; Tue, 30 Aug 2016 23:30:13 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 7CDFF267057; Tue, 30 Aug 2016 23:30:11 +0200 (CEST) Received: from mail-pa0-f68.google.com (mail-pa0-f68.google.com [209.85.220.68]) by alsa0.perex.cz (Postfix) with ESMTP id D986E26747D for ; Tue, 30 Aug 2016 21:27:14 +0200 (CEST) Received: by mail-pa0-f68.google.com with SMTP id hh10so1496411pac.1 for ; Tue, 30 Aug 2016 12:27:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=gewkL512R+BQeCHKZPDNRGGx7p2ZCI0vJq+WaCITY4s=; b=lUEDQqadzmr0xUmHpTRAHTbhSSa+RdTc7+0TXKVwF2rgEw8bQjiysZctThN10NV704 f4pBZfKcKXUAnpNoExF5wKJ5AuuFwBP/0gKiFcR/wSNNjEsqB4hnPDN8CKwLl0tajFRd D3+lMGosRd5FyOOolG7hb8x9NDuipoinOZCF4ktk+ICFn4UznA0Rgs6sU7CgP+g8aqOw b4UiwFr1wF8UQtfwoHl4ytTnj9po8IGWVQLaXguBRMpLqtpNz2oP5qnrHhOg3s9q4Zb5 kYVwLrXqL+c+uR+BTh3cdubeyV3A8VoBztDLx4KCYe71BdPVGqmD+IaDfCzfftxTyd33 4QLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=gewkL512R+BQeCHKZPDNRGGx7p2ZCI0vJq+WaCITY4s=; b=X5gDDJL8RQaoxcFEU9mNMYhPwr/88OTT/BbDO75CbXA62k8mLg8d+f3zeEsYJ2+sGP G9Za5qlxkul/iI2W+jV5owbwkyFonBARrah2dgoAjFTGYhNjFFTasErZpJ1QUakkm1RJ ALUV/wZO8u3/KhqwirJ8EEN3LYG3ACzptogP5rUs3xGlg9RzvcftZs56SddU15xp3sA/ 3DVDnGlYC97omeFtOTFprB60B9KKHo9/4uFSLmDgAjJ7NrfIo2GdI1zE/ppX63faKsZa 8CqpWqFj+guMcCPXi3784omuyVy2ScsR+neEfIEsXznQwO+m+yJKTAErMbYeLsuicItZ Muzw== X-Gm-Message-State: AE9vXwOfwy3GerenWp4Lrll/WD9Q9WwrJ1g+g8Vr/uTztNHuEmFKMnpPkHjruUm6R9hmGw== X-Received: by 10.66.9.42 with SMTP id w10mr9252870paa.34.1472585233139; Tue, 30 Aug 2016 12:27:13 -0700 (PDT) Received: from Karyakshetra ([14.139.82.6]) by smtp.gmail.com with ESMTPSA id w64sm59061204pfb.93.2016.08.30.12.27.12 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 30 Aug 2016 12:27:12 -0700 (PDT) Date: Wed, 31 Aug 2016 00:57:09 +0530 From: Bhaktipriya Shridhar To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai Message-ID: <20160830192709.GA16591@Karyakshetra> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) Cc: Tejun Heo , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [alsa-devel] [PATCH v3] ASoC: Remove deprecated create_singlethread_workqueue X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP The workqueue "dac33_wq" queues a single work item &dac33->work and hence doesn't require ordering. Also, it is not being used on a memory reclaim path. Hence, it has been converted to use system_wq. The work item has been flushed in dac33_soc_remove to ensure that there are no pending tasks while disconnecting the driver. The workqueue "post_msg_wq" queues a single work item &drv->ipc_post_msg_wq and hence doesn't require ordering. Also, it is not being used on a memory reclaim path. Hence, it has been converted to use system_wq. The work item has been flushed in sst_context_cleanup to ensure that there are no pending tasks while disconnecting the driver. System workqueues have been able to handle high level of concurrency for a long time now and hence it's not required to have a singlethreaded workqueue just to gain concurrency. Unlike a dedicated per-cpu workqueue created with create_singlethread_workqueue(), system_wq allows multiple work items to overlap executions even on the same CPU; however, a per-cpu workqueue doesn't have any CPU locality or global ordering guarantee unless the target CPU is explicitly specified and thus the increase of local concurrency shouldn't make any difference. Signed-off-by: Bhaktipriya Shridhar Acked-by: Tejun Heo --- Changes in v3: -Added missing '&' sound/soc/codecs/tlv320dac33.c | 17 ++++------------- sound/soc/intel/atom/sst/sst.c | 14 +++++--------- 2 files changed, 9 insertions(+), 22 deletions(-) -- 2.1.4 diff --git a/sound/soc/codecs/tlv320dac33.c b/sound/soc/codecs/tlv320dac33.c index f7a6ce7..6822ac1 100644 --- a/sound/soc/codecs/tlv320dac33.c +++ b/sound/soc/codecs/tlv320dac33.c @@ -90,7 +90,6 @@ static const char *dac33_supply_names[DAC33_NUM_SUPPLIES] = { struct tlv320dac33_priv { struct mutex mutex; - struct workqueue_struct *dac33_wq; struct work_struct work; struct snd_soc_codec *codec; struct regulator_bulk_data supplies[DAC33_NUM_SUPPLIES]; @@ -771,7 +770,7 @@ static irqreturn_t dac33_interrupt_handler(int irq, void *dev) /* Do not schedule the workqueue in Mode7 */ if (dac33->fifo_mode != DAC33_FIFO_MODE7) - queue_work(dac33->dac33_wq, &dac33->work); + schedule_work(&dac33->work); return IRQ_HANDLED; } @@ -1127,7 +1126,7 @@ static int dac33_pcm_trigger(struct snd_pcm_substream *substream, int cmd, case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: if (dac33->fifo_mode) { dac33->state = DAC33_PREFILL; - queue_work(dac33->dac33_wq, &dac33->work); + schedule_work(&dac33->work); } break; case SNDRV_PCM_TRIGGER_STOP: @@ -1135,7 +1134,7 @@ static int dac33_pcm_trigger(struct snd_pcm_substream *substream, int cmd, case SNDRV_PCM_TRIGGER_PAUSE_PUSH: if (dac33->fifo_mode) { dac33->state = DAC33_FLUSH; - queue_work(dac33->dac33_wq, &dac33->work); + schedule_work(&dac33->work); } break; default: @@ -1410,14 +1409,6 @@ static int dac33_soc_probe(struct snd_soc_codec *codec) dac33->irq = -1; } if (dac33->irq != -1) { - /* Setup work queue */ - dac33->dac33_wq = - create_singlethread_workqueue("tlv320dac33"); - if (dac33->dac33_wq == NULL) { - free_irq(dac33->irq, codec); - return -ENOMEM; - } - INIT_WORK(&dac33->work, dac33_work); } } @@ -1437,7 +1428,7 @@ static int dac33_soc_remove(struct snd_soc_codec *codec) if (dac33->irq >= 0) { free_irq(dac33->irq, dac33->codec); - destroy_workqueue(dac33->dac33_wq); + flush_work(&dac33->work); } return 0; } diff --git a/sound/soc/intel/atom/sst/sst.c b/sound/soc/intel/atom/sst/sst.c index a4b458e..1454603 100644 --- a/sound/soc/intel/atom/sst/sst.c +++ b/sound/soc/intel/atom/sst/sst.c @@ -76,7 +76,7 @@ static irqreturn_t intel_sst_interrupt_mrfld(int irq, void *context) spin_unlock(&drv->ipc_spin_lock); /* we can send more messages to DSP so trigger work */ - queue_work(drv->post_msg_wq, &drv->ipc_post_msg_wq); + schedule_work(&drv->ipc_post_msg_wq); retval = IRQ_HANDLED; } @@ -212,10 +212,6 @@ static int sst_workqueue_init(struct intel_sst_drv *ctx) INIT_WORK(&ctx->ipc_post_msg_wq, sst_process_pending_msg); init_waitqueue_head(&ctx->wait_queue); - ctx->post_msg_wq = - create_singlethread_workqueue("sst_post_msg_wq"); - if (!ctx->post_msg_wq) - return -EBUSY; return 0; } @@ -318,7 +314,6 @@ int sst_context_init(struct intel_sst_drv *ctx) return 0; do_free_mem: - destroy_workqueue(ctx->post_msg_wq); return ret; } EXPORT_SYMBOL_GPL(sst_context_init); @@ -330,7 +325,7 @@ void sst_context_cleanup(struct intel_sst_drv *ctx) sst_unregister(ctx->dev); sst_set_fw_state_locked(ctx, SST_SHUTDOWN); flush_scheduled_work(); - destroy_workqueue(ctx->post_msg_wq); + flush_work(&ctx->ipc_post_msg_wq); pm_qos_remove_request(ctx->qos); kfree(ctx->fw_sg_list.src); kfree(ctx->fw_sg_list.dst); @@ -414,7 +409,7 @@ static int intel_sst_runtime_suspend(struct device *dev) sst_set_fw_state_locked(ctx, SST_RESET); synchronize_irq(ctx->irq_num); - flush_workqueue(ctx->post_msg_wq); + flush_work(&ctx->ipc_post_msg_wq); ctx->ops->reset(ctx); /* save the shim registers because PMC doesn't save state */ @@ -445,8 +440,9 @@ static int intel_sst_suspend(struct device *dev) return -EBUSY; } } + synchronize_irq(ctx->irq_num); - flush_workqueue(ctx->post_msg_wq); + flush_work(&ctx->ipc_post_msg_wq); /* Move the SST state to Reset */ sst_set_fw_state_locked(ctx, SST_RESET);