From patchwork Tue Jul 3 11:22:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liam Girdwood X-Patchwork-Id: 10503849 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 95B23602BC for ; Tue, 3 Jul 2018 11:22:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 76475288C7 for ; Tue, 3 Jul 2018 11:22:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 680AA288F4; Tue, 3 Jul 2018 11:22:38 +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=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham 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 9F49B288C7 for ; Tue, 3 Jul 2018 11:22:37 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id D17D22673E1; Tue, 3 Jul 2018 13:22:33 +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 4A82D26771C; Tue, 3 Jul 2018 13:22:31 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by alsa0.perex.cz (Postfix) with ESMTP id 8CA2B26735C for ; Tue, 3 Jul 2018 13:22:28 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Jul 2018 04:22:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,303,1526367600"; d="scan'208";a="54772636" Received: from kkolady-mobl2.amr.corp.intel.com (HELO sif.ger.corp.intel.com) ([10.252.29.145]) by orsmga006.jf.intel.com with ESMTP; 03 Jul 2018 04:22:25 -0700 From: Liam Girdwood To: Date: Tue, 3 Jul 2018 12:22:25 +0100 Message-Id: <20180703112225.14604-1-liam.r.girdwood@linux.intel.com> X-Mailer: git-send-email 2.17.1 Cc: Takashi Iwai , Liam Girdwood Subject: [alsa-devel] [PATCH v3] ALSA: core: Allow drivers to set R/W wait time. 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: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Currently ALSA core blocks userspace for about 10 seconds for PCM R/W IO. This needs to be configurable for modern hardware like DSPs where no pointer update in milliseconds can indicate terminal DSP errors. Add a substream variable to set the wait time in ms. This allows userspace and drivers to recover more quickly from terminal DSP errors. Signed-off-by: Liam Girdwood --- Changes since V1 :- o Remove API method and alow drivers to set directly. o Validate time is driver supplied times. V2 :- o Max wait calc now in ms. o checkpatch. include/sound/pcm.h | 1 + sound/core/pcm_lib.c | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/include/sound/pcm.h b/include/sound/pcm.h index e054c583d3b3..fcdf358a25f0 100644 --- a/include/sound/pcm.h +++ b/include/sound/pcm.h @@ -462,6 +462,7 @@ struct snd_pcm_substream { /* -- timer section -- */ struct snd_timer *timer; /* timer */ unsigned timer_running: 1; /* time is running */ + long wait_time; /* time in ms for R/W to wait for avail */ /* -- next substream -- */ struct snd_pcm_substream *next; /* -- linked substreams -- */ diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c index 44b5ae833082..82a41e4d7170 100644 --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c @@ -1832,12 +1832,18 @@ static int wait_for_avail(struct snd_pcm_substream *substream, if (runtime->no_period_wakeup) wait_time = MAX_SCHEDULE_TIMEOUT; else { - wait_time = 10; + /* use wait time from substream if available */ + if (substream->wait_time) + wait_time = substream->wait_time; + else + wait_time = 10 * 1000; /* 10 secs */ + if (runtime->rate) { - long t = runtime->period_size * 2 / runtime->rate; + long t = runtime->period_size * 2 / + (runtime->rate / 1000); wait_time = max(t, wait_time); } - wait_time = msecs_to_jiffies(wait_time * 1000); + wait_time = msecs_to_jiffies(wait_time); } for (;;) {