All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cezary Rojewski <cezary.rojewski@intel.com>
To: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: vkoul@kernel.org, alsa-devel@alsa-project.org,
	broonie@kernel.org, tiwai@suse.com, lgirdwood@gmail.com
Subject: Re: [PATCH v4 06/11] ASoC: SOF: Intel: Account for compress streams when servicing IRQs
Date: Tue, 18 Feb 2020 15:49:10 +0100	[thread overview]
Message-ID: <44e8f78b-dbb5-e03a-637e-d8a8d71f4721@intel.com> (raw)
In-Reply-To: <56ed74d5-2f03-711f-9f21-cde0ddf8ecc7@linux.intel.com>

On 2020-01-31 17:39, Pierre-Louis Bossart wrote:
> Maybe be a paranoid check but the types used in this patch seem to need 
> additional work:
> 
>> diff --git a/include/sound/hdaudio.h b/include/sound/hdaudio.h
>> index 9a8bf1eb7d69..9a24d57f0cf2 100644
>> --- a/include/sound/hdaudio.h
>> +++ b/include/sound/hdaudio.h
>> @@ -496,6 +496,7 @@ struct hdac_stream {
>>       bool locked:1;
>>       bool stripe:1;            /* apply stripe control */
>> +    unsigned long curr_pos;
> 
> 'long' is an error-prone definition...
> 
>>       /* timestamp */
>>       unsigned long start_wallclk;    /* start + minimum wallclk */
>>       unsigned long period_wallclk;    /* wallclk for period */
>> diff --git a/sound/soc/sof/intel/hda-stream.c 
>> b/sound/soc/sof/intel/hda-stream.c
>> index c0ab9bb2a797..c8920a60e346 100644
>> --- a/sound/soc/sof/intel/hda-stream.c
>> +++ b/sound/soc/sof/intel/hda-stream.c
>> @@ -571,6 +571,23 @@ bool hda_dsp_check_stream_irq(struct snd_sof_dev 
>> *sdev)
>>       return ret;
>>   }
>> +static void hda_dsp_set_bytes_transferred(struct hdac_stream *hstream,
>> +                      u64 buffer_size)
>> +{
>> +    unsigned int prev_pos;
>> +    int pos, num_bytes;
>> +
>> +    div_u64_rem(hstream->curr_pos, buffer_size, &prev_pos);
> 
> ... here you use it as a u64 value so I guess the intent was to use more 
> than 32 bits?
> 
> But then the u64 for the 'buffer size' argument is also not consistent 
> with the definition of div_u64_rem, it's got to be u32, or you wanted to 
> use div64_64_rem?
> 
> static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
> 
> prev_pos should also be declared as u32 to avoid any ambiguity.
> 
>> +    pos = snd_hdac_stream_get_pos_posbuf(hstream);
>> +
>> +    if (pos < prev_pos)
>> +        num_bytes = (buffer_size - prev_pos) +  pos;
>> +    else
>> +        num_bytes = pos - prev_pos;
>> +
>> +    hstream->curr_pos += num_bytes;
> 
> ... and here it's a never ending-increment that is likely to hit a 
> 32-bit ceiling.
> 
> I remember we made a mistake some time back on compressed stuff and 
> updated the counters to rely on 64 bits. Unless this is a hardware 
> counter (and then we should use u32 and deal with overflow), we should 
> use u64, no?

All addressed in v5, thanks for review!

  reply	other threads:[~2020-02-18 14:50 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-31 12:31 [alsa-devel] [PATCH v4 00/11] ASoC: SOF: Data probing Cezary Rojewski
2020-01-31 12:31 ` [alsa-devel] [PATCH v4 01/11] ALSA: hda: Allow for compress stream to hdac_ext_stream assignment Cezary Rojewski
2020-01-31 12:31 ` [alsa-devel] [PATCH v4 02/11] ALSA: hda: Prepare for compress stream support Cezary Rojewski
2020-01-31 12:31 ` [alsa-devel] [PATCH v4 03/11] ALSA: hda: Interrupt servicing and BDL setup for compress streams Cezary Rojewski
2020-01-31 12:31 ` [alsa-devel] [PATCH v4 04/11] ALSA: core: Expand DMA buffer information Cezary Rojewski
2020-01-31 12:31 ` [alsa-devel] [PATCH v4 05/11] ALSA: core: Implement compress page allocation and free routines Cezary Rojewski
2020-01-31 12:31 ` [alsa-devel] [PATCH v4 06/11] ASoC: SOF: Intel: Account for compress streams when servicing IRQs Cezary Rojewski
2020-01-31 16:39   ` Pierre-Louis Bossart
2020-02-18 14:49     ` Cezary Rojewski [this message]
2020-01-31 12:31 ` [alsa-devel] [PATCH v4 07/11] ASoC: SOF: Implement Probe IPC API Cezary Rojewski
2020-01-31 12:31 ` [alsa-devel] [PATCH v4 08/11] ASoC: SOF: Generic probe compress operations Cezary Rojewski
2020-01-31 12:31 ` [alsa-devel] [PATCH v4 09/11] ASoC: SOF: Intel: Probe " Cezary Rojewski
2020-01-31 17:05   ` Pierre-Louis Bossart
2020-01-31 12:31 ` [alsa-devel] [PATCH v4 10/11] ASoC: SOF: Provide probe debugfs support Cezary Rojewski
2020-01-31 12:31 ` [alsa-devel] [PATCH v4 11/11] ASoC: SOF: Intel: Add Probe compress CPU DAIs Cezary Rojewski
2020-01-31 17:02 ` [alsa-devel] [PATCH v4 00/11] ASoC: SOF: Data probing Pierre-Louis Bossart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=44e8f78b-dbb5-e03a-637e-d8a8d71f4721@intel.com \
    --to=cezary.rojewski@intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=tiwai@suse.com \
    --cc=vkoul@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.