From owner-freebsd-x11@FreeBSD.ORG Mon Oct 27 14:16:38 2014 Return-Path: Delivered-To: x11@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B927D435; Mon, 27 Oct 2014 14:16:38 +0000 (UTC) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2A45BCC3; Mon, 27 Oct 2014 14:16:37 +0000 (UTC) Received: from tom.home (kostik@localhost [127.0.0.1]) by kib.kiev.ua (8.14.9/8.14.9) with ESMTP id s9REGVUS096887 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 27 Oct 2014 16:16:31 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.9.2 kib.kiev.ua s9REGVUS096887 Received: (from kostik@localhost) by tom.home (8.14.9/8.14.9/Submit) id s9REGVJU096886; Mon, 27 Oct 2014 16:16:31 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Mon, 27 Oct 2014 16:16:31 +0200 From: Konstantin Belousov To: Tijl Coosemans Subject: Re: [rfc] Radeon AGP support patches Message-ID: <20141027141631.GX1877@kib.kiev.ua> References: <20141026162442.1330d4c3@kalimero.tijl.coosemans.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20141026162442.1330d4c3@kalimero.tijl.coosemans.org> User-Agent: Mutt/1.5.23 (2014-03-12) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on tom.home Cc: x11@FreeBSD.org, dumbbell@FreeBSD.org X-BeenThere: freebsd-x11@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: X11 on FreeBSD -- maintaining and support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Oct 2014 14:16:38 -0000 On Sun, Oct 26, 2014 at 04:24:42PM +0100, Tijl Coosemans wrote: > Hi, > > I worked on AGP support for Radeon cards this week. Please take a look > at the attached patches. > > Patch 1: > Adds support for AGP_USER_TYPES to sys/dev/agp. For normal memory types > a vm_object is allocated, for user types only a vm_page array. It is > then up to the caller (e.g. TTM code) to manage this array. Arbitrary > pages can be mapped into the GTT this way. > Patch 3: > Enable AGP support in sys/dev/drm2. In PCI mode the GTT exists on the > graphics card so when accessing system memory it already does its own > virtual address translation and only physical addresses appear on the > system bus. The CPU can access the same addresses with its own VM > system like it always does. In AGP mode, translation is done by the > AGP chipset so fictitious addresses appear on the system bus. For the > CPU cache management to work correctly it needs to use these same > fictitious addresses instead of using the real physical addresses > directly. The patch marks the AGP aperture range fictitious in > radeon_device.c where the VRAM aperture is also marked fictitious such > that PHYS_TO_VM_PAGE in ttm_bo_vm_fault works for addresses in this > range. > > The rest of the patch is mostly porting to our agp_* API. It also > fixes two memory leaks in ttm_agp_backend.c. One is a missing free in > ttm_agp_tt_create. The other is because ttm_agp_bind allocates an > agp_memory struct but ttm_agp_unbind does not free it. So when calling > ttm_agp_bind a second time the reference to the struct is lost. The > patch changes ttm_agp_bind so the allocation only happens in the first > call. The struct is released in ttm_agp_destroy. Looking at the combination of patch 1 + 3. Do you really need to change the container for the AGP_USER_MEMORY ? Wouldn't it be enough to allocate array in ttm_agp_bind() and copy pointers to pages from the agp backing object to the array ?