<p>Hi Christian,</p><p><br></p><p>Can you help explain more detail under what circumstances userspace mapping</p><p>will be problematic, you mean cached mappings also need adjustment in</p><p>function ttm_prot_from_caching?</p><p><br></p><p>Regards,</p><p>Cong.</p><div id="cs2c_mail_sigature"><p></p></div><p></p><div id="re" style="margin-left:0.5em;padding-left:0.5em;border-left:1px solid green;"><br><br><br>
<div style="background-color:#f5f7fa"><b>主 题:</b><span id="subject">Re: 回复: Re: 回复: Re: [PATCH v1 1/2] drm/qxl: replace ioremap by ioremap_cache on arm64</span>
<br><b>日 期:</b><span id="date">2022-03-23 18:17</span>
<br><b>发件人:</b><span id="from">Christian König</span>
<br><b>收件人:</b><span id="to">liucong2@kylinos.cnairlied@redhat.comkraxel@redhat.comairlied@linux.iedaniel@ffwll.chray.huang@amd.comvirtualization@lists.linux-foundation.orgspice-devel@lists.freedesktop.orgdri-devel@lists.freedesktop.org</span>
</div><br>
<div id="content"><div class="viewer_part"><div><meta http-equiv="Content-Type" content="text/html; charset=utf-8">Hi Cong,<br>
<br>
yes I've seen that, but that is still not sufficient.<br>
<br>
You need to update the check in ttm_module.c as well or otherwise
your userspace mapping might not work correctly either.<br>
<br>
Regards,<br>
Christian. <br>
<br>
<div class="moz-cite-prefix">Am 23.03.22 um 11:00 schrieb <a class="moz-txt-link-abbreviated" href="mailto:liucong2@kylinos.cn">liucong2@kylinos.cn</a>:<br>
</div><blockquote type="cite" cite="mid:odhwkkfdf7-odj6iduf90@nsmail6.0"> <br>
<p>Hi <span style="background-color: rgb(245, 247, 250);">Christian,</span></p><p><br>
</p><p>another commit fix the case in ttm. I send two patches at the
same time, but seems I miss</p><p> '--cover-letter' when run format-patch or some other bad
operation.</p><p>----</p><div id="cs2c_mail_sigature"><p><br>
</p><p>Regards,</p><p>Cong.</p></div><div id="re" style="margin-left:0.5em;padding-left:0.5em;border-left:1px
solid green;"><br>
<br>
<br>
<div style="background-color:#f5f7fa"><b>主 题:</b><span id="subject">Re: 回复: Re: [PATCH v1 1/2] drm/qxl: replace
ioremap by ioremap_cache on arm64</span> <br>
<b>日 期:</b><span id="date">2022-03-23 17:34</span> <br>
<b>发件人:</b><span id="from">Christian König</span> <br>
<b>收件人:</b><span id="to"><a class="moz-txt-link-abbreviated" href="mailto:liucong2@kylinos.cnairlied@redhat.comkraxel@redhat.comairlied@linux.iedaniel@ffwll.chray.huang@amd.comvirtualization@lists.linux-foundation.orgspice-devel@lists.freedesktop.orgdri-devel@lists.freedesktop.org">liucong2@kylinos.cnairlied@redhat.comkraxel@redhat.comairlied@linux.iedaniel@ffwll.chray.huang@amd.comvirtualization@lists.linux-foundation.orgspice-devel@lists.freedesktop.orgdri-devel@lists.freedesktop.org</a></span>
</div><br>
<div id="content"><div class="viewer_part"><div>Hi Cong,<br>
<br>
well than Dave must decide what to do here.<br>
<br>
When QXL emulates a device it should also not use
memory accesses which won't work on a physical device.<br>
<br>
BTW: Your patch is really buggy, it misses the cases in
ttm_module.c<br>
<br>
Regards,<br>
Christian.<br>
<br>
<div class="moz-cite-prefix">Am 23.03.22 um 09:48 schrieb
<a class="moz-txt-link-abbreviated
moz-txt-link-freetext" href="mailto:liucong2@kylinos.cn" moz-do-not-send="true">liucong2@kylinos.cn</a>:<br>
</div><blockquote type="cite" cite="mid:18a8ijpwp6j-18a9shjbr0c@nsmail6.0"><p>Hi Christian,</p><p><br>
</p><p>according to 'Arm Architecture Reference Manual
Armv8,for Armv8-A</p><p>architecture profile' pdf E2.6.5</p><p><br>
</p><p>E2.6.5 Generation of Alignment faults by load/store
multiple accesses to</p><p> Device memory</p><p><br>
</p><p><span style="white-space:pre"> </span>When
FEAT_LSMAOC is implemented and the value of the
applicable nTLSMD</p><p><span style="white-space:pre"> </span>field is 0, any
memory access by an AArch32 Load Multiple or
Store </p><p><span style="white-space:pre"> </span>Multiple
instruction to an address that the stage 1
translation </p><p><span style="white-space:pre"> </span>assigns as
Device-nGRE, Device-nGnRE, or Device-nGnRnE
generates </p><p><span style="white-space: pre;"> </span>an Alignment
fault.</p><br>
<p>so it seems not just some ARM boards doesn't allow
unaligned access to MMIO </p><p>space, all pci memory mapped as Device-nGnRE in arm64
cannot support</p><p>unaligned access. and qxl is a device simulated by
qemu, it should be able to access </p><p>to MMIO space in a more flexible way(PROT_NORMAL)
than the real physical </p><p>graphics card.</p><p><br>
</p><p>----</p><p><br>
</p><p><br>
</p><p>Cong.<br>
</p><p><br>
</p><p><br>
<br>
<br>
</p><p><strong>主 题:</strong><span id="subject">Re: [PATCH v1
1/2] drm/qxl: replace ioremap by
ioremap_cache on arm64</span> <br>
<strong>日 期:</strong><span id="date">2022-03-23
15:15</span> <br>
<strong>发件人:</strong><span id="from">Christian
König</span> <br>
<strong>收件人:</strong><span id="to">Cong<a class="moz-txt-link-abbreviated
moz-txt-link-freetext" href="mailto:Liuairlied@redhat.comkraxel@redhat.comairlied@linux.iedaniel@ffwll.chray.huang@amd.comvirtualization@lists.linux-foundation.orgspice-devel@lists.freedesktop.orgdri-devel@lists.freedesktop.org" moz-do-not-send="true">Liuairlied@redhat.comkraxel@redhat.comairlied@linux.iedaniel@ffwll.chray.huang@amd.comvirtualization@lists.linux-foundation.orgspice-devel@lists.freedesktop.orgdri-devel@lists.freedesktop.org</a></span>
</p><p><br>
</p><p>Am 22.03.22 um 10:34 schrieb Cong Liu:<br>
> qxl use ioremap to map ram_header and rom,
in the arm64 implementation,<br>
> the device is mapped as DEVICE_nGnRE, it
can not support unaligned<br>
> access.<br>
<br>
Well that some ARM boards doesn't allow
unaligned access to MMIO space <br>
is a well known bug of those ARM boards.<br>
<br>
So as far as I know this is a hardware bug you
are trying to workaround <br>
here and I'm not 100% sure that this is
correct.<br>
<br>
Christian.<br>
<br>
><br>
> 6.620515] pc : setup_hw_slot+0x24/0x60
[qxl]<br>
> [ 6.620961] lr : setup_slot+0x34/0xf0
[qxl]<br>
> [ 6.621376] sp : ffff800012b73760<br>
> [ 6.621701] x29: ffff800012b73760 x28:
0000000000000001 x27: 0000000010000000<br>
> [ 6.622400] x26: 0000000000000001 x25:
0000000004000000 x24: ffffcf376848c000<br>
> [ 6.623099] x23: ffff0000c4087400 x22:
ffffcf3718e17140 x21: 0000000000000000<br>
> [ 6.623823] x20: ffff0000c4086000 x19:
ffff0000c40870b0 x18: 0000000000000014<br>
> [ 6.624519] x17: 000000004d3605ab x16:
00000000bb3b6129 x15: 000000006e771809<br>
> [ 6.625214] x14: 0000000000000001 x13:
007473696c5f7974 x12: 696e696666615f65<br>
> [ 6.625909] x11: 00000000d543656a x10:
0000000000000000 x9 : ffffcf3718e085a4<br>
> [ 6.626616] x8 : 00000000006c7871 x7 :
000000000000000a x6 : 0000000000000017<br>
> [ 6.627343] x5 : 0000000000001400 x4 :
ffff800011f63400 x3 : 0000000014000000<br>
> [ 6.628047] x2 : 0000000000000000 x1 :
ffff0000c40870b0 x0 : ffff0000c4086000<br>
> [ 6.628751] Call trace:<br>
> [ 6.628994] setup_hw_slot+0x24/0x60
[qxl]<br>
> [ 6.629404] setup_slot+0x34/0xf0 [qxl]<br>
> [ 6.629790]
qxl_device_init+0x6f0/0x7f0 [qxl]<br>
> [ 6.630235] qxl_pci_probe+0xdc/0x1d0
[qxl]<br>
> [ 6.630654] local_pci_probe+0x48/0xb8<br>
> [ 6.631027]
pci_device_probe+0x194/0x208<br>
> [ 6.631464] really_probe+0xd0/0x458<br>
> [ 6.631818]
__driver_probe_device+0x124/0x1c0<br>
> [ 6.632256]
driver_probe_device+0x48/0x130<br>
> [ 6.632669] __driver_attach+0xc4/0x1a8<br>
> [ 6.633049] bus_for_each_dev+0x78/0xd0<br>
> [ 6.633437] driver_attach+0x2c/0x38<br>
> [ 6.633789] bus_add_driver+0x154/0x248<br>
> [ 6.634168] driver_register+0x6c/0x128<br>
> [ 6.635205]
__pci_register_driver+0x4c/0x58<br>
> [ 6.635628] qxl_init+0x48/0x1000 [qxl]<br>
> [ 6.636013] do_one_initcall+0x50/0x240<br>
> [ 6.636390] do_init_module+0x60/0x238<br>
> [ 6.636768] load_module+0x2458/0x2900<br>
> [ 6.637136]
__do_sys_finit_module+0xbc/0x128<br>
> [ 6.637561]
__arm64_sys_finit_module+0x28/0x38<br>
> [ 6.638004] invoke_syscall+0x74/0xf0<br>
> [ 6.638366]
el0_svc_common.constprop.0+0x58/0x1a8<br>
> [ 6.638836] do_el0_svc+0x2c/0x90<br>
> [ 6.639216] el0_svc+0x40/0x190<br>
> [ 6.639526]
el0t_64_sync_handler+0xb0/0xb8<br>
> [ 6.639934] el0t_64_sync+0x1a4/0x1a8<br>
> [ 6.640294] Code: 910003fd f9484804
f9400c23 8b050084 (f809c083)<br>
> [ 6.640889] ---[ end trace
95615d89b7c87f95 ]---<br>
><br>
> Signed-off-by: Cong Liu<liucong2@kylinos.cn><br>
> ---<br>
> drivers/gpu/drm/qxl/qxl_kms.c | 10
++++++++++<br>
> 1 file changed, 10 insertions(+)<br>
><br>
> diff --git
a/drivers/gpu/drm/qxl/qxl_kms.c
b/drivers/gpu/drm/qxl/qxl_kms.c<br>
> index 4dc5ad13f12c..0e61ac04d8ad
100644<br>
> --- a/drivers/gpu/drm/qxl/qxl_kms.c<br>
> +++ b/drivers/gpu/drm/qxl/qxl_kms.c<br>
> @@ -165,7 +165,11 @@ int
qxl_device_init(struct qxl_device *qdev,<br>
> (int)qdev->surfaceram_size /
1024,<br>
> (sb == 4) ? "64bit" : "32bit");<br>
> <br>
> +#ifdef CONFIG_ARM64<br>
> + qdev->rom =
ioremap_cache(qdev->rom_base,
qdev->rom_size);<br>
> +#else<br>
> qdev->rom =
ioremap(qdev->rom_base,
qdev->rom_size);<br>
> +#endif<br>
> if (!qdev->rom) {<br>
> pr_err("Unable to ioremap ROM\n");<br>
> r = -ENOMEM;<br>
> @@ -183,9 +187,15 @@ int
qxl_device_init(struct qxl_device *qdev,<br>
> goto rom_unmap;<br>
> }<br>
> <br>
> +#ifdef CONFIG_ARM64<br>
> + qdev->ram_header =
ioremap_cache(qdev->vram_base +<br>
> +
qdev->rom->ram_header_offset,<br>
> + sizeof(*qdev->ram_header));<br>
> +#else<br>
> qdev->ram_header =
ioremap(qdev->vram_base +<br>
>
qdev->rom->ram_header_offset,<br>
> sizeof(*qdev->ram_header));<br>
> +#endif<br>
> if (!qdev->ram_header) {<br>
> DRM_ERROR("Unable to ioremap RAM
header\n");<br>
> r = -ENOMEM;<br>
<br>
</liucong2@kylinos.cn></p></blockquote><br>
</div></div></div></div></blockquote><br>
</div></div></div></div>