View | Details | Raw Unified | Return to bug 441070
Collapse All | Expand All

(-)src.orig/mga.h (+7 lines)
Lines 333-338 Link Here
333
    int			mastervideoRam;
333
    int			mastervideoRam;
334
    int			slavevideoRam;
334
    int			slavevideoRam;
335
    Bool		directRenderingEnabled;
335
    Bool		directRenderingEnabled;
336
337
    void  *		mappedIOBase;
338
    int			mappedIOUsage;
339
340
    void  *		mappedILOADBase;
341
    int			mappedILOADUsage;
342
336
    ScrnInfoPtr 	pScrn_1;
343
    ScrnInfoPtr 	pScrn_1;
337
    ScrnInfoPtr 	pScrn_2;
344
    ScrnInfoPtr 	pScrn_2;
338
} MGAEntRec, *MGAEntPtr;
345
} MGAEntRec, *MGAEntPtr;
(-)src.orig/mga_driver.c (-25 / +81 lines)
Lines 2809-2838 Link Here
2809
#ifdef XSERVER_LIBPCIACCESS
2809
#ifdef XSERVER_LIBPCIACCESS
2810
    struct pci_device *const dev = pMga->PciInfo;
2810
    struct pci_device *const dev = pMga->PciInfo;
2811
    struct pci_mem_region *region;
2811
    struct pci_mem_region *region;
2812
    void **memory[2];
2813
    int i, err;
2812
    int i, err;
2814
#endif
2813
#endif
2815
2814
2816
2815
2817
    if (!pMga->FBDev) {
2816
    if (!pMga->FBDev) {
2818
#ifdef XSERVER_LIBPCIACCESS
2817
#ifdef XSERVER_LIBPCIACCESS
2819
        memory[pMga->io_bar] = &pMga->IOBase;
2820
        memory[pMga->framebuffer_bar] = &pMga->FbBase;
2821
2818
2822
        for (i = 0; i < 2; i++) {
2819
	    pciaddr_t fbaddr = pMga->FbAddress;
2823
            region = &dev->regions[i];
2820
	    pciaddr_t fbsize = pMga->FbMapSize;
2824
            err = pci_device_map_range(dev,
2821
            err = pci_device_map_range(dev,
2825
                                       region->base_addr, region->size,
2822
				   fbaddr, fbsize,
2826
                                       PCI_DEV_MAP_FLAG_WRITABLE,
2823
				   PCI_DEV_MAP_FLAG_WRITABLE,
2827
                                       memory[i]);
2824
				   (void **)&pMga->FbBase);
2828
2829
            if (err) {
2825
            if (err) {
2830
                xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
2826
                xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
2831
                           "Unable to map BAR %i.  %s (%d)\n",
2827
                           "Unable to map Framebuffer %08llX %llx.  %s (%d)\n", (long long)fbaddr, (long long)fbsize, strerror(err), err);
2832
                           i, strerror(err), err);
2833
                return FALSE;
2828
                return FALSE;
2834
            }
2829
	    }
2835
        }
2830
		
2831
	if(pMga->entityPrivate == NULL || pMga->entityPrivate->mappedIOUsage == 0)
2832
	{
2833
		region = &dev->regions[pMga->io_bar];
2834
		err = pci_device_map_range(dev,
2835
				   region->base_addr, region->size,
2836
				   PCI_DEV_MAP_FLAG_WRITABLE,
2837
				   &pMga->IOBase);
2838
2839
		if (err) {
2840
			xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
2841
				   "Unable to map IO Region %i.  %s (%d)\n",
2842
				   pMga->io_bar, strerror(err), err);
2843
			return FALSE;
2844
		}
2845
		if(pMga->entityPrivate != NULL)
2846
		{
2847
			pMga->entityPrivate->mappedIOBase = pMga->IOBase;
2848
		}
2849
	}
2850
	else
2851
		pMga->IOBase = pMga->entityPrivate->mappedIOBase;
2852
2853
	if(pMga->entityPrivate != NULL)		
2854
		pMga->entityPrivate->mappedIOUsage ++;
