%include "style.mgp" %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %page %nodefault %size 7, font "standard", fore "white", vgap 20 %bquality 10 %center Ugly Ducklings %size 4 Resurrecting unmaintained code. %size 3 (UKUUG, Edinburgh, August 2003) %size 4 Dave Jones SuSE Labs. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %page %nodefault %size 7, font "standard", fore "white", vgap 20 %bquality 10 %center Ugly Ducklings %size 4 Resurrecting unmaintained code. %size 3 (UKUUG, Edinburgh, August 2003) %size 4 Dave Jones Red Hat. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %page Agenda.. %size 4 Driver lifecycle. Case study 1: x86 MTRR driver. Case study 2: AGPGARTs transformation into a swan. TODO %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %page Lifecycle of a driver. %size 4 Driver written for hardware vendor A's widget. Vendor B makes compatable widget ID for vendor Bs widget added to driver Repeat. %pause Slightly different widgets start appearing. Special cases start getting added. Abstraction layers start getting added to clean up special cases. Repeat. %pause Driver maintainer gets bored, and moves on to new fields.. Driver is now unmaintained... %pause ... and unmaintainable! %page Lifecycle of a driver (pt2). %size 4 Driver is now 100K+ of spaghetti. "new ids only" state. New widget IDs get added. Most people too scared to change code too much. "If it works, don't touch it" %%%%%%%%%%%%%%%%% %page Case study #1: x86 MTRR driver. %size 4 Userspace interface (/proc/mtrr) for MTRR registers. arch/i386/kernel/mtrr.c introduced mid 2.1.x Original supported Intel style MTRRs... %pause And then Cyrix ARRs... %pause And then AMD K6 style MTRRs... %pause And then Centaur MCRs... %pause And then Intel-style on non-Intel (Athlon, VIA etc). %%%%%%%%%%%%%%%%% %page Case study #1: x86 MTRR driver. %size 4 Things got a bit out of hand. 2.4 today - 2314 lines of code. (stripped down x86-64 variant - 1314 lines of code). 2.5 today - 2179 lines of code. No real code differences. Split out into per vendor files. No more "your AMD change broke my Intel box" %%%%%%%%%%%%%%%%% %page Case study #2: AGPGART %size 4 CPU<->Mem<->Graphic MMU, /dev/agpgart drivers/char/agp/ January 2002 AMD64 project needed a GART driver. Originally offered to Pavel Machek %pause (who had sense to turn it down). agpgart was in the "new IDs only" state. (show new_id.diff) %page Getting up to speed on AGPGART %size 4 134KB of code. 6880 lines of code. Supporting 50 different AGP chipsets From 8 different vendors. All subtley different. No response from Maintainer. %%%%%%%%%%%%%%%%%%%%%%%% %page Hacking AMD64 support. %size 4 AMD64 GART unlike other GARTs. Northbridge is on CPU. May be >1 of them. Must be kept coherent. No AGP 3.0 support. Mostly compatable. Somehow, by June 2002, it worked. Mostly. %pause "Never, ever again..." For 2.5, time to rethink things. %%%%%%%%%%%%%%%%%% %page Per vendor files. %size 4 Keep things simple.. #ifdef CONFIG_FOO .. foo .. #endif move foo to foo.c #ifdef CONFIG_FOO #include foo.c #endif Fugly, but works. %%%%%%%%%%%%%%%%% %page Reducing dependancies. %size 4 Make each vendor.c compile standalone externs local copies of functions. Functions that do one thing only. Split up huge "support everything" functions. Lots of "support xxx" functions instead. %%%%%%%%%%%%%%%%% %page The device ID list from hell. %size 4 Show list in 2.4 & split. %pause REJECTED!! %%%%%%%%%%%%%%%%% %page Split into seperate modules. %size 4 GregKH had done most of the conversion to 'new' PCI API A few extra pci_driver changes. Increased seperation between core and driver. Added more dependancy rules to modules Broke compatability with 2.4 Still needs hotplug fixes. (Show 2.5 split up). %%%%%%%%%%%%%%%%%%% %page Useless abstractions. CACHE_FLUSH(); A macro which expands to agp_bridge.cache_flush %pause agp_bridge.cache_flush in 99% of cases, points to global_cache_flush %pause On SMP, global_cache_flush is a define for smp_flush_cache smp_flush_cache just does an smp_call_function on flush_cache %pause On UP, it's a define for flush_cache %pause flush_cache does a "wbinvd" on IA32/X86_64, "mb" on IA64 (or #errors on anything else). %%%%%%%%%%%%%%%%%% %page Moving forward... %size 4 Clean slate to build upon. AGP 3 support. AMD64 had support already. More generic support added. Coincided with arrival of more AGP3 chipsets VIA KT400, Intel E7x05 Driver had evolved somewhat since 2.4 MAINTAINERS addition. %%%%%%%%%%%%%%%%%%% %page A nice surprise. %size 4 Original maintainer reappears. %pause Had been working on agpgart privately for some time. Generic AGP 3 support. (Though no chipset drivers). Large amounts of code rewritten. Missed out on the obvious cleanups. Was based on 2.4.early Ended up with 380KB of diffs. %%%%%%%%%%%%%%%%%%%%% %page Integration. %size 4 Working with Jeff to split up diffs. Fed bits to Linus. Remainder left for the time being. Possibly 2.7 material. Linus objections to Jeffs remainders. ioctl -> sysfs Breaks FreeBSD. %%%%%%%%%%%%%%%%%%%%%%%% %page Exploring other areas. %size 4 DRI - close ties to agpgart. XFree86 - Userspace side of agpgart. FreeBSD - The other free agpgart implementation. NVIDIA / ATi part binary drivers - ? %%%%%%%%%%%%%%%%%%%%%%%%% %page Vendor drivers. - NVIDIA %size 4 Supported NForce / NForce2 AGPGART IFF you had an NVIDIA GFX card. EXPORT_SYMBOL_GPL(agp_add_bridge); 2.4.18 AGPGART driver. 2.5 forward port. %%%%%%%%%%%%%%%%%%%%%%%%% %page Vendor drivers. - ATi %size 4 2.4.18 based. Ugly as all hell. Doesn't seem to support ATI GARTs. Reverse engineering Radeon IGP. Several drivers now exist. My driver. Wouter Bijlsma's driver. ATI driver. All subtley broken. Serverworks? AMD ? %%%%%%%%%%%%%%%%%%%%%%%%% %page Results. %size 4 For: Much cleaner AGP code in 2.6 Infinitly more maintainable. Infinitly more enhanceable. (Though with PCI-Express coming soon...) %pause Against: Headache! Abuse! Increased workload! "blame" attribution. %%%%%%%%%%%%%%%%%%%%%%%%% %page TODO %size 4 AGPGART Module locking. DRI <-> AGP inter module. Hotplug chipset drivers. Frontend. list.h, sysfs. Other potential kernel areas.. Watchdog drivers security problem watchdoglib? ECC drivers. not yet merged. existing patches need work. Memory copy routines. Reduce need for 'athlon' kernels. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %page Questions & Heckling.