ChangeSet 1.1982.80.37, 2005/02/24 10:47:48-05:00, [EMAIL PROTECTED]

        ohci1394.c allocates the legacy IR DMA Context on demand. This happens 
in IRQ
        path resulting in call to dma_pool_create from within interrupt. Same 
is true
        for de-allocation of the IR DMA Context - it happens again in IRQ path
        resulting in call to dma_pool_destroy.
        
        After attempting to fix the above by using schedule_work for delayed
        allocation and de-allocation, it was determined that it should be fixed
        simply by moving the allocation to the drivers probe() function and
        de-allocation to remove() function. This way it reduces the complexity 
and
        does not result into any significant wastage of resources.
        
        This patch also fixes duplicate pci pool names and removes spaces from 
the
        names to make it easier for parsing by scripts.
        
        Thanks go to Dave Brownell for greatly simplifying this.
        
        Signed-off-by: Parag Warudkar <[EMAIL PROTECTED]>
        Signed-off-by: Jody McIntyre <[EMAIL PROTECTED]>



 ohci1394.c |   80 ++++++++++++++++++++++++++++++++++++++-----------------------
 1 files changed, 50 insertions(+), 30 deletions(-)


diff -Nru a/drivers/ieee1394/ohci1394.c b/drivers/ieee1394/ohci1394.c
--- a/drivers/ieee1394/ohci1394.c       2005-03-28 23:08:35 -08:00
+++ b/drivers/ieee1394/ohci1394.c       2005-03-28 23:08:35 -08:00
@@ -538,6 +538,11 @@
        /* Initialize AT dma */
        initialize_dma_trm_ctx(&ohci->at_req_context);
        initialize_dma_trm_ctx(&ohci->at_resp_context);
+       
+       /* Initialize IR Legacy DMA */
+       ohci->ir_legacy_channels = 0;
+       initialize_dma_rcv_ctx(&ohci->ir_legacy_context, 1);
+       DBGMSG("ISO receive legacy context activated");
 
        /*
         * Accept AT requests from all nodes. This probably
@@ -1035,22 +1040,6 @@
                        return -EFAULT;
                }
 
-               /* activate the legacy IR context */
-               if (ohci->ir_legacy_context.ohci == NULL) {
-                       if (alloc_dma_rcv_ctx(ohci, &ohci->ir_legacy_context,
-                                             DMA_CTX_ISO, 0, IR_NUM_DESC,
-                                             IR_BUF_SIZE, IR_SPLIT_BUF_SIZE,
-                                             OHCI1394_IsoRcvContextBase) < 0) {
-                               PRINT(KERN_ERR, "%s: failed to allocate an IR 
context",
-                                     __FUNCTION__);
-                               return -ENOMEM;
-                       }
-                       ohci->ir_legacy_channels = 0;
-                       initialize_dma_rcv_ctx(&ohci->ir_legacy_context, 1);
-
-                       DBGMSG("ISO receive legacy context activated");
-               }
-
                mask = (u64)0x1<<arg;
 
                 spin_lock_irqsave(&ohci->IR_channel_lock, flags);
@@ -1112,12 +1101,6 @@
 
                 spin_unlock_irqrestore(&ohci->IR_channel_lock, flags);
                 DBGMSG("Listening disabled on channel %d", arg);
-
-               if (ohci->ir_legacy_channels == 0) {
-                       stop_dma_rcv_ctx(&ohci->ir_legacy_context);
-                       free_dma_rcv_ctx(&ohci->ir_legacy_context);
-                       DBGMSG("ISO receive legacy context deactivated");
-               }
                 break;
         }
        default:
@@ -2921,7 +2904,9 @@
                  enum context_type type, int ctx, int num_desc,
                  int buf_size, int split_buf_size, int context_base)
 {
-       int i;
+       int i, len;
+       static int num_allocs;
+       static char pool_name[20];
 
        d->ohci = ohci;
        d->type = type;
@@ -2965,9 +2950,19 @@
                free_dma_rcv_ctx(d);
                return -ENOMEM;
        }
