Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp3039476pxa; Tue, 18 Aug 2020 05:10:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxB3j3ph5j8cEwqa1/8xdM0pjIYzeMUgohlGWtaFutBYufTsNzk9FmvRJFhgExjxYM5jHkr X-Received: by 2002:a17:906:a00d:: with SMTP id p13mr20827535ejy.535.1597752642990; Tue, 18 Aug 2020 05:10:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597752642; cv=none; d=google.com; s=arc-20160816; b=VmOU+tg54mSJ/ux+HzTpvgzrUbyv+bRKSx8pJ5Z+ODabmrbpKV6SaaKz9bHtY8CuUS +A70Vpgb69AAH3IAwmjmRNxi0eq4nS9qNogsHaHj5O4wHziQCMmBP8OHk8M8TqmxvIhK KeqkBTXF39C0CupbHfLoSJATtfFvUC+VCYlk3Pm8rh8BQ7sHOyqU8io/upkr9DUmvRYY NP8wvZmbU2f7IHfgCMrzq/8BvocbFPxVQK67B8mobWE5nVIOc22CnlO+wEWIGATAotxk K+baeMglXx4YB5LDh3Aq/LU1d7rNwwaFv3Hwtqwo/ZlXuKQxSyV0jGseEg/UKE2ZfYBZ UAXA== 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=7jQO+J17MJFQ3m84CKWzWSFb/sLF/20eL/p8inTicHg=; b=MJHb8GclYGBf76lauXOJ4hOnPRm9kBzGKEdhIOUUdIndRazjFSFE+yeIXmtBFE4FdT M5WwYGb1AeaKGQm6YppiWIe36+89s52Bjz3RzAS5MV9UzWasedxMzkiiIMr6BXy+Tqr9 Kak89/gg9HOCu7EC3b5xzyUm2YkJ9f/h1avvzIl+InT98/0fFiYbPzUiDnzYwEdKEz3w Twka9aiKvzYaUxgpBuM1LDxWbAYTNagPZ1AZg3KuHr6ohGFDGrLN0Kaynw9zFVXsC2tR Q6j67BPdpNsKBLZ9M19C0mIL/gz8uvUv3b785b004VpO9sbMkfe0muojscC6pMWOVBDD DrFQ== 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 us11si13476943ejb.699.2020.08.18.05.10.19; Tue, 18 Aug 2020 05:10:42 -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 S1726697AbgHRMJp (ORCPT + 99 others); Tue, 18 Aug 2020 08:09:45 -0400 Received: from mga03.intel.com ([134.134.136.65]:46057 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726357AbgHRMJo (ORCPT ); Tue, 18 Aug 2020 08:09:44 -0400 IronPort-SDR: mmmdvIUZushEk/qYYbXX2z8Gd7rJK9+ntXq/6e4i9HIrGcB34CabCWTMpqKD9V/+HvBiy6gKyJ /mP2UOwrTTdQ== X-IronPort-AV: E=McAfee;i="6000,8403,9716"; a="154858783" X-IronPort-AV: E=Sophos;i="5.76,327,1592895600"; d="scan'208";a="154858783" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Aug 2020 05:09:44 -0700 IronPort-SDR: nE7KDIMg9QlBsdRoU29DOvkkZeyvCbLlCKWCcoa2bwJdcra3a1uGTS6k/nIb8mxGuhU4DUbT8K LGh5G+j7mBxQ== X-IronPort-AV: E=Sophos;i="5.76,327,1592895600"; d="scan'208";a="471783463" Received: from kumaraaj-mobl1.amr.corp.intel.com (HELO [10.251.23.85]) ([10.251.23.85]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Aug 2020 05:09:42 -0700 Subject: Re: [PATCH 2/2] soundwire: fix port_ready[] dynamic allocation in mipi_disco and ASoC codecs To: Vinod Koul , Bard Liao Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, tiwai@suse.de, broonie@kernel.org, gregkh@linuxfoundation.org, jank@cadence.com, srinivas.kandagatla@linaro.org, rander.wang@linux.intel.com, ranjani.sridharan@linux.intel.com, hui.wang@canonical.com, sanyog.r.kale@intel.com, mengdong.lin@intel.com, bard.liao@intel.com References: <20200817174727.15139-1-yung-chuan.liao@linux.intel.com> <20200817174727.15139-3-yung-chuan.liao@linux.intel.com> <20200818063659.GW2639@vkoul-mobl> From: Pierre-Louis Bossart Message-ID: Date: Tue, 18 Aug 2020 07:09:41 -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: <20200818063659.GW2639@vkoul-mobl> 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 On 8/18/20 1:36 AM, Vinod Koul wrote: > On 18-08-20, 01:47, Bard Liao wrote: >> From: Pierre-Louis Bossart >> >> The existing code allocates memory for the total number of ports. >> This only works if the ports are contiguous, but will break if e.g. a >> Devices uses port0, 1, and 14. The port_ready[] array would contain 3 >> elements, which would lead to an out-of-bounds access. Conversely in >> other cases, the wrong port index would be used leading to timeouts on >> prepare. >> >> This can be fixed by allocating for the worst-case of 15 >> ports (DP0..DP14). In addition since the number is now fixed, we can >> use an array instead of a dynamic allocation. >> >> Signed-off-by: Pierre-Louis Bossart >> Reviewed-by: Rander Wang >> Reviewed-by: Guennadi Liakhovetski >> Signed-off-by: Bard Liao >> --- >> drivers/soundwire/mipi_disco.c | 18 +----------------- >> drivers/soundwire/slave.c | 4 ++++ >> include/linux/soundwire/sdw.h | 2 +- >> sound/soc/codecs/max98373-sdw.c | 15 +-------------- >> sound/soc/codecs/rt1308-sdw.c | 14 +------------- >> sound/soc/codecs/rt5682-sdw.c | 15 +-------------- >> sound/soc/codecs/rt700-sdw.c | 15 +-------------- >> sound/soc/codecs/rt711-sdw.c | 15 +-------------- >> sound/soc/codecs/rt715-sdw.c | 33 +-------------------------------- > > This looks fine, but the asoc changes are not dependent, so maybe we > should split them up and then can go thru Mark. Or Mark acks, either way > would work for me There are 3 dependencies that we tracked between SoundWire and ASoC subsystems: a) addition of SDCA control macro (needed before SDCA codec drivers can be shared) b) this series - we could indeed submit the codec changes to Mark's tree separately, but then the SoundWire tree would be broken: the codec drivers would still try to allocate dynamically what is now a fixed-size array. c) configuration of the interrupt masks in codec drivers instead of hard-coded in bus driver + spurious parity error workaround (not posted yet but ready). The changes in ASoC codecs are really only on the initialization part (either removing a dynamic allocation or setting masks), there's no functional change otherwise. I think the simplest to avoid multiple back-and-forth is to have these small interface/initialization changes merged through the SoundWire subsystem, then merged by Mark from a single immutable tag. Would this work for everyone? In addition, there's a WIP change to regmap to add support for SoundWire 1.2 MBQ-based register access, but this only affects regmap and ASoC trees, all handled by Mark. I don't think we have any other cross-tree changes planned for now, the SDCA infrastructure plumbing is still rather open.