WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] Re: ATI radeon fails with "iommu=soft swiotlb=force" (se

To: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>, Jeremy Fitzhardinge <jeremy@xxxxxxxx>
Subject: Re: [Xen-devel] Re: ATI radeon fails with "iommu=soft swiotlb=force" (seen on RV730/RV740 and RS780/RS800)
From: Boris Derzhavets <bderzhavets@xxxxxxxxx>
Date: Thu, 1 Oct 2009 22:02:03 -0700 (PDT)
Cc: dri-devel@xxxxxxxxxxxxxxxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxx, JBeulich@xxxxxxxxxx
Delivery-date: Thu, 01 Oct 2009 22:03:00 -0700
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1254459724; bh=n45jbyfLD6YqlB48ONWD9VtLjeU55wydIGNFSCXc4Jo=; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:Cc:MIME-Version:Content-Type; b=kNqzTK8giYxIHReGq1aCuiXgW6+IodmUsCHSBKnQidtM+frnHdgCoFj+qBw4MZg6KeQ8DUCrtZDbSxE6lET/3R8nKEuAIY3GD/GTkhsakuyW5pKM7HcfP12OL51LUtbKBmwjj16P3LHq7orB+1sOH1NJKYQvhNk37E/iCTIWSQk=
Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:Cc:MIME-Version:Content-Type; b=k1f7QODrwaSchQJA3w4+y6wlGtA9Q7KCcZVrRss+SC4O88pX6Zw5J75kx1bDpb/sFumvQg1ngXEc65k1VIr1OQ7HTmOwv520bjSxjs3mtUR+bXbPbJ134el+3rXzvVK9PbCUAYxwoKAGXd+aDh1VdFOt1X/ZpGH4jeCNAtd7n/s=;
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Patch applied on the box with Radeon HD 4650 and seems to be working
for 2.6.31.1 under Xen 3.4.1 on top Ubuntu 9.04 Server ( Ubuntu Desktop
installed via tasksel). Before login to Gnome Desktop monitor shows up for 2-3 seconds "power saving" message, like it has got disconnected, the awakes back and normal login procedure resumes.

Boris.

--- On Thu, 10/1/09, Jeremy Fitzhardinge <jeremy@xxxxxxxx> wrote:

From: Jeremy Fitzhardinge <jeremy@xxxxxxxx>
Subject: [Xen-devel] Re: ATI radeon fails with "iommu=soft swiotlb=force" (seen on RV730/RV740 and RS780/RS800)
To: "Konrad Rzeszutek Wilk" <konrad.wilk@xxxxxxxxxx>
Cc: dri-devel@xxxxxxxxxxxxxxxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxx, JBeulich@xxxxxxxxxx
Date: Thursday, October 1, 2009, 3:37 PM

On 10/01/09 12:07, Jeremy Fitzhardinge wrote:
> Could modify drm_vmalloc_dma to do the vmalloc "manually":
>
>    1. call __get_vm_area to reserve a chunk of vmalloc address space
>    2. allocate a bunch of individual pages with dma_alloc_coherent
>    3. insert them into the vmalloc mapping with map_vm_area
>
> That will guarantee a normal-looking vmalloc area with device-friendly
> pages that subsequent pci_map_page operations will use as-is.
>   

Like this (untested):

diff --git a/drivers/gpu/drm/drm_scatter.c b/drivers/gpu/drm/drm_scatter.c
index c7823c8..73bfa63 100644
--- a/drivers/gpu/drm/drm_scatter.c
+++ b/drivers/gpu/drm/drm_scatter.c
@@ -32,16 +32,60 @@
  */

#include <linux/vmalloc.h>
+#include <linux/mm.h>
#include "drmP.h"

#define DEBUG_SCATTER 0

-static inline void *drm_vmalloc_dma(unsigned long size)
+static inline void *drm_vmalloc_dma(struct drm_device *drmdev, unsigned long size)
{
#if defined(__powerpc__) && defined(CONFIG_NOT_COHERENT_CACHE)
    return __vmalloc(size, GFP_KERNEL, PAGE_KERNEL | _PAGE_NO_CACHE);
#else
-    return vmalloc_32(size);
+    struct device *dev = &drmdev->pdev->dev;
+    struct vm_struct *vma;
+    struct page **pages;
+    const int npages = PFN_UP(size);
+    int i;
+
+    pages = kmalloc(npages * sizeof(*pages), GFP_KERNEL);
+    if (!pages)
+        goto out_free_pagearr;
+
+    vma = __get_vm_area(size, VM_ALLOC, VMALLOC_START, VMALLOC_END);
+    if (!vma)
+        goto out_release_vma;
+
+    for (i = 0; i < npages; i++) {
+        dma_addr_t phys;
+        void *addr;
+        addr = dma_alloc_coherent(dev, PAGE_SIZE, &phys, GFP_KERNEL);
+        if (addr == NULL)
+            goto out_free_pages;
+
+        pages[i] = virt_to_page(addr);
+    }
+
+    if (map_vm_area(vma, PAGE_KERNEL, &pages))
+        goto out_free_pages;
+
+    kfree(pages);
+
+    return vma->addr;
+
+out_free_pages:
+    while(i > 0) {
+        void *addr = page_address(pages[--i]);
+        dma_free_coherent(dev, PAGE_SIZE, addr, virt_to_bus(addr));
+    }
+
+out_release_vma:
+    vunmap(vma->addr);
+
+out_free_pagearr:
+    kfree(pages);
+
+    return NULL;
#endif
}

@@ -107,7 +151,7 @@ int drm_sg_alloc(struct drm_device *dev, struct drm_scatter_gather * request)
    }
    memset((void *)entry->busaddr, 0, pages * sizeof(*entry->busaddr));

-    entry->virtual = drm_vmalloc_dma(pages << PAGE_SHIFT);
+    entry->virtual = drm_vmalloc_dma(dev, pages << PAGE_SHIFT);
    if (!entry->virtual) {
        kfree(entry->busaddr);
        kfree(entry->pagelist);



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

Attachment: config.drm_scatter
Description: Binary data

Attachment: drm_scatter.c
Description: Text Data

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>