[Openpvrsgx-devgroup] [PATCH] Update pvrsgx 1.14.3759903 to latest kernel

H. Nikolaus Schaller hns at goldelico.com
Fri Nov 12 16:19:50 CET 2021


Hi Lucas,

> Am 12.11.2021 um 13:53 schrieb Lucas Fryzek <lucas.fryzek at hazeco.xyz>:
> 
> Incorporate fixes from the pvrsgx 1.17.4948957 driver to the
> 1.14.3759903 driver to allow it to build on the latest 5.15 kernel version
> ---
> .../services4/srvkm/env/linux/dmabuf.c        |   3 +-
> .../eurasia_km/services4/srvkm/env/linux/mm.c |  56 +++++++++
> .../services4/srvkm/env/linux/mmap.c          |  19 ++++
> .../services4/srvkm/env/linux/module.c        |   4 +
> .../services4/srvkm/env/linux/mutils.h        |   6 +
> .../services4/srvkm/env/linux/osfunc.c        | 106 +++++++++++++-----
> .../services4/srvkm/env/linux/private_data.h  |   3 +
> .../services4/srvkm/env/linux/proc.c          |  11 ++
> .../services4/srvkm/env/linux/pvr_bridge_k.c  |   4 +
> .../services4/srvkm/env/linux/pvr_drm.h       |   3 +
> .../services4/srvkm/env/linux/pvr_uaccess.h   |   4 +-
> .../services4/system/sgx_jz4780/sysconfig.h   |   3 +
> 12 files changed, 193 insertions(+), 29 deletions(-)

excellent!

I have added an #ifndef SYS_SGX_DEV_NAME to .../services4/system/sgx_jz4780/sysconfig.h
because I got a duplicate symbol warning.

Now I can compile it (with a very small number of other warnings about va_list).

Booting unfortunately fails with a segfault (see below).

OSInvalidateCPUCacheRangeKM/dma_sync_phys indicates that some fix does not handle
the processor cache properly. Maybe the changes for 1.17.4948957 were too OMAP specific
or we are missing some detail. Or it is even related to the va_list things.

Or some 1.17.4948957 fixes are not 100% compatible to the 1.14.3759903.
Maybe a comparison with the fixes for the 1.14.3699939 will show. That one
also works on omap3/am335x (e.g. Beaglebone).

Unfortunatley I have not the spare time to look deeper into it, although it is tempting :)

Anyways this is a really big step forwards. For the first time we can compile a
jz4780 kernel driver for a modern kernel with working HDMI *and* have a (potentially)
matching user-space available.

BR and thanks,
Nikolaus


