[PATCH net-next 3/5] driver/net: enic: Try DMA 64 first, then failover to DMA

2013-09-03 Thread Govindarajulu Varadarajan
In servers with more than 1.1 TB of RAM, the existing 40/32 bit DMA
could cause failure as the DMA-able address could go outside the range
addressable using 40/32 bits.

The following patch first tried 64 bit DMA if possible, failover to 32
bit.

Signed-off-by: Sujith Sankar 
Signed-off-by: Christian Benvenuti 
Signed-off-by: Govindarajulu Varadarajan 
---
 drivers/net/ethernet/cisco/enic/enic_main.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c 
b/drivers/net/ethernet/cisco/enic/enic_main.c
index 93898ba..7b756cf9 100644
--- a/drivers/net/ethernet/cisco/enic/enic_main.c
+++ b/drivers/net/ethernet/cisco/enic/enic_main.c
@@ -2080,11 +2080,11 @@ static int enic_probe(struct pci_dev *pdev, const 
struct pci_device_id *ent)
pci_set_master(pdev);
 
/* Query PCI controller on system for DMA addressing
-* limitation for the device.  Try 40-bit first, and
+* limitation for the device.  Try 64-bit first, and
 * fail to 32-bit.
 */
 
-   err = pci_set_dma_mask(pdev, DMA_BIT_MASK(40));
+   err = pci_set_dma_mask(pdev, DMA_BIT_MASK(64));
if (err) {
err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
if (err) {
@@ -2098,10 +2098,10 @@ static int enic_probe(struct pci_dev *pdev, const 
struct pci_device_id *ent)
goto err_out_release_regions;
}
} else {
-   err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(40));
+   err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64));
if (err) {
dev_err(dev, "Unable to obtain %u-bit DMA "
-   "for consistent allocations, aborting\n", 40);
+   "for consistent allocations, aborting\n", 64);
goto err_out_release_regions;
}
using_dac = 1;
-- 
1.8.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH net-next 3/5] driver/net: enic: Try DMA 64 first, then failover to DMA

2013-09-03 Thread Govindarajulu Varadarajan

Hi Dave

The subject for this should be "driver/net: enic: Try DMA 64 first, then
failover to DMA 32"

The "32" got truncated, please add this while committing. Let me know if
you want me to send another patch.

thanks
//govind

On Wed, 4 Sep 2013, Govindarajulu Varadarajan wrote:


In servers with more than 1.1 TB of RAM, the existing 40/32 bit DMA
could cause failure as the DMA-able address could go outside the range
addressable using 40/32 bits.

The following patch first tried 64 bit DMA if possible, failover to 32
bit.

Signed-off-by: Sujith Sankar 
Signed-off-by: Christian Benvenuti 
Signed-off-by: Govindarajulu Varadarajan 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH net-next 0/5] driver/net: enic: enic driver updates

2013-09-03 Thread Govindarajulu Varadarajan
This series includes support for multi-tx, rss_hash, RPS, RFS, DMA64, 
export symbols for cisco low latency driver and update the driver version and 
driver maintainers.

Govindarajulu Varadarajan (5):
  driver/net: enic: Add multi tx support for enic
  driver/net: enic: record q_number and rss_hash for skb
  driver/net: enic: Try DMA 64 first, then failover to DMA
  driver/net: enic: Exposing symbols for Cisco's low latency driver
  driver/net: enic: update enic maintainers and driver

 MAINTAINERS |  3 +-
 drivers/net/ethernet/cisco/enic/enic.h  |  4 +--
 drivers/net/ethernet/cisco/enic/enic_main.c | 55 -
 drivers/net/ethernet/cisco/enic/vnic_dev.c  | 10 ++
 drivers/net/ethernet/cisco/enic/vnic_dev.h  |  1 +
 5 files changed, 54 insertions(+), 19 deletions(-)

-- 
1.8.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH net-next 1/5] driver/net: enic: Add multi tx support for enic

2013-09-03 Thread Govindarajulu Varadarajan
The following patch adds multi tx support for enic.

Signed-off-by: Nishank Trivedi 
Signed-off-by: Christian Benvenuti 
Signed-off-by: Govindarajulu Varadarajan 
---
 drivers/net/ethernet/cisco/enic/enic.h  |  2 +-
 drivers/net/ethernet/cisco/enic/enic_main.c | 36 +++--
 2 files changed, 25 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ethernet/cisco/enic/enic.h 
b/drivers/net/ethernet/cisco/enic/enic.h
index be16731..34b637a 100644
--- a/drivers/net/ethernet/cisco/enic/enic.h
+++ b/drivers/net/ethernet/cisco/enic/enic.h
@@ -37,7 +37,7 @@
 
 #define ENIC_BARS_MAX  6
 
-#define ENIC_WQ_MAX1
+#define ENIC_WQ_MAX8
 #define ENIC_RQ_MAX8
 #define ENIC_CQ_MAX(ENIC_WQ_MAX + ENIC_RQ_MAX)
 #define ENIC_INTR_MAX  (ENIC_CQ_MAX + 2)
diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c 
b/drivers/net/ethernet/cisco/enic/enic_main.c
index bcf15b1..1ab3f18 100644
--- a/drivers/net/ethernet/cisco/enic/enic_main.c
+++ b/drivers/net/ethernet/cisco/enic/enic_main.c
@@ -128,10 +128,10 @@ static int enic_wq_service(struct vnic_dev *vdev, struct 
cq_desc *cq_desc,
completed_index, enic_wq_free_buf,
opaque);
 
-   if (netif_queue_stopped(enic->netdev) &&
+   if (netif_tx_queue_stopped(netdev_get_tx_queue(enic->netdev, q_number)) 
&&
vnic_wq_desc_avail(&enic->wq[q_number]) >=
(MAX_SKB_FRAGS + ENIC_DESC_MAX_SPLITS))
-   netif_wake_queue(enic->netdev);
+   netif_wake_subqueue(enic->netdev, q_number);
 
spin_unlock(&enic->wq_lock[q_number]);
 
@@ -292,10 +292,15 @@ static irqreturn_t enic_isr_msix_rq(int irq, void *data)
 static irqreturn_t enic_isr_msix_wq(int irq, void *data)
 {
struct enic *enic = data;
-   unsigned int cq = enic_cq_wq(enic, 0);
-   unsigned int intr = enic_msix_wq_intr(enic, 0);
+   unsigned int cq;
+   unsigned int intr;
unsigned int wq_work_to_do = -1; /* no limit */
unsigned int wq_work_done;
+   unsigned int wq_irq;
+
+   wq_irq = (u32)irq - enic->msix_entry[enic_msix_wq_intr(enic, 0)].vector;
+   cq = enic_cq_wq(enic, wq_irq);
+   intr = enic_msix_wq_intr(enic, wq_irq);
 
wq_work_done = vnic_cq_service(&enic->cq[cq],
wq_work_to_do, enic_wq_service, NULL);
@@ -511,14 +516,18 @@ static netdev_tx_t enic_hard_start_xmit(struct sk_buff 
*skb,
struct net_device *netdev)
 {
struct enic *enic = netdev_priv(netdev);
-   struct vnic_wq *wq = &enic->wq[0];
+   struct vnic_wq *wq;
unsigned long flags;
+   unsigned int txq_map;
 
if (skb->len <= 0) {
dev_kfree_skb(skb);
return NETDEV_TX_OK;
}
 
+   txq_map = skb_get_queue_mapping(skb) % enic->wq_count;
+   wq = &enic->wq[txq_map];
+
/* Non-TSO sends must fit within ENIC_NON_TSO_MAX_DESC descs,
 * which is very likely.  In the off chance it's going to take
 * more than * ENIC_NON_TSO_MAX_DESC, linearize the skb.
@@ -531,23 +540,23 @@ static netdev_tx_t enic_hard_start_xmit(struct sk_buff 
*skb,
return NETDEV_TX_OK;
}
 
-   spin_lock_irqsave(&enic->wq_lock[0], flags);
+   spin_lock_irqsave(&enic->wq_lock[txq_map], flags);
 
if (vnic_wq_desc_avail(wq) <
skb_shinfo(skb)->nr_frags + ENIC_DESC_MAX_SPLITS) {
-   netif_stop_queue(netdev);
+   netif_tx_stop_queue(netdev_get_tx_queue(netdev, txq_map));
/* This is a hard error, log it */
netdev_err(netdev, "BUG! Tx ring full when queue awake!\n");
-   spin_unlock_irqrestore(&enic->wq_lock[0], flags);
+   spin_unlock_irqrestore(&enic->wq_lock[txq_map], flags);
return NETDEV_TX_BUSY;
}
 
enic_queue_wq_skb(enic, wq, skb);
 
if (vnic_wq_desc_avail(wq) < MAX_SKB_FRAGS + ENIC_DESC_MAX_SPLITS)
-   netif_stop_queue(netdev);
+   netif_tx_stop_queue(netdev_get_tx_queue(netdev, txq_map));
 
-   spin_unlock_irqrestore(&enic->wq_lock[0], flags);
+   spin_unlock_irqrestore(&enic->wq_lock[txq_map], flags);
 
return NETDEV_TX_OK;
 }
@@ -1369,7 +1378,7 @@ static int enic_open(struct net_device *netdev)
 
enic_set_rx_mode(netdev);
 
-   netif_wake_queue(netdev);
+   netif_tx_wake_all_queues(netdev);
 
for (i = 0; i < enic->rq_count; i++)
napi_enable(&enic->napi[i]);
@@ -2032,7 +2041,8 @@ static int enic_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
 * instance data is initialized to zero.
 */
 
-   netdev = alloc_etherdev(sizeof(struct enic));
+   netdev = alloc_etherdev_mqs(sizeof(struct enic),
+  

[PATCH net-next 5/5] driver/net: enic: update enic maintainers and driver

2013-09-03 Thread Govindarajulu Varadarajan
Signed-off-by: Govindarajulu Varadarajan 
Signed-off-by: Sujith Sankar 
Signed-off-by: Nishank Trivedi 
Signed-off-by: Christian Benvenuti 
---
 MAINTAINERS| 3 ++-
 drivers/net/ethernet/cisco/enic/enic.h | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 705bb96..ecb83cd 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2076,7 +2076,8 @@ F:drivers/usb/chipidea/
 
 CISCO VIC ETHERNET NIC DRIVER
 M: Christian Benvenuti 
-M: Roopa Prabhu 
+M: Sujith Sankar 
+M: Govindarajulu Varadarajan 
 M: Neel Patel 
 M: Nishank Trivedi 
 S: Supported
diff --git a/drivers/net/ethernet/cisco/enic/enic.h 
b/drivers/net/ethernet/cisco/enic/enic.h
index 34b637a..e9f7c65 100644
--- a/drivers/net/ethernet/cisco/enic/enic.h
+++ b/drivers/net/ethernet/cisco/enic/enic.h
@@ -32,7 +32,7 @@
 
 #define DRV_NAME   "enic"
 #define DRV_DESCRIPTION"Cisco VIC Ethernet NIC Driver"
-#define DRV_VERSION"2.1.1.43"
+#define DRV_VERSION"2.1.1.50"
 #define DRV_COPYRIGHT  "Copyright 2008-2013 Cisco Systems, Inc"
 
 #define ENIC_BARS_MAX  6
-- 
1.8.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH net-next 4/5] driver/net: enic: Exposing symbols for Cisco's low latency driver

2013-09-03 Thread Govindarajulu Varadarajan
This patch exposes symbols for usnic low latency driver that can be used to 
register and unregister vNics as well to traverse the resources on vNics.

Signed-off-by: Upinder Malhi 
Signed-off-by: Nishank Trivedi 
Signed-off-by: Christian Benvenuti 
---
 drivers/net/ethernet/cisco/enic/vnic_dev.c | 10 ++
 drivers/net/ethernet/cisco/enic/vnic_dev.h |  1 +
 2 files changed, 11 insertions(+)

diff --git a/drivers/net/ethernet/cisco/enic/vnic_dev.c 
b/drivers/net/ethernet/cisco/enic/vnic_dev.c
index 97455c5..69dd925 100644
--- a/drivers/net/ethernet/cisco/enic/vnic_dev.c
+++ b/drivers/net/ethernet/cisco/enic/vnic_dev.c
@@ -175,6 +175,7 @@ unsigned int vnic_dev_get_res_count(struct vnic_dev *vdev,
 {
return vdev->res[type].count;
 }
+EXPORT_SYMBOL(vnic_dev_get_res_count);
 
 void __iomem *vnic_dev_get_res(struct vnic_dev *vdev, enum vnic_res_type type,
unsigned int index)
@@ -193,6 +194,7 @@ void __iomem *vnic_dev_get_res(struct vnic_dev *vdev, enum 
vnic_res_type type,
return (char __iomem *)vdev->res[type].vaddr;
}
 }
+EXPORT_SYMBOL(vnic_dev_get_res);
 
 static unsigned int vnic_dev_desc_ring_size(struct vnic_dev_ring *ring,
unsigned int desc_count, unsigned int desc_size)
@@ -942,6 +944,7 @@ void vnic_dev_unregister(struct vnic_dev *vdev)
kfree(vdev);
}
 }
+EXPORT_SYMBOL(vnic_dev_unregister);
 
 struct vnic_dev *vnic_dev_register(struct vnic_dev *vdev,
void *priv, struct pci_dev *pdev, struct vnic_dev_bar *bar,
@@ -969,6 +972,13 @@ err_out:
vnic_dev_unregister(vdev);
return NULL;
 }
