Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1568799ybh; Thu, 16 Jul 2020 16:21:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzW1eB/hU0+yCOqBoOtnXO0yVaCB8J+GU2xOQQa7LkbkRDf2rFxcREJT8oUjLzfQCRY8B4w X-Received: by 2002:a17:906:3009:: with SMTP id 9mr5849760ejz.220.1594941674985; Thu, 16 Jul 2020 16:21:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594941674; cv=none; d=google.com; s=arc-20160816; b=E6uJSd29z3cfjwnsrTtbAO7xKGunnEfaCElOZX2b3pcqZvoX1HoKB+ACzEPiTcOnA7 12MpTAJfYPF/9XFrdinl8ZA0f9h8q+9Yk5USBt7lDrJJ3BgIvTvJaXZSe9F+4ftMD+iJ hAG23N81tV2MoejpaoZckcKug8tPjTkfkkXIMDc7gTY19ep4HAQ6SD367HXU6l9yYA+e F5Q9v2eaZgyIcIMi+hXjfvxys6kswkbl7pPrnAKQFQJthJwnrKqsSKYWKDhzaMHXdfg/ h4PkSxEkFd1FGAiPUCFOvqb8x5g0CWcZ8zQEAabbdC4L21zhJV5Adubx08qTU17JoXJU sfJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=rRlvvHVOlssZOjqWIkzRzCMnvlmtUd7Tnvbrt5nzg9E=; b=hukB01TYjqWEbDeglM49fccs4tDz4d0CFsq89+A4bO0vJpETcMd+cgDKJU8lAKzRDw J2j+gq55zJIoxmvf2ujJLnyNYrBIQJUVDznV5cU7F/PgLzfq0dnvhSLwqA6tGlBVtkNY 7wrAEC6xcAb0xZpCdq9cX/jS3iNzpkjGtKmZHh83Omvgp0fAuW2vzqEhNtu1utxcEzDl 6GIqJ5Oj3pdAG/v0ZJd8hnG8we3YEK8opEEmqpcKuqhCg6+IePxXKdGXJinGrDDdrgyw hbKZZYLT+JKNgNxK034RV0NqzPiTo3aDDhLaoF+CkItTemXj/Ifr+LV2km52BB/Bkqas CPfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=eHayiyg0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d21si3963740eja.703.2020.07.16.16.20.53; Thu, 16 Jul 2020 16:21:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=eHayiyg0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727857AbgGPXUa (ORCPT + 99 others); Thu, 16 Jul 2020 19:20:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726337AbgGPXU3 (ORCPT ); Thu, 16 Jul 2020 19:20:29 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70AABC061755 for ; Thu, 16 Jul 2020 16:20:29 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id cv18so3446134pjb.1 for ; Thu, 16 Jul 2020 16:20:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=rRlvvHVOlssZOjqWIkzRzCMnvlmtUd7Tnvbrt5nzg9E=; b=eHayiyg0bfJPU1GbuLYA++YcuhbGdyxqWe29Vgabr+F//AYpjSn5hx+bdQvykpDmsc ezsY+2hZn+5I7jW0hkEAVggqN2D1cABrwQQ1q1jdU9obkJLL5ze9Cv5A0xsfXpFZfjqo gajcWV9fpnCR9mpdItqaY1+cFqI+OC3yuo9qcpH69Fg1SZS9t8nAJN3ZsRrct2vVjaye //CVtLwhW8SMwVwggvOItzEYVUWRWUC28SBV/Bem0hfFp2g20SIgJKyU/VBeVAqn9/8l IScUuZSAgaFQypVHjyJ2AYP5k/PTvyLAtyC+ZIy2gLxHfdbl9vspQM3mNujgf4GtaFJH lsgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=rRlvvHVOlssZOjqWIkzRzCMnvlmtUd7Tnvbrt5nzg9E=; b=DR5DkHgw5OEZokoMsiKiQ+9LsJGoxB6521SlmVMiWzr4xff0wofSfG4g50g4pYWTmP FPxySnhHQbVeOtZT31ThgHl8FE7BwAICv4MCd7N/lpG+3q6JWBnjsMRYTRV4dKkQwTc0 +TEGEyKY1GOVgs6NMCRxyGHhRBIdb1UwDZSMjH8qshTwAhxkEsLVheyKWFJw9TELP9fQ D8zk6HlYTe4y9I9wMlcchFR9kxKmTduDjynfBUw6Af59xGF4uubcmPLQri+Bk6pCf4k2 3pWFw8/Pn6MtVMmpr0u/2+TNnKs2RU+jNqmVWpCRvN2e7/2r0E3Oh1kRoUJbTEy3DR5c Ir0A== X-Gm-Message-State: AOAM532hdP6OZ6S34S9BC8AvzAP9IaKk2DaZqTsn/IMcwrAQZ9/0SrRu NqrH2A8fpXWqIrv2EG/5F1/Owb4uTvMK8Q== X-Received: by 2002:a17:90a:7c4f:: with SMTP id e15mr6671510pjl.133.1594941628897; Thu, 16 Jul 2020 16:20:28 -0700 (PDT) Received: from Asurada-Nvidia (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id nk22sm912733pjb.51.2020.07.16.16.20.28 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 16 Jul 2020 16:20:28 -0700 (PDT) Date: Thu, 16 Jul 2020 16:20:02 -0700 From: Nicolin Chen To: Arnaud Ferraris Cc: alsa-devel@alsa-project.org, Timur Tabi , Xiubo Li , Fabio Estevam , Shengjiu Wang , Liam Girdwood , Mark Brown , linux-kernel@vger.kernel.org, kernel@collabora.com Subject: Re: [PATCH v2 1/2] ASoC: fsl_asrc: make sure the input and output clocks are different Message-ID: <20200716232000.GA27246@Asurada-Nvidia> References: <20200716145201.186270-1-arnaud.ferraris@collabora.com> <20200716151352.193451-1-arnaud.ferraris@collabora.com> <20200716151352.193451-2-arnaud.ferraris@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200716151352.193451-2-arnaud.ferraris@collabora.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 16, 2020 at 05:13:52PM +0200, Arnaud Ferraris wrote: > The current clock selection algorithm might select the same clock for > both input and output. This can happen when, for instance, the output > sample rate is a multiple of the input rate. What's the issue when selecting the same clock source for both input and output? Please explain it in the commit logs. > This patch makes sure it always selects distinct input and output > clocks. > > Signed-off-by: Arnaud Ferraris > --- > sound/soc/fsl/fsl_asrc.c | 11 ++++++----- > 1 file changed, 6 insertions(+), 5 deletions(-) > > diff --git a/sound/soc/fsl/fsl_asrc.c b/sound/soc/fsl/fsl_asrc.c > index 02c81d2e34ad..6d43cab6c885 100644 > --- a/sound/soc/fsl/fsl_asrc.c > +++ b/sound/soc/fsl/fsl_asrc.c > @@ -608,8 +608,8 @@ static void fsl_asrc_select_clk(struct fsl_asrc_priv *asrc_priv, > { > struct fsl_asrc_pair_priv *pair_priv = pair->private; > struct asrc_config *config = pair_priv->config; > - int rate[2], select_clk[2]; /* Array size 2 means IN and OUT */ > - int clk_rate, clk_index; > + int rate[2], select_clk[2], clk_index[2]; /* Array size 2 means IN and OUT */ > + int clk_rate; > int i = 0, j = 0; > > rate[IN] = in_rate; > @@ -618,11 +618,12 @@ static void fsl_asrc_select_clk(struct fsl_asrc_priv *asrc_priv, > /* Select proper clock source for internal ratio mode */ > for (j = 0; j < 2; j++) { > for (i = 0; i < ASRC_CLK_MAP_LEN; i++) { > - clk_index = asrc_priv->clk_map[j][i]; > - clk_rate = clk_get_rate(asrc_priv->asrck_clk[clk_index]); > + clk_index[j] = asrc_priv->clk_map[j][i]; > + clk_rate = clk_get_rate(asrc_priv->asrck_clk[clk_index[j]]); > /* Only match a perfect clock source with no remainder */ Better to update the comments here as there's a new condition. > if (clk_rate != 0 && (clk_rate / rate[j]) <= 1024 && > - (clk_rate % rate[j]) == 0) > + (clk_rate % rate[j]) == 0 && > + (j == 0 || clk_index[j] != clk_index[j-1])) clk_index[j - 1]