-
-       d->prg_pool = pci_pool_create("ohci1394 rcv prg", ohci->dev,
+       
+       len = sprintf(pool_name, "ohci1394_rcv_prg");
+       sprintf(pool_name+len, "%d", num_allocs);
+       d->prg_pool = pci_pool_create(pool_name, ohci->dev,
                                sizeof(struct dma_cmd), 4, 0);
+       if(d->prg_pool == NULL)
+       {
+               PRINT(KERN_ERR, "pci_pool_create failed for %s", pool_name);
+               free_dma_rcv_ctx(d);
+               return -ENOMEM;
+       }
+       num_allocs++;
+
        OHCI_DMA_ALLOC("dma_rcv prg pool");
 
        for (i=0; i<d->num_desc; i++) {
@@ -3060,7 +3055,9 @@
                  enum context_type type, int ctx, int num_desc,
                  int context_base)
 {
-       int i;
+       int i, len;
+       static char pool_name[20];
+       static int num_allocs=0;
 
        d->ohci = ohci;
        d->type = type;
@@ -3082,8 +3079,17 @@
        memset(d->prg_cpu, 0, d->num_desc * sizeof(struct at_dma_prg*));
        memset(d->prg_bus, 0, d->num_desc * sizeof(dma_addr_t));
 
-       d->prg_pool = pci_pool_create("ohci1394 trm prg", ohci->dev,
+       len = sprintf(pool_name, "ohci1394_trm_prg");
+       sprintf(pool_name+len, "%d", num_allocs);
+       d->prg_pool = pci_pool_create(pool_name, ohci->dev,
                                sizeof(struct at_dma_prg), 4, 0);
+       if (d->prg_pool == NULL) {
+               PRINT(KERN_ERR, "pci_pool_create failed for %s", pool_name);
+               free_dma_trm_ctx(d);
+               return -ENOMEM;
+       }
+       num_allocs++;
+
        OHCI_DMA_ALLOC("dma_rcv prg pool");
 
        for (i = 0; i < d->num_desc; i++) {
@@ -3355,10 +3361,19 @@
        ohci->ISO_channel_usage = 0;
         spin_lock_init(&ohci->IR_channel_lock);
 
-       /* the IR DMA context is allocated on-demand; mark it inactive */
-       ohci->ir_legacy_context.ohci = NULL;
+       /* Allocate the IR DMA context right here so we don't have
+        * to do it in interrupt path - note that this doesn't
+        * waste much memory and avoids the jugglery required to
+        * allocate it in IRQ path. */
+       if (alloc_dma_rcv_ctx(ohci, &ohci->ir_legacy_context,
+                             DMA_CTX_ISO, 0, IR_NUM_DESC,
+                             IR_BUF_SIZE, IR_SPLIT_BUF_SIZE,
+                             OHCI1394_IsoRcvContextBase) < 0) {
+               FAIL(-ENOMEM, "Cannot allocate IR Legacy DMA context");
+       }
 
-       /* same for the IT DMA context */
+       /* We hopefully don't have to pre-allocate IT DMA like we did
+        * for IR DMA above. Allocate it on-demand and mark inactive. */
        ohci->it_legacy_context.ohci = NULL;
 
        if (request_irq(dev->irq, ohci_irq_handler, SA_SHIRQ,
@@ -3398,6 +3413,7 @@
 
        switch (ohci->init_state) {
        case OHCI_INIT_DONE:
+               stop_dma_rcv_ctx(&ohci->ir_legacy_context);
                hpsb_remove_host(ohci->host);
 
                /* Clear out BUS Options */
@@ -3446,6 +3462,10 @@
 
                /* Free IT dma */
                free_dma_trm_ctx(&ohci->it_legacy_context);
+
+               /* Free IR legacy dma */
+               free_dma_rcv_ctx(&ohci->ir_legacy_context);
+
 
        case OHCI_INIT_HAVE_SELFID_BUFFER:
                pci_free_consistent(ohci->dev, OHCI1394_SI_DMA_BUF_SIZE,
-
To unsubscribe from this list: send the line "unsubscribe bk-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to