+EXPORT_SYMBOL(vnic_dev_register);
+
+struct pci_dev *vnic_dev_get_pdev(struct vnic_dev *vdev)
+{
+   return vdev->pdev;
+}
+EXPORT_SYMBOL(vnic_dev_get_pdev);
 
 int vnic_dev_init_prov2(struct vnic_dev *vdev, u8 *buf, u32 len)
 {
diff --git a/drivers/net/ethernet/cisco/enic/vnic_dev.h 
b/drivers/net/ethernet/cisco/enic/vnic_dev.h
index f3d9b79..e670029 100644
--- a/drivers/net/ethernet/cisco/enic/vnic_dev.h
+++ b/drivers/net/ethernet/cisco/enic/vnic_dev.h
@@ -127,6 +127,7 @@ int vnic_dev_set_ig_vlan_rewrite_mode(struct vnic_dev *vdev,
 struct vnic_dev *vnic_dev_register(struct vnic_dev *vdev,
void *priv, struct pci_dev *pdev, struct vnic_dev_bar *bar,
unsigned int num_bars);
+struct pci_dev *vnic_dev_get_pdev(struct vnic_dev *vdev);
 int vnic_dev_init_prov2(struct vnic_dev *vdev, u8 *buf, u32 len);
 int vnic_dev_enable2(struct vnic_dev *vdev, int active);
 int vnic_dev_enable2_done(struct vnic_dev *vdev, int *status);
-- 
1.8.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH net-next 2/5] driver/net: enic: record q_number and rss_hash for skb

2013-09-03 Thread Govindarajulu Varadarajan
The following patch sets the skb->rxhash and skb->q_number.
This is used by RPS and RFS. Kernel can make use of hw provided hash
instead of calculating the hash.

Signed-off-by: Govindarajulu Varadarajan 
Signed-off-by: Nishank Trivedi 
Signed-off-by: Christian Benvenuti 
---
 drivers/net/ethernet/cisco/enic/enic_main.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c 
b/drivers/net/ethernet/cisco/enic/enic_main.c
index 1ab3f18..93898ba 100644
--- a/drivers/net/ethernet/cisco/enic/enic_main.c
+++ b/drivers/net/ethernet/cisco/enic/enic_main.c
@@ -1034,6 +1034,14 @@ static void enic_rq_indicate_buf(struct vnic_rq *rq,
 
skb_put(skb, bytes_written);
skb->protocol = eth_type_trans(skb, netdev);
+   skb_record_rx_queue(skb, q_number);
+   if (netdev->features & NETIF_F_RXHASH) {
+   skb->rxhash = rss_hash;
+   if (rss_type & (NIC_CFG_RSS_HASH_TYPE_TCP_IPV6_EX |
+   NIC_CFG_RSS_HASH_TYPE_TCP_IPV6 |
+   NIC_CFG_RSS_HASH_TYPE_TCP_IPV4))
+   skb->l4_rxhash = true;
+   }
 
if ((netdev->features & NETIF_F_RXCSUM) && !csum_not_calc) {
skb->csum = htons(checksum);
@@ -2209,6 +2217,7 @@ static int enic_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
}
 
netif_set_real_num_tx_queues(netdev, enic->wq_count);
+   netif_set_real_num_rx_queues(netdev, enic->rq_count);
 
/* Setup notification timer, HW reset task, and wq locks
 */
@@ -2258,6 +2267,8 @@ static int enic_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
if (ENIC_SETTING(enic, TSO))
netdev->hw_features |= NETIF_F_TSO |
NETIF_F_TSO6 | NETIF_F_TSO_ECN;
+   if (ENIC_SETTING(enic, RSS))
+   netdev->hw_features |= NETIF_F_RXHASH;
if (ENIC_SETTING(enic, RXCSUM))
netdev->hw_features |= NETIF_F_RXCSUM;
 
-- 
1.8.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH net-next 00/13] Protect dev_kfree_skb_irq from NULL and remove unnecessary NULL checks

2013-11-02 Thread Govindarajulu Varadarajan
dev_kfree_skb_irq is not NULL safe. The following patch checks skb for NULL in
dev_kfree_skb_irq. 

At many places we check for NULL before calling dev_kfree_skb_*(). Moving the
check to dev_kfree_skb_irq_*() removes the reddundant if condition and makes
code simpler. 

Also dev_kfree_skb_any either calls dev_kfree_skb_irq or dev_kfree_skb
depending on where your code is running. dev_kfree_skb is NULL safe but
dev_kfree_skb_irq is not. This patch fixes it. 

Govindarajulu Varadarajan (13):
  net: Check skb for NULL in dev_kfree_skb_irq
  driver: net: remove unnecessary skb NULL check before calling
dev_kfree_skb_irq
  driver: atm: remove unnecessary skb NULL check before calling
dev_kfree_skb_irq
  driver: staging:  remove unnecessary skb NULL check before calling
dev_kfree_skb_irq
  driver: net: remove unnecessary skb NULL check before calling
dev_kfree_skb_irq
  driver: net: remove unnecessary NULL check before dev_kfree_skb_any
  driver: staging: remove unnecessary NULL check before
dev_kfree_skb_any
  driver: isdn: remove unnecessary NULL check before dev_kfree_skb_any
  driver: s390: remove unnecessary NULL check before dev_kfree_skb_any
  driver: infiniband: remove unnecessary NULL check before
dev_kfree_skb_any
  driver: usb: remove unnecessary NULL check before dev_kfree_skb_any
  driver: net: fix space before '(' and remove extra variable
  scripts/checkpatch.pl: Add dev_kfree_skb*(NULL) check to ckeckpatch

 drivers/atm/eni.c|  2 +-
 drivers/infiniband/hw/amso1100/c2.c  |  6 ++
 drivers/infiniband/hw/nes/nes_hw.c   |  3 +--
 drivers/isdn/gigaset/ser-gigaset.c   |  3 +--
 drivers/isdn/hisax/hfc_usb.c |  6 ++
 drivers/isdn/hisax/icc.c |  6 ++
 drivers/isdn/hisax/ipacx.c   |  6 ++
 drivers/isdn/hisax/isac.c|  6 ++
 drivers/isdn/hisax/st5481_b.c|  6 ++
 drivers/isdn/hisax/w6692.c   |  6 ++
 drivers/net/ethernet/amd/lance.c |  9 +++--
 drivers/net/ethernet/amd/ni65.c  |  6 ++
 drivers/net/ethernet/atheros/alx/main.c  |  6 ++
 drivers/net/ethernet/atheros/atl1c/atl1c_main.c  | 10 --
 drivers/net/ethernet/atheros/atl1e/atl1e_main.c  | 12 
 drivers/net/ethernet/atheros/atlx/atl1.c | 12 
 drivers/net/ethernet/cisco/enic/enic_main.c  |  3 +--
 drivers/net/ethernet/freescale/fec_main.c|  6 ++
 drivers/net/ethernet/hp/hp100.c  |  3 +--
 drivers/net/ethernet/icplus/ipg.c|  6 ++
 drivers/net/ethernet/intel/e1000/e1000_main.c|  6 ++
 drivers/net/ethernet/intel/e1000e/netdev.c   | 15 +--
 drivers/net/ethernet/intel/igb/igb_ptp.c |  6 ++
 drivers/net/ethernet/intel/igbvf/netdev.c|  6 ++
 drivers/net/ethernet/intel/ixgb/ixgb_main.c  |  6 ++
 drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c |  6 ++
 drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c|  6 ++
 drivers/net/ethernet/korina.c| 12 
 drivers/net/ethernet/marvell/pxa168_eth.c|  3 +--
 drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c | 12 
 drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c |  9 +++--
 drivers/net/ethernet/qlogic/qlcnic/qlcnic_init.c |  6 ++
 drivers/net/ethernet/seeq/sgiseeq.c  |  6 ++
 drivers/net/ethernet/sgi/ioc3-eth.c  | 11 +++
 drivers/net/ethernet/smsc/smsc9420.c |  3 +--
 drivers/net/ethernet/sun/sunbmac.c   | 12 
 drivers/net/ethernet/ti/cpmac.c  |  6 ++
 drivers/net/ethernet/xilinx/ll_temac_main.c  |  3 +--
 drivers/net/ethernet/xilinx/xilinx_axienet_main.c|  6 ++
 drivers/net/hamradio/scc.c   | 10 +++---
 drivers/net/hyperv/netvsc_drv.c  |  3 +--
 drivers/net/irda/vlsi_ir.c   | 15 +--
 drivers/net/usb/cdc_mbim.c   |  3 +--
 drivers/net/usb/cdc_ncm.c| 15 +--
 drivers/net/usb/lg-vl600.c   |  6 ++
 drivers/net/usb/usbnet.c |  3 +--
 drivers/net/vmxnet3/vmxnet3_drv.c|  9 +++--
 drivers/net/wireless/ath/ar5523/ar5523.c |  6 ++
 drivers/net/wireless/ath/ath10k/mac.c|  6 ++
 drivers/net/wireless/ath/ath9k/htc_drv_txrx.c|  3 +--
 drivers/net/wireless/ath/ath9k/main.c|  6 ++
 drivers/net/wireless/ath/ath9k/recv.c|  6 ++
 drivers/net/wireless/ath/wil6

[PATCH net-next 01/13] net: Check skb for NULL in dev_kfree_skb_irq

2013-11-02 Thread Govindarajulu Varadarajan
Signed-off-by: Govindarajulu Varadarajan 
---
 net/core/dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index 0054c8c..63bd44d 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2146,7 +2146,7 @@ EXPORT_SYMBOL(__netif_schedule);
 
 void dev_kfree_skb_irq(struct sk_buff *skb)
 {
-   if (atomic_dec_and_test(&skb->users)) {
+   if (skb && atomic_dec_and_test(&skb->users)) {
struct softnet_data *sd;
unsigned long flags;
 
-- 
1.8.4.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH net-next 03/13] driver: atm: remove unnecessary skb NULL check before calling dev_kfree_skb_irq

2013-11-02 Thread Govindarajulu Varadarajan
dev_kfree_skb_irq is protected from NULL. No need to check for NULL while
calling this function.

Signed-off-by: Govindarajulu Varadarajan 
---
 drivers/atm/eni.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
index b1955ba..78a4445 100644
--- a/drivers/atm/eni.c
+++ b/drivers/atm/eni.c
@@ -481,7 +481,7 @@ trouble:
if (paddr)
pci_unmap_single(eni_dev->pci_dev,paddr,skb->len,
PCI_DMA_FROMDEVICE);
-   if (skb) dev_kfree_skb_irq(skb);
+   dev_kfree_skb_irq(skb);
return -1;
 }
 
-- 
1.8.4.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH net-next 09/13] driver: s390: remove unnecessary NULL check before dev_kfree_skb_any

2013-11-02 Thread Govindarajulu Varadarajan
dev_kfree_skb_any is protected from NULL. No need to check for NULL
while calling this function.

Signed-off-by: Govindarajulu Varadarajan 
---
 drivers/s390/net/claw.c   | 6 ++
 drivers/s390/net/ctcm_mpc.c   | 6 ++
 drivers/s390/net/qeth_core_main.c | 6 ++
 3 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/s390/net/claw.c b/drivers/s390/net/claw.c
index fd7b3bd..66c0b14 100644
--- a/drivers/s390/net/claw.c
+++ b/drivers/s390/net/claw.c
@@ -834,10 +834,8 @@ claw_release(struct net_device *dev)
 ccw_check_return_code(privptr->channel[i].cdev, rc);
 }
 }
-   if (privptr->pk_skb != NULL) {
-   dev_kfree_skb_any(privptr->pk_skb);
-   privptr->pk_skb = NULL;
-   }
+   dev_kfree_skb_any(privptr->pk_skb);
+   privptr->pk_skb = NULL;
if(privptr->buffs_alloc != 1) {
CLAW_DBF_TEXT(4, trace, "none2fre");
return 0;
diff --git a/drivers/s390/net/ctcm_mpc.c b/drivers/s390/net/ctcm_mpc.c
index 2dbc77b..2dd53a6 100644
--- a/drivers/s390/net/ctcm_mpc.c
+++ b/drivers/s390/net/ctcm_mpc.c
@@ -964,8 +964,7 @@ void mpc_channel_action(struct channel *ch, int direction, 
int action)
grp->outstanding_xid2++;
ch->in_mpcgroup = 1;
 
-   if (ch->xid_skb != NULL)
-   dev_kfree_skb_any(ch->xid_skb);
+   dev_kfree_skb_any(ch->xid_skb);
 
ch->xid_skb = __dev_alloc_skb(MPC_BUFSIZE_DEFAULT,
GFP_ATOMIC | GFP_DMA);
@@ -1017,8 +1016,7 @@ void mpc_channel_action(struct channel *ch, int 
direction, int action)
grp->num_channel_paths--;
grp->active_channels[direction]--;
 
-   if (ch->xid_skb != NULL)
-   dev_kfree_skb_any(ch->xid_skb);
+   dev_kfree_skb_any(ch->xid_skb);
ch->xid_skb = NULL;
 
if (grp->channels_terminating)
diff --git a/drivers/s390/net/qeth_core_main.c 
b/drivers/s390/net/qeth_core_main.c
index 0a328d0..7d33b94 100644
--- a/drivers/s390/net/qeth_core_main.c
+++ b/drivers/s390/net/qeth_core_main.c
@@ -1282,10 +1282,8 @@ static void qeth_free_qdio_buffers(struct qeth_card 
*card)
 
qeth_free_cq(card);
cancel_delayed_work_sync(&card->buffer_reclaim_work);
-   for (j = 0; j < QDIO_MAX_BUFFERS_PER_Q; ++j) {
-   if (card->qdio.in_q->bufs[j].rx_skb)
-   dev_kfree_skb_any(card->qdio.in_q->bufs[j].rx_skb);
-   }
+   for (j = 0; j < QDIO_MAX_BUFFERS_PER_Q; ++j)
+   dev_kfree_skb_any(card->qdio.in_q->bufs[j].rx_skb);
kfree(card->qdio.in_q);
card->qdio.in_q = NULL;
/* inbound buffer pool */
-- 
1.8.4.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH net-next 04/13] driver: staging: remove unnecessary skb NULL check before calling dev_kfree_skb_irq

2013-11-02 Thread Govindarajulu Varadarajan
dev_kfree_skb_irq is protected from NULL. No need to check for NULL while
calling this function.

Signed-off-by: Govindarajulu Varadarajan 
---
 drivers/staging/slicoss/slicoss.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/slicoss/slicoss.c 
b/drivers/staging/slicoss/slicoss.c
index 869dcd3..1073880 100644
--- a/drivers/staging/slicoss/slicoss.c
+++ b/drivers/staging/slicoss/slicoss.c
@@ -2616,8 +2616,7 @@ static void slic_xmit_complete(struct adapter *adapter)
address;
 /*  hcmd = (struct slic_hostcmd *) rspbuf->hosthandle; */
if (hcmd->type == SLIC_CMD_DUMB) {
-   if (hcmd->skb)
-   dev_kfree_skb_irq(hcmd->skb);
+   dev_kfree_skb_irq(hcmd->skb);
slic_cmdq_putdone_irq(adapter, hcmd);
}
rspbuf->status = 0;
-- 
1.8.4.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH net-next 12/13] driver: net: fix space before '(' and remove extra variable

2013-11-02 Thread Govindarajulu Varadarajan
Signed-off-by: Govindarajulu Varadarajan 
---
 drivers/net/ethernet/sgi/ioc3-eth.c | 4 +---
 drivers/net/usb/usbnet.c| 2 +-
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/sgi/ioc3-eth.c 
b/drivers/net/ethernet/sgi/ioc3-eth.c
index 6bd90f2..80dcfd9 100644
--- a/drivers/net/ethernet/sgi/ioc3-eth.c
+++ b/drivers/net/ethernet/sgi/ioc3-eth.c
@@ -851,13 +851,11 @@ static inline void ioc3_clean_rx_ring(struct ioc3_private 
*ip)
 
 static inline void ioc3_clean_tx_ring(struct ioc3_private *ip)
 {
-   struct sk_buff *skb;
int i;
 
for (i=0; i < 128; i++) {
-   skb = ip->tx_skbs[i];
+   dev_kfree_skb_any(ip->tx_skbs[i]);
ip->tx_skbs[i] = NULL;
-   dev_kfree_skb_any(skb);
ip->txr[i].cmd = 0;
}
ip->tx_pi = 0;
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index b37f812..bd18155 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -1377,7 +1377,7 @@ netdev_tx_t usbnet_start_xmit (struct sk_buff *skb,
 drop:
dev->net->stats.tx_dropped++;
 not_drop:
-   dev_kfree_skb_any (skb);
+   dev_kfree_skb_any(skb);
if (urb) {
kfree(urb->sg);
usb_free_urb(urb);
-- 
1.8.4.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH net-next 05/13] driver: usb/gadget: remove unnecessary skb NULL check before calling dev_kfree_skb_irq

2013-11-02 Thread Govindarajulu Varadarajan
dev_kfree_skb_irq is protected from NULL. No need to check for NULL
while calling this function.

Signed-off-by: Govindarajulu Varadarajan 
---
 drivers/usb/gadget/f_phonet.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/f_phonet.c b/drivers/usb/gadget/f_phonet.c
index eb3aa81..9e220b6 100644
--- a/drivers/usb/gadget/f_phonet.c
+++ b/drivers/usb/gadget/f_phonet.c
@@ -393,10 +393,8 @@ static void __pn_reset(struct usb_function *f)
 
usb_ep_disable(fp->out_ep);
usb_ep_disable(fp->in_ep);
-   if (fp->rx.skb) {
-   dev_kfree_skb_irq(fp->rx.skb);
-   fp->rx.skb = NULL;
-   }
+   dev_kfree_skb_irq(fp->rx.skb);
+   fp->rx.skb = NULL;
 }
 
 static int pn_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
-- 
1.8.4.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH net-next 11/13] driver: usb: remove unnecessary NULL check before dev_kfree_skb_any

2013-11-02 Thread Govindarajulu Varadarajan
dev_kfree_skb_any is protected from NULL. No need to check for NULL
while calling this function.

Signed-off-by: Govindarajulu Varadarajan 
---
 drivers/usb/gadget/u_ether.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/u_ether.c b/drivers/usb/gadget/u_ether.c
index 2aae0d6..3b61ac6 100644
--- a/drivers/usb/gadget/u_ether.c
+++ b/drivers/usb/gadget/u_ether.c
@@ -251,8 +251,7 @@ enomem:
defer_kevent(dev, WORK_RX_MEMORY);
if (retval) {
DBG(dev, "rx submit --> %d\n", retval);
-   if (skb)
-   dev_kfree_skb_any(skb);
+   dev_kfree_skb_any(skb);
spin_lock_irqsave(&dev->req_lock, flags);
list_add(&req->list, &dev->rx_reqs);
spin_unlock_irqrestore(&dev->req_lock, flags);
@@ -339,8 +338,7 @@ quiesce:
break;
}
 
-   if (skb)
-   dev_kfree_skb_any(skb);
+   dev_kfree_skb_any(skb);
if (!netif_running(dev->net)) {
 clean:
spin_lock(&dev->req_lock);
-- 
1.8.4.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH net-next 08/13] driver: isdn: remove unnecessary NULL check before dev_kfree_skb_any

