A bug about cache inconsistency report
Quoted 23 lines
Quoted 21 lines
Quoted 11 lines
Quoted 10 lines
Quoted 8 lines
Then the next step would be to fake sg-buffer from this straight buffer. Revert the above, and modify
sgbuf.cto the following:
- Allocate a large continuous buffer
- Assign each page in this large bufferIf this still works, it's not about vmap, but it just means
that the physically ordered pages do matter -- implicitly
showing that the snooping behavior isn't properly turned on / off on the controller.To fake SG-buffer, I did this test: restore all the codes to the original, then added some codes in
snd_malloc_sgbuf_pages()like below, the result is badly niose.Quoted 8 lines
Quoted 1 line
Not really what I meant. Rather something like below (totally untested).
[Hans :] I know what you mean now and complete code like below, but the result is still noise.
OK, so indeed the vmapped address does seem matter. Interesting.
What kind of user access does produce the noise? Does it via aplay mmap mode, too?In anyway, if the vmap is a problem, it might be worked around a patch like below (again totally untested and not sure whether it's correct).
[Hans :] As I know, In the hardware layer HDAC’s stream have two data transport path : non-snoop & snoop; In the software layer ALSA-Driver have two data transport path : mmap & not
mmap(test shows, it is dependent on wav's format or mmap_flag in aplay.c). When hardware at non-snoop mode, without hardware module's help, software must mark the mem to uncacheable type: when mmap used, the mark action happened atpcm_mmap_prepare(), the not-mmap mode's mark action happened at__mark_pages_wc(). And when at not-mmap mode, the vmapped address directly used insnd_pcm_lib_write_transfer()->copy_from_user().
Quoted 7 lines
Quoted 3 lines
Well, that's usually no problem regarding that cache coherency. At least it hasn't been any issue with Intel and AMD CPUs. Does the problem happen with Intel CPU instead of VIA?
[Hans :] I don't have enough Intel/AMD machine here, up to now, only find one Intel's : HW: mother board is Dell 042P49, HDA controller is 8086:1c20, codec is cx20641.
And the same issue is seen on that machine?
[Hans :] Yes
Thanks,
Hans
Quoted 10 lines
Quoted 5 lines
Yes, of course, this path combinations(non-snoop + not-mmap) unlikely be used by most music players.
[Hans :] I complete the patch in your last mail like below, not used the vunmap & re-vmap way(it has a little problem). Result is OK now(no noise anymore).
What problem did you get with vunmap / vmap?
[Hans :] if patch like below, even the new vmapped address
new_areabe assigned todmab->area, it will not use this time, but next. This time useddmab->areastill the last one, but the old one had been vunmap, so Oops reported.That's bad. But the problem isn't as you guessed, I guess.
The allocator re-uses the pre-allocated buffer if available, and this makes things inconsistent. I'll cook later.
保密声明:
本邮件含有保密或专有信息,仅供指定收件人使用。严禁对本邮件或其内容做任何未经授权的查阅、使用、复制或转发。
CONFIDENTIAL NOTE:
This email contains confidential or legally privileged information and is for the sole use of its intended recipient. Any unauthorized review, use, copying or forwarding of this email or the content of this email is strictly prohibited.
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Quoted 28 lines · Hans Hu(SH-RD)
Quoted 28 lines
Quoted 27 lines
Quoted 12 lines
Quoted 11 lines
Quoted 9 lines
Then the next step would be to fake sg-buffer from this straight buffer. Revert the above, and modify
sgbuf.cto the following:
- Allocate a large continuous buffer
- Assign each page in this large bufferIf this still works, it's not about vmap, but it just means
that the physically ordered pages do matter -- implicitly
showing that the snooping behavior isn't properly turned on / off on the controller.To fake SG-buffer, I did this test: restore all the codes to the original, then added some codes in
snd_malloc_sgbuf_pages()like below, the result is badly niose.Quoted 8 lines
Quoted 1 line
Not really what I meant. Rather something like below (totally untested).
[Hans :] I know what you mean now and complete code like below, but the result is still noise.
OK, so indeed the vmapped address does seem matter. Interesting.
What kind of user access does produce the noise? Does it via aplay mmap mode, too?In anyway, if the vmap is a problem, it might be worked around a patch like below (again totally untested and not sure whether it's correct).
[Hans :] As I know, In the hardware layer HDAC’s stream have two data transport path : non-snoop & snoop; In the software layer ALSA-Driver have two data transport path : mmap & not
mmap(test shows, it is dependent on wav's format or mmap_flag in aplay.c). When hardware at non-snoop mode, without hardware module's help, software must mark the mem to uncacheable type: when mmap used, the mark action happened atpcm_mmap_prepare(), the not-mmap mode's mark action happened at__mark_pages_wc(). And when at not-mmap mode, the vmapped address directly used insnd_pcm_lib_write_transfer()->copy_from_user().Well, that's usually no problem regarding that cache coherency. At least it hasn't been any issue with Intel and AMD CPUs. Does the problem happen with Intel CPU instead of VIA?
Quoted 5 lines
Quoted 3 lines
[Hans :] I don't have enough Intel/AMD machine here, up to now, only find one Intel's : HW: mother board is Dell 042P49, HDA controller is 8086:1c20, codec is cx20641.
And the same issue is seen on that machine?
[Hans :] Yes
OK, then let's fix it properly.
I managed to add the non-cached type buffer allocations in the memalloc.c, so that we can reduce lots of codes in each driver side.
The patches are pushed to topic/memalloc-uc branch of my sound git tree. Please give it a try and report back whether it works for you.
Since such a change in the core code would affect many drivers, I'll postpone this for 4.20, in anyway.
thanks,
Takashi
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Quoted 33 lines
Quoted 23 lines
Quoted 21 lines
Quoted 11 lines
Quoted 10 lines
Quoted 8 lines
Then the next step would be to fake sg-buffer from this straight buffer. Revert the above, and modify
sgbuf.cto the following:
- Allocate a large continuous buffer
- Assign each page in this large bufferIf this still works, it's not about vmap, but it just means
that the physically ordered pages do matter -- implicitly
showing that the snooping behavior isn't properly turned on / off on the controller.To fake SG-buffer, I did this test: restore all the codes to the original, then added some codes in
snd_malloc_sgbuf_pages()like below, the result is badly niose.Quoted 8 lines
Quoted 1 line
Not really what I meant. Rather something like below (totally untested).
[Hans :] I know what you mean now and complete code like below, but the result is still noise.
OK, so indeed the vmapped address does seem matter. Interesting.
What kind of user access does produce the noise? Does it via aplay mmap mode, too?In anyway, if the vmap is a problem, it might be worked around a patch like below (again totally untested and not sure whether it's correct).
[Hans :] As I know, In the hardware layer HDAC’s stream have two data transport path : non-snoop & snoop; In the software layer ALSA-Driver have two data transport path : mmap & not
mmap(test shows, it is dependent on wav's format or mmap_flag in aplay.c). When hardware at non-snoop mode, without hardware module's help, software must mark the mem to uncacheable type: when mmap used, the mark action happened atpcm_mmap_prepare(), the not-mmap mode's mark action happened at__mark_pages_wc(). And when at not-mmap mode, the vmapped address directly used insnd_pcm_lib_write_transfer()->copy_from_user().Quoted 7 lines
Quoted 3 lines
Well, that's usually no problem regarding that cache coherency. At least it hasn't been any issue with Intel and AMD CPUs. Does the problem happen with Intel CPU instead of VIA?
[Hans :] I don't have enough Intel/AMD machine here, up to now, only find one Intel's : HW: mother board is Dell 042P49, HDA controller is 8086:1c20, codec is cx20641.
And the same issue is seen on that machine?
[Hans :] Yes
Quoted 7 lines
OK, then let's fix it properly.
I managed to add the non-cached type buffer allocations in the
memalloc.c, so that we can reduce lots of codes in each driver side.The patches are pushed to topic/memalloc-uc branch of my sound git tree. Please give it a try and report back whether it works for you.
Since such a change in the core code would affect many drivers, I'll postpone this for 4.20, in anyway.
[Hans :] This patch works for me.
Thank you!
Hans
保密声明:
本邮件含有保密或专有信息,仅供指定收件人使用。严禁对本邮件或其内容做任何未经授权的查阅、使用、复制或转发。
CONFIDENTIAL NOTE:
This email contains confidential or legally privileged information and is for the sole use of its intended recipient. Any unauthorized review, use, copying or forwarding of this email or the content of this email is strictly prohibited.
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel