mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Luis Henriques <luis.henriques@canonical.com>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	kernel-team@lists.ubuntu.com
Cc: Gavin Shan <shangw@linux.vnet.ibm.com>,
	"David S. Miller" <davem@davemloft.net>,
	Luis Henriques <luis.henriques@canonical.com>
Subject: [PATCH 41/50] net/tg3: Avoid delay during MMIO access
Date: Tue,  2 Jul 2013 12:07:29 +0100	[thread overview]
Message-ID: <1372763258-20664-42-git-send-email-luis.henriques@canonical.com> (raw)
In-Reply-To: <1372763258-20664-1-git-send-email-luis.henriques@canonical.com>

3.5.7.16 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Gavin Shan <shangw@linux.vnet.ibm.com>

commit 6d446ec32f169c6a5d9bc90684a8082a6cbe90f6 upstream.

When the EEH error is the result of a fenced host bridge, MMIO accesses
can be very slow (milliseconds) to timeout and return all 1's,
thus causing the driver various timeout loops to take way too long and
trigger soft-lockup warnings (in addition to taking minutes to recover).

It might be worthwhile to check if for any of these cases, ffffffff is
a valid possible value, and if not, bail early since that means the HW
is either gone or isolated. In the meantime, checking that the PCI channel
is offline would be workaround of the problem.

Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
[ luis: backported to 3.5:
  - adjusted context
  - inlined changes to tg3_pause_cpu function in function tg3_halt_cpu ]
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 drivers/net/ethernet/broadcom/tg3.c | 38 +++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index 8a0b948..504b4f0 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -689,6 +689,9 @@ static int tg3_ape_lock(struct tg3 *tp, int locknum)
 		status = tg3_ape_read32(tp, gnt + off);
 		if (status == bit)
 			break;
+		if (pci_channel_offline(tp->pdev))
+			break;
+
 		udelay(10);
 	}
 
@@ -1466,6 +1469,9 @@ static void tg3_wait_for_event_ack(struct tg3 *tp)
 	for (i = 0; i < delay_cnt; i++) {
 		if (!(tr32(GRC_RX_CPU_EVENT) & GRC_RX_CPU_DRIVER_EVENT))
 			break;
+		if (pci_channel_offline(tp->pdev))
+			break;
+
 		udelay(8);
 	}
 }
@@ -1639,6 +1645,9 @@ static int tg3_poll_fw(struct tg3 *tp)
 		for (i = 0; i < 200; i++) {
 			if (tr32(VCPU_STATUS) & VCPU_STATUS_INIT_DONE)
 				return 0;
+			if (pci_channel_offline(tp->pdev))
+				return -ENODEV;
+
 			udelay(100);
 		}
 		return -ENODEV;
@@ -1649,6 +1658,15 @@ static int tg3_poll_fw(struct tg3 *tp)
 		tg3_read_mem(tp, NIC_SRAM_FIRMWARE_MBOX, &val);
 		if (val == ~NIC_SRAM_FIRMWARE_MBOX_MAGIC1)
 			break;
+		if (pci_channel_offline(tp->pdev)) {
+			if (!tg3_flag(tp, NO_FWARE_REPORTED)) {
+				tg3_flag_set(tp, NO_FWARE_REPORTED);
+				netdev_info(tp->dev, "No firmware running\n");
+			}
+
+			break;
+		}
+
 		udelay(10);
 	}
 
@@ -3305,6 +3323,8 @@ static int tg3_halt_cpu(struct tg3 *tp, u32 offset)
 			tw32(offset + CPU_MODE,  CPU_MODE_HALT);
 			if (tr32(offset + CPU_MODE) & CPU_MODE_HALT)
 				break;
+			if (pci_channel_offline(tp->pdev))
+				return -EBUSY;
 		}
 
 		tw32(offset + CPU_STATE, 0xffffffff);
@@ -3316,6 +3336,8 @@ static int tg3_halt_cpu(struct tg3 *tp, u32 offset)
 			tw32(offset + CPU_MODE,  CPU_MODE_HALT);
 			if (tr32(offset + CPU_MODE) & CPU_MODE_HALT)
 				break;
+			if (pci_channel_offline(tp->pdev))
+				return -EBUSY;
 		}
 	}
 
