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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 9473FC433EF for ; Wed, 27 Apr 2022 10:38:02 +0000 (UTC) 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 1A97B1779; Wed, 27 Apr 2022 12:37:10 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 1A97B1779 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1651055880; bh=lZLiGHVWuFZSASNVf7fH/qfz+Cn+fM7FoWXZ1ncVXRs=; h=Date:From:To:Subject:References:In-Reply-To:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=d/9aTXJKAXZmekH7MITUYSALCjvA97TLbJLep4WF1EJKjbRASdKYegdprShkclUQR vs1S3kSQCCbw8hUGMScrZFdIQwsPK1fFSvDkQf4qlL3YqJ1viROMP8oBFO0sqbkfVk Uhj86ryHeVlhk860t/7vNVAE0C+6DJkt6UbOe468= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id A5F9EF80155; Wed, 27 Apr 2022 12:37:09 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id CF014F8016E; Wed, 27 Apr 2022 12:37:07 +0200 (CEST) Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 21256F80152 for ; Wed, 27 Apr 2022 12:37:04 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 21256F80152 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="MHXUq4mU" Received: by mail-pj1-x1034.google.com with SMTP id cx11-20020a17090afd8b00b001d9fe5965b3so2707168pjb.3 for ; Wed, 27 Apr 2022 03:37:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=mWK3Ah0FDk22pf9sujkcYspgwVYCPqr0+KwmeDIU3uQ=; b=MHXUq4mUw74vqzVFqwrQdLU4aBqFCaf5uW2+N1mMXPHa+8um6EJ9n9ZrkgxthmEKJv SqOa1SD4dxp8OBo0A4cp+TOoYmVCZHwGsWfpufoOB+MhC7TMfInW61siUW3Olx/X4jRr y6o4daF6MvDT9FknB+NRUfn4zcUsS4bmUxQVg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=mWK3Ah0FDk22pf9sujkcYspgwVYCPqr0+KwmeDIU3uQ=; b=msqhyrdr2CdOIAbkwIZSuOx9eIhQ5Phi/YhnAkeHf3WHhUjFeW1VcmsHOxuf1T8TTi 6gjMzZm7rMJbWs8NU8WP+RCjuyCxFv3lKbqQgWWLX0157f95nRdiPt3i7uQL44mwlqRT tGwfv84jwLWzRmxRl6b7jT4fD0fRrgWznHjTffJ9GFvmwVMnPSz5RyRJeA+aHGBCyD7K Rt/W+CqilB6AnaG9p2MGIJqCbyOrrvc8FSh3q7UhercvwWce69Mf8RhKMO6ub6alq5KB aIiR3a0I75FTI4k4dndD5JetaBLI93xDaPE2c5pJ2Rm1H4JrtcwMOgjhdWV1hpjKRi+9 Kf+w== X-Gm-Message-State: AOAM533EjGtdRUkENNEY9eBoRkU7rbDrUFBiGfsvSNBpO0dKTzF8tqK2 xmyi3VWSQ9gsSRdLcV09B/SaUA== X-Google-Smtp-Source: ABdhPJyIfZE7AnuSSKuBTrhRzVlSuqyrTXEssSf4e9t4V/jp+JJY8YclrTyAC5EbCFgEr/RQAQ8h0Q== X-Received: by 2002:a17:902:b286:b0:15b:335b:53e6 with SMTP id u6-20020a170902b28600b0015b335b53e6mr27552600plr.169.1651055822228; Wed, 27 Apr 2022 03:37:02 -0700 (PDT) Received: from google.com ([2401:fa00:8f:203:8e2d:263:26e7:c039]) by smtp.gmail.com with ESMTPSA id h8-20020a17090a3d0800b001cd4989ff4asm2403647pjc.17.2022.04.27.03.36.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 03:37:01 -0700 (PDT) Date: Wed, 27 Apr 2022 19:36:57 +0900 From: Sergey Senozhatsky To: Peter Ujfalusi Subject: Re: [PATCH] ASoC: SOF: ipc3-topology: Correct get_control_data for non bytes payload Message-ID: References: <20220427085011.21805-1-peter.ujfalusi@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220427085011.21805-1-peter.ujfalusi@linux.intel.com> Cc: pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, kai.vehmanen@linux.intel.com, cujomalainey@google.com, ranjani.sridharan@linux.intel.com, lgirdwood@gmail.com, senozhatsky@chromium.org, broonie@kernel.org 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 (22/04/27 11:50), Peter Ujfalusi wrote: > @@ -784,16 +785,23 @@ static int sof_get_control_data(struct snd_soc_component *scomp, > } > > cdata = wdata[i].control->ipc_control_data; > - wdata[i].pdata = cdata->data; > - if (!wdata[i].pdata) > - return -EINVAL; > > /* make sure data is valid - data can be updated at runtime */ > - if (widget->dobj.widget.kcontrol_type[i] == SND_SOC_TPLG_TYPE_BYTES && > - wdata[i].pdata->magic != SOF_ABI_MAGIC) > - return -EINVAL; > + if (widget->dobj.widget.kcontrol_type[i] == SND_SOC_TPLG_TYPE_BYTES) { > + if (!cdata->data) > + return -EINVAL; > + > + if (cdata->data->magic != SOF_ABI_MAGIC) > + return -EINVAL; > + > + wdata[i].pdata = cdata->data->data; > + wdata[i].pdata_size = cdata->data->size; > + } else { > + wdata[i].pdata = cdata->chanv; /* points to the control data union */ > + wdata[i].pdata_size = wdata[i].control->size; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ A question, so here wdata[i].control->size is scontrol->size = struct_size(scontrol->control_data, chanv, le32_to_cpu(mc->num_channels)); Right? If so, then is this really what we memcpy()? We memcpy() control->data->chanv and its size is `sizeof(chanv) * le32_to_cpu(mc->num_channels)`, isn't it? [..] > if (ipc_data_size) { > for (i = 0; i < widget->num_kcontrols; i++) { > + if (!wdata[i].pdata_size) > + continue; > + > + memcpy(&process->data[offset], wdata[i].pdata, > + wdata[i].pdata_size); > + offset += wdata[i].pdata_size; > } > } So should sof_get_control_data() have instead of this wdata[i].pdata_size = wdata[i].control->size; something like this wdata[i].pdata_size = wdata[i].control->size - sizeof(struct sof_ipc_ctrl_data); So that we will copy payload data, which is a bunch of chanv structs 8 bytes each.