* Re: [PATCH] net/core: Fix seeking in /proc/net/dev
From: Eric Dumazet @ 2012-04-06 17:43 UTC (permalink / raw)
To: David Miller; +Cc: john, netdev, linux-kernel, mihai.maruseac
In-Reply-To: <20120406.131800.651812823796333479.davem@davemloft.net>
On Fri, 2012-04-06 at 13:18 -0400, David Miller wrote:
> Eric Dumazet already fixed this the other day.
> --
John, take a look at
http://git.kernel.org/?p=linux/kernel/git/davem/net.git;a=commit;h=2def16ae6b0c77571200f18ba4be049b03d75579
Thanks
^ permalink raw reply
* Re: [PATCH] net/core: Fix seeking in /proc/net/dev
From: Eric Dumazet @ 2012-04-06 17:41 UTC (permalink / raw)
To: Mihai Maruseac
Cc: John Keeping, netdev, linux-kernel, Mihai Maruseac, Daniel Baluta
In-Reply-To: <CAOMsUMLDFpYw9REPjZd2m49xV4UKFjFobNorGmOPCFeqjV-RDg@mail.gmail.com>
On Fri, 2012-04-06 at 20:14 +0300, Mihai Maruseac wrote:
> On Fri, Apr 6, 2012 at 8:05 PM, John Keeping <john@keeping.me.uk> wrote:
> > Commit f04565ddf52e4 (dev: use name hash for dev_seq_ops) introduced
> > code that fails to check the requested position when getting an item for
> > /proc/net/dev. This means that any code which seeks within this file is
> > likely to receive corrupted data.
> >
> > A test case for this is to use the read builtin in bash:
> >
...
> Looks good to me. However, Eric just submitted a patch here with other
> changes caused by a logic error in the original patch.
Hmm, I think my patch fixed this lseek issue as well.
^ permalink raw reply
* [PATCH net-next V2] tcp: Fix bug when gap in rcv sequence is filled
From: Vijay Subramanian @ 2012-04-06 17:36 UTC (permalink / raw)
To: netdev; +Cc: davem, ncardwell, ilpo.jarvinen, loke.chetan, Vijay Subramanian
As per RFC2581 and the newer RFC5681, "the receiver SHOULD send an immediate ACK
when it receives a data segment that fills in all or part of a gap in the
sequence space." When TCP receiver gets the next in-sequence packet, we move
data from ofo queue to receive queue. At this point, we should send an immediate
ack by entering quickack mode. In the current code, instead of entering
quickack mode upon requeing packets from ofo queue to receive_queue, we enter
quickack mode only when ofo queue becomes empty after requeuing. This ignores
the possibility that there may be further packets left in ofo queue. This patch
fixes this behavior and enters quickack mode whenever packets are moved from ofo
queue to receive queue.
Also, comment has been updated to reflect that RFC5681 obsoletes RFC2581.
Signed-off-by: Vijay Subramanian <subramanian.vijay@gmail.com>
---
Changes from V1:
-- Removed bool variable to simplify code. (chetan loke <loke.chetan@gmail.com>)
net/ipv4/tcp_input.c | 13 ++++++++-----
1 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index e886e2f..f4561f9 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -4388,12 +4388,14 @@ static void tcp_sack_remove(struct tcp_sock *tp)
/* This one checks to see if we can put data from the
* out_of_order queue into the receive_queue.
+ * Return 1 if data is moved from ofo queue to receive_queue and 0 otherwise.
*/
-static void tcp_ofo_queue(struct sock *sk)
+static int tcp_ofo_queue(struct sock *sk)
{
struct tcp_sock *tp = tcp_sk(sk);
__u32 dsack_high = tp->rcv_nxt;
struct sk_buff *skb;
+ int requeued = 0; /*1 if an skb is requeued to receive_queue*/
while ((skb = skb_peek(&tp->out_of_order_queue)) != NULL) {
if (after(TCP_SKB_CB(skb)->seq, tp->rcv_nxt))
@@ -4418,10 +4420,12 @@ static void tcp_ofo_queue(struct sock *sk)
__skb_unlink(skb, &tp->out_of_order_queue);
__skb_queue_tail(&sk->sk_receive_queue, skb);
+ requeued = 1;
tp->rcv_nxt = TCP_SKB_CB(skb)->end_seq;
if (tcp_hdr(skb)->fin)
tcp_fin(sk);
}
+ return requeued;
}
static int tcp_prune_ofo_queue(struct sock *sk);
@@ -4636,12 +4640,11 @@ queue_and_out:
tcp_fin(sk);
if (!skb_queue_empty(&tp->out_of_order_queue)) {
- tcp_ofo_queue(sk);
- /* RFC2581. 4.2. SHOULD send immediate ACK, when
- * gap in queue is filled.
+ /* RFC5681 (which obsoletes RFC2581.) 4.2. SHOULD send
+ * immediate ACK, when gap in queue is filled.
*/
- if (skb_queue_empty(&tp->out_of_order_queue))
+ if (tcp_ofo_queue(sk))
inet_csk(sk)->icsk_ack.pingpong = 0;
}
--
1.7.0.4
^ permalink raw reply related
* [GIT] Networking
From: David Miller @ 2012-04-06 17:35 UTC (permalink / raw)
To: torvalds; +Cc: akpm, netdev, linux-kernel
1) Fix inaccuracies in network driver interface documentation, from
Ben Hutchings.
2) Fix handling of negative offsets in BPF JITs, from Jan Seiffert.
3) Compile warning, locking, and refcounting fixes in netfilter's
xt_CT, from Pablo Neira Ayuso.
4) phonet sendmsg needs to validate user length just like any
other datagram protocol, fix from Sasha Levin.
5) Ipv6 multicast code uses wrong loop index, from RongQing Li.
6) Link handling and firmware fixes in bnx2x driver from Yaniv
Rosner and Yuval Mintz.
7) mlx4 erroneously allocates 4 pages at a time, regardless of page
size, fix from Thadeu Lima de Souza Cascardo.
8) SCTP socket option wasn't extended in a backwards compatible
way, fix from Thomas Graf.
9) Add missing address change event emissions to bonding, from
Shlomo Pongratz.
10) /proc/net/dev regressed because it uses a private offset to
track where we are in the hash table, but this doesn't
track the offset pullback that the seq_file code does
resulting in some entries being missed in large dumps.
Fix from Eric Dumazet.
11) do_tcp_sendpage() unloads the send queue way too fast, because
it invokes tcp_push() when it shouldn't. Let the natural sequence
generated by the splice paths, and the assosciated MSG_MORE
settings, guide the tcp_push() calls.
Otherwise what goes out of TCP is spaghetti and doesn't batch
effectively into GSO/TSO clusters.
From Eric Dumazet.
12) Once we put a SKB into either the netlink receiver's queue
or a socket error queue, it can be consumed and freed up,
therefore we cannot touch it after queueing it like that.
Fixes from Eric Dumazet.
13) PPP has this annoying behavior in that for every transmit
call it immediately stops the TX queue, then calls down
into the next layer to transmit the PPP frame.
But if that next layer can take it immediately, it just
un-stops the TX queue right before returning from the
transmit method.
Besides being useless work, it makes several facilities
unusable, in particular things like the equalizers. Well
behaved devices should only stop the TX queue when they
really are full, and in PPP's case when it gets backlogged
to the downstream device.
David Woodhouse therefore fixed PPP to not stop the TX
queue until it's downstream can't take data any more.
14) IFF_UNICAST_FLT got accidently lost in some recent stmmac
driver changes, re-add. From Marc Kleine-Budde.
15) Fix link flaps in ixgbe, from Eric W. Multanen.
16) Descriptor writeback fixes in e1000e from Matthew Vick.
Please pull, thanks a lot!
The following changes since commit 314489bd4c7780fde6a069783d5128f6cef52919:
Merge tag 'fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc (2012-04-05 22:13:39 -0700)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git master
Artem Savkov (1):
r8169: enable napi on resume.
Ben Hutchings (6):
ethtool: Remove exception to the requirement of holding RTNL lock
doc, net: Remove obsolete reference to dev->poll
doc, net: Update documentation of synchronisation for TX multiqueue
doc, net: Update netdev operation names
doc, net: Remove instruction to set net_device::trans_start
doc, net: Update ndo_start_xmit return type and values
Bruce Allan (1):
e1000e: prevent oops when adapter is being closed and reset simultaneously
David S. Miller (2):
Merge branch 'master' of git://git.kernel.org/.../jkirsher/net
Merge branch 'master' of git://1984.lsi.us.es/net
David Woodhouse (1):
ppp: Don't stop and restart queue on every TX packet
Eric Dumazet (5):
net: fix /proc/net/dev regression
tcp: allow splice() to build full TSO packets
tcp: tcp_sendpages() should call tcp_push() once
netlink: fix races after skb queueing
net: fix a race in sock_queue_err_skb()
Fernando Luis Vazquez Cao (1):
TCP: update ip_local_port_range documentation
Jan Beulich (1):
netfilter: xt_LOG: don't use xchg() for simple assignment
Jan Engelhardt (1):
netfilter: ipset: avoid use of kernel-only types
Jan Seiffert (2):
bpf jit: Make the filter.c::__load_pointer helper non-static for the jits
bpf jit: Let the x86 jit handle negative offsets
Marc Kleine-Budde (1):
stmmac: re-add IFF_UNICAST_FLT for dwmac1000
Matthew Vick (1):
e1000e: Guarantee descriptor writeback flush success.
Multanen, Eric W (1):
ixgbe: driver fix for link flap
Pablo Neira Ayuso (4):
netfilter: xt_CT: remove a compile warning
netfilter: xt_CT: allocation has to be GFP_ATOMIC under rcu_read_lock section
netfilter: xt_CT: fix missing put timeout object in error path
netfilter: nf_conntrack: fix count leak in error path of __nf_conntrack_alloc
RongQing.Li (1):
ipv6: fix array index in ip6_mc_add_src()
Sasha Levin (1):
phonet: Check input from user before allocating
Shlomo Pongratz (2):
net/bonding: emit address change event also in bond_release
net/bonding: correctly proxy slave neigh param setup ndo function
Srinivas Kandagatla (1):
phy:icplus:fix Auto Power Saving in ip101a_config_init.
Thadeu Lima de Souza Cascardo (1):
mlx4: allocate just enough pages instead of always 4 pages
Thomas Graf (1):
sctp: Allow struct sctp_event_subscribe to grow without breaking binaries
Veaceslav Falico (1):
bonding: properly unset current_arp_slave on slave link up
Yaniv Rosner (10):
bnx2x: PFC fix
bnx2x: Fix BCM57810-KR FC
bnx2x: Fix BCM57810-KR AN speed transition
bnx2x: Fix BCM578x0-SFI pre-emphasis settings
bnx2x: Restore 1G LED on BCM57712+BCM8727 designs.
bnx2x: Fix link issue for BCM8727 boards.
bnx2x: Fix BCM84833 PHY FW version presentation
bnx2x: Clear BCM84833 LED after fan failure
bnx2x: Fix BCM57711+BCM84823 link issue
bnx2x: Clear MDC/MDIO warning message
Yuval Mintz (1):
bnx2x: correction to firmware interface
stephen hemminger (2):
sky2: copy received packets on inefficient unaligned architecture
MAINTAINERS: update for Marvell Ethernet drivers
Documentation/networking/driver.txt | 31 ++--
Documentation/networking/ip-sysctl.txt | 11 +-
Documentation/networking/netdevices.txt | 25 ++--
MAINTAINERS | 19 +--
arch/x86/net/bpf_jit.S | 122 +++++++++++----
arch/x86/net/bpf_jit_comp.c | 41 +++--
drivers/net/bonding/bond_main.c | 60 ++++++-
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 1 -
.../net/ethernet/broadcom/bnx2x/bnx2x_fw_defs.h | 110 +++++++-------
drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c | 147 +++++++++++++----
drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h | 8 +
drivers/net/ethernet/intel/e1000e/e1000.h | 6 +
drivers/net/ethernet/intel/e1000e/netdev.c | 26 +++
drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_nl.c | 164 ++++++++++----------
drivers/net/ethernet/marvell/sky2.c | 13 ++-
drivers/net/ethernet/mellanox/mlx4/mlx4_en.h | 5 +-
drivers/net/ethernet/realtek/r8169.c | 3 +
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 +-
drivers/net/phy/icplus.c | 3 +-
drivers/net/ppp/ppp_generic.c | 14 +-
fs/splice.c | 5 +-
include/linux/ethtool.h | 3 +-
include/linux/netdevice.h | 2 -
include/linux/netfilter/xt_set.h | 4 +-
include/linux/socket.h | 2 +-
include/net/netfilter/xt_log.h | 2 +-
net/core/dev.c | 58 ++------
net/core/dev_addr_lists.c | 3 +-
net/core/filter.c | 9 +-
net/core/skbuff.c | 4 +-
net/ipv4/tcp.c | 2 +-
net/ipv6/mcast.c | 2 +-
net/netfilter/nf_conntrack_core.c | 1 +
net/netfilter/xt_CT.c | 28 +++-
net/netlink/af_netlink.c | 24 ++--
net/phonet/pep.c | 3 +
net/sctp/socket.c | 5 +-
net/socket.c | 6 +-
38 files changed, 602 insertions(+), 376 deletions(-)
^ permalink raw reply
* Re: [PATCH] net/core: Fix seeking in /proc/net/dev
From: David Miller @ 2012-04-06 17:18 UTC (permalink / raw)
To: john; +Cc: netdev, linux-kernel, mihai.maruseac
In-Reply-To: <1333731944-15808-1-git-send-email-john@keeping.me.uk>
Eric Dumazet already fixed this the other day.
^ permalink raw reply
* Re: [PATCH net-next #2 00/39] net_device.{base_addr, irq} removal update
From: Grant Grundler @ 2012-04-06 17:17 UTC (permalink / raw)
To: David Miller
Cc: romieu, netdev, gallatin, andy, chris.snook, venza, DavidLv,
ionut, jcliburn, jdmason, mason, mchan, stas.yakovlev,
steve.glendinning, thockin
In-Reply-To: <20120406.062626.578458566949440559.davem@davemloft.net>
On Fri, Apr 6, 2012 at 3:26 AM, David Miller <davem@davemloft.net> wrote:
> From: Francois Romieu <romieu@fr.zoreil.com>
> Date: Fri, 6 Apr 2012 12:06:14 +0200
>
>> If there are no further changes, I'll rebase and send a single pull request
>> for the series including Grant's Acked-by once he says it is ok.
>
> Besides the request_irq() return value test issues, this series
> seems fine to me.
Ditto. I didn't see the request_irq() issue though. :( Oh well...this
is clearly an improvement.
thanks,
grant
^ permalink raw reply
* Re: [PATCH net-next #2 23/39] uli526x: fix regions leak in driver probe error path.
From: Grant Grundler @ 2012-04-06 17:15 UTC (permalink / raw)
To: Francois Romieu; +Cc: netdev, David Miller, Grant Grundler
In-Reply-To: <5a61e7c690fce53cd37eddc9808134bc0e6b9837.1333704409.git.romieu@fr.zoreil.com>
On Fri, Apr 6, 2012 at 3:06 AM, Francois Romieu <romieu@fr.zoreil.com> wrote:
> Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
> Cc: Grant Grundler <grundler@parisc-linux.org>
Ack-by: Grant Grundler <grundler@parisc-linux.org>
I'm assuming uli526x_remove_one() is called after uli526x_stop()
(which quiesces the HW). That appears to be the case for tulip_core.c
as well - so this should be ok.
thanks,
grant
> ---
> drivers/net/ethernet/dec/tulip/uli526x.c | 48 ++++++++++++-----------------
> 1 files changed, 20 insertions(+), 28 deletions(-)
>
> diff --git a/drivers/net/ethernet/dec/tulip/uli526x.c b/drivers/net/ethernet/dec/tulip/uli526x.c
> index fc4001f..c9b3396 100644
> --- a/drivers/net/ethernet/dec/tulip/uli526x.c
> +++ b/drivers/net/ethernet/dec/tulip/uli526x.c
> @@ -313,9 +313,9 @@ static int __devinit uli526x_init_one (struct pci_dev *pdev,
> goto err_out_disable;
> }
>
> - if (pci_request_regions(pdev, DRV_NAME)) {
> + err = pci_request_regions(pdev, DRV_NAME);
> + if (err < 0) {
> pr_err("Failed to request PCI regions\n");
> - err = -ENODEV;
> goto err_out_disable;
> }
>
> @@ -323,18 +323,15 @@ static int __devinit uli526x_init_one (struct pci_dev *pdev,
> db = netdev_priv(dev);
>
> /* Allocate Tx/Rx descriptor memory */
> + err = -ENOMEM;
> +
> db->desc_pool_ptr = pci_alloc_consistent(pdev, sizeof(struct tx_desc) * DESC_ALL_CNT + 0x20, &db->desc_pool_dma_ptr);
> - if(db->desc_pool_ptr == NULL)
> - {
> - err = -ENOMEM;
> - goto err_out_nomem;
> - }
> + if (!db->desc_pool_ptr)
> + goto err_out_release;
> +
> db->buf_pool_ptr = pci_alloc_consistent(pdev, TX_BUF_ALLOC * TX_DESC_CNT + 4, &db->buf_pool_dma_ptr);
> - if(db->buf_pool_ptr == NULL)
> - {
> - err = -ENOMEM;
> - goto err_out_nomem;
> - }
> + if (!db->buf_pool_ptr)
> + goto err_out_free_tx_desc;
>
> db->first_tx_desc = (struct tx_desc *) db->desc_pool_ptr;
> db->first_tx_desc_dma = db->desc_pool_dma_ptr;
> @@ -387,7 +384,7 @@ static int __devinit uli526x_init_one (struct pci_dev *pdev,
> }
> err = register_netdev (dev);
> if (err)
> - goto err_out_res;
> + goto err_out_free_tx_buf;
>
> netdev_info(dev, "ULi M%04lx at pci%s, %pM, irq %d\n",
> ent->driver_data >> 16, pci_name(pdev),
> @@ -397,16 +394,14 @@ static int __devinit uli526x_init_one (struct pci_dev *pdev,
>
> return 0;
>
> -err_out_res:
> +err_out_free_tx_buf:
> + pci_free_consistent(pdev, TX_BUF_ALLOC * TX_DESC_CNT + 4,
> + db->buf_pool_ptr, db->buf_pool_dma_ptr);
> +err_out_free_tx_desc:
> + pci_free_consistent(pdev, sizeof(struct tx_desc) * DESC_ALL_CNT + 0x20,
> + db->desc_pool_ptr, db->desc_pool_dma_ptr);
> +err_out_release:
> pci_release_regions(pdev);
> -err_out_nomem:
> - if(db->desc_pool_ptr)
> - pci_free_consistent(pdev, sizeof(struct tx_desc) * DESC_ALL_CNT + 0x20,
> - db->desc_pool_ptr, db->desc_pool_dma_ptr);
> -
> - if(db->buf_pool_ptr != NULL)
> - pci_free_consistent(pdev, TX_BUF_ALLOC * TX_DESC_CNT + 4,
> - db->buf_pool_ptr, db->buf_pool_dma_ptr);
> err_out_disable:
> pci_disable_device(pdev);
> err_out_free:
> @@ -422,19 +417,16 @@ static void __devexit uli526x_remove_one (struct pci_dev *pdev)
> struct net_device *dev = pci_get_drvdata(pdev);
> struct uli526x_board_info *db = netdev_priv(dev);
>
> - ULI526X_DBUG(0, "uli526x_remove_one()", 0);
> -
> + unregister_netdev(dev);
> pci_free_consistent(db->pdev, sizeof(struct tx_desc) *
> DESC_ALL_CNT + 0x20, db->desc_pool_ptr,
> db->desc_pool_dma_ptr);
> pci_free_consistent(db->pdev, TX_BUF_ALLOC * TX_DESC_CNT + 4,
> db->buf_pool_ptr, db->buf_pool_dma_ptr);
> - unregister_netdev(dev);
> pci_release_regions(pdev);
> - free_netdev(dev); /* free board information */
> - pci_set_drvdata(pdev, NULL);
> pci_disable_device(pdev);
> - ULI526X_DBUG(0, "uli526x_remove_one() exit", 0);
> + pci_set_drvdata(pdev, NULL);
> + free_netdev(dev);
> }
>
>
> --
> 1.7.7.6
>
^ permalink raw reply
* Re: [PATCH] net/core: Fix seeking in /proc/net/dev
From: Mihai Maruseac @ 2012-04-06 17:14 UTC (permalink / raw)
To: John Keeping; +Cc: netdev, linux-kernel, Mihai Maruseac, Daniel Baluta
In-Reply-To: <1333731944-15808-1-git-send-email-john@keeping.me.uk>
On Fri, Apr 6, 2012 at 8:05 PM, John Keeping <john@keeping.me.uk> wrote:
> Commit f04565ddf52e4 (dev: use name hash for dev_seq_ops) introduced
> code that fails to check the requested position when getting an item for
> /proc/net/dev. This means that any code which seeks within this file is
> likely to receive corrupted data.
>
> A test case for this is to use the read builtin in bash:
>
> $ while read line; do echo "$line"; done </proc/net/dev | cut -c-20
> Inter-| Receive
> face |bytes packe
> virbr0: 20706
> 0
> lo: 2329335 10305
> eth0: 0
>
> compared to just cat'ing the file:
>
> $ cat /proc/net/dev | cut -c-20
> Inter-| Receive
> face |bytes pack
> lo: 2329335 10
> virbr0: 20706
> sit0: 0
> wlan0: 1727234745 1
> eth0: 0
>
> This patch takes the sledgehammer approach of starting again from the
> beginning if asked to seek backwards.
>
> Signed-off-by: John Keeping <john@keeping.me.uk>
>
> ---
> I have made the minimal change required to fix the bug here. If desired I
> can spend some more time and enhance the dev_from_new_bucket and
> dev_from_same_bucket functions to support walking backwards as well as
> forwards through the items in the table.
>
> ---
> net/core/dev.c | 24 +++++++++++++++++++-----
> 1 files changed, 19 insertions(+), 5 deletions(-)
>
> diff --git a/net/core/dev.c b/net/core/dev.c
> index 6ca32f6..66b1e891 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -4040,6 +4040,7 @@ static int dev_ifconf(struct net *net, char __user *arg)
>
> struct dev_iter_state {
> struct seq_net_private p;
> + loff_t expected_pos; /* current index */
> unsigned int pos; /* bucket << BUCKET_SPACE + offset */
> };
>
> @@ -4096,24 +4097,37 @@ static inline struct net_device *dev_from_new_bucket(struct seq_file *seq)
> void *dev_seq_start(struct seq_file *seq, loff_t *pos)
> __acquires(RCU)
> {
> + struct net_device *dev;
> struct dev_iter_state *state = seq->private;
>
> rcu_read_lock();
> - if (!*pos)
> + if (!*pos) {
> + state->expected_pos = 0;
> + state->pos = 0;
> return SEQ_START_TOKEN;
> + }
>
> - /* check for end of the hash */
> - if (state->pos == 0 && *pos > 1)
> - return NULL;
> + /* If we're asked for something behind where we are, start again. */
> + if (state->expected_pos >= *pos) {
> + state->expected_pos = 0;
> + state->pos = 0;
> + }
>
> - return dev_from_new_bucket(seq);
> + do {
> + dev = dev_from_new_bucket(seq);
> + ++state->expected_pos;
> + } while (dev && state->expected_pos < *pos);
> +
> + return dev;
> }
>
> void *dev_seq_next(struct seq_file *seq, void *v, loff_t *pos)
> {
> struct net_device *dev;
> + struct dev_iter_state *state = seq->private;
>
> ++*pos;
> + state->expected_pos = *pos;
>
> if (v == SEQ_START_TOKEN)
> return dev_from_new_bucket(seq);
> --
> 1.7.8.5
>
Looks good to me. However, Eric just submitted a patch here with other
changes caused by a logic error in the original patch.
Now I understand why those resets to the beginning were there (though
they are very rare)
^ permalink raw reply
* Re: [RFC] net/hsr: Add support for IEC 62439-3 High-availability Seamless Redundancy
From: Arvid Brodin @ 2012-04-06 17:08 UTC (permalink / raw)
To: David Miller; +Cc: shemminger, netdev, balferreira, arvid.brodin
In-Reply-To: <20120406.124344.564538802640968013.davem@davemloft.net>
David Miller wrote:
> From: Arvid Brodin <arvid.brodin@enea.com>
> Date: Fri, 6 Apr 2012 17:51:24 +0200
>
>> Just out of curiosity, what's the mechanism behind this inline
>> assignment that turns the memcpy into an unaligned access? If gcc is
>> "smart" enough to detect a bunch of char * accesses and turn them
>> into unaligned 32-bit accesses, isn't that a bug in gcc?
>
> It's not doing it with "char *", it's doing it with other types like
> the type of the ICMP header in this case.
>
> memcpy is expanded by the compiler internally into __builtin_memcpy()
> which if it sees the length is reasonably short will inline the
> copy. And subsequently it uses the alignment of the types involved
> to determine what kinds of loads and stores it can use in that
> inline memcpy().
>
> So the result is that just because in your case with your compiler
> it doesn't get expanded inline and fault, it doesn't mean it won't
> for someone else.
>
> You're just lucky, and you really haven't fixed the bug.
>
Ok. And thanks for the explanation. Would something like this do the
trick then?
+ /* Need to cast to (char *) below to keep gcc optimizations
+ from causing alignment faults. */
+ memcpy(&icmp_param.data.icmph, (char *) icmp_hdr(skb),
+ sizeof(icmp_param.data.icmph));
If not, any suggestions on how to tackle this?
--
Arvid Brodin
Enea Services Stockholm AB - since February 16 a part of Xdin in the Alten
Group. Soon we will be working under the common brand Xdin. Read more at
www.xdin.com.
^ permalink raw reply
* Re: [RFC] net/hsr: Add support for IEC 62439-3 High-availability Seamless Redundancy
From: Ben Hutchings @ 2012-04-06 17:06 UTC (permalink / raw)
To: Arvid Brodin; +Cc: David Miller, shemminger, netdev, balferreira, arvid.brodin
In-Reply-To: <4F7F10FC.3020308@enea.com>
On Fri, 2012-04-06 at 17:51 +0200, Arvid Brodin wrote:
> David Miller wrote:
> > From: Stephen Hemminger <shemminger@vyatta.com>
> > Date: Wed, 4 Apr 2012 16:55:59 -0700
> >
> >> That isn't so bad, doing a memcpy versus a structure copy.
> >
> > GCC is going to inline the memcpy and thus we'll still do the
> > unaligned accesses. This change therefore won't fix the problem.
>
> Well, it does work for me, with gcc-4.2.2-compiled linux-2.6.37 running
> on an AVR32 board.
>
> Just out of curiosity, what's the mechanism behind this inline
> assignment that turns the memcpy into an unaligned access? If gcc is
> "smart" enough to detect a bunch of char * accesses and turn them
> into unaligned 32-bit accesses, isn't that a bug in gcc?
If I remember correctly, casting a char* pointer to foo* where the
original pointer isn't properly aligned for type foo results in
undefined behaviour. And that is what icmp_hdr() is doing, so there is
no requirement that the compiler does anything reasonable with the
result. Removing that cast (using skb_transport_header() instead of
icmp_hdr()) should avoid that.
(We do generally assume, however, that if the processor can handle
unaligned accesses in a useful way then the compiler will be reasonable
and not break them.)
Ben.
> Or will this only happen on archs which __HAVE_ARCH_MEMCPY? (But looking
> at a couple of arch/xxx/lib/string.c, these too seem to take alignment
> into account.)
>
--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply
* [PATCH] net/core: Fix seeking in /proc/net/dev
From: John Keeping @ 2012-04-06 17:05 UTC (permalink / raw)
To: netdev; +Cc: John Keeping, linux-kernel, Mihai Maruseac
Commit f04565ddf52e4 (dev: use name hash for dev_seq_ops) introduced
code that fails to check the requested position when getting an item for
/proc/net/dev. This means that any code which seeks within this file is
likely to receive corrupted data.
A test case for this is to use the read builtin in bash:
$ while read line; do echo "$line"; done </proc/net/dev | cut -c-20
Inter-| Receive
face |bytes packe
virbr0: 20706
0
lo: 2329335 10305
eth0: 0
compared to just cat'ing the file:
$ cat /proc/net/dev | cut -c-20
Inter-| Receive
face |bytes pack
lo: 2329335 10
virbr0: 20706
sit0: 0
wlan0: 1727234745 1
eth0: 0
This patch takes the sledgehammer approach of starting again from the
beginning if asked to seek backwards.
Signed-off-by: John Keeping <john@keeping.me.uk>
---
I have made the minimal change required to fix the bug here. If desired I
can spend some more time and enhance the dev_from_new_bucket and
dev_from_same_bucket functions to support walking backwards as well as
forwards through the items in the table.
---
net/core/dev.c | 24 +++++++++++++++++++-----
1 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/net/core/dev.c b/net/core/dev.c
index 6ca32f6..66b1e891 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -4040,6 +4040,7 @@ static int dev_ifconf(struct net *net, char __user *arg)
struct dev_iter_state {
struct seq_net_private p;
+ loff_t expected_pos; /* current index */
unsigned int pos; /* bucket << BUCKET_SPACE + offset */
};
@@ -4096,24 +4097,37 @@ static inline struct net_device *dev_from_new_bucket(struct seq_file *seq)
void *dev_seq_start(struct seq_file *seq, loff_t *pos)
__acquires(RCU)
{
+ struct net_device *dev;
struct dev_iter_state *state = seq->private;
rcu_read_lock();
- if (!*pos)
+ if (!*pos) {
+ state->expected_pos = 0;
+ state->pos = 0;
return SEQ_START_TOKEN;
+ }
- /* check for end of the hash */
- if (state->pos == 0 && *pos > 1)
- return NULL;
+ /* If we're asked for something behind where we are, start again. */
+ if (state->expected_pos >= *pos) {
+ state->expected_pos = 0;
+ state->pos = 0;
+ }
- return dev_from_new_bucket(seq);
+ do {
+ dev = dev_from_new_bucket(seq);
+ ++state->expected_pos;
+ } while (dev && state->expected_pos < *pos);
+
+ return dev;
}
void *dev_seq_next(struct seq_file *seq, void *v, loff_t *pos)
{
struct net_device *dev;
+ struct dev_iter_state *state = seq->private;
++*pos;
+ state->expected_pos = *pos;
if (v == SEQ_START_TOKEN)
return dev_from_new_bucket(seq);
--
1.7.8.5
^ permalink raw reply related
* Re: [PATCH net-next #2 21/39] tulip_core: stop using net_device.{base_addr, irq}.
From: Grant Grundler @ 2012-04-06 16:57 UTC (permalink / raw)
To: Francois Romieu; +Cc: netdev, David Miller, Grant Grundler
In-Reply-To: <43487f61a41077ec5cf8587248eb502f5d9be785.1333704409.git.romieu@fr.zoreil.com>
On Fri, Apr 6, 2012 at 3:06 AM, Francois Romieu <romieu@fr.zoreil.com> wrote:
> Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
> Cc: Grant Grundler <grundler@parisc-linux.org>
Ack-by: Grant Grundler <grundler@parisc-linux.org>
thanks,
grant
> ---
> drivers/net/ethernet/dec/tulip/tulip_core.c | 27 ++++++++++++++++-----------
> 1 files changed, 16 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/net/ethernet/dec/tulip/tulip_core.c b/drivers/net/ethernet/dec/tulip/tulip_core.c
> index fea3641..25fe117 100644
> --- a/drivers/net/ethernet/dec/tulip/tulip_core.c
> +++ b/drivers/net/ethernet/dec/tulip/tulip_core.c
> @@ -328,7 +328,7 @@ static void tulip_up(struct net_device *dev)
> udelay(100);
>
> if (tulip_debug > 1)
> - netdev_dbg(dev, "tulip_up(), irq==%d\n", dev->irq);
> + netdev_dbg(dev, "tulip_up(), irq==%d\n", tp->pdev->irq);
>
> iowrite32(tp->rx_ring_dma, ioaddr + CSR3);
> iowrite32(tp->tx_ring_dma, ioaddr + CSR4);
> @@ -515,11 +515,13 @@ media_picked:
> static int
> tulip_open(struct net_device *dev)
> {
> + struct tulip_private *tp = netdev_priv(dev);
> int retval;
>
> tulip_init_ring (dev);
>
> - retval = request_irq(dev->irq, tulip_interrupt, IRQF_SHARED, dev->name, dev);
> + retval = request_irq(tp->pdev->irq, tulip_interrupt, IRQF_SHARED,
> + dev->name, dev);
> if (retval)
> goto free_ring;
>
> @@ -841,7 +843,7 @@ static int tulip_close (struct net_device *dev)
> netdev_dbg(dev, "Shutting down ethercard, status was %02x\n",
> ioread32 (ioaddr + CSR5));
>
> - free_irq (dev->irq, dev);
> + free_irq (tp->pdev->irq, dev);
>
> tulip_free_ring (dev);
>
> @@ -1489,8 +1491,6 @@ static int __devinit tulip_init_one (struct pci_dev *pdev,
>
> INIT_WORK(&tp->media_work, tulip_tbl[tp->chip_id].media_task);
>
> - dev->base_addr = (unsigned long)ioaddr;
> -
> #ifdef CONFIG_TULIP_MWI
> if (!force_csr0 && (tp->flags & HAS_PCI_MWI))
> tulip_mwi_config (pdev, dev);
> @@ -1650,7 +1650,6 @@ static int __devinit tulip_init_one (struct pci_dev *pdev,
> for (i = 0; i < 6; i++)
> last_phys_addr[i] = dev->dev_addr[i];
> last_irq = irq;
> - dev->irq = irq;
>
> /* The lower four bits are the media type. */
> if (board_idx >= 0 && board_idx < MAX_UNITS) {
> @@ -1858,7 +1857,8 @@ static int tulip_suspend (struct pci_dev *pdev, pm_message_t state)
> tulip_down(dev);
>
> netif_device_detach(dev);
> - free_irq(dev->irq, dev);
> + /* FIXME: it needlessly adds an error path. */
> + free_irq(tp->pdev->irq, dev);
>
> save_state:
> pci_save_state(pdev);
> @@ -1900,7 +1900,9 @@ static int tulip_resume(struct pci_dev *pdev)
> return retval;
> }
>
> - if ((retval = request_irq(dev->irq, tulip_interrupt, IRQF_SHARED, dev->name, dev))) {
> + retval = request_irq(pdev->irq, tulip_interrupt, IRQF_SHARED,
> + dev->name, dev);
> + if (retval < 0) {
> pr_err("request_irq failed in resume\n");
> return retval;
> }
> @@ -1960,11 +1962,14 @@ static void __devexit tulip_remove_one (struct pci_dev *pdev)
>
> static void poll_tulip (struct net_device *dev)
> {
> + struct tulip_private *tp = netdev_priv(dev);
> + const int irq = tp->pdev->irq;
> +
> /* disable_irq here is not very nice, but with the lockless
> interrupt handler we have no other choice. */
> - disable_irq(dev->irq);
> - tulip_interrupt (dev->irq, dev);
> - enable_irq(dev->irq);
> + disable_irq(irq);
> + tulip_interrupt (irq, dev);
> + enable_irq(irq);
> }
> #endif
>
> --
> 1.7.7.6
>
^ permalink raw reply
* Re: ath: DMA failed to stop in 10 ms AR_CR=0x00000024 AR_DIAG_SW=0x02000020 DMADBG_7=0x00008040
From: Felix Fietkau @ 2012-04-06 16:56 UTC (permalink / raw)
To: Justin P. Mattock
Cc: Sujith Manoharan, Mohammed Shafi, Linux-wireless, linux-kernel,
Linux-netdev
In-Reply-To: <4F7F1C74.7080009@gmail.com>
On 2012-04-06 6:40 PM, Justin P. Mattock wrote:
> On 03/26/2012 07:17 PM, Sujith Manoharan wrote:
>> Justin P. Mattock wrote:
>>> I would have to say this patch above does get rid of this crash I was
>>> seeing. as a quick test I simply connect to a WPA network, then connect
>>> to an open network going back and forth triggers this freeze for me
>>> after applying this I am able to toggle back and forth without a freeze.
>>
>> Thanks for verifying.
>>
>> Sujith
>>
>
>
> From going through the warning message I was playing around and am
> looking at: AH_UNPLUGGED .. seems if I remove this from the code I have
> not seen this warning message.
> is there something wrong with AH_UNPLUGGED = 0x2 ?
> is this the wrong address(0x2)?
>
> the patch that I was using is:
>
> From ea8a7d6ecf8b0706f3f0521cd22cc359b20b9373 Mon Sep 17 00:00:00 2001
> From: "Justin P. Mattock" <justinmattock@gmail.com>
> Date: Sun, 25 Mar 2012 21:53:31 -0700
> Subject: [PATCH] ath_test
>
> Signed-off-by: Justin P. Mattock <justinmattock@gmail.com>
>
> ---
> drivers/net/wireless/ath/ath9k/recv.c | 3 +--
> 1 files changed, 1 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/wireless/ath/ath9k/recv.c
> b/drivers/net/wireless/ath/ath9k/recv.c
> index f4ae3ba..d887cee 100644
> --- a/drivers/net/wireless/ath/ath9k/recv.c
> +++ b/drivers/net/wireless/ath/ath9k/recv.c
> @@ -523,8 +523,7 @@ bool ath_stoprecv(struct ath_softc *sc)
> sc->rx.rxlink = NULL;
> spin_unlock_bh(&sc->rx.rxbuflock);
>
> - if (!(ah->ah_flags & AH_UNPLUGGED) &&
> - unlikely(!stopped)) {
> + if (!(ah->ah_flags) && unlikely(!stopped)) {
That patch is completely messed up - before showing the warning, it
checks if ah_flags is set to 0, which will never happen with most
devices. You're simply making the warning impossible to trigger.
- Felix
^ permalink raw reply
* Re: [PATCH net-next #2 24/39] xircom_cb: fix device probe error path.
From: Grant Grundler @ 2012-04-06 16:56 UTC (permalink / raw)
To: Francois Romieu; +Cc: netdev, David Miller, Grant Grundler
In-Reply-To: <271dcd170006b9d55eb555b2e79e22c1fa86e0a0.1333704409.git.romieu@fr.zoreil.com>
On Fri, Apr 6, 2012 at 3:06 AM, Francois Romieu <romieu@fr.zoreil.com> wrote:
> - unbalanced pci_disable_device
> - PCI ressources were not released
> - mismatching pci_alloc_.../kfree pairs are replaced by DMA alloc helpers.
>
> Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
> Cc: Grant Grundler <grundler@parisc-linux.org>
Acked-by: Grant Grundler <grundler@parisc-linux.org>
Very nice - thank you! :)
grant
> ---
> drivers/net/ethernet/dec/tulip/xircom_cb.c | 53 ++++++++++++++++++----------
> 1 files changed, 34 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/net/ethernet/dec/tulip/xircom_cb.c b/drivers/net/ethernet/dec/tulip/xircom_cb.c
> index fdb329f..cbcc6d6 100644
> --- a/drivers/net/ethernet/dec/tulip/xircom_cb.c
> +++ b/drivers/net/ethernet/dec/tulip/xircom_cb.c
> @@ -192,15 +192,18 @@ static const struct net_device_ops netdev_ops = {
> */
> static int __devinit xircom_probe(struct pci_dev *pdev, const struct pci_device_id *id)
> {
> + struct device *d = &pdev->dev;
> struct net_device *dev = NULL;
> struct xircom_private *private;
> unsigned long flags;
> unsigned short tmp16;
> + int rc;
>
> /* First do the PCI initialisation */
>
> - if (pci_enable_device(pdev))
> - return -ENODEV;
> + rc = pci_enable_device(pdev);
> + if (rc < 0)
> + goto out;
>
> /* disable all powermanagement */
> pci_write_config_dword(pdev, PCI_POWERMGMT, 0x0000);
> @@ -211,11 +214,13 @@ static int __devinit xircom_probe(struct pci_dev *pdev, const struct pci_device_
> pci_read_config_word (pdev,PCI_STATUS, &tmp16);
> pci_write_config_word (pdev, PCI_STATUS,tmp16);
>
> - if (!request_region(pci_resource_start(pdev, 0), 128, "xircom_cb")) {
> + rc = pci_request_regions(pdev, "xircom_cb");
> + if (rc < 0) {
> pr_err("%s: failed to allocate io-region\n", __func__);
> - return -ENODEV;
> + goto err_disable;
> }
>
> + rc = -ENOMEM;
> /*
> Before changing the hardware, allocate the memory.
> This way, we can fail gracefully if not enough memory
> @@ -223,17 +228,21 @@ static int __devinit xircom_probe(struct pci_dev *pdev, const struct pci_device_
> */
> dev = alloc_etherdev(sizeof(struct xircom_private));
> if (!dev)
> - goto device_fail;
> + goto err_release;
>
> private = netdev_priv(dev);
>
> /* Allocate the send/receive buffers */
> - private->rx_buffer = pci_alloc_consistent(pdev,8192,&private->rx_dma_handle);
> + private->rx_buffer = dma_alloc_coherent(d, 8192,
> + &private->rx_dma_handle,
> + GFP_KERNEL);
> if (private->rx_buffer == NULL) {
> pr_err("%s: no memory for rx buffer\n", __func__);
> goto rx_buf_fail;
> }
> - private->tx_buffer = pci_alloc_consistent(pdev,8192,&private->tx_dma_handle);
> + private->tx_buffer = dma_alloc_coherent(d, 8192,
> + &private->tx_dma_handle,
> + GFP_KERNEL);
> if (private->tx_buffer == NULL) {
> pr_err("%s: no memory for tx buffer\n", __func__);
> goto tx_buf_fail;
> @@ -256,7 +265,8 @@ static int __devinit xircom_probe(struct pci_dev *pdev, const struct pci_device_
> dev->netdev_ops = &netdev_ops;
> pci_set_drvdata(pdev, dev);
>
> - if (register_netdev(dev)) {
> + rc = register_netdev(dev);
> + if (rc < 0) {
> pr_err("%s: netdevice registration failed\n", __func__);
> goto reg_fail;
> }
> @@ -273,17 +283,21 @@ static int __devinit xircom_probe(struct pci_dev *pdev, const struct pci_device_
> spin_unlock_irqrestore(&private->lock,flags);
>
> trigger_receive(private);
> -
> - return 0;
> +out:
> + return rc;
>
> reg_fail:
> - kfree(private->tx_buffer);
> + pci_set_drvdata(pdev, NULL);
> + dma_free_coherent(d, 8192, private->tx_buffer, private->tx_dma_handle);
> tx_buf_fail:
> - kfree(private->rx_buffer);
> + dma_free_coherent(d, 8192, private->rx_buffer, private->rx_dma_handle);
> rx_buf_fail:
> free_netdev(dev);
> -device_fail:
> - return -ENODEV;
> +err_release:
> + pci_release_regions(pdev);
> +err_disable:
> + pci_disable_device(pdev);
> + goto out;
> }
>
>
> @@ -297,14 +311,15 @@ static void __devexit xircom_remove(struct pci_dev *pdev)
> {
> struct net_device *dev = pci_get_drvdata(pdev);
> struct xircom_private *card = netdev_priv(dev);
> + struct device *d = &pdev->dev;
>
> - pci_free_consistent(pdev,8192,card->rx_buffer,card->rx_dma_handle);
> - pci_free_consistent(pdev,8192,card->tx_buffer,card->tx_dma_handle);
> -
> - release_region(dev->base_addr, 128);
> unregister_netdev(dev);
> - free_netdev(dev);
> pci_set_drvdata(pdev, NULL);
> + dma_free_coherent(d, 8192, card->tx_buffer, card->tx_dma_handle);
> + dma_free_coherent(d, 8192, card->rx_buffer, card->rx_dma_handle);
> + free_netdev(dev);
> + pci_release_regions(pdev);
> + pci_disable_device(pdev);
> }
>
> static irqreturn_t xircom_interrupt(int irq, void *dev_instance)
> --
> 1.7.7.6
>
^ permalink raw reply
* Re: [PATCH net-next #2 26/39] de2104x: stop using net_device.{base_addr, irq}.
From: Grant Grundler @ 2012-04-06 16:54 UTC (permalink / raw)
To: Francois Romieu; +Cc: netdev, David Miller, Grant Grundler
In-Reply-To: <3cebeb3c55c12a033d30603baf34d449df75d2c1.1333704409.git.romieu@fr.zoreil.com>
On Fri, Apr 6, 2012 at 3:06 AM, Francois Romieu <romieu@fr.zoreil.com> wrote:
> Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
> Cc: Grant Grundler <grundler@parisc-linux.org>
Acked-by: Grant Grundler <grundler@parisc-linux.org>
thanks,
grant
> ---
> drivers/net/ethernet/dec/tulip/de2104x.c | 34 ++++++++++++++---------------
> 1 files changed, 16 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/net/ethernet/dec/tulip/de2104x.c b/drivers/net/ethernet/dec/tulip/de2104x.c
> index 68f1c39..61cc093 100644
> --- a/drivers/net/ethernet/dec/tulip/de2104x.c
> +++ b/drivers/net/ethernet/dec/tulip/de2104x.c
> @@ -1380,6 +1380,7 @@ static void de_free_rings (struct de_private *de)
> static int de_open (struct net_device *dev)
> {
> struct de_private *de = netdev_priv(dev);
> + const int irq = de->pdev->irq;
> int rc;
>
> netif_dbg(de, ifup, dev, "enabling interface\n");
> @@ -1394,10 +1395,9 @@ static int de_open (struct net_device *dev)
>
> dw32(IntrMask, 0);
>
> - rc = request_irq(dev->irq, de_interrupt, IRQF_SHARED, dev->name, dev);
> + rc = request_irq(irq, de_interrupt, IRQF_SHARED, dev->name, dev);
> if (rc) {
> - netdev_err(dev, "IRQ %d request failure, err=%d\n",
> - dev->irq, rc);
> + netdev_err(dev, "IRQ %d request failure, err=%d\n", irq, rc);
> goto err_out_free;
> }
>
> @@ -1413,7 +1413,7 @@ static int de_open (struct net_device *dev)
> return 0;
>
> err_out_free_irq:
> - free_irq(dev->irq, dev);
> + free_irq(irq, dev);
> err_out_free:
> de_free_rings(de);
> return rc;
> @@ -1434,7 +1434,7 @@ static int de_close (struct net_device *dev)
> netif_carrier_off(dev);
> spin_unlock_irqrestore(&de->lock, flags);
>
> - free_irq(dev->irq, dev);
> + free_irq(de->pdev->irq, dev);
>
> de_free_rings(de);
> de_adapter_sleep(de);
> @@ -1444,6 +1444,7 @@ static int de_close (struct net_device *dev)
> static void de_tx_timeout (struct net_device *dev)
> {
> struct de_private *de = netdev_priv(dev);
> + const int irq = de->pdev->irq;
>
> netdev_dbg(dev, "NIC status %08x mode %08x sia %08x desc %u/%u/%u\n",
> dr32(MacStatus), dr32(MacMode), dr32(SIAStatus),
> @@ -1451,7 +1452,7 @@ static void de_tx_timeout (struct net_device *dev)
>
> del_timer_sync(&de->media_timer);
>
> - disable_irq(dev->irq);
> + disable_irq(irq);
> spin_lock_irq(&de->lock);
>
> de_stop_hw(de);
> @@ -1459,12 +1460,12 @@ static void de_tx_timeout (struct net_device *dev)
> netif_carrier_off(dev);
>
> spin_unlock_irq(&de->lock);
> - enable_irq(dev->irq);
> + enable_irq(irq);
>
> /* Update the error counts. */
> __de_get_stats(de);
>
> - synchronize_irq(dev->irq);
> + synchronize_irq(irq);
> de_clean_rings(de);
>
> de_init_rings(de);
> @@ -2024,8 +2025,6 @@ static int __devinit de_init_one (struct pci_dev *pdev,
> goto err_out_res;
> }
>
> - dev->irq = pdev->irq;
> -
> /* obtain and check validity of PCI I/O address */
> pciaddr = pci_resource_start(pdev, 1);
> if (!pciaddr) {
> @@ -2050,7 +2049,6 @@ static int __devinit de_init_one (struct pci_dev *pdev,
> pciaddr, pci_name(pdev));
> goto err_out_res;
> }
> - dev->base_addr = (unsigned long) regs;
> de->regs = regs;
>
> de_adapter_wake(de);
> @@ -2078,11 +2076,9 @@ static int __devinit de_init_one (struct pci_dev *pdev,
> goto err_out_iomap;
>
> /* print info about board and interface just registered */
> - netdev_info(dev, "%s at 0x%lx, %pM, IRQ %d\n",
> + netdev_info(dev, "%s at %p, %pM, IRQ %d\n",
> de->de21040 ? "21040" : "21041",
> - dev->base_addr,
> - dev->dev_addr,
> - dev->irq);
> + regs, dev->dev_addr, pdev->irq);
>
> pci_set_drvdata(pdev, dev);
>
> @@ -2130,9 +2126,11 @@ static int de_suspend (struct pci_dev *pdev, pm_message_t state)
>
> rtnl_lock();
> if (netif_running (dev)) {
> + const int irq = pdev->irq;
> +
> del_timer_sync(&de->media_timer);
>
> - disable_irq(dev->irq);
> + disable_irq(irq);
> spin_lock_irq(&de->lock);
>
> de_stop_hw(de);
> @@ -2141,12 +2139,12 @@ static int de_suspend (struct pci_dev *pdev, pm_message_t state)
> netif_carrier_off(dev);
>
> spin_unlock_irq(&de->lock);
> - enable_irq(dev->irq);
> + enable_irq(irq);
>
> /* Update the error counts. */
> __de_get_stats(de);
>
> - synchronize_irq(dev->irq);
> + synchronize_irq(irq);
> de_clean_rings(de);
>
> de_adapter_sleep(de);
> --
> 1.7.7.6
>
^ permalink raw reply
* Re: [PATCH net-next #2 31/39] uli526x: stop using net_device.{base_addr, irq} and convert to __iomem.
From: Grant Grundler @ 2012-04-06 16:53 UTC (permalink / raw)
To: Francois Romieu; +Cc: netdev, David Miller, Grant Grundler
In-Reply-To: <0a3928f4342bab3bf0b2eb63fe71cecace548e99.1333704409.git.romieu@fr.zoreil.com>
On Fri, Apr 6, 2012 at 3:06 AM, Francois Romieu <romieu@fr.zoreil.com> wrote:
> The bulk of the patch comes from the __iomem changes.
>
> - the phy read and write operations were carrying the chip id deep
> down the call chain. Let's waste a pointer and contain the flying
> spaghetti monster.
> - phy_{read, write}_1bit only need to access the DCR9 register. The loss
> of generality here should not hurt.
> - removed a leftover printk of the EISA era. This is a pure PCI device.
>
> Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
> Cc: Grant Grundler <grundler@parisc-linux.org>
Acked-By: Grant Grundler <grundler@parisc-linux.org>
I suggest taking a look at srom_clk_write() and uli526x_init_one()
regarding posted MMIO write vs udelay().
I think I found an example that appears to get the ROM clocking
correct with MMIO:
ethernet/realtek/8139cp.c: read_eeprom()
thanks!
grant
> ---
> drivers/net/ethernet/dec/tulip/uli526x.c | 397 +++++++++++++++---------------
> 1 files changed, 202 insertions(+), 195 deletions(-)
>
> diff --git a/drivers/net/ethernet/dec/tulip/uli526x.c b/drivers/net/ethernet/dec/tulip/uli526x.c
> index c9b3396..75d45f8 100644
> --- a/drivers/net/ethernet/dec/tulip/uli526x.c
> +++ b/drivers/net/ethernet/dec/tulip/uli526x.c
> @@ -42,6 +42,8 @@
> #include <asm/dma.h>
> #include <asm/uaccess.h>
>
> +#define uw32(reg, val) iowrite32(val, ioaddr + (reg))
> +#define ur32(reg) ioread32(ioaddr + (reg))
>
> /* Board/System/Debug information/definition ---------------- */
> #define PCI_ULI5261_ID 0x526110B9 /* ULi M5261 ID*/
> @@ -110,14 +112,6 @@ do { \
>
> #define SROM_V41_CODE 0x14
>
> -#define SROM_CLK_WRITE(data, ioaddr) \
> - outl(data|CR9_SROM_READ|CR9_SRCS,ioaddr); \
> - udelay(5); \
> - outl(data|CR9_SROM_READ|CR9_SRCS|CR9_SRCLK,ioaddr); \
> - udelay(5); \
> - outl(data|CR9_SROM_READ|CR9_SRCS,ioaddr); \
> - udelay(5);
> -
> /* Structure/enum declaration ------------------------------- */
> struct tx_desc {
> __le32 tdes0, tdes1, tdes2, tdes3; /* Data for the card */
> @@ -132,12 +126,15 @@ struct rx_desc {
> } __attribute__(( aligned(32) ));
>
> struct uli526x_board_info {
> - u32 chip_id; /* Chip vendor/Device ID */
> + struct uli_phy_ops {
> + void (*write)(struct uli526x_board_info *, u8, u8, u16);
> + u16 (*read)(struct uli526x_board_info *, u8, u8);
> + } phy;
> struct net_device *next_dev; /* next device */
> struct pci_dev *pdev; /* PCI device */
> spinlock_t lock;
>
> - long ioaddr; /* I/O base address */
> + void __iomem *ioaddr; /* I/O base address */
> u32 cr0_data;
> u32 cr5_data;
> u32 cr6_data;
> @@ -227,21 +224,21 @@ static netdev_tx_t uli526x_start_xmit(struct sk_buff *,
> static int uli526x_stop(struct net_device *);
> static void uli526x_set_filter_mode(struct net_device *);
> static const struct ethtool_ops netdev_ethtool_ops;
> -static u16 read_srom_word(long, int);
> +static u16 read_srom_word(struct uli526x_board_info *, int);
> static irqreturn_t uli526x_interrupt(int, void *);
> #ifdef CONFIG_NET_POLL_CONTROLLER
> static void uli526x_poll(struct net_device *dev);
> #endif
> -static void uli526x_descriptor_init(struct net_device *, unsigned long);
> +static void uli526x_descriptor_init(struct net_device *, void __iomem *);
> static void allocate_rx_buffer(struct net_device *);
> -static void update_cr6(u32, unsigned long);
> +static void update_cr6(u32, void __iomem *);
> static void send_filter_frame(struct net_device *, int);
> -static u16 phy_read(unsigned long, u8, u8, u32);
> -static u16 phy_readby_cr10(unsigned long, u8, u8);
> -static void phy_write(unsigned long, u8, u8, u16, u32);
> -static void phy_writeby_cr10(unsigned long, u8, u8, u16);
> -static void phy_write_1bit(unsigned long, u32, u32);
> -static u16 phy_read_1bit(unsigned long, u32);
> +static u16 phy_readby_cr9(struct uli526x_board_info *, u8, u8);
> +static u16 phy_readby_cr10(struct uli526x_board_info *, u8, u8);
> +static void phy_writeby_cr9(struct uli526x_board_info *, u8, u8, u16);
> +static void phy_writeby_cr10(struct uli526x_board_info *, u8, u8, u16);
> +static void phy_write_1bit(struct uli526x_board_info *db, u32);
> +static u16 phy_read_1bit(struct uli526x_board_info *db);
> static u8 uli526x_sense_speed(struct uli526x_board_info *);
> static void uli526x_process_mode(struct uli526x_board_info *);
> static void uli526x_timer(unsigned long);
> @@ -253,6 +250,18 @@ static void uli526x_free_rxbuffer(struct uli526x_board_info *);
> static void uli526x_init(struct net_device *);
> static void uli526x_set_phyxcer(struct uli526x_board_info *);
>
> +static void srom_clk_write(struct uli526x_board_info *db, u32 data)
> +{
> + void __iomem *ioaddr = db->ioaddr;
> +
> + uw32(DCR9, data | CR9_SROM_READ | CR9_SRCS);
> + udelay(5);
> + uw32(DCR9, data | CR9_SROM_READ | CR9_SRCS | CR9_SRCLK);
> + udelay(5);
> + uw32(DCR9, data | CR9_SROM_READ | CR9_SRCS);
> + udelay(5);
> +}
> +
> /* ULI526X network board routine ---------------------------- */
>
> static const struct net_device_ops netdev_ops = {
> @@ -277,6 +286,7 @@ static int __devinit uli526x_init_one (struct pci_dev *pdev,
> {
> struct uli526x_board_info *db; /* board information structure */
> struct net_device *dev;
> + void __iomem *ioaddr;
> int i, err;
>
> ULI526X_DBUG(0, "uli526x_init_one()", 0);
> @@ -338,14 +348,26 @@ static int __devinit uli526x_init_one (struct pci_dev *pdev,
> db->buf_pool_start = db->buf_pool_ptr;
> db->buf_pool_dma_start = db->buf_pool_dma_ptr;
>
> - db->chip_id = ent->driver_data;
> - db->ioaddr = pci_resource_start(pdev, 0);
> + switch (ent->driver_data) {
> + case PCI_ULI5263_ID:
> + db->phy.write = phy_writeby_cr10;
> + db->phy.read = phy_readby_cr10;
> + break;
> + default:
> + db->phy.write = phy_writeby_cr9;
> + db->phy.read = phy_readby_cr9;
> + break;
> + }
>
> + /* IO region. */
> + ioaddr = pci_iomap(pdev, 0, 0);
> + if (!ioaddr)
> + goto err_out_free_tx_buf;
> +
> + db->ioaddr = ioaddr;
> db->pdev = pdev;
> db->init = 1;
>
> - dev->base_addr = db->ioaddr;
> - dev->irq = pdev->irq;
> pci_set_drvdata(pdev, dev);
>
> /* Register some necessary functions */
> @@ -357,24 +379,24 @@ static int __devinit uli526x_init_one (struct pci_dev *pdev,
>
> /* read 64 word srom data */
> for (i = 0; i < 64; i++)
> - ((__le16 *) db->srom)[i] = cpu_to_le16(read_srom_word(db->ioaddr, i));
> + ((__le16 *) db->srom)[i] = cpu_to_le16(read_srom_word(db, i));
>
> /* Set Node address */
> if(((u16 *) db->srom)[0] == 0xffff || ((u16 *) db->srom)[0] == 0) /* SROM absent, so read MAC address from ID Table */
> {
> - outl(0x10000, db->ioaddr + DCR0); //Diagnosis mode
> - outl(0x1c0, db->ioaddr + DCR13); //Reset dianostic pointer port
> - outl(0, db->ioaddr + DCR14); //Clear reset port
> - outl(0x10, db->ioaddr + DCR14); //Reset ID Table pointer
> - outl(0, db->ioaddr + DCR14); //Clear reset port
> - outl(0, db->ioaddr + DCR13); //Clear CR13
> - outl(0x1b0, db->ioaddr + DCR13); //Select ID Table access port
> + uw32(DCR0, 0x10000); //Diagnosis mode
> + uw32(DCR13, 0x1c0); //Reset dianostic pointer port
> + uw32(DCR14, 0); //Clear reset port
> + uw32(DCR14, 0x10); //Reset ID Table pointer
> + uw32(DCR14, 0); //Clear reset port
> + uw32(DCR13, 0); //Clear CR13
> + uw32(DCR13, 0x1b0); //Select ID Table access port
> //Read MAC address from CR14
> for (i = 0; i < 6; i++)
> - dev->dev_addr[i] = inl(db->ioaddr + DCR14);
> + dev->dev_addr[i] = ur32(DCR14);
> //Read end
> - outl(0, db->ioaddr + DCR13); //Clear CR13
> - outl(0, db->ioaddr + DCR0); //Clear CR0
> + uw32(DCR13, 0); //Clear CR13
> + uw32(DCR0, 0); //Clear CR0
> udelay(10);
> }
> else /*Exist SROM*/
> @@ -384,16 +406,18 @@ static int __devinit uli526x_init_one (struct pci_dev *pdev,
> }
> err = register_netdev (dev);
> if (err)
> - goto err_out_free_tx_buf;
> + goto err_out_unmap;
>
> netdev_info(dev, "ULi M%04lx at pci%s, %pM, irq %d\n",
> ent->driver_data >> 16, pci_name(pdev),
> - dev->dev_addr, dev->irq);
> + dev->dev_addr, pdev->irq);
>
> pci_set_master(pdev);
>
> return 0;
>
> +err_out_unmap:
> + pci_iounmap(pdev, db->ioaddr);
> err_out_free_tx_buf:
> pci_free_consistent(pdev, TX_BUF_ALLOC * TX_DESC_CNT + 4,
> db->buf_pool_ptr, db->buf_pool_dma_ptr);
> @@ -418,6 +442,7 @@ static void __devexit uli526x_remove_one (struct pci_dev *pdev)
> struct uli526x_board_info *db = netdev_priv(dev);
>
> unregister_netdev(dev);
> + pci_iounmap(pdev, db->ioaddr);
> pci_free_consistent(db->pdev, sizeof(struct tx_desc) *
> DESC_ALL_CNT + 0x20, db->desc_pool_ptr,
> db->desc_pool_dma_ptr);
> @@ -460,7 +485,8 @@ static int uli526x_open(struct net_device *dev)
> /* Initialize ULI526X board */
> uli526x_init(dev);
>
> - ret = request_irq(dev->irq, uli526x_interrupt, IRQF_SHARED, dev->name, dev);
> + ret = request_irq(db->pdev->irq, uli526x_interrupt, IRQF_SHARED,
> + dev->name, dev);
> if (ret)
> return ret;
>
> @@ -488,57 +514,57 @@ static int uli526x_open(struct net_device *dev)
> static void uli526x_init(struct net_device *dev)
> {
> struct uli526x_board_info *db = netdev_priv(dev);
> - unsigned long ioaddr = db->ioaddr;
> + struct uli_phy_ops *phy = &db->phy;
> + void __iomem *ioaddr = db->ioaddr;
> u8 phy_tmp;
> u8 timeout;
> - u16 phy_value;
> u16 phy_reg_reset;
>
>
> ULI526X_DBUG(0, "uli526x_init()", 0);
>
> /* Reset M526x MAC controller */
> - outl(ULI526X_RESET, ioaddr + DCR0); /* RESET MAC */
> + uw32(DCR0, ULI526X_RESET); /* RESET MAC */
> udelay(100);
> - outl(db->cr0_data, ioaddr + DCR0);
> + uw32(DCR0, db->cr0_data);
> udelay(5);
>
> /* Phy addr : In some boards,M5261/M5263 phy address != 1 */
> db->phy_addr = 1;
> - for(phy_tmp=0;phy_tmp<32;phy_tmp++)
> - {
> - phy_value=phy_read(db->ioaddr,phy_tmp,3,db->chip_id);//peer add
> - if(phy_value != 0xffff&&phy_value!=0)
> - {
> + for (phy_tmp = 0; phy_tmp < 32; phy_tmp++) {
> + u16 phy_value;
> +
> + phy_value = phy->read(db, phy_tmp, 3); //peer add
> + if (phy_value != 0xffff && phy_value != 0) {
> db->phy_addr = phy_tmp;
> break;
> }
> }
> - if(phy_tmp == 32)
> +
> + if (phy_tmp == 32)
> pr_warn("Can not find the phy address!!!\n");
> /* Parser SROM and media mode */
> db->media_mode = uli526x_media_mode;
>
> /* phyxcer capability setting */
> - phy_reg_reset = phy_read(db->ioaddr, db->phy_addr, 0, db->chip_id);
> + phy_reg_reset = phy->read(db, db->phy_addr, 0);
> phy_reg_reset = (phy_reg_reset | 0x8000);
> - phy_write(db->ioaddr, db->phy_addr, 0, phy_reg_reset, db->chip_id);
> + phy->write(db, db->phy_addr, 0, phy_reg_reset);
>
> /* See IEEE 802.3-2002.pdf (Section 2, Chapter "22.2.4 Management
> * functions") or phy data sheet for details on phy reset
> */
> udelay(500);
> timeout = 10;
> - while (timeout-- &&
> - phy_read(db->ioaddr, db->phy_addr, 0, db->chip_id) & 0x8000)
> - udelay(100);
> + while (timeout-- && phy->read(db, db->phy_addr, 0) & 0x8000)
> + udelay(100);
>
> /* Process Phyxcer Media Mode */
> uli526x_set_phyxcer(db);
>
> /* Media Mode Process */
> if ( !(db->media_mode & ULI526X_AUTO) )
> - db->op_mode = db->media_mode; /* Force Mode */
> + db->op_mode = db->media_mode; /* Force Mode */
>
> /* Initialize Transmit/Receive decriptor and CR3/4 */
> uli526x_descriptor_init(dev, ioaddr);
> @@ -551,10 +577,10 @@ static void uli526x_init(struct net_device *dev)
>
> /* Init CR7, interrupt active bit */
> db->cr7_data = CR7_DEFAULT;
> - outl(db->cr7_data, ioaddr + DCR7);
> + uw32(DCR7, db->cr7_data);
>
> /* Init CR15, Tx jabber and Rx watchdog timer */
> - outl(db->cr15_data, ioaddr + DCR15);
> + uw32(DCR15, db->cr15_data);
>
> /* Enable ULI526X Tx/Rx function */
> db->cr6_data |= CR6_RXSC | CR6_TXSC;
> @@ -571,6 +597,7 @@ static netdev_tx_t uli526x_start_xmit(struct sk_buff *skb,
> struct net_device *dev)
> {
> struct uli526x_board_info *db = netdev_priv(dev);
> + void __iomem *ioaddr = db->ioaddr;
> struct tx_desc *txptr;
> unsigned long flags;
>
> @@ -596,7 +623,7 @@ static netdev_tx_t uli526x_start_xmit(struct sk_buff *skb,
> }
>
> /* Disable NIC interrupt */
> - outl(0, dev->base_addr + DCR7);
> + uw32(DCR7, 0);
>
> /* transmit this packet */
> txptr = db->tx_insert_ptr;
> @@ -607,10 +634,10 @@ static netdev_tx_t uli526x_start_xmit(struct sk_buff *skb,
> db->tx_insert_ptr = txptr->next_tx_desc;
>
> /* Transmit Packet Process */
> - if ( (db->tx_packet_cnt < TX_DESC_CNT) ) {
> + if (db->tx_packet_cnt < TX_DESC_CNT) {
> txptr->tdes0 = cpu_to_le32(0x80000000); /* Set owner bit */
> db->tx_packet_cnt++; /* Ready to send */
> - outl(0x1, dev->base_addr + DCR1); /* Issue Tx polling */
> + uw32(DCR1, 0x1); /* Issue Tx polling */
> dev->trans_start = jiffies; /* saved time stamp */
> }
>
> @@ -620,7 +647,7 @@ static netdev_tx_t uli526x_start_xmit(struct sk_buff *skb,
>
> /* Restore CR7 to enable interrupt */
> spin_unlock_irqrestore(&db->lock, flags);
> - outl(db->cr7_data, dev->base_addr + DCR7);
> + uw32(DCR7, db->cr7_data);
>
> /* free this SKB */
> dev_kfree_skb(skb);
> @@ -637,9 +664,7 @@ static netdev_tx_t uli526x_start_xmit(struct sk_buff *skb,
> static int uli526x_stop(struct net_device *dev)
> {
> struct uli526x_board_info *db = netdev_priv(dev);
> - unsigned long ioaddr = dev->base_addr;
> -
> - ULI526X_DBUG(0, "uli526x_stop", 0);
> + void __iomem *ioaddr = db->ioaddr;
>
> /* disable system */
> netif_stop_queue(dev);
> @@ -648,12 +673,12 @@ static int uli526x_stop(struct net_device *dev)
> del_timer_sync(&db->timer);
>
> /* Reset & stop ULI526X board */
> - outl(ULI526X_RESET, ioaddr + DCR0);
> + uw32(DCR0, ULI526X_RESET);
> udelay(5);
> - phy_write(db->ioaddr, db->phy_addr, 0, 0x8000, db->chip_id);
> + db->phy.write(db, db->phy_addr, 0, 0x8000);
>
> /* free interrupt */
> - free_irq(dev->irq, dev);
> + free_irq(db->pdev->irq, dev);
>
> /* free allocated rx buffer */
> uli526x_free_rxbuffer(db);
> @@ -671,18 +696,18 @@ static irqreturn_t uli526x_interrupt(int irq, void *dev_id)
> {
> struct net_device *dev = dev_id;
> struct uli526x_board_info *db = netdev_priv(dev);
> - unsigned long ioaddr = dev->base_addr;
> + void __iomem *ioaddr = db->ioaddr;
> unsigned long flags;
>
> spin_lock_irqsave(&db->lock, flags);
> - outl(0, ioaddr + DCR7);
> + uw32(DCR7, 0);
>
> /* Got ULI526X status */
> - db->cr5_data = inl(ioaddr + DCR5);
> - outl(db->cr5_data, ioaddr + DCR5);
> + db->cr5_data = ur32(DCR5);
> + uw32(DCR5, db->cr5_data);
> if ( !(db->cr5_data & 0x180c1) ) {
> /* Restore CR7 to enable interrupt mask */
> - outl(db->cr7_data, ioaddr + DCR7);
> + uw32(DCR7, db->cr7_data);
> spin_unlock_irqrestore(&db->lock, flags);
> return IRQ_HANDLED;
> }
> @@ -710,7 +735,7 @@ static irqreturn_t uli526x_interrupt(int irq, void *dev_id)
> uli526x_free_tx_pkt(dev, db);
>
> /* Restore CR7 to enable interrupt mask */
> - outl(db->cr7_data, ioaddr + DCR7);
> + uw32(DCR7, db->cr7_data);
>
> spin_unlock_irqrestore(&db->lock, flags);
> return IRQ_HANDLED;
> @@ -719,8 +744,10 @@ static irqreturn_t uli526x_interrupt(int irq, void *dev_id)
> #ifdef CONFIG_NET_POLL_CONTROLLER
> static void uli526x_poll(struct net_device *dev)
> {
> + struct uli526x_board_info *db = netdev_priv(dev);
> +
> /* ISR grabs the irqsave lock, so this should be safe */
> - uli526x_interrupt(dev->irq, dev);
> + uli526x_interrupt(db->pdev->irq, dev);
> }
> #endif
>
> @@ -954,12 +981,7 @@ static void netdev_get_drvinfo(struct net_device *dev,
>
> strlcpy(info->driver, DRV_NAME, sizeof(info->driver));
> strlcpy(info->version, DRV_VERSION, sizeof(info->version));
> - if (np->pdev)
> - strlcpy(info->bus_info, pci_name(np->pdev),
> - sizeof(info->bus_info));
> - else
> - sprintf(info->bus_info, "EISA 0x%lx %d",
> - dev->base_addr, dev->irq);
> + strlcpy(info->bus_info, pci_name(np->pdev), sizeof(info->bus_info));
> }
>
> static int netdev_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) {
> @@ -999,18 +1021,20 @@ static const struct ethtool_ops netdev_ethtool_ops = {
>
> static void uli526x_timer(unsigned long data)
> {
> - u32 tmp_cr8;
> - unsigned char tmp_cr12=0;
> struct net_device *dev = (struct net_device *) data;
> struct uli526x_board_info *db = netdev_priv(dev);
> + struct uli_phy_ops *phy = &db->phy;
> + void __iomem *ioaddr = db->ioaddr;
> unsigned long flags;
> + u8 tmp_cr12 = 0;
> + u32 tmp_cr8;
>
> //ULI526X_DBUG(0, "uli526x_timer()", 0);
> spin_lock_irqsave(&db->lock, flags);
>
>
> /* Dynamic reset ULI526X : system error or transmit time-out */
> - tmp_cr8 = inl(db->ioaddr + DCR8);
> + tmp_cr8 = ur32(DCR8);
> if ( (db->interval_rx_cnt==0) && (tmp_cr8) ) {
> db->reset_cr8++;
> db->wait_reset = 1;
> @@ -1020,7 +1044,7 @@ static void uli526x_timer(unsigned long data)
> /* TX polling kick monitor */
> if ( db->tx_packet_cnt &&
> time_after(jiffies, dev_trans_start(dev) + ULI526X_TX_KICK) ) {
> - outl(0x1, dev->base_addr + DCR1); // Tx polling again
> + uw32(DCR1, 0x1); // Tx polling again
>
> // TX Timeout
> if ( time_after(jiffies, dev_trans_start(dev) + ULI526X_TX_TIMEOUT) ) {
> @@ -1041,7 +1065,7 @@ static void uli526x_timer(unsigned long data)
> }
>
> /* Link status check, Dynamic media type change */
> - if((phy_read(db->ioaddr, db->phy_addr, 5, db->chip_id) & 0x01e0)!=0)
> + if ((phy->read(db, db->phy_addr, 5) & 0x01e0)!=0)
> tmp_cr12 = 3;
>
> if ( !(tmp_cr12 & 0x3) && !db->link_failed ) {
> @@ -1054,7 +1078,7 @@ static void uli526x_timer(unsigned long data)
> /* For Force 10/100M Half/Full mode: Enable Auto-Nego mode */
> /* AUTO don't need */
> if ( !(db->media_mode & 0x8) )
> - phy_write(db->ioaddr, db->phy_addr, 0, 0x1000, db->chip_id);
> + phy->write(db, db->phy_addr, 0, 0x1000);
>
> /* AUTO mode, if INT phyxcer link failed, select EXT device */
> if (db->media_mode & ULI526X_AUTO) {
> @@ -1111,12 +1135,13 @@ static void uli526x_timer(unsigned long data)
> static void uli526x_reset_prepare(struct net_device *dev)
> {
> struct uli526x_board_info *db = netdev_priv(dev);
> + void __iomem *ioaddr = db->ioaddr;
>
> /* Sopt MAC controller */
> db->cr6_data &= ~(CR6_RXSC | CR6_TXSC); /* Disable Tx/Rx */
> - update_cr6(db->cr6_data, dev->base_addr);
> - outl(0, dev->base_addr + DCR7); /* Disable Interrupt */
> - outl(inl(dev->base_addr + DCR5), dev->base_addr + DCR5);
> + update_cr6(db->cr6_data, ioaddr);
> + uw32(DCR7, 0); /* Disable Interrupt */
> + uw32(DCR5, ur32(DCR5));
>
> /* Disable upper layer interface */
> netif_stop_queue(dev);
> @@ -1281,7 +1306,7 @@ static void uli526x_reuse_skb(struct uli526x_board_info *db, struct sk_buff * sk
> * Using Chain structure, and allocate Tx/Rx buffer
> */
>
> -static void uli526x_descriptor_init(struct net_device *dev, unsigned long ioaddr)
> +static void uli526x_descriptor_init(struct net_device *dev, void __iomem *ioaddr)
> {
> struct uli526x_board_info *db = netdev_priv(dev);
> struct tx_desc *tmp_tx;
> @@ -1296,14 +1321,14 @@ static void uli526x_descriptor_init(struct net_device *dev, unsigned long ioaddr
> /* tx descriptor start pointer */
> db->tx_insert_ptr = db->first_tx_desc;
> db->tx_remove_ptr = db->first_tx_desc;
> - outl(db->first_tx_desc_dma, ioaddr + DCR4); /* TX DESC address */
> + uw32(DCR4, db->first_tx_desc_dma); /* TX DESC address */
>
> /* rx descriptor start pointer */
> db->first_rx_desc = (void *)db->first_tx_desc + sizeof(struct tx_desc) * TX_DESC_CNT;
> db->first_rx_desc_dma = db->first_tx_desc_dma + sizeof(struct tx_desc) * TX_DESC_CNT;
> db->rx_insert_ptr = db->first_rx_desc;
> db->rx_ready_ptr = db->first_rx_desc;
> - outl(db->first_rx_desc_dma, ioaddr + DCR3); /* RX DESC address */
> + uw32(DCR3, db->first_rx_desc_dma); /* RX DESC address */
>
> /* Init Transmit chain */
> tmp_buf = db->buf_pool_start;
> @@ -1344,11 +1369,9 @@ static void uli526x_descriptor_init(struct net_device *dev, unsigned long ioaddr
> * Update CR6 value
> * Firstly stop ULI526X, then written value and start
> */
> -
> -static void update_cr6(u32 cr6_data, unsigned long ioaddr)
> +static void update_cr6(u32 cr6_data, void __iomem *ioaddr)
> {
> -
> - outl(cr6_data, ioaddr + DCR6);
> + uw32(DCR6, cr6_data);
> udelay(5);
> }
>
> @@ -1367,6 +1390,7 @@ static void update_cr6(u32 cr6_data, unsigned long ioaddr)
> static void send_filter_frame(struct net_device *dev, int mc_cnt)
> {
> struct uli526x_board_info *db = netdev_priv(dev);
> + void __iomem *ioaddr = db->ioaddr;
> struct netdev_hw_addr *ha;
> struct tx_desc *txptr;
> u16 * addrptr;
> @@ -1412,9 +1436,9 @@ static void send_filter_frame(struct net_device *dev, int mc_cnt)
> /* Resource Empty */
> db->tx_packet_cnt++;
> txptr->tdes0 = cpu_to_le32(0x80000000);
> - update_cr6(db->cr6_data | 0x2000, dev->base_addr);
> - outl(0x1, dev->base_addr + DCR1); /* Issue Tx polling */
> - update_cr6(db->cr6_data, dev->base_addr);
> + update_cr6(db->cr6_data | 0x2000, ioaddr);
> + uw32(DCR1, 0x1); /* Issue Tx polling */
> + update_cr6(db->cr6_data, ioaddr);
> dev->trans_start = jiffies;
> } else
> netdev_err(dev, "No Tx resource - Send_filter_frame!\n");
> @@ -1457,37 +1481,38 @@ static void allocate_rx_buffer(struct net_device *dev)
> * Read one word data from the serial ROM
> */
>
> -static u16 read_srom_word(long ioaddr, int offset)
> +static u16 read_srom_word(struct uli526x_board_info *db, int offset)
> {
> - int i;
> + void __iomem *ioaddr = db->ioaddr;
> u16 srom_data = 0;
> - long cr9_ioaddr = ioaddr + DCR9;
> + int i;
>
> - outl(CR9_SROM_READ, cr9_ioaddr);
> - outl(CR9_SROM_READ | CR9_SRCS, cr9_ioaddr);
> + uw32(DCR9, CR9_SROM_READ);
> + uw32(DCR9, CR9_SROM_READ | CR9_SRCS);
>
> /* Send the Read Command 110b */
> - SROM_CLK_WRITE(SROM_DATA_1, cr9_ioaddr);
> - SROM_CLK_WRITE(SROM_DATA_1, cr9_ioaddr);
> - SROM_CLK_WRITE(SROM_DATA_0, cr9_ioaddr);
> + srom_clk_write(db, SROM_DATA_1);
> + srom_clk_write(db, SROM_DATA_1);
> + srom_clk_write(db, SROM_DATA_0);
>
> /* Send the offset */
> for (i = 5; i >= 0; i--) {
> srom_data = (offset & (1 << i)) ? SROM_DATA_1 : SROM_DATA_0;
> - SROM_CLK_WRITE(srom_data, cr9_ioaddr);
> + srom_clk_write(db, srom_data);
> }
>
> - outl(CR9_SROM_READ | CR9_SRCS, cr9_ioaddr);
> + uw32(DCR9, CR9_SROM_READ | CR9_SRCS);
>
> for (i = 16; i > 0; i--) {
> - outl(CR9_SROM_READ | CR9_SRCS | CR9_SRCLK, cr9_ioaddr);
> + uw32(DCR9, CR9_SROM_READ | CR9_SRCS | CR9_SRCLK);
> udelay(5);
> - srom_data = (srom_data << 1) | ((inl(cr9_ioaddr) & CR9_CRDOUT) ? 1 : 0);
> - outl(CR9_SROM_READ | CR9_SRCS, cr9_ioaddr);
> + srom_data = (srom_data << 1) |
> + ((ur32(DCR9) & CR9_CRDOUT) ? 1 : 0);
> + uw32(DCR9, CR9_SROM_READ | CR9_SRCS);
> udelay(5);
> }
>
> - outl(CR9_SROM_READ, cr9_ioaddr);
> + uw32(DCR9, CR9_SROM_READ);
> return srom_data;
> }
>
> @@ -1498,15 +1523,16 @@ static u16 read_srom_word(long ioaddr, int offset)
>
> static u8 uli526x_sense_speed(struct uli526x_board_info * db)
> {
> + struct uli_phy_ops *phy = &db->phy;
> u8 ErrFlag = 0;
> u16 phy_mode;
>
> - phy_mode = phy_read(db->ioaddr, db->phy_addr, 1, db->chip_id);
> - phy_mode = phy_read(db->ioaddr, db->phy_addr, 1, db->chip_id);
> + phy_mode = phy->read(db, db->phy_addr, 1);
> + phy_mode = phy->read(db, db->phy_addr, 1);
>
> if ( (phy_mode & 0x24) == 0x24 ) {
>
> - phy_mode = ((phy_read(db->ioaddr, db->phy_addr, 5, db->chip_id) & 0x01e0)<<7);
> + phy_mode = ((phy->read(db, db->phy_addr, 5) & 0x01e0)<<7);
> if(phy_mode&0x8000)
> phy_mode = 0x8000;
> else if(phy_mode&0x4000)
> @@ -1541,10 +1567,11 @@ static u8 uli526x_sense_speed(struct uli526x_board_info * db)
>
> static void uli526x_set_phyxcer(struct uli526x_board_info *db)
> {
> + struct uli_phy_ops *phy = &db->phy;
> u16 phy_reg;
>
> /* Phyxcer capability setting */
> - phy_reg = phy_read(db->ioaddr, db->phy_addr, 4, db->chip_id) & ~0x01e0;
> + phy_reg = phy->read(db, db->phy_addr, 4) & ~0x01e0;
>
> if (db->media_mode & ULI526X_AUTO) {
> /* AUTO Mode */
> @@ -1565,10 +1592,10 @@ static void uli526x_set_phyxcer(struct uli526x_board_info *db)
> phy_reg|=db->PHY_reg4;
> db->media_mode|=ULI526X_AUTO;
> }
> - phy_write(db->ioaddr, db->phy_addr, 4, phy_reg, db->chip_id);
> + phy->write(db, db->phy_addr, 4, phy_reg);
>
> /* Restart Auto-Negotiation */
> - phy_write(db->ioaddr, db->phy_addr, 0, 0x1200, db->chip_id);
> + phy->write(db, db->phy_addr, 0, 0x1200);
> udelay(50);
> }
>
> @@ -1582,6 +1609,7 @@ static void uli526x_set_phyxcer(struct uli526x_board_info *db)
>
> static void uli526x_process_mode(struct uli526x_board_info *db)
> {
> + struct uli_phy_ops *phy = &db->phy;
> u16 phy_reg;
>
> /* Full Duplex Mode Check */
> @@ -1593,10 +1621,10 @@ static void uli526x_process_mode(struct uli526x_board_info *db)
> update_cr6(db->cr6_data, db->ioaddr);
>
> /* 10/100M phyxcer force mode need */
> - if ( !(db->media_mode & 0x8)) {
> + if (!(db->media_mode & 0x8)) {
> /* Forece Mode */
> - phy_reg = phy_read(db->ioaddr, db->phy_addr, 6, db->chip_id);
> - if ( !(phy_reg & 0x1) ) {
> + phy_reg = phy->read(db, db->phy_addr, 6);
> + if (!(phy_reg & 0x1)) {
> /* parter without N-Way capability */
> phy_reg = 0x0;
> switch(db->op_mode) {
> @@ -1605,148 +1633,126 @@ static void uli526x_process_mode(struct uli526x_board_info *db)
> case ULI526X_100MHF: phy_reg = 0x2000; break;
> case ULI526X_100MFD: phy_reg = 0x2100; break;
> }
> - phy_write(db->ioaddr, db->phy_addr, 0, phy_reg, db->chip_id);
> + phy->write(db, db->phy_addr, 0, phy_reg);
> }
> }
> }
>
>
> -/*
> - * Write a word to Phy register
> - */
> -
> -static void phy_write(unsigned long iobase, u8 phy_addr, u8 offset, u16 phy_data, u32 chip_id)
> +/* M5261/M5263 Chip */
> +static void phy_writeby_cr9(struct uli526x_board_info *db, u8 phy_addr,
> + u8 offset, u16 phy_data)
> {
> u16 i;
> - unsigned long ioaddr;
> -
> - if(chip_id == PCI_ULI5263_ID)
> - {
> - phy_writeby_cr10(iobase, phy_addr, offset, phy_data);
> - return;
> - }
> - /* M5261/M5263 Chip */
> - ioaddr = iobase + DCR9;
>
> /* Send 33 synchronization clock to Phy controller */
> for (i = 0; i < 35; i++)
> - phy_write_1bit(ioaddr, PHY_DATA_1, chip_id);
> + phy_write_1bit(db, PHY_DATA_1);
>
> /* Send start command(01) to Phy */
> - phy_write_1bit(ioaddr, PHY_DATA_0, chip_id);
> - phy_write_1bit(ioaddr, PHY_DATA_1, chip_id);
> + phy_write_1bit(db, PHY_DATA_0);
> + phy_write_1bit(db, PHY_DATA_1);
>
> /* Send write command(01) to Phy */
> - phy_write_1bit(ioaddr, PHY_DATA_0, chip_id);
> - phy_write_1bit(ioaddr, PHY_DATA_1, chip_id);
> + phy_write_1bit(db, PHY_DATA_0);
> + phy_write_1bit(db, PHY_DATA_1);
>
> /* Send Phy address */
> for (i = 0x10; i > 0; i = i >> 1)
> - phy_write_1bit(ioaddr, phy_addr & i ? PHY_DATA_1 : PHY_DATA_0, chip_id);
> + phy_write_1bit(db, phy_addr & i ? PHY_DATA_1 : PHY_DATA_0);
>
> /* Send register address */
> for (i = 0x10; i > 0; i = i >> 1)
> - phy_write_1bit(ioaddr, offset & i ? PHY_DATA_1 : PHY_DATA_0, chip_id);
> + phy_write_1bit(db, offset & i ? PHY_DATA_1 : PHY_DATA_0);
>
> /* written trasnition */
> - phy_write_1bit(ioaddr, PHY_DATA_1, chip_id);
> - phy_write_1bit(ioaddr, PHY_DATA_0, chip_id);
> + phy_write_1bit(db, PHY_DATA_1);
> + phy_write_1bit(db, PHY_DATA_0);
>
> /* Write a word data to PHY controller */
> - for ( i = 0x8000; i > 0; i >>= 1)
> - phy_write_1bit(ioaddr, phy_data & i ? PHY_DATA_1 : PHY_DATA_0, chip_id);
> -
> + for (i = 0x8000; i > 0; i >>= 1)
> + phy_write_1bit(db, phy_data & i ? PHY_DATA_1 : PHY_DATA_0);
> }
>
> -
> -/*
> - * Read a word data from phy register
> - */
> -
> -static u16 phy_read(unsigned long iobase, u8 phy_addr, u8 offset, u32 chip_id)
> +static u16 phy_readby_cr9(struct uli526x_board_info *db, u8 phy_addr, u8 offset)
> {
> - int i;
> u16 phy_data;
> - unsigned long ioaddr;
> -
> - if(chip_id == PCI_ULI5263_ID)
> - return phy_readby_cr10(iobase, phy_addr, offset);
> - /* M5261/M5263 Chip */
> - ioaddr = iobase + DCR9;
> + int i;
>
> /* Send 33 synchronization clock to Phy controller */
> for (i = 0; i < 35; i++)
> - phy_write_1bit(ioaddr, PHY_DATA_1, chip_id);
> + phy_write_1bit(db, PHY_DATA_1);
>
> /* Send start command(01) to Phy */
> - phy_write_1bit(ioaddr, PHY_DATA_0, chip_id);
> - phy_write_1bit(ioaddr, PHY_DATA_1, chip_id);
> + phy_write_1bit(db, PHY_DATA_0);
> + phy_write_1bit(db, PHY_DATA_1);
>
> /* Send read command(10) to Phy */
> - phy_write_1bit(ioaddr, PHY_DATA_1, chip_id);
> - phy_write_1bit(ioaddr, PHY_DATA_0, chip_id);
> + phy_write_1bit(db, PHY_DATA_1);
> + phy_write_1bit(db, PHY_DATA_0);
>
> /* Send Phy address */
> for (i = 0x10; i > 0; i = i >> 1)
> - phy_write_1bit(ioaddr, phy_addr & i ? PHY_DATA_1 : PHY_DATA_0, chip_id);
> + phy_write_1bit(db, phy_addr & i ? PHY_DATA_1 : PHY_DATA_0);
>
> /* Send register address */
> for (i = 0x10; i > 0; i = i >> 1)
> - phy_write_1bit(ioaddr, offset & i ? PHY_DATA_1 : PHY_DATA_0, chip_id);
> + phy_write_1bit(db, offset & i ? PHY_DATA_1 : PHY_DATA_0);
>
> /* Skip transition state */
> - phy_read_1bit(ioaddr, chip_id);
> + phy_read_1bit(db);
>
> /* read 16bit data */
> for (phy_data = 0, i = 0; i < 16; i++) {
> phy_data <<= 1;
> - phy_data |= phy_read_1bit(ioaddr, chip_id);
> + phy_data |= phy_read_1bit(db);
> }
>
> return phy_data;
> }
>
> -static u16 phy_readby_cr10(unsigned long iobase, u8 phy_addr, u8 offset)
> +static u16 phy_readby_cr10(struct uli526x_board_info *db, u8 phy_addr,
> + u8 offset)
> {
> - unsigned long ioaddr,cr10_value;
> + void __iomem *ioaddr = db->ioaddr;
> + u32 cr10_value = phy_addr;
>
> - ioaddr = iobase + DCR10;
> - cr10_value = phy_addr;
> - cr10_value = (cr10_value<<5) + offset;
> - cr10_value = (cr10_value<<16) + 0x08000000;
> - outl(cr10_value,ioaddr);
> + cr10_value = (cr10_value << 5) + offset;
> + cr10_value = (cr10_value << 16) + 0x08000000;
> + uw32(DCR10, cr10_value);
> udelay(1);
> - while(1)
> - {
> - cr10_value = inl(ioaddr);
> - if(cr10_value&0x10000000)
> + while (1) {
> + cr10_value = ur32(DCR10);
> + if (cr10_value & 0x10000000)
> break;
> }
> return cr10_value & 0x0ffff;
> }
>
> -static void phy_writeby_cr10(unsigned long iobase, u8 phy_addr, u8 offset, u16 phy_data)
> +static void phy_writeby_cr10(struct uli526x_board_info *db, u8 phy_addr,
> + u8 offset, u16 phy_data)
> {
> - unsigned long ioaddr,cr10_value;
> + void __iomem *ioaddr = db->ioaddr;
> + u32 cr10_value = phy_addr;
>
> - ioaddr = iobase + DCR10;
> - cr10_value = phy_addr;
> - cr10_value = (cr10_value<<5) + offset;
> - cr10_value = (cr10_value<<16) + 0x04000000 + phy_data;
> - outl(cr10_value,ioaddr);
> + cr10_value = (cr10_value << 5) + offset;
> + cr10_value = (cr10_value << 16) + 0x04000000 + phy_data;
> + uw32(DCR10, cr10_value);
> udelay(1);
> }
> /*
> * Write one bit data to Phy Controller
> */
>
> -static void phy_write_1bit(unsigned long ioaddr, u32 phy_data, u32 chip_id)
> +static void phy_write_1bit(struct uli526x_board_info *db, u32 data)
> {
> - outl(phy_data , ioaddr); /* MII Clock Low */
> + void __iomem *ioaddr = db->ioaddr;
> +
> + uw32(DCR9, data); /* MII Clock Low */
> udelay(1);
> - outl(phy_data | MDCLKH, ioaddr); /* MII Clock High */
> + uw32(DCR9, data | MDCLKH); /* MII Clock High */
> udelay(1);
> - outl(phy_data , ioaddr); /* MII Clock Low */
> + uw32(DCR9, data); /* MII Clock Low */
> udelay(1);
> }
>
> @@ -1755,14 +1761,15 @@ static void phy_write_1bit(unsigned long ioaddr, u32 phy_data, u32 chip_id)
> * Read one bit phy data from PHY controller
> */
>
> -static u16 phy_read_1bit(unsigned long ioaddr, u32 chip_id)
> +static u16 phy_read_1bit(struct uli526x_board_info *db)
> {
> + void __iomem *ioaddr = db->ioaddr;
> u16 phy_data;
>
> - outl(0x50000 , ioaddr);
> + uw32(DCR9, 0x50000);
> udelay(1);
> - phy_data = ( inl(ioaddr) >> 19 ) & 0x1;
> - outl(0x40000 , ioaddr);
> + phy_data = (ur32(DCR9) >> 19) & 0x1;
> + uw32(DCR9, 0x40000);
> udelay(1);
>
> return phy_data;
> --
> 1.7.7.6
>
^ permalink raw reply
* Re: [RFC] net/hsr: Add support for IEC 62439-3 High-availability Seamless Redundancy
From: David Miller @ 2012-04-06 16:43 UTC (permalink / raw)
To: arvid.brodin; +Cc: shemminger, netdev, balferreira, arvid.brodin
In-Reply-To: <4F7F10FC.3020308@enea.com>
From: Arvid Brodin <arvid.brodin@enea.com>
Date: Fri, 6 Apr 2012 17:51:24 +0200
> Just out of curiosity, what's the mechanism behind this inline
> assignment that turns the memcpy into an unaligned access? If gcc is
> "smart" enough to detect a bunch of char * accesses and turn them
> into unaligned 32-bit accesses, isn't that a bug in gcc?
It's not doing it with "char *", it's doing it with other types like
the type of the ICMP header in this case.
memcpy is expanded by the compiler internally into __builtin_memcpy()
which if it sees the length is reasonably short will inline the
copy. And subsequently it uses the alignment of the types involved
to determine what kinds of loads and stores it can use in that
inline memcpy().
So the result is that just because in your case with your compiler
it doesn't get expanded inline and fault, it doesn't mean it won't
for someone else.
You're just lucky, and you really haven't fixed the bug.
^ permalink raw reply
* Re: [PATCH net-next #2 25/39] xircom_cb: stop using net_device.{base_addr, irq} and convert to __iomem.
From: Grant Grundler @ 2012-04-06 16:42 UTC (permalink / raw)
To: Francois Romieu; +Cc: netdev, David Miller, Grant Grundler
In-Reply-To: <d8cb2b1097a9c64778dc1ab9bb33bcf5bf62bfc7.1333704409.git.romieu@fr.zoreil.com>
On Fri, Apr 6, 2012 at 3:06 AM, Francois Romieu <romieu@fr.zoreil.com> wrote:
> Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
> Cc: Grant Grundler <grundler@parisc-linux.org>
Acked-by: Grant Grundler <grundler@parisc-linux.org>
Similar to dmfe driver, possible MMIO write/udelay issue that can be
fixed later if the device actually offers MMIO registers.
(I'm looking at the hunk in initialize_card()).
Note that udelay() is just the easier-to-find case where posted writes
can cause problems. Other cases include disabling part of the chip
(e.g. receive engine) but the MMIO write is posted and the engine
isn't actually disabled until "much later". This is a problem if the
next section of code depends on chip being disabled and (for example)
starts tearing down or rebuilding shared memory
(dma_alloc_consistent).
To be clear, I don't see any "real bug" - just potential issues.
That's why I'd rather see this patch go in and address the potential
issues in a future patch.
thanks,
grant
> ---
> drivers/net/ethernet/dec/tulip/xircom_cb.c | 227 +++++++++++++++-------------
> 1 files changed, 124 insertions(+), 103 deletions(-)
>
> diff --git a/drivers/net/ethernet/dec/tulip/xircom_cb.c b/drivers/net/ethernet/dec/tulip/xircom_cb.c
> index cbcc6d6..138bf83 100644
> --- a/drivers/net/ethernet/dec/tulip/xircom_cb.c
> +++ b/drivers/net/ethernet/dec/tulip/xircom_cb.c
> @@ -41,7 +41,9 @@ MODULE_DESCRIPTION("Xircom Cardbus ethernet driver");
> MODULE_AUTHOR("Arjan van de Ven <arjanv@redhat.com>");
> MODULE_LICENSE("GPL");
>
> -
> +#define xw32(reg, val) iowrite32(val, ioaddr + (reg))
> +#define xr32(reg) ioread32(ioaddr + (reg))
> +#define xr8(reg) ioread8(ioaddr + (reg))
>
> /* IO registers on the card, offsets */
> #define CSR0 0x00
> @@ -83,7 +85,7 @@ struct xircom_private {
>
> struct sk_buff *tx_skb[4];
>
> - unsigned long io_port;
> + void __iomem *ioaddr;
> int open;
>
> /* transmit_used is the rotating counter that indicates which transmit
> @@ -137,7 +139,7 @@ static int link_status(struct xircom_private *card);
>
>
> static DEFINE_PCI_DEVICE_TABLE(xircom_pci_table) = {
> - {0x115D, 0x0003, PCI_ANY_ID, PCI_ANY_ID,},
> + { PCI_VDEVICE(XIRCOM, 0x0003), },
> {0,},
> };
> MODULE_DEVICE_TABLE(pci, xircom_pci_table);
> @@ -146,9 +148,7 @@ static struct pci_driver xircom_ops = {
> .name = "xircom_cb",
> .id_table = xircom_pci_table,
> .probe = xircom_probe,
> - .remove = xircom_remove,
> - .suspend =NULL,
> - .resume =NULL
> + .remove = __devexit_p(xircom_remove),
> };
>
>
> @@ -253,10 +253,13 @@ static int __devinit xircom_probe(struct pci_dev *pdev, const struct pci_device_
>
> private->dev = dev;
> private->pdev = pdev;
> - private->io_port = pci_resource_start(pdev, 0);
> +
> + /* IO range. */
> + private->ioaddr = pci_iomap(pdev, 0, 0);
> + if (!private->ioaddr)
> + goto reg_fail;
> +
> spin_lock_init(&private->lock);
> - dev->irq = pdev->irq;
> - dev->base_addr = private->io_port;
>
> initialize_card(private);
> read_mac_address(private);
> @@ -268,7 +271,7 @@ static int __devinit xircom_probe(struct pci_dev *pdev, const struct pci_device_
> rc = register_netdev(dev);
> if (rc < 0) {
> pr_err("%s: netdevice registration failed\n", __func__);
> - goto reg_fail;
> + goto err_unmap;
> }
>
> netdev_info(dev, "Xircom cardbus revision %i at irq %i\n",
> @@ -286,6 +289,8 @@ static int __devinit xircom_probe(struct pci_dev *pdev, const struct pci_device_
> out:
> return rc;
>
> +err_unmap:
> + pci_iounmap(pdev, private->ioaddr);
> reg_fail:
> pci_set_drvdata(pdev, NULL);
> dma_free_coherent(d, 8192, private->tx_buffer, private->tx_dma_handle);
> @@ -314,6 +319,7 @@ static void __devexit xircom_remove(struct pci_dev *pdev)
> struct device *d = &pdev->dev;
>
> unregister_netdev(dev);
> + pci_iounmap(pdev, card->ioaddr);
> pci_set_drvdata(pdev, NULL);
> dma_free_coherent(d, 8192, card->tx_buffer, card->tx_dma_handle);
> dma_free_coherent(d, 8192, card->rx_buffer, card->rx_dma_handle);
> @@ -326,11 +332,12 @@ static irqreturn_t xircom_interrupt(int irq, void *dev_instance)
> {
> struct net_device *dev = (struct net_device *) dev_instance;
> struct xircom_private *card = netdev_priv(dev);
> + void __iomem *ioaddr = card->ioaddr;
> unsigned int status;
> int i;
>
> spin_lock(&card->lock);
> - status = inl(card->io_port+CSR5);
> + status = xr32(CSR5);
>
> #if defined DEBUG && DEBUG > 1
> print_binary(status);
> @@ -360,7 +367,7 @@ static irqreturn_t xircom_interrupt(int irq, void *dev_instance)
> /* Clear all remaining interrupts */
> status |= 0xffffffff; /* FIXME: make this clear only the
> real existing bits */
> - outl(status,card->io_port+CSR5);
> + xw32(CSR5, status);
>
>
> for (i=0;i<NUMDESCRIPTORS;i++)
> @@ -438,11 +445,11 @@ static netdev_tx_t xircom_start_xmit(struct sk_buff *skb,
> static int xircom_open(struct net_device *dev)
> {
> struct xircom_private *xp = netdev_priv(dev);
> + const int irq = xp->pdev->irq;
> int retval;
>
> - netdev_info(dev, "xircom cardbus adaptor found, using irq %i\n",
> - dev->irq);
> - retval = request_irq(dev->irq, xircom_interrupt, IRQF_SHARED, dev->name, dev);
> + netdev_info(dev, "xircom cardbus adaptor found, using irq %i\n", irq);
> + retval = request_irq(irq, xircom_interrupt, IRQF_SHARED, dev->name, dev);
> if (retval)
> return retval;
>
> @@ -474,7 +481,7 @@ static int xircom_close(struct net_device *dev)
> spin_unlock_irqrestore(&card->lock,flags);
>
> card->open = 0;
> - free_irq(dev->irq,dev);
> + free_irq(card->pdev->irq, dev);
>
> return 0;
>
> @@ -484,35 +491,39 @@ static int xircom_close(struct net_device *dev)
> #ifdef CONFIG_NET_POLL_CONTROLLER
> static void xircom_poll_controller(struct net_device *dev)
> {
> - disable_irq(dev->irq);
> - xircom_interrupt(dev->irq, dev);
> - enable_irq(dev->irq);
> + struct xircom_private *xp = netdev_priv(dev);
> + const int irq = xp->pdev->irq;
> +
> + disable_irq(irq);
> + xircom_interrupt(irq, dev);
> + enable_irq(irq);
> }
> #endif
>
>
> static void initialize_card(struct xircom_private *card)
> {
> - unsigned int val;
> + void __iomem *ioaddr = card->ioaddr;
> unsigned long flags;
> + u32 val;
>
> spin_lock_irqsave(&card->lock, flags);
>
> /* First: reset the card */
> - val = inl(card->io_port + CSR0);
> + val = xr32(CSR0);
> val |= 0x01; /* Software reset */
> - outl(val, card->io_port + CSR0);
> + xw32(CSR0, val);
>
> udelay(100); /* give the card some time to reset */
>
> - val = inl(card->io_port + CSR0);
> + val = xr32(CSR0);
> val &= ~0x01; /* disable Software reset */
> - outl(val, card->io_port + CSR0);
> + xw32(CSR0, val);
>
>
> val = 0; /* Value 0x00 is a safe and conservative value
> for the PCI configuration settings */
> - outl(val, card->io_port + CSR0);
> + xw32(CSR0, val);
>
>
> disable_all_interrupts(card);
> @@ -530,10 +541,9 @@ ignored; I chose zero.
> */
> static void trigger_transmit(struct xircom_private *card)
> {
> - unsigned int val;
> + void __iomem *ioaddr = card->ioaddr;
>
> - val = 0;
> - outl(val, card->io_port + CSR1);
> + xw32(CSR1, 0);
> }
>
> /*
> @@ -545,10 +555,9 @@ ignored; I chose zero.
> */
> static void trigger_receive(struct xircom_private *card)
> {
> - unsigned int val;
> + void __iomem *ioaddr = card->ioaddr;
>
> - val = 0;
> - outl(val, card->io_port + CSR2);
> + xw32(CSR2, 0);
> }
>
> /*
> @@ -557,6 +566,7 @@ descriptors and programs the addresses into the card.
> */
> static void setup_descriptors(struct xircom_private *card)
> {
> + void __iomem *ioaddr = card->ioaddr;
> u32 address;
> int i;
>
> @@ -586,7 +596,7 @@ static void setup_descriptors(struct xircom_private *card)
> wmb();
> /* Write the receive descriptor ring address to the card */
> address = card->rx_dma_handle;
> - outl(address, card->io_port + CSR3); /* Receive descr list address */
> + xw32(CSR3, address); /* Receive descr list address */
>
>
> /* transmit descriptors */
> @@ -611,7 +621,7 @@ static void setup_descriptors(struct xircom_private *card)
> wmb();
> /* wite the transmit descriptor ring to the card */
> address = card->tx_dma_handle;
> - outl(address, card->io_port + CSR4); /* xmit descr list address */
> + xw32(CSR4, address); /* xmit descr list address */
> }
>
> /*
> @@ -620,11 +630,12 @@ valid by setting the address in the card to 0x00.
> */
> static void remove_descriptors(struct xircom_private *card)
> {
> + void __iomem *ioaddr = card->ioaddr;
> unsigned int val;
>
> val = 0;
> - outl(val, card->io_port + CSR3); /* Receive descriptor address */
> - outl(val, card->io_port + CSR4); /* Send descriptor address */
> + xw32(CSR3, val); /* Receive descriptor address */
> + xw32(CSR4, val); /* Send descriptor address */
> }
>
> /*
> @@ -635,17 +646,17 @@ This function also clears the status-bit.
> */
> static int link_status_changed(struct xircom_private *card)
> {
> + void __iomem *ioaddr = card->ioaddr;
> unsigned int val;
>
> - val = inl(card->io_port + CSR5); /* Status register */
> -
> - if ((val & (1 << 27)) == 0) /* no change */
> + val = xr32(CSR5); /* Status register */
> + if (!(val & (1 << 27))) /* no change */
> return 0;
>
> /* clear the event by writing a 1 to the bit in the
> status register. */
> val = (1 << 27);
> - outl(val, card->io_port + CSR5);
> + xw32(CSR5, val);
>
> return 1;
> }
> @@ -657,11 +668,9 @@ in a non-stopped state.
> */
> static int transmit_active(struct xircom_private *card)
> {
> - unsigned int val;
> + void __iomem *ioaddr = card->ioaddr;
>
> - val = inl(card->io_port + CSR5); /* Status register */
> -
> - if ((val & (7 << 20)) == 0) /* transmitter disabled */
> + if (!(xr32(CSR5) & (7 << 20))) /* transmitter disabled */
> return 0;
>
> return 1;
> @@ -673,11 +682,9 @@ in a non-stopped state.
> */
> static int receive_active(struct xircom_private *card)
> {
> - unsigned int val;
> -
> - val = inl(card->io_port + CSR5); /* Status register */
> + void __iomem *ioaddr = card->ioaddr;
>
> - if ((val & (7 << 17)) == 0) /* receiver disabled */
> + if (!(xr32(CSR5) & (7 << 17))) /* receiver disabled */
> return 0;
>
> return 1;
> @@ -695,10 +702,11 @@ must be called with the lock held and interrupts disabled.
> */
> static void activate_receiver(struct xircom_private *card)
> {
> + void __iomem *ioaddr = card->ioaddr;
> unsigned int val;
> int counter;
>
> - val = inl(card->io_port + CSR6); /* Operation mode */
> + val = xr32(CSR6); /* Operation mode */
>
> /* If the "active" bit is set and the receiver is already
> active, no need to do the expensive thing */
> @@ -707,7 +715,7 @@ static void activate_receiver(struct xircom_private *card)
>
>
> val = val & ~2; /* disable the receiver */
> - outl(val, card->io_port + CSR6);
> + xw32(CSR6, val);
>
> counter = 10;
> while (counter > 0) {
> @@ -721,9 +729,9 @@ static void activate_receiver(struct xircom_private *card)
> }
>
> /* enable the receiver */
> - val = inl(card->io_port + CSR6); /* Operation mode */
> - val = val | 2; /* enable the receiver */
> - outl(val, card->io_port + CSR6);
> + val = xr32(CSR6); /* Operation mode */
> + val = val | 2; /* enable the receiver */
> + xw32(CSR6, val);
>
> /* now wait for the card to activate again */
> counter = 10;
> @@ -748,12 +756,13 @@ must be called with the lock held and interrupts disabled.
> */
> static void deactivate_receiver(struct xircom_private *card)
> {
> + void __iomem *ioaddr = card->ioaddr;
> unsigned int val;
> int counter;
>
> - val = inl(card->io_port + CSR6); /* Operation mode */
> - val = val & ~2; /* disable the receiver */
> - outl(val, card->io_port + CSR6);
> + val = xr32(CSR6); /* Operation mode */
> + val = val & ~2; /* disable the receiver */
> + xw32(CSR6, val);
>
> counter = 10;
> while (counter > 0) {
> @@ -780,10 +789,11 @@ must be called with the lock held and interrupts disabled.
> */
> static void activate_transmitter(struct xircom_private *card)
> {
> + void __iomem *ioaddr = card->ioaddr;
> unsigned int val;
> int counter;
>
> - val = inl(card->io_port + CSR6); /* Operation mode */
> + val = xr32(CSR6); /* Operation mode */
>
> /* If the "active" bit is set and the receiver is already
> active, no need to do the expensive thing */
> @@ -791,7 +801,7 @@ static void activate_transmitter(struct xircom_private *card)
> return;
>
> val = val & ~(1 << 13); /* disable the transmitter */
> - outl(val, card->io_port + CSR6);
> + xw32(CSR6, val);
>
> counter = 10;
> while (counter > 0) {
> @@ -806,9 +816,9 @@ static void activate_transmitter(struct xircom_private *card)
> }
>
> /* enable the transmitter */
> - val = inl(card->io_port + CSR6); /* Operation mode */
> + val = xr32(CSR6); /* Operation mode */
> val = val | (1 << 13); /* enable the transmitter */
> - outl(val, card->io_port + CSR6);
> + xw32(CSR6, val);
>
> /* now wait for the card to activate again */
> counter = 10;
> @@ -833,12 +843,13 @@ must be called with the lock held and interrupts disabled.
> */
> static void deactivate_transmitter(struct xircom_private *card)
> {
> + void __iomem *ioaddr = card->ioaddr;
> unsigned int val;
> int counter;
>
> - val = inl(card->io_port + CSR6); /* Operation mode */
> + val = xr32(CSR6); /* Operation mode */
> val = val & ~2; /* disable the transmitter */
> - outl(val, card->io_port + CSR6);
> + xw32(CSR6, val);
>
> counter = 20;
> while (counter > 0) {
> @@ -861,11 +872,12 @@ must be called with the lock held and interrupts disabled.
> */
> static void enable_transmit_interrupt(struct xircom_private *card)
> {
> + void __iomem *ioaddr = card->ioaddr;
> unsigned int val;
>
> - val = inl(card->io_port + CSR7); /* Interrupt enable register */
> - val |= 1; /* enable the transmit interrupt */
> - outl(val, card->io_port + CSR7);
> + val = xr32(CSR7); /* Interrupt enable register */
> + val |= 1; /* enable the transmit interrupt */
> + xw32(CSR7, val);
> }
>
>
> @@ -876,11 +888,12 @@ must be called with the lock held and interrupts disabled.
> */
> static void enable_receive_interrupt(struct xircom_private *card)
> {
> + void __iomem *ioaddr = card->ioaddr;
> unsigned int val;
>
> - val = inl(card->io_port + CSR7); /* Interrupt enable register */
> - val = val | (1 << 6); /* enable the receive interrupt */
> - outl(val, card->io_port + CSR7);
> + val = xr32(CSR7); /* Interrupt enable register */
> + val = val | (1 << 6); /* enable the receive interrupt */
> + xw32(CSR7, val);
> }
>
> /*
> @@ -890,11 +903,12 @@ must be called with the lock held and interrupts disabled.
> */
> static void enable_link_interrupt(struct xircom_private *card)
> {
> + void __iomem *ioaddr = card->ioaddr;
> unsigned int val;
>
> - val = inl(card->io_port + CSR7); /* Interrupt enable register */
> - val = val | (1 << 27); /* enable the link status chage interrupt */
> - outl(val, card->io_port + CSR7);
> + val = xr32(CSR7); /* Interrupt enable register */
> + val = val | (1 << 27); /* enable the link status chage interrupt */
> + xw32(CSR7, val);
> }
>
>
> @@ -906,10 +920,9 @@ must be called with the lock held and interrupts disabled.
> */
> static void disable_all_interrupts(struct xircom_private *card)
> {
> - unsigned int val;
> + void __iomem *ioaddr = card->ioaddr;
>
> - val = 0; /* disable all interrupts */
> - outl(val, card->io_port + CSR7);
> + xw32(CSR7, 0);
> }
>
> /*
> @@ -919,9 +932,10 @@ must be called with the lock held and interrupts disabled.
> */
> static void enable_common_interrupts(struct xircom_private *card)
> {
> + void __iomem *ioaddr = card->ioaddr;
> unsigned int val;
>
> - val = inl(card->io_port + CSR7); /* Interrupt enable register */
> + val = xr32(CSR7); /* Interrupt enable register */
> val |= (1<<16); /* Normal Interrupt Summary */
> val |= (1<<15); /* Abnormal Interrupt Summary */
> val |= (1<<13); /* Fatal bus error */
> @@ -930,7 +944,7 @@ static void enable_common_interrupts(struct xircom_private *card)
> val |= (1<<5); /* Transmit Underflow */
> val |= (1<<2); /* Transmit Buffer Unavailable */
> val |= (1<<1); /* Transmit Process Stopped */
> - outl(val, card->io_port + CSR7);
> + xw32(CSR7, val);
> }
>
> /*
> @@ -940,11 +954,12 @@ must be called with the lock held and interrupts disabled.
> */
> static int enable_promisc(struct xircom_private *card)
> {
> + void __iomem *ioaddr = card->ioaddr;
> unsigned int val;
>
> - val = inl(card->io_port + CSR6);
> + val = xr32(CSR6);
> val = val | (1 << 6);
> - outl(val, card->io_port + CSR6);
> + xw32(CSR6, val);
>
> return 1;
> }
> @@ -959,13 +974,16 @@ Must be called in locked state with interrupts disabled
> */
> static int link_status(struct xircom_private *card)
> {
> - unsigned int val;
> + void __iomem *ioaddr = card->ioaddr;
> + u8 val;
>
> - val = inb(card->io_port + CSR12);
> + val = xr8(CSR12);
>
> - if (!(val&(1<<2))) /* bit 2 is 0 for 10mbit link, 1 for not an 10mbit link */
> + /* bit 2 is 0 for 10mbit link, 1 for not an 10mbit link */
> + if (!(val & (1 << 2)))
> return 10;
> - if (!(val&(1<<1))) /* bit 1 is 0 for 100mbit link, 1 for not an 100mbit link */
> + /* bit 1 is 0 for 100mbit link, 1 for not an 100mbit link */
> + if (!(val & (1 << 1)))
> return 100;
>
> /* If we get here -> no link at all */
> @@ -984,29 +1002,31 @@ static int link_status(struct xircom_private *card)
> */
> static void read_mac_address(struct xircom_private *card)
> {
> - unsigned char j, tuple, link, data_id, data_count;
> + void __iomem *ioaddr = card->ioaddr;
> unsigned long flags;
> + u8 link;
> int i;
>
> spin_lock_irqsave(&card->lock, flags);
>
> - outl(1 << 12, card->io_port + CSR9); /* enable boot rom access */
> + xw32(CSR9, 1 << 12); /* enable boot rom access */
> for (i = 0x100; i < 0x1f7; i += link + 2) {
> - outl(i, card->io_port + CSR10);
> - tuple = inl(card->io_port + CSR9) & 0xff;
> - outl(i + 1, card->io_port + CSR10);
> - link = inl(card->io_port + CSR9) & 0xff;
> - outl(i + 2, card->io_port + CSR10);
> - data_id = inl(card->io_port + CSR9) & 0xff;
> - outl(i + 3, card->io_port + CSR10);
> - data_count = inl(card->io_port + CSR9) & 0xff;
> + u8 tuple, data_id, data_count;
> +
> + xw32(CSR10, i);
> + tuple = xr32(CSR9);
> + xw32(CSR10, i + 1);
> + link = xr32(CSR9);
> + xw32(CSR10, i + 2);
> + data_id = xr32(CSR9);
> + xw32(CSR10, i + 3);
> + data_count = xr32(CSR9);
> if ((tuple == 0x22) && (data_id == 0x04) && (data_count == 0x06)) {
> - /*
> - * This is it. We have the data we want.
> - */
> + int j;
> +
> for (j = 0; j < 6; j++) {
> - outl(i + j + 4, card->io_port + CSR10);
> - card->dev->dev_addr[j] = inl(card->io_port + CSR9) & 0xff;
> + xw32(CSR10, i + j + 4);
> + card->dev->dev_addr[j] = xr32(CSR9) & 0xff;
> }
> break;
> } else if (link == 0) {
> @@ -1025,6 +1045,7 @@ static void read_mac_address(struct xircom_private *card)
> */
> static void transceiver_voodoo(struct xircom_private *card)
> {
> + void __iomem *ioaddr = card->ioaddr;
> unsigned long flags;
>
> /* disable all powermanagement */
> @@ -1034,14 +1055,14 @@ static void transceiver_voodoo(struct xircom_private *card)
>
> spin_lock_irqsave(&card->lock, flags);
>
> - outl(0x0008, card->io_port + CSR15);
> - udelay(25);
> - outl(0xa8050000, card->io_port + CSR15);
> - udelay(25);
> - outl(0xa00f0000, card->io_port + CSR15);
> - udelay(25);
> + xw32(CSR15, 0x0008);
> + udelay(25);
> + xw32(CSR15, 0xa8050000);
> + udelay(25);
> + xw32(CSR15, 0xa00f0000);
> + udelay(25);
>
> - spin_unlock_irqrestore(&card->lock, flags);
> + spin_unlock_irqrestore(&card->lock, flags);
>
> netif_start_queue(card->dev);
> }
> --
> 1.7.7.6
>
^ permalink raw reply
* Re: ath: DMA failed to stop in 10 ms AR_CR=0x00000024 AR_DIAG_SW=0x02000020 DMADBG_7=0x00008040
From: Justin P. Mattock @ 2012-04-06 16:40 UTC (permalink / raw)
To: Sujith Manoharan
Cc: Mohammed Shafi, Linux-wireless, Felix Fietkau, linux-kernel,
Linux-netdev
In-Reply-To: <20337.9030.686697.228453@gargle.gargle.HOWL>
On 03/26/2012 07:17 PM, Sujith Manoharan wrote:
> Justin P. Mattock wrote:
>> I would have to say this patch above does get rid of this crash I was
>> seeing. as a quick test I simply connect to a WPA network, then connect
>> to an open network going back and forth triggers this freeze for me
>> after applying this I am able to toggle back and forth without a freeze.
>
> Thanks for verifying.
>
> Sujith
>
From going through the warning message I was playing around and am
looking at: AH_UNPLUGGED .. seems if I remove this from the code I have
not seen this warning message.
is there something wrong with AH_UNPLUGGED = 0x2 ?
is this the wrong address(0x2)?
the patch that I was using is:
From ea8a7d6ecf8b0706f3f0521cd22cc359b20b9373 Mon Sep 17 00:00:00 2001
From: "Justin P. Mattock" <justinmattock@gmail.com>
Date: Sun, 25 Mar 2012 21:53:31 -0700
Subject: [PATCH] ath_test
Signed-off-by: Justin P. Mattock <justinmattock@gmail.com>
---
drivers/net/wireless/ath/ath9k/recv.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/drivers/net/wireless/ath/ath9k/recv.c
b/drivers/net/wireless/ath/ath9k/recv.c
index f4ae3ba..d887cee 100644
--- a/drivers/net/wireless/ath/ath9k/recv.c
+++ b/drivers/net/wireless/ath/ath9k/recv.c
@@ -523,8 +523,7 @@ bool ath_stoprecv(struct ath_softc *sc)
sc->rx.rxlink = NULL;
spin_unlock_bh(&sc->rx.rxbuflock);
- if (!(ah->ah_flags & AH_UNPLUGGED) &&
- unlikely(!stopped)) {
+ if (!(ah->ah_flags) && unlikely(!stopped)) {
ath_err(ath9k_hw_common(sc->sc_ah),
"Could not stop RX, we could be "
"confusing the DMA engine when we start RX up\n");
--
1.7.5.4
let me know what you think!
Justin P. Mattock
^ permalink raw reply related
* Re: [PATCH net-next #2 33/39] dmfe: stop using net_device.{base_addr, irq} and convert to __iomem.
From: Grant Grundler @ 2012-04-06 16:31 UTC (permalink / raw)
To: Francois Romieu; +Cc: netdev, David Miller, Grant Grundler
In-Reply-To: <83b453d5ea2df18d0af1a760e458c5b649415bfd.1333704409.git.romieu@fr.zoreil.com>
On Fri, Apr 6, 2012 at 3:06 AM, Francois Romieu <romieu@fr.zoreil.com> wrote:
> This is a pure PCI driver, no ISA here.
>
> Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
> Cc: Grant Grundler <grundler@parisc-linux.org>
Acked-by: Grant Grundler <grundler@parisc-linux.org>
I want to point out one potential bug below (that can be fixed later
if necessary.)
> ---
> drivers/net/ethernet/dec/tulip/dmfe.c | 295 +++++++++++++++++----------------
> 1 files changed, 153 insertions(+), 142 deletions(-)
>
> diff --git a/drivers/net/ethernet/dec/tulip/dmfe.c b/drivers/net/ethernet/dec/tulip/dmfe.c
> index 1eccf49..0ef5b68 100644
> --- a/drivers/net/ethernet/dec/tulip/dmfe.c
> +++ b/drivers/net/ethernet/dec/tulip/dmfe.c
> @@ -150,6 +150,12 @@
> #define DMFE_TX_TIMEOUT ((3*HZ)/2) /* tx packet time-out time 1.5 s" */
> #define DMFE_TX_KICK (HZ/2) /* tx packet Kick-out time 0.5 s" */
>
> +#define dw32(reg, val) iowrite32(val, ioaddr + (reg))
> +#define dw16(reg, val) iowrite16(val, ioaddr + (reg))
> +#define dr32(reg) ioread32(ioaddr + (reg))
> +#define dr16(reg) ioread16(ioaddr + (reg))
> +#define dr8(reg) ioread8(ioaddr + (reg))
> +
> #define DMFE_DBUG(dbug_now, msg, value) \
> do { \
> if (dmfe_debug || (dbug_now)) \
> @@ -178,14 +184,6 @@
>
> #define SROM_V41_CODE 0x14
>
> -#define SROM_CLK_WRITE(data, ioaddr) \
> - outl(data|CR9_SROM_READ|CR9_SRCS,ioaddr); \
> - udelay(5); \
> - outl(data|CR9_SROM_READ|CR9_SRCS|CR9_SRCLK,ioaddr); \
> - udelay(5); \
> - outl(data|CR9_SROM_READ|CR9_SRCS,ioaddr); \
> - udelay(5);
> -
> #define __CHK_IO_SIZE(pci_id, dev_rev) \
> (( ((pci_id)==PCI_DM9132_ID) || ((dev_rev) >= 0x30) ) ? \
> DM9102A_IO_SIZE: DM9102_IO_SIZE)
> @@ -213,11 +211,11 @@ struct rx_desc {
> struct dmfe_board_info {
> u32 chip_id; /* Chip vendor/Device ID */
> u8 chip_revision; /* Chip revision */
> - struct DEVICE *next_dev; /* next device */
> + struct net_device *next_dev; /* next device */
> struct pci_dev *pdev; /* PCI device */
> spinlock_t lock;
>
> - long ioaddr; /* I/O base address */
> + void __iomem *ioaddr; /* I/O base address */
> u32 cr0_data;
> u32 cr5_data;
> u32 cr6_data;
> @@ -320,20 +318,20 @@ static netdev_tx_t dmfe_start_xmit(struct sk_buff *, struct DEVICE *);
> static int dmfe_stop(struct DEVICE *);
> static void dmfe_set_filter_mode(struct DEVICE *);
> static const struct ethtool_ops netdev_ethtool_ops;
> -static u16 read_srom_word(long ,int);
> +static u16 read_srom_word(void __iomem *, int);
> static irqreturn_t dmfe_interrupt(int , void *);
> #ifdef CONFIG_NET_POLL_CONTROLLER
> static void poll_dmfe (struct net_device *dev);
> #endif
> -static void dmfe_descriptor_init(struct net_device *, unsigned long);
> +static void dmfe_descriptor_init(struct net_device *);
> static void allocate_rx_buffer(struct net_device *);
> -static void update_cr6(u32, unsigned long);
> +static void update_cr6(u32, void __iomem *);
> static void send_filter_frame(struct DEVICE *);
> static void dm9132_id_table(struct DEVICE *);
> -static u16 phy_read(unsigned long, u8, u8, u32);
> -static void phy_write(unsigned long, u8, u8, u16, u32);
> -static void phy_write_1bit(unsigned long, u32);
> -static u16 phy_read_1bit(unsigned long);
> +static u16 phy_read(void __iomem *, u8, u8, u32);
> +static void phy_write(void __iomem *, u8, u8, u16, u32);
> +static void phy_write_1bit(void __iomem *, u32);
> +static u16 phy_read_1bit(void __iomem *);
> static u8 dmfe_sense_speed(struct dmfe_board_info *);
> static void dmfe_process_mode(struct dmfe_board_info *);
> static void dmfe_timer(unsigned long);
> @@ -462,14 +460,16 @@ static int __devinit dmfe_init_one (struct pci_dev *pdev,
> db->buf_pool_dma_start = db->buf_pool_dma_ptr;
>
> db->chip_id = ent->driver_data;
> - db->ioaddr = pci_resource_start(pdev, 0);
> + /* IO type range. */
> + db->ioaddr = pci_iomap(pdev, 0, 0);
> + if (!db->ioaddr)
> + goto err_out_free_buf;
> +
> db->chip_revision = pdev->revision;
> db->wol_mode = 0;
>
> db->pdev = pdev;
>
> - dev->base_addr = db->ioaddr;
> - dev->irq = pdev->irq;
> pci_set_drvdata(pdev, dev);
> dev->netdev_ops = &netdev_ops;
> dev->ethtool_ops = &netdev_ethtool_ops;
> @@ -484,9 +484,10 @@ static int __devinit dmfe_init_one (struct pci_dev *pdev,
> db->chip_type = 0;
>
> /* read 64 word srom data */
> - for (i = 0; i < 64; i++)
> + for (i = 0; i < 64; i++) {
> ((__le16 *) db->srom)[i] =
> cpu_to_le16(read_srom_word(db->ioaddr, i));
> + }
>
> /* Set Node address */
> for (i = 0; i < 6; i++)
> @@ -494,16 +495,18 @@ static int __devinit dmfe_init_one (struct pci_dev *pdev,
>
> err = register_netdev (dev);
> if (err)
> - goto err_out_free_buf;
> + goto err_out_unmap;
>
> dev_info(&dev->dev, "Davicom DM%04lx at pci%s, %pM, irq %d\n",
> ent->driver_data >> 16,
> - pci_name(pdev), dev->dev_addr, dev->irq);
> + pci_name(pdev), dev->dev_addr, pdev->irq);
>
> pci_set_master(pdev);
>
> return 0;
>
> +err_out_unmap:
> + pci_iounmap(pdev, db->ioaddr);
> err_out_free_buf:
> pci_free_consistent(pdev, TX_BUF_ALLOC * TX_DESC_CNT + 4,
> db->buf_pool_ptr, db->buf_pool_dma_ptr);
> @@ -532,7 +535,7 @@ static void __devexit dmfe_remove_one (struct pci_dev *pdev)
> if (dev) {
>
> unregister_netdev(dev);
> -
> + pci_iounmap(db->pdev, db->ioaddr);
> pci_free_consistent(db->pdev, sizeof(struct tx_desc) *
> DESC_ALL_CNT + 0x20, db->desc_pool_ptr,
> db->desc_pool_dma_ptr);
> @@ -555,13 +558,13 @@ static void __devexit dmfe_remove_one (struct pci_dev *pdev)
>
> static int dmfe_open(struct DEVICE *dev)
> {
> - int ret;
> struct dmfe_board_info *db = netdev_priv(dev);
> + const int irq = db->pdev->irq;
> + int ret;
>
> DMFE_DBUG(0, "dmfe_open", 0);
>
> - ret = request_irq(dev->irq, dmfe_interrupt,
> - IRQF_SHARED, dev->name, dev);
> + ret = request_irq(irq, dmfe_interrupt, IRQF_SHARED, dev->name, dev);
> if (ret)
> return ret;
>
> @@ -615,14 +618,14 @@ static int dmfe_open(struct DEVICE *dev)
> static void dmfe_init_dm910x(struct DEVICE *dev)
> {
> struct dmfe_board_info *db = netdev_priv(dev);
> - unsigned long ioaddr = db->ioaddr;
> + void __iomem *ioaddr = db->ioaddr;
>
> DMFE_DBUG(0, "dmfe_init_dm910x()", 0);
>
> /* Reset DM910x MAC controller */
> - outl(DM910X_RESET, ioaddr + DCR0); /* RESET MAC */
> + dw32(DCR0, DM910X_RESET); /* RESET MAC */
> udelay(100);
If this driver supports devices that offer MMIO BARs, the dw32()
followed by udelay() won't work the same way outl()/udelay() worked.
See http://www.parisc-linux.org/~grundler/talks/ols_2002/4_3MMIO_is_harder.html
for explanation of problem and how to fix this (It's simple enough).
Ugh..since I wrote "Porting to ZX1" 10 years ago, the link to the tg3
patch is dead (long live bitkeeper!). I think it was this patch:
http://permalink.gmane.org/gmane.linux.kernel.commits.2-4/7007
You might find modeling after this patch to be helpful.
thanks,
grant
> - outl(db->cr0_data, ioaddr + DCR0);
> + dw32(DCR0, db->cr0_data);
> udelay(5);
>
> /* Phy addr : DM910(A)2/DM9132/9801, phy address = 1 */
> @@ -633,12 +636,12 @@ static void dmfe_init_dm910x(struct DEVICE *dev)
> db->media_mode = dmfe_media_mode;
>
> /* RESET Phyxcer Chip by GPR port bit 7 */
> - outl(0x180, ioaddr + DCR12); /* Let bit 7 output port */
> + dw32(DCR12, 0x180); /* Let bit 7 output port */
> if (db->chip_id == PCI_DM9009_ID) {
> - outl(0x80, ioaddr + DCR12); /* Issue RESET signal */
> + dw32(DCR12, 0x80); /* Issue RESET signal */
> mdelay(300); /* Delay 300 ms */
> }
> - outl(0x0, ioaddr + DCR12); /* Clear RESET signal */
> + dw32(DCR12, 0x0); /* Clear RESET signal */
>
> /* Process Phyxcer Media Mode */
> if ( !(db->media_mode & 0x10) ) /* Force 1M mode */
> @@ -649,7 +652,7 @@ static void dmfe_init_dm910x(struct DEVICE *dev)
> db->op_mode = db->media_mode; /* Force Mode */
>
> /* Initialize Transmit/Receive decriptor and CR3/4 */
> - dmfe_descriptor_init(dev, ioaddr);
> + dmfe_descriptor_init(dev);
>
> /* Init CR6 to program DM910x operation */
> update_cr6(db->cr6_data, ioaddr);
> @@ -662,10 +665,10 @@ static void dmfe_init_dm910x(struct DEVICE *dev)
>
> /* Init CR7, interrupt active bit */
> db->cr7_data = CR7_DEFAULT;
> - outl(db->cr7_data, ioaddr + DCR7);
> + dw32(DCR7, db->cr7_data);
>
> /* Init CR15, Tx jabber and Rx watchdog timer */
> - outl(db->cr15_data, ioaddr + DCR15);
> + dw32(DCR15, db->cr15_data);
>
> /* Enable DM910X Tx/Rx function */
> db->cr6_data |= CR6_RXSC | CR6_TXSC | 0x40000;
> @@ -682,6 +685,7 @@ static netdev_tx_t dmfe_start_xmit(struct sk_buff *skb,
> struct DEVICE *dev)
> {
> struct dmfe_board_info *db = netdev_priv(dev);
> + void __iomem *ioaddr = db->ioaddr;
> struct tx_desc *txptr;
> unsigned long flags;
>
> @@ -707,7 +711,7 @@ static netdev_tx_t dmfe_start_xmit(struct sk_buff *skb,
> }
>
> /* Disable NIC interrupt */
> - outl(0, dev->base_addr + DCR7);
> + dw32(DCR7, 0);
>
> /* transmit this packet */
> txptr = db->tx_insert_ptr;
> @@ -721,11 +725,11 @@ static netdev_tx_t dmfe_start_xmit(struct sk_buff *skb,
> if ( (!db->tx_queue_cnt) && (db->tx_packet_cnt < TX_MAX_SEND_CNT) ) {
> txptr->tdes0 = cpu_to_le32(0x80000000); /* Set owner bit */
> db->tx_packet_cnt++; /* Ready to send */
> - outl(0x1, dev->base_addr + DCR1); /* Issue Tx polling */
> + dw32(DCR1, 0x1); /* Issue Tx polling */
> dev->trans_start = jiffies; /* saved time stamp */
> } else {
> db->tx_queue_cnt++; /* queue TX packet */
> - outl(0x1, dev->base_addr + DCR1); /* Issue Tx polling */
> + dw32(DCR1, 0x1); /* Issue Tx polling */
> }
>
> /* Tx resource check */
> @@ -734,7 +738,7 @@ static netdev_tx_t dmfe_start_xmit(struct sk_buff *skb,
>
> /* Restore CR7 to enable interrupt */
> spin_unlock_irqrestore(&db->lock, flags);
> - outl(db->cr7_data, dev->base_addr + DCR7);
> + dw32(DCR7, db->cr7_data);
>
> /* free this SKB */
> dev_kfree_skb(skb);
> @@ -751,7 +755,7 @@ static netdev_tx_t dmfe_start_xmit(struct sk_buff *skb,
> static int dmfe_stop(struct DEVICE *dev)
> {
> struct dmfe_board_info *db = netdev_priv(dev);
> - unsigned long ioaddr = dev->base_addr;
> + void __iomem *ioaddr = db->ioaddr;
>
> DMFE_DBUG(0, "dmfe_stop", 0);
>
> @@ -762,12 +766,12 @@ static int dmfe_stop(struct DEVICE *dev)
> del_timer_sync(&db->timer);
>
> /* Reset & stop DM910X board */
> - outl(DM910X_RESET, ioaddr + DCR0);
> + dw32(DCR0, DM910X_RESET);
> udelay(5);
> - phy_write(db->ioaddr, db->phy_addr, 0, 0x8000, db->chip_id);
> + phy_write(ioaddr, db->phy_addr, 0, 0x8000, db->chip_id);
>
> /* free interrupt */
> - free_irq(dev->irq, dev);
> + free_irq(db->pdev->irq, dev);
>
> /* free allocated rx buffer */
> dmfe_free_rxbuffer(db);
> @@ -794,7 +798,7 @@ static irqreturn_t dmfe_interrupt(int irq, void *dev_id)
> {
> struct DEVICE *dev = dev_id;
> struct dmfe_board_info *db = netdev_priv(dev);
> - unsigned long ioaddr = dev->base_addr;
> + void __iomem *ioaddr = db->ioaddr;
> unsigned long flags;
>
> DMFE_DBUG(0, "dmfe_interrupt()", 0);
> @@ -802,15 +806,15 @@ static irqreturn_t dmfe_interrupt(int irq, void *dev_id)
> spin_lock_irqsave(&db->lock, flags);
>
> /* Got DM910X status */
> - db->cr5_data = inl(ioaddr + DCR5);
> - outl(db->cr5_data, ioaddr + DCR5);
> + db->cr5_data = dr32(DCR5);
> + dw32(DCR5, db->cr5_data);
> if ( !(db->cr5_data & 0xc1) ) {
> spin_unlock_irqrestore(&db->lock, flags);
> return IRQ_HANDLED;
> }
>
> /* Disable all interrupt in CR7 to solve the interrupt edge problem */
> - outl(0, ioaddr + DCR7);
> + dw32(DCR7, 0);
>
> /* Check system status */
> if (db->cr5_data & 0x2000) {
> @@ -838,11 +842,11 @@ static irqreturn_t dmfe_interrupt(int irq, void *dev_id)
> if (db->dm910x_chk_mode & 0x2) {
> db->dm910x_chk_mode = 0x4;
> db->cr6_data |= 0x100;
> - update_cr6(db->cr6_data, db->ioaddr);
> + update_cr6(db->cr6_data, ioaddr);
> }
>
> /* Restore CR7 to enable interrupt mask */
> - outl(db->cr7_data, ioaddr + DCR7);
> + dw32(DCR7, db->cr7_data);
>
> spin_unlock_irqrestore(&db->lock, flags);
> return IRQ_HANDLED;
> @@ -858,11 +862,14 @@ static irqreturn_t dmfe_interrupt(int irq, void *dev_id)
>
> static void poll_dmfe (struct net_device *dev)
> {
> + struct dmfe_board_info *db = netdev_priv(dev);
> + const int irq = db->pdev->irq;
> +
> /* disable_irq here is not very nice, but with the lockless
> interrupt handler we have no other choice. */
> - disable_irq(dev->irq);
> - dmfe_interrupt (dev->irq, dev);
> - enable_irq(dev->irq);
> + disable_irq(irq);
> + dmfe_interrupt (irq, dev);
> + enable_irq(irq);
> }
> #endif
>
> @@ -873,7 +880,7 @@ static void poll_dmfe (struct net_device *dev)
> static void dmfe_free_tx_pkt(struct DEVICE *dev, struct dmfe_board_info * db)
> {
> struct tx_desc *txptr;
> - unsigned long ioaddr = dev->base_addr;
> + void __iomem *ioaddr = db->ioaddr;
> u32 tdes0;
>
> txptr = db->tx_remove_ptr;
> @@ -897,7 +904,7 @@ static void dmfe_free_tx_pkt(struct DEVICE *dev, struct dmfe_board_info * db)
> db->tx_fifo_underrun++;
> if ( !(db->cr6_data & CR6_SFT) ) {
> db->cr6_data = db->cr6_data | CR6_SFT;
> - update_cr6(db->cr6_data, db->ioaddr);
> + update_cr6(db->cr6_data, ioaddr);
> }
> }
> if (tdes0 & 0x0100)
> @@ -924,7 +931,7 @@ static void dmfe_free_tx_pkt(struct DEVICE *dev, struct dmfe_board_info * db)
> txptr->tdes0 = cpu_to_le32(0x80000000); /* Set owner bit */
> db->tx_packet_cnt++; /* Ready to send */
> db->tx_queue_cnt--;
> - outl(0x1, ioaddr + DCR1); /* Issue Tx polling */
> + dw32(DCR1, 0x1); /* Issue Tx polling */
> dev->trans_start = jiffies; /* saved time stamp */
> }
>
> @@ -1087,12 +1094,7 @@ static void dmfe_ethtool_get_drvinfo(struct net_device *dev,
>
> strlcpy(info->driver, DRV_NAME, sizeof(info->driver));
> strlcpy(info->version, DRV_VERSION, sizeof(info->version));
> - if (np->pdev)
> - strlcpy(info->bus_info, pci_name(np->pdev),
> - sizeof(info->bus_info));
> - else
> - sprintf(info->bus_info, "EISA 0x%lx %d",
> - dev->base_addr, dev->irq);
> + strlcpy(info->bus_info, pci_name(np->pdev), sizeof(info->bus_info));
> }
>
> static int dmfe_ethtool_set_wol(struct net_device *dev,
> @@ -1132,10 +1134,11 @@ static const struct ethtool_ops netdev_ethtool_ops = {
>
> static void dmfe_timer(unsigned long data)
> {
> + struct net_device *dev = (struct net_device *)data;
> + struct dmfe_board_info *db = netdev_priv(dev);
> + void __iomem *ioaddr = db->ioaddr;
> u32 tmp_cr8;
> unsigned char tmp_cr12;
> - struct DEVICE *dev = (struct DEVICE *) data;
> - struct dmfe_board_info *db = netdev_priv(dev);
> unsigned long flags;
>
> int link_ok, link_ok_phy;
> @@ -1148,11 +1151,10 @@ static void dmfe_timer(unsigned long data)
> db->first_in_callback = 1;
> if (db->chip_type && (db->chip_id==PCI_DM9102_ID)) {
> db->cr6_data &= ~0x40000;
> - update_cr6(db->cr6_data, db->ioaddr);
> - phy_write(db->ioaddr,
> - db->phy_addr, 0, 0x1000, db->chip_id);
> + update_cr6(db->cr6_data, ioaddr);
> + phy_write(ioaddr, db->phy_addr, 0, 0x1000, db->chip_id);
> db->cr6_data |= 0x40000;
> - update_cr6(db->cr6_data, db->ioaddr);
> + update_cr6(db->cr6_data, ioaddr);
> db->timer.expires = DMFE_TIMER_WUT + HZ * 2;
> add_timer(&db->timer);
> spin_unlock_irqrestore(&db->lock, flags);
> @@ -1167,7 +1169,7 @@ static void dmfe_timer(unsigned long data)
> db->dm910x_chk_mode = 0x4;
>
> /* Dynamic reset DM910X : system error or transmit time-out */
> - tmp_cr8 = inl(db->ioaddr + DCR8);
> + tmp_cr8 = dr32(DCR8);
> if ( (db->interval_rx_cnt==0) && (tmp_cr8) ) {
> db->reset_cr8++;
> db->wait_reset = 1;
> @@ -1177,7 +1179,7 @@ static void dmfe_timer(unsigned long data)
> /* TX polling kick monitor */
> if ( db->tx_packet_cnt &&
> time_after(jiffies, dev_trans_start(dev) + DMFE_TX_KICK) ) {
> - outl(0x1, dev->base_addr + DCR1); /* Tx polling again */
> + dw32(DCR1, 0x1); /* Tx polling again */
>
> /* TX Timeout */
> if (time_after(jiffies, dev_trans_start(dev) + DMFE_TX_TIMEOUT) ) {
> @@ -1200,9 +1202,9 @@ static void dmfe_timer(unsigned long data)
>
> /* Link status check, Dynamic media type change */
> if (db->chip_id == PCI_DM9132_ID)
> - tmp_cr12 = inb(db->ioaddr + DCR9 + 3); /* DM9132 */
> + tmp_cr12 = dr8(DCR9 + 3); /* DM9132 */
> else
> - tmp_cr12 = inb(db->ioaddr + DCR12); /* DM9102/DM9102A */
> + tmp_cr12 = dr8(DCR12); /* DM9102/DM9102A */
>
> if ( ((db->chip_id == PCI_DM9102_ID) &&
> (db->chip_revision == 0x30)) ||
> @@ -1251,7 +1253,7 @@ static void dmfe_timer(unsigned long data)
> /* 10/100M link failed, used 1M Home-Net */
> db->cr6_data|=0x00040000; /* bit18=1, MII */
> db->cr6_data&=~0x00000200; /* bit9=0, HD mode */
> - update_cr6(db->cr6_data, db->ioaddr);
> + update_cr6(db->cr6_data, ioaddr);
> }
> } else if (!netif_carrier_ok(dev)) {
>
> @@ -1288,17 +1290,18 @@ static void dmfe_timer(unsigned long data)
> * Re-initialize DM910X board
> */
>
> -static void dmfe_dynamic_reset(struct DEVICE *dev)
> +static void dmfe_dynamic_reset(struct net_device *dev)
> {
> struct dmfe_board_info *db = netdev_priv(dev);
> + void __iomem *ioaddr = db->ioaddr;
>
> DMFE_DBUG(0, "dmfe_dynamic_reset()", 0);
>
> /* Sopt MAC controller */
> db->cr6_data &= ~(CR6_RXSC | CR6_TXSC); /* Disable Tx/Rx */
> - update_cr6(db->cr6_data, dev->base_addr);
> - outl(0, dev->base_addr + DCR7); /* Disable Interrupt */
> - outl(inl(dev->base_addr + DCR5), dev->base_addr + DCR5);
> + update_cr6(db->cr6_data, ioaddr);
> + dw32(DCR7, 0); /* Disable Interrupt */
> + dw32(DCR5, dr32(DCR5));
>
> /* Disable upper layer interface */
> netif_stop_queue(dev);
> @@ -1364,9 +1367,10 @@ static void dmfe_reuse_skb(struct dmfe_board_info *db, struct sk_buff * skb)
> * Using Chain structure, and allocate Tx/Rx buffer
> */
>
> -static void dmfe_descriptor_init(struct net_device *dev, unsigned long ioaddr)
> +static void dmfe_descriptor_init(struct net_device *dev)
> {
> struct dmfe_board_info *db = netdev_priv(dev);
> + void __iomem *ioaddr = db->ioaddr;
> struct tx_desc *tmp_tx;
> struct rx_desc *tmp_rx;
> unsigned char *tmp_buf;
> @@ -1379,7 +1383,7 @@ static void dmfe_descriptor_init(struct net_device *dev, unsigned long ioaddr)
> /* tx descriptor start pointer */
> db->tx_insert_ptr = db->first_tx_desc;
> db->tx_remove_ptr = db->first_tx_desc;
> - outl(db->first_tx_desc_dma, ioaddr + DCR4); /* TX DESC address */
> + dw32(DCR4, db->first_tx_desc_dma); /* TX DESC address */
>
> /* rx descriptor start pointer */
> db->first_rx_desc = (void *)db->first_tx_desc +
> @@ -1389,7 +1393,7 @@ static void dmfe_descriptor_init(struct net_device *dev, unsigned long ioaddr)
> sizeof(struct tx_desc) * TX_DESC_CNT;
> db->rx_insert_ptr = db->first_rx_desc;
> db->rx_ready_ptr = db->first_rx_desc;
> - outl(db->first_rx_desc_dma, ioaddr + DCR3); /* RX DESC address */
> + dw32(DCR3, db->first_rx_desc_dma); /* RX DESC address */
>
> /* Init Transmit chain */
> tmp_buf = db->buf_pool_start;
> @@ -1431,14 +1435,14 @@ static void dmfe_descriptor_init(struct net_device *dev, unsigned long ioaddr)
> * Firstly stop DM910X , then written value and start
> */
>
> -static void update_cr6(u32 cr6_data, unsigned long ioaddr)
> +static void update_cr6(u32 cr6_data, void __iomem *ioaddr)
> {
> u32 cr6_tmp;
>
> cr6_tmp = cr6_data & ~0x2002; /* stop Tx/Rx */
> - outl(cr6_tmp, ioaddr + DCR6);
> + dw32(DCR6, cr6_tmp);
> udelay(5);
> - outl(cr6_data, ioaddr + DCR6);
> + dw32(DCR6, cr6_data);
> udelay(5);
> }
>
> @@ -1448,24 +1452,19 @@ static void update_cr6(u32 cr6_data, unsigned long ioaddr)
> * This setup frame initialize DM910X address filter mode
> */
>
> -static void dm9132_id_table(struct DEVICE *dev)
> +static void dm9132_id_table(struct net_device *dev)
> {
> + struct dmfe_board_info *db = netdev_priv(dev);
> + void __iomem *ioaddr = db->ioaddr + 0xc0;
> + u16 *addrptr = (u16 *)dev->dev_addr;
> struct netdev_hw_addr *ha;
> - u16 * addrptr;
> - unsigned long ioaddr = dev->base_addr+0xc0; /* ID Table */
> - u32 hash_val;
> u16 i, hash_table[4];
>
> - DMFE_DBUG(0, "dm9132_id_table()", 0);
> -
> /* Node address */
> - addrptr = (u16 *) dev->dev_addr;
> - outw(addrptr[0], ioaddr);
> - ioaddr += 4;
> - outw(addrptr[1], ioaddr);
> - ioaddr += 4;
> - outw(addrptr[2], ioaddr);
> - ioaddr += 4;
> + for (i = 0; i < 3; i++) {
> + dw16(0, addrptr[i]);
> + ioaddr += 4;
> + }
>
> /* Clear Hash Table */
> memset(hash_table, 0, sizeof(hash_table));
> @@ -1475,13 +1474,14 @@ static void dm9132_id_table(struct DEVICE *dev)
>
> /* the multicast address in Hash Table : 64 bits */
> netdev_for_each_mc_addr(ha, dev) {
> - hash_val = cal_CRC((char *) ha->addr, 6, 0) & 0x3f;
> + u32 hash_val = cal_CRC((char *)ha->addr, 6, 0) & 0x3f;
> +
> hash_table[hash_val / 16] |= (u16) 1 << (hash_val % 16);
> }
>
> /* Write the hash table to MAC MD table */
> for (i = 0; i < 4; i++, ioaddr += 4)
> - outw(hash_table[i], ioaddr);
> + dw16(0, hash_table[i]);
> }
>
>
> @@ -1490,7 +1490,7 @@ static void dm9132_id_table(struct DEVICE *dev)
> * This setup frame initialize DM910X address filter mode
> */
>
> -static void send_filter_frame(struct DEVICE *dev)
> +static void send_filter_frame(struct net_device *dev)
> {
> struct dmfe_board_info *db = netdev_priv(dev);
> struct netdev_hw_addr *ha;
> @@ -1535,12 +1535,14 @@ static void send_filter_frame(struct DEVICE *dev)
>
> /* Resource Check and Send the setup packet */
> if (!db->tx_packet_cnt) {
> + void __iomem *ioaddr = db->ioaddr;
> +
> /* Resource Empty */
> db->tx_packet_cnt++;
> txptr->tdes0 = cpu_to_le32(0x80000000);
> - update_cr6(db->cr6_data | 0x2000, dev->base_addr);
> - outl(0x1, dev->base_addr + DCR1); /* Issue Tx polling */
> - update_cr6(db->cr6_data, dev->base_addr);
> + update_cr6(db->cr6_data | 0x2000, ioaddr);
> + dw32(DCR1, 0x1); /* Issue Tx polling */
> + update_cr6(db->cr6_data, ioaddr);
> dev->trans_start = jiffies;
> } else
> db->tx_queue_cnt++; /* Put in TX queue */
> @@ -1575,43 +1577,55 @@ static void allocate_rx_buffer(struct net_device *dev)
> db->rx_insert_ptr = rxptr;
> }
>
> +static void srom_clk_write(void __iomem *ioaddr, u32 data)
> +{
> + static const u32 cmd[] = {
> + CR9_SROM_READ | CR9_SRCS,
> + CR9_SROM_READ | CR9_SRCS | CR9_SRCLK,
> + CR9_SROM_READ | CR9_SRCS
> + };
> + int i;
> +
> + for (i = 0; i < ARRAY_SIZE(cmd); i++) {
> + dw32(DCR9, data | cmd[i]);
> + udelay(5);
> + }
> +}
>
> /*
> * Read one word data from the serial ROM
> */
> -
> -static u16 read_srom_word(long ioaddr, int offset)
> +static u16 read_srom_word(void __iomem *ioaddr, int offset)
> {
> + u16 srom_data;
> int i;
> - u16 srom_data = 0;
> - long cr9_ioaddr = ioaddr + DCR9;
>
> - outl(CR9_SROM_READ, cr9_ioaddr);
> - outl(CR9_SROM_READ | CR9_SRCS, cr9_ioaddr);
> + dw32(DCR9, CR9_SROM_READ);
> + dw32(DCR9, CR9_SROM_READ | CR9_SRCS);
>
> /* Send the Read Command 110b */
> - SROM_CLK_WRITE(SROM_DATA_1, cr9_ioaddr);
> - SROM_CLK_WRITE(SROM_DATA_1, cr9_ioaddr);
> - SROM_CLK_WRITE(SROM_DATA_0, cr9_ioaddr);
> + srom_clk_write(ioaddr, SROM_DATA_1);
> + srom_clk_write(ioaddr, SROM_DATA_1);
> + srom_clk_write(ioaddr, SROM_DATA_0);
>
> /* Send the offset */
> for (i = 5; i >= 0; i--) {
> srom_data = (offset & (1 << i)) ? SROM_DATA_1 : SROM_DATA_0;
> - SROM_CLK_WRITE(srom_data, cr9_ioaddr);
> + srom_clk_write(ioaddr, srom_data);
> }
>
> - outl(CR9_SROM_READ | CR9_SRCS, cr9_ioaddr);
> + dw32(DCR9, CR9_SROM_READ | CR9_SRCS);
>
> for (i = 16; i > 0; i--) {
> - outl(CR9_SROM_READ | CR9_SRCS | CR9_SRCLK, cr9_ioaddr);
> + dw32(DCR9, CR9_SROM_READ | CR9_SRCS | CR9_SRCLK);
> udelay(5);
> srom_data = (srom_data << 1) |
> - ((inl(cr9_ioaddr) & CR9_CRDOUT) ? 1 : 0);
> - outl(CR9_SROM_READ | CR9_SRCS, cr9_ioaddr);
> + ((dr32(DCR9) & CR9_CRDOUT) ? 1 : 0);
> + dw32(DCR9, CR9_SROM_READ | CR9_SRCS);
> udelay(5);
> }
>
> - outl(CR9_SROM_READ, cr9_ioaddr);
> + dw32(DCR9, CR9_SROM_READ);
> return srom_data;
> }
>
> @@ -1620,13 +1634,14 @@ static u16 read_srom_word(long ioaddr, int offset)
> * Auto sense the media mode
> */
>
> -static u8 dmfe_sense_speed(struct dmfe_board_info * db)
> +static u8 dmfe_sense_speed(struct dmfe_board_info *db)
> {
> + void __iomem *ioaddr = db->ioaddr;
> u8 ErrFlag = 0;
> u16 phy_mode;
>
> /* CR6 bit18=0, select 10/100M */
> - update_cr6( (db->cr6_data & ~0x40000), db->ioaddr);
> + update_cr6(db->cr6_data & ~0x40000, ioaddr);
>
> phy_mode = phy_read(db->ioaddr, db->phy_addr, 1, db->chip_id);
> phy_mode = phy_read(db->ioaddr, db->phy_addr, 1, db->chip_id);
> @@ -1665,11 +1680,12 @@ static u8 dmfe_sense_speed(struct dmfe_board_info * db)
>
> static void dmfe_set_phyxcer(struct dmfe_board_info *db)
> {
> + void __iomem *ioaddr = db->ioaddr;
> u16 phy_reg;
>
> /* Select 10/100M phyxcer */
> db->cr6_data &= ~0x40000;
> - update_cr6(db->cr6_data, db->ioaddr);
> + update_cr6(db->cr6_data, ioaddr);
>
> /* DM9009 Chip: Phyxcer reg18 bit12=0 */
> if (db->chip_id == PCI_DM9009_ID) {
> @@ -1765,18 +1781,15 @@ static void dmfe_process_mode(struct dmfe_board_info *db)
> * Write a word to Phy register
> */
>
> -static void phy_write(unsigned long iobase, u8 phy_addr, u8 offset,
> +static void phy_write(void __iomem *ioaddr, u8 phy_addr, u8 offset,
> u16 phy_data, u32 chip_id)
> {
> u16 i;
> - unsigned long ioaddr;
>
> if (chip_id == PCI_DM9132_ID) {
> - ioaddr = iobase + 0x80 + offset * 4;
> - outw(phy_data, ioaddr);
> + dw16(0x80 + offset * 4, phy_data);
> } else {
> /* DM9102/DM9102A Chip */
> - ioaddr = iobase + DCR9;
>
> /* Send 33 synchronization clock to Phy controller */
> for (i = 0; i < 35; i++)
> @@ -1816,19 +1829,16 @@ static void phy_write(unsigned long iobase, u8 phy_addr, u8 offset,
> * Read a word data from phy register
> */
>
> -static u16 phy_read(unsigned long iobase, u8 phy_addr, u8 offset, u32 chip_id)
> +static u16 phy_read(void __iomem *ioaddr, u8 phy_addr, u8 offset, u32 chip_id)
> {
> int i;
> u16 phy_data;
> - unsigned long ioaddr;
>
> if (chip_id == PCI_DM9132_ID) {
> /* DM9132 Chip */
> - ioaddr = iobase + 0x80 + offset * 4;
> - phy_data = inw(ioaddr);
> + phy_data = dr16(0x80 + offset * 4);
> } else {
> /* DM9102/DM9102A Chip */
> - ioaddr = iobase + DCR9;
>
> /* Send 33 synchronization clock to Phy controller */
> for (i = 0; i < 35; i++)
> @@ -1870,13 +1880,13 @@ static u16 phy_read(unsigned long iobase, u8 phy_addr, u8 offset, u32 chip_id)
> * Write one bit data to Phy Controller
> */
>
> -static void phy_write_1bit(unsigned long ioaddr, u32 phy_data)
> +static void phy_write_1bit(void __iomem *ioaddr, u32 phy_data)
> {
> - outl(phy_data, ioaddr); /* MII Clock Low */
> + dw32(DCR9, phy_data); /* MII Clock Low */
> udelay(1);
> - outl(phy_data | MDCLKH, ioaddr); /* MII Clock High */
> + dw32(DCR9, phy_data | MDCLKH); /* MII Clock High */
> udelay(1);
> - outl(phy_data, ioaddr); /* MII Clock Low */
> + dw32(DCR9, phy_data); /* MII Clock Low */
> udelay(1);
> }
>
> @@ -1885,14 +1895,14 @@ static void phy_write_1bit(unsigned long ioaddr, u32 phy_data)
> * Read one bit phy data from PHY controller
> */
>
> -static u16 phy_read_1bit(unsigned long ioaddr)
> +static u16 phy_read_1bit(void __iomem *ioaddr)
> {
> u16 phy_data;
>
> - outl(0x50000, ioaddr);
> + dw32(DCR9, 0x50000);
> udelay(1);
> - phy_data = ( inl(ioaddr) >> 19 ) & 0x1;
> - outl(0x40000, ioaddr);
> + phy_data = (dr32(DCR9) >> 19) & 0x1;
> + dw32(DCR9, 0x40000);
> udelay(1);
>
> return phy_data;
> @@ -1978,7 +1988,7 @@ static void dmfe_parse_srom(struct dmfe_board_info * db)
>
> /* Check DM9801 or DM9802 present or not */
> db->HPNA_present = 0;
> - update_cr6(db->cr6_data|0x40000, db->ioaddr);
> + update_cr6(db->cr6_data | 0x40000, db->ioaddr);
> tmp_reg = phy_read(db->ioaddr, db->phy_addr, 3, db->chip_id);
> if ( ( tmp_reg & 0xfff0 ) == 0xb900 ) {
> /* DM9801 or DM9802 present */
> @@ -2095,6 +2105,7 @@ static int dmfe_suspend(struct pci_dev *pci_dev, pm_message_t state)
> {
> struct net_device *dev = pci_get_drvdata(pci_dev);
> struct dmfe_board_info *db = netdev_priv(dev);
> + void __iomem *ioaddr = db->ioaddr;
> u32 tmp;
>
> /* Disable upper layer interface */
> @@ -2102,11 +2113,11 @@ static int dmfe_suspend(struct pci_dev *pci_dev, pm_message_t state)
>
> /* Disable Tx/Rx */
> db->cr6_data &= ~(CR6_RXSC | CR6_TXSC);
> - update_cr6(db->cr6_data, dev->base_addr);
> + update_cr6(db->cr6_data, ioaddr);
>
> /* Disable Interrupt */
> - outl(0, dev->base_addr + DCR7);
> - outl(inl (dev->base_addr + DCR5), dev->base_addr + DCR5);
> + dw32(DCR7, 0);
> + dw32(DCR5, dr32(DCR5));
>
> /* Fre RX buffers */
> dmfe_free_rxbuffer(db);
> --
> 1.7.7.6
>
^ permalink raw reply
* [PATCH] [IPv6]: Treat ND option 31 as userland (DNSSL support)
From: Alexey I. Froloff @ 2012-04-06 15:50 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev
As specified in RFC6106, DNSSL option contains one or more domain names
of DNS suffixes. 8-bit identifier of the DNSSL option type as assigned
by the IANA is 31. This option should also be treated as userland.
Signed-off-by: Alexey I. Froloff <raorn@raorn.name>
---
include/net/ndisc.h | 1 +
net/ipv6/ndisc.c | 4 +++-
2 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/include/net/ndisc.h b/include/net/ndisc.h
index 6f9c25a..c02b6ad 100644
--- a/include/net/ndisc.h
+++ b/include/net/ndisc.h
@@ -34,6 +34,7 @@ enum {
__ND_OPT_ARRAY_MAX,
ND_OPT_ROUTE_INFO = 24, /* RFC4191 */
ND_OPT_RDNSS = 25, /* RFC5006 */
+ ND_OPT_DNSSL = 31, /* RFC6106 */
__ND_OPT_MAX
};
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index 3dcdb81..d04c6eb 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -15,6 +15,7 @@
/*
* Changes:
*
+ * Alexey I. Froloff : RFC6106 (DNSSL) support
* Pierre Ynard : export userland ND options
* through netlink (RDNSS support)
* Lars Fenneberg : fixed MTU setting on receipt
@@ -228,7 +229,8 @@ static struct nd_opt_hdr *ndisc_next_option(struct nd_opt_hdr *cur,
static inline int ndisc_is_useropt(struct nd_opt_hdr *opt)
{
- return opt->nd_opt_type == ND_OPT_RDNSS;
+ return opt->nd_opt_type == ND_OPT_RDNSS ||
+ opt->nd_opt_type == ND_OPT_DNSSL;
}
static struct nd_opt_hdr *ndisc_next_useropt(struct nd_opt_hdr *cur,
--
1.7.3.4
^ permalink raw reply related
* Re: e1000e interface hang on 82574L
From: Nix @ 2012-04-06 16:05 UTC (permalink / raw)
To: Henrique de Moraes Holschuh
Cc: Chris Boot, e1000-devel, netdev, lkml, linux-pci, Bjorn Helgaas,
Matthew Garrett
In-Reply-To: <20120406134144.GA22526@khazad-dum.debian.net>
On 6 Apr 2012, Henrique de Moraes Holschuh outgrape:
> You probably need to disable it upstream of the 82574L as well. Here
> (SuperMicro C7X58) I managed to get it to be stable by telling the BIOS
> to disable L0s and L1 system-wide.
>
> But not all BIOSes will have that option...
Indeed not :( the Tyan S7010 mobo in my headless server can't do it.
--
NULL && (void)
------------------------------------------------------------------------------
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
_______________________________________________
E1000-devel mailing list
E1000-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/e1000-devel
To learn more about Intel® Ethernet, visit http://communities.intel.com/community/wired
^ permalink raw reply
* Re: e1000e interface hang on 82574L
From: Nix @ 2012-04-06 16:04 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: Chris Boot, e1000-devel, netdev, lkml, linux-pci, Matthew Garrett
In-Reply-To: <CAErSpo4TJ-9NsD5QTpFi9fsnD9qHt7+Tr5jJHQPuS7vg6ghq_w@mail.gmail.com>
On 6 Apr 2012, Bjorn Helgaas outgrape:
> If I understand correctly, e1000e attempts to disable ASPM to work
> around an 82574L hardware erratum, but the PCI core either doesn't
> disable ASPM or it gets re-enabled somehow.
It gets re-enabled. If you explicitly do a setpci in the boot process to
turn ASPM off on the interface, after doing your 'ip link up' and routing
initialization, by the end of the boot process ASPM is back on again.
I speculate that the stabilization of the interface (as indicated by the
link-enabled message) has somehow flipped ASPM on, but I have no actual
evidence for when this re-enabling happens. I just know it does.
--
NULL && (void)
------------------------------------------------------------------------------
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
_______________________________________________
E1000-devel mailing list
E1000-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/e1000-devel
To learn more about Intel® Ethernet, visit http://communities.intel.com/community/wired
^ permalink raw reply
* [PATCH v2 2/2] cgroup: get rid of populate for memcg
From: Glauber Costa @ 2012-04-06 16:04 UTC (permalink / raw)
To: Tejun Heo
Cc: netdev-u79uwXL29TY76Z2rM5mHXA, cgroups-u79uwXL29TY76Z2rM5mHXA,
Li Zefan, kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A, Glauber Costa,
Li Zefan
In-Reply-To: <1333728250-14248-1-git-send-email-glommer-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
The last man standing justifying the need for populate() is the
sock memcg initialization functions. Now that we are able to pass
a struct mem_cgroup instead of a struct cgroup to the socket
initialization, there is nothing that stops us from initializing
everything in create().
Signed-off-by: Glauber Costa <glommer-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
CC: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
CC: Li Zefan <lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
---
mm/memcontrol.c | 16 +++++-----------
1 files changed, 5 insertions(+), 11 deletions(-)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 704054d..64a1bcd 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -4640,7 +4640,7 @@ static int mem_control_numa_stat_open(struct inode *unused, struct file *file)
#endif /* CONFIG_NUMA */
#ifdef CONFIG_CGROUP_MEM_RES_CTLR_KMEM
-static int register_kmem_files(struct mem_cgroup *memcg, struct cgroup_subsys *ss)
+static int memcg_init_kmem(struct mem_cgroup *memcg, struct cgroup_subsys *ss)
{
return mem_cgroup_sockets_init(memcg, ss);
};
@@ -4650,7 +4650,7 @@ static void kmem_cgroup_destroy(struct mem_cgroup *memcg)
mem_cgroup_sockets_destroy(memcg);
}
#else
-static int register_kmem_files(struct mem_cgroup *memcg, struct cgroup_subsys *ss)
+static int memcg_init_kmem(struct mem_cgroup *memcg, struct cgroup_subsys *ss)
{
return 0;
}
@@ -5010,7 +5010,9 @@ mem_cgroup_create(struct cgroup *cont)
memcg->move_charge_at_immigrate = 0;
mutex_init(&memcg->thresholds_lock);
spin_lock_init(&memcg->move_lock);
- return &memcg->css;
+
+ if (!memcg_init_kmem(memcg, &mem_cgroup_subsys))
+ return &memcg->css;
free_out:
__mem_cgroup_free(memcg);
return ERR_PTR(error);
@@ -5032,13 +5034,6 @@ static void mem_cgroup_destroy(struct cgroup *cont)
mem_cgroup_put(memcg);
}
-static int mem_cgroup_populate(struct cgroup_subsys *ss,
- struct cgroup *cont)
-{
- struct mem_cgroup *memcg = mem_cgroup_from_cont(cont);
- return register_kmem_files(memcg, ss);
-}
-
#ifdef CONFIG_MMU
/* Handlers for move charge at task migration. */
#define PRECHARGE_COUNT_AT_ONCE 256
@@ -5622,7 +5617,6 @@ struct cgroup_subsys mem_cgroup_subsys = {
.create = mem_cgroup_create,
.pre_destroy = mem_cgroup_pre_destroy,
.destroy = mem_cgroup_destroy,
- .populate = mem_cgroup_populate,
.can_attach = mem_cgroup_can_attach,
.cancel_attach = mem_cgroup_cancel_attach,
.attach = mem_cgroup_move_task,
--
1.7.7.6
^ permalink raw reply related
* [PATCH v2 1/2] cgroup: pass struct mem_cgroup instead of struct cgroup to socket memcg
From: Glauber Costa @ 2012-04-06 16:04 UTC (permalink / raw)
To: Tejun Heo
Cc: netdev-u79uwXL29TY76Z2rM5mHXA, cgroups-u79uwXL29TY76Z2rM5mHXA,
Li Zefan, kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A, Glauber Costa,
Li Zefan
In-Reply-To: <1333728250-14248-1-git-send-email-glommer-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
The only reason cgroup was used, was to be consistent with the populate()
interface. Now that we're getting rid of it, not only we no longer need
it, but we also *can't* call it this way.
Since we will no longer rely on populate(), this will be called from
create(). During create, the association between struct mem_cgroup
and struct cgroup does not yet exist, since cgroup internals hasn't
yet initialized its bookkeeping. This means we would not be able
to draw the memcg pointer from the cgroup pointer in these
functions, which is highly undesirable.
Signed-off-by: Glauber Costa <glommer-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
CC: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
CC: Li Zefan <lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
---
include/net/sock.h | 12 ++++++------
include/net/tcp_memcontrol.h | 4 ++--
mm/memcontrol.c | 24 +++++++++---------------
net/core/sock.c | 10 +++++-----
net/ipv4/tcp_memcontrol.c | 6 ++----
5 files changed, 24 insertions(+), 32 deletions(-)
diff --git a/include/net/sock.h b/include/net/sock.h
index a6ba1f8..b3ebe6b 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -70,16 +70,16 @@
struct cgroup;
struct cgroup_subsys;
#ifdef CONFIG_NET
-int mem_cgroup_sockets_init(struct cgroup *cgrp, struct cgroup_subsys *ss);
-void mem_cgroup_sockets_destroy(struct cgroup *cgrp);
+int mem_cgroup_sockets_init(struct mem_cgroup *memcg, struct cgroup_subsys *ss);
+void mem_cgroup_sockets_destroy(struct mem_cgroup *memcg);
#else
static inline
-int mem_cgroup_sockets_init(struct cgroup *cgrp, struct cgroup_subsys *ss)
+int mem_cgroup_sockets_init(struct mem_cgroup *memcg, struct cgroup_subsys *ss)
{
return 0;
}
static inline
-void mem_cgroup_sockets_destroy(struct cgroup *cgrp)
+void mem_cgroup_sockets_destroy(struct mem_cgroup *memcg)
{
}
#endif
@@ -900,9 +900,9 @@ struct proto {
* This function has to setup any files the protocol want to
* appear in the kmem cgroup filesystem.
*/
- int (*init_cgroup)(struct cgroup *cgrp,
+ int (*init_cgroup)(struct mem_cgroup *memcg,
struct cgroup_subsys *ss);
- void (*destroy_cgroup)(struct cgroup *cgrp);
+ void (*destroy_cgroup)(struct mem_cgroup *memcg);
struct cg_proto *(*proto_cgroup)(struct mem_cgroup *memcg);
#endif
};
diff --git a/include/net/tcp_memcontrol.h b/include/net/tcp_memcontrol.h
index 48410ff..7df18bc 100644
--- a/include/net/tcp_memcontrol.h
+++ b/include/net/tcp_memcontrol.h
@@ -12,8 +12,8 @@ struct tcp_memcontrol {
};
struct cg_proto *tcp_proto_cgroup(struct mem_cgroup *memcg);
-int tcp_init_cgroup(struct cgroup *cgrp, struct cgroup_subsys *ss);
-void tcp_destroy_cgroup(struct cgroup *cgrp);
+int tcp_init_cgroup(struct mem_cgroup *memcg, struct cgroup_subsys *ss);
+void tcp_destroy_cgroup(struct mem_cgroup *memcg);
unsigned long long tcp_max_memory(const struct mem_cgroup *memcg);
void tcp_prot_mem(struct mem_cgroup *memcg, long val, int idx);
#endif /* _TCP_MEMCG_H */
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index bef1142..704054d 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -4640,29 +4640,22 @@ static int mem_control_numa_stat_open(struct inode *unused, struct file *file)
#endif /* CONFIG_NUMA */
#ifdef CONFIG_CGROUP_MEM_RES_CTLR_KMEM
-static int register_kmem_files(struct cgroup *cont, struct cgroup_subsys *ss)
+static int register_kmem_files(struct mem_cgroup *memcg, struct cgroup_subsys *ss)
{
- /*
- * Part of this would be better living in a separate allocation
- * function, leaving us with just the cgroup tree population work.
- * We, however, depend on state such as network's proto_list that
- * is only initialized after cgroup creation. I found the less
- * cumbersome way to deal with it to defer it all to populate time
- */
- return mem_cgroup_sockets_init(cont, ss);
+ return mem_cgroup_sockets_init(memcg, ss);
};
-static void kmem_cgroup_destroy(struct cgroup *cont)
+static void kmem_cgroup_destroy(struct mem_cgroup *memcg)
{
- mem_cgroup_sockets_destroy(cont);
+ mem_cgroup_sockets_destroy(memcg);
}
#else
-static int register_kmem_files(struct cgroup *cont, struct cgroup_subsys *ss)
+static int register_kmem_files(struct mem_cgroup *memcg, struct cgroup_subsys *ss)
{
return 0;
}
-static void kmem_cgroup_destroy(struct cgroup *cont)
+static void kmem_cgroup_destroy(struct mem_cgroup *memcg)
{
}
#endif
@@ -5034,7 +5027,7 @@ static void mem_cgroup_destroy(struct cgroup *cont)
{
struct mem_cgroup *memcg = mem_cgroup_from_cont(cont);
- kmem_cgroup_destroy(cont);
+ kmem_cgroup_destroy(memcg);
mem_cgroup_put(memcg);
}
@@ -5042,7 +5035,8 @@ static void mem_cgroup_destroy(struct cgroup *cont)
static int mem_cgroup_populate(struct cgroup_subsys *ss,
struct cgroup *cont)
{
- return register_kmem_files(cont, ss);
+ struct mem_cgroup *memcg = mem_cgroup_from_cont(cont);
+ return register_kmem_files(memcg, ss);
}
#ifdef CONFIG_MMU
diff --git a/net/core/sock.c b/net/core/sock.c
index b2e14c0..878f744 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -140,7 +140,7 @@ static DEFINE_MUTEX(proto_list_mutex);
static LIST_HEAD(proto_list);
#ifdef CONFIG_CGROUP_MEM_RES_CTLR_KMEM
-int mem_cgroup_sockets_init(struct cgroup *cgrp, struct cgroup_subsys *ss)
+int mem_cgroup_sockets_init(struct mem_cgroup *memcg, struct cgroup_subsys *ss)
{
struct proto *proto;
int ret = 0;
@@ -148,7 +148,7 @@ int mem_cgroup_sockets_init(struct cgroup *cgrp, struct cgroup_subsys *ss)
mutex_lock(&proto_list_mutex);
list_for_each_entry(proto, &proto_list, node) {
if (proto->init_cgroup) {
- ret = proto->init_cgroup(cgrp, ss);
+ ret = proto->init_cgroup(memcg, ss);
if (ret)
goto out;
}
@@ -159,19 +159,19 @@ int mem_cgroup_sockets_init(struct cgroup *cgrp, struct cgroup_subsys *ss)
out:
list_for_each_entry_continue_reverse(proto, &proto_list, node)
if (proto->destroy_cgroup)
- proto->destroy_cgroup(cgrp);
+ proto->destroy_cgroup(memcg);
mutex_unlock(&proto_list_mutex);
return ret;
}
-void mem_cgroup_sockets_destroy(struct cgroup *cgrp)
+void mem_cgroup_sockets_destroy(struct mem_cgroup *memcg)
{
struct proto *proto;
mutex_lock(&proto_list_mutex);
list_for_each_entry_reverse(proto, &proto_list, node)
if (proto->destroy_cgroup)
- proto->destroy_cgroup(cgrp);
+ proto->destroy_cgroup(memcg);
mutex_unlock(&proto_list_mutex);
}
#endif
diff --git a/net/ipv4/tcp_memcontrol.c b/net/ipv4/tcp_memcontrol.c
index 8f1753d..1517037 100644
--- a/net/ipv4/tcp_memcontrol.c
+++ b/net/ipv4/tcp_memcontrol.c
@@ -18,7 +18,7 @@ static void memcg_tcp_enter_memory_pressure(struct sock *sk)
}
EXPORT_SYMBOL(memcg_tcp_enter_memory_pressure);
-int tcp_init_cgroup(struct cgroup *cgrp, struct cgroup_subsys *ss)
+int tcp_init_cgroup(struct mem_cgroup *memcg, struct cgroup_subsys *ss)
{
/*
* The root cgroup does not use res_counters, but rather,
@@ -28,7 +28,6 @@ int tcp_init_cgroup(struct cgroup *cgrp, struct cgroup_subsys *ss)
struct res_counter *res_parent = NULL;
struct cg_proto *cg_proto, *parent_cg;
struct tcp_memcontrol *tcp;
- struct mem_cgroup *memcg = mem_cgroup_from_cont(cgrp);
struct mem_cgroup *parent = parent_mem_cgroup(memcg);
struct net *net = current->nsproxy->net_ns;
@@ -61,9 +60,8 @@ int tcp_init_cgroup(struct cgroup *cgrp, struct cgroup_subsys *ss)
}
EXPORT_SYMBOL(tcp_init_cgroup);
-void tcp_destroy_cgroup(struct cgroup *cgrp)
+void tcp_destroy_cgroup(struct mem_cgroup *memcg)
{
- struct mem_cgroup *memcg = mem_cgroup_from_cont(cgrp);
struct cg_proto *cg_proto;
struct tcp_memcontrol *tcp;
u64 val;
--
1.7.7.6
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox