From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 94A01C433DF for ; Wed, 19 Aug 2020 14:22:36 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1DA3D20639 for ; Wed, 19 Aug 2020 14:22:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="s2bEw7s4" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1DA3D20639 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id B1BCF184D; Wed, 19 Aug 2020 16:21:44 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz B1BCF184D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1597846954; bh=qUHCr5DXl8CktUDfuqBMKfpSkpefGCTQrDh2OYnidZI=; h=Date:From:To:Subject:References:In-Reply-To:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=s2bEw7s4uOSRVyKUoEZEAGonrv1ndFSdB7zsThMrRp9Ds2EjA1QFzJ9uSMsmWgVRE Xal/1p7lHYkEu80L/lU+OZ6c0J1FBhjUIKIzS1h5D4nVJrortuH2CSTAG2nbF108/i NTUcOhAiOoxGHcZ0IoCg/F7NB8fTzcJCyF71CZNA= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 3B78CF80216; Wed, 19 Aug 2020 16:21:44 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id AB17EF80218; Wed, 19 Aug 2020 16:21:42 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 7A8CFF80114 for ; Wed, 19 Aug 2020 16:21:37 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 7A8CFF80114 IronPort-SDR: 2I3Xc8onKaifIjiHRV0R929JxqMfe4aGrsvD/8N9OJq1pLIcLcWvhYhYra1KVJF439rj4BNcuF tIdR+RTg55TA== X-IronPort-AV: E=McAfee;i="6000,8403,9717"; a="173159433" X-IronPort-AV: E=Sophos;i="5.76,331,1592895600"; d="scan'208";a="173159433" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Aug 2020 07:21:34 -0700 IronPort-SDR: aIdkXcW/9eo9ipWcuZQY8k/swEIS1M5HMUXXdZBXSCytEPUC3vfQgyDbVw1Up9JtQsdGBiQQnC ooHCM4wXCclQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,331,1592895600"; d="scan'208";a="327102646" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by orsmga008.jf.intel.com with ESMTP; 19 Aug 2020 07:21:30 -0700 Received: from andy by smile with local (Exim 4.94) (envelope-from ) id 1k8Oy0-009tTP-J7; Wed, 19 Aug 2020 17:21:28 +0300 Date: Wed, 19 Aug 2020 17:21:28 +0300 From: Andy Shevchenko To: Cezary Rojewski Subject: Re: [PATCH v4 02/13] ASoC: Intel: catpt: Define DSP operations Message-ID: <20200819142128.GP1891694@smile.fi.intel.com> References: <20200812205753.29115-1-cezary.rojewski@intel.com> <20200812205753.29115-3-cezary.rojewski@intel.com> <20200813185129.GB1891694@smile.fi.intel.com> <946fdd80-c89d-ee1b-6eef-e752318b55a6@intel.com> <20200818115050.GI1891694@smile.fi.intel.com> <9a733e30-8d44-edf7-1bae-5b6f935628d2@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9a733e30-8d44-edf7-1bae-5b6f935628d2@intel.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Cc: pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, filip.kaczmarski@intel.com, harshapriya.n@intel.com, marcin.barlik@intel.com, zwisler@google.com, lgirdwood@gmail.com, tiwai@suse.com, filip.proborszcz@intel.com, broonie@kernel.org, amadeuszx.slawinski@linux.intel.com, michal.wasko@intel.com, cujomalainey@chromium.org, krzysztof.hejmowski@intel.com, ppapierkowski@habana.ai, vamshi.krishna.gopal@intel.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" On Wed, Aug 19, 2020 at 03:46:30PM +0200, Cezary Rojewski wrote: > On 2020-08-18 1:50 PM, Andy Shevchenko wrote: > > On Mon, Aug 17, 2020 at 01:12:01PM +0200, Cezary Rojewski wrote: > > > On 2020-08-13 8:51 PM, Andy Shevchenko wrote: > > > > On Wed, Aug 12, 2020 at 10:57:42PM +0200, Cezary Rojewski wrote: ... > > > > > + bool lp; > > > > > + > > > > > + if (list_empty(&cdev->stream_list)) > > > > > + return catpt_dsp_select_lpclock(cdev, true, true); > > > > > + > > > > > + lp = true; > > > > > + list_for_each_entry(stream, &cdev->stream_list, node) { > > > > > + if (stream->prepared) { > > > > > + lp = false; > > > > > + break; > > > > > + } > > > > > + } > > > > > + > > > > > + return catpt_dsp_select_lpclock(cdev, lp, true); > > > > > > > > Seems too much duplication. > > > > > > > > struct catpt_stream_runtime *stream; > > > > > > > > list_for_each_entry(stream, &cdev->stream_list, node) { > > > > if (stream->prepared) > > > > return catpt_dsp_select_lpclock(cdev, false, true); > > > > } > > > > > > > > return catpt_dsp_select_lpclock(cdev, true, true); > > > > > > > > > > > > Better? > > > > > > list_first_entry (part of list_for_each_entry) expects list to be non-empty. > > > ->streal_list may be empty when invoking catpt_dsp_update_lpclock(). > > > > I didn't get this. Can you point out where is exactly problematic place? > > > > list_for_each_entry makes use of list_first_entry when initializing 'pos' > index variable. Correct. > Documentation for list_first_entry reads: "Note, that list > is expected to be not empty" Correct. > so I'm validating list's status before moving > on to the loop as stream_list may be empty when catpt_dsp_update_lpclock() > gets called. But here you missed the second part of the for-loop, i.e. exit conditional. If your assumption (that list_for_each_*() is not empty-safe) is correct, it would be disaster in global kernel source level. -- With Best Regards, Andy Shevchenko