Re: [patch 2.6.10-rc3 1/4] agpgart: allow multiple backends to be initialized

2004-12-20 Thread Alan Cox
On Gwe, 2004-12-17 at 20:55, Mike Werner wrote:
 [2/4] Run Lindent on generic.c

Please don't mix reformatting with oither submissions, especially as
Dave Jones is parallel working on and submitting patches for the various
cache/tlb flush violations in the current code that will overlap such a
reformatting.



---
SF email is sponsored by - The IT Product Guide
Read honest  candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. 
http://productguide.itmanagersjournal.com/
--
___
Dri-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dri-devel


Re: [patch 2.6.10-rc3 1/4] agpgart: allow multiple backends to be initialized

2004-12-20 Thread Mike Werner
This version removes the agp_find_bridge function pointer as Christoph 
requested.

 drivers/char/agp/agp.h  |3 +
 drivers/char/agp/backend.c  |  109 
 drivers/char/agp/frontend.c |   30 ++--
 drivers/char/agp/generic.c  |   73 +
 include/linux/agp_backend.h |   31 +++-
 5 files changed, 143 insertions(+), 103 deletions(-)

# This is a BitKeeper generated diff -Nru style patch.
#
# Allow multiple backends to be initialized
# 
diff -Nru a/drivers/char/agp/agp.h b/drivers/char/agp/agp.h
--- a/drivers/char/agp/agp.h2004-12-20 15:45:16 -08:00
+++ b/drivers/char/agp/agp.h2004-12-20 15:45:16 -08:00
@@ -1,5 +1,6 @@
 /*
  * AGPGART
+ * Copyright (C) 2004 Silicon Graphics, Inc.
  * Copyright (C) 2002-2004 Dave Jones
  * Copyright (C) 1999 Jeff Hartmann
  * Copyright (C) 1999 Precision Insight, Inc.
@@ -139,6 +140,7 @@
int capndx;
char major_version;
char minor_version;
+   struct list_head list;
 };
 
 #define OUTREG64(mmap, addr, val)  __raw_writeq((val), (mmap)+(addr))
@@ -271,6 +273,7 @@
 void global_cache_flush(void);
 void get_agp_version(struct agp_bridge_data *bridge);
 unsigned long agp_generic_mask_memory(unsigned long addr, int type);
+struct agp_bridge_data *agp_generic_find_bridge(struct pci_dev *pdev);
 
 /* generic routines for agp=3 */
 int agp3_generic_fetch_size(void);
diff -Nru a/drivers/char/agp/backend.c b/drivers/char/agp/backend.c
--- a/drivers/char/agp/backend.c2004-12-20 15:45:16 -08:00
+++ b/drivers/char/agp/backend.c2004-12-20 15:45:16 -08:00
@@ -1,5 +1,6 @@
 /*
  * AGPGART driver backend routines.
+ * Copyright (C) 2004 Silicon Graphics, Inc.
  * Copyright (C) 2002-2003 Dave Jones.
  * Copyright (C) 1999 Jeff Hartmann.
  * Copyright (C) 1999 Precision Insight, Inc.
@@ -42,34 +43,35 @@
  * fix some real stupidity. It's only by chance we can bump
  * past 0.99 at all due to some boolean logic error. */
 #define AGPGART_VERSION_MAJOR 0
-#define AGPGART_VERSION_MINOR 100
+#define AGPGART_VERSION_MINOR 101
 static struct agp_version agp_current_version =
 {
.major = AGPGART_VERSION_MAJOR,
.minor = AGPGART_VERSION_MINOR,
 };
 
-static int agp_count=0;
-
-struct agp_bridge_data agp_bridge_dummy = { .type = NOT_SUPPORTED };
-struct agp_bridge_data *agp_bridge = agp_bridge_dummy;
+struct agp_bridge_data *agp_bridge;
+LIST_HEAD(agp_bridges);
 EXPORT_SYMBOL(agp_bridge);