@@ -7723,6 +7745,14 @@ static int tg3_stop_block(struct tg3 *tp, unsigned long ofs, u32 enable_bit, int
 	tw32_f(ofs, val);
 
 	for (i = 0; i < MAX_WAIT_CNT; i++) {
+		if (pci_channel_offline(tp->pdev)) {
+			dev_err(&tp->pdev->dev,
+				"tg3_stop_block device offline, "
+				"ofs=%lx enable_bit=%x\n",
+				ofs, enable_bit);
+			return -ENODEV;
+		}
+
 		udelay(100);
 		val = tr32(ofs);
 		if ((val & enable_bit) == 0)
@@ -7746,6 +7776,13 @@ static int tg3_abort_hw(struct tg3 *tp, int silent)
 
 	tg3_disable_ints(tp);
 
+	if (pci_channel_offline(tp->pdev)) {
+		tp->rx_mode &= ~(RX_MODE_ENABLE | TX_MODE_ENABLE);
+		tp->mac_mode &= ~MAC_MODE_TDE_ENABLE;
+		err = -ENODEV;
+		goto err_no_dev;
+	}
+
 	tp->rx_mode &= ~RX_MODE_ENABLE;
 	tw32_f(MAC_RX_MODE, tp->rx_mode);
 	udelay(10);
@@ -7794,6 +7831,7 @@ static int tg3_abort_hw(struct tg3 *tp, int silent)
 	err |= tg3_stop_block(tp, BUFMGR_MODE, BUFMGR_MODE_ENABLE, silent);
 	err |= tg3_stop_block(tp, MEMARB_MODE, MEMARB_MODE_ENABLE, silent);
 
+err_no_dev:
 	for (i = 0; i < tp->irq_cnt; i++) {
 		struct tg3_napi *tnapi = &tp->napi[i];
 		if (tnapi->hw_status)
-- 
1.8.1.2


  parent reply	other threads:[~2013-07-02 11:11 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-02 11:06 [ 3.5.y.z extended stable ] Linux 3.5.7.16 stable review Luis Henriques
2013-07-02 11:06 ` [PATCH 01/50] clk: remove notifier from list before freeing it Luis Henriques
2013-07-02 11:06 ` [PATCH 02/50] ALSA: usb-audio: work around Android accessory firmware bug Luis Henriques
2013-07-02 11:06 ` [PATCH 03/50] ALSA: usb-audio: Fix invalid volume resolution for Logitech HD Webcam c310 Luis Henriques
2013-07-02 11:06 ` [PATCH 04/50] ncpfs: fix rmdir returns Device or resource busy Luis Henriques
2013-07-02 11:06 ` [PATCH 05/50] tcp: fix tcp_md5_hash_skb_data() Luis Henriques
2013-07-02 11:06 ` [PATCH 06/50] gianfar: add missing iounmap() on error in gianfar_ptp_probe() Luis Henriques
2013-07-02 11:06 ` [PATCH 07/50] ipv6: fix possible crashes in ip6_cork_release() Luis Henriques
2013-07-02 11:06 ` [PATCH 08/50] netlabel: improve domain mapping validation Luis Henriques
2013-07-02 11:06 ` [PATCH 09/50] r8169: fix 8168evl frame padding Luis Henriques
2013-07-02 11:06 ` [PATCH 10/50] r8169: fix offloaded tx checksum for small packets Luis Henriques
2013-07-02 11:06 ` [PATCH 11/50] 8139cp: reset BQL when ring tx ring cleared Luis Henriques
2013-07-02 11:07 ` [PATCH 12/50] tcp: bug fix in proportional rate reduction Luis Henriques
2013-07-02 11:07 ` [PATCH 13/50] net: Block MSG_CMSG_COMPAT in send(m)msg and recv(m)msg Luis Henriques
2013-07-02 11:07 ` [PATCH 14/50] net: Unbreak compat_sys_{send,recv}msg Luis Henriques
2013-07-02 11:07 ` [PATCH 15/50] tcp: xps: fix reordering issues Luis Henriques
2013-07-02 11:07 ` [PATCH 16/50] ip_tunnel: fix kernel panic with icmp_dest_unreach Luis Henriques
2013-07-02 11:07 ` [PATCH 17/50] net: force a reload of first item in hlist_nulls_for_each_entry_rcu Luis Henriques
2013-07-02 11:07 ` [PATCH 18/50] ipv6: assign rt6_info to inet6_ifaddr in init_loopback Luis Henriques
2013-07-02 11:07 ` [PATCH 19/50] net: sctp: fix NULL pointer dereference in socket destruction Luis Henriques
2013-07-02 11:07 ` [PATCH 20/50] team: check return value of team_get_port_by_index_rcu() for NULL Luis Henriques
2013-07-02 11:07 ` [PATCH 21/50] packet: packet_getname_spkt: make sure string is always 0-terminated Luis Henriques
2013-07-02 11:07 ` [PATCH 22/50] l2tp: Fix PPP header erasure and memory leak Luis Henriques
2013-07-02 11:07 ` [PATCH 23/50] l2tp: Fix sendmsg() return value Luis Henriques
2013-07-02 11:07 ` [PATCH 24/50] bonding: rlb mode of bond should not alter ARP originating via bridge Luis Henriques
2013-07-02 11:07 ` [PATCH 25/50] tilepro: work around module link error with gcc 4.7 Luis Henriques
2013-07-02 11:07 ` [PATCH 26/50] Input: cyttsp - fix memcpy size param Luis Henriques
2013-07-02 11:07 ` [PATCH 27/50] target/iscsi: don't corrupt bh_count in iscsit_stop_time2retain_timer() Luis Henriques
2013-07-02 11:07 ` [PATCH 28/50] tcm_qla2xxx: Fix residual for underrun commands that fail Luis Henriques
2013-07-02 11:07 ` [PATCH 29/50] KVM: x86: remove vcpu's CPL check in host-invoked XCR set Luis Henriques
2013-07-02 11:07 ` [PATCH 30/50] x86: fix build error and kconfig for ia32_emulation and binfmt Luis Henriques
2013-07-02 11:07 ` [PATCH 31/50] USB: serial: ti_usb_3410_5052: new device id for Abbot strip port cable Luis Henriques
2013-07-02 11:07 ` [PATCH 32/50] drm/radeon: update lockup tracking when scheduling in empty ring Luis Henriques
2013-07-02 11:07 ` [PATCH 33/50] team: move add to port list before port enablement Luis Henriques
2013-07-02 11:07 ` [PATCH 34/50] net: sh_eth: fix incorrect RX length error if R8A7740 Luis Henriques
2013-07-02 11:07 ` [PATCH 35/50] sctp: fully initialize sctp_outq in sctp_outq_init Luis Henriques
2013-07-02 11:07 ` [PATCH 36/50] ARM: 7755/1: handle user space mapped pages in flush_kernel_dcache_page Luis Henriques
2013-07-02 11:07 ` [PATCH 37/50] iwlwifi: dvm: fix chain noise calibration Luis Henriques
2013-07-02 11:07 ` [PATCH 38/50] Bluetooth: Fix crash in l2cap_build_cmd() with small MTU Luis Henriques
2013-07-02 11:07 ` [PATCH 39/50] hw_breakpoint: Use cpu_possible_mask in {reserve,release}_bp_slot() Luis Henriques
2013-07-02 11:07 ` [PATCH 40/50] ARM: 7772/1: Fix missing flush_kernel_dcache_page() for noMMU Luis Henriques
2013-07-02 11:07 ` Luis Henriques [this message]
2013-07-02 11:07 ` [PATCH 42/50] dlci: acquire rtnl_lock before calling __dev_get_by_name() Luis Henriques
2013-07-02 11:07 ` [PATCH 43/50] dlci: validate the net device in dlci_del() Luis Henriques
2013-07-02 11:07 ` [PATCH 44/50] Bluetooth: btmrvl: fix thread stopping race Luis Henriques
2013-07-02 11:07 ` [PATCH 45/50] pch_uart: fix a deadlock when pch_uart as console Luis Henriques
2013-07-02 11:07 ` [PATCH 46/50] perf: Disable monitoring on setuid processes for regular users Luis Henriques
2013-07-02 11:07 ` [PATCH 47/50] UBIFS: prepare to fix a horrid bug Luis Henriques
2013-07-02 11:07 ` [PATCH 48/50] UBIFS: " Luis Henriques
2013-07-02 11:07 ` [PATCH 49/50] perf: Fix perf mmap bugs Luis Henriques
2013-07-02 11:07 ` [PATCH 50/50] perf: Fix mmap() accounting hole Luis Henriques

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=1372763258-20664-42-git-send-email-luis.henriques@canonical.com \
    --to=luis.henriques@canonical.com \
    --cc=davem@davemloft.net \
    --cc=kernel-team@lists.ubuntu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=shangw@linux.vnet.ibm.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

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

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

all inboxes | Powered by JetHome®