[Openpvrsgx-devgroup] [PATCH] staging: pvr: Add a simplified pvr-drv.c as replacement for messy pvr_drm.c
H. Nikolaus Schaller
hns at goldelico.com
Mon Nov 11 22:05:00 CET 2019
Hi Tony,
> Am 09.11.2019 um 17:25 schrieb Tony Lindgren <tony at atomide.com>:
>
>
> Now I get this trying to run the gles1test1 on am437x-sk-evm
> after patching it to probe:
>
> PVR_K: UM DDK-(3699939) and KM DDK-(3699939) match. [ OK ]
> ...
> PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xf: Tc [0, ]
> PVR:(Error): LoadOGLES2AndGetFunctions: Wrong version. Got: 2, Expected 3 [0, ]
> 'eglCreateContext' returned egl error 'EGL_NOT_INITIALIZED' (0x3001)
>
> And I guess these related to this in dmesg:
>
> PVR_K:(Error): DoMapToUser: Error - vmf_insert_mixed failed (100)
I did remember that I also had the SGX driver compiled and tested
on BeagleBoard Black with a 4.19 kernel tree.
So I did rebuild a kernel from source code after configuring for
SGX from this branch:
https://github.com/goldelico/letux-kernel/tree/letux-4.19.83
And the interesting news is that there is no PVRPMapKMem: mmap(2) failed.
So we have some regression between 4.19 and 5.4.
The good thing we now know is
* it is a problem of pvrsrvkm on newer kernel
* and not user-space setup
To be sure, I reinstalled letux-5.4-rc7.
It should not be too difficult to git diff the changed components.
iMac:master hns$ git diff --stat letux-4.19-next drivers/staging/pvr/1.14.3699939/
drivers/staging/pvr/1.14.3699939/eurasia_km/Makefile | 23 ++++--
drivers/staging/pvr/1.14.3699939/eurasia_km/services4/srvkm/common/devicemem.c | 1 +
drivers/staging/pvr/1.14.3699939/eurasia_km/services4/srvkm/env/linux/mmap.c | 2 +
drivers/staging/pvr/1.14.3699939/eurasia_km/services4/srvkm/env/linux/osfunc.c | 10 +++
drivers/staging/pvr/1.14.3699939/eurasia_km/services4/srvkm/env/linux/pvr_drm.c | 848 -------- ... -----
drivers/staging/pvr/1.14.3699939/eurasia_km/services4/system/omap/sysconfig.c | 6 ++
6 files changed, 35 insertions(+), 855 deletions(-)
iMac:master hns$
The only significant and memory related diff (the others are printk or comments) I did find in the driver is:
diff --git a/drivers/staging/pvr/1.14.3699939/eurasia_km/services4/srvkm/env/linux/osfunc.c b/drivers/staging/pvr/1.14.3699939/eurasia_km/services4/srvkm/env/linux/osfunc.c
index dd5e659a410d..03e05627afbe 100644
--- a/drivers/staging/pvr/1.14.3699939/eurasia_km/services4/srvkm/env/linux/osfunc.c
+++ b/drivers/staging/pvr/1.14.3699939/eurasia_km/services4/srvkm/env/linux/osfunc.c
@@ -3427,6 +3427,9 @@ static IMG_BOOL CPUVAddrToPFN(struct vm_area_struct *psVMArea, IMG_UINTPTR_T uCP
{
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,10))
pgd_t *psPGD;
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(4,12,0))
+ p4d_t *psP4D;
+#endif
pud_t *psPUD;
pmd_t *psPMD;
pte_t *psPTE;
@@ -3441,7 +3444,14 @@ static IMG_BOOL CPUVAddrToPFN(struct vm_area_struct *psVMArea, IMG_UINTPTR_T uCP
if (pgd_none(*psPGD) || pgd_bad(*psPGD))
return bRet;
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(4,12,0))
+ psP4D = p4d_offset(psPGD, uCPUVAddr);
+ if (p4d_none(*psP4D))
+ return bRet;
+ psPUD = pud_offset(psP4D, uCPUVAddr);
+#else
psPUD = pud_offset(psPGD, uCPUVAddr);
+#endif
if (pud_none(*psPUD) || pud_bad(*psPUD))
return bRet;
I have done a revert and the error is still there. So it is not the reason for the problem.
And it was there before I have added your pvr-drv cleanup.
In any case it means some API or function return value has changed since 4.19 and we may need another
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,?,0))
But which one?
The symptom I see with another printk for the DoMapToUser in
drivers/staging/pvr/1.14.3699939/eurasia_km/services4/srvkm/env/linux/mmap.c:
result = vmf_insert_mixed(ps_vma, ulVMAPos, pfn_to_pfn_t(pfn));
if(result != 0) {
// return value is a bit pattern: https://elixir.bootlin.com/linux/v5.4-rc2/source/include/linux/mm_types.h#L640
printk("%s: pfn=%px vmf_insert_mixed(vma=%px, addr=%px, pfn_t=%llx) ret=%08x\n", __func__, (void *) pfn, ps_vma, (void *) ulVMAPos, pfn_to_pfn_t(pfn).val, result);
PVR_DPF((PVR_DBG_ERROR,"%s: Error - vmf_insert_mixed failed (%x)", __FUNCTION__, result)); return IMG_FALSE;
}
is:
root at letux:~# pvrsrvctl --start --no-module
[ 37.359790] PVR_K: UM DDK-(3699939) and KM DDK-(3699939) match. [ OK ]
root at letux:~# gles1test1
[ 39.301073] DoMapToUser: pfn=0004804a vmf_insert_mixed(vma=dad81f00, addr=b6fa5000, pfn_t=4804a) ret=00000100
[ 39.312014] PVR_K:(Error): DoMapToUser: Error - vmf_insert_mixed failed (100)
PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xf: TLƶlp浳 [0, ]
root at letux:~# gles1test1
[ 41.708922] DoMapToUser: pfn=0004804a vmf_insert_mixed(vma=dad81a80, addr=b6f1a000, pfn_t=4804a) ret=00000100
[ 41.719902] PVR_K:(Error): DoMapToUser: Error - vmf_insert_mixed failed (100)
PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xf: Tp慌 [0, ]
root at letux:~# gles1test1
[ 43.869296] DoMapToUser: pfn=0004804a vmf_insert_mixed(vma=dd6991e0, addr=b6fd9000, pfn_t=4804a) ret=00000100
[ 43.880230] PVR_K:(Error): DoMapToUser: Error - vmf_insert_mixed failed (100)
PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xf: T後ɶp5恾 [0, ]
root at letux:~# gles1test1
[ 44.841519] DoMapToUser: pfn=0004804a vmf_insert_mixed(vma=dd6970c0, addr=b6f24000, pfn_t=4804a) ret=00000100
[ 44.852977] PVR_K:(Error): DoMapToUser: Error - vmf_insert_mixed failed (100)
PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xf: T<\p妾 [0, ]
root at letux:~# gles1test1
[ 45.712815] DoMapToUser: pfn=0004804a vmf_insert_mixed(vma=dd699180, addr=b6ff9000, pfn_t=4804a) ret=00000100
[ 45.723622] PVR_K:(Error): DoMapToUser: Error - vmf_insert_mixed failed (100)
PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xf: T˶p [0, ]
root at letux:~# gles1test1
[ 46.684186] DoMapToUser: pfn=0004804a vmf_insert_mixed(vma=dd5e50c0, addr=b6f8d000, pfn_t=4804a) ret=00000100
[ 46.695007] PVR_K:(Error): DoMapToUser: Error - vmf_insert_mixed failed (100)
PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xf: TĶ'p楺 [0, ]
root at letux:~# gles1test1
[ 47.454286] DoMapToUser: pfn=0004804a vmf_insert_mixed(vma=dd697ea0, addr=b6f99000, pfn_t=4804a) ret=00000100
[ 47.465138] PVR_K:(Error): DoMapToUser: Error - vmf_insert_mixed failed (100)
PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xf: TŶp楖 [0, ]
root at letux:~# gles1test1
[ 48.669989] DoMapToUser: pfn=0004804a vmf_insert_mixed(vma=dd699ba0, addr=b6f11000, pfn_t=4804a) ret=00000100
[ 48.680869] PVR_K:(Error): DoMapToUser: Error - vmf_insert_mixed failed (100)
PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xf: Tg,pE梾 [0, ]
root at letux:~#
The vmf_insert_mixed() error 0x0100 means according to include/linux/mm_types.h:
VM_FAULT_NOPAGE = (__force vm_fault_t)0x000100,
* @VM_FAULT_NOPAGE: ->fault installed the pte, not return page
So what could make the return value differ between v4.19.83 and v5.4-rc7?
BR,
Nikolaus
More information about the openpvrsgx-devgroup
mailing list