2013-11-02 Thread Govindarajulu Varadarajan
dev_kfree_skb_any is protected from NULL. No need to check for NULL
while calling this function.

Signed-off-by: Govindarajulu Varadarajan 
---
 drivers/isdn/gigaset/ser-gigaset.c | 3 +--
 drivers/isdn/hisax/hfc_usb.c   | 6 ++
 drivers/isdn/hisax/icc.c   | 6 ++
 drivers/isdn/hisax/ipacx.c | 6 ++
 drivers/isdn/hisax/isac.c  | 6 ++
 drivers/isdn/hisax/st5481_b.c  | 6 ++
 drivers/isdn/hisax/w6692.c | 6 ++
 7 files changed, 13 insertions(+), 26 deletions(-)

diff --git a/drivers/isdn/gigaset/ser-gigaset.c 
b/drivers/isdn/gigaset/ser-gigaset.c
index 8c91fd5..9128526 100644
--- a/drivers/isdn/gigaset/ser-gigaset.c
+++ b/drivers/isdn/gigaset/ser-gigaset.c
@@ -221,8 +221,7 @@ static void flush_send_queue(struct cardstate *cs)
spin_unlock_irqrestore(&cs->cmdlock, flags);
 
/* data queue */
-   if (cs->bcs->tx_skb)
-   dev_kfree_skb_any(cs->bcs->tx_skb);
+   dev_kfree_skb_any(cs->bcs->tx_skb);
while ((skb = skb_dequeue(&cs->bcs->squeue)) != NULL)
dev_kfree_skb_any(skb);
 }
diff --git a/drivers/isdn/hisax/hfc_usb.c b/drivers/isdn/hisax/hfc_usb.c
index 849a807..a1f8380 100644
--- a/drivers/isdn/hisax/hfc_usb.c
+++ b/drivers/isdn/hisax/hfc_usb.c
@@ -864,10 +864,8 @@ rx_int_complete(struct urb *urb)
fifon, urb->status);
 
fifo->urb->interval = 0;/* cancel automatic 
rescheduling */
-   if (fifo->skbuff) {
-   dev_kfree_skb_any(fifo->skbuff);
-   fifo->skbuff = NULL;
-   }
+   dev_kfree_skb_any(fifo->skbuff);
+   fifo->skbuff = NULL;
return;
}
len = urb->actual_length;
diff --git a/drivers/isdn/hisax/icc.c b/drivers/isdn/hisax/icc.c
index 51dae91..2c52996 100644
--- a/drivers/isdn/hisax/icc.c
+++ b/drivers/isdn/hisax/icc.c
@@ -549,10 +549,8 @@ ICC_l1hw(struct PStack *st, int pr, void *arg)
case (HW_DEACTIVATE | RESPONSE):
skb_queue_purge(&cs->rq);
skb_queue_purge(&cs->sq);
-   if (cs->tx_skb) {
-   dev_kfree_skb_any(cs->tx_skb);
-   cs->tx_skb = NULL;
-   }
+   dev_kfree_skb_any(cs->tx_skb);
+   cs->tx_skb = NULL;
if (test_and_clear_bit(FLG_DBUSY_TIMER, &cs->HW_Flags))
del_timer(&cs->dbusytimer);
if (test_and_clear_bit(FLG_L1_DBUSY, &cs->HW_Flags))
diff --git a/drivers/isdn/hisax/ipacx.c b/drivers/isdn/hisax/ipacx.c
index 5faa5de..55192a4 100644
--- a/drivers/isdn/hisax/ipacx.c
+++ b/drivers/isdn/hisax/ipacx.c
@@ -181,10 +181,8 @@ dch_l2l1(struct PStack *st, int pr, void *arg)
case (HW_DEACTIVATE | RESPONSE):
skb_queue_purge(&cs->rq);
skb_queue_purge(&cs->sq);
-   if (cs->tx_skb) {
-   dev_kfree_skb_any(cs->tx_skb);
-   cs->tx_skb = NULL;
-   }
+   dev_kfree_skb_any(cs->tx_skb);
+   cs->tx_skb = NULL;
if (test_and_clear_bit(FLG_DBUSY_TIMER, &cs->HW_Flags))
del_timer(&cs->dbusytimer);
break;
diff --git a/drivers/isdn/hisax/isac.c b/drivers/isdn/hisax/isac.c
index 7fdf78f..d0895f2 100644
--- a/drivers/isdn/hisax/isac.c
+++ b/drivers/isdn/hisax/isac.c
@@ -547,10 +547,8 @@ ISAC_l1hw(struct PStack *st, int pr, void *arg)
case (HW_DEACTIVATE | RESPONSE):
skb_queue_purge(&cs->rq);
skb_queue_purge(&cs->sq);
-   if (cs->tx_skb) {
-   dev_kfree_skb_any(cs->tx_skb);
-   cs->tx_skb = NULL;
-   }
+   dev_kfree_skb_any(cs->tx_skb);
+   cs->tx_skb = NULL;
if (test_and_clear_bit(FLG_DBUSY_TIMER, &cs->HW_Flags))
del_timer(&cs->dbusytimer);
if (test_and_clear_bit(FLG_L1_DBUSY, &cs->HW_Flags))
diff --git a/drivers/isdn/hisax/st5481_b.c b/drivers/isdn/hisax/st5481_b.c
index 4098491..b753aca 100644
--- a/drivers/isdn/hisax/st5481_b.c
+++ b/drivers/isdn/hisax/st5481_b.c
@@ -254,10 +254,8 @@ static void st5481B_mode(struct st5481_bcs *bcs, int mode)
} else {
st5481_usb_device_ctrl_msg(adapter, GPIO_OUT, 
adapter->leds, NULL, NULL);
}
-   if (b_out->tx_skb) {
-   dev_kfree_skb_any(b_out->tx_skb);
-   b_out->tx_skb = NULL;
-   }
+   dev_kfree_skb_any(b_out->tx_skb);
+   b_out->tx_skb = NULL;
 
}
 }
diff --git a/drivers/isdn/hisax/w6692.c b/drivers/

[PATCH net-next 10/13] driver: infiniband: remove unnecessary NULL check before dev_kfree_skb_any

2013-11-02 Thread Govindarajulu Varadarajan
dev_kfree_skb_any is protected from NULL. No need to check for NULL
while calling this function.

Signed-off-by: Govindarajulu Varadarajan 
---
 drivers/infiniband/hw/amso1100/c2.c | 6 ++
 drivers/infiniband/hw/nes/nes_hw.c  | 3 +--
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/infiniband/hw/amso1100/c2.c 
b/drivers/infiniband/hw/amso1100/c2.c
index d53cf51..30c4d00 100644
--- a/drivers/infiniband/hw/amso1100/c2.c
+++ b/drivers/infiniband/hw/amso1100/c2.c
@@ -312,10 +312,8 @@ static inline int c2_tx_free(struct c2_dev *c2dev, struct 
c2_element *elem)
pci_unmap_single(c2dev->pcidev, elem->mapaddr, elem->maplen,
 PCI_DMA_TODEVICE);
 
-   if (elem->skb) {
-   dev_kfree_skb_any(elem->skb);
-   elem->skb = NULL;
-   }
+   dev_kfree_skb_any(elem->skb);
+   elem->skb = NULL;
 
return 0;
 }
diff --git a/drivers/infiniband/hw/nes/nes_hw.c 
b/drivers/infiniband/hw/nes/nes_hw.c
index 9020024..2275a8e 100644
--- a/drivers/infiniband/hw/nes/nes_hw.c
+++ b/drivers/infiniband/hw/nes/nes_hw.c
@@ -2856,8 +2856,7 @@ void nes_nic_ce_handler(struct nes_device *nesdev, struct 
nes_hw_nic_cq *cq)
break;
}
}
-   if (skb)
-   dev_kfree_skb_any(skb);
+   dev_kfree_skb_any(skb);
nesnic->sq_tail++;
nesnic->sq_tail &= nesnic->sq_size-1;
if (sq_cqes > 128) {
-- 
1.8.4.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH net-next 06/13] driver: net: remove unnecessary NULL check before dev_kfree_skb_any

2013-11-02 Thread Govindarajulu Varadarajan
dev_kfree_skb_any is protected from NULL. No need to check for NULL
while calling this function.

Signed-off-by: Govindarajulu Varadarajan 
---
 drivers/net/ethernet/amd/lance.c |  9 +++--
 drivers/net/ethernet/atheros/alx/main.c  |  6 ++
 drivers/net/ethernet/atheros/atl1e/atl1e_main.c  |  6 ++
 drivers/net/ethernet/atheros/atlx/atl1.c |  6 ++
 drivers/net/ethernet/cisco/enic/enic_main.c  |  3 +--
 drivers/net/ethernet/freescale/fec_main.c|  6 ++
 drivers/net/ethernet/hp/hp100.c  |  3 +--
 drivers/net/ethernet/intel/e1000/e1000_main.c|  6 ++
 drivers/net/ethernet/intel/e1000e/netdev.c   | 12 
 drivers/net/ethernet/intel/igb/igb_ptp.c |  6 ++
 drivers/net/ethernet/intel/igbvf/netdev.c|  6 ++
 drivers/net/ethernet/intel/ixgb/ixgb_main.c  |  6 ++
 drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c |  6 ++
 drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c|  6 ++
 drivers/net/ethernet/korina.c| 12 
 drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c | 12 
 drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c |  9 +++--
 drivers/net/ethernet/qlogic/qlcnic/qlcnic_init.c |  6 ++
 drivers/net/ethernet/seeq/sgiseeq.c  |  6 ++
 drivers/net/ethernet/sgi/ioc3-eth.c  |  9 +++--
 drivers/net/ethernet/smsc/smsc9420.c |  3 +--
 drivers/net/ethernet/sun/sunbmac.c   | 12 
 drivers/net/ethernet/ti/cpmac.c  |  6 ++
 drivers/net/hyperv/netvsc_drv.c  |  3 +--
 drivers/net/irda/vlsi_ir.c   | 15 +--
 drivers/net/usb/cdc_mbim.c   |  3 +--
 drivers/net/usb/cdc_ncm.c| 15 +--
 drivers/net/usb/lg-vl600.c   |  6 ++
 drivers/net/usb/usbnet.c |  3 +--
 drivers/net/vmxnet3/vmxnet3_drv.c|  6 ++
 drivers/net/wireless/ath/ath10k/mac.c|  6 ++
 drivers/net/wireless/ath/ath9k/htc_drv_txrx.c|  3 +--
 drivers/net/wireless/ath/ath9k/main.c|  6 ++
 drivers/net/wireless/ath/ath9k/recv.c|  6 ++
 drivers/net/wireless/ath/wil6210/txrx.c  |  6 ++
 drivers/net/wireless/b43/main.c  |  9 +++--
 drivers/net/wireless/b43legacy/main.c|  9 +++--
 drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c  |  3 +--
 drivers/net/wireless/brcm80211/brcmsmac/main.c   | 12 
 drivers/net/wireless/ipw2x00/ipw2200.c   |  6 ++
 drivers/net/wireless/ipw2x00/libipw_rx.c |  3 +--
 drivers/net/wireless/ipw2x00/libipw_tx.c |  3 +--
 drivers/net/wireless/mwifiex/init.c  |  3 +--
 43 files changed, 96 insertions(+), 192 deletions(-)

diff --git a/drivers/net/ethernet/amd/lance.c b/drivers/net/ethernet/amd/lance.c
index 256f590..4b8fc50 100644
--- a/drivers/net/ethernet/amd/lance.c
+++ b/drivers/net/ethernet/amd/lance.c
@@ -845,14 +845,11 @@ lance_purge_ring(struct net_device *dev)
struct sk_buff *skb = lp->rx_skbuff[i];
lp->rx_skbuff[i] = NULL;
lp->rx_ring[i].base = 0;/* Not owned by LANCE 
chip. */
-   if (skb)
-   dev_kfree_skb_any(skb);
+   dev_kfree_skb_any(skb);
}
for (i = 0; i < TX_RING_SIZE; i++) {
-   if (lp->tx_skbuff[i]) {
-   dev_kfree_skb_any(lp->tx_skbuff[i]);
-   lp->tx_skbuff[i] = NULL;
-   }
+   dev_kfree_skb_any(lp->tx_skbuff[i]);
+   lp->tx_skbuff[i] = NULL;
}
 }
 
diff --git a/drivers/net/ethernet/atheros/alx/main.c 
b/drivers/net/ethernet/atheros/alx/main.c
index 5aa5e81..2bee48b 100644
--- a/drivers/net/ethernet/atheros/alx/main.c
+++ b/drivers/net/ethernet/atheros/alx/main.c
@@ -64,10 +64,8 @@ static void alx_free_txbuf(struct alx_priv *alx, int entry)
dma_unmap_len_set(txb, size, 0);
}
 
-   if (txb->skb) {
-   dev_kfree_skb_any(txb->skb);
-   txb->skb = NULL;
-   }
+   dev_kfree_skb_any(txb->skb);
+   txb->skb = NULL;
 }
 
 static int alx_refill_rx_ring(struct alx_priv *alx, gfp_t gfp)