[    9.870707] pvrsrvkm 13040000.gpu: Enabling quirks 00000000
[    9.879065] [drm] Initialized ingenic-drm 1.1.0 20200716 for 13050000.lcdc0 on minor 0
[    9.894156] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    9.927309] input: gpio_ir_recv as /devices/platform/ir/rc/rc0/input1
[    9.969773] dwc2 13500000.usb: Looking up vbus-supply from device tree
[   10.011616] CPU 0 Unable to handle kernel paging request at virtual address 402a1000, epc == 8011a838, ra == 8011ac58
[   10.022386] Oops[#1]:
[   10.024685] CPU: 0 PID: 494 Comm: systemd-udevd Not tainted 5.15.0-letux-ci20+ #7327
[   10.032480] $ 0   : 00000000 00000001 ffffffe0 00000002
[   10.037747] $ 4   : 402a1000 402a1fe0 84b05ea4 00000001
[   10.043014] $ 8   : 00000002 84153410 00001000 00000000
[   10.048280] $12   : 80c80000 17d78400 fffffffd ffffffff
[   10.053547] $16   : 402a1000 00001000 84b05ea4 00000002
[   10.058815] $20   : 402a1000 80c70000 80c80000 80c70000
[   10.064082] $24   : 00000000 8017d250                  
[   10.069347] $28   : 843fa000 843fb8f8 80c70000 8011ac58
[   10.074614] Hi    : 00180542
[   10.077514] Lo    : 000c02a1
[   10.080414] epc   : 8011a838 blast_inv_dcache_range+0x10/0x24
[   10.086202] ra    : 8011ac58 ingenic_xburst_dma_cache_inv+0x98/0xa0
[   10.092500] Status: 10000403 KERNEL EXL IE 
[   10.096718] Cause : 00800008 (ExcCode 02)
[   10.100748] BadVA : 402a1000
[   10.103647] PrId  : 3ee1024f (Ingenic XBurst)
[   10.108025] Modules linked in: pvrsrvkm_jz4780_sgx540_130(+) ci20_audio gpio_ir_recv(+) rc_core gpio_keys ohci_platform(+) ingenic_drm(+) display_connector dw_hdmi ohci_hcd ehci_platform(+) drm_kms_helper dwc2(+) cfbfillrect roles syscopyarea cfbimgblt ehci_hcd sysfillrect sysimgblt fb_sys_fops cfbcopyarea dm9000 rtc_pcf8563 mii drm nvmem_jz4780_efuse drm_panel_orientation_quirks snd_soc_jz4780_codec snd_soc_jz4740_i2s phy_ingenic_usb ipv6 autofs4
[   10.147952] Process systemd-udevd (pid: 494, threadinfo=(ptrval), task=(ptrval), tls=77ea0490)
[   10.156612] Stack : 85d5ba00 c0380000 843fb908 00001000 00001000 00001000 00001000 8011a57c
[   10.165051]         8585b100 00000001 00002cc2 ffffffff 80c70000 00000000 00001000 c02a1000
[   10.173487]         00001000 85de1348 c0390000 8585b280 00000000 85de1374 00000000 c03701bc
[   10.181924]         c036cad4 00000001 00000dc0 00000001 85de1348 0000c000 00001000 843fba4c
[   10.190359]         85de1348 00004000 00001000 843fba4c 843fbaf0 8585b280 85d5ba00 c0380000
[   10.198797]         ...
[   10.201269] Call Trace:
[   10.203734] [<8011a838>] blast_inv_dcache_range+0x10/0x24
[   10.209165] [<8011ac58>] ingenic_xburst_dma_cache_inv+0x98/0xa0
[   10.215117] [<8011a57c>] dma_sync_phys+0x10c/0x1e4
[   10.219942] [<c03701bc>] CheckExecuteCacheOp+0x178/0x264 [pvrsrvkm_jz4780_sgx540_130]
[   10.228482] [<c0371f7c>] OSInvalidateCPUCacheRangeKM+0x24/0x30 [pvrsrvkm_jz4780_sgx540_130]
[   10.237478] [<c036cb1c>] NewVMallocLinuxMemArea+0x94/0x100 [pvrsrvkm_jz4780_sgx540_130]
[   10.246128] [<c036f998>] OSAllocPages_Impl+0x60/0x12c [pvrsrvkm_jz4780_sgx540_130]
[   10.254342] [<c03644bc>] MMU_Initialise+0x138/0x358 [pvrsrvkm_jz4780_sgx540_130]
[   10.262385] [<c0352bec>] BM_CreateContext+0x1a0/0x2bc [pvrsrvkm_jz4780_sgx540_130]
[   10.270599] [<c0366bdc>] DevInitSGXPart1+0xf8/0x1d4 [pvrsrvkm_jz4780_sgx540_130]
[   10.278641] [<c035d5f8>] PVRSRVInitialiseDevice+0xfc/0x114 [pvrsrvkm_jz4780_sgx540_130]
[   10.287291] [<c0349958>] SysInitialise+0x538/0x57c [pvrsrvkm_jz4780_sgx540_130]
[   10.295243] [<c036f3a8>] PVRCore_Init+0x114/0x124 [pvrsrvkm_jz4780_sgx540_130]
[   10.303111] [<c034a1a4>] pvr_probe+0x18c/0x238 [pvrsrvkm_jz4780_sgx540_130]
[   10.310693] [<805e4740>] platform_probe+0x68/0xc0
[   10.315431] [<805e2488>] really_probe+0x18c/0x318
[   10.320167] [<805e2704>] __driver_probe_device+0xf0/0xf8
[   10.325510] [<805e274c>] driver_probe_device+0x40/0xd0
[   10.330679] [<805e2c40>] __driver_attach+0xe4/0xf8
[   10.335501] [<805e0390>] bus_for_each_dev+0x6c/0xb0
[   10.340408] [<805e16a4>] bus_add_driver+0x19c/0x1e4
[   10.345315] [<805e3664>] driver_register+0xd4/0x114
[   10.350220] [<80100eb4>] do_one_initcall+0xa0/0x1dc
[   10.355125] [<808b4c48>] do_init_module+0x74/0x214
[   10.359946] [<801a2724>] load_module+0x1130/0x194c
[   10.364769] [<801a3170>] sys_finit_module+0xb4/0xe4
[   10.369675] [<80110800>] syscall_common+0x34/0x58
[   10.374411] 


> 
> diff --git a/drivers/gpu/drm/pvrsgx/1.14.3759903/eurasia_km/services4/srvkm/env/linux/dmabuf.c b/drivers/gpu/drm/pvrsgx/1.14.3759903/eurasia_km/services4/srvkm/env/linux/dmabuf.c
> index 8e26d7c01027..14cb0e986ca6 100644
> --- a/drivers/gpu/drm/pvrsgx/1.14.3759903/eurasia_km/services4/srvkm/env/linux/dmabuf.c
> +++ b/drivers/gpu/drm/pvrsgx/1.14.3759903/eurasia_km/services4/srvkm/env/linux/dmabuf.c
> @@ -48,7 +48,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
> #include <linux/err.h>
> #include <linux/dma-buf.h>
> #include <linux/scatterlist.h>
> -#if defined(SUPPORT_DRI_DRM)
> +#include <linux/version.h>
> +#if defined(SUPPORT_DRI_DRM) && (LINUX_VERSION_CODE < KERNEL_VERSION(5,5,0))
> #include <drm/drmP.h>
> #endif
> 
> diff --git a/drivers/gpu/drm/pvrsgx/1.14.3759903/eurasia_km/services4/srvkm/env/linux/mm.c b/drivers/gpu/drm/pvrsgx/1.14.3759903/eurasia_km/services4/srvkm/env/linux/mm.c
> index c5a9b9b0bf63..80147aabd416 100644
> --- a/drivers/gpu/drm/pvrsgx/1.14.3759903/eurasia_km/services4/srvkm/env/linux/mm.c
> +++ b/drivers/gpu/drm/pvrsgx/1.14.3759903/eurasia_km/services4/srvkm/env/linux/mm.c
> @@ -485,6 +485,58 @@ AllocFlagsToPGProt(pgprot_t *pPGProtFlags, IMG_UINT32 ui32AllocFlags)
>     return IMG_TRUE;
> }
> 
> +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5,8,0))
> +#else
> +/* provide pre-5.8 __vmalloc() with 3 parameters */
> +
> +#include <linux/kallsyms.h>
> +
> +static void *__old_vmalloc_node(unsigned long size, unsigned long align,
> +			    gfp_t gfp_mask, pgprot_t prot,
> +			    int node, const void *caller)
> +{
> +#if 0
> +/* unfortunately this does no longer work
> + * because now kallsyms_lookup_name() itself is no longer
> + * exported
> + * See: https://lwn.net/Articles/813350/
> +*/
> +	/* look up a function that is not exported by EXPORT_SYMBOL
> +	 * so that we can link a kernel module
> +	 * see: https://www.programmersought.com/article/40296591069/
> +	 */
> +
> +	typedef void *ft(unsigned long size, unsigned long align,
> +			unsigned long start, unsigned long end, gfp_t gfp_mask,
> +			pgprot_t prot, unsigned long vm_flags, int node,
> +			const void *caller);
> +
> +	ft *fp = (ft *) kallsyms_lookup_name("__vmalloc_node_range");
> +
> +	if (!fp)
> +		return NULL;
> +
> +	return fp(size, align, VMALLOC_START, VMALLOC_END,
> +				gfp_mask, prot, 0, node, caller);
> +#else
> +/* this works
> + * if we add EXPORT_SYMBOL(__vmalloc_node_range);
> + * to vmalloc.c */
> +
> +	return __vmalloc_node_range(size, align, VMALLOC_START, VMALLOC_END,
> +				    gfp_mask, prot, 0, node, caller);
> +
> +
> +#endif
> +}
> +
> +static void *__old_vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot)
> +{
> +	return __old_vmalloc_node(size, 1, gfp_mask, prot, NUMA_NO_NODE,
> +				__builtin_return_address(0));
> +}
> +#endif
> +
> IMG_VOID *
> _VMallocWrapper(IMG_SIZE_T uiBytes,
>                 IMG_UINT32 ui32AllocFlags,
> @@ -509,7 +561,11 @@ _VMallocWrapper(IMG_SIZE_T uiBytes,
> #endif
> 
> 	/* Allocate virtually contiguous pages */
> +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5,8,0))
>     pvRet = __vmalloc(uiBytes, gfp_mask, PGProtFlags);
> +#else
> +    pvRet = __old_vmalloc(uiBytes, gfp_mask, PGProtFlags);
> +#endif
> 
> #if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS)
>     if (pvRet)
> diff --git a/drivers/gpu/drm/pvrsgx/1.14.3759903/eurasia_km/services4/srvkm/env/linux/mmap.c b/drivers/gpu/drm/pvrsgx/1.14.3759903/eurasia_km/services4/srvkm/env/linux/mmap.c
> index e7fb667ec398..5a6068e04452 100644
> --- a/drivers/gpu/drm/pvrsgx/1.14.3759903/eurasia_km/services4/srvkm/env/linux/mmap.c
> +++ b/drivers/gpu/drm/pvrsgx/1.14.3759903/eurasia_km/services4/srvkm/env/linux/mmap.c
> @@ -66,12 +66,18 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
> #include <asm/current.h>
> #endif
> #if defined(SUPPORT_DRI_DRM)
> +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5,5,0))
> #include <drm/drmP.h>
> +#else
> +#include <linux/platform_device.h>
> +#endif
> #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
> #include <drm/drm_legacy.h>
> #endif
> #endif
> 
> +
> +
> #ifdef CONFIG_ARCH_OMAP5
> #ifdef CONFIG_DSSCOMP
> #include <../drivers/staging/omapdrm/omap_dmm_tiler.h>
> @@ -787,7 +793,20 @@ DoMapToUser(LinuxMemArea *psLinuxMemArea,
> #if defined(PVR_MAKE_ALL_PFNS_SPECIAL)
> 		    if (bMixedMap)
> 		    {
> +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,20,0))
> +			pfn_t pfns = { pfn };
> +			vm_fault_t vmf;
> +
> +			vmf = vmf_insert_mixed(ps_vma, ulVMAPos, pfns);
> +			if (vmf & VM_FAULT_ERROR)
> +				result = vm_fault_to_errno(vmf, 0);
> +#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(4,5,0))
> +			pfn_t pfns = { pfn };
> +
> +			result = vm_insert_mixed(ps_vma, ulVMAPos, pfns);
> +#else
> 			result = vm_insert_mixed(ps_vma, ulVMAPos, pfn);
> +#endif
> 	                if(result != 0)
> 	                {
> 	                    PVR_DPF((PVR_DBG_ERROR,"%s: Error - vm_insert_mixed failed (%d)", __FUNCTION__, result));
> diff --git a/drivers/gpu/drm/pvrsgx/1.14.3759903/eurasia_km/services4/srvkm/env/linux/module.c b/drivers/gpu/drm/pvrsgx/1.14.3759903/eurasia_km/services4/srvkm/env/linux/module.c
> index 59e101149de6..c31f9ca8e719 100644
> --- a/drivers/gpu/drm/pvrsgx/1.14.3759903/eurasia_km/services4/srvkm/env/linux/module.c
> +++ b/drivers/gpu/drm/pvrsgx/1.14.3759903/eurasia_km/services4/srvkm/env/linux/module.c
> @@ -87,7 +87,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
> #include <linux/fs.h>
> 
> #if defined(SUPPORT_DRI_DRM)
> +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5,5,0))
> #include <drm/drmP.h>
> +#else
> +#include <drm/drm_file.h>
> +#endif
> #if defined(PVR_SECURE_DRM_AUTH_EXPORT)
> #include "env_perproc.h"
> #endif
> diff --git a/drivers/gpu/drm/pvrsgx/1.14.3759903/eurasia_km/services4/srvkm/env/linux/mutils.h b/drivers/gpu/drm/pvrsgx/1.14.3759903/eurasia_km/services4/srvkm/env/linux/mutils.h
> index 61edf9523555..9d3ff0f2c575 100644
> --- a/drivers/gpu/drm/pvrsgx/1.14.3759903/eurasia_km/services4/srvkm/env/linux/mutils.h
> +++ b/drivers/gpu/drm/pvrsgx/1.14.3759903/eurasia_km/services4/srvkm/env/linux/mutils.h
> @@ -57,6 +57,12 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
> #endif
> #endif
> 
> +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,6,0))
> +#define ioremap_nocache ioremap
> +// #define ioremap_cache(physaddr, size) memremap((physaddr), (size), MEMREMAP_WB)
> +// #define ioremap_wt(physaddr, size) memremap((physaddr), (size), MEMREMAP_WT)
> +#endif
> +
> #if defined(SUPPORT_LINUX_X86_PAT)
> 	pgprot_t pvr_pgprot_writecombine(pgprot_t prot);
> 	#define	PGPROT_WC(pv)	pvr_pgprot_writecombine(pv)
> diff --git a/drivers/gpu/drm/pvrsgx/1.14.3759903/eurasia_km/services4/srvkm/env/linux/osfunc.c b/drivers/gpu/drm/pvrsgx/1.14.3759903/eurasia_km/services4/srvkm/env/linux/osfunc.c
> index c56ff2537f4b..7925a7103d31 100644
> --- a/drivers/gpu/drm/pvrsgx/1.14.3759903/eurasia_km/services4/srvkm/env/linux/osfunc.c
> +++ b/drivers/gpu/drm/pvrsgx/1.14.3759903/eurasia_km/services4/srvkm/env/linux/osfunc.c
> @@ -52,14 +52,26 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
> #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)) && (LINUX_VERSION_CODE < KERNEL_VERSION(3,2,0))
> #include <asm/system.h>
> #endif
> +#if (LINUX_VERSION_CODE < KERNEL_VERSION(4,19,0))
> #include <asm/cacheflush.h>
> +#endif
> #include <linux/mm.h>
> +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5,8,0))
> +#else
> +#define mmap_sem mmap_lock	// has been renamed by v5.8-rc1
> +#endif
> +
> #include <linux/pagemap.h>
> #include <linux/hugetlb.h> 
> #include <linux/slab.h>
> #include <linux/vmalloc.h>
> #include <linux/delay.h>
> #include <linux/pci.h>
> +#include <linux/platform_device.h>
> +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5,10,0))
> +#else
> +#include <linux/dma-map-ops.h>
> +#endif
> 
> #include <linux/string.h>
> #include <linux/sched.h>
> @@ -2793,15 +2805,27 @@ static void OSTimerCallbackBody(TIMER_CALLBACK_DATA *psTimerCBData)
>     mod_timer(&psTimerCBData->sTimer, psTimerCBData->ui32Delay + jiffies);
> }
> 
> +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0))
> + /*!
> + ******************************************************************************
> +
> + @Function      OSTimerCallbackWrapper
> +
> + @Description   OS specific timer callback wrapper function
> 
> + @Input         psTimer    Timer list structure
> +
> +*/ /**************************************************************************/
> +static void OSTimerCallbackWrapper(struct timer_list *psTimer)
> +{
> +	TIMER_CALLBACK_DATA *psTimerCBData = from_timer(psTimerCBData, psTimer, sTimer);
> +#else
> /*!
> ******************************************************************************
> 
>  @Function	OSTimerCallbackWrapper
> 
> - @Description 
> - 
> - OS specific timer callback wrapper function
> + @Description 	OS specific timer callback wrapper function
> 
>  @Input    ui32Data : timer callback data
> 
> @@ -2811,7 +2835,9 @@ static void OSTimerCallbackBody(TIMER_CALLBACK_DATA *psTimerCBData)
> static IMG_VOID OSTimerCallbackWrapper(IMG_UINTPTR_T uiData)
> {
>     TIMER_CALLBACK_DATA	*psTimerCBData = (TIMER_CALLBACK_DATA*)uiData;
> -    
> +
> +#endif
> +
> #if defined(PVR_LINUX_TIMERS_USING_WORKQUEUES) || defined(PVR_LINUX_TIMERS_USING_SHARED_WORKQUEUE)
>     int res;
> 
> @@ -2910,6 +2936,9 @@ IMG_HANDLE OSAddTimer(PFN_TIMER_FUNC pfnTimerFunc, IMG_VOID *pvData, IMG_UINT32
>     psTimerCBData->ui32Delay = ((HZ * ui32MsTimeout) < 1000)
>                                 ?	1
>                                 :	((HZ * ui32MsTimeout) / 1000);
> +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0))
> +    timer_setup(&psTimerCBData->sTimer, OSTimerCallbackWrapper, 0);
> +#else
>     /* initialise object */
>     init_timer(&psTimerCBData->sTimer);
> 
> @@ -2917,7 +2946,7 @@ IMG_HANDLE OSAddTimer(PFN_TIMER_FUNC pfnTimerFunc, IMG_VOID *pvData, IMG_UINT32
>     /* PRQA S 0307,0563 1 */ /* ignore warning about inconpartible ptr casting */
>     psTimerCBData->sTimer.function = (IMG_VOID *)OSTimerCallbackWrapper;
>     psTimerCBData->sTimer.data = (IMG_UINTPTR_T)psTimerCBData;
> -    
> +#endif
>     return (IMG_HANDLE)(ui + 1);
> }
> 
> @@ -3378,19 +3407,8 @@ PVRSRV_ERROR OSCopyFromUser( IMG_PVOID pvProcess,
> ******************************************************************************/
> IMG_BOOL OSAccessOK(IMG_VERIFY_TEST eVerification, IMG_VOID *pvUserPtr, IMG_SIZE_T uiBytes)
> {
> -    IMG_INT linuxType;
> -
> -    if (eVerification == PVR_VERIFY_READ)
> -    {
> -        linuxType = VERIFY_READ;
> -    }
> -    else
> -    {
> -        PVR_ASSERT(eVerification == PVR_VERIFY_WRITE);
> -        linuxType = VERIFY_WRITE;
> -    }
> -
> -    return access_ok(linuxType, pvUserPtr, uiBytes);
> +    (void)eVerification; /* unused */
> +    return access_ok(pvUserPtr, uiBytes);
> }
> 
> typedef enum _eWrapMemType_
> @@ -3445,6 +3463,9 @@ static IMG_BOOL CPUVAddrToPFN(struct vm_area_struct *psVMArea, IMG_UINTPTR_T uCP
>     pud_t *psPUD;
>     pmd_t *psPMD;
>     pte_t *psPTE;
> +#if (LINUX_VERSION_CODE > KERNEL_VERSION(4,12,0))
> +    p4d_t *psP4D;
> +#endif
>     struct mm_struct *psMM = psVMArea->vm_mm;
>     spinlock_t *psPTLock;
>     IMG_BOOL bRet = IMG_FALSE;
> @@ -3456,7 +3477,15 @@ 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) || unlikely(p4d_bad(*psP4D)))
> +        return bRet;
> +
> +    psPUD = pud_offset(psP4D, uCPUVAddr);
> +#else
>     psPUD = pud_offset(psPGD, uCPUVAddr);
> +#endif
>     if (pud_none(*psPUD) || pud_bad(*psPUD))
>         return bRet;
> 
> @@ -3542,7 +3571,11 @@ PVRSRV_ERROR OSReleasePhysPageAddr(IMG_HANDLE hOSWrapMem)
>                         SetPageDirty(psPage);
>                     }
> 	        }
> +#if (LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0))
>                 page_cache_release(psPage);
> +#else
> +                put_page(psPage);
> +#endif
> 	    }
>             break;
>         }
> @@ -3724,8 +3757,17 @@ PVRSRV_ERROR OSAcquirePhysPageAddr(IMG_VOID *pvCPUVAddr,
>     bMMapSemHeld = IMG_TRUE;
> 
>     /* Get page list */
> -    psInfo->iNumPagesMapped = get_user_pages(current, current->mm, uStartAddr, psInfo->iNumPages, 1, 0, psInfo->ppsPages, NULL);
> -
> +#if (LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0))
> +    psInfo->iNumPagesMapped = get_user_pages(
> +		current, current->mm,
> +		uStartAddr, psInfo->iNumPages, 1, 0, psInfo->ppsPages, NULL);
> +#elif (LINUX_VERSION_CODE < KERNEL_VERSION(4,9,0))
> +    psInfo->iNumPagesMapped = get_user_pages(
> +		uStartAddr, psInfo->iNumPages, 1, 0, psInfo->ppsPages, NULL);
> +#else
> +    psInfo->iNumPagesMapped = get_user_pages(
> +		uStartAddr, psInfo->iNumPages, 1, psInfo->ppsPages, NULL);
> +#endif
>     if (psInfo->iNumPagesMapped >= 0)
>     {
>         /* See if we got all the pages we wanted */
> @@ -4540,8 +4582,12 @@ static inline size_t pvr_dma_range_len(const void *pvStart, const void *pvEnd)
> static void pvr_dma_cache_wback_inv(const void *pvStart, const void *pvEnd)
> {
> 	size_t uLength = pvr_dma_range_len(pvStart, pvEnd);
> -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)
> -	dma_cache_sync(NULL, (void *)pvStart, uLength, DMA_BIDIRECTIONAL);
> +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,5,0)
> +	struct device *dev = PVRLDMGetDevice();
> +	dma_sync_single_for_device(dev, (dma_addr_t)pvStart, uLength, DMA_BIDIRECTIONAL);
> +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)
> +	struct device *dev = PVRLDMGetDevice();
> +	dma_cache_sync(dev, (void *)pvStart, uLength, DMA_BIDIRECTIONAL);
> #else
> 	dma_cache_wback_inv((unsigned long)pvStart, uLength);
> #endif
> @@ -4550,8 +4596,12 @@ static void pvr_dma_cache_wback_inv(const void *pvStart, const void *pvEnd)
> static void pvr_dma_cache_wback(const void *pvStart, const void *pvEnd)
> {
> 	size_t uLength = pvr_dma_range_len(pvStart, pvEnd);
> -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)
> -	dma_cache_sync(NULL, (void *)pvStart, uLength, DMA_TO_DEVICE);
> +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,5,0)
> +	struct device *dev = PVRLDMGetDevice();
> +	dma_sync_single_for_device(dev, (dma_addr_t)pvStart, uLength, DMA_TO_DEVICE);
> +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)
> +	struct device *dev = PVRLDMGetDevice();
> +	dma_cache_sync(dev, (void *)pvStart, uLength, DMA_TO_DEVICE);
> #else
> 	dma_cache_wback((unsigned long)pvStart, uLength);
> #endif
> @@ -4560,8 +4610,12 @@ static void pvr_dma_cache_wback(const void *pvStart, const void *pvEnd)
> static void pvr_dma_cache_inv(const void *pvStart, const void *pvEnd)
> {
> 	size_t uLength = pvr_dma_range_len(pvStart, pvEnd);
> -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)
> -	dma_cache_sync(NULL, (void *)pvStart, uLength, DMA_FROM_DEVICE);
> +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,5,0)
> +	struct device *dev = PVRLDMGetDevice();
> +	dma_sync_single_for_device(dev, (dma_addr_t)pvStart, uLength, DMA_FROM_DEVICE);
> +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)
> +	struct device *dev = PVRLDMGetDevice();
> +	dma_cache_sync(dev, (void *)pvStart, uLength, DMA_FROM_DEVICE);
> #else
> 	dma_cache_inv((unsigned long)pvStart, uLength);
> #endif
> diff --git a/drivers/gpu/drm/pvrsgx/1.14.3759903/eurasia_km/services4/srvkm/env/linux/private_data.h b/drivers/gpu/drm/pvrsgx/1.14.3759903/eurasia_km/services4/srvkm/env/linux/private_data.h
> index e2a6c74d35d4..3e75b7e6da14 100644
> --- a/drivers/gpu/drm/pvrsgx/1.14.3759903/eurasia_km/services4/srvkm/env/linux/private_data.h
> +++ b/drivers/gpu/drm/pvrsgx/1.14.3759903/eurasia_km/services4/srvkm/env/linux/private_data.h
> @@ -42,10 +42,13 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
> #ifndef __INCLUDED_PRIVATE_DATA_H_
> #define __INCLUDED_PRIVATE_DATA_H_
> 
> +#include <linux/version.h>
> #if defined(SUPPORT_DRI_DRM) && defined(PVR_SECURE_DRM_AUTH_EXPORT)
> #include <linux/list.h>
> +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5,5,0))
> #include <drm/drmP.h>
> #endif
> +#endif
> 
> /* This structure is required in the rare case that a process creates
>  * a connection to services, but before closing the file descriptor,
> diff --git a/drivers/gpu/drm/pvrsgx/1.14.3759903/eurasia_km/services4/srvkm/env/linux/proc.c b/drivers/gpu/drm/pvrsgx/1.14.3759903/eurasia_km/services4/srvkm/env/linux/proc.c
> index 788757ba2a48..9f8e293686b7 100644
> --- a/drivers/gpu/drm/pvrsgx/1.14.3759903/eurasia_km/services4/srvkm/env/linux/proc.c
> +++ b/drivers/gpu/drm/pvrsgx/1.14.3759903/eurasia_km/services4/srvkm/env/linux/proc.c
> @@ -91,6 +91,7 @@ static const IMG_CHAR PVRProcDirRoot[] = "pvr";
> static IMG_INT pvr_proc_open(struct inode *inode,struct file *file);
> static ssize_t pvr_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos);
> 
> +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0))
> static struct file_operations pvr_proc_operations =
> {
> 	.open		= pvr_proc_open,
> @@ -99,6 +100,16 @@ static struct file_operations pvr_proc_operations =
> 	.llseek		= seq_lseek,
> 	.release	= seq_release,
> };
> +#else
> +static struct proc_ops pvr_proc_operations =
> +{
> +	.proc_open	= pvr_proc_open,
> +	.proc_read	= seq_read,
> +	.proc_write	= pvr_proc_write,
> +	.proc_lseek	= seq_lseek,
> +	.proc_release	= seq_release,
> +};
> +#endif
> 
> static void *pvr_proc_seq_start (struct seq_file *m, loff_t *pos);
> static void *pvr_proc_seq_next (struct seq_file *m, void *v, loff_t *pos);
> diff --git a/drivers/gpu/drm/pvrsgx/1.14.3759903/eurasia_km/services4/srvkm/env/linux/pvr_bridge_k.c b/drivers/gpu/drm/pvrsgx/1.14.3759903/eurasia_km/services4/srvkm/env/linux/pvr_bridge_k.c
> index 2a61e545015f..8840ba49f1fa 100644
> --- a/drivers/gpu/drm/pvrsgx/1.14.3759903/eurasia_km/services4/srvkm/env/linux/pvr_bridge_k.c
> +++ b/drivers/gpu/drm/pvrsgx/1.14.3759903/eurasia_km/services4/srvkm/env/linux/pvr_bridge_k.c
> @@ -59,7 +59,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
> #include "buffer_manager.h"
> 
> #if defined(SUPPORT_DRI_DRM)
> +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5,5,0))
> #include <drm/drmP.h>
> +#else
> +#include <drm/drm_file.h>
> +#endif
> #include "pvr_drm.h"
> #if defined(PVR_SECURE_DRM_AUTH_EXPORT)
> #include "env_perproc.h"
> diff --git a/drivers/gpu/drm/pvrsgx/1.14.3759903/eurasia_km/services4/srvkm/env/linux/pvr_drm.h b/drivers/gpu/drm/pvrsgx/1.14.3759903/eurasia_km/services4/srvkm/env/linux/pvr_drm.h
> index 1c537559e3b1..409a6490918d 100644
> --- a/drivers/gpu/drm/pvrsgx/1.14.3759903/eurasia_km/services4/srvkm/env/linux/pvr_drm.h
> +++ b/drivers/gpu/drm/pvrsgx/1.14.3759903/eurasia_km/services4/srvkm/env/linux/pvr_drm.h
> @@ -42,6 +42,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
> #if !defined(__PVR_DRM_H__)
> #define __PVR_DRM_H__
> 
> +#include <drm/drm_device.h>
> +#include <linux/platform_device.h>
> +
> #if defined (PDUMP)
> #include "linuxsrv.h"
> #endif
> diff --git a/drivers/gpu/drm/pvrsgx/1.14.3759903/eurasia_km/services4/srvkm/env/linux/pvr_uaccess.h b/drivers/gpu/drm/pvrsgx/1.14.3759903/eurasia_km/services4/srvkm/env/linux/pvr_uaccess.h
> index 7583d7eb25bc..736eab953aba 100644
> --- a/drivers/gpu/drm/pvrsgx/1.14.3759903/eurasia_km/services4/srvkm/env/linux/pvr_uaccess.h
> +++ b/drivers/gpu/drm/pvrsgx/1.14.3759903/eurasia_km/services4/srvkm/env/linux/pvr_uaccess.h
> @@ -54,7 +54,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
> static inline unsigned long pvr_copy_to_user(void __user *pvTo, const void *pvFrom, unsigned long ulBytes)
> {
> #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33))
> -    if (access_ok(VERIFY_WRITE, pvTo, ulBytes))
> +    if (access_ok(pvTo, ulBytes))
>     {
> 	return __copy_to_user(pvTo, pvFrom, ulBytes);
>     }
> @@ -71,7 +71,7 @@ static inline unsigned long pvr_copy_from_user(void *pvTo, const void __user *pv
>      * The compile time correctness checking introduced for copy_from_user in
>      * Linux 2.6.33 isn't fully comaptible with our usage of the function.
>      */
> -    if (access_ok(VERIFY_READ, pvFrom, ulBytes))
> +    if (access_ok(pvFrom, ulBytes))
>     {
> 	return __copy_from_user(pvTo, pvFrom, ulBytes);
>     }
> diff --git a/drivers/gpu/drm/pvrsgx/1.14.3759903/eurasia_km/services4/system/sgx_jz4780/sysconfig.h b/drivers/gpu/drm/pvrsgx/1.14.3759903/eurasia_km/services4/system/sgx_jz4780/sysconfig.h
> index 4bbcb75e874e..77607a04c8b7 100644
> --- a/drivers/gpu/drm/pvrsgx/1.14.3759903/eurasia_km/services4/system/sgx_jz4780/sysconfig.h
> +++ b/drivers/gpu/drm/pvrsgx/1.14.3759903/eurasia_km/services4/system/sgx_jz4780/sysconfig.h
> @@ -49,6 +49,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
> 
> #define VS_PRODUCT_NAME	"JZ4780 SGX"
> 
> +#define SYS_SGX_HWRECOVERY_TIMEOUT_FREQ		(100)	// 10ms (100hz)
> +#define SYS_SGX_PDS_TIMER_FREQ				(1000)	// 1ms (1000hz)
> +
> #define SYS_SGX_USSE_COUNT					(1)
> 
> #if defined(NO_HARDWARE)
> -- 
> 2.33.1
> 
> _______________________________________________
> https://github.com/openpvrsgx-devgroup/linux_openpvrsgx
> openpvrsgx-devgroup mailing list
> openpvrsgx-devgroup at letux.org
> https://lists.goldelico.com/mailman/listinfo.cgi/openpvrsgx-devgroup



More information about the openpvrsgx-devgroup mailing list