Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1052139ybh; Tue, 21 Jul 2020 14:33:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwhBzQ/uGTl/N6XzmKJiczxGQVyPJPs7pEPowV3hnCsOKOSjaPj1AkX03+9lA6+kBWc7R0O X-Received: by 2002:a17:906:fca4:: with SMTP id qw4mr25369715ejb.362.1595367215413; Tue, 21 Jul 2020 14:33:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595367215; cv=none; d=google.com; s=arc-20160816; b=CjLb7FXVXTUM+RXANV2F7uAR4+8UzTMfKy8GietJzghwDmsZewA1tQI2HtPSg0oxp7 7Fo0wIv4ZK8J8hgMfaOLR/Wl/g5guI6CZMjmxYih9sn7Elwx3BSC7w9rVLGd6kZqCKBd cWr9mZcUqzRfS0Jn+Jdf87hJk6Rr+VHQd84O2j2wjRQFF611q6z6x9g7M9l8QcX4G7l3 Zbnm/2hnzqh2PcKz5eDDfkt3CW4+jRkgRhUV/JJi+khCPRQbJD66rORR35rCZL+DaBjM qwK88KtNLZJlnfMi+0xGjqEhUXIMeiyGLUu8vZ27ad9ZWioqgsYdTFfSIg+GHFmkzzke YC4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:ironport-sdr:ironport-sdr; bh=z/EHMMlLRSZeMu9Ex5OrnHEeGkU3AZk2LJyhhcgl9MI=; b=RNrcfjIkTmk1mHCPKAqog46qmpWaZs52NPiZ3b7BE4QRWGd1p86+u1+SlPvVLQl4ir pmHPUpNUY4bcAhEv4sJlDfFWjA7ToDTB1+uIQ2tyHUR+XNNPOf8CtFVxZUwHGX2wvQZE WNPyoH5RblkDVileKw8HgtQdufPlK6Es35+tm2lR9EM8SXmkuJ0f99Sd9X2uYWR6DzNo mNkxIDALbcgQJyHOB+UH3S4a2gFnA6oq6iLbx0981QUxrALMByGHBxzlzenbtzas6QHY eiAb9jrpYgtiVLlWFe9tUlm2/rRAzNDUZ5PDLdsxKnrsvkFex1rmhkTyH2p4jdy4xIOu 14fQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q20si13030503edw.521.2020.07.21.14.33.13; Tue, 21 Jul 2020 14:33:35 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731360AbgGUVcY (ORCPT + 99 others); Tue, 21 Jul 2020 17:32:24 -0400 Received: from mga18.intel.com ([134.134.136.126]:62112 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726658AbgGUVcW (ORCPT ); Tue, 21 Jul 2020 17:32:22 -0400 IronPort-SDR: k65/b9l/Mk6bvJLPgRCvt3tSTJj8GpUEEwd1fNzk3XjLOa4swm71FMGgtaRPW9A8FtPKJTjheg B13q11vpJr1w== X-IronPort-AV: E=McAfee;i="6000,8403,9689"; a="137737631" X-IronPort-AV: E=Sophos;i="5.75,380,1589266800"; d="scan'208";a="137737631" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jul 2020 14:32:21 -0700 IronPort-SDR: ybNbB6Dp/FbRgWS2I2DqKRYKfFdSSNj7Qg2UfmHO8E9YpeoxpHhEBrXFDuOnGvyxQ6SYg2pGly lLywEmsGCTug== X-IronPort-AV: E=Sophos;i="5.75,380,1589266800"; d="scan'208";a="462222006" Received: from mtchavar-mobl.amr.corp.intel.com (HELO [10.254.78.149]) ([10.254.78.149]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jul 2020 14:32:20 -0700 Subject: Re: [PATCH v7] ASoC: Intel: kbl_rt5663_rt5514_max98927: Fix kabylake_ssp_fixup function To: Harsha Priya , alsa-devel@alsa-project.org, broonie@kernel.org Cc: lma@semihalf.com, yang.jie@linux.intel.com, liam.r.girdwood@linux.intel.com, rad@semihalf.com, zwisler@google.com, linux-kernel@vger.kernel.org, sathya.prakash.m.r@intel.com, brndt@google.com, mw@semihalf.com, levinale@chromium.org, Vamshi Krishna Gopal References: <1595365649-8019-1-git-send-email-harshapriya.n@intel.com> From: Pierre-Louis Bossart Message-ID: Date: Tue, 21 Jul 2020 16:32:18 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <1595365649-8019-1-git-send-email-harshapriya.n@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Harsha, this looks mostly good to me, only have a couple of nit-picks below. Thanks! > kabylake_ssp_fixup function uses snd_soc_dpcm to identify the codecs DAIs. > The hw parameters are changed based on the codec DAI, > the stream is intended for. The earlier approach to get > snd_soc_dpcm was using container_of() macro on snd_pcm_hw_params. > The structures have been modified over time and snd_soc_dpcm does > not have snd_pcm_hw_params as a reference but as a copy. > This causes the current driver to crash when used. > This patch changes the way snd_soc_dpcm is extracted. > The snd_soc_pcm_runtime holds 2 dpcm > instances (one for playback and one for capture). > The 2 codecs on this SSP are dmic and speakers. > One is for capture and one is for playback respectively. > Based on the direction of the stream, > the snd_soc_dpcm is extracted from the snd_soc_pcm_runtime structure. > Tested for all use cases of the driver. Maybe reformat a bit and add newlines, this is difficult to read. > Signed-off-by: Harsha Priya > Signed-off-by: Vamshi Krishna Gopal > Tested-by: Lukasz Majczak > diff --git a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c > index 584e4f9cedc2..9f4b949cc39c 100644 > --- a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c > +++ b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c > @@ -379,22 +379,42 @@ static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd, > struct snd_interval *chan = hw_param_interval(params, > SNDRV_PCM_HW_PARAM_CHANNELS); > struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); > - struct snd_soc_dpcm *dpcm = container_of( > - params, struct snd_soc_dpcm, hw_params); > - struct snd_soc_dai_link *fe_dai_link = dpcm->fe->dai_link; > - struct snd_soc_dai_link *be_dai_link = dpcm->be->dai_link; > + struct snd_soc_dpcm *dpcm, *rtd_dpcm = NULL; The idea of initializing was also to test before dereferencing this pointer. Without the test, this is somewhat useless, tools may still complain about dereferencing a NULL pointer? > + > + /* > + * The following loop will be called only for playback stream > + * In this platform, there is only one playback device on every SSP > + */ > + for_each_dpcm_fe(rtd, SNDRV_PCM_STREAM_PLAYBACK, dpcm) { > + rtd_dpcm = dpcm; > + break; > + } > + > + /* > + * This following loop will be called only for capture stream > + * In this platform, there is only one capture device on every SSP > + */ > + for_each_dpcm_fe(rtd, SNDRV_PCM_STREAM_CAPTURE, dpcm) { > + rtd_dpcm = dpcm; > + break; > + } add if (!rtd_dpcm) return -EINVAL here? > + /* > + * The above 2 loops are mutually exclusive based on the strem direction, typo: stream > + * thus rtd_dpcm variable will never be overwritten > + */