Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1582304ybl; Wed, 8 Jan 2020 20:59:23 -0800 (PST) X-Google-Smtp-Source: APXvYqyFJ76KGEfQTfHoOs+eOeuBAzfMyO25zcmGnaPDpJKBqcWbNY7W0tipu6hq6FBK9PoN8lm2 X-Received: by 2002:a05:6830:1f95:: with SMTP id v21mr7221853otr.325.1578545963664; Wed, 08 Jan 2020 20:59:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578545963; cv=none; d=google.com; s=arc-20160816; b=qVI96G6EPHUzijbi9ZmPmp9AD9C0aizF8nnwcOql4oLkGkuQEQj70IXs+dwjtwqCJy gGj/rOGb7rkhtrngScjK2xSb2lZ5YdWt0FSK9VqtYMxaSSRaE9nMfSf6lTXWPIgUIefX Fu1MP6Pfnkw373p/BRLeXvftNUHbQ6VQgnDqra/yHubD2LTJ0Zz+ogjL5AT+lYaGpDb+ np5fgifQGeDUbWEVVV4kH2ahQ7XB89lgWPlLBYAuafduWJjxaxCSFGRtOM9NXml8hquf goZDhyHeA5jm4qAD7y9bew7Hot3K2+YjW+8aeFsXQ8wrj8J82idloj8kpfxFZ0kCgbbY BF3g== 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=/VMi5RKokSD1bSLba837QPSe93h6ZNWDgrRnva2rnDU=; b=cyCHtiBgKEZ6su7xBbU0i/HbXMyld4z8RrTn1PQZJczqeFNV0lJbi2cEDcKY0YC7MS TxDqvEkbFlQkoEvEvsKf25XzM7LkUMl/mrUtkXOIJGLYsIAHbg05sY4O5tK8uH71OGVq hEH/yJOVjMvCjVgrxQ3suxMJFsR36TTDrPwcQWfRJxStvmShatHHZnRzYcsbMGZA6R15 +GQ0dO6sm5Fj6uR2Ifyinj7qY7Ah7od40VwR1mkYWs5AXA0eOOLfQUGMBvOSfjxUzI6F 9dcBLZzGzzy1AWTiG2XfxZq20P7xOgarTU2fy50370lsaeRfV8uaqa+TDC7e+tDKypu1 wdvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ag8nqYeW; 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 1si2880299oip.277.2020.01.08.20.59.10; Wed, 08 Jan 2020 20:59:23 -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=ag8nqYeW; 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 S1727905AbgAIE63 (ORCPT + 99 others); Wed, 8 Jan 2020 23:58:29 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:36441 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726913AbgAIE63 (ORCPT ); Wed, 8 Jan 2020 23:58:29 -0500 Received: by mail-wm1-f66.google.com with SMTP id p17so1324322wma.1; Wed, 08 Jan 2020 20:58:27 -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=/VMi5RKokSD1bSLba837QPSe93h6ZNWDgrRnva2rnDU=; b=ag8nqYeWGk2pLTA0jJLgOeLPs6j/8VzJrYnQflUrxpAuHEVC545WyJuOXttmHNsluR 2ZH1X28E9gpXSqn3YiRnWsqI1l5a4IhoFaMKgH2WI8DjxScbecbQm4qB9TN3Wdi4pXSN zOl7Tn/UsEHSTnZEl1pQhc5Swjg1eW7aWK1ayjVqOTck9E8bGRamt65sOZCNXcQaD/53 IO0RwTVbet55WKsk3d696k0Ite+YoCHee/1AP5OuScjTBQh7c+JKQ5+QgMJuKz/paBD0 gK5CJ4Biuo94bkQquF3KhJiAdb5aL3zDPDJ4Fve8sdy/x6liyacgigvgwia0FqOrI6yD ybaw== 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=/VMi5RKokSD1bSLba837QPSe93h6ZNWDgrRnva2rnDU=; b=KQ+FL+epLt+yLc50Eupq7jtAfKZYZ43rrhZMb+ldaop3y7W/M5SyjoX5kGzEEsXFjA hEQMx99mvue7PZ0O10Db8r0jn/ogr2mQw15ugQ7cZBMkdtQ+r5AVFq8mZI9a26StsHog W09zRu8h8eR0lCJYxrpU56paJ+s3dstP7FIkAJn7gYUnUN7kAMGjajU+xj+Ka7E6Vlex nZe50k4IEWk0cVa/EbwQhFE86kr+H96RZBqEf+hazaxv4QUcEwJ98nhJcKVEPOxjs/Dn RXvlCHRYNGsFSyG/z0VIUx6z5FesLM2EXwU0AfaVtQTqobmctjVx0mgS0uiLYP9uBqE7 MH5g== X-Gm-Message-State: APjAAAWMuAUnirIe6CYTbvCYip4/hrXZsBApAWRNQQNNhTgHETBmdYks 3zS5Twzi3YH/827WdyInHPpoQIKBIJS4LUyvxjQ= X-Received: by 2002:a1c:488a:: with SMTP id v132mr2154030wma.153.1578545906700; Wed, 08 Jan 2020 20:58:26 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: John Stultz Date: Wed, 8 Jan 2020 20:58:15 -0800 Message-ID: Subject: Re: [PATCH V6 3/4] ASoC: pcm_dmaengine: Extract snd_dmaengine_pcm_refine_runtime_hwparams To: Shengjiu Wang Cc: timur@kernel.org, nicoleotsuka@gmail.com, Xiubo.Lee@gmail.com, festevam@gmail.com, lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org, linuxppc-dev@lists.ozlabs.org, Linux Kernel Mailing List , Rob Herring , Mark Rutland , devicetree@vger.kernel.org, lars@metafoo.de 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, 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? thanks -john