-
+EXPORT_SYMBOL(agp_bridges);
 
 /**
- * agp_backend_acquire  -  attempt to acquire the agp backend.
+ * agp_backend_acquire  -  attempt to acquire an agp backend.
  *
- * returns -EBUSY if agp is in use,
- * returns 0 if the caller owns the agp backend
  */
-int agp_backend_acquire(void)
+struct agp_bridge_data *agp_backend_acquire(struct pci_dev *pdev)
 {
-   if (agp_bridge-type == NOT_SUPPORTED)
-   return -EINVAL;
-   if (atomic_read(agp_bridge-agp_in_use))
-   return -EBUSY;
-   atomic_inc(agp_bridge-agp_in_use);
-   return 0;
+   struct agp_bridge_data *bridge;
+
+   bridge = agp_generic_find_bridge(pdev);
+
+   if (!bridge)
+   return NULL;
+   
+   if (atomic_read(bridge-agp_in_use))
+   return NULL;
+   atomic_inc(bridge-agp_in_use);
+   return bridge;
 }
 EXPORT_SYMBOL(agp_backend_acquire);
 
@@ -82,10 +84,11 @@
  *
  * (Ensure that all memory it bound is unbound.)
  */
-void agp_backend_release(void)
+void agp_backend_release(struct agp_bridge_data *bridge)
 {
-   if (agp_bridge-type != NOT_SUPPORTED)
-   atomic_dec(agp_bridge-agp_in_use);
+
+   if (bridge)
+   atomic_dec(bridge-agp_in_use);
 }
 EXPORT_SYMBOL(agp_backend_release);
 
@@ -121,7 +124,6 @@
 (maxes_table[index].agp - maxes_table[index - 1].agp)) /
   (maxes_table[index].mem - maxes_table[index - 1].mem);
 
-   printk(KERN_INFO PFX Maximum main memory to use for agp memory: 
%ldM\n, result);
result = result  (20 - PAGE_SHIFT);
return result;
 }
@@ -178,9 +180,6 @@
goto err_out;
}
 
-   printk(KERN_INFO PFX AGP aperture is %dM @ 0x%lx\n,
-  size_value, bridge-gart_bus_addr);
-
return 0;
 
 err_out:
@@ -225,16 +224,31 @@
agp_copy_info
 };
 