diff --git a/drivers/net/ethernet/atheros/atl1e/atl1e_main.c 
b/drivers/net/ethernet/atheros/atl1e/atl1e_main.c
index c3ca8c6..b420ead 100644
--- a/drivers/net/ethernet/atheros/atl1e/atl1e_main.c
+++ b/drivers/net/ethernet/atheros/atl1e/atl1e_main.c
@@ -686,10 +686,8 @@ static void atl1e_clean_tx_ring(struct atl1e_adapter 
*adapter)
/* second free skb */
for (index = 0; index < rin

[PATCH net-next 13/13] scripts/checkpatch.pl: Add dev_kfree_skb*(NULL) check to checkpatch

2013-11-02 Thread Govindarajulu Varadarajan
Signed-off-by: Govindarajulu Varadarajan 
---
 scripts/checkpatch.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 66cad50..e651b8a 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3719,7 +3719,7 @@ sub process {
 # check for needless "if () fn()" uses
if ($prevline =~ /\bif\s*\(\s*($Lval)\s*\)/) {
my $expr = '\s*\(\s*' . quotemeta($1) . '\s*\)\s*;';
-   if ($line =~ 
/\b(kfree|usb_free_urb|debugfs_remove(?:_recursive)?)$expr/) {
+   if ($line =~ 
/\b(kfree|dev_kfree_skb|dev_kfree_skb_any|dev_kfree_skb_irq|usb_free_urb|debugfs_remove(?:_recursive)?)$expr/)
 {
WARN('NEEDLESS_IF',
 "$1(NULL) is safe this check is probably 
not required\n" . $hereprev);
}
-- 
1.8.4.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH net-next 02/13] driver: net: remove unnecessary skb NULL check before calling dev_kfree_skb_irq

2013-11-02 Thread Govindarajulu Varadarajan
dev_kfree_skb_irq is protected from NULL. No need to check for NULL
while calling this function.

Signed-off-by: Govindarajulu Varadarajan 
---
 drivers/net/ethernet/amd/ni65.c   |  6 ++
 drivers/net/ethernet/atheros/atl1c/atl1c_main.c   | 10 --
 drivers/net/ethernet/atheros/atl1e/atl1e_main.c   |  6 ++
 drivers/net/ethernet/atheros/atlx/atl1.c  |  6 ++
 drivers/net/ethernet/icplus/ipg.c |  6 ++
 drivers/net/ethernet/intel/e1000e/netdev.c|  3 +--
 drivers/net/ethernet/marvell/pxa168_eth.c |  3 +--
 drivers/net/ethernet/xilinx/ll_temac_main.c   |  3 +--
 drivers/net/ethernet/xilinx/xilinx_axienet_main.c |  6 ++
 drivers/net/hamradio/scc.c| 10 +++---
 drivers/net/vmxnet3/vmxnet3_drv.c |  3 +--
 drivers/net/wireless/ath/ar5523/ar5523.c  |  6 ++
 12 files changed, 23 insertions(+), 45 deletions(-)

diff --git a/drivers/net/ethernet/amd/ni65.c b/drivers/net/ethernet/amd/ni65.c
index 1cf33ad..0695ce2 100644
--- a/drivers/net/ethernet/amd/ni65.c
+++ b/drivers/net/ethernet/amd/ni65.c
@@ -1030,10 +1030,8 @@ static void ni65_xmit_intr(struct net_device *dev,int 
csr0)
}
 
 #ifdef XMT_VIA_SKB
-   if(p->tmd_skb[p->tmdlast]) {
-dev_kfree_skb_irq(p->tmd_skb[p->tmdlast]);
-p->tmd_skb[p->tmdlast] = NULL;
-   }
+dev_kfree_skb_irq(p->tmd_skb[p->tmdlast]);
+p->tmd_skb[p->tmdlast] = NULL;
 #endif
 
p->tmdlast = (p->tmdlast + 1) & (TMDNUM-1);
diff --git a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c 
b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
index a36a760..cf89008 100644
--- a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
+++ b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
@@ -848,12 +848,10 @@ static inline void atl1c_clean_buffer(struct pci_dev 
*pdev,
pci_unmap_page(pdev, buffer_info->dma,
buffer_info->length, pci_driection);
}
-   if (buffer_info->skb) {
-   if (in_irq)
-   dev_kfree_skb_irq(buffer_info->skb);
-   else
-   dev_kfree_skb(buffer_info->skb);
-   }
+   if (in_irq)
+   dev_kfree_skb_irq(buffer_info->skb);
+   else
+   dev_kfree_skb(buffer_info->skb);
buffer_info->dma = 0;
buffer_info->skb = NULL;
ATL1C_SET_BUFFER_STATE(buffer_info, ATL1C_BUFFER_FREE);
diff --git a/drivers/net/ethernet/atheros/atl1e/atl1e_main.c 
b/drivers/net/ethernet/atheros/atl1e/atl1e_main.c
index 7a73f3a..c3ca8c6 100644
--- a/drivers/net/ethernet/atheros/atl1e/atl1e_main.c
+++ b/drivers/net/ethernet/atheros/atl1e/atl1e_main.c
@@ -1257,10 +1257,8 @@ static bool atl1e_clean_tx_irq(struct atl1e_adapter 
*adapter)
tx_buffer->dma = 0;
}
 
-   if (tx_buffer->skb) {
-   dev_kfree_skb_irq(tx_buffer->skb);
-   tx_buffer->skb = NULL;
-   }
+   dev_kfree_skb_irq(tx_buffer->skb);
+   tx_buffer->skb = NULL;
 
if (++next_to_clean == tx_ring->count)
next_to_clean = 0;
diff --git a/drivers/net/ethernet/atheros/atlx/atl1.c 
b/drivers/net/ethernet/atheros/atlx/atl1.c
index 538211d..b8cc654 100644
--- a/drivers/net/ethernet/atheros/atlx/atl1.c
+++ b/drivers/net/ethernet/atheros/atlx/atl1.c
@@ -2082,10 +2082,8 @@ static int atl1_intr_tx(struct atl1_adapter *adapter)
buffer_info->dma = 0;
}
 
-   if (buffer_info->skb) {
-   dev_kfree_skb_irq(buffer_info->skb);
-   buffer_info->skb = NULL;
-   }
+   dev_kfree_skb_irq(buffer_info->skb);
+   buffer_info->skb = NULL;
 
if (++sw_tpd_next_to_clean == tpd_ring->count)
sw_tpd_next_to_clean = 0;
diff --git a/drivers/net/ethernet/icplus/ipg.c 
b/drivers/net/ethernet/icplus/ipg.c
index 25045ae..d3a5e1f 100644
--- a/drivers/net/ethernet/icplus/ipg.c
+++ b/drivers/net/ethernet/icplus/ipg.c
@@ -823,10 +823,8 @@ static void init_tfdlist(struct net_device *dev)
 
txfd->tfc = cpu_to_le64(IPG_TFC_TFDDONE);
 
-   if (sp->tx_buff[i]) {
-   dev_kfree_skb_irq(sp->tx_buff[i]);
-   sp->tx_buff[i] = NULL;
-   }
+   dev_kfree_skb_irq(sp->tx_buff[i]);
+   sp->tx_buff[i] = NULL;
 
txfd->next_desc = cpu_to_le64(sp->txd_map +
sizeof(struct ipg_tx)*(i + 1));
diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c 
b/drivers/net/ethernet/intel/e1000e/net

[PATCH net-next 07/13] driver: staging: remove unnecessary NULL check before dev_kfree_skb_any

2013-11-02 Thread Govindarajulu Varadarajan
dev_kfree_skb_any is protected from NULL. No need to check for NULL while
calling this function.

Signed-off-by: Govindarajulu Varadarajan 
---
 drivers/staging/rtl8187se/ieee80211/ieee80211_rx.c |  3 +--
 drivers/staging/rtl8187se/ieee80211/ieee80211_tx.c |  3 +--
 drivers/staging/rtl8188eu/core/rtw_recv.c  |  6 ++
 drivers/staging/rtl8192e/rtllib_rx.c   |  3 +--
 drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c  |  3 +--
 drivers/staging/rtl8712/recv_linux.c   |  3 +--
 drivers/staging/rtl8712/rtl8712_recv.c |  6 ++
 drivers/staging/rtl8712/xmit_linux.c   |  3 +--
 drivers/staging/sbe-2t3e3/dc.c | 12 
 9 files changed, 14 insertions(+), 28 deletions(-)

diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_rx.c 
b/drivers/staging/rtl8187se/ieee80211/ieee80211_rx.c
index 10b2210..bbafdcc 100644
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211_rx.c
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_rx.c
@@ -138,8 +138,7 @@ ieee80211_frag_cache_get(struct ieee80211_device *ieee,
if (ieee->frag_next_idx[tid] >= IEEE80211_FRAG_CACHE_LEN)
ieee->frag_next_idx[tid] = 0;
 
-   if (entry->skb != NULL)
-   dev_kfree_skb_any(entry->skb);
+   dev_kfree_skb_any(entry->skb);
 
entry->first_frag_time = jiffies;
entry->seq = seq;
diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_tx.c 
b/drivers/staging/rtl8187se/ieee80211/ieee80211_tx.c
index b346653..fe747b1 100644
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211_tx.c
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_tx.c
@@ -234,8 +234,7 @@ void ieee80211_txb_free(struct ieee80211_txb *txb) {
if (unlikely(!txb))
return;
for (i = 0; i < txb->nr_frags; i++)
-   if (txb->fragments[i])
-   dev_kfree_skb_any(txb->fragments[i]);
+   dev_kfree_skb_any(txb->fragments[i]);
kfree(txb);
 }
 
diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c 
b/drivers/staging/rtl8188eu/core/rtw_recv.c
index 2011657..93fb9ed 100644
--- a/drivers/staging/rtl8188eu/core/rtw_recv.c
+++ b/drivers/staging/rtl8188eu/core/rtw_recv.c
@@ -209,10 +209,8 @@ int rtw_free_recvframe(union recv_frame *precvframe, 
struct __queue *pfree_recv_
 
 _func_enter_;
 
-   if (precvframe->u.hdr.pkt) {
-   dev_kfree_skb_any(precvframe->u.hdr.pkt);/* free skb by driver 
*/
-   precvframe->u.hdr.pkt = NULL;
-   }
+   dev_kfree_skb_any(precvframe->u.hdr.pkt);/* free skb by driver */
+   precvframe->u.hdr.pkt = NULL;
 
_enter_critical_bh(&pfree_recv_queue->lock, &irqL);
 
diff --git a/drivers/staging/rtl8192e/rtllib_rx.c 
b/drivers/staging/rtl8192e/rtllib_rx.c
index 8aeaed5..0118854 100644
--- a/drivers/staging/rtl8192e/rtllib_rx.c
+++ b/drivers/staging/rtl8192e/rtllib_rx.c
@@ -133,8 +133,7 @@ rtllib_frag_cache_get(struct rtllib_device *ieee,
if (ieee->frag_next_idx[tid] >= RTLLIB_FRAG_CACHE_LEN)
ieee->frag_next_idx[tid] = 0;
 
-   if (entry->skb != NULL)
-   dev_kfree_skb_any(entry->skb);
+   dev_kfree_skb_any(entry->skb);
 
entry->first_frag_time = jiffies;
entry->seq = seq;
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c 
b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
index 59900bf..70bf7a4 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
@@ -138,8 +138,7 @@ ieee80211_frag_cache_get(struct ieee80211_device *ieee,
if (ieee->frag_next_idx[tid] >= IEEE80211_FRAG_CACHE_LEN)
ieee->frag_next_idx[tid] = 0;
 
-   if (entry->skb != NULL)
-   dev_kfree_skb_any(entry->skb);
+   dev_kfree_skb_any(entry->skb);
 
entry->first_frag_time = jiffies;
entry->seq = seq;
diff --git a/drivers/staging/rtl8712/recv_linux.c 
b/drivers/staging/rtl8712/recv_linux.c
index 495ee12..c422d1f 100644
--- a/drivers/staging/rtl8712/recv_linux.c
+++ b/drivers/staging/rtl8712/recv_linux.c
@@ -75,8 +75,7 @@ int r8712_os_recvbuf_resource_alloc(struct _adapter *padapter,
 int r8712_os_recvbuf_resource_free(struct _adapter *padapter,
 struct recv_buf *precvbuf)
 {
-   if (precvbuf->pskb)
-   dev_kfree_skb_any(precvbuf->pskb);
+   dev_kfree_skb_any(precvbuf->pskb);
if (precvbuf->purb) {
usb_kill_urb(precvbuf->purb);
usb_free_urb(precvbuf->purb);
diff --git a/drivers/staging/rtl8712/rtl8712_recv.c 
b/drivers/staging/rtl8712/rtl8712_recv.c
index d59a74a

Re: [PATCH net-next 02/13] driver: net: remove unnecessary skb NULL check before calling dev_kfree_skb_irq

2013-11-11 Thread Govindarajulu Varadarajan



On Mon, 4 Nov 2013, David Miller wrote:


From: Govindarajulu Varadarajan 
Date: Sat,  2 Nov 2013 19:17:43 +0530


@@ -1030,10 +1030,8 @@ static void ni65_xmit_intr(struct net_device *dev,int 
csr0)
}

 #ifdef XMT_VIA_SKB
-   if(p->tmd_skb[p->tmdlast]) {
-dev_kfree_skb_irq(p->tmd_skb[p->tmdlast]);
-p->tmd_skb[p->tmdlast] = NULL;
-   }
+dev_kfree_skb_irq(p->tmd_skb[p->tmdlast]);
+p->tmd_skb[p->tmdlast] = NULL;
 #endif


I absolutely disagree with this kind of change.

There is a non-trivial cost for NULL'ing out that array entry
unconditionally.  It's a dirtied cache line and this is in the
fast path of TX SKB reclaim of this driver.

You've made several changes of this kind.

And it sort-of shows that the places that do check for NULL,
are getting something in return for that test, namely avoidance
of an unnecessary cpu store in the fast path of the driver.



True, in case of dev_kfree_skb_irq. If you look at patch 06-12, at many
places we do

if (s->skb) {
dev_kfree_skb_any(s->skb);
s->skb = NULL)
}

This is in fast path. If the code is not running in hardirq,
dev_kfree_skb_any calls dev_kfree_skb. Which again check if skb is NULL.
So we are checking if skb is null twice. That is what this patch is
trying to fix. (sorry I should have mentioned this in cover letter).

I am not sure if you have read my previous mail. I am pasting it below.

On Sun, 3 Nov 2013, Brandeburg, Jesse wrote: 
Thanks for this work, I'm a little concerned that there is a
non-trivial 
overhead to this patch.


when doing (for example in the Intel drivers): 
if (s->skb) {

 dev_kfree_skb(s->skb);
 s->skb = NULL; 
}




In current code, dev_kfree_skb is NULL safe. Which means skb is
checked for NULL inside dev_kfree_skb. dev_kfree_skb_any is also NULL safe
when the code is running in non-hardirq.

Lets consider two cases

1. skb is not NULL:
 * Without my patch:
  In the code above, we check for skb!=NULL twice. (once
  before calling dev_kfree_skb, once by dev_kfree_skb). And
  then we do assignment.
  * With this patch:
  we check for skb!=NULL once, And then we do assignment.

  To fix the twice NULL check, we either have to remove the check
  which is inside dev_kfree_skb (1). Or do whats done in this
  patch.

  (1) is not an option because a lot of kernel code already
  assumes that dev_kfree_skb is NULL safe.

2. skb is NULL:
  * Without this patch:
  One if statement is executed.
  * With this patch:
  One if statement and one assignment is executed.

From my observation most of the dev_kfree_skb calls are from
e1000_unmap_and_free_tx_resource, e1000_put_txbuf,
atl1_clean_tx_ring, alx_free_txbuf etc. in clean up functions.

Is is quite unlikely thats skb is NULL. So it comes down to one extra
if-branching statement or one extra assignment. I would prefer extra
assignment to branching statement. In my opinion extra assignment is
very little price we pay.

//govind


Another way to solve the double NULL check is to define a new function
something like this

dev_kfree_skb_NULL(struct sk_buff **skb)
{
if(*skb) {
free_skb(*skb);
*skb=NULL;
}
}

and use this if you want to free a skb and make it NULL.
Is this approach better?

//govind

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2] WAN: Adding support for Infineon PEF2256 E1 chipset (FALC56)

2013-11-01 Thread Govindarajulu Varadarajan



On Fri, 1 Nov 2013, Christophe Leroy wrote:


diff -urN a/drivers/net/wan/pef2256.c b/drivers/net/wan/pef2256.c

[..]

+static int pef2256_remove(struct platform_device *pdev)
+{
+   struct net_device *ndev = dev_get_drvdata(&pdev->dev);
+   struct pef2256_dev_priv *priv = dev_to_hdlc(ndev)->priv;
+
+
+   device_remove_file(priv->dev, &dev_attr_regs);
+   device_remove_file(priv->dev, &dev_attr_Tx_TS);
+   device_remove_file(priv->dev, &dev_attr_Rx_TS);
+   device_remove_file(priv->dev, &dev_attr_mode);
+
+   unregister_hdlc_device(priv->netdev);
+
+   free_netdev(priv->netdev);
+
+   iounmap(priv->base_addr);
+
+   kfree(priv);
+
+   dev_set_drvdata(&pdev->dev, NULL);


dev_set_drvdata is not necessary. driver core clears the driver data to NULL
after device_release or on probe failure.

//govind
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH net-next 10/35] enic: Use pci_enable_msix_range() instead of pci_enable_msix()

2014-02-18 Thread Govindarajulu Varadarajan



On Tue, 18 Feb 2014, Alexander Gordeev wrote:


As result of deprecation of MSI-X/MSI enablement functions
pci_enable_msix() and pci_enable_msi_block() all drivers
using these two interfaces need to be updated to use the
new pci_enable_msi_range() and pci_enable_msix_range()
interfaces.


looks good, thanks

Acked-by: Govindarajulu Varadarajan 




Signed-off-by: Alexander Gordeev 
Cc: Christian Benvenuti 
Cc: Sujith Sankar 
Cc: Govindarajulu Varadarajan 
Cc: Neel Patel 
Cc: net...@vger.kernel.org
Cc: linux-...@vger.kernel.org
---
drivers/net/ethernet/cisco/enic/enic_main.c |6 --
1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c 
b/drivers/net/ethernet/cisco/enic/enic_main.c
index b740bfc..dcd58f2 100644
--- a/drivers/net/ethernet/cisco/enic/enic_main.c
+++ b/drivers/net/ethernet/cisco/enic/enic_main.c
@@ -1796,7 +1796,8 @@ static int enic_set_intr_mode(struct enic *enic)
enic->cq_count >= n + m &&
enic->intr_count >= n + m + 2) {

-   if (!pci_enable_msix(enic->pdev, enic->msix_entry, n + m + 2)) {
+   if (pci_enable_msix_range(enic->pdev, enic->msix_entry,
+ n + m + 2, n + m + 2) > 0) {

enic->rq_count = n;
enic->wq_count = m;
@@ -1815,7 +1816,8 @@ static int enic_set_intr_mode(struct enic *enic)
enic->wq_count >= m &&
enic->cq_count >= 1 + m &&
enic->intr_count >= 1 + m + 2) {
-   if (!pci_enable_msix(enic->pdev, enic->msix_entry, 1 + m + 2)) {
+   if (pci_enable_msix_range(enic->pdev, enic->msix_entry,
+ 1 + m + 2, 1 + m + 2) > 0) {

enic->rq_count = 1;
enic->wq_count = m;
--
1.7.7.6



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [tip:sched/core] sched/numa: Move task_numa_free() to __put_task_struct()

2014-04-13 Thread Govindarajulu Varadarajan



On Mon, 7 Apr 2014, Mike Galbraith wrote:


On Mon, 2014-04-07 at 10:16 +0200, Peter Zijlstra wrote:

On Mon, Apr 07, 2014 at 09:30:30AM +0200, Mike Galbraith wrote:

-   double_lock(&my_grp->lock, &grp->lock);
+   BUG_ON(irqs_disabled());
+   double_lock_irq(&my_grp->lock, &grp->lock);


So either make this:

local_irq_disable();
double_lock();

or



for (i = 0; i < NR_NUMA_HINT_FAULT_STATS * nr_node_ids; i++) {
my_grp->faults[i] -= p->numa_faults_memory[i];
@@ -1692,6 +1693,7 @@ static void task_numa_group(struct task_

spin_unlock(&my_grp->lock);
spin_unlock(&grp->lock);
+   local_irq_enable();


use:
spin_unlock()
spin_unlock_irq()

or so, but this imbalance is making my itch :-)


sched, numa: fix task_numa_free() lockdep splat

Sasha reports that lockdep claims 156654f491dd8d52687a5fbe1637f472a52ce75b made
numa_group.lock interrupt unsafe.  While I don't see how that could be given the
commit in question moved task_numa_free() from one irq enabled region to 
another,
the below does make both gripes and lockups upon gripe with numa=fake=4 go away.



Hi

I Am hitting this bug quite frequently. I do not see the problem after applying
this patch.

Thanks

Tested-by: Govindarajulu Varadarajan 


Reported-by: Sasha Levin 
Signed-off-by: Mike Galbraith 
---
kernel/sched/fair.c  |   13 +++--
kernel/sched/sched.h |9 +
2 files changed, 16 insertions(+), 6 deletions(-)

--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -1497,7 +1497,7 @@ static void task_numa_placement(struct t
/* If the task is part of a group prevent parallel updates to group 
stats */
if (p->numa_group) {
group_lock = &p->numa_group->lock;
-   spin_lock(group_lock);
+   spin_lock_irq(group_lock);
}

/* Find the node with the highest number of faults */
@@ -1572,7 +1572,7 @@ static void task_numa_placement(struct t
}
}

-   spin_unlock(group_lock);
+   spin_unlock_irq(group_lock);
}

/* Preferred node as the node with the most faults */
@@ -1677,7 +1677,8 @@ static void task_numa_group(struct task_
if (!join)
return;

-   double_lock(&my_grp->lock, &grp->lock);
+   BUG_ON(irqs_disabled());
+   double_lock_irq(&my_grp->lock, &grp->lock);

for (i = 0; i < NR_NUMA_HINT_FAULT_STATS * nr_node_ids; i++) {
my_grp->faults[i] -= p->numa_faults_memory[i];
@@ -1691,7 +1692,7 @@ static void task_numa_group(struct task_
grp->nr_tasks++;

spin_unlock(&my_grp->lock);
-   spin_unlock(&grp->lock);
+   spin_unlock_irq(&grp->lock);

rcu_assign_pointer(p->numa_group, grp);

@@ -1710,14 +1711,14 @@ void task_numa_free(struct task_struct *
void *numa_faults = p->numa_faults_memory;

if (grp) {
-   spin_lock(&grp->lock);
+   spin_lock_irq(&grp->lock);
for (i = 0; i < NR_NUMA_HINT_FAULT_STATS * nr_node_ids; i++)
grp->faults[i] -= p->numa_faults_memory[i];
grp->total_faults -= p->total_numa_faults;

list_del(&p->numa_entry);
grp->nr_tasks--;
-   spin_unlock(&grp->lock);
+   spin_unlock_irq(&grp->lock);
rcu_assign_pointer(p->numa_group, NULL);
put_numa_group(grp);
}
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -1388,6 +1388,15 @@ static inline void double_lock(spinlock_
spin_lock_nested(l2, SINGLE_DEPTH_NESTING);
}

+static inline void double_lock_irq(spinlock_t *l1, spinlock_t *l2)
+{
+   if (l1 > l2)
+   swap(l1, l2);
+
+   spin_lock_irq(l1);
+   spin_lock_nested(l2, SINGLE_DEPTH_NESTING);
+}
+
static inline void double_raw_lock(raw_spinlock_t *l1, raw_spinlock_t *l2)
{
if (l1 > l2)


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 10/22] enic: Use pci_zalloc_consistent

2014-06-25 Thread Govindarajulu Varadarajan



On Mon, 23 Jun 2014, Joe Perches wrote:


Remove the now unnecessary memset too.

Signed-off-by: Joe Perches 


Looks good, thanks
Acked-by: Govindarajulu Varadarajan <_gov...@gmx.com>


---
drivers/net/ethernet/cisco/enic/vnic_dev.c | 8 +++-
1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/cisco/enic/vnic_dev.c 
b/drivers/net/ethernet/cisco/enic/vnic_dev.c
index e86a45c..8a4799c 100644
--- a/drivers/net/ethernet/cisco/enic/vnic_dev.c
+++ b/drivers/net/ethernet/cisco/enic/vnic_dev.c
@@ -432,14 +432,12 @@ int vnic_dev_fw_info(struct vnic_dev *vdev,
int err = 0;

if (!vdev->fw_info) {
-   vdev->fw_info = pci_alloc_consistent(vdev->pdev,
-   sizeof(struct vnic_devcmd_fw_info),
-   &vdev->fw_info_pa);
+   vdev->fw_info = pci_zalloc_consistent(vdev->pdev,
+ sizeof(struct 
vnic_devcmd_fw_info),
+ &vdev->fw_info_pa);
if (!vdev->fw_info)
return -ENOMEM;

-   memset(vdev->fw_info, 0, sizeof(struct vnic_devcmd_fw_info));
-
a0 = vdev->fw_info_pa;
a1 = sizeof(struct vnic_devcmd_fw_info);

--
1.8.1.2.459.gbcd45b4.dirty



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [net-next PATCH v2 3/3] drivers: net: cpsw: Add support for multicast/broadcast rate limit

2014-07-09 Thread Govindarajulu Varadarajan



On Wed, 9 Jul 2014, Mugunthan V N wrote:


Add support for multicast/broadcast rate limit feature via ethtool coalesce.

Signed-off-by: Mugunthan V N 
---
drivers/net/ethernet/ti/cpsw.c | 80 --
1 file changed, 78 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index a6117e6..2a984e6 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -403,6 +403,8 @@ struct cpsw_priv {
bool irq_enabled;
struct cpts *cpts;
u32 emac_port;
+   u32 rx_max_mcast;
+   u32 rx_max_bcast;
};

struct cpsw_stats {
@@ -871,11 +873,13 @@ static int cpsw_get_coalesce(struct net_device *ndev,
struct cpsw_priv *priv = netdev_priv(ndev);

coal->rx_coalesce_usecs = priv->coal_intvl;
+   coal->rx_max_mcast = priv->rx_max_mcast;
+   coal->rx_max_bcast = priv->rx_max_bcast;
return 0;
}

-static int cpsw_set_coalesce(struct net_device *ndev,
-   struct ethtool_coalesce *coal)
+static int cpsw_set_coalesce_usecs(struct net_device *ndev,
+  struct ethtool_coalesce *coal)
{
struct cpsw_priv *priv = netdev_priv(ndev);
u32 int_ctrl;
@@ -933,6 +937,74 @@ static int cpsw_set_coalesce(struct net_device *ndev,
return 0;
}

+static int cpsw_set_coalesce_mcast(struct net_device *ndev,
+  struct ethtool_coalesce *coal)
+{
+   struct cpsw_priv *priv = netdev_priv(ndev);
+   int port;
+
+   priv->rx_max_mcast = coal->rx_max_mcast;
+
+   if (priv->data.dual_emac)
+   port = priv->emac_port;
+   else
+   port = priv->data.active_slave;
+
+   cpsw_ale_control_set(priv->ale, port, ALE_PORT_MCAST_LIMIT,
+coal->rx_max_mcast);
+
+   dev_dbg(priv->dev, "rx_max_mcast set to %d\n", priv->rx_max_mcast);
+   return 0;
+}
+
+static int cpsw_set_coalesce_bcast(struct net_device *ndev,
+  struct ethtool_coalesce *coal)
+{
+   struct cpsw_priv *priv = netdev_priv(ndev);
+   int port;
+
+   priv->rx_max_bcast = coal->rx_max_bcast;
+
+   if (priv->data.dual_emac)
+   port = priv->emac_port + 1;
+   else
+   port = priv->data.active_slave + 1;
+
+   cpsw_ale_control_set(priv->ale, port, ALE_PORT_BCAST_LIMIT,
+coal->rx_max_bcast);


Both cpsw_set_coalesce_bcast & cpsw_set_coalesce_mcast always return 0.
May be you can return result of cpsw_ale_control_set()?


+
+   dev_dbg(priv->dev, "rx_max_mcast set to %d\n", priv->rx_max_bcast);
+   return 0;
+}
+
+static int cpsw_set_coalesce(struct net_device *ndev,
+struct ethtool_coalesce *coal)
+{
+   int ret = -EINVAL;
+
+   if (coal->rx_coalesce_usecs) {
+   ret = cpsw_set_coalesce_usecs(ndev, coal);
+   if (ret) {
+   dev_err(&ndev->dev, "set rx-usecs failed\n");
+   return ret;
+   }
+   }
+
+   ret = cpsw_set_coalesce_mcast(ndev, coal);
+   if (ret) {
+   dev_err(&ndev->dev, "set coalesce rx-max-mcast failed\n");
+   return ret;
+   }


So that ret check here will be meaningful.

thanks

+
+   ret = cpsw_set_coalesce_bcast(ndev, coal);
+   if (ret) {
+   dev_err(&ndev->dev, "set coalesce rx-max-bcast failed\n");
+   return ret;
+   }
+
+   return ret;
+}
+
static int cpsw_get_sset_count(struct net_device *ndev, int sset)
{
switch (sset) {
@@ -1227,6 +1299,10 @@ static int cpsw_ndo_open(struct net_device *ndev)
/* enable statistics collection only on all ports */
__raw_writel(0x7, &priv->regs->stat_port_en);

+   /* Enable rate limit feature in the switch for rx only */
+   cpsw_ale_control_set(priv->ale, 0, ALE_RATE_LIMIT, 1);
+   cpsw_ale_control_set(priv->ale, 0, ALE_RATE_LIMIT_TX, 0);
+
if (WARN_ON(!priv->data.rx_descs))
priv->data.rx_descs = 128;

--
2.0.0.390.gcb682f8

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: randconfig build error with next-20140522, in drivers/net/ethernet/cisco/enic/enic_main.c

2014-05-22 Thread Govindarajulu Varadarajan



On Thu, 22 May 2014, Jim Davis wrote:


Building with the attached random configuration file,

drivers/built-in.o: In function `enic_poll_msix':
enic_main.c:(.text+0x48710a): undefined reference to `__udivdi3'
make: *** [vmlinux] Error 1



Looks like 64 bit divide issue. Will look into it.

Thanks for reporting.

Govind
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH net-next 02/13] driver: net: remove unnecessary skb NULL check before calling dev_kfree_skb_irq

2013-11-18 Thread Govindarajulu Varadarajan

Hi Dave

Did you have a chance to look at this? Let me know how you want me to
fix this.

//govind

On Mon, 11 Nov 2013, Govindarajulu Varadarajan wrote:




On Mon, 4 Nov 2013, David Miller wrote:


From: Govindarajulu Varadarajan 
Date: Sat,  2 Nov 2013 19:17:43 +0530

@@ -1030,10 +1030,8 @@ static void ni65_xmit_intr(struct net_device 
*dev,int csr0)

}

 #ifdef XMT_VIA_SKB
-   if(p->tmd_skb[p->tmdlast]) {
-dev_kfree_skb_irq(p->tmd_skb[p->tmdlast]);
-p->tmd_skb[p->tmdlast] = NULL;
-   }
+dev_kfree_skb_irq(p->tmd_skb[p->tmdlast]);
+p->tmd_skb[p->tmdlast] = NULL;
 #endif


I absolutely disagree with this kind of change.

There is a non-trivial cost for NULL'ing out that array entry
unconditionally.  It's a dirtied cache line and this is in the
fast path of TX SKB reclaim of this driver.

You've made several changes of this kind.

And it sort-of shows that the places that do check for NULL,
are getting something in return for that test, namely avoidance
of an unnecessary cpu store in the fast path of the driver.



True, in case of dev_kfree_skb_irq. If you look at patch 06-12, at many
places we do

if (s->skb) {
dev_kfree_skb_any(s->skb);
s->skb = NULL)
}

This is in fast path. If the code is not running in hardirq,
dev_kfree_skb_any calls dev_kfree_skb. Which again check if skb is NULL.
So we are checking if skb is null twice. That is what this patch is
trying to fix. (sorry I should have mentioned this in cover letter).

I am not sure if you have read my previous mail. I am pasting it below.

On Sun, 3 Nov 2013, Brandeburg, Jesse wrote: Thanks for this work, I'm a 
little concerned that there is a

non-trivial overhead to this patch.

when doing (for example in the Intel drivers): if (s->skb) {
 dev_kfree_skb(s->skb);
 s->skb = NULL; }



In current code, dev_kfree_skb is NULL safe. Which means skb is
checked for NULL inside dev_kfree_skb. dev_kfree_skb_any is also NULL safe
when the code is running in non-hardirq.

Lets consider two cases

1. skb is not NULL:
 * Without my patch:
  In the code above, we check for skb!=NULL twice. (once
  before calling dev_kfree_skb, once by dev_kfree_skb). And
  then we do assignment.
  * With this patch:
  we check for skb!=NULL once, And then we do assignment.

  To fix the twice NULL check, we either have to remove the check
  which is inside dev_kfree_skb (1). Or do whats done in this
  patch.

  (1) is not an option because a lot of kernel code already
  assumes that dev_kfree_skb is NULL safe.

2. skb is NULL:
  * Without this patch:
  One if statement is executed.
  * With this patch:
  One if statement and one assignment is executed.

From my observation most of the dev_kfree_skb calls are from
e1000_unmap_and_free_tx_resource, e1000_put_txbuf,
atl1_clean_tx_ring, alx_free_txbuf etc. in clean up functions.

Is is quite unlikely thats skb is NULL. So it comes down to one extra
if-branching statement or one extra assignment. I would prefer extra
assignment to branching statement. In my opinion extra assignment is
very little price we pay.

//govind


Another way to solve the double NULL check is to define a new function
something like this

dev_kfree_skb_NULL(struct sk_buff **skb)
{
if(*skb) {
free_skb(*skb);
*skb=NULL;
}
}

and use this if you want to free a skb and make it NULL.
Is this approach better?

//govind



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH net-next v3 04/19] net: enic: slight optimization of addr compare

2013-12-30 Thread Govindarajulu Varadarajan

On Mon, 30 Dec 2013, Ding Tianhong wrote:


Use possibly more efficient ether_addr_equal
to instead of memcmp.

Cc: Christian Benvenuti 
Cc: Sujith Sankar 
Cc: Govindarajulu Varadarajan 
Cc: Neel Patel 
Cc: Nishank Trivedi 
Signed-off-by: Ding Tianhong 
---
drivers/net/ethernet/cisco/enic/enic_pp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/cisco/enic/enic_pp.c 
b/drivers/net/ethernet/cisco/enic/enic_pp.c
index 43464f0..e6a8319 100644
--- a/drivers/net/ethernet/cisco/enic/enic_pp.c
+++ b/drivers/net/ethernet/cisco/enic/enic_pp.c
@@ -162,7 +162,7 @@ static int enic_are_pp_different(struct enic_port_profile 
*pp1,
return strcmp(pp1->name, pp2->name) | !!memcmp(pp1->instance_uuid,
pp2->instance_uuid, PORT_UUID_MAX) |
!!memcmp(pp1->host_uuid, pp2->host_uuid, PORT_UUID_MAX) |
-   !!memcmp(pp1->mac_addr, pp2->mac_addr, ETH_ALEN);
+   !ether_addr_equal(pp1->mac_addr, pp2->mac_addr);
}

static int enic_pp_preassociate(struct enic *enic, int vf,
--
1.8.0



looks good for me

Acked-by: Govindarajulu Varadarajan 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: btrfs: kernel BUG at mm/page-writeback.c:2286!

2015-05-21 Thread Govindarajulu Varadarajan

On Tue, 19 May 2015, Piotr Szymaniak wrote:


On Tue, May 19, 2015 at 09:43:10AM -0400, Chris Mason wrote:

On 05/19/2015 03:55 AM, Govindarajulu Varadarajan wrote:

2286--->BUG_ON(!PageLocked(page));

[  166.769868] BTRFS info (device sdf): no csum found for inode 1154
start 43192320
[  166.774334] BTRFS info (device sdf): csum failed ino 1154 extent
4434247680 csum 1388825687 wanted 0 mirror 0



Josef and I both missed this the first time you pasted it, but the
unlocked page is almost certainly related to this csum error.  While
we're looking at things can you please scrub?


Hi,

In the original report there was:


[root@stg ~]#btrfs scru status /mnt/stg
scrub status for dd10b751-d2aa-40d1-971f-e15b0062dd11
scrub started at Tue May 19 03:33:26 2015 and finished after 468 seconds
total bytes scrubbed: 101.80GiB with 0 errors


Correct me if I'm wrong, but I think that Govindarajulu Varadarajan made the
scrub _after_ the crash.



I ran the scrub before and after the crash. Scrub shows 0 error but then I
access the file which is corrupt, I get I/O error and csum failure
in kernel log.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: btrfs: kernel BUG at mm/page-writeback.c:2286!

2015-05-21 Thread Govindarajulu Varadarajan

On Tue, 19 May 2015, Chris Mason wrote:


On 05/19/2015 09:54 AM, Piotr Szymaniak wrote:

On Tue, May 19, 2015 at 09:43:10AM -0400, Chris Mason wrote:

On 05/19/2015 03:55 AM, Govindarajulu Varadarajan wrote:

2286--->BUG_ON(!PageLocked(page));

[  166.769868] BTRFS info (device sdf): no csum found for inode 1154
start 43192320
[  166.774334] BTRFS info (device sdf): csum failed ino 1154 extent
4434247680 csum 1388825687 wanted 0 mirror 0



Josef and I both missed this the first time you pasted it, but the
unlocked page is almost certainly related to this csum error.  While
we're looking at things can you please scrub?


Josef and I just read through all of this, and I'm not finding a way to
connect the crc error to the BUG_ON.  Do all kernels crash like this, or
was it just 4.1-rc?



The csum error was for one of the files. Scrub did not fix it. When I run Scrub
it shows 0 error. So I deleted the file. I do no see the crash now.

Crash did not happen on 3.18 kernel. I first faced this problem in 3.19.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: btrfs: kernel BUG at mm/page-writeback.c:2286!

2015-05-21 Thread Govindarajulu Varadarajan

On Tue, 19 May 2015, Josef Bacik wrote:


On 05/19/2015 03:55 AM, Govindarajulu Varadarajan wrote:

Hi all

I am seeing the following crash on my btrfs filesystem with nfs export.
If I disable the nfs share and reboot, I do not hit the crash. Look like
the crash happens on btrfs with nfs export.

Is this a known issue? Has anyone else faced this? Let me know if you
need more
information.



Somebody else is unlocking the page while we have it locked (by somebody else 
I mean somebody other than in this particular code path, so could totally 
still be us, it's just not obvious.)  What are your mount options?  Are you 
capable of building your own kernel?  A git bisect would be good to try and 
find where the problem was introduced, seems like it's easy to reproduce. 
I'll look through our recent commits and see if anything pops out.  Thanks,




Yes, I can do git bisect. But, now that I have deleted the file with csum error
I do not see the crash any more. Sorry.

Is there any was to introduce
"BTRFS info (device sdf): csum failed ino 1154 extent 4434247680 csum 1388825687 
wanted 0 mirror 0"?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


btrfs: kernel BUG at mm/page-writeback.c:2286!

2015-05-19 Thread Govindarajulu Varadarajan

Hi all

I am seeing the following crash on my btrfs filesystem with nfs export.
If I disable the nfs share and reboot, I do not hit the crash. Look like
the crash happens on btrfs with nfs export.

Is this a known issue? Has anyone else faced this? Let me know if you need more
information.

Thanks

mm/page-writeback.c:2286:
int clear_page_dirty_for_io(struct page *page) 
{

struct address_space *mapping = page_mapping(page);

2286--->BUG_ON(!PageLocked(page));

[  166.769868] BTRFS info (device sdf): no csum found for inode 1154 start 
43192320
[  166.774334] BTRFS info (device sdf): csum failed ino 1154 extent 4434247680 
csum 1388825687 wanted 0 mirror 0
[  166.774453] [ cut here ]
[  166.774481] kernel BUG at mm/page-writeback.c:2286!
[  166.774495] invalid opcode:  [#1] PREEMPT SMP 
[  166.774514] Modules linked in: nfsv3 target_core_user uio target_core_pscsi target_core_file target_core_iblock iscsi_target_mod target_core_mod rpcsec_gss_krb5 nfsv4 dns_resolver coretemp intel_rapl iosf_mbi x86_pkg_temp_thermal intel_powerclamp kvm_intel kvm crct10dif_pclmul crc32_pclmul ghash_clmulni_intel aesni_intel aes_x86_64 iTCO_wdt lrw joydev gf128mul mgag200 glue_helper ablk_helper mousedev evdev pcspkr iTCO_vendor_support cryptd ttm drm_kms_helper drm syscopyarea sysfillrect mac_hid sysimgblt i2c_i801 lpc_ich acpi_power_meter tpm_tis sb_edac edac_core wmi shpchp processor ipmi_si ipmi_msghandler tpm ac button sch_fq_codel ses enclosure sd_mod hid_generic usbhid hid ehci_pci ehci_hcd megaraid_sas scsi_mod usbcore usb_common nfsd auth_rpcgss oid_registry nfs_acl nfs lockd grace sunrpc fscache

[  166.774801]  igb hwmon ptp pps_core i2c_algo_bit i2c_core dca ext4 crc16 
mbcache jbd2 crc32c_generic crc32c_intel btrfs xor raid6_pq
[  166.774852] CPU: 4 PID: 806 Comm: nfsd Not tainted 
4.1.0-rc3-ARCH-00165-g110bc76 #4
[  166.774873] Hardware name: Cisco Systems Inc UCSC-C240-M3S/UCSC-C240-M3S, 
BIOS C240M3.1.5.1c.0.013120130509 01/31/2013
[  166.774901] task: 88183796c980 ti: 881839034000 task.ti: 
881839034000
[  166.774922] RIP: 0010:[]  [] 
clear_page_dirty_for_io+0xd0/0xf0
[  166.774950] RSP: 0018:881839037908  EFLAGS: 00010246
[  166.774965] RAX: 02fffe000806 RBX: ea0030ffd680 RCX: 0484
[  166.774985] RDX:  RSI:  RDI: ea0030ffd680
[  166.775004] RBP: 881839037918 R08: 0001ff40 R09: 880c474e8600
[  166.775023] R10: 880c4fb1ff40 R11: ea00311943c0 R12: 880c44210300
[  166.775042] R13: 0001 R14: 880c48355b40 R15: 
[  166.775062] FS:  () GS:880c4fb0() 
knlGS:
[  166.775083] CS:  0010 DS:  ES:  CR0: 80050033
[  166.775099] CR2: 7fcfe214e0a0 CR3: 0173f000 CR4: 000407e0
[  166.775118] Stack:
[  166.775125]  0001 880c48355b40 881839037988 
a0073d32
[  166.775150]  881839037a10 0050 1000 
880c442101b0
[  166.775174]  880c44210040 881839037a20 880c4937ee40 
0001
[  166.775198] Call Trace:
[  166.775220]  [] lock_and_cleanup_extent_if_need+0x72/0x1f0 
[btrfs]
[  166.775248]  [] __btrfs_buffered_write+0x1b1/0x680 [btrfs]
[  166.775273]  [] btrfs_file_write_iter+0x162/0x5a0 [btrfs]
[  166.775295]  [] do_iter_readv_writev+0x6c/0xb0
[  166.775312]  [] do_readv_writev+0x13b/0x280
[  166.775334]  [] ? btrfs_sync_file+0x380/0x380 [btrfs]
[  166.775354]  [] ? inode_to_bdi+0x27/0x60
[  166.775371]  [] ? finish_no_open+0x20/0x20
[  166.775388]  [] ? file_ra_state_init+0x19/0x30
[  166.775405]  [] ? do_dentry_open+0x230/0x320
[  166.775422]  [] vfs_writev+0x39/0x50
[  166.775443]  [] nfsd_vfs_write.isra.15+0xb8/0x380 [nfsd]
[  166.775467]  [] nfsd_write+0xec/0x100 [nfsd]
[  166.775487]  [] nfsd3_proc_write+0xbb/0x160 [nfsd]
[  166.776205]  [] nfsd_dispatch+0xc3/0x220 [nfsd]
[  166.776922]  [] ? svc_tcp_adjust_wspace+0x12/0x30 [sunrpc]
[  166.777639]  [] svc_process_common+0x45c/0x680 [sunrpc]
[  166.778371]  [] svc_process+0x113/0x200 [sunrpc]
[  166.779087]  [] nfsd+0x107/0x170 [nfsd]
[  166.779765]  [] ? nfsd_destroy+0x80/0x80 [nfsd]
[  166.780465]  [] kthread+0xd8/0xf0
[  166.781137]  [] ? kthread_create_on_node+0x1c0/0x1c0
[  166.781799]  [] ret_from_fork+0x42/0x70
[  166.782443]  [] ? kthread_create_on_node+0x1c0/0x1c0
[  166.783072] Code: 41 5c 5d c3 0f 1f 80 00 00 00 00 48 89 df e8 f8 0d 03 00 85 c0 75 1c f0 0f ba 33 04 72 85 31 c0 e9 75 ff ff ff 66 0f 1f 44 00 00 <0f> 0b 66 0f 1f 44 00 00 48 89 df e8 60 fe ff ff eb da 66 66 66 
[  166.784408] RIP  [] clear_page_dirty_for_io+0xd0/0xf0

[  166.785026]  RSP 
[  166.785630] ---[ end trace c20a91c708e09203 ]---


[root@stg ~]#btrfs fi sh
Label: 'stg'  uuid: dd10b751-d2aa-40d1-971f-e15b0062dd11
Total devices 14 FS bytes used 101.80GiB
devid1 size 278.46GiB used 9.47GiB path /dev/sdb
devid2 size 278.46GiB used 9.47GiB pa

[PATCH V2] PCI: AER: fix deadlock in do_recovery

2017-09-29 Thread Govindarajulu Varadarajan
it_for_completion+0x14a/0x1d0
[  110.847068]  wait_for_completion+0x169/0x1d0
[  110.898165]  ? wait_for_completion+0x169/0x1d0
[  110.951354]  ? wake_up_q+0x80/0x80
[  110.992060]  flush_work+0x237/0x300
[  111.033795]  ? flush_workqueue_prep_pwqs+0x1b0/0x1b0
[  111.093224]  ? wait_for_completion+0x5a/0x1d0
[  111.145363]  ? flush_work+0x237/0x300
[  111.189189]  work_on_cpu+0x94/0xb0
[  111.229894]  ? work_is_static_object+0x20/0x20
[  111.283070]  ? pci_device_shutdown+0x60/0x60
[  111.334173]  pci_device_probe+0x17a/0x190
[  111.382163]  driver_probe_device+0x2ff/0x450
[  111.433260]  __driver_attach+0x103/0x140
[  111.480195]  ? driver_probe_device+0x450/0x450
[  111.533381]  bus_for_each_dev+0x74/0xb0
[  111.579276]  driver_attach+0x1e/0x20
[  111.622056]  bus_add_driver+0x1ca/0x270
[  111.667955]  ? 0xc039c000
[  111.707616]  driver_register+0x60/0xe0
[  111.752472]  ? 0xc039c000
[  111.792126]  __pci_register_driver+0x6b/0x70
[  111.843275]  enic_init_module+0x38/0x1000 [enic]
[  111.898533]  do_one_initcall+0x50/0x192
[  111.944428]  ? trace_hardirqs_on+0xd/0x10
[  111.992408]  do_init_module+0x5f/0x1f2
[  112.037274]  load_module+0x1740/0x1f70
[  112.082148]  SYSC_finit_module+0xd7/0xf0
[  112.129083]  ? SYSC_finit_module+0xd7/0xf0
[  112.178106]  SyS_finit_module+0xe/0x10
[  112.222972]  do_syscall_64+0x69/0x180
[  112.266793]  entry_SYSCALL64_slow_path+0x25/0x25
[  112.322047] RIP: 0033:0x7f3da098b559
[  112.364826] RSP: 002b:7ffeb3306a38 EFLAGS: 0246 ORIG_RAX: 
0139
[  112.455447] RAX: ffda RBX: 557fe41ed3d0 RCX: 7f3da098b559
[  112.540860] RDX:  RSI: 7f3da14c79c5 RDI: 0006
[  112.626281] RBP: 7f3da14c79c5 R08:  R09: 7ffeb3306b50
[  112.711698] R10: 0006 R11: 0246 R12: 
[  112.797114] R13: 557fe420e210 R14: 0002 R15: 557fe2c1ef4a
[  112.882568]
   Showing all locks held in the system:
[  112.956545] 5 locks held by kworker/0:1/76:
[  113.006616]  #0:  ("events"){+.+.}, at: [] 
process_one_work+0x1ed/0x6c0
[  113.104535]  #1:  ((&rpc->dpc_handler)){+.+.}, at: [] 
process_one_work+0x1ed/0x6c0
[  113.213894]  #2:  (&rpc->rpc_mutex){+.+.}, at: [] 
aer_isr+0x32/0x3b0
[  113.308711]  #3:  (pci_bus_sem){}, at: [] 
pci_walk_bus+0x2a/0x90
[  113.403501]  #4:  (&dev->mutex){}, at: [] 
report_error_detected+0xa6/0x210
[  113.508715] 3 locks held by kworker/0:2/205:
[  113.559808]  #0:  ("events"){+.+.}, at: [] 
process_one_work+0x1ed/0x6c0
[  113.657718]  #1:  ((&wfc.work)){+.+.}, at: [] 
process_one_work+0x1ed/0x6c0
[  113.758745]  #2:  (pci_bus_sem){}, at: [] 
pci_device_add+0x158/0x240
[  113.857710] 1 lock held by khungtaskd/239:
[  113.906729]  #0:  (tasklist_lock){.+.+}, at: [] 
debug_show_all_locks+0x3d/0x1a0
[  114.012972] 2 locks held by systemd-udevd/492:
[  114.066148]  #0:  (&dev->mutex){}, at: [] 
__driver_attach+0x55/0x140
[  114.165107]  #1:  (&dev->mutex){}, at: [] 
__driver_attach+0x72/0x140

[  114.281879] =

Signed-off-by: Govindarajulu Varadarajan 
---
 drivers/pci/pcie/aer/aerdrv.h  |  5 +
 drivers/pci/pcie/aer/aerdrv_core.c | 45 --
 2 files changed, 48 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/pcie/aer/aerdrv.h b/drivers/pci/pcie/aer/aerdrv.h
index d51e4a57b190..f6d8761dc656 100644
--- a/drivers/pci/pcie/aer/aerdrv.h
+++ b/drivers/pci/pcie/aer/aerdrv.h
@@ -105,6 +105,11 @@ static inline pci_ers_result_t merge_result(enum 
pci_ers_result orig,
return orig;
 }
 
+struct aer_device_list {
+   struct device *dev;
+   struct hlist_node node;
+};
+
 extern struct bus_type pcie_port_bus_type;
 void aer_isr(struct work_struct *work);
 void aer_print_error(struct pci_dev *dev, struct aer_err_info *info);
diff --git a/drivers/pci/pcie/aer/aerdrv_core.c 
b/drivers/pci/pcie/aer/aerdrv_core.c
index 890efcc574cb..d524f2c2c288 100644
--- a/drivers/pci/pcie/aer/aerdrv_core.c
+++ b/drivers/pci/pcie/aer/aerdrv_core.c
@@ -346,6 +346,47 @@ static int report_resume(struct pci_dev *dev, void *data)
return 0;
 }
 
+int aer_get_pci_dev(struct pci_dev *pdev, void *data)
+{
+   struct hlist_head *hhead = (struct hlist_head *)data;
+   struct device *dev = &pdev->dev;
+   struct aer_device_list *entry;
+
+   entry = kmalloc(sizeof(*entry), GFP_KERNEL);
+   if (!entry)
+   /* continue with other devices, lets not return error */
+   return 0;
+
+   entry->dev = get_device(dev);
+   hlist_add_head(&entry->node, hhead);
+
+   return 0;
+}
+
+static void aer_pci_walk_bus(struct pci_bus *top,
+int (*cb)(struct pci_dev *, void *),
+struct aer_broadcast_data *result)
+{
+   HLIST_HEAD(dev_hlist);
+   struct hli

Re: [PATCH 3/4] pci aer: fix deadlock in do_recovery

2017-09-29 Thread Govindarajulu Varadarajan

On Fri, 29 Sep 2017, Sinan Kaya wrote:


On 9/28/2017 7:46 PM, Govindarajulu Varadarajan wrote:

How about releasing the device_lock here on CPU0?>


pci_device_add() is called by driver's pci probe function. device_lock(dev)
should be held before calling pci driver probe function.


I see. The goal of the lock held here is to protect probe() operation from
being disrupted. I also don't think we can change this.




or in other words keep device_lock as short as possible?


The problem is not the duration device_lock is held. It is the order two locks
are aquired. We cannot control or implement a restriction that during
device_lock() is held, driver probe should not call pci function which aquires
pci_bus_sem. And in case of pci aer, aer handler needs to call driver 
err_handler()
for which we need to hold device_lock() before calling err_handler(). In order
to find all the devices on a pci bus, we should hold pci_bus_sem to do
pci_walk_bus().


I was reacting to this to see if there is a better way to do this.

"Only fix I could think of is to lock &pci_bus_sem and try locking all
device->mutex under that pci_bus. If it fails, unlock all device->mutex
and &pci_bus_sem and try again."

How about gracefully returning from report_error_detected() when we cannot 
obtain
the device_lock() by replacing it with device_trylock()?



Some of the devices may miss the error reporthing. I have sent V2 where we do
a pci_bus_walk and adds all the devices to a list. After unlocking (up_read)
&pci_bus_sem, we go through the list and call err_handler of the devices with
devic_lock() held. This way, we dont try to hold both locks at same time and
we dont hold 50+ device_lock. Let me know if this approach is better.


aer_pci_walk_bus() can still poll like you did until it gets the lock. At least,
we don't get to introduce a new API, new lock semantics and code refactoring.
__pci_bus_trylock() looked very powerful and also dangerously flexible to
introduce new bugs to me.

For instance, you called it like this.

+   down_read(&pci_bus_sem);
+   locked = __pci_bus_trylock(bus, pci_device_trylock,
+  pci_device_unlock);

pci_bus_trylock() would obtain device + cfg locks whereas pci_device_trylock() 
only
obtains the device lock. Can it race against cfg lock? It depends on the caller.
Very subtle difference.

--
Sinan Kaya
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm 
Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux 
Foundation Collaborative Project.



Re: [PATCH 4/4] lockdep: make MAX_LOCK_DEPTH configurable from Kconfig

2017-09-29 Thread Govindarajulu Varadarajan

On Fri, 29 Sep 2017, Bjorn Helgaas wrote:


On Thu, Sep 28, 2017 at 04:51:46PM -0700, Govindarajulu Varadarajan wrote:

On Thu, 28 Sep 2017, Peter Zijlstra wrote:


On Wed, Sep 27, 2017 at 02:42:20PM -0700, Govindarajulu Varadarajan wrote:

Make MAX_LOCK_DEPTH configurable. It is set to 48 right now. Number of
VFs under a PCI pf bus can exceed 48 and this disables lockdep.

lockdep currently allows max of 63 held_locks.


But why a config knob? Why not just raise the number to 64
unconditionally? And is that sufficient; you only state 48 is
insufficient, you don't actually state the VF limit.



I did not want to change the default configuration for everyone.

I will change it 63 unconditionally in v2 and resubmit the series.


I'm not happy about having to increase MAX_LOCK_DEPTH based on a
number of VFs.  I haven't had time to look at the locking strategy
you're proposing, but it just doesn't feel right to have to take 50+
locks for one operation.


I agree. I have sent V2 where we dont lock 50+ device_lock. Please have a look.


Re: [PATCH V2] PCI: AER: fix deadlock in do_recovery

2017-10-02 Thread Govindarajulu Varadarajan

On Sun, 1 Oct 2017, Christoph Hellwig wrote:


+struct aer_device_list {
+   struct device *dev;
+   struct hlist_node node;
+};
+
 extern struct bus_type pcie_port_bus_type;
 void aer_isr(struct work_struct *work);
 void aer_print_error(struct pci_dev *dev, struct aer_err_info *info);
diff --git a/drivers/pci/pcie/aer/aerdrv_core.c 
b/drivers/pci/pcie/aer/aerdrv_core.c
index 890efcc574cb..d524f2c2c288 100644
--- a/drivers/pci/pcie/aer/aerdrv_core.c
+++ b/drivers/pci/pcie/aer/aerdrv_core.c
@@ -346,6 +346,47 @@ static int report_resume(struct pci_dev *dev, void *data)
return 0;
 }

+int aer_get_pci_dev(struct pci_dev *pdev, void *data)
+{
+   struct hlist_head *hhead = (struct hlist_head *)data;
+   struct device *dev = &pdev->dev;
+   struct aer_device_list *entry;
+
+   entry = kmalloc(sizeof(*entry), GFP_KERNEL);
+   if (!entry)
+   /* continue with other devices, lets not return error */
+   return 0;
+
+   entry->dev = get_device(dev);
+   hlist_add_head(&entry->node, hhead);
+
+   return 0;


Can we just embedded the list_head in the pci_dev?  Or is there a way
we can have multiple chains like this pending at the same time?



I would avoid increasing the size of pci_dev. The list_head would be empty after
we call aer_pci_walk_bus(). We already have pci_bus *subordinate to link all the
'device's. Making list_head available to others would require a lock. I would
avoid that.


+static void aer_pci_walk_bus(struct pci_bus *top,
+int (*cb)(struct pci_dev *, void *),
+struct aer_broadcast_data *result)
+{
+   HLIST_HEAD(dev_hlist);
+   struct hlist_node *tmp;
+   struct aer_device_list *entry;


Do we want to offer this as generic PCIe functionality?  If not we can
probably hardcode the callback and callback data to simplify this a lot.



I could not find any other code which aquires device_lock in pci_walk_bus cb
function. Can you tell me how we can hardcore callback and callback data here?


Re: [PATCH V2] PCI: AER: fix deadlock in do_recovery

2017-10-02 Thread Govindarajulu Varadarajan

On Sat, 30 Sep 2017, Sinan Kaya wrote:


On 9/30/2017 1:49 AM, Govindarajulu Varadarajan wrote:

This patch does a pci_bus_walk and adds all the devices to a list. After
unlocking (up_read) &pci_bus_sem, we go through the list and call
err_handler of the devices with devic_lock() held. This way, we dont try
to hold both locks at same time.


I do like this approach with some more feedback.

I need a little bit of help here from someone that knows get/put device calls.

I understand get_device() and put_device() are there to increment/decrement
reference counters. This patch seems to use them as an alternative for 
device_lock()
and device_unlock() API.



get/put_deivce is not used as an alternative to device_lock() here. We are
incrementing the counter to make sure no one else free the device while they
are in our list. report_error_detected() and other cb will still acquire
device_lock().



If this is a good assumption, then you can get away with just replacing 
device_lock()
with get_device() and device_unlock() with put_device() in the existing code as
well. Then, you don't need to build a linklist.




[PATCH 0/4] pci aer: fix deadlock in do_recovery

2017-09-27 Thread Govindarajulu Varadarajan
I am seeing a dead lock while loading enic driver with sriov enabled.

CPU0CPU1
-
__driver_attach()
device_lock(&dev->mutex) <--- device mutex lock here
driver_probe_device()
pci_enable_sriov()
pci_iov_add_virtfn()
pci_device_add()
aer_isr()   <--- pci aer 
error
do_recovery()
broadcast_error_message()
pci_walk_bus()
down_read(&pci_bus_sem) <--- rd sem
down_write(&pci_bus_sem) <-- stuck on wr sem
report_error_detected()
device_lock(&dev->mutex)<--- DEAD LOCK

This can also happen when aer error occurs while pci_dev->sriov_config() is
called.

Only fix I could think of is to lock &pci_bus_sem and try locking all
device->mutex under that pci_bus. If it fails, unlock all device->mutex
and &pci_bus_sem and try again. This approach seems to be hackish and I
do not have better solution. I would like to open the discussion for
this.

Path 1 and 2 are code refactoring for pci locking api. Patch 3 fixes the
issue.

With current fix, we hold mutex lock of parent device and all the
devices under the bus. This can exceed the size of held_locks in lockdep
if number of devices (VFs) exceed 48. Patch 4 extends this 63, max
supported by lockdep.

Govindarajulu Varadarajan (4):
  pci: introduce __pci_walk_bus for caller with pci_bus_sem held
  pci: code refactor pci_bus_lock/unlock/trylock
  pci aer: fix deadlock in do_recovery
  lockdep: make MAX_LOCK_DEPTH configurable from Kconfig

 drivers/pci/bus.c  | 13 --
 drivers/pci/pci.c  | 38 -
 drivers/pci/pcie/aer/aerdrv_core.c | 50 ++
 fs/configfs/inode.c|  2 +-
 include/linux/pci.h| 18 ++
 include/linux/sched.h  |  3 +--
 kernel/locking/lockdep.c   | 13 +-
 lib/Kconfig.debug  | 10 
 8 files changed, 115 insertions(+), 32 deletions(-)

-- 
2.14.1



[PATCH 4/4] lockdep: make MAX_LOCK_DEPTH configurable from Kconfig

2017-09-27 Thread Govindarajulu Varadarajan
Make MAX_LOCK_DEPTH configurable. It is set to 48 right now. Number of
VFs under a PCI pf bus can exceed 48 and this disables lockdep.

lockdep currently allows max of 63 held_locks.

Signed-off-by: Govindarajulu Varadarajan 
---
 fs/configfs/inode.c  |  2 +-
 include/linux/sched.h|  3 +--
 kernel/locking/lockdep.c | 13 +++--
 lib/Kconfig.debug| 10 ++
 4 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/fs/configfs/inode.c b/fs/configfs/inode.c
index ad718e5e37bb..a1e2a7ce69d0 100644
--- a/fs/configfs/inode.c
+++ b/fs/configfs/inode.c
@@ -41,7 +41,7 @@
 #include "configfs_internal.h"
 
 #ifdef CONFIG_LOCKDEP
-static struct lock_class_key default_group_class[MAX_LOCK_DEPTH];
+static struct lock_class_key default_group_class[CONFIG_MAX_LOCK_DEPTH];
 #endif
 
 static const struct address_space_operations configfs_aops = {
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 92fb8dd5a9e4..9a81eec702be 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -841,11 +841,10 @@ struct task_struct {
 #endif
 
 #ifdef CONFIG_LOCKDEP
-# define MAX_LOCK_DEPTH48UL
u64 curr_chain_key;
int lockdep_depth;
unsigned intlockdep_recursion;
-   struct held_lockheld_locks[MAX_LOCK_DEPTH];
+   struct held_lockheld_locks[CONFIG_MAX_LOCK_DEPTH];
 #endif
 
 #ifdef CONFIG_LOCKDEP_CROSSRELEASE
diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index 44c8d0d17170..22a4a338616d 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -3404,7 +3404,7 @@ static int __lock_acquire(struct lockdep_map *lock, 
unsigned int subclass,
/*
 * Ran out of static storage for our per-task lock stack again have we?
 */
-   if (DEBUG_LOCKS_WARN_ON(depth >= MAX_LOCK_DEPTH))
+   if (DEBUG_LOCKS_WARN_ON(depth >= CONFIG_MAX_LOCK_DEPTH))
return 0;
 
class_idx = class - lock_classes + 1;
@@ -3513,11 +3513,11 @@ static int __lock_acquire(struct lockdep_map *lock, 
unsigned int subclass,
if (unlikely(!debug_locks))
return 0;
 #endif
-   if (unlikely(curr->lockdep_depth >= MAX_LOCK_DEPTH)) {
+   if (unlikely(curr->lockdep_depth >= CONFIG_MAX_LOCK_DEPTH)) {
debug_locks_off();
print_lockdep_off("BUG: MAX_LOCK_DEPTH too low!");
printk(KERN_DEBUG "depth: %i  max: %lu!\n",
-  curr->lockdep_depth, MAX_LOCK_DEPTH);
+  curr->lockdep_depth, CONFIG_MAX_LOCK_DEPTH);
 
lockdep_print_held_locks(current);
debug_show_all_locks();
@@ -4276,7 +4276,8 @@ void lockdep_reset(void)
current->curr_chain_key = 0;
current->lockdep_depth = 0;
current->lockdep_recursion = 0;
-   memset(current->held_locks, 0, MAX_LOCK_DEPTH*sizeof(struct held_lock));
+   memset(current->held_locks, 0,
+  CONFIG_MAX_LOCK_DEPTH * sizeof(struct held_lock));
nr_hardirq_chains = 0;
nr_softirq_chains = 0;
nr_process_chains = 0;
@@ -4421,7 +4422,7 @@ void __init lockdep_info(void)
printk("Lock dependency validator: Copyright (c) 2006 Red Hat, Inc., 
Ingo Molnar\n");
 
printk("... MAX_LOCKDEP_SUBCLASSES:  %lu\n", MAX_LOCKDEP_SUBCLASSES);
-   printk("... MAX_LOCK_DEPTH:  %lu\n", MAX_LOCK_DEPTH);
+   printk("... MAX_LOCK_DEPTH:  %lu\n", CONFIG_MAX_LOCK_DEPTH);
printk("... MAX_LOCKDEP_KEYS:%lu\n", MAX_LOCKDEP_KEYS);
printk("... CLASSHASH_SIZE:  %lu\n", CLASSHASH_SIZE);
printk("... MAX_LOCKDEP_ENTRIES: %lu\n", MAX_LOCKDEP_ENTRIES);
@@ -4441,7 +4442,7 @@ void __init lockdep_info(void)
);
 
printk(" per task-struct memory footprint: %lu bytes\n",
-   sizeof(struct held_lock) * MAX_LOCK_DEPTH);
+   sizeof(struct held_lock) * CONFIG_MAX_LOCK_DEPTH);
 }
 
 static void
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 2689b7c50c52..60bc084315a6 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -1187,6 +1187,16 @@ config DEBUG_LOCKDEP
  additional runtime checks to debug itself, at the price
  of more runtime overhead.
 
+config MAX_LOCK_DEPTH
+   int "Maximum held_locks depth"
+   depends on DEBUG_LOCKDEP
+   default 48
+   range 1 63
+   help
+ This is maximum held_lock depth in task_struct for debugging.
+ Increment if you think a task can hold more than default(48) locks.
+ If unsure, set to default value, 48.
+
 config DEBUG_ATOMIC_SLEEP
bool "Sleep inside atomic section checking"
select PREEMPT_COUNT
-- 
2.14.1



[PATCH 1/4] pci: introduce __pci_walk_bus for caller with pci_bus_sem held

2017-09-27 Thread Govindarajulu Varadarajan
Move pci_bus_sem down/up out of pci_walk_bus and rename it to
__pci_walk_bus. Caller who already hold pci_bus_sem can call
__pci_walk_bus.

Signed-off-by: Govindarajulu Varadarajan 
---
 drivers/pci/bus.c   | 13 +++--
 include/linux/pci.h |  2 ++
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c
index bc56cf19afd3..3cababe74af0 100644
--- a/drivers/pci/bus.c
+++ b/drivers/pci/bus.c
@@ -376,8 +376,10 @@ EXPORT_SYMBOL(pci_bus_add_devices);
  *  We check the return of @cb each time. If it returns anything
  *  other than 0, we break out.
  *
+ *  Should be called with read pci_bus_sem held.
+ *
  */
-void pci_walk_bus(struct pci_bus *top, int (*cb)(struct pci_dev *, void *),
+void __pci_walk_bus(struct pci_bus *top, int (*cb)(struct pci_dev *, void *),
  void *userdata)
 {
struct pci_dev *dev;
@@ -386,7 +388,6 @@ void pci_walk_bus(struct pci_bus *top, int (*cb)(struct 
pci_dev *, void *),
int retval;
 
bus = top;
-   down_read(&pci_bus_sem);
next = top->devices.next;
for (;;) {
if (next == &bus->devices) {
@@ -409,6 +410,14 @@ void pci_walk_bus(struct pci_bus *top, int (*cb)(struct 
pci_dev *, void *),
if (retval)
break;
}
+}
+EXPORT_SYMBOL_GPL(__pci_walk_bus);
+
+void pci_walk_bus(struct pci_bus *top, int (*cb)(struct pci_dev *, void *),
+ void *userdata)
+{
+   down_read(&pci_bus_sem);
+   __pci_walk_bus(top, cb, userdata);
up_read(&pci_bus_sem);
 }
 EXPORT_SYMBOL_GPL(pci_walk_bus);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index f68c58a93dd0..b4b1a8a164c0 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1297,6 +1297,8 @@ int pci_scan_bridge(struct pci_bus *bus, struct pci_dev 
*dev, int max,
 
 void pci_walk_bus(struct pci_bus *top, int (*cb)(struct pci_dev *, void *),
  void *userdata);
+void __pci_walk_bus(struct pci_bus *top, int (*cb)(struct pci_dev *, void *),
+   void *userdata);
 int pci_cfg_space_size(struct pci_dev *dev);
 unsigned char pci_bus_max_busnr(struct pci_bus *bus);
 void pci_setup_bridge(struct pci_bus *bus);
-- 
2.14.1



[PATCH 3/4] pci aer: fix deadlock in do_recovery

2017-09-27 Thread Govindarajulu Varadarajan
[  111.145363]  ? flush_work+0x237/0x300
[  111.189189]  work_on_cpu+0x94/0xb0
[  111.229894]  ? work_is_static_object+0x20/0x20
[  111.283070]  ? pci_device_shutdown+0x60/0x60
[  111.334173]  pci_device_probe+0x17a/0x190
[  111.382163]  driver_probe_device+0x2ff/0x450
[  111.433260]  __driver_attach+0x103/0x140
[  111.480195]  ? driver_probe_device+0x450/0x450
[  111.533381]  bus_for_each_dev+0x74/0xb0
[  111.579276]  driver_attach+0x1e/0x20
[  111.622056]  bus_add_driver+0x1ca/0x270
[  111.667955]  ? 0xc039c000
[  111.707616]  driver_register+0x60/0xe0
[  111.752472]  ? 0xc039c000
[  111.792126]  __pci_register_driver+0x6b/0x70
[  111.843275]  enic_init_module+0x38/0x1000 [enic]
[  111.898533]  do_one_initcall+0x50/0x192
[  111.944428]  ? trace_hardirqs_on+0xd/0x10
[  111.992408]  do_init_module+0x5f/0x1f2
[  112.037274]  load_module+0x1740/0x1f70
[  112.082148]  SYSC_finit_module+0xd7/0xf0
[  112.129083]  ? SYSC_finit_module+0xd7/0xf0
[  112.178106]  SyS_finit_module+0xe/0x10
[  112.222972]  do_syscall_64+0x69/0x180
[  112.266793]  entry_SYSCALL64_slow_path+0x25/0x25
[  112.322047] RIP: 0033:0x7f3da098b559
[  112.364826] RSP: 002b:7ffeb3306a38 EFLAGS: 0246 ORIG_RAX: 
0139
[  112.455447] RAX: ffda RBX: 557fe41ed3d0 RCX: 7f3da098b559
[  112.540860] RDX:  RSI: 7f3da14c79c5 RDI: 0006
[  112.626281] RBP: 7f3da14c79c5 R08:  R09: 7ffeb3306b50
[  112.711698] R10: 0006 R11: 0246 R12: 
[  112.797114] R13: 557fe420e210 R14: 0002 R15: 557fe2c1ef4a
[  112.882568]
   Showing all locks held in the system:
[  112.956545] 5 locks held by kworker/0:1/76:
[  113.006616]  #0:  ("events"){+.+.}, at: [] 
process_one_work+0x1ed/0x6c0
[  113.104535]  #1:  ((&rpc->dpc_handler)){+.+.}, at: [] 
process_one_work+0x1ed/0x6c0
[  113.213894]  #2:  (&rpc->rpc_mutex){+.+.}, at: [] 
aer_isr+0x32/0x3b0
[  113.308711]  #3:  (pci_bus_sem){}, at: [] 
pci_walk_bus+0x2a/0x90
[  113.403501]  #4:  (&dev->mutex){}, at: [] 
report_error_detected+0xa6/0x210
[  113.508715] 3 locks held by kworker/0:2/205:
[  113.559808]  #0:  ("events"){+.+.}, at: [] 
process_one_work+0x1ed/0x6c0
[  113.657718]  #1:  ((&wfc.work)){+.+.}, at: [] 
process_one_work+0x1ed/0x6c0
[  113.758745]  #2:  (pci_bus_sem){}, at: [] 
pci_device_add+0x158/0x240
[  113.857710] 1 lock held by khungtaskd/239:
[  113.906729]  #0:  (tasklist_lock){.+.+}, at: [] 
debug_show_all_locks+0x3d/0x1a0
[  114.012972] 2 locks held by systemd-udevd/492:
[  114.066148]  #0:  (&dev->mutex){}, at: [] 
__driver_attach+0x55/0x140
[  114.165107]  #1:  (&dev->mutex){}, at: [] 
__driver_attach+0x72/0x140

[  114.281879] =

Signed-off-by: Govindarajulu Varadarajan 
---
 drivers/pci/pcie/aer/aerdrv_core.c | 50 ++
 1 file changed, 40 insertions(+), 10 deletions(-)

diff --git a/drivers/pci/pcie/aer/aerdrv_core.c 
b/drivers/pci/pcie/aer/aerdrv_core.c
index 890efcc574cb..a3869a3b6e82 100644
--- a/drivers/pci/pcie/aer/aerdrv_core.c
+++ b/drivers/pci/pcie/aer/aerdrv_core.c
@@ -26,6 +26,7 @@
 #include 
 #include 
 #include "aerdrv.h"
+#include "../../pci.h"
 
 #definePCI_EXP_AER_FLAGS   (PCI_EXP_DEVCTL_CERE | 
PCI_EXP_DEVCTL_NFERE | \
 PCI_EXP_DEVCTL_FERE | PCI_EXP_DEVCTL_URRE)
@@ -241,7 +242,6 @@ static int report_error_detected(struct pci_dev *dev, void 
*data)
struct aer_broadcast_data *result_data;
result_data = (struct aer_broadcast_data *) data;
 
-   device_lock(&dev->dev);
dev->error_state = result_data->state;
 
if (!dev->driver ||
@@ -281,7 +281,6 @@ static int report_error_detected(struct pci_dev *dev, void 
*data)
}
 
result_data->result = merge_result(result_data->result, vote);
-   device_unlock(&dev->dev);
return 0;
 }
 
@@ -292,7 +291,6 @@ static int report_mmio_enabled(struct pci_dev *dev, void 
*data)
struct aer_broadcast_data *result_data;
result_data = (struct aer_broadcast_data *) data;
 
-   device_lock(&dev->dev);
if (!dev->driver ||
!dev->driver->err_handler ||
!dev->driver->err_handler->mmio_enabled)
@@ -302,7 +300,6 @@ static int report_mmio_enabled(struct pci_dev *dev, void 
*data)
vote = err_handler->mmio_enabled(dev);
result_data->result = merge_result(result_data->result, vote);
 out:
-   device_unlock(&dev->dev);
return 0;
 }
 
@@ -313,7 +310,6 @@ static int report_slot_reset(struct pci_dev *dev, void 
*data)
struct aer_broadcast_data *result_data;
result_data = (struct aer_broadcast_data *) data;
 
-   device_lock(&dev->dev);

[PATCH 2/4] pci: code refactor pci_bus_lock/unlock/trylock

2017-09-27 Thread Govindarajulu Varadarajan
Introduce __pci_bus_trylock and __pci_bus_unlock with lock and unlock cb
functions as arguments. User can pass on what they want to lock in pci_dev.

Signed-off-by: Govindarajulu Varadarajan 
---
 drivers/pci/pci.c   | 38 +++---
 include/linux/pci.h | 16 
 2 files changed, 43 insertions(+), 11 deletions(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 6078dfc11b11..3c6a9210f27c 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -4377,29 +4377,38 @@ static void pci_bus_lock(struct pci_bus *bus)
}
 }
 
-/* Unlock devices from the bottom of the tree up */
-static void pci_bus_unlock(struct pci_bus *bus)
+void __pci_bus_unlock(struct pci_bus *bus,
+ void (*unlock)(struct pci_dev *dev))
 {
struct pci_dev *dev;
 
list_for_each_entry(dev, &bus->devices, bus_list) {
if (dev->subordinate)
-   pci_bus_unlock(dev->subordinate);
-   pci_dev_unlock(dev);
+   __pci_bus_unlock(dev->subordinate, unlock);
+   unlock(dev);
}
 }
+EXPORT_SYMBOL_GPL(__pci_bus_unlock);
 
-/* Return 1 on successful lock, 0 on contention */
-static int pci_bus_trylock(struct pci_bus *bus)
+/* Unlock devices from the bottom of the tree up */
+static void pci_bus_unlock(struct pci_bus *bus)
+{
+   __pci_bus_unlock(bus, pci_dev_unlock);
+}
+
+int __pci_bus_trylock(struct pci_bus *bus,
+ int (*lock)(struct pci_dev *dev),
+ void (*unlock)(struct pci_dev *dev))
 {
struct pci_dev *dev;
 
list_for_each_entry(dev, &bus->devices, bus_list) {
-   if (!pci_dev_trylock(dev))
+   if (!lock(dev))
goto unlock;
if (dev->subordinate) {
-   if (!pci_bus_trylock(dev->subordinate)) {
-   pci_dev_unlock(dev);
+   if (!__pci_bus_trylock(dev->subordinate, lock,
+  unlock)) {
+   unlock(dev);
goto unlock;
}
}
@@ -4409,11 +4418,18 @@ static int pci_bus_trylock(struct pci_bus *bus)
 unlock:
list_for_each_entry_continue_reverse(dev, &bus->devices, bus_list) {
if (dev->subordinate)
-   pci_bus_unlock(dev->subordinate);
-   pci_dev_unlock(dev);
+   __pci_bus_unlock(dev->subordinate, unlock);
+   unlock(dev);
}
return 0;
 }
+EXPORT_SYMBOL_GPL(__pci_bus_trylock);
+
+/* Return 1 on successful lock, 0 on contention */
+static int pci_bus_trylock(struct pci_bus *bus)
+{
+   return __pci_bus_trylock(bus, pci_dev_trylock, pci_dev_unlock);
+}
 
 /* Do any devices on or below this slot prevent a bus reset? */
 static bool pci_slot_resetable(struct pci_slot *slot)
diff --git a/include/linux/pci.h b/include/linux/pci.h
index b4b1a8a164c0..33359c64cd2e 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1515,6 +1515,22 @@ void pci_cfg_access_lock(struct pci_dev *dev);
 bool pci_cfg_access_trylock(struct pci_dev *dev);
 void pci_cfg_access_unlock(struct pci_dev *dev);
 
+void __pci_bus_unlock(struct pci_bus *bus,
+ void (*unlock)(struct pci_dev *dev));
+int __pci_bus_trylock(struct pci_bus *bus,
+ int (*lock)(struct pci_dev *dev),
+ void (*unlock)(struct pci_dev *dev));
+static inline int pci_device_trylock(struct pci_dev *dev)
+{
+   return device_trylock(&dev->dev);
+}
+
+static inline void pci_device_unlock(struct pci_dev *dev)
+{
+   device_unlock(&dev->dev);
+}
+
+
 /*
  * PCI domain support.  Sometimes called PCI segment (eg by ACPI),
  * a PCI domain is defined to be a set of PCI buses which share
-- 
2.14.1



Re: [PATCH 3/4] pci aer: fix deadlock in do_recovery

2017-09-28 Thread Govindarajulu Varadarajan

On Thu, 28 Sep 2017, Sinan Kaya wrote:


On 9/27/2017 5:42 PM, Govindarajulu Varadarajan wrote:

CPU0CPU1
-
__driver_attach()
device_lock(&dev->mutex) <--- device mutex lock here
driver_probe_device()
pci_enable_sriov()
pci_iov_add_virtfn()
pci_device_add()
aer_isr()   <--- pci aer 
error
do_recovery()
broadcast_error_message()
pci_walk_bus()
down_read(&pci_bus_sem) <--- rd sem


How about releasing the device_lock here on CPU0?>


pci_device_add() is called by driver's pci probe function. device_lock(dev)
should be held before calling pci driver probe function.


or in other words keep device_lock as short as possible?


The problem is not the duration device_lock is held. It is the order two locks
are aquired. We cannot control or implement a restriction that during
device_lock() is held, driver probe should not call pci function which aquires
pci_bus_sem. And in case of pci aer, aer handler needs to call driver 
err_handler()
for which we need to hold device_lock() before calling err_handler(). In order
to find all the devices on a pci bus, we should hold pci_bus_sem to do
pci_walk_bus().


down_write(&pci_bus_sem) <-- stuck on wr sem
report_error_detected()
device_lock(&dev->mutex)<--- DEAD LOCK




Re: [PATCH 4/4] lockdep: make MAX_LOCK_DEPTH configurable from Kconfig

2017-09-28 Thread Govindarajulu Varadarajan

On Thu, 28 Sep 2017, Peter Zijlstra wrote:


On Wed, Sep 27, 2017 at 02:42:20PM -0700, Govindarajulu Varadarajan wrote:

Make MAX_LOCK_DEPTH configurable. It is set to 48 right now. Number of
VFs under a PCI pf bus can exceed 48 and this disables lockdep.

lockdep currently allows max of 63 held_locks.


But why a config knob? Why not just raise the number to 64
unconditionally? And is that sufficient; you only state 48 is
insufficient, you don't actually state the VF limit.



I did not want to change the default configuration for everyone.

I will change it 63 unconditionally in v2 and resubmit the series.


Re: [PATCH 1/4] pci: introduce __pci_walk_bus for caller with pci_bus_sem held

2017-09-28 Thread Govindarajulu Varadarajan

On Thu, 28 Sep 2017, Sinan Kaya wrote:


On 9/27/2017 5:42 PM, Govindarajulu Varadarajan wrote:

+void __pci_walk_bus(struct pci_bus *top, int (*cb)(struct pci_dev *, void *),
+   void *userdata);


pci_walk_bus_locked would be a better name as you are assuming that caller is
holding the lock.



Will change and resubmit for v2.



Re: [PATCH 4.4 234/268] enic: enable rq before updating rq descriptors

2018-06-17 Thread Govindarajulu Varadarajan (gvaradar)
On Mon, 2018-06-18 at 00:06 +0100, Ben Hutchings wrote:
> On Mon, 2018-05-28 at 12:03 +0200, Greg Kroah-Hartman wrote:
> > 4.4-stable review patch.  If anyone has any objections, please let me know.
> > 
> > --
> > 
> > From: Govindarajulu Varadarajan 
> > 
> > [ Upstream commit e8588e268509292550634d9a35f2723a207683b2 ]
> 
> [...]
> > --- a/drivers/net/ethernet/cisco/enic/enic_main.c
> > +++ b/drivers/net/ethernet/cisco/enic/enic_main.c
> 
> [...]
> > @@ -1765,8 +1765,12 @@ static int enic_open(struct net_device *
> > >   return 0;
> > 
> >  
> >  err_out_free_rq:
> > -   for (i = 0; i < enic->rq_count; i++)
> > +   for (i = 0; i < enic->rq_count; i++) {
> > +   err = vnic_rq_disable(&enic->rq[i]);
> > +   if (err)
> > +   return err;
> 
> This added code is wrong: it overwrites the error code that was
> previously in err.  If vnic_rq_disable() succeeds, enic_open() will
> wrongly return 0.  If vnic_rq_disable() fails, I still don't think it
> makes sense to skip the remaining cleanup actins.

Good catch. Fixing it.