From patchwork Sat Dec 13 19:15:17 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: roel kluin X-Patchwork-Id: 13831 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id F1418475F6 for ; Sun, 14 Dec 2008 06:16:09 +1100 (EST) X-Original-To: linuxppc-dev@ozlabs.org Delivered-To: linuxppc-dev@ozlabs.org Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.168]) by ozlabs.org (Postfix) with ESMTP id B4748DDFB5 for ; Sun, 14 Dec 2008 06:15:17 +1100 (EST) Received: by ug-out-1314.google.com with SMTP id 17so50375ugm.14 for ; Sat, 13 Dec 2008 11:15:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:cc:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=7GBaQfIJmMZ3veVnHHrKNlmvWUugjAf82D+Vid2iS0Y=; b=V+68gJuHmCzgVSKfU1ts+ilqcnVLle7RHVJ9wFetu5Z/Atjom3tirk9YB6q4DeuqZb 3Weci55cJE3bWxsSXQIbpjIUhSWPo92aRcsCEaCerKsIgN7qu2zHUSGXctCG6myj4L5U aHv6zzXPgizafqo5Ju1je1fyE6F7S7UZzWN1k= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; b=cKkC+H2mlpubFXun69FMeOdrswbcAiax+43g3A52g6Yf6cX43WR+/GHb7iJYkwaF2n TrJOOPB8ObPlOIFrtFhu6WcSJgSNfwVtackYPrdaiEI9hM6P40xobT/gV81YOrvJJ19v KtKbGJUP9JkAhpBGJAYDyue9ReUMUhDT/xXXQ= Received: by 10.67.115.8 with SMTP id s8mr713797ugm.50.1229195715204; Sat, 13 Dec 2008 11:15:15 -0800 (PST) Received: from ?192.168.1.148? (d133062.upc-d.chello.nl [213.46.133.62]) by mx.google.com with ESMTPS id k1sm1395894ugf.3.2008.12.13.11.15.14 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 13 Dec 2008 11:15:14 -0800 (PST) Message-ID: <494409C5.1050308@gmail.com> Date: Sat, 13 Dec 2008 20:15:17 +0100 From: Roel Kluin User-Agent: Thunderbird 2.0.0.18 (X11/20081105) MIME-Version: 1.0 To: Olof Johansson Subject: Re: [PATCH] [POWERPC] pasemi: ioremap/iounmap balance and failure handling References: <4943E6B5.6010501@gmail.com> In-Reply-To: <4943E6B5.6010501@gmail.com> Cc: linuxppc-dev@ozlabs.org X-BeenThere: linuxppc-dev@ozlabs.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org Roel Kluin wrote: > map_onedev can return NULL, so catch that. Also iounmap if DMA controller can't be > found. I think there may also be a problem with pasemi_mac_init_module(): if pci_register_driver() fails, then iob_regs won't get iounmapped. maybe something like the totally untested patch below? diff --git a/arch/powerpc/include/asm/pasemi_dma.h b/arch/powerpc/include/asm/pasemi_dma.h index 19fd793..7256a2c 100644 --- a/arch/powerpc/include/asm/pasemi_dma.h +++ b/arch/powerpc/include/asm/pasemi_dma.h @@ -535,4 +535,7 @@ extern void pasemi_dma_free_fun(int fun); /* Initialize the library, must be called before any other functions */ extern int pasemi_dma_init(void); +/* Clean up the library */ +extern void pasemi_dma_exit(void); + #endif /* ASM_PASEMI_DMA_H */ diff --git a/arch/powerpc/platforms/pasemi/dma_lib.c b/arch/powerpc/platforms/pasemi/dma_lib.c index 217af32..fc0e1f9 100644 --- a/arch/powerpc/platforms/pasemi/dma_lib.c +++ b/arch/powerpc/platforms/pasemi/dma_lib.c @@ -534,14 +534,21 @@ int pasemi_dma_init(void) err = -ENODEV; goto out; } + iob_regs = map_onedev(iob_pdev, 0); + if (iob_regs == NULL) { + BUG(); + printk(KERN_WARNING "Can't ioremap I/O Bridge registers\n"); + err = -ENODEV; + goto out; + } dma_pdev = pci_get_device(PCI_VENDOR_ID_PASEMI, 0xa007, NULL); if (!dma_pdev) { BUG(); printk(KERN_WARNING "Can't find DMA controller\n"); err = -ENODEV; - goto out; + goto out_unmap; } dma_regs = map_onedev(dma_pdev, 0); base_hw_irq = virq_to_hw(dma_pdev->irq); @@ -624,9 +631,19 @@ int pasemi_dma_init(void) printk(KERN_INFO "PA Semi PWRficient DMA library initialized " "(%d tx, %d rx channels)\n", num_txch, num_rxch); + goto out; + +out_unmap: + iounmap(iob_regs); out: spin_unlock(&init_lock); return err; } EXPORT_SYMBOL(pasemi_dma_init); + +void pasemi_dma_exit(void) +{ + iounmap(iob_regs); +} + diff --git a/drivers/net/pasemi_mac.c b/drivers/net/pasemi_mac.c index edc0fd5..0897fa0 100644 --- a/drivers/net/pasemi_mac.c +++ b/drivers/net/pasemi_mac.c @@ -1919,7 +1919,11 @@ int pasemi_mac_init_module(void) if (err) return err; - return pci_register_driver(&pasemi_mac_driver); + err = pci_register_driver(&pasemi_mac_driver); + if (err) + pasemi_dma_exit(); + + return err; } module_init(pasemi_mac_init_module);