All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pantelis Antoniou <panto@intracom.gr>
To: Matt Porter <mporter@kernel.crashing.org>
Cc: Tom Rini <trini@kernel.crashing.org>,
	linuxppc-embedded <linuxppc-embedded@ozlabs.org>
Subject: Re: [PATCH  03/04] Freescale Ethernet combined driver
Date: Thu, 12 May 2005 12:37:13 +0300	[thread overview]
Message-ID: <428323C9.8070608@intracom.gr> (raw)
In-Reply-To: <20050510064702.B21835@cox.net>

[-- Attachment #1: Type: text/plain, Size: 1767 bytes --]

Matt Porter wrote:
> On Tue, May 10, 2005 at 04:14:51PM +0300, Pantelis Antoniou wrote:
> 
>>Matt Porter wrote:
>>
>>>On Tue, May 10, 2005 at 08:13:48AM -0400, Dan Malek wrote:
>>>
>>>
>>>>On May 10, 2005, at 7:17 AM, Pantelis Antoniou wrote:
>>>>
>>>>
>>>>
>>>>>This patch replace iopa use with virt_to_phys.
>>>>
>>>>Not gonna work .....
>>>>
>>>>When you map uncached on 8xx you get a new vmalloc()
>>>>space.  The virt_to_xxx macros don't work on those addresses.
>>>>You need to use the dma_consistent() function, stash the
>>>>real physical address it returns and then use it where
>>>>appropriate.
>>>
>>>
>>>That and the use of virt_to_* and friends is deprecated by
>>>the DMA API. You'll never get that upstream even if it were
>>>a case where it did work.  That's a good thing to know for
>>>anybody doing other drivers...
>>>
>>>-Matt
>>>
>>>
>>
>>OK then.
>>
>>What's the recommended function to call to go from a
>>virtual -> physical address, but without doing a cache
>>flush/invalidate?
> 
> 
> There is no generic function to do that in a driver since
> no mainstream drivers in the kernel need to do it. Generally
> you can rework the driver such that you cache the DMA address
> as Dan suggested already.  I don't know your exact usage, however,
> you can allocate memory with dma_alloc_noncoherent() that is
> cached on ppc32 NOT_CACHE_COHERENT prcoessors and stash the
> dma_addr_t/void * for later use. The other way is to kmalloc and
> dma_map_single() (stashing the same way) which is basically the
> same thing.
> 
> Do you have a case where this doesn't work?
> 
> -Matt
> 
> 

Here is the final (I hope) fix.

This patch kills iopa/virt_to_phys usage by using the returned
physical address from the DMA API.

Comments?

Regards

Pantelis


[-- Attachment #2: fs_enet-iopa-kill.patch --]
[-- Type: text/x-patch, Size: 2328 bytes --]

Index: linux-2.6.11.7-fs_enet/drivers/net/fs_enet/mac-fcc.c
===================================================================
--- linux-2.6.11.7-fs_enet.orig/drivers/net/fs_enet/mac-fcc.c
+++ linux-2.6.11.7-fs_enet/drivers/net/fs_enet/mac-fcc.c
@@ -212,8 +212,10 @@ static void restart(struct net_device *d
 {
 	cpm2_map_t *immap = (cpm2_map_t *)CPM_MAP_ADDR;
 	struct fs_enet_private *fep = netdev_priv(dev);
+	const struct fs_platform_info *fpi = fep->fpi;
 	fcc_t *fccp = fep->fcc.fccp;
 	fcc_enet_t *ep = fep->fcc.ep;
+	dma_addr_t rx_bd_base_phys, tx_bd_base_phys;
 	__u16 paddrh, paddrm, paddrl;
 	__u16 mem_addr;
 	const unsigned char *mac;
@@ -225,9 +227,13 @@ static void restart(struct net_device *d
 	for (i = 0; i < sizeof(*ep); i++)
 		__fcc_out8((char *)ep + i, 0);
 
+	/* get physical address */
+	rx_bd_base_phys = fep->ring_mem_addr;
+	tx_bd_base_phys = rx_bd_base_phys + sizeof(cbd_t) * fpi->rx_ring;
+
 	/* point to bds */
-	W32(ep, fen_genfcc.fcc_rbase, iopa((__u32)fep->rx_bd_base));
-	W32(ep, fen_genfcc.fcc_tbase, iopa((__u32)fep->tx_bd_base));
+	W32(ep, fen_genfcc.fcc_rbase, rx_bd_base_phys);
+	W32(ep, fen_genfcc.fcc_tbase, tx_bd_base_phys);
 
 	/* Set maximum bytes per receive buffer.
 	 * It must be a multiple of 32.
Index: linux-2.6.11.7-fs_enet/drivers/net/fs_enet/mac-fec.c
===================================================================
--- linux-2.6.11.7-fs_enet.orig/drivers/net/fs_enet/mac-fec.c
+++ linux-2.6.11.7-fs_enet/drivers/net/fs_enet/mac-fec.c
@@ -271,6 +271,7 @@ static void restart(struct net_device *d
 	struct fs_enet_private *fep = netdev_priv(dev);
 	fec_t *fecp = fep->fec.fecp;
 	const struct fs_platform_info *fpi = fep->fpi;
+	dma_addr_t rx_bd_base_phys, tx_bd_base_phys;
 	int r;
 	__u32 addrhi, addrlo;
 
@@ -303,11 +304,15 @@ static void restart(struct net_device *d
 	FW(fecp, r_buff_size, PKT_MAXBLR_SIZE);
 	FW(fecp, r_hash, PKT_MAXBUF_SIZE);
 
+	/* get physical address */
+	rx_bd_base_phys = fep->ring_mem_addr;
+	tx_bd_base_phys = rx_bd_base_phys + sizeof(cbd_t) * fpi->rx_ring;
+
 	/*
 	 * Set receive and transmit descriptor base. 
 	 */
-	FW(fecp, r_des_start, iopa((__u32)fep->rx_bd_base));
-	FW(fecp, x_des_start, iopa((__u32)fep->tx_bd_base));
+	FW(fecp, r_des_start, rx_bd_base_phys);
+	FW(fecp, x_des_start, tx_bd_base_phys);
 
 	fs_init_bds(dev);
 

  parent reply	other threads:[~2005-05-12  9:53 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-09 11:45 [PATCH 03/04] Freescale Ethernet combined driver Pantelis Antoniou
2005-05-09 20:38 ` Matt Porter
2005-05-10 11:17   ` Pantelis Antoniou
2005-05-10 12:13     ` Dan Malek
2005-05-10 12:15       ` Pantelis Antoniou
2005-05-10 13:27       ` Matt Porter
2005-05-10 13:14         ` Pantelis Antoniou
2005-05-10 13:47           ` Matt Porter
2005-05-10 13:36             ` Pantelis Antoniou
2005-05-12  9:37             ` Pantelis Antoniou [this message]
2005-05-13  8:51               ` Pantelis Antoniou
2005-05-10 18:14           ` Dan Malek
  -- strict thread matches above, loose matches on Subject: below --
2005-05-10 14:53 Rune Torgersen
2005-05-10 18:24 ` Dan Malek

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=428323C9.8070608@intracom.gr \
    --to=panto@intracom.gr \
    --cc=linuxppc-embedded@ozlabs.org \
    --cc=mporter@kernel.crashing.org \
    --cc=trini@kernel.crashing.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.