-/* XXX Kludge alert: agpgart isn't ready for multiple bridges yet */
+/* When we remove the global variable agp_bridge from all drivers
+ * then agp_alloc_bridge and agp_generic_find_bridge need to be updated
+ */
+
 struct agp_bridge_data *agp_alloc_bridge(void)
 {
-   return agp_bridge;
+   struct agp_bridge_data *bridge = kmalloc(sizeof(*bridge), GFP_KERNEL);
+
+   if (!bridge)
+   return NULL;
+
+   if (list_empty(agp_bridges))
+   agp_bridge = bridge;
+
+   return bridge;
 }
 EXPORT_SYMBOL(agp_alloc_bridge);
 
 
 void agp_put_bridge(struct agp_bridge_data *bridge)
 {
+

Re: [patch 2.6.10-rc3 1/4] agpgart: allow multiple backends to be initialized

2004-12-19 Thread Christoph Hellwig
On Sat, Dec 18, 2004 at 09:17:14AM -0800, Mike Werner wrote:
  The agp_bridge_find function pointer is bogus, that way you can only support
  one backend at a time. 
 Obviously you mean one type of backend here.
 I have tried to simplify this patch as much as possible so that it only tries 
 to do one thing
 and that is just the api change. I think the searching for valid bridges is a 
 separate issue
 since none of the currently supported hardware needs it. The only possible 
 platform
 that I assumed might is amd64 and Andi Kleen specifically told me it doesn't.

I agree that it's a separate issue.  So keep the function poniter out for
the time beeing and we can discuss it last.

 I don't agree that you *must* pass the agp_bridge_data pointer for every 
 method.
 You don't need it for bind/unbind/free if you associate each memory region
 allocated using agp_allocate_memory(bridge,...) with a particular bridge 
 which is what the patch does. That is, agp_memory knows which bridge it 
 belongs to.

Yes, agreed.  But you need to pass the agp_bridge_data to each function in
some way.


---
SF email is sponsored by - The IT Product Guide
Read honest  candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. 
http://productguide.itmanagersjournal.com/
--
___
Dri-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dri-devel


Re: [patch 2.6.10-rc3 1/4] agpgart: allow multiple backends to be initialized

2004-12-18 Thread Christoph Hellwig
On Fri, Dec 17, 2004 at 12:55:59PM -0800, Mike Werner wrote:
 This new version reduces the number of changes required by users of the 
 agpgart
 such as drm to support the new api for multiple agp bridges. 
 The first patch doesn't touch any platform specific files and all current 
 platform
 gart drivers will just work the same as they do now since the global 
 agp_bridge is still supported as the default bridge.

The agp_bridge_find function pointer is bogus, that way you can only support
one backend at a time.  I'm not really sure how to do that propery, best have
the generic code walk down the pci device parent chain until it finds an AGP
bridge and allow drivers that don't present their bridges as PCI devices to
supply additional ways to search.

Most other bits of the patch are fine, but in either case you first need to
change the agp bridge driver API to take a struct agp_bridge_data in every
method, else all these changes don't make sense at all.



---
SF email is sponsored by - The IT Product Guide
Read honest  candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. 
http://productguide.itmanagersjournal.com/
--
___
Dri-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dri-devel


[patch 2.6.10-rc3 1/4] agpgart: allow multiple backends to be initialized

2004-12-17 Thread Mike Werner
This new version reduces the number of changes required by users of the agpgart
such as drm to support the new api for multiple agp bridges. 
The first patch doesn't touch any platform specific files and all current 
platform
gart drivers will just work the same as they do now since the global 
agp_bridge is still supported as the default bridge.

Summary for the 4 patches.
[1/4] Allow multiple backends to be initialized for agpgart
[2/4] Run Lindent on generic.c
[3/4] Patch drm code to work with modified agpgart api.
[4/4] Patch framebuffer code to work with modified agpgart api.
-
drivers/char/agp/agp.h  |3 +
drivers/char/agp/backend.c  |  112 +---
drivers/char/agp/frontend.c |   30 ++-
drivers/char/agp/generic.c  |   71 ---
include/linux/agp_backend.h |   32 +++-
5 files changed, 145 insertions(+), 103 deletions(-)
 
# This is a BitKeeper generated diff -Nru style patch.
#
#   Allow multiple backends to be initialized
#
diff -Nru a/drivers/char/agp/agp.h b/drivers/char/agp/agp.h
--- a/drivers/char/agp/agp.h2004-12-17 10:36:04 -08:00
+++ b/drivers/char/agp/agp.h2004-12-17 10:36:04 -08:00
@@ -1,5 +1,6 @@
 /*
  * AGPGART
+ * Copyright (C) 2004 Silicon Graphics, Inc.
  * Copyright (C) 2002-2004 Dave Jones
  * Copyright (C) 1999 Jeff Hartmann
  * Copyright (C) 1999 Precision Insight, Inc.
@@ -139,6 +140,7 @@
int capndx;
char major_version;
char minor_version;
+   struct list_head list;
 };
 
 #define OUTREG64(mmap, addr, val)  __raw_writeq((val), (mmap)+(addr))
@@ -271,6 +273,7 @@
 void global_cache_flush(void);
 void get_agp_version(struct agp_bridge_data *bridge);
 unsigned long agp_generic_mask_memory(unsigned long addr, int type);
+struct agp_bridge_data *agp_generic_find_bridge(struct pci_dev *pdev);
 
 /* generic routines for agp=3 */
 int agp3_generic_fetch_size(void);
diff -Nru a/drivers/char/agp/backend.c b/drivers/char/agp/backend.c
--- a/drivers/char/agp/backend.c2004-12-17 10:36:04 -08:00
+++ b/drivers/char/agp/backend.c2004-12-17 10:36:04 -08:00
@@ -1,5 +1,6 @@
 /*
  * AGPGART driver backend routines.
+ * Copyright (C) 2004 Silicon Graphics, Inc.
  * Copyright (C) 2002-2003 Dave Jones.
  * Copyright (C) 1999 Jeff Hartmann.
  * Copyright (C) 1999 Precision Insight, Inc.
@@ -42,34 +43,36 @@
  * fix some real stupidity. It's only by chance we can bump
  * past 0.99 at all due to some boolean logic error. */
 #define AGPGART_VERSION_MAJOR 0
-#define AGPGART_VERSION_MINOR 100
+#define AGPGART_VERSION_MINOR 101
 static struct agp_version agp_current_version =
 {
.major = AGPGART_VERSION_MAJOR,
.minor = AGPGART_VERSION_MINOR,
 };
 
-static int agp_count=0;
-
-struct agp_bridge_data agp_bridge_dummy = { .type = NOT_SUPPORTED };
-struct agp_bridge_data *agp_bridge = agp_bridge_dummy;
+struct agp_bridge_data *agp_bridge;
+LIST_HEAD(agp_bridges);
+struct agp_bridge_data *(*agp_find_bridge)(struct pci_dev *pdev);
 EXPORT_SYMBOL(agp_bridge);
-
+EXPORT_SYMBOL(agp_bridges);
 
 /**
- * agp_backend_acquire  -  attempt to acquire the agp backend.
+ * agp_backend_acquire  -  attempt to acquire an agp backend.
  *
- * returns -EBUSY if agp is in use,
- * returns 0 if the caller owns the agp backend
  */
-int agp_backend_acquire(void)
+struct agp_bridge_data *agp_backend_acquire(struct pci_dev *pdev)
 {
-   if (agp_bridge-type == NOT_SUPPORTED)
-   return -EINVAL;
-   if (atomic_read(agp_bridge-agp_in_use))
-   return -EBUSY;
-   atomic_inc(agp_bridge-agp_in_use);
-   return 0;
+   struct agp_bridge_data *bridge;
+
+   bridge = agp_find_bridge(pdev);
+
+   if (!bridge)
+   return NULL;
+   
+   if (atomic_read(bridge-agp_in_use))
+   return NULL;
+   atomic_inc(bridge-agp_in_use);
+   return bridge;
 }
 EXPORT_SYMBOL(agp_backend_acquire);
 
@@ -82,10 +85,11 @@
  *
  * (Ensure that all memory it bound is unbound.)
  */
-void agp_backend_release(void)
+void agp_backend_release(struct agp_bridge_data *bridge)
 {
-   if (agp_bridge-type != NOT_SUPPORTED)
-   atomic_dec(agp_bridge-agp_in_use);
+
+   if (bridge)
+   atomic_dec(bridge-agp_in_use);
 }
 EXPORT_SYMBOL(agp_backend_release);
 
@@ -121,7 +125,6 @@
 (maxes_table[index].agp - maxes_table[index - 1].agp)) /
   (maxes_table[index].mem - maxes_table[index - 1].mem);
 
-   printk(KERN_INFO PFX Maximum main memory to use for agp memory: 
%ldM\n, result);
result = result  (20 - PAGE_SHIFT);
return result;
 }
@@ -178,9 +181,6 @@
goto err_out;
}
 
-   printk(KERN_INFO PFX AGP aperture is %dM @ 0x%lx\n,
-  size_value, bridge-gart_bus_addr);
-
return 0;
 
 err_out:
@@ -225,16 +225,31 @@
agp_copy_info
 };