Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp130458ybl; Fri, 17 Jan 2020 20:06:16 -0800 (PST) X-Google-Smtp-Source: APXvYqwTjZHIptmXHiZxDqeTlTQWLqP3l+U+PUvl6t80m4jPpUuR3UqwyTFqOsDBJdNrlUpwUEoG X-Received: by 2002:a9d:6181:: with SMTP id g1mr8860640otk.104.1579320376123; Fri, 17 Jan 2020 20:06:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579320376; cv=none; d=google.com; s=arc-20160816; b=fyuIA1CWqv26NwLh1ndCciKw4QRICKXmrT0IYZmubc1hM85UrDMwFw6P/TOynAWzse d6nonBSwLBKt/OImkBc/aE/zpseNRqw6qPmMdt1Zz+UFaNfri/wk+AN7a6UP1ENqi2eP rA0aqJcbr+ZYtKLnGTQK1/yW8p85hWXmE55HaYK4uZiTY9o0COXFl/DBP6wFmUIggoNM 5Rqx2dPThfWZ9jrsWaj9YSKXaGGiHpAi3EeE02mNlAh9Ug+TUAm/ZKuqQU+OrkqQO2pZ 7GqdBG2rnbTtsy8de/MRxhuXZO6x4Dz9J+xx6CntVoZFDOB32r28yMukS3TUJUdAOegC TyEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Vb5cyWLJV5ZR0F5iDmlf/8PvEYOZeZfUNSdNGtLvZJI=; b=y6ajmqqyBz7kBWLLC1ZHtkEzXHODExZokoG8S2J/fWtonvmQ4oci/1sI5bOLnub3RE D/JyTsOQC9HMrLxvMGs62y+4YA0b63+Ec0DeedpHB4eEov5uuyR7/E4r5z2VRMK06tKg FOYZIO2sWVAeteNsKIxnmTS0iIOLqAAwITYTkCywaDgqv2/TencW0gJ8JFsXSZEHulcZ wUrSPKx+2I1gQJ9Q+5vKBZzugb0Ka+iX/425778pT2gh2PgU35yAEjsFjmTj/nWwJwQ9 tLBGszXEMzpUC1fdcIxzC1UCSl6nYY/n7ahLlEKejjVR6heIgh1xRnPugxH5ykOOaPqn XyXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oJRPpWc8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q9si14388620oif.92.2020.01.17.20.05.31; Fri, 17 Jan 2020 20:06:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oJRPpWc8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727007AbgARECQ (ORCPT + 99 others); Fri, 17 Jan 2020 23:02:16 -0500 Received: from mail-ot1-f65.google.com ([209.85.210.65]:34547 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726744AbgARECQ (ORCPT ); Fri, 17 Jan 2020 23:02:16 -0500 Received: by mail-ot1-f65.google.com with SMTP id a15so24357376otf.1 for ; Fri, 17 Jan 2020 20:02:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Vb5cyWLJV5ZR0F5iDmlf/8PvEYOZeZfUNSdNGtLvZJI=; b=oJRPpWc86aW8ElClMpbeSmGps0a3/zd+opvvpOkEBC8hVNCtjdLp5PzynS4G4c56BU 3VSWjMLxP2DgfZAY4Ynqq28PxgwynoAx/Ega1iY5vHADe1nx28Ss+oVjWt9i17loT/Tn /hJnGFOj25AP5GZ9CftweA9mgLEHxvhOGHMWu4SjXw7OsNretKxT+LYInNxlwjS8R8tX Kvx6LsE4imBsm/FB7RCiHcxLA7Gd4WNxHPzi9y/zW+G3PDYWzBmvAJI8YG+Bi4dU8j07 3cRGWMsJ6Qcd04JnH4bRW0YK5AQHQQcVmjuz3NgVrXoa9eJdOhYIIChJqAExfXq0gD00 gpLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Vb5cyWLJV5ZR0F5iDmlf/8PvEYOZeZfUNSdNGtLvZJI=; b=Uuo825C52W2Nc1QMIP9eXTxG6QVfSqBRz5e1r9ZKxiAgJrqRYIYEeEFz3WjHDnU9hQ HCkj9yV268cocQniLoFAihkFjGWC0RuBn4cqXYuvt5DQwzTeYPoailzhDSVURfCnoFxF RKB8VSarNWo8qyZGQLjwJVYaCcggy66ufg09HY8gTd9kTTgqf19PmNx1w812ZRTNg+t0 vgke/ceekzjUSopuDDQ/YWZMCT4Wi9HKG28IJkzaiL3L7hGBXzS2x1Qu6cQEaJ7yfCHd 7l15+uYswBrvV9RCkIEd0HS+Si9aJHz9ZY9keQ9yosV7oOfpaMNWdhyVlcTWfZmdBMKA piuQ== X-Gm-Message-State: APjAAAXgYeeYx0ufDuiJWY/v7uHwz72zdv6wnXKzx0f7ouoZ9gqSQXQj l2xvI3qCOajA/VAm3VE+iPYTd5j0E/Tawhobzqb6Aw== X-Received: by 2002:a9d:66ca:: with SMTP id t10mr8495244otm.352.1579320135542; Fri, 17 Jan 2020 20:02:15 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: John Stultz Date: Fri, 17 Jan 2020 20:02:04 -0800 Message-ID: Subject: Re: [alsa-devel] [PATCH V6 3/4] ASoC: pcm_dmaengine: Extract snd_dmaengine_pcm_refine_runtime_hwparams To: Shengjiu Wang Cc: Shengjiu Wang , Mark Rutland , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Linux-ALSA , Lars-Peter Clausen , Timur Tabi , Xiubo Li , linuxppc-dev@lists.ozlabs.org, Takashi Iwai , Liam Girdwood , Rob Herring , Nicolin Chen , Mark Brown , Fabio Estevam , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 16, 2020 at 11:11 PM Shengjiu Wang wrote: > > Hi > > On Thu, Jan 16, 2020 at 1:56 PM John Stultz wrote: > > > > On Wed, Jan 8, 2020 at 8:58 PM John Stultz wrote: > > > On Thu, Sep 26, 2019 at 6:50 PM Shengjiu Wang wrote: > > > > > > > > When set the runtime hardware parameters, we may need to query > > > > the capability of DMA to complete the parameters. > > > > > > > > This patch is to Extract this operation from > > > > dmaengine_pcm_set_runtime_hwparams function to a separate function > > > > snd_dmaengine_pcm_refine_runtime_hwparams, that other components > > > > which need this feature can call this function. > > > > > > > > Signed-off-by: Shengjiu Wang > > > > Reviewed-by: Nicolin Chen > > > > > > As a heads up, this patch seems to be causing a regression on the HiKey board. > > > > > > On boot up I'm seeing: > > > [ 17.721424] hi6210_i2s f7118000.i2s: ASoC: can't open component > > > f7118000.i2s: -6 > > > > > > And HDMI audio isn't working. With this patch reverted, audio works again. > > > > > > > > > > diff --git a/sound/core/pcm_dmaengine.c b/sound/core/pcm_dmaengine.c > > > > index 89a05926ac73..5749a8a49784 100644 > > > > --- a/sound/core/pcm_dmaengine.c > > > > +++ b/sound/core/pcm_dmaengine.c > > > > @@ -369,4 +369,87 @@ int snd_dmaengine_pcm_close_release_chan(struct snd_pcm_substream *substream) > > > ... > > > > + ret = dma_get_slave_caps(chan, &dma_caps); > > > > + if (ret == 0) { > > > > + if (dma_caps.cmd_pause && dma_caps.cmd_resume) > > > > + hw->info |= SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME; > > > > + if (dma_caps.residue_granularity <= DMA_RESIDUE_GRANULARITY_SEGMENT) > > > > + hw->info |= SNDRV_PCM_INFO_BATCH; > > > > + > > > > + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) > > > > + addr_widths = dma_caps.dst_addr_widths; > > > > + else > > > > + addr_widths = dma_caps.src_addr_widths; > > > > + } > > > > > > It seems a failing ret from dma_get_slave_caps() here is being returned... > > > > > > > + > > > > + /* > > > > + * If SND_DMAENGINE_PCM_DAI_FLAG_PACK is set keep > > > > + * hw.formats set to 0, meaning no restrictions are in place. > > > > + * In this case it's the responsibility of the DAI driver to > > > > + * provide the supported format information. > > > > + */ > > > > + if (!(dma_data->flags & SND_DMAENGINE_PCM_DAI_FLAG_PACK)) > > > > + /* > > > > + * Prepare formats mask for valid/allowed sample types. If the > > > > + * dma does not have support for the given physical word size, > > > > + * it needs to be masked out so user space can not use the > > > > + * format which produces corrupted audio. > > > > + * In case the dma driver does not implement the slave_caps the > > > > + * default assumption is that it supports 1, 2 and 4 bytes > > > > + * widths. > > > > + */ > > > > + for (i = SNDRV_PCM_FORMAT_FIRST; i <= SNDRV_PCM_FORMAT_LAST; i++) { > > > > + int bits = snd_pcm_format_physical_width(i); > > > > + > > > > + /* > > > > + * Enable only samples with DMA supported physical > > > > + * widths > > > > + */ > > > > + switch (bits) { > > > > + case 8: > > > > + case 16: > > > > + case 24: > > > > + case 32: > > > > + case 64: > > > > + if (addr_widths & (1 << (bits / 8))) > > > > + hw->formats |= pcm_format_to_bits(i); > > > > + break; > > > > + default: > > > > + /* Unsupported types */ > > > > + break; > > > > + } > > > > + } > > > > + > > > > + return ret; > > > > > > ... down here. > > > > > > Where as in the old code... > > > > > > > diff --git a/sound/soc/soc-generic-dmaengine-pcm.c b/sound/soc/soc-generic-dmaengine-pcm.c > > > > index 748f5f641002..b9f147eaf7c4 100644 > > > > --- a/sound/soc/soc-generic-dmaengine-pcm.c > > > > +++ b/sound/soc/soc-generic-dmaengine-pcm.c > > > > > > > @@ -145,56 +140,12 @@ static int dmaengine_pcm_set_runtime_hwparams(struct snd_pcm_substream *substrea > > > > if (pcm->flags & SND_DMAENGINE_PCM_FLAG_NO_RESIDUE) > > > > hw.info |= SNDRV_PCM_INFO_BATCH; > > > > > > > > - ret = dma_get_slave_caps(chan, &dma_caps); > > > > - if (ret == 0) { > > > > - if (dma_caps.cmd_pause && dma_caps.cmd_resume) > > > > - hw.info |= SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME; > > > > - if (dma_caps.residue_granularity <= DMA_RESIDUE_GRANULARITY_SEGMENT) > > > > - hw.info |= SNDRV_PCM_INFO_BATCH; > > > > - > > > > - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) > > > > - addr_widths = dma_caps.dst_addr_widths; > > > > - else > > > > - addr_widths = dma_caps.src_addr_widths; > > > > - } > > > > > > ...the ret from dma_get_slave_caps() checked above, but is not > > > actually returned. > > > > > > Suggestions on how to sort this out? > > > > Just wanted to check in on this, as I'm still seeing this regression with -rc6. > > > Compare with the old code. it seems that we shouldn't check the return value. > > Could you help to test below changes? > > --- a/sound/soc/soc-generic-dmaengine-pcm.c > +++ b/sound/soc/soc-generic-dmaengine-pcm.c > @@ -138,12 +138,10 @@ dmaengine_pcm_set_runtime_hwparams(struct > snd_soc_component *component, > if (pcm->flags & SND_DMAENGINE_PCM_FLAG_NO_RESIDUE) > hw.info |= SNDRV_PCM_INFO_BATCH; > > - ret = snd_dmaengine_pcm_refine_runtime_hwparams(substream, > + snd_dmaengine_pcm_refine_runtime_hwparams(substream, > dma_data, > &hw, > chan); > - if (ret) > - return ret; > > return snd_soc_set_runtime_hwparams(substream, &hw); > } Yes, thanks for taking a look at this! Your patch does appear to avoid the regression. (Though you'll want to drop the ret declaration to avoid "warning: unused variable 'ret'" compiler warnings.) thanks -john