All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: dave@thedillows.org
Cc: ben@decadent.org.uk, netdev@vger.kernel.org
Subject: Re: [PATCH v2] typhoon: Use request_firmware()
Date: Sun, 01 Mar 2009 20:29:29 -0800 (PST)	[thread overview]
Message-ID: <20090301.202929.81587113.davem@davemloft.net> (raw)
In-Reply-To: <20090301.201123.112634333.davem@davemloft.net>

From: David Miller <davem@davemloft.net>
Date: Sun, 01 Mar 2009 20:11:23 -0800 (PST)

> Give me a fix so I don't have to revert.

Nevermind, I checked in a fix myself.

I cared enough to fix this, maybe one of you will care enough
to test it.

typhoon: Need non-vmalloc memory to DMA firmware to the card.

request_firmware() gives vmalloc'd memory, which is not suitable
for pci_map_single() and friends.

Use a kmalloc()'d copy of the firmware for this DMA operation.

Signed-off-by: David S. Miller <davem@davemloft.net>
---
 drivers/net/typhoon.c |   27 ++++++++++++++++++++-------
 1 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/drivers/net/typhoon.c b/drivers/net/typhoon.c
index cd3283f..ec2541c 100644
--- a/drivers/net/typhoon.c
+++ b/drivers/net/typhoon.c
@@ -1347,6 +1347,7 @@ typhoon_init_rings(struct typhoon *tp)
 }
 
 static const struct firmware *typhoon_fw;
+static u8 *typhoon_fw_image;
 
 static int
 typhoon_request_firmware(struct typhoon *tp)
@@ -1367,12 +1368,22 @@ typhoon_request_firmware(struct typhoon *tp)
 	    memcmp(typhoon_fw->data, "TYPHOON", 8)) {
 		printk(KERN_ERR "%s: Invalid firmware image\n",
 		       tp->name);
-		release_firmware(typhoon_fw);
-		typhoon_fw = NULL;
-		return -EINVAL;
+		err = -EINVAL;
+		goto out_err;
+	}
+
+	typhoon_fw_image = kmalloc(typhoon_fw->size, GFP_KERNEL);
+	if (!typhoon_fw_image) {
+		err = -ENOMEM;
+		goto out_err;
 	}
 
 	return 0;
+
+out_err:
+	release_firmware(typhoon_fw);
+	typhoon_fw = NULL;
+	return err;
 }
 
 static int
@@ -1394,11 +1405,11 @@ typhoon_download_firmware(struct typhoon *tp)
 	int i;
 	int err;
 
-	image_data = typhoon_fw->data;
+	image_data = typhoon_fw_image;
 	fHdr = (struct typhoon_file_header *) image_data;
 
 	err = -ENOMEM;
-	image_dma = pci_map_single(pdev, (u8 *) typhoon_fw->data,
+	image_dma = pci_map_single(pdev, (u8 *) image_data,
 				   typhoon_fw->size, PCI_DMA_TODEVICE);
 	if (pci_dma_mapping_error(pdev, image_dma)) {
 		printk(KERN_ERR "%s: no DMA mem for firmware\n", tp->name);
@@ -1469,7 +1480,7 @@ typhoon_download_firmware(struct typhoon *tp)
 		iowrite32(load_addr,
 			  ioaddr + TYPHOON_REG_BOOT_DEST_ADDR);
 		iowrite32(0, ioaddr + TYPHOON_REG_BOOT_DATA_HI);
-		iowrite32(image_dma + (image_data - typhoon_fw->data),
+		iowrite32(image_dma + (image_data - typhoon_fw_image),
 			  ioaddr + TYPHOON_REG_BOOT_DATA_LO);
 		typhoon_post_pci_writes(ioaddr);
 		iowrite32(TYPHOON_BOOTCMD_SEG_AVAILABLE,
@@ -2639,8 +2650,10 @@ typhoon_init(void)
 static void __exit
 typhoon_cleanup(void)
 {
-	if (typhoon_fw)
+	if (typhoon_fw) {
+		kfree(typhoon_fw_image);
 		release_firmware(typhoon_fw);
+	}
 	pci_unregister_driver(&typhoon_driver);
 }
 
-- 
1.6.1.2.253.ga34a


  reply	other threads:[~2009-03-02  4:29 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1235324217.2832.49.camel@hashbaz.i.decadent.org.uk>
2009-02-26 13:49 ` [PATCH v2] typhoon: Use request_firmware() Ben Hutchings
2009-02-27  7:21   ` David Miller
2009-03-01 20:38   ` David Dillow
2009-03-02  1:02     ` Ben Hutchings
2009-03-02  1:44       ` David Miller
2009-03-02  3:16         ` David Dillow
2009-03-02  4:11           ` David Miller
2009-03-02  4:29             ` David Miller [this message]
2009-03-02  7:56               ` David Dillow
2009-03-02  9:53                 ` David Miller
2009-03-03  5:44                   ` David Dillow
2009-03-03  5:49                     ` [PATCH v3 checked] " David Dillow
2009-03-03  6:15                       ` David Miller
     [not found] ` <1235622381.8683.38.camel@hashbaz.i.decadent.org.uk>
2009-02-27  7:21   ` [PATCH v2] " David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090301.202929.81587113.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=ben@decadent.org.uk \
    --cc=dave@thedillows.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.