2836
#else
2855
#else
2837
	/*
2856
	/*
2838
	 * For Alpha, we need to map SPARSE memory, since we need
2857
	 * For Alpha, we need to map SPARSE memory, since we need
Lines 2874-2889 Link Here
2874
    if (pMga->iload_bar != -1) {
2893
    if (pMga->iload_bar != -1) {
2875
#ifdef XSERVER_LIBPCIACCESS
2894
#ifdef XSERVER_LIBPCIACCESS
2876
        region = &dev->regions[pMga->iload_bar];
2895
        region = &dev->regions[pMga->iload_bar];
2877
        err = pci_device_map_range(dev,
2896
2897
	if(pMga->entityPrivate == NULL || pMga->entityPrivate->mappedILOADUsage == 0)
2898
	{
2899
		err = pci_device_map_range(dev,
2878
                                   region->base_addr, region->size,
2900
                                   region->base_addr, region->size,
2879
                                   PCI_DEV_MAP_FLAG_WRITABLE,
2901
                                   PCI_DEV_MAP_FLAG_WRITABLE,
2880
                                   (void *) &pMga->ILOADBase);
2902
                                   (void *) &pMga->ILOADBase);
2881
	if (err) {
2903
		if (err) {
2882
	    xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
2904
			xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
2883
		       "Unable to map BAR 2 (ILOAD region).  %s (%d)\n",
2905
				   "Unable to map BAR 2 (ILOAD region).  %s (%d)\n",
2884
		       strerror(err), err);
2906
				   strerror(err), err);
2885
	    return FALSE;
2907
			return FALSE;
2908
		}
2909
		if(pMga->entityPrivate != NULL)
2910
			pMga->entityPrivate->mappedILOADBase = pMga->ILOADBase;
2886
	}
2911
	}
2912
	else
2913
		pMga->ILOADBase = pMga->entityPrivate->mappedILOADBase;
2914
2915
	if(pMga->entityPrivate != NULL)
2916
		pMga->entityPrivate->mappedILOADUsage ++;
2887
#else
2917
#else
2888
	pMga->ILOADBase = xf86MapPciMem(pScrn->scrnIndex,
2918
	pMga->ILOADBase = xf86MapPciMem(pScrn->scrnIndex,
2889
					VIDMEM_MMIO | VIDMEM_MMIO_32BIT |
2919
					VIDMEM_MMIO | VIDMEM_MMIO_32BIT |
Lines 2905-2911 Link Here
2905
static Bool
2935
static Bool
2906
MGAUnmapMem(ScrnInfoPtr pScrn)
2936
MGAUnmapMem(ScrnInfoPtr pScrn)
2907
{
2937
{
2908
    MGAPtr pMga = MGAPTR(pScrn);
2938
 MGAPtr pMga = MGAPTR(pScrn);
2909
#ifdef XSERVER_LIBPCIACCESS
2939
#ifdef XSERVER_LIBPCIACCESS
2910
    struct pci_device * const dev = pMga->PciInfo;
2940
    struct pci_device * const dev = pMga->PciInfo;
2911
#endif
2941
#endif
Lines 2913-2922 Link Here
2913
    
2943
    
2914
    if (!pMga->FBDev) {
2944
    if (!pMga->FBDev) {
2915
#ifdef XSERVER_LIBPCIACCESS
2945
#ifdef XSERVER_LIBPCIACCESS
2916
        pci_device_unmap_range(dev, pMga->IOBase, 
2946
	    if(pMga->entityPrivate != NULL)
2917
			       dev->regions[pMga->io_bar].size);
2947
		    pMga->entityPrivate->mappedIOUsage --;
2918
        pci_device_unmap_range(dev, pMga->FbBase, 
2948
2919
			       dev->regions[pMga->framebuffer_bar].size);
2949
	    if(pMga->entityPrivate == NULL || pMga->entityPrivate->mappedIOUsage == 0)
2950
	    {
2951
		    int err = pci_device_unmap_range(dev, pMga->IOBase, 
2952
					   dev->regions[pMga->io_bar].size);
2953
2954
		if(err)
2955
	            xf86DrvMsg(pScrn->scrnIndex, X_INFO, "failed UNMAPPING io 0x%08llX, 0x%llX\n", (long long)pMga->IOBase, (long long)dev->regions[pMga->io_bar].size);
2956
	
2957
		    if(pMga->entityPrivate != NULL)
2958
			    pMga->entityPrivate->mappedIOBase = NULL;
2959
	    }
2960
2961
        int err = pci_device_unmap_range(dev, pMga->FbBase, pMga->FbMapSize);
2962
	if(err)
2963
	    xf86DrvMsg(pScrn->scrnIndex, X_INFO, "failed UNMAPPING framebuffer 0x%08llX, 0x%llX\n", (long long)pMga->FbBase, (long long)pMga->FbMapSize);
2920
#else
2964
#else
2921
	xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pMga->IOBase, 0x4000);
2965
	xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pMga->IOBase, 0x4000);
2922
	xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pMga->FbBase, pMga->FbMapSize);
2966
	xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pMga->FbBase, pMga->FbMapSize);
Lines 2929-2936 Link Here
2929
2973
2930
    if ((pMga->iload_bar != -1) && (pMga->ILOADBase != NULL)) {
2974
    if ((pMga->iload_bar != -1) && (pMga->ILOADBase != NULL)) {
2931
#ifdef XSERVER_LIBPCIACCESS
2975
#ifdef XSERVER_LIBPCIACCESS
2932
        pci_device_unmap_range(dev, pMga->ILOADBase,
2976
	    if(pMga->entityPrivate != NULL)
2977
		    pMga->entityPrivate->mappedILOADUsage --;
2978
2979
	    if(pMga->entityPrivate == NULL || pMga->entityPrivate->mappedILOADUsage == 0)
2980
	    {
2981
		int err =   pci_device_unmap_range(dev, pMga->ILOADBase,
2933
			       dev->regions[pMga->iload_bar].size);
2982
			       dev->regions[pMga->iload_bar].size);
2983
               if(err)
2984
                    xf86DrvMsg(pScrn->scrnIndex, X_INFO, "failed UNMAPPING iLOAD 0x%08llX, 0x%llX\n", (long long)pMga->ILOADBase, (long long)dev->regions[pMga->iload_bar].size);
2985
2986
		    if(pMga->entityPrivate != NULL)
2987
			    pMga->entityPrivate->mappedILOADBase = NULL;
2988
	    }
2989
2934
#else
2990
#else
2935
	xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pMga->ILOADBase, 0x800000);
2991
	xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pMga->ILOADBase, 0x800000);
2936
#endif
2992
#endif

Return to bug 441070