Changeset 4738


Ignore:
Timestamp:
11/02/08 09:43:38 (8 years ago)
Author:
werner
Message:

Cleanup.

drivers/ar6000/hif/hif2.c:

  • MODULE_LICENSE is GPLv2, not just GPL
  • added cleanup after initialization errors
  • added partial cleanup on removal
  • removed solved/obsolete problems from list of known bugs
  • added description of differences to Atheros's HIFs
  • removed initialization thread, since it doesn't seem to be needed
  • removed out-of-band interrupt code
  • removed setting of SDIO_POWER_EMPC in SDIO_CCCR_POWER (still needs checking with Atheros, though)
  • added sections and moved HIFInit to a more logical place
Location:
developers/werner/wlan-spi/patches-tracking
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • developers/werner/wlan-spi/patches-tracking/gta02-mmc-mci.patch

    r4737 r4738  
    33Index: ktrack/arch/arm/mach-s3c2440/Kconfig 
    44=================================================================== 
    5 --- ktrack.orig/arch/arm/mach-s3c2440/Kconfig   2008-11-02 04:29:34.000000000 -0200 
    6 +++ ktrack/arch/arm/mach-s3c2440/Kconfig        2008-11-02 04:32:14.000000000 -0200 
     5--- ktrack.orig/arch/arm/mach-s3c2440/Kconfig   2008-11-02 07:32:56.000000000 -0200 
     6+++ ktrack/arch/arm/mach-s3c2440/Kconfig        2008-11-02 07:32:56.000000000 -0200 
    77@@ -113,6 +113,11 @@ 
    88                 bool "GPIO bit-banging SPI" 
     
    1919Index: ktrack/arch/arm/mach-s3c2440/mach-gta02.c 
    2020=================================================================== 
    21 --- ktrack.orig/arch/arm/mach-s3c2440/mach-gta02.c      2008-11-02 04:29:34.000000000 -0200 
    22 +++ ktrack/arch/arm/mach-s3c2440/mach-gta02.c   2008-11-02 04:33:05.000000000 -0200 
     21--- ktrack.orig/arch/arm/mach-s3c2440/mach-gta02.c      2008-11-02 07:32:56.000000000 -0200 
     22+++ ktrack/arch/arm/mach-s3c2440/mach-gta02.c   2008-11-02 07:32:56.000000000 -0200 
    2323@@ -1720,6 +1720,11 @@ 
    2424        platform_device_register(&gta02_spi_wlan); 
  • developers/werner/wlan-spi/patches-tracking/hif-linux-sdio.patch

    r4726 r4738  
    1212Index: ktrack/drivers/ar6000/Makefile 
    1313=================================================================== 
    14 --- ktrack.orig/drivers/ar6000/Makefile 2008-10-15 22:04:35.000000000 -0200 
    15 +++ ktrack/drivers/ar6000/Makefile      2008-10-15 22:04:35.000000000 -0200 
     14--- ktrack.orig/drivers/ar6000/Makefile 2008-11-02 05:48:42.000000000 -0200 
     15+++ ktrack/drivers/ar6000/Makefile      2008-11-02 05:48:44.000000000 -0200 
    1616@@ -21,7 +21,7 @@ 
    1717                htc/htc_recv.o             \ 
     
    2626=================================================================== 
    2727--- /dev/null   1970-01-01 00:00:00.000000000 +0000 
    28 +++ ktrack/drivers/ar6000/hif/hif2.c    2008-10-17 04:26:14.000000000 -0200 
    29 @@ -0,0 +1,625 @@ 
     28+++ ktrack/drivers/ar6000/hif/hif2.c    2008-11-02 07:39:48.000000000 -0200 
     29@@ -0,0 +1,569 @@ 
    3030+/* 
    3131+ * hif2.c - HIF layer re-implementation for the Linux SDIO stack 
     
    6464+ * 
    6565+ * - HIF_DEVICE_IRQ_ASYNC_SYNC doesn't work yet (gets MMC errors) 
    66 + * - does not work with S3C SDI (probably due to bugs in the latter) 
    67 + * - not ready for S3C SPI yet 
    68 + * - no cleanup on setup errors yet 
    6966+ * - driver doesn't remove cleanly yet 
    7067+ * - latency can reach hundreds of ms, probably because of scheduling delays 
    7168+ * - packets go through about three queues before finally hitting the network 
     69+ */ 
     70+ 
     71+/* 
     72+ * Differences from Atheros' HIFs: 
     73+ * 
     74+ * - synchronous and asynchronous requests may get reordered with respect to 
     75+ *   each other, e.g., if HIFReadWrite returns for an asynchronous request and 
     76+ *   then HIFReadWrite is called for a synchronous request, the synchronous 
     77+ *   request may be executed before the asynchronous request. 
     78+ * 
     79+ * - request queue locking seems unnecessarily complex in the Atheros HIFs. 
     80+ * 
     81+ * - Atheros mask interrupts by calling sdio_claim_irq/sdio_release_irq, which 
     82+ *   can cause quite a bit of overhead. This HIF has its own light-weight 
     83+ *   interrupt masking. 
     84+ * 
     85+ * - Atheros call deviceInsertedHandler from a thread spawned off the probe or 
     86+ *   device insertion function. The original explanation for the Atheros SDIO 
     87+ *   stack said that this is done because a delay is needed to let the chip 
     88+ *   complete initialization. There is indeed a one second delay in the thread. 
     89+ * 
     90+ *   The Atheros Linux SDIO HIF removes the delay and only retains the thread. 
     91+ *   Experimentally removing the thread didn't show any conflicts, so let's get 
     92+ *   rid of it for good. 
     93+ * 
     94+ * - The Atheros SDIO stack with Samuel's driver sets SDIO_CCCR_POWER in 
     95+ *   SDIO_POWER_EMPC. Atheros' Linux SDIO code apparently doesn't. We don't 
     96+ *   either, and this seems to work fine. 
     97+ *   @@@ Need to check this with Atheros. 
    7298+ */ 
    7399+ 
     
    118144+ 
    119145+ 
    120 +int HIFInit(HTC_CALLBACKS *callbacks) 
    121 +{ 
    122 +       BUG_ON(!callbacks); 
    123 + 
    124 +       printk(KERN_INFO "HIFInit\n"); 
    125 +       htcCallbacks = *callbacks; 
    126 + 
    127 +       return 0; 
    128 +} 
     146+/* ----- Request processing ------------------------------------------------ */ 
    129147+ 
    130148+ 
     
    182200+{ 
    183201+       struct hif_device *hif = data; 
    184 +       DECLARE_WAITQUEUE(wait, current); 
     202+       DEFINE_WAIT(wait); 
    185203+       struct hif_request *req; 
    186204+ 
    187205+       while (1) { 
    188 +               add_wait_queue(&hif->wait, &wait); 
    189206+               while (1) { 
    190 +                       set_current_state(TASK_INTERRUPTIBLE); 
    191 +                       if (signal_pending(current)) { 
    192 +                               req = NULL; 
    193 +                               break; 
     207+                       prepare_to_wait(&hif->wait, &wait, TASK_INTERRUPTIBLE); 
     208+                       if (kthread_should_stop()) { 
     209+                               finish_wait(&hif->wait, &wait); 
     210+                               return 0; 
    194211+                       } 
    195212+                       req = dequeue_request(hif); 
     
    198215+                       schedule(); 
    199216+               } 
    200 +               set_current_state(TASK_RUNNING); 
    201 +               remove_wait_queue(&hif->wait, &wait); 
    202 + 
    203 +               if (!req) 
    204 +                       break; 
     217+               finish_wait(&hif->wait, &wait); 
    205218+ 
    206219+               (void) process_request(req); 
     
    265278+ 
    266279+       return A_OK; 
     280+} 
     281+ 
     282+ 
     283+/* ----- Device initialization and shutdown (HIF side) --------------------- */ 
     284+ 
     285+ 
     286+int HIFInit(HTC_CALLBACKS *callbacks) 
     287+{ 
     288+       BUG_ON(!callbacks); 
     289+ 
     290+       printk(KERN_INFO "HIFInit\n"); 
     291+       htcCallbacks = *callbacks; 
     292+ 
     293+       return 0; 
    267294+} 
    268295+ 
     
    306333+ 
    307334+ 
    308 +/* ========================================================================= */ 
    309 + 
    310 +#if 1 
     335+/* ----- Interrupt handling ------------------------------------------------ */ 
    311336+ 
    312337+/* 
     
    416441+} 
    417442+ 
    418 +#endif 
    419 + 
    420 +/* ========================================================================= */ 
    421 + 
    422 +/* 
    423 + * The code below is for handling interrupts signalled out-of-band. 
    424 + */ 
    425 +#if 0 
    426 +#define IRQ_GPIO S3C2410_GPE8 /* SDDAT1 */ 
    427 + 
    428 + 
    429 +static atomic_t mask = ATOMIC_INIT(1); 
    430 + 
    431 + 
    432 +static void sdio_ar6000_irq(struct sdio_func *func) 
    433 +{ 
    434 +       HIF_DEVICE *hif = sdio_get_drvdata(func); 
    435 + 
    436 +       printk(KERN_DEBUG "sdio_ar6000_irq -> %p\n", htcCallbacks.dsrHandler); 
    437 +       BUG(); 
    438 +} 
    439 + 
    440 + 
    441 +static void sdio_ar6000_poll(void *context) 
    442 +{ 
    443 +       HIF_DEVICE *hif = context; 
    444 +       A_STATUS status; 
    445 + 
    446 +       while (1) { 
    447 +               yield(); 
    448 +               if (!gpio_get_value(IRQ_GPIO)) 
    449 +                       continue; 
    450 +               if (!atomic_add_unless(&mask, 1, 1)) 
    451 +                       continue; 
    452 +               status = htcCallbacks.dsrHandler(hif->htc_handle); 
    453 +               BUG_ON(status != A_OK); 
    454 +       } 
    455 +} 
    456 + 
    457 + 
    458 +void HIFAckInterrupt(HIF_DEVICE *hif) 
    459 +{ 
    460 +       struct device *dev = HIFGetOSDevice(hif); 
    461 +       int ret; 
    462 + 
    463 +       ret = atomic_dec_return(&mask); 
    464 +       BUG_ON(ret < 0); 
    465 +       dev_dbg(dev, "HIFAckInterrupt (%d)\n", ret); 
    466 +} 
    467 + 
    468 + 
    469 +void HIFUnMaskInterrupt(HIF_DEVICE *hif) 
    470 +{ 
    471 +       struct device *dev = HIFGetOSDevice(hif); 
    472 +       int ret; 
    473 + 
    474 +       ret = atomic_dec_return(&mask); 
    475 +       BUG_ON(ret < 0); 
    476 +       dev_dbg(dev, "HIFUnMaskInterrupt (%d)\n", ret); 
    477 +} 
    478 + 
    479 + 
    480 +void HIFMaskInterrupt(HIF_DEVICE *hif) 
    481 +{ 
    482 +       struct device *dev = HIFGetOSDevice(hif); 
    483 +       int ret; 
    484 + 
    485 +       ret = atomic_inc_return(&mask); 
    486 +       BUG_ON(ret > 1); 
    487 +       dev_dbg(dev, "HIFMaskInterrupt (%d)\n", ret); 
    488 +} 
    489 +#endif 
    490 + 
    491 +/* ========================================================================= */ 
    492 + 
    493 + 
    494 +/* ----- Some stuff needed for Atheros' API -------------------------------- */ 
     443+ 
     444+/* ----- HIF API glue functions -------------------------------------------- */ 
     445+ 
    495446+ 
    496447+struct device *HIFGetOSDevice(HIF_DEVICE *hif) 
     
    508459+ 
    509460+ 
    510 +/* -----  */ 
    511 + 
    512 + 
    513 + 
    514 +/* 
    515 + * @@@ Atheros' HIF says this hack is necessary. Check this. 
    516 + */ 
    517 + 
    518 +static int inserter(void *data) 
    519 +{ 
    520 +       int ret; 
    521 + 
    522 +       msleep(1000); 
    523 +       ret = htcCallbacks.deviceInsertedHandler(&hif_device); 
    524 +       printk(KERN_ERR "got %d\n", ret); 
    525 +       return 0; 
    526 +} 
     461+/* ----- Device setup and removal (Linux side) ----------------------------- */ 
    527462+ 
    528463+ 
     
    532467+       struct device *dev = &func->dev; 
    533468+       int ret; 
    534 +       struct task_struct *task; 
    535469+ 
    536470+       dev_dbg(dev, "sdio_ar6000_probe\n"); 
     
    549483+       if (ret < 0) { 
    550484+               dev_err(dev, "sdio_set_block_size returns %d\n", ret); 
    551 +               /* @@@ cleanup */ 
     485+               goto out_enabled; 
    552486+       } 
    553487+       ret = sdio_claim_irq(func, sdio_ar6000_irq); 
    554488+       if (ret) { 
    555489+               dev_err(dev, "sdio_claim_irq returns %d\n", ret); 
    556 +               /* @@@ cleanup */ 
     490+               goto out_enabled; 
    557491+       } 
    558492+       /* Set SDIO_BUS_CD_DISABLE in SDIO_CCCR_IF ? */ 
     
    562496+               dev_err(dev, "sdio_f0_writeb(SDIO_CCCR_CAPS) returns %d\n", 
    563497+                   ret); 
    564 +               /* @@@ cleanup */ 
     498+               goto out_got_irq; 
    565499+       } 
    566500+#endif 
    567 +#if 0 
    568 +       /* 
    569 +        * @@@ Samuel's driver sets this, Atheros' Linux SDIO HIF apparently 
    570 +        * doesn't, and things seem to work okay without it here as well. 
    571 +        * Check with Atheros. 
    572 +        */ 
    573 +       sdio_f0_writeb(func, SDIO_POWER_EMPC, SDIO_CCCR_POWER, &ret); 
    574 +       if (ret) { 
    575 +               dev_err(dev, "sdio_f0_writeb(SDIO_CCCR_POWER) returns %d\n", 
    576 +                   ret); 
    577 +               /* @@@ cleanup */ 
    578 +       } 
    579 +#endif 
     501+ 
    580502+       sdio_release_host(func); 
    581503+ 
     
    583505+       if (IS_ERR(hif_device.io_task)) { 
    584506+               dev_err(dev, "kthread_run(ar6000_io): %d\n", ret); 
    585 +               /* @@@ cleanup */ 
    586 +       } 
    587 +       task = kthread_run(inserter, NULL, "ar6000_inserter"); 
    588 +       if (IS_ERR(task)) { 
    589 +               dev_err(dev, "kthread_run (ar6000_inserter): %d\n", ret); 
    590 +               /* @@@ cleanup */ 
    591 +       } 
    592 + 
    593 +       return 0; 
     507+               goto out_func_ready; 
     508+       } 
     509+ 
     510+       ret = htcCallbacks.deviceInsertedHandler(&hif_device); 
     511+       if (ret == A_OK) 
     512+               return 0; 
     513+ 
     514+       dev_err(dev, "deviceInsertedHandler: %d\n", ret); 
     515+ 
     516+       ret = kthread_stop(hif_device.io_task); 
     517+       if (ret) 
     518+               dev_err(dev, "kthread_stop (ar6000_io): %d\n", ret); 
     519+ 
     520+out_func_ready: 
     521+       sdio_claim_host(func); 
     522+ 
     523+/* generates a warning */ 
     524+out_got_irq: 
     525+       sdio_release_irq(func); 
     526+ 
     527+out_enabled: 
     528+       sdio_set_drvdata(func, NULL); 
     529+       sdio_disable_func(func); 
     530+       sdio_release_host(func); 
     531+ 
     532+       return ret; 
    594533+} 
    595534+ 
     
    597536+static void sdio_ar6000_remove(struct sdio_func *func) 
    598537+{ 
     538+       struct device *dev = &func->dev; 
     539+       int ret; 
     540+ 
     541+       ret = kthread_stop(hif_device.io_task); 
     542+       if (ret) 
     543+               dev_err(dev, "kthread_stop (ar6000_io): %d\n", ret); 
    599544+       sdio_claim_host(func); 
    600545+       sdio_release_irq(func); 
     
    602547+       sdio_release_host(func); 
    603548+       /* @@@ remove */ 
    604 +       /* @@@ kill _tasks */ 
    605549+} 
    606550+ 
     
    652596+ 
    653597+MODULE_AUTHOR("Werner Almesberger"); 
    654 +MODULE_LICENSE("GPL"); 
     598+MODULE_LICENSE("GPL v2"); 
Note: See TracChangeset for help on using the changeset viewer.