[PATCH net-next] tcp/dccp: add SLAB_DESTROY_BY_RCU flag for request sockets

2015-10-03 Thread Eric Dumazet
From: Eric Dumazet 

Before letting request sockets being put in TCP/DCCP regular
ehash table, we need to add either :

- SLAB_DESTROY_BY_RCU flag to their kmem_cache
- add RCU grace period before freeing them.

Since we carefully respected the SLAB_DESTROY_BY_RCU protocol
like ESTABLISH and TIMEWAIT sockets, use it here.

req_prot_init() being only used by TCP and DCCP, I did not add
a new slab_flags into their rsk_prot, but reuse prot->slab_flags

Since all reqsk_alloc() users are correctly dealing with a failure,
add the __GFP_NOWARN flag to avoid traces under pressure.

Fixes: 079096f103fa ("tcp/dccp: install syn_recv requests into ehash table")
Signed-off-by: Eric Dumazet 
---
 include/net/request_sock.h |4 +++-
 net/core/sock.c|2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/net/request_sock.h b/include/net/request_sock.h
index bae6936d75c4..dd423d840852 100644
--- a/include/net/request_sock.h
+++ b/include/net/request_sock.h
@@ -82,7 +82,9 @@ static inline struct sock *req_to_sk(struct request_sock *req)
 static inline struct request_sock *
 reqsk_alloc(const struct request_sock_ops *ops, struct sock *sk_listener)
 {
-   struct request_sock *req = kmem_cache_alloc(ops->slab, GFP_ATOMIC);
+   struct request_sock *req;
+
+   req = kmem_cache_alloc(ops->slab, GFP_ATOMIC | __GFP_NOWARN);
 
if (req) {
req->rsk_ops = ops;
diff --git a/net/core/sock.c b/net/core/sock.c
index 3307c02244d3..7dd1263e4c24 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -2758,7 +2758,7 @@ static int req_prot_init(const struct proto *prot)
 
rsk_prot->slab = kmem_cache_create(rsk_prot->slab_name,
   rsk_prot->obj_size, 0,
-  0, NULL);
+  prot->slab_flags, NULL);
 
if (!rsk_prot->slab) {
pr_crit("%s: Can't create request sock SLAB cache!\n",


--
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


Re: [PATCH 1/3] net: dsa: Use devm_ prefixed allocations

2015-10-03 Thread Neil Armstrong
On 10/03/2015 02:39 PM, Felix Fietkau wrote:
> On 2015-10-02 15:30, Neil Armstrong wrote:
>> On 10/02/2015 03:29 PM, Sergei Shtylyov wrote:
>>> On 10/2/2015 1:48 PM, Neil Armstrong wrote:
>>>
 To simplify and prevent memory leakage when unbinding, use
 the devm_ memory allocation calls.

 Tested-by: Andrew Lunn 
 Tested-by: Florian Fainelli 
 Signed-off-by: Neil Armstrong 
 ---
   net/dsa/dsa.c | 6 +++---
   1 file changed, 3 insertions(+), 3 deletions(-)

 diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
 index c59fa5d..98f94c2 100644
 --- a/net/dsa/dsa.c
 +++ b/net/dsa/dsa.c
 @@ -305,7 +305,7 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, 
 struct device *parent)
   if (ret < 0)
   goto out;

 -ds->slave_mii_bus = mdiobus_alloc();
 +ds->slave_mii_bus = devm_mdiobus_alloc(parent);
   if (ds->slave_mii_bus == NULL) {
   ret = -ENOMEM;
   goto out;
 @@ -400,7 +400,7 @@ dsa_switch_setup(struct dsa_switch_tree *dst, int 
 index,
   /*
* Allocate and initialise switch state.
*/
 -ds = kzalloc(sizeof(*ds) + drv->priv_size, GFP_KERNEL);
 +ds = devm_kzalloc(parent, sizeof(*ds) + drv->priv_size, GFP_KERNEL);
   if (ds == NULL)
   return ERR_PTR(-ENOMEM);

 @@ -883,7 +883,7 @@ static int dsa_probe(struct platform_device *pdev)
   goto out;
   }

 -dst = kzalloc(sizeof(*dst), GFP_KERNEL);
 +dst = devm_kzalloc(>dev, sizeof(*dst), GFP_KERNEL);
   if (dst == NULL) {
   dev_put(dev);
   ret = -ENOMEM;

>>>
>>>Shouldn't you remove the correspoding kfree(), etc. calls?
>>>
>>> MBR, Sergei
>>>
>> The corresponding kfree() calls were all missing.
> Not in the error handling path. mdiobus_alloc has a corresponding
> mdiobus_free in the same function.
> The ds kzalloc in dsa_switch_setup has a kfree in dsa_switch_setup_one.
> 
> - Felix
> 
Thanks Felix & Sergei,

I will repost based on net with an intermediate commit adding the missing kfree 
calls.

Neil
--
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


[PATCH 05/15] cx88: use pci_set_dma_mask insted of pci_dma_supported

2015-10-03 Thread Christoph Hellwig
This ensures the dma mask that is supported by the driver is recorded
in the device structure.

Signed-off-by: Christoph Hellwig 
---
 drivers/media/pci/cx88/cx88-alsa.c  | 2 +-
 drivers/media/pci/cx88/cx88-mpeg.c  | 2 +-
 drivers/media/pci/cx88/cx88-video.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/pci/cx88/cx88-alsa.c 
b/drivers/media/pci/cx88/cx88-alsa.c
index 7f8dc60..0703a81 100644
--- a/drivers/media/pci/cx88/cx88-alsa.c
+++ b/drivers/media/pci/cx88/cx88-alsa.c
@@ -890,7 +890,7 @@ static int snd_cx88_create(struct snd_card *card, struct 
pci_dev *pci,
return err;
}
 
-   if (!pci_dma_supported(pci,DMA_BIT_MASK(32))) {
+   if (!pci_set_dma_mask(pci,DMA_BIT_MASK(32))) {
dprintk(0, "%s/1: Oops: no 32bit PCI DMA ???\n",core->name);
err = -EIO;
cx88_core_put(core, pci);
diff --git a/drivers/media/pci/cx88/cx88-mpeg.c 
b/drivers/media/pci/cx88/cx88-mpeg.c
index 34f5057..9b3b565 100644
--- a/drivers/media/pci/cx88/cx88-mpeg.c
+++ b/drivers/media/pci/cx88/cx88-mpeg.c
@@ -393,7 +393,7 @@ static int cx8802_init_common(struct cx8802_dev *dev)
if (pci_enable_device(dev->pci))
return -EIO;
pci_set_master(dev->pci);
-   if (!pci_dma_supported(dev->pci,DMA_BIT_MASK(32))) {
+   if (!pci_set_dma_mask(dev->pci,DMA_BIT_MASK(32))) {
printk("%s/2: Oops: no 32bit PCI DMA ???\n",dev->core->name);
return -EIO;
}
diff --git a/drivers/media/pci/cx88/cx88-video.c 
b/drivers/media/pci/cx88/cx88-video.c
index 400e5ca..f12af31 100644
--- a/drivers/media/pci/cx88/cx88-video.c
+++ b/drivers/media/pci/cx88/cx88-video.c
@@ -1311,7 +1311,7 @@ static int cx8800_initdev(struct pci_dev *pci_dev,
   dev->pci_lat,(unsigned long long)pci_resource_start(pci_dev,0));
 
pci_set_master(pci_dev);
-   if (!pci_dma_supported(pci_dev,DMA_BIT_MASK(32))) {
+   if (!pci_set_dma_mask(pci_dev,DMA_BIT_MASK(32))) {
printk("%s/0: Oops: no 32bit PCI DMA ???\n",core->name);
err = -EIO;
goto fail_core;
-- 
1.9.1

--
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


[PATCH 03/15] saa7164: use pci_set_dma_mask insted of pci_dma_supported

2015-10-03 Thread Christoph Hellwig
This ensures the dma mask that is supported by the driver is recorded
in the device structure.

Signed-off-by: Christoph Hellwig 
---
 drivers/media/pci/saa7164/saa7164-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/saa7164/saa7164-core.c 
b/drivers/media/pci/saa7164/saa7164-core.c
index 3206a82..8f36b48 100644
--- a/drivers/media/pci/saa7164/saa7164-core.c
+++ b/drivers/media/pci/saa7164/saa7164-core.c
@@ -1264,7 +1264,7 @@ static int saa7164_initdev(struct pci_dev *pci_dev,
 
pci_set_master(pci_dev);
/* TODO */
-   if (!pci_dma_supported(pci_dev, 0x)) {
+   if (!pci_set_dma_mask(pci_dev, 0x)) {
printk("%s/0: Oops: no 32bit PCI DMA ???\n", dev->name);
err = -EIO;
goto fail_irq;
-- 
1.9.1

--
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


[PATCH 02/15] tw68-core: use pci_set_dma_mask insted of pci_dma_supported

2015-10-03 Thread Christoph Hellwig
This ensures the dma mask that is supported by the driver is recorded
in the device structure.

Signed-off-by: Christoph Hellwig 
---
 drivers/media/pci/tw68/tw68-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/tw68/tw68-core.c 
b/drivers/media/pci/tw68/tw68-core.c
index 04706cc..8c5655d 100644
--- a/drivers/media/pci/tw68/tw68-core.c
+++ b/drivers/media/pci/tw68/tw68-core.c
@@ -257,7 +257,7 @@ static int tw68_initdev(struct pci_dev *pci_dev,
dev->name, pci_name(pci_dev), dev->pci_rev, pci_dev->irq,
dev->pci_lat, (u64)pci_resource_start(pci_dev, 0));
pci_set_master(pci_dev);
-   if (!pci_dma_supported(pci_dev, DMA_BIT_MASK(32))) {
+   if (!pci_set_dma_mask(pci_dev, DMA_BIT_MASK(32))) {
pr_info("%s: Oops: no 32bit PCI DMA ???\n", dev->name);
err = -EIO;
goto fail1;
-- 
1.9.1

--
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


[PATCH 04/15] saa7134: use pci_set_dma_mask insted of pci_dma_supported

2015-10-03 Thread Christoph Hellwig
This ensures the dma mask that is supported by the driver is recorded
in the device structure.

Signed-off-by: Christoph Hellwig 
---
 drivers/media/pci/saa7134/saa7134-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/saa7134/saa7134-core.c 
b/drivers/media/pci/saa7134/saa7134-core.c
index 72d7f99..6ba4086 100644
--- a/drivers/media/pci/saa7134/saa7134-core.c
+++ b/drivers/media/pci/saa7134/saa7134-core.c
@@ -949,7 +949,7 @@ static int saa7134_initdev(struct pci_dev *pci_dev,
   pci_name(pci_dev), dev->pci_rev, pci_dev->irq,
   dev->pci_lat,(unsigned long long)pci_resource_start(pci_dev,0));
pci_set_master(pci_dev);
-   if (!pci_dma_supported(pci_dev, DMA_BIT_MASK(32))) {
+   if (!pci_set_dma_mask(pci_dev, DMA_BIT_MASK(32))) {
pr_warn("%s: Oops: no 32bit PCI DMA ???\n", dev->name);
err = -EIO;
goto fail1;
-- 
1.9.1

--
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


remove dma_supported and pci_dma_supported as public APIs

2015-10-03 Thread Christoph Hellwig
All driver should be using dma_set_mask / pci_set_dma_mask to try
to set the dma mask instead of just querying it.  Without that some
iommu implementations may not work.

pci_dma_supported is removed entirely, but dma_supported stays for
dma_ops implementations for now.

--
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


Re: [PATCH net-next v3 2/2] net: Microchip encx24j600 driver

2015-10-03 Thread kbuild test robot
Hi Jon,

[auto build test results on v4.3-rc3 -- if it's inappropriate base, please 
ignore]

config: mn10300-allmodconfig (attached as .config)
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=mn10300 

All warnings (new ones prefixed by >>):

   drivers/net/ethernet/microchip/encx24j600-regmap.c: In function 
'regmap_encx24j600_read':
>> drivers/net/ethernet/microchip/encx24j600-regmap.c:272:3: warning: format 
>> '%zu' expects argument of type 'size_t', but argument 4 has type 'unsigned 
>> int' [-Wformat=]
  pr_err("%s: reg=%02x reg_size=%zu\n", __func__, reg, reg_size);
  ^
   drivers/net/ethernet/microchip/encx24j600-regmap.c:280:3: warning: format 
'%zu' expects argument of type 'size_t', but argument 4 has type 'unsigned int' 
[-Wformat=]
  pr_err("%s: reg=%02x val_size=%zu\n", __func__, reg, val_size);
  ^

vim +272 drivers/net/ethernet/microchip/encx24j600-regmap.c

   256  if (reg > 0xa0)
   257  return regmap_encx24j600_spi_write(context, reg, dout, 
len);
   258  
   259  if (len > 2)
   260  return -EINVAL;
   261  
   262  return regmap_encx24j600_sfr_write(context, reg, dout, len);
   263  }
   264  
   265  static int regmap_encx24j600_read(void *context,
   266const void *reg_buf, size_t reg_size,
   267void *val, size_t val_size)
   268  {
   269  u8 reg = *(const u8 *)reg_buf;
   270  
   271  if (reg_size != 1) {
 > 272  pr_err("%s: reg=%02x reg_size=%zu\n", __func__, reg, 
 > reg_size);
   273  return -EINVAL;
   274  }
   275  
   276  if (reg > 0xa0)
   277  return regmap_encx24j600_spi_read(context, reg, val, 
val_size);
   278  
   279  if (val_size > 2) {
   280  pr_err("%s: reg=%02x val_size=%zu\n", __func__, reg, 
val_size);

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data


[PATCH 01/15] pcnet32: use pci_set_dma_mask insted of pci_dma_supported

2015-10-03 Thread Christoph Hellwig
This ensures the dma mask that is supported by the driver is recorded
in the device structure.

Signed-off-by: Christoph Hellwig 
---
 drivers/net/ethernet/amd/pcnet32.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/amd/pcnet32.c 
b/drivers/net/ethernet/amd/pcnet32.c
index bc8b04f..e2afabf 100644
--- a/drivers/net/ethernet/amd/pcnet32.c
+++ b/drivers/net/ethernet/amd/pcnet32.c
@@ -1500,7 +1500,7 @@ pcnet32_probe_pci(struct pci_dev *pdev, const struct 
pci_device_id *ent)
return -ENODEV;
}
 
-   if (!pci_dma_supported(pdev, PCNET32_DMA_MASK)) {
+   if (!pci_set_dma_mask(pdev, PCNET32_DMA_MASK)) {
if (pcnet32_debug & NETIF_MSG_PROBE)
pr_err("architecture does not support 32bit PCI 
busmaster DMA\n");
return -ENODEV;
-- 
1.9.1

--
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


[PATCH 18/23] spear13xx_pcie_gadget: use per-attribute show and store methods

2015-10-03 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig 
---
 drivers/misc/spear13xx_pcie_gadget.c | 216 ---
 1 file changed, 71 insertions(+), 145 deletions(-)

diff --git a/drivers/misc/spear13xx_pcie_gadget.c 
b/drivers/misc/spear13xx_pcie_gadget.c
index b8374cd..ee120dc 100644
--- a/drivers/misc/spear13xx_pcie_gadget.c
+++ b/drivers/misc/spear13xx_pcie_gadget.c
@@ -220,11 +220,17 @@ static irqreturn_t spear_pcie_gadget_irq(int irq, void 
*dev_id)
 /*
  * configfs interfaces show/store functions
  */
-static ssize_t pcie_gadget_show_link(
-   struct spear_pcie_gadget_config *config,
-   char *buf)
+
+static struct pcie_gadget_target *to_target(struct config_item *item)
 {
-   struct pcie_app_reg __iomem *app_reg = config->va_app_base;
+   return item ?
+   container_of(to_configfs_subsystem(to_config_group(item)),
+   struct pcie_gadget_target, subsys) : NULL;
+}
+
+static ssize_t pcie_gadget_link_show(struct config_item *item, char *buf)
+{
+   struct pcie_app_reg __iomem *app_reg = to_target(item)->va_app_base;
 
if (readl(_reg->app_status_1) & ((u32)1 << XMLH_LINK_UP_ID))
return sprintf(buf, "UP");
@@ -232,11 +238,10 @@ static ssize_t pcie_gadget_show_link(
return sprintf(buf, "DOWN");
 }
 
-static ssize_t pcie_gadget_store_link(
-   struct spear_pcie_gadget_config *config,
+static ssize_t pcie_gadget_link_store(struct config_item *item,
const char *buf, size_t count)
 {
-   struct pcie_app_reg __iomem *app_reg = config->va_app_base;
+   struct pcie_app_reg __iomem *app_reg = to_target(item)->va_app_base;
 
if (sysfs_streq(buf, "UP"))
writel(readl(_reg->app_ctrl_0) | (1 << APP_LTSSM_ENABLE_ID),
@@ -250,17 +255,15 @@ static ssize_t pcie_gadget_store_link(
return count;
 }
 
-static ssize_t pcie_gadget_show_int_type(
-   struct spear_pcie_gadget_config *config,
-   char *buf)
+static ssize_t pcie_gadget_int_type_show(struct config_item *item, char *buf)
 {
-   return sprintf(buf, "%s", config->int_type);
+   return sprintf(buf, "%s", to_target(item)->int_type);
 }
 
-static ssize_t pcie_gadget_store_int_type(
-   struct spear_pcie_gadget_config *config,
+static ssize_t pcie_gadget_int_type_store(struct config_item *item,
const char *buf, size_t count)
 {
+   struct spear_pcie_gadget_config *config = to_target(item)
u32 cap, vec, flags;
ulong vector;
 
@@ -288,11 +291,10 @@ static ssize_t pcie_gadget_store_int_type(
return count;
 }
 
-static ssize_t pcie_gadget_show_no_of_msi(
-   struct spear_pcie_gadget_config *config,
-   char *buf)
+static ssize_t pcie_gadget_no_of_msi_show(struct config_item *item, char *buf)
 {
-   struct pcie_app_reg __iomem *app_reg = config->va_app_base;
+   struct spear_pcie_gadget_config *config = to_target(item)
+   struct pcie_app_reg __iomem *app_reg = to_target(item)->va_app_base;
u32 cap, vec, flags;
ulong vector;
 
@@ -313,13 +315,12 @@ static ssize_t pcie_gadget_show_no_of_msi(
return sprintf(buf, "%lu", vector);
 }
 
-static ssize_t pcie_gadget_store_no_of_msi(
-   struct spear_pcie_gadget_config *config,
+static ssize_t pcie_gadget_no_of_msi_store(struct config_item *item,
const char *buf, size_t count)
 {
int ret;
 
-   ret = kstrtoul(buf, 0, >requested_msi);
+   ret = kstrtoul(buf, 0, _target(item)->requested_msi);
if (ret)
return ret;
 
@@ -329,11 +330,10 @@ static ssize_t pcie_gadget_store_no_of_msi(
return count;
 }
 
-static ssize_t pcie_gadget_store_inta(
-   struct spear_pcie_gadget_config *config,
+static ssize_t pcie_gadget_inta_store(struct config_item *item,
const char *buf, size_t count)
 {
-   struct pcie_app_reg __iomem *app_reg = config->va_app_base;
+   struct pcie_app_reg __iomem *app_reg = to_target(item)->va_app_base;
ulong en;
int ret;
 
@@ -351,10 +351,10 @@ static ssize_t pcie_gadget_store_inta(
return count;
 }
 
-static ssize_t pcie_gadget_store_send_msi(
-   struct spear_pcie_gadget_config *config,
+static ssize_t pcie_gadget_send_msi_store(struct config_item *item,
const char *buf, size_t count)
 {
+   struct spear_pcie_gadget_config *config = to_target(item)
struct pcie_app_reg __iomem *app_reg = config->va_app_base;
ulong vector;
u32 ven_msi;
@@ -388,19 +388,16 @@ static ssize_t pcie_gadget_store_send_msi(
return count;
 }
 
-static ssize_t pcie_gadget_show_vendor_id(
-   struct spear_pcie_gadget_config *config,
-   char *buf)
+static ssize_t pcie_gadget_vendor_id_show(struct config_item *item, char *buf)
 {
u32 id;
 
-   spear_dbi_read_reg(config, 

[PATCH 07/23] usb-gadget/f_loopback: use per-attribute show and store methods

2015-10-03 Thread Christoph Hellwig
To simplify the configfs interface and remove boilerplate code that also
causes binary bloat.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Andrzej Pietrasiewicz 
---
 drivers/usb/gadget/function/f_loopback.c | 31 ---
 1 file changed, 12 insertions(+), 19 deletions(-)

diff --git a/drivers/usb/gadget/function/f_loopback.c 
b/drivers/usb/gadget/function/f_loopback.c
index 6e2fe63..b9d8f05 100644
--- a/drivers/usb/gadget/function/f_loopback.c
+++ b/drivers/usb/gadget/function/f_loopback.c
@@ -413,9 +413,6 @@ static inline struct f_lb_opts *to_f_lb_opts(struct 
config_item *item)
func_inst.group);
 }
 
-CONFIGFS_ATTR_STRUCT(f_lb_opts);
-CONFIGFS_ATTR_OPS(f_lb_opts);
-
 static void lb_attr_release(struct config_item *item)
 {
struct f_lb_opts *lb_opts = to_f_lb_opts(item);
@@ -425,12 +422,11 @@ static void lb_attr_release(struct config_item *item)
 
 static struct configfs_item_operations lb_item_ops = {
.release= lb_attr_release,
-   .show_attribute = f_lb_opts_attr_show,
-   .store_attribute= f_lb_opts_attr_store,
 };
 
-static ssize_t f_lb_opts_qlen_show(struct f_lb_opts *opts, char *page)
+static ssize_t f_lb_opts_qlen_show(struct config_item *item, char *page)
 {
+   struct f_lb_opts *opts = to_f_lb_opts(item);
int result;
 
mutex_lock(>lock);
@@ -440,9 +436,10 @@ static ssize_t f_lb_opts_qlen_show(struct f_lb_opts *opts, 
char *page)
return result;
 }
 
-static ssize_t f_lb_opts_qlen_store(struct f_lb_opts *opts,
+static ssize_t f_lb_opts_qlen_store(struct config_item *item,
const char *page, size_t len)
 {
+   struct f_lb_opts *opts = to_f_lb_opts(item);
int ret;
u32 num;
 
@@ -463,13 +460,11 @@ end:
return ret;
 }
 
-static struct f_lb_opts_attribute f_lb_opts_qlen =
-   __CONFIGFS_ATTR(qlen, S_IRUGO | S_IWUSR,
-   f_lb_opts_qlen_show,
-   f_lb_opts_qlen_store);
+CONFIGFS_ATTR(f_lb_opts_, qlen);
 
-static ssize_t f_lb_opts_bulk_buflen_show(struct f_lb_opts *opts, char *page)
+static ssize_t f_lb_opts_bulk_buflen_show(struct config_item *item, char *page)
 {
+   struct f_lb_opts *opts = to_f_lb_opts(item);
int result;
 
mutex_lock(>lock);
@@ -479,9 +474,10 @@ static ssize_t f_lb_opts_bulk_buflen_show(struct f_lb_opts 
*opts, char *page)
return result;
 }
 
-static ssize_t f_lb_opts_bulk_buflen_store(struct f_lb_opts *opts,
+static ssize_t f_lb_opts_bulk_buflen_store(struct config_item *item,
const char *page, size_t len)
 {
+   struct f_lb_opts *opts = to_f_lb_opts(item);
int ret;
u32 num;
 
@@ -502,14 +498,11 @@ end:
return ret;
 }
 
-static struct f_lb_opts_attribute f_lb_opts_bulk_buflen =
-   __CONFIGFS_ATTR(buflen, S_IRUGO | S_IWUSR,
-   f_lb_opts_bulk_buflen_show,
-   f_lb_opts_bulk_buflen_store);
+CONFIGFS_ATTR(f_lb_opts_, bulk_buflen);
 
 static struct configfs_attribute *lb_attrs[] = {
-   _lb_opts_qlen.attr,
-   _lb_opts_bulk_buflen.attr,
+   _lb_opts_attr_qlen,
+   _lb_opts_attr_bulk_buflen,
NULL,
 };
 
-- 
1.9.1

--
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


[PATCH 12/23] usb-gadget/f_uac1: use per-attribute show and store methods

2015-10-03 Thread Christoph Hellwig
To simplify the configfs interface and remove boilerplate code that also
causes binary bloat.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Andrzej Pietrasiewicz 
---
 drivers/usb/gadget/function/f_uac1.c | 39 +++-
 1 file changed, 16 insertions(+), 23 deletions(-)

diff --git a/drivers/usb/gadget/function/f_uac1.c 
b/drivers/usb/gadget/function/f_uac1.c
index 7856b33..ad01032 100644
--- a/drivers/usb/gadget/function/f_uac1.c
+++ b/drivers/usb/gadget/function/f_uac1.c
@@ -773,9 +773,6 @@ static inline struct f_uac1_opts *to_f_uac1_opts(struct 
config_item *item)
func_inst.group);
 }
 
-CONFIGFS_ATTR_STRUCT(f_uac1_opts);
-CONFIGFS_ATTR_OPS(f_uac1_opts);
-
 static void f_uac1_attr_release(struct config_item *item)
 {
struct f_uac1_opts *opts = to_f_uac1_opts(item);
@@ -785,14 +782,13 @@ static void f_uac1_attr_release(struct config_item *item)
 
 static struct configfs_item_operations f_uac1_item_ops = {
.release= f_uac1_attr_release,
-   .show_attribute = f_uac1_opts_attr_show,
-   .store_attribute = f_uac1_opts_attr_store,
 };
 
 #define UAC1_INT_ATTRIBUTE(name)   \
-static ssize_t f_uac1_opts_##name##_show(struct f_uac1_opts *opts, \
+static ssize_t f_uac1_opts_##name##_show(struct config_item *item, \
 char *page)\
 {  \
+   struct f_uac1_opts *opts = to_f_uac1_opts(item);\
int result; \
\
mutex_lock(>lock);\
@@ -802,9 +798,10 @@ static ssize_t f_uac1_opts_##name##_show(struct 
f_uac1_opts *opts, \
return result;  \
 }  \
\
-static ssize_t f_uac1_opts_##name##_store(struct f_uac1_opts *opts,\
+static ssize_t f_uac1_opts_##name##_store(struct config_item *item,
\
  const char *page, size_t len) \
 {  \
+   struct f_uac1_opts *opts = to_f_uac1_opts(item);\
int ret;\
u32 num;\
\
@@ -826,19 +823,17 @@ end:  
\
return ret; \
 }  \
\
-static struct f_uac1_opts_attribute f_uac1_opts_##name =   \
-   __CONFIGFS_ATTR(name, S_IRUGO | S_IWUSR,\
-   f_uac1_opts_##name##_show,  \
-   f_uac1_opts_##name##_store)
+CONFIGFS_ATTR(f_uac1_opts_, name)
 
 UAC1_INT_ATTRIBUTE(req_buf_size);
 UAC1_INT_ATTRIBUTE(req_count);
 UAC1_INT_ATTRIBUTE(audio_buf_size);
 
 #define UAC1_STR_ATTRIBUTE(name)   \
-static ssize_t f_uac1_opts_##name##_show(struct f_uac1_opts *opts, \
+static ssize_t f_uac1_opts_##name##_show(struct config_item *item, \
 char *page)\
 {  \
+   struct f_uac1_opts *opts = to_f_uac1_opts(item);\
int result; \
\
mutex_lock(>lock);\
@@ -848,9 +843,10 @@ static ssize_t f_uac1_opts_##name##_show(struct 
f_uac1_opts *opts, \
return result;  \
 }  \
\
-static ssize_t f_uac1_opts_##name##_store(struct f_uac1_opts *opts,\
+static ssize_t f_uac1_opts_##name##_store(struct config_item *item,\
  const char *page, size_t len) \
 {  \
+   struct f_uac1_opts *opts = to_f_uac1_opts(item);\
int ret = -EBUSY;   \
char *tmp;  \
 

[PATCH 09/23] usb-gadget/f_printer: use per-attribute show and store methods

2015-10-03 Thread Christoph Hellwig
To simplify the configfs interface and remove boilerplate code that also
causes binary bloat.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Andrzej Pietrasiewicz 
---
 drivers/usb/gadget/function/f_printer.c | 30 --
 1 file changed, 12 insertions(+), 18 deletions(-)

diff --git a/drivers/usb/gadget/function/f_printer.c 
b/drivers/usb/gadget/function/f_printer.c
index 8e2b6be..3a37846 100644
--- a/drivers/usb/gadget/function/f_printer.c
+++ b/drivers/usb/gadget/function/f_printer.c
@@ -1148,9 +1148,6 @@ static inline struct f_printer_opts
func_inst.group);
 }
 
-CONFIGFS_ATTR_STRUCT(f_printer_opts);
-CONFIGFS_ATTR_OPS(f_printer_opts);
-
 static void printer_attr_release(struct config_item *item)
 {
struct f_printer_opts *opts = to_f_printer_opts(item);
@@ -1160,13 +1157,12 @@ static void printer_attr_release(struct config_item 
*item)
 
 static struct configfs_item_operations printer_item_ops = {
.release= printer_attr_release,
-   .show_attribute = f_printer_opts_attr_show,
-   .store_attribute = f_printer_opts_attr_store,
 };
 
-static ssize_t f_printer_opts_pnp_string_show(struct f_printer_opts *opts,
+static ssize_t f_printer_opts_pnp_string_show(struct config_item *item,
  char *page)
 {
+   struct f_printer_opts *opts = to_f_printer_opts(item);
int result;
 
mutex_lock(>lock);
@@ -1176,9 +1172,10 @@ static ssize_t f_printer_opts_pnp_string_show(struct 
f_printer_opts *opts,
return result;
 }
 
-static ssize_t f_printer_opts_pnp_string_store(struct f_printer_opts *opts,
+static ssize_t f_printer_opts_pnp_string_store(struct config_item *item,
   const char *page, size_t len)
 {
+   struct f_printer_opts *opts = to_f_printer_opts(item);
int result, l;
 
mutex_lock(>lock);
@@ -1191,14 +1188,12 @@ static ssize_t f_printer_opts_pnp_string_store(struct 
f_printer_opts *opts,
return result;
 }
 
-static struct f_printer_opts_attribute f_printer_opts_pnp_string =
-   __CONFIGFS_ATTR(pnp_string, S_IRUGO | S_IWUSR,
-   f_printer_opts_pnp_string_show,
-   f_printer_opts_pnp_string_store);
+CONFIGFS_ATTR(f_printer_opts_, pnp_string);
 
-static ssize_t f_printer_opts_q_len_show(struct f_printer_opts *opts,
+static ssize_t f_printer_opts_q_len_show(struct config_item *item,
 char *page)
 {
+   struct f_printer_opts *opts = to_f_printer_opts(item);
int result;
 
mutex_lock(>lock);
@@ -1208,9 +1203,10 @@ static ssize_t f_printer_opts_q_len_show(struct 
f_printer_opts *opts,
return result;
 }
 
-static ssize_t f_printer_opts_q_len_store(struct f_printer_opts *opts,
+static ssize_t f_printer_opts_q_len_store(struct config_item *item,
  const char *page, size_t len)
 {
+   struct f_printer_opts *opts = to_f_printer_opts(item);
int ret;
u16 num;
 
@@ -1231,13 +1227,11 @@ end:
return ret;
 }
 
-static struct f_printer_opts_attribute f_printer_opts_q_len =
-   __CONFIGFS_ATTR(q_len, S_IRUGO | S_IWUSR, f_printer_opts_q_len_show,
-   f_printer_opts_q_len_store);
+CONFIGFS_ATTR(f_printer_opts_, q_len);
 
 static struct configfs_attribute *printer_attrs[] = {
-   _printer_opts_pnp_string.attr,
-   _printer_opts_q_len.attr,
+   _printer_opts_attr_pnp_string,
+   _printer_opts_attr_q_len,
NULL,
 };
 
-- 
1.9.1

--
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


[PATCH 23/23] configfs: remove old API

2015-10-03 Thread Christoph Hellwig
Remove the old show_attribute and store_attribute methods and update
the documentation.  Also replace the two C samples with a single new
one in the proper samples directory where people expect to find it.

Signed-off-by: Christoph Hellwig 
---
 Documentation/filesystems/Makefile |   2 -
 Documentation/filesystems/configfs/Makefile|   3 -
 Documentation/filesystems/configfs/configfs.txt|  38 +-
 .../configfs/configfs_example_explicit.c   | 483 -
 .../filesystems/configfs/configfs_example_macros.c | 446 ---
 fs/configfs/file.c |  15 +-
 include/linux/configfs.h   |  82 
 samples/Kconfig|   6 +
 samples/Makefile   |   3 +-
 samples/configfs/Makefile  |   2 +
 samples/configfs/configfs_sample.c | 404 +
 11 files changed, 428 insertions(+), 1056 deletions(-)
 delete mode 100644 Documentation/filesystems/configfs/Makefile
 delete mode 100644 
Documentation/filesystems/configfs/configfs_example_explicit.c
 delete mode 100644 Documentation/filesystems/configfs/configfs_example_macros.c
 create mode 100644 samples/configfs/Makefile
 create mode 100644 samples/configfs/configfs_sample.c

diff --git a/Documentation/filesystems/Makefile 
b/Documentation/filesystems/Makefile
index 13483d1..883010c 100644
--- a/Documentation/filesystems/Makefile
+++ b/Documentation/filesystems/Makefile
@@ -1,5 +1,3 @@
-subdir-y := configfs
-
 # List of programs to build
 hostprogs-y := dnotify_test
 
diff --git a/Documentation/filesystems/configfs/Makefile 
b/Documentation/filesystems/configfs/Makefile
deleted file mode 100644
index be7ec5e..000
--- a/Documentation/filesystems/configfs/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
-ifneq ($(CONFIG_CONFIGFS_FS),)
-obj-m += configfs_example_explicit.o configfs_example_macros.o
-endif
diff --git a/Documentation/filesystems/configfs/configfs.txt 
b/Documentation/filesystems/configfs/configfs.txt
index b40fec9..af68efd 100644
--- a/Documentation/filesystems/configfs/configfs.txt
+++ b/Documentation/filesystems/configfs/configfs.txt
@@ -160,12 +160,6 @@ among other things.  For that, it needs a type.
 
struct configfs_item_operations {
void (*release)(struct config_item *);
-   ssize_t (*show_attribute)(struct config_item *,
- struct configfs_attribute *,
- char *);
-   ssize_t (*store_attribute)(struct config_item *,
-  struct configfs_attribute *,
-  const char *, size_t);
int (*allow_link)(struct config_item *src,
  struct config_item *target);
int (*drop_link)(struct config_item *src,
@@ -183,9 +177,7 @@ The most basic function of a config_item_type is to define 
what
 operations can be performed on a config_item.  All items that have been
 allocated dynamically will need to provide the ct_item_ops->release()
 method.  This method is called when the config_item's reference count
-reaches zero.  Items that wish to display an attribute need to provide
-the ct_item_ops->show_attribute() method.  Similarly, storing a new
-attribute value uses the store_attribute() method.
+reaches zero.
 
 [struct configfs_attribute]
 
@@ -193,6 +185,8 @@ attribute value uses the store_attribute() method.
char*ca_name;
struct module   *ca_owner;
umode_t  ca_mode;
+   ssize_t (*show)(struct config_item *, char *);
+   ssize_t (*store)(struct config_item *, const char *, size_t);
};
 
 When a config_item wants an attribute to appear as a file in the item's
@@ -202,10 +196,10 @@ config_item_type->ct_attrs.  When the item appears in 
configfs, the
 attribute file will appear with the configfs_attribute->ca_name
 filename.  configfs_attribute->ca_mode specifies the file permissions.
 
-If an attribute is readable and the config_item provides a
-ct_item_ops->show_attribute() method, that method will be called
-whenever userspace asks for a read(2) on the attribute.  The converse
-will happen for write(2).
+If an attribute is readable and provides a ->show method, that method will
+be called whenever userspace asks for a read(2) on the attribute.  If an
+attribute is writable and provides a ->store  method, that method will be
+be called whenever userspace asks for a write(2) on the attribute.
 
 [struct config_group]
 
@@ -311,20 +305,10 @@ the subsystem must be ready for it.
 [An Example]
 
 The best example of these basic concepts is the simple_children
-subsystem/group and the simple_child item in configfs_example_explicit.c
-and configfs_example_macros.c.  It 

[PATCH 17/23] dlm: use per-attribute show and store methods

2015-10-03 Thread Christoph Hellwig
To simplify the configfs interface and remove boilerplate code that also
causes binary bloat.

Signed-off-by: Christoph Hellwig 
Reviewed-by: David Teigland cl_cluster_name);
 }
 
-static ssize_t cluster_cluster_name_write(struct dlm_cluster *cl,
+static ssize_t cluster_cluster_name_store(struct config_item *item,
  const char *buf, size_t len)
 {
+   struct dlm_cluster *cl = config_item_to_cluster(item);
+
strlcpy(dlm_config.ci_cluster_name, buf,
sizeof(dlm_config.ci_cluster_name));
strlcpy(cl->cl_cluster_name, buf, sizeof(cl->cl_cluster_name));
return len;
 }
 
-static struct cluster_attribute cluster_attr_cluster_name = {
-   .attr   = { .ca_owner = THIS_MODULE,
-.ca_name = "cluster_name",
-.ca_mode = S_IRUGO | S_IWUSR },
-   .show   = cluster_cluster_name_read,
-   .store  = cluster_cluster_name_write,
-};
+CONFIGFS_ATTR(cluster_, cluster_name);
 
 static ssize_t cluster_set(struct dlm_cluster *cl, unsigned int *cl_field,
   int *info_field, int check_zero,
@@ -175,17 +145,19 @@ static ssize_t cluster_set(struct dlm_cluster *cl, 
unsigned int *cl_field,
 }
 
 #define CLUSTER_ATTR(name, check_zero)\
-static ssize_t name##_write(struct dlm_cluster *cl, const char *buf, size_t 
len) \
+static ssize_t cluster_##name##_store(struct config_item *item, \
+   const char *buf, size_t len) \
 { \
+   struct dlm_cluster *cl = config_item_to_cluster(item);\
return cluster_set(cl, 

[PATCH 13/23] usb-gadget/f_uac2: use per-attribute show and store methods

2015-10-03 Thread Christoph Hellwig
To simplify the configfs interface and remove boilerplate code that also
causes binary bloat.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Andrzej Pietrasiewicz 
---
 drivers/usb/gadget/function/f_uac2.c | 28 +++-
 1 file changed, 11 insertions(+), 17 deletions(-)

diff --git a/drivers/usb/gadget/function/f_uac2.c 
b/drivers/usb/gadget/function/f_uac2.c
index f8de7ea..0a5a1e1 100644
--- a/drivers/usb/gadget/function/f_uac2.c
+++ b/drivers/usb/gadget/function/f_uac2.c
@@ -1445,9 +1445,6 @@ static inline struct f_uac2_opts *to_f_uac2_opts(struct 
config_item *item)
func_inst.group);
 }
 
-CONFIGFS_ATTR_STRUCT(f_uac2_opts);
-CONFIGFS_ATTR_OPS(f_uac2_opts);
-
 static void f_uac2_attr_release(struct config_item *item)
 {
struct f_uac2_opts *opts = to_f_uac2_opts(item);
@@ -1457,14 +1454,13 @@ static void f_uac2_attr_release(struct config_item 
*item)
 
 static struct configfs_item_operations f_uac2_item_ops = {
.release= f_uac2_attr_release,
-   .show_attribute = f_uac2_opts_attr_show,
-   .store_attribute = f_uac2_opts_attr_store,
 };
 
 #define UAC2_ATTRIBUTE(name)   \
-static ssize_t f_uac2_opts_##name##_show(struct f_uac2_opts *opts, \
+static ssize_t f_uac2_opts_##name##_show(struct config_item *item, \
 char *page)\
 {  \
+   struct f_uac2_opts *opts = to_f_uac2_opts(item);\
int result; \
\
mutex_lock(>lock);\
@@ -1474,9 +1470,10 @@ static ssize_t f_uac2_opts_##name##_show(struct 
f_uac2_opts *opts,   \
return result;  \
 }  \
\
-static ssize_t f_uac2_opts_##name##_store(struct f_uac2_opts *opts,\
+static ssize_t f_uac2_opts_##name##_store(struct config_item *item,\
  const char *page, size_t len) \
 {  \
+   struct f_uac2_opts *opts = to_f_uac2_opts(item);\
int ret;\
u32 num;\
\
@@ -1498,10 +1495,7 @@ end: 
\
return ret; \
 }  \
\
-static struct f_uac2_opts_attribute f_uac2_opts_##name =   \
-   __CONFIGFS_ATTR(name, S_IRUGO | S_IWUSR,\
-   f_uac2_opts_##name##_show,  \
-   f_uac2_opts_##name##_store)
+CONFIGFS_ATTR(f_uac2_opts_, name)
 
 UAC2_ATTRIBUTE(p_chmask);
 UAC2_ATTRIBUTE(p_srate);
@@ -1511,12 +1505,12 @@ UAC2_ATTRIBUTE(c_srate);
 UAC2_ATTRIBUTE(c_ssize);
 
 static struct configfs_attribute *f_uac2_attrs[] = {
-   _uac2_opts_p_chmask.attr,
-   _uac2_opts_p_srate.attr,
-   _uac2_opts_p_ssize.attr,
-   _uac2_opts_c_chmask.attr,
-   _uac2_opts_c_srate.attr,
-   _uac2_opts_c_ssize.attr,
+   _uac2_opts_attr_p_chmask,
+   _uac2_opts_attr_p_srate,
+   _uac2_opts_attr_p_ssize,
+   _uac2_opts_attr_c_chmask,
+   _uac2_opts_attr_c_srate,
+   _uac2_opts_attr_c_ssize,
NULL,
 };
 
-- 
1.9.1

--
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


[PATCH 21/23] ocfs2/cluster: move locking into attribute store methods

2015-10-03 Thread Christoph Hellwig
The test and separate set bit scheme was racy to start with, so move to do
a test_and_set_bit after doing the earlier error checks inside the actual
store methods.  Also remove the locking for the local attribute which
already has a different scheme to synchronize.

Signed-off-by: Christoph Hellwig 
---
 fs/ocfs2/cluster/nodemanager.c | 54 +++---
 1 file changed, 19 insertions(+), 35 deletions(-)

diff --git a/fs/ocfs2/cluster/nodemanager.c b/fs/ocfs2/cluster/nodemanager.c
index 441c84e..7a398f6 100644
--- a/fs/ocfs2/cluster/nodemanager.c
+++ b/fs/ocfs2/cluster/nodemanager.c
@@ -188,7 +188,6 @@ enum {
O2NM_NODE_ATTR_NUM = 0,
O2NM_NODE_ATTR_PORT,
O2NM_NODE_ATTR_ADDRESS,
-   O2NM_NODE_ATTR_LOCAL,
 };
 
 static ssize_t o2nm_node_num_write(struct o2nm_node *node, const char *page,
@@ -197,6 +196,7 @@ static ssize_t o2nm_node_num_write(struct o2nm_node *node, 
const char *page,
struct o2nm_cluster *cluster = to_o2nm_cluster_from_node(node);
unsigned long tmp;
char *p = (char *)page;
+   int ret = 0;
 
tmp = simple_strtoul(p, , 0);
if (!p || (*p && (*p != '\n')))
@@ -215,15 +215,18 @@ static ssize_t o2nm_node_num_write(struct o2nm_node 
*node, const char *page,
 
write_lock(>cl_nodes_lock);
if (cluster->cl_nodes[tmp])
-   p = NULL;
+   ret = -EEXIST;
+   else if (test_and_set_bit(O2NM_NODE_ATTR_NUM,
+   >nd_set_attributes))
+   ret = -EBUSY;
else  {
cluster->cl_nodes[tmp] = node;
node->nd_num = tmp;
set_bit(tmp, cluster->cl_nodes_bitmap);
}
write_unlock(>cl_nodes_lock);
-   if (p == NULL)
-   return -EEXIST;
+   if (ret)
+   return ret;
 
return count;
 }
@@ -247,6 +250,8 @@ static ssize_t o2nm_node_ipv4_port_write(struct o2nm_node 
*node,
if (tmp >= (u16)-1)
return -ERANGE;
 
+   if (test_and_set_bit(O2NM_NODE_ATTR_PORT, >nd_set_attributes))
+   return -EBUSY;
node->nd_ipv4_port = htons(tmp);
 
return count;
@@ -282,6 +287,9 @@ static ssize_t o2nm_node_ipv4_address_write(struct 
o2nm_node *node,
write_lock(>cl_nodes_lock);
if (o2nm_node_ip_tree_lookup(cluster, ipv4_addr, , ))
ret = -EEXIST;
+   else if (test_and_set_bit(O2NM_NODE_ATTR_ADDRESS,
+   >nd_set_attributes))
+   ret = -EBUSY;
else {
rb_link_node(>nd_ip_node, parent, p);
rb_insert_color(>nd_ip_node, >cl_node_ip_tree);
@@ -388,24 +396,13 @@ static struct o2nm_node_attribute o2nm_node_attr_local = {
 };
 
 static struct configfs_attribute *o2nm_node_attrs[] = {
-   [O2NM_NODE_ATTR_NUM] = _node_attr_num.attr,
-   [O2NM_NODE_ATTR_PORT] = _node_attr_ipv4_port.attr,
-   [O2NM_NODE_ATTR_ADDRESS] = _node_attr_ipv4_address.attr,
-   [O2NM_NODE_ATTR_LOCAL] = _node_attr_local.attr,
+   _node_attr_num.attr,
+   _node_attr_ipv4_port.attr,
+   _node_attr_ipv4_address.attr,
+   _node_attr_local.attr,
NULL,
 };
 
-static int o2nm_attr_index(struct configfs_attribute *attr)
-{
-   int i;
-   for (i = 0; i < ARRAY_SIZE(o2nm_node_attrs); i++) {
-   if (attr == o2nm_node_attrs[i])
-   return i;
-   }
-   BUG();
-   return 0;
-}
-
 static ssize_t o2nm_node_show(struct config_item *item,
  struct configfs_attribute *attr,
  char *page)
@@ -427,24 +424,11 @@ static ssize_t o2nm_node_store(struct config_item *item,
struct o2nm_node *node = to_o2nm_node(item);
struct o2nm_node_attribute *o2nm_node_attr =
container_of(attr, struct o2nm_node_attribute, attr);
-   ssize_t ret;
-   int attr_index = o2nm_attr_index(attr);
 
-   if (o2nm_node_attr->store == NULL) {
-   ret = -EINVAL;
-   goto out;
-   }
-
-   if (test_bit(attr_index, >nd_set_attributes))
-   return -EBUSY;
-
-   ret = o2nm_node_attr->store(node, page, count);
-   if (ret < count)
-   goto out;
+   if (o2nm_node_attr->store == NULL)
+   return -EINVAL;
 
-   set_bit(attr_index, >nd_set_attributes);
-out:
-   return ret;
+   return o2nm_node_attr->store(node, page, count);
 }
 
 static struct configfs_item_operations o2nm_node_item_ops = {
-- 
1.9.1

--
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


[PATCH 05/23] usb-gadget/f_acm: use per-attribute show and store methods

2015-10-03 Thread Christoph Hellwig
To simplify the configfs interface and remove boilerplate code that also
causes binary bloat.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Andrzej Pietrasiewicz 
---
 drivers/usb/gadget/function/f_acm.c | 26 --
 1 file changed, 4 insertions(+), 22 deletions(-)

diff --git a/drivers/usb/gadget/function/f_acm.c 
b/drivers/usb/gadget/function/f_acm.c
index be9df09..68b289f 100644
--- a/drivers/usb/gadget/function/f_acm.c
+++ b/drivers/usb/gadget/function/f_acm.c
@@ -776,21 +776,6 @@ static inline struct f_serial_opts 
*to_f_serial_opts(struct config_item *item)
func_inst.group);
 }
 
-CONFIGFS_ATTR_STRUCT(f_serial_opts);
-static ssize_t f_acm_attr_show(struct config_item *item,
-struct configfs_attribute *attr,
-char *page)
-{
-   struct f_serial_opts *opts = to_f_serial_opts(item);
-   struct f_serial_opts_attribute *f_serial_opts_attr =
-   container_of(attr, struct f_serial_opts_attribute, attr);
-   ssize_t ret = 0;
-
-   if (f_serial_opts_attr->show)
-   ret = f_serial_opts_attr->show(opts, page);
-   return ret;
-}
-
 static void acm_attr_release(struct config_item *item)
 {
struct f_serial_opts *opts = to_f_serial_opts(item);
@@ -800,20 +785,17 @@ static void acm_attr_release(struct config_item *item)
 
 static struct configfs_item_operations acm_item_ops = {
.release= acm_attr_release,
-   .show_attribute = f_acm_attr_show,
 };
 
-static ssize_t f_acm_port_num_show(struct f_serial_opts *opts, char *page)
+static ssize_t f_acm_port_num_show(struct config_item *item, char *page)
 {
-   return sprintf(page, "%u\n", opts->port_num);
+   return sprintf(page, "%u\n", to_f_serial_opts(item)->port_num);
 }
 
-static struct f_serial_opts_attribute f_acm_port_num =
-   __CONFIGFS_ATTR_RO(port_num, f_acm_port_num_show);
-
+CONFIGFS_ATTR_RO(f_acm_port_, num);
 
 static struct configfs_attribute *acm_attrs[] = {
-   _acm_port_num.attr,
+   _acm_port_attr_num,
NULL,
 };
 
-- 
1.9.1

--
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


[PATCH 10/23] usb-gadget/f_sourcesink: use per-attribute show and store methods

2015-10-03 Thread Christoph Hellwig
To simplify the configfs interface and remove boilerplate code that also
causes binary bloat.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Andrzej Pietrasiewicz 
---
 drivers/usb/gadget/function/f_sourcesink.c | 83 +-
 1 file changed, 36 insertions(+), 47 deletions(-)

diff --git a/drivers/usb/gadget/function/f_sourcesink.c 
b/drivers/usb/gadget/function/f_sourcesink.c
index cbfaf86..878a581 100644
--- a/drivers/usb/gadget/function/f_sourcesink.c
+++ b/drivers/usb/gadget/function/f_sourcesink.c
@@ -898,9 +898,6 @@ static inline struct f_ss_opts *to_f_ss_opts(struct 
config_item *item)
func_inst.group);
 }
 
-CONFIGFS_ATTR_STRUCT(f_ss_opts);
-CONFIGFS_ATTR_OPS(f_ss_opts);
-
 static void ss_attr_release(struct config_item *item)
 {
struct f_ss_opts *ss_opts = to_f_ss_opts(item);
@@ -910,12 +907,11 @@ static void ss_attr_release(struct config_item *item)
 
 static struct configfs_item_operations ss_item_ops = {
.release= ss_attr_release,
-   .show_attribute = f_ss_opts_attr_show,
-   .store_attribute= f_ss_opts_attr_store,
 };
 
-static ssize_t f_ss_opts_pattern_show(struct f_ss_opts *opts, char *page)
+static ssize_t f_ss_opts_pattern_show(struct config_item *item, char *page)
 {
+   struct f_ss_opts *opts = to_f_ss_opts(item);
int result;
 
mutex_lock(>lock);
@@ -925,9 +921,10 @@ static ssize_t f_ss_opts_pattern_show(struct f_ss_opts 
*opts, char *page)
return result;
 }
 
-static ssize_t f_ss_opts_pattern_store(struct f_ss_opts *opts,
+static ssize_t f_ss_opts_pattern_store(struct config_item *item,
   const char *page, size_t len)
 {
+   struct f_ss_opts *opts = to_f_ss_opts(item);
int ret;
u8 num;
 
@@ -953,13 +950,11 @@ end:
return ret;
 }
 
-static struct f_ss_opts_attribute f_ss_opts_pattern =
-   __CONFIGFS_ATTR(pattern, S_IRUGO | S_IWUSR,
-   f_ss_opts_pattern_show,
-   f_ss_opts_pattern_store);
+CONFIGFS_ATTR(f_ss_opts_, pattern);
 
-static ssize_t f_ss_opts_isoc_interval_show(struct f_ss_opts *opts, char *page)
+static ssize_t f_ss_opts_isoc_interval_show(struct config_item *item, char 
*page)
 {
+   struct f_ss_opts *opts = to_f_ss_opts(item);
int result;
 
mutex_lock(>lock);
@@ -969,9 +964,10 @@ static ssize_t f_ss_opts_isoc_interval_show(struct 
f_ss_opts *opts, char *page)
return result;
 }
 
-static ssize_t f_ss_opts_isoc_interval_store(struct f_ss_opts *opts,
+static ssize_t f_ss_opts_isoc_interval_store(struct config_item *item,
   const char *page, size_t len)
 {
+   struct f_ss_opts *opts = to_f_ss_opts(item);
int ret;
u8 num;
 
@@ -997,13 +993,11 @@ end:
return ret;
 }
 
-static struct f_ss_opts_attribute f_ss_opts_isoc_interval =
-   __CONFIGFS_ATTR(isoc_interval, S_IRUGO | S_IWUSR,
-   f_ss_opts_isoc_interval_show,
-   f_ss_opts_isoc_interval_store);
+CONFIGFS_ATTR(f_ss_opts_, isoc_interval);
 
-static ssize_t f_ss_opts_isoc_maxpacket_show(struct f_ss_opts *opts, char 
*page)
+static ssize_t f_ss_opts_isoc_maxpacket_show(struct config_item *item, char 
*page)
 {
+   struct f_ss_opts *opts = to_f_ss_opts(item);
int result;
 
mutex_lock(>lock);
@@ -1013,9 +1007,10 @@ static ssize_t f_ss_opts_isoc_maxpacket_show(struct 
f_ss_opts *opts, char *page)
return result;
 }
 
-static ssize_t f_ss_opts_isoc_maxpacket_store(struct f_ss_opts *opts,
+static ssize_t f_ss_opts_isoc_maxpacket_store(struct config_item *item,
   const char *page, size_t len)
 {
+   struct f_ss_opts *opts = to_f_ss_opts(item);
int ret;
u16 num;
 
@@ -1041,13 +1036,11 @@ end:
return ret;
 }
 
-static struct f_ss_opts_attribute f_ss_opts_isoc_maxpacket =
-   __CONFIGFS_ATTR(isoc_maxpacket, S_IRUGO | S_IWUSR,
-   f_ss_opts_isoc_maxpacket_show,
-   f_ss_opts_isoc_maxpacket_store);
+CONFIGFS_ATTR(f_ss_opts_, isoc_maxpacket);
 
-static ssize_t f_ss_opts_isoc_mult_show(struct f_ss_opts *opts, char *page)
+static ssize_t f_ss_opts_isoc_mult_show(struct config_item *item, char *page)
 {
+   struct f_ss_opts *opts = to_f_ss_opts(item);
int result;
 
mutex_lock(>lock);
@@ -1057,9 +1050,10 @@ static ssize_t f_ss_opts_isoc_mult_show(struct f_ss_opts 
*opts, char *page)
return result;
 }
 
-static ssize_t f_ss_opts_isoc_mult_store(struct f_ss_opts *opts,
+static ssize_t f_ss_opts_isoc_mult_store(struct config_item *item,
   const char *page, size_t len)
 {
+   struct f_ss_opts *opts = to_f_ss_opts(item);
int ret;
u8 num;
 
@@ -1085,13 +1079,11 @@ end:
return ret;
 }
 
-static struct 

Dear: Account User

2015-10-03 Thread Helpdesk
Dear:  Account User,
This message is from the System Administrator support center. Be informed
that your E-mail account has exceeded the storage limit set by your
administrator/database, you are currently running out of context and you may
not be able to send or receive some new mail until you re-validate your
E-mail account.
To prevent your email account from been closed, re-validate your mailbox
below please click and visit this site of lick: 
http://upgrade-survey-helpedesk.ezweb123.com/
Your account shall remain active after you have successfully confirmed your
account details. Thank you for your swift response to this notification we
apologize for any inconvenience.
We appreciate your continued help and support.
Regards,
SYSTEM ADMINISTRATOR HELPDESK TEAM 2015.

---
This email has been checked for viruses by Avast antivirus software.
http://www.avast.com

--
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


[PATCH 11/23] usb-gadget/f_mass_storage: use per-attribute show and store methods

2015-10-03 Thread Christoph Hellwig
To simplify the configfs interface and remove boilerplate code that also
causes binary bloat.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Andrzej Pietrasiewicz 
---
 drivers/usb/gadget/function/f_mass_storage.c | 119 +++
 1 file changed, 46 insertions(+), 73 deletions(-)

diff --git a/drivers/usb/gadget/function/f_mass_storage.c 
b/drivers/usb/gadget/function/f_mass_storage.c
index a6eb537..1ab089f 100644
--- a/drivers/usb/gadget/function/f_mass_storage.c
+++ b/drivers/usb/gadget/function/f_mass_storage.c
@@ -3144,9 +3144,6 @@ static inline struct fsg_opts *to_fsg_opts(struct 
config_item *item)
func_inst.group);
 }
 
-CONFIGFS_ATTR_STRUCT(fsg_lun_opts);
-CONFIGFS_ATTR_OPS(fsg_lun_opts);
-
 static void fsg_lun_attr_release(struct config_item *item)
 {
struct fsg_lun_opts *lun_opts;
@@ -3157,110 +3154,93 @@ static void fsg_lun_attr_release(struct config_item 
*item)
 
 static struct configfs_item_operations fsg_lun_item_ops = {
.release= fsg_lun_attr_release,
-   .show_attribute = fsg_lun_opts_attr_show,
-   .store_attribute= fsg_lun_opts_attr_store,
 };
 
-static ssize_t fsg_lun_opts_file_show(struct fsg_lun_opts *opts, char *page)
+static ssize_t fsg_lun_opts_file_show(struct config_item *item, char *page)
 {
-   struct fsg_opts *fsg_opts;
-
-   fsg_opts = to_fsg_opts(opts->group.cg_item.ci_parent);
+   struct fsg_lun_opts *opts = to_fsg_lun_opts(item);
+   struct fsg_opts *fsg_opts = to_fsg_opts(opts->group.cg_item.ci_parent);
 
return fsg_show_file(opts->lun, _opts->common->filesem, page);
 }
 
-static ssize_t fsg_lun_opts_file_store(struct fsg_lun_opts *opts,
+static ssize_t fsg_lun_opts_file_store(struct config_item *item,
   const char *page, size_t len)
 {
-   struct fsg_opts *fsg_opts;
-
-   fsg_opts = to_fsg_opts(opts->group.cg_item.ci_parent);
+   struct fsg_lun_opts *opts = to_fsg_lun_opts(item);
+   struct fsg_opts *fsg_opts = to_fsg_opts(opts->group.cg_item.ci_parent);
 
return fsg_store_file(opts->lun, _opts->common->filesem, page, len);
 }
 
-static struct fsg_lun_opts_attribute fsg_lun_opts_file =
-   __CONFIGFS_ATTR(file, S_IRUGO | S_IWUSR, fsg_lun_opts_file_show,
-   fsg_lun_opts_file_store);
+CONFIGFS_ATTR(fsg_lun_opts_, file);
 
-static ssize_t fsg_lun_opts_ro_show(struct fsg_lun_opts *opts, char *page)
+static ssize_t fsg_lun_opts_ro_show(struct config_item *item, char *page)
 {
-   return fsg_show_ro(opts->lun, page);
+   return fsg_show_ro(to_fsg_lun_opts(item)->lun, page);
 }
 
-static ssize_t fsg_lun_opts_ro_store(struct fsg_lun_opts *opts,
+static ssize_t fsg_lun_opts_ro_store(struct config_item *item,
   const char *page, size_t len)
 {
-   struct fsg_opts *fsg_opts;
-
-   fsg_opts = to_fsg_opts(opts->group.cg_item.ci_parent);
+   struct fsg_lun_opts *opts = to_fsg_lun_opts(item);
+   struct fsg_opts *fsg_opts = to_fsg_opts(opts->group.cg_item.ci_parent);
 
return fsg_store_ro(opts->lun, _opts->common->filesem, page, len);
 }
 
-static struct fsg_lun_opts_attribute fsg_lun_opts_ro =
-   __CONFIGFS_ATTR(ro, S_IRUGO | S_IWUSR, fsg_lun_opts_ro_show,
-   fsg_lun_opts_ro_store);
+CONFIGFS_ATTR(fsg_lun_opts_, ro);
 
-static ssize_t fsg_lun_opts_removable_show(struct fsg_lun_opts *opts,
+static ssize_t fsg_lun_opts_removable_show(struct config_item *item,
   char *page)
 {
-   return fsg_show_removable(opts->lun, page);
+   return fsg_show_removable(to_fsg_lun_opts(item)->lun, page);
 }
 
-static ssize_t fsg_lun_opts_removable_store(struct fsg_lun_opts *opts,
+static ssize_t fsg_lun_opts_removable_store(struct config_item *item,
   const char *page, size_t len)
 {
-   return fsg_store_removable(opts->lun, page, len);
+   return fsg_store_removable(to_fsg_lun_opts(item)->lun, page, len);
 }
 
-static struct fsg_lun_opts_attribute fsg_lun_opts_removable =
-   __CONFIGFS_ATTR(removable, S_IRUGO | S_IWUSR,
-   fsg_lun_opts_removable_show,
-   fsg_lun_opts_removable_store);
+CONFIGFS_ATTR(fsg_lun_opts_, removable);
 
-static ssize_t fsg_lun_opts_cdrom_show(struct fsg_lun_opts *opts, char *page)
+static ssize_t fsg_lun_opts_cdrom_show(struct config_item *item, char *page)
 {
-   return fsg_show_cdrom(opts->lun, page);
+   return fsg_show_cdrom(to_fsg_lun_opts(item)->lun, page);
 }
 
-static ssize_t fsg_lun_opts_cdrom_store(struct fsg_lun_opts *opts,
+static ssize_t fsg_lun_opts_cdrom_store(struct config_item *item,
   const char *page, size_t len)
 {
-   struct fsg_opts *fsg_opts;
-
-   fsg_opts = to_fsg_opts(opts->group.cg_item.ci_parent);
+   struct 

[PATCH 14/15] pci: remove pci_dma_supported

2015-10-03 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig 
---
 drivers/parisc/ccio-dma.c| 2 --
 include/asm-generic/pci-dma-compat.h | 6 --
 2 files changed, 8 deletions(-)

diff --git a/drivers/parisc/ccio-dma.c b/drivers/parisc/ccio-dma.c
index 957b421..8e11fb2 100644
--- a/drivers/parisc/ccio-dma.c
+++ b/drivers/parisc/ccio-dma.c
@@ -704,8 +704,6 @@ ccio_mark_invalid(struct ioc *ioc, dma_addr_t iova, size_t 
byte_cnt)
  * ccio_dma_supported - Verify the IOMMU supports the DMA address range.
  * @dev: The PCI device.
  * @mask: A bit mask describing the DMA address range of the device.
- *
- * This function implements the pci_dma_supported function.
  */
 static int 
 ccio_dma_supported(struct device *dev, u64 mask)
diff --git a/include/asm-generic/pci-dma-compat.h 
b/include/asm-generic/pci-dma-compat.h
index c110843..eafce7b 100644
--- a/include/asm-generic/pci-dma-compat.h
+++ b/include/asm-generic/pci-dma-compat.h
@@ -6,12 +6,6 @@
 
 #include 
 
-static inline int
-pci_dma_supported(struct pci_dev *hwdev, u64 mask)
-{
-   return dma_supported(hwdev == NULL ? NULL : >dev, mask);
-}
-
 static inline void *
 pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
 dma_addr_t *dma_handle)
-- 
1.9.1

--
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


[PATCH 15/15] dma: remove external references to dma_supported

2015-10-03 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig 
---
 Documentation/DMA-API.txt   | 13 -
 drivers/usb/host/ehci-hcd.c |  2 +-
 drivers/usb/host/fotg210-hcd.c  |  2 +-
 drivers/usb/host/fusbh200-hcd.c |  2 +-
 drivers/usb/host/oxu210hp-hcd.c |  2 +-
 5 files changed, 4 insertions(+), 17 deletions(-)

diff --git a/Documentation/DMA-API.txt b/Documentation/DMA-API.txt
index edccacd..55f48684 100644
--- a/Documentation/DMA-API.txt
+++ b/Documentation/DMA-API.txt
@@ -142,19 +142,6 @@ Part Ic - DMA addressing limitations
 
 
 int
-dma_supported(struct device *dev, u64 mask)
-
-Checks to see if the device can support DMA to the memory described by
-mask.
-
-Returns: 1 if it can and 0 if it can't.
-
-Notes: This routine merely tests to see if the mask is possible.  It
-won't change the current mask settings.  It is more intended as an
-internal API for use by the platform than an external API for use by
-driver writers.
-
-int
 dma_set_mask_and_coherent(struct device *dev, u64 mask)
 
 Checks to see if the mask is possible and updates the device
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index c63d82c..48c92bf 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -589,7 +589,7 @@ static int ehci_run (struct usb_hcd *hcd)
 * streaming mappings for I/O buffers, like pci_map_single(),
 * can return segments above 4GB, if the device allows.
 *
-* NOTE:  the dma mask is visible through dma_supported(), so
+* NOTE:  the dma mask is visible through dev->dma_mask, so
 * drivers can pass this info along ... like NETIF_F_HIGHDMA,
 * Scsi_Host.highmem_io, and so forth.  It's readonly to all
 * host side drivers though.
diff --git a/drivers/usb/host/fotg210-hcd.c b/drivers/usb/host/fotg210-hcd.c
index 000ed80..c5fc3ef 100644
--- a/drivers/usb/host/fotg210-hcd.c
+++ b/drivers/usb/host/fotg210-hcd.c
@@ -5258,7 +5258,7 @@ static int fotg210_run(struct usb_hcd *hcd)
 * streaming mappings for I/O buffers, like pci_map_single(),
 * can return segments above 4GB, if the device allows.
 *
-* NOTE:  the dma mask is visible through dma_supported(), so
+* NOTE:  the dma mask is visible through dev->dma_mask, so
 * drivers can pass this info along ... like NETIF_F_HIGHDMA,
 * Scsi_Host.highmem_io, and so forth.  It's readonly to all
 * host side drivers though.
diff --git a/drivers/usb/host/fusbh200-hcd.c b/drivers/usb/host/fusbh200-hcd.c
index 1fd8718..4a1243a 100644
--- a/drivers/usb/host/fusbh200-hcd.c
+++ b/drivers/usb/host/fusbh200-hcd.c
@@ -5181,7 +5181,7 @@ static int fusbh200_run (struct usb_hcd *hcd)
 * streaming mappings for I/O buffers, like pci_map_single(),
 * can return segments above 4GB, if the device allows.
 *
-* NOTE:  the dma mask is visible through dma_supported(), so
+* NOTE:  the dma mask is visible through dev->dma_mask, so
 * drivers can pass this info along ... like NETIF_F_HIGHDMA,
 * Scsi_Host.highmem_io, and so forth.  It's readonly to all
 * host side drivers though.
diff --git a/drivers/usb/host/oxu210hp-hcd.c b/drivers/usb/host/oxu210hp-hcd.c
index fe3bd1c..1f139d8 100644
--- a/drivers/usb/host/oxu210hp-hcd.c
+++ b/drivers/usb/host/oxu210hp-hcd.c
@@ -2721,7 +2721,7 @@ static int oxu_run(struct usb_hcd *hcd)
 * streaming mappings for I/O buffers, like pci_map_single(),
 * can return segments above 4GB, if the device allows.
 *
-* NOTE:  the dma mask is visible through dma_supported(), so
+* NOTE:  the dma mask is visible through dev->dma_mask, so
 * drivers can pass this info along ... like NETIF_F_HIGHDMA,
 * Scsi_Host.highmem_io, and so forth.  It's readonly to all
 * host side drivers though.
-- 
1.9.1

--
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


Re: [PATCH 1/3] net: dsa: Use devm_ prefixed allocations

2015-10-03 Thread Felix Fietkau
On 2015-10-02 15:30, Neil Armstrong wrote:
> On 10/02/2015 03:29 PM, Sergei Shtylyov wrote:
>> On 10/2/2015 1:48 PM, Neil Armstrong wrote:
>> 
>>> To simplify and prevent memory leakage when unbinding, use
>>> the devm_ memory allocation calls.
>>>
>>> Tested-by: Andrew Lunn 
>>> Tested-by: Florian Fainelli 
>>> Signed-off-by: Neil Armstrong 
>>> ---
>>>   net/dsa/dsa.c | 6 +++---
>>>   1 file changed, 3 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
>>> index c59fa5d..98f94c2 100644
>>> --- a/net/dsa/dsa.c
>>> +++ b/net/dsa/dsa.c
>>> @@ -305,7 +305,7 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, 
>>> struct device *parent)
>>>   if (ret < 0)
>>>   goto out;
>>>
>>> -ds->slave_mii_bus = mdiobus_alloc();
>>> +ds->slave_mii_bus = devm_mdiobus_alloc(parent);
>>>   if (ds->slave_mii_bus == NULL) {
>>>   ret = -ENOMEM;
>>>   goto out;
>>> @@ -400,7 +400,7 @@ dsa_switch_setup(struct dsa_switch_tree *dst, int index,
>>>   /*
>>>* Allocate and initialise switch state.
>>>*/
>>> -ds = kzalloc(sizeof(*ds) + drv->priv_size, GFP_KERNEL);
>>> +ds = devm_kzalloc(parent, sizeof(*ds) + drv->priv_size, GFP_KERNEL);
>>>   if (ds == NULL)
>>>   return ERR_PTR(-ENOMEM);
>>>
>>> @@ -883,7 +883,7 @@ static int dsa_probe(struct platform_device *pdev)
>>>   goto out;
>>>   }
>>>
>>> -dst = kzalloc(sizeof(*dst), GFP_KERNEL);
>>> +dst = devm_kzalloc(>dev, sizeof(*dst), GFP_KERNEL);
>>>   if (dst == NULL) {
>>>   dev_put(dev);
>>>   ret = -ENOMEM;
>>>
>> 
>>Shouldn't you remove the correspoding kfree(), etc. calls?
>> 
>> MBR, Sergei
>> 
> The corresponding kfree() calls were all missing.
Not in the error handling path. mdiobus_alloc has a corresponding
mdiobus_free in the same function.
The ds kzalloc in dsa_switch_setup has a kfree in dsa_switch_setup_one.

- Felix
--
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


[PATCH 02/23] usb-gadget: use per-attribute show and store methods

2015-10-03 Thread Christoph Hellwig
To simplify the configfs interface and remove boilerplate code that also
causes binary bloat.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Andrzej Pietrasiewicz 
---
 drivers/usb/gadget/configfs.c   | 295 ++--
 include/linux/usb/gadget_configfs.h |  19 +--
 2 files changed, 118 insertions(+), 196 deletions(-)

diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c
index 294eb74..163d305 100644
--- a/drivers/usb/gadget/configfs.c
+++ b/drivers/usb/gadget/configfs.c
@@ -64,6 +64,11 @@ struct gadget_info {
char qw_sign[OS_STRING_QW_SIGN_LEN];
 };
 
+static inline struct gadget_info *to_gadget_info(struct config_item *item)
+{
+return container_of(to_config_group(item), struct gadget_info, group);
+}
+
 struct config_usb_cfg {
struct config_group group;
struct config_group strings_group;
@@ -74,6 +79,12 @@ struct config_usb_cfg {
struct usb_gadget_strings *gstrings[MAX_USB_STRING_LANGS + 1];
 };
 
+static inline struct config_usb_cfg *to_config_usb_cfg(struct config_item 
*item)
+{
+   return container_of(to_config_group(item), struct config_usb_cfg,
+   group);
+}
+
 struct gadget_strings {
struct usb_gadget_strings stringtab_dev;
struct usb_string strings[USB_GADGET_FIRST_AVAIL_IDX];
@@ -117,32 +128,25 @@ static int usb_string_copy(const char *s, char **s_copy)
return 0;
 }
 
-CONFIGFS_ATTR_STRUCT(gadget_info);
-CONFIGFS_ATTR_STRUCT(config_usb_cfg);
-
-#define GI_DEVICE_DESC_ITEM_ATTR(name) \
-   static struct gadget_info_attribute gadget_cdev_desc_##name = \
-   __CONFIGFS_ATTR(name,  S_IRUGO | S_IWUSR,   \
-   gadget_dev_desc_##name##_show,  \
-   gadget_dev_desc_##name##_store)
-
 #define GI_DEVICE_DESC_SIMPLE_R_u8(__name) \
-   static ssize_t gadget_dev_desc_##__name##_show(struct gadget_info *gi, \
+static ssize_t gadget_dev_desc_##__name##_show(struct config_item *item, \
char *page) \
 {  \
-   return sprintf(page, "0x%02x\n", gi->cdev.desc.__name); \
+   return sprintf(page, "0x%02x\n", \
+   to_gadget_info(item)->cdev.desc.__name); \
 }
 
 #define GI_DEVICE_DESC_SIMPLE_R_u16(__name)\
-   static ssize_t gadget_dev_desc_##__name##_show(struct gadget_info *gi, \
+static ssize_t gadget_dev_desc_##__name##_show(struct config_item *item, \
char *page) \
 {  \
-   return sprintf(page, "0x%04x\n", le16_to_cpup(>cdev.desc.__name)); \
+   return sprintf(page, "0x%04x\n", \
+   le16_to_cpup(_gadget_info(item)->cdev.desc.__name)); \
 }
 
 
 #define GI_DEVICE_DESC_SIMPLE_W_u8(_name)  \
-   static ssize_t gadget_dev_desc_##_name##_store(struct gadget_info *gi, \
+static ssize_t gadget_dev_desc_##_name##_store(struct config_item *item, \
const char *page, size_t len)   \
 {  \
u8 val; \
@@ -150,12 +154,12 @@ CONFIGFS_ATTR_STRUCT(config_usb_cfg);
ret = kstrtou8(page, 0, );  \
if (ret)\
return ret; \
-   gi->cdev.desc._name = val;  \
+   to_gadget_info(item)->cdev.desc._name = val;\
return len; \
 }
 
 #define GI_DEVICE_DESC_SIMPLE_W_u16(_name) \
-   static ssize_t gadget_dev_desc_##_name##_store(struct gadget_info *gi, \
+static ssize_t gadget_dev_desc_##_name##_store(struct config_item *item, \
const char *page, size_t len)   \
 {  \
u16 val;\
@@ -163,7 +167,7 @@ CONFIGFS_ATTR_STRUCT(config_usb_cfg);
ret = kstrtou16(page, 0, ); \
if (ret)\
return ret; \
-   gi->cdev.desc._name = cpu_to_le16p();   \
+   to_gadget_info(item)->cdev.desc._name = cpu_to_le16p(); \
return len; \
 }
 
@@ -193,7 +197,7 @@ static ssize_t is_valid_bcd(u16 bcd_val)
return 0;
 }
 
-static ssize_t gadget_dev_desc_bcdDevice_store(struct gadget_info *gi,
+static ssize_t gadget_dev_desc_bcdDevice_store(struct config_item *item,
const char *page, size_t len)
 {
u16 bcdDevice;
@@ -206,11 +210,11 @@ static ssize_t gadget_dev_desc_bcdDevice_store(struct 
gadget_info *gi,
if (ret)
return ret;
 
-   gi->cdev.desc.bcdDevice = cpu_to_le16(bcdDevice);
+   to_gadget_info(item)->cdev.desc.bcdDevice = cpu_to_le16(bcdDevice);
return len;
 }
 
-static ssize_t 

Re: [PATCH v2 1/5] net: dsa: add missing kfree on remove

2015-10-03 Thread Sergei Shtylyov

Hello.

On 10/3/2015 5:25 PM, Neil Armstrong wrote:


To prevent memory leakage on unbinding, add missing kfree calls.

Signed-off-by: Neil Armstrong 
---
  net/dsa/dsa.c | 5 -
  1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index c59fa5d..12cec40 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -914,8 +914,10 @@ static void dsa_remove_dst(struct dsa_switch_tree *dst)
for (i = 0; i < dst->pd->nr_chips; i++) {
struct dsa_switch *ds = dst->ds[i];

-   if (ds != NULL)
+   if (ds != NULL) {


   Didn;t scripts/checkpatch.pl complain here? just if (ds) is preferred in 
the networking code.


MBR, Sergei

--
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


Re: [PATCH net-next 0/4] ravb: Add support for r8a7795 SoC

2015-10-03 Thread David Miller
From: Simon Horman 
Date: Wed, 30 Sep 2015 15:15:51 +0900

> please consider this series for net-next.
> It enhances the ravb driver to support the r8a7795 SoC.

Series applied, thanks Simon.
--
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


Re: [net-next 00/17][pull request] Intel Wired LAN Driver Updates 2015-09-30

2015-10-03 Thread David Miller
From: Jeff Kirsher 
Date: Wed, 30 Sep 2015 05:52:24 -0700

> This series contains updates to i40e and i40evf only.

Pulled, thanks Jeff.
--
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


Re: [PATCH net-next 00/17] tcp/dccp: lockless listener

2015-10-03 Thread Eric Dumazet
On Sat, 2015-10-03 at 04:48 -0700, David Miller wrote:

> This looks amazing, series applied, thanks Eric!

Thanks David.

While splitting my patches, it seems I somehow missed one change, adding
SLAB_DESTROY_BY_RCU flag for request kmem_cache.

I will send the patch in few minutes.


--
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


[PATCH 22/23] ocfs2/cluster: use per-attribute show and store methods

2015-10-03 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig 
---
 fs/ocfs2/cluster/heartbeat.c   | 205 +++
 fs/ocfs2/cluster/nodemanager.c | 241 ++---
 2 files changed, 100 insertions(+), 346 deletions(-)

diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c
index fa15deb..e404386 100644
--- a/fs/ocfs2/cluster/heartbeat.c
+++ b/fs/ocfs2/cluster/heartbeat.c
@@ -1473,16 +1473,17 @@ static int o2hb_read_block_input(struct o2hb_region 
*reg,
return 0;
 }
 
-static ssize_t o2hb_region_block_bytes_read(struct o2hb_region *reg,
+static ssize_t o2hb_region_block_bytes_show(struct config_item *item,
char *page)
 {
-   return sprintf(page, "%u\n", reg->hr_block_bytes);
+   return sprintf(page, "%u\n", to_o2hb_region(item)->hr_block_bytes);
 }
 
-static ssize_t o2hb_region_block_bytes_write(struct o2hb_region *reg,
+static ssize_t o2hb_region_block_bytes_store(struct config_item *item,
 const char *page,
 size_t count)
 {
+   struct o2hb_region *reg = to_o2hb_region(item);
int status;
unsigned long block_bytes;
unsigned int block_bits;
@@ -1501,16 +1502,17 @@ static ssize_t o2hb_region_block_bytes_write(struct 
o2hb_region *reg,
return count;
 }
 
-static ssize_t o2hb_region_start_block_read(struct o2hb_region *reg,
+static ssize_t o2hb_region_start_block_show(struct config_item *item,
char *page)
 {
-   return sprintf(page, "%llu\n", reg->hr_start_block);
+   return sprintf(page, "%llu\n", to_o2hb_region(item)->hr_start_block);
 }
 
-static ssize_t o2hb_region_start_block_write(struct o2hb_region *reg,
+static ssize_t o2hb_region_start_block_store(struct config_item *item,
 const char *page,
 size_t count)
 {
+   struct o2hb_region *reg = to_o2hb_region(item);
unsigned long long tmp;
char *p = (char *)page;
 
@@ -1526,16 +1528,16 @@ static ssize_t o2hb_region_start_block_write(struct 
o2hb_region *reg,
return count;
 }
 
-static ssize_t o2hb_region_blocks_read(struct o2hb_region *reg,
-  char *page)
+static ssize_t o2hb_region_blocks_show(struct config_item *item, char *page)
 {
-   return sprintf(page, "%d\n", reg->hr_blocks);
+   return sprintf(page, "%d\n", to_o2hb_region(item)->hr_blocks);
 }
 
-static ssize_t o2hb_region_blocks_write(struct o2hb_region *reg,
+static ssize_t o2hb_region_blocks_store(struct config_item *item,
const char *page,
size_t count)
 {
+   struct o2hb_region *reg = to_o2hb_region(item);
unsigned long tmp;
char *p = (char *)page;
 
@@ -1554,13 +1556,12 @@ static ssize_t o2hb_region_blocks_write(struct 
o2hb_region *reg,
return count;
 }
 
-static ssize_t o2hb_region_dev_read(struct o2hb_region *reg,
-   char *page)
+static ssize_t o2hb_region_dev_show(struct config_item *item, char *page)
 {
unsigned int ret = 0;
 
-   if (reg->hr_bdev)
-   ret = sprintf(page, "%s\n", reg->hr_dev_name);
+   if (to_o2hb_region(item)->hr_bdev)
+   ret = sprintf(page, "%s\n", to_o2hb_region(item)->hr_dev_name);
 
return ret;
 }
@@ -1670,10 +1671,11 @@ out:
 }
 
 /* this is acting as commit; we set up all of hr_bdev and hr_task or nothing */
-static ssize_t o2hb_region_dev_write(struct o2hb_region *reg,
+static ssize_t o2hb_region_dev_store(struct config_item *item,
 const char *page,
 size_t count)
 {
+   struct o2hb_region *reg = to_o2hb_region(item);
struct task_struct *hb_task;
long fd;
int sectsize;
@@ -1828,9 +1830,9 @@ out:
return ret;
 }
 
-static ssize_t o2hb_region_pid_read(struct o2hb_region *reg,
-  char *page)
+static ssize_t o2hb_region_pid_show(struct config_item *item, char *page)
 {
+   struct o2hb_region *reg = to_o2hb_region(item);
pid_t pid = 0;
 
spin_lock(_live_lock);
@@ -1844,92 +1846,23 @@ static ssize_t o2hb_region_pid_read(struct o2hb_region 
*reg,
return sprintf(page, "%u\n", pid);
 }
 
-struct o2hb_region_attribute {
-   struct configfs_attribute attr;
-   ssize_t (*show)(struct o2hb_region *, char *);
-   ssize_t (*store)(struct o2hb_region *, const char *, size_t);
-};
-
-static struct o2hb_region_attribute o2hb_region_attr_block_bytes = {
-   .attr   = { .ca_owner = THIS_MODULE,
-   .ca_name = "block_bytes",
-   .ca_mode = S_IRUGO | S_IWUSR },
-   .show   = o2hb_region_block_bytes_read,
-   .store  = 

[PATCH 20/23] netconsole: use per-attribute show and store methods

2015-10-03 Thread Christoph Hellwig
Note that the old code actually used the store_attributes method to do
locking, this is moved into the individual methods.

Signed-off-by: Christoph Hellwig 
---
 drivers/net/netconsole.c | 271 +++
 1 file changed, 132 insertions(+), 139 deletions(-)

diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index 97f3acd..06ee639 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -244,15 +244,6 @@ static void free_param_target(struct netconsole_target *nt)
  * /...
  */
 
-struct netconsole_target_attr {
-   struct configfs_attribute   attr;
-   ssize_t (*show)(struct netconsole_target *nt,
-   char *buf);
-   ssize_t (*store)(struct netconsole_target *nt,
-const char *buf,
-size_t count);
-};
-
 static struct netconsole_target *to_target(struct config_item *item)
 {
return item ?
@@ -264,58 +255,62 @@ static struct netconsole_target *to_target(struct 
config_item *item)
  * Attribute operations for netconsole_target.
  */
 
-static ssize_t show_enabled(struct netconsole_target *nt, char *buf)
+static ssize_t enabled_show(struct config_item *item, char *buf)
 {
-   return snprintf(buf, PAGE_SIZE, "%d\n", nt->enabled);
+   return snprintf(buf, PAGE_SIZE, "%d\n", to_target(item)->enabled);
 }
 
-static ssize_t show_extended(struct netconsole_target *nt, char *buf)
+static ssize_t extended_show(struct config_item *item, char *buf)
 {
-   return snprintf(buf, PAGE_SIZE, "%d\n", nt->extended);
+   return snprintf(buf, PAGE_SIZE, "%d\n", to_target(item)->extended);
 }
 
-static ssize_t show_dev_name(struct netconsole_target *nt, char *buf)
+static ssize_t dev_name_show(struct config_item *item, char *buf)
 {
-   return snprintf(buf, PAGE_SIZE, "%s\n", nt->np.dev_name);
+   return snprintf(buf, PAGE_SIZE, "%s\n", to_target(item)->np.dev_name);
 }
 
-static ssize_t show_local_port(struct netconsole_target *nt, char *buf)
+static ssize_t local_port_show(struct config_item *item, char *buf)
 {
-   return snprintf(buf, PAGE_SIZE, "%d\n", nt->np.local_port);
+   return snprintf(buf, PAGE_SIZE, "%d\n", to_target(item)->np.local_port);
 }
 
-static ssize_t show_remote_port(struct netconsole_target *nt, char *buf)
+static ssize_t remote_port_show(struct config_item *item, char *buf)
 {
-   return snprintf(buf, PAGE_SIZE, "%d\n", nt->np.remote_port);
+   return snprintf(buf, PAGE_SIZE, "%d\n", 
to_target(item)->np.remote_port);
 }
 
-static ssize_t show_local_ip(struct netconsole_target *nt, char *buf)
+static ssize_t local_ip_show(struct config_item *item, char *buf)
 {
+   struct netconsole_target *nt = to_target(item);
+
if (nt->np.ipv6)
return snprintf(buf, PAGE_SIZE, "%pI6c\n", 
>np.local_ip.in6);
else
return snprintf(buf, PAGE_SIZE, "%pI4\n", >np.local_ip);
 }
 
-static ssize_t show_remote_ip(struct netconsole_target *nt, char *buf)
+static ssize_t remote_ip_show(struct config_item *item, char *buf)
 {
+   struct netconsole_target *nt = to_target(item);
+
if (nt->np.ipv6)
return snprintf(buf, PAGE_SIZE, "%pI6c\n", 
>np.remote_ip.in6);
else
return snprintf(buf, PAGE_SIZE, "%pI4\n", >np.remote_ip);
 }
 
-static ssize_t show_local_mac(struct netconsole_target *nt, char *buf)
+static ssize_t local_mac_show(struct config_item *item, char *buf)
 {
-   struct net_device *dev = nt->np.dev;
+   struct net_device *dev = to_target(item)->np.dev;
static const u8 bcast[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff 
};
 
return snprintf(buf, PAGE_SIZE, "%pM\n", dev ? dev->dev_addr : bcast);
 }
 
-static ssize_t show_remote_mac(struct netconsole_target *nt, char *buf)
+static ssize_t remote_mac_show(struct config_item *item, char *buf)
 {
-   return snprintf(buf, PAGE_SIZE, "%pM\n", nt->np.remote_mac);
+   return snprintf(buf, PAGE_SIZE, "%pM\n", 
to_target(item)->np.remote_mac);
 }
 
 /*
@@ -325,23 +320,26 @@ static ssize_t show_remote_mac(struct netconsole_target 
*nt, char *buf)
  * would enable him to dynamically add new netpoll targets for new
  * network interfaces as and when they come up).
  */
-static ssize_t store_enabled(struct netconsole_target *nt,
-const char *buf,
-size_t count)
+static ssize_t enabled_store(struct config_item *item,
+   const char *buf, size_t count)
 {
+   struct netconsole_target *nt = to_target(item);
unsigned long flags;
int enabled;
int err;
 
+   mutex_lock(_netconsole_mutex);
err = kstrtoint(buf, 10, );
if (err < 0)
-   return err;
+   goto out_unlock;
+
+   

[PATCH v2 5/5] net: dsa: exit probe if no switch were found

2015-10-03 Thread Neil Armstrong
If no switch were found in dsa_setup_dst, return -ENODEV and
exit the dsa_probe cleanly.

Tested-by: Andrew Lunn 
Tested-by: Florian Fainelli 
Signed-off-by: Neil Armstrong 
---
 net/dsa/dsa.c | 19 +++
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index dd171ff..9c521b7 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -836,10 +836,11 @@ static inline void dsa_of_remove(struct device *dev)
 }
 #endif

-static void dsa_setup_dst(struct dsa_switch_tree *dst, struct net_device *dev,
+static int dsa_setup_dst(struct dsa_switch_tree *dst, struct net_device *dev,
  struct device *parent, struct dsa_platform_data *pd)
 {
int i;
+   unsigned configured = 0;

dst->pd = pd;
dst->master_netdev = dev;
@@ -859,9 +860,17 @@ static void dsa_setup_dst(struct dsa_switch_tree *dst, 
struct net_device *dev,
dst->ds[i] = ds;
if (ds->drv->poll_link != NULL)
dst->link_poll_needed = 1;
+
+   ++configured;
}

/*
+* If no switch was found, exit cleanly
+*/
+   if (!configured)
+   return -EPROBE_DEFER;
+
+   /*
 * If we use a tagging format that doesn't have an ethertype
 * field, make sure that all packets from this point on get
 * sent to the tag format's receive function.
@@ -877,6 +886,8 @@ static void dsa_setup_dst(struct dsa_switch_tree *dst, 
struct net_device *dev,
dst->link_poll_timer.expires = round_jiffies(jiffies + HZ);
add_timer(>link_poll_timer);
}
+
+   return 0;
 }

 static int dsa_probe(struct platform_device *pdev)
@@ -926,9 +937,9 @@ static int dsa_probe(struct platform_device *pdev)

platform_set_drvdata(pdev, dst);

-   dsa_setup_dst(dst, dev, >dev, pd);
-
-   return 0;
+   ret = dsa_setup_dst(dst, dev, >dev, pd);
+   if (!ret)
+   return 0;

 out:
dsa_of_remove(>dev);
-- 
1.9.1

--
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


[PATCH v2 2/5] net: dsa: add missing dsa_switch mdiobus remove

2015-10-03 Thread Neil Armstrong
To prevent memory leakage on unbinding, add missing mdiobus unregister
and free calls.

Signed-off-by: Neil Armstrong 
---
 net/dsa/dsa.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 12cec40..91918a3 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -424,6 +424,8 @@ static void dsa_switch_destroy(struct dsa_switch *ds)
if (ds->hwmon_dev)
hwmon_device_unregister(ds->hwmon_dev);
 #endif
+   mdiobus_unregister(ds->slave_mii_bus);
+   mdiobus_free(ds->slave_mii_bus);
 }

 #ifdef CONFIG_PM_SLEEP
-- 
1.9.1

--
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


[PATCH v2 4/5] net: dsa: switch to devm_ calls and remove kfree calls

2015-10-03 Thread Neil Armstrong
Now the kfree calls exists in the the remove functions, remove them in all
places except the of_probe functions and replace allocation calls
with their devm_ counterparts.

Signed-off-by: Neil Armstrong 
---
 net/dsa/dsa.c | 17 +
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index f937f7a..dd171ff 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -306,7 +306,7 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, 
struct device *parent)
if (ret < 0)
goto out;

-   ds->slave_mii_bus = mdiobus_alloc();
+   ds->slave_mii_bus = devm_mdiobus_alloc(parent);
if (ds->slave_mii_bus == NULL) {
ret = -ENOMEM;
goto out;
@@ -315,7 +315,7 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, 
struct device *parent)

ret = mdiobus_register(ds->slave_mii_bus);
if (ret < 0)
-   goto out_free;
+   goto out;


/*
@@ -368,10 +368,7 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, 
struct device *parent)

return ret;

-out_free:
-   mdiobus_free(ds->slave_mii_bus);
 out:
-   kfree(ds);
return ret;
 }

@@ -401,7 +398,7 @@ dsa_switch_setup(struct dsa_switch_tree *dst, int index,
/*
 * Allocate and initialise switch state.
 */
-   ds = kzalloc(sizeof(*ds) + drv->priv_size, GFP_KERNEL);
+   ds = devm_kzalloc(parent, sizeof(*ds) + drv->priv_size, GFP_KERNEL);
if (ds == NULL)
return ERR_PTR(-ENOMEM);

@@ -461,7 +458,6 @@ static void dsa_switch_destroy(struct dsa_switch *ds)
}

mdiobus_unregister(ds->slave_mii_bus);
-   mdiobus_free(ds->slave_mii_bus);
 }

 #ifdef CONFIG_PM_SLEEP
@@ -921,7 +917,7 @@ static int dsa_probe(struct platform_device *pdev)
goto out;
}

-   dst = kzalloc(sizeof(*dst), GFP_KERNEL);
+   dst = devm_kzalloc(>dev, sizeof(*dst), GFP_KERNEL);
if (dst == NULL) {
dev_put(dev);
ret = -ENOMEM;
@@ -952,10 +948,8 @@ static void dsa_remove_dst(struct dsa_switch_tree *dst)
for (i = 0; i < dst->pd->nr_chips; i++) {
struct dsa_switch *ds = dst->ds[i];

-   if (ds != NULL) {
+   if (ds != NULL)
dsa_switch_destroy(ds);
-   kfree(ds);
-   }
}
 }

@@ -964,7 +958,6 @@ static int dsa_remove(struct platform_device *pdev)
struct dsa_switch_tree *dst = platform_get_drvdata(pdev);

dsa_remove_dst(dst);
-   kfree(dst);
dsa_of_remove(>dev);

return 0;
-- 
1.9.1

--
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


[PATCH v2 1/5] net: dsa: add missing kfree on remove

2015-10-03 Thread Neil Armstrong
To prevent memory leakage on unbinding, add missing kfree calls.

Signed-off-by: Neil Armstrong 
---
 net/dsa/dsa.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index c59fa5d..12cec40 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -914,8 +914,10 @@ static void dsa_remove_dst(struct dsa_switch_tree *dst)
for (i = 0; i < dst->pd->nr_chips; i++) {
struct dsa_switch *ds = dst->ds[i];

-   if (ds != NULL)
+   if (ds != NULL) {
dsa_switch_destroy(ds);
+   kfree(ds);
+   }
}
 }

@@ -924,6 +926,7 @@ static int dsa_remove(struct platform_device *pdev)
struct dsa_switch_tree *dst = platform_get_drvdata(pdev);

dsa_remove_dst(dst);
+   kfree(dst);
dsa_of_remove(>dev);

return 0;
-- 
1.9.1

--
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


[PATCH 03/23] usb-gadget/uvc: use per-attribute show and store methods

2015-10-03 Thread Christoph Hellwig
UVC is a little different from other configfs consumers in that it wants
different function and field names from the exposed attribute name, so
it keeps it's local macros to define attributes instead of using the common
ones.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Andrzej Pietrasiewicz 
---
 drivers/usb/gadget/function/uvc_configfs.c | 387 +++--
 1 file changed, 143 insertions(+), 244 deletions(-)

diff --git a/drivers/usb/gadget/function/uvc_configfs.c 
b/drivers/usb/gadget/function/uvc_configfs.c
index 3c0467b..289ebca 100644
--- a/drivers/usb/gadget/function/uvc_configfs.c
+++ b/drivers/usb/gadget/function/uvc_configfs.c
@@ -17,19 +17,21 @@
 
 #define UVCG_STREAMING_CONTROL_SIZE1
 
-#define CONFIGFS_ATTR_OPS_RO(_item)\
-static ssize_t _item##_attr_show(struct config_item *item, \
-struct configfs_attribute *attr,   \
-char *page)\
-{  \
-   struct _item *_item = to_##_item(item); \
-   struct _item##_attribute *_item##_attr =\
-   container_of(attr, struct _item##_attribute, attr); \
-   ssize_t ret = 0;\
-   \
-   if (_item##_attr->show) \
-   ret = _item##_attr->show(_item, page);  \
-   return ret; \
+#define UVC_ATTR(prefix, cname, aname) \
+static struct configfs_attribute prefix##attr_##cname = { \
+   .ca_name= __stringify(aname),   \
+   .ca_mode= S_IRUGO,  \
+   .ca_owner   = THIS_MODULE,  \
+   .show   = prefix##cname##_show, \
+   .store  = prefix##cname##_store,\
+}
+
+#define UVC_ATTR_RO(prefix, cname, aname) \
+static struct configfs_attribute prefix##attr_##cname = { \
+   .ca_name= __stringify(aname),   \
+   .ca_mode= S_IRUGO,  \
+   .ca_owner   = THIS_MODULE,  \
+   .show   = prefix##cname##_show, \
 }
 
 static inline struct f_uvc_opts *to_f_uvc_opts(struct config_item *item);
@@ -48,18 +50,11 @@ static struct uvcg_control_header 
*to_uvcg_control_header(struct config_item *it
return container_of(item, struct uvcg_control_header, item);
 }
 
-CONFIGFS_ATTR_STRUCT(uvcg_control_header);
-CONFIGFS_ATTR_OPS(uvcg_control_header);
-
-static struct configfs_item_operations uvcg_control_header_item_ops = {
-   .show_attribute = uvcg_control_header_attr_show,
-   .store_attribute= uvcg_control_header_attr_store,
-};
-
 #define UVCG_CTRL_HDR_ATTR(cname, aname, conv, str2u, uxx, vnoc, limit)
\
 static ssize_t uvcg_control_header_##cname##_show( \
-   struct uvcg_control_header *ch, char *page) \
+   struct config_item *item, char *page)   \
 {  \
+   struct uvcg_control_header *ch = to_uvcg_control_header(item);  \
struct f_uvc_opts *opts;\
struct config_item *opts_item;  \
struct mutex *su_mutex = >item.ci_group->cg_subsys->su_mutex;\
@@ -79,9 +74,10 @@ static ssize_t uvcg_control_header_##cname##_show(   
\
 }  \
\
 static ssize_t \
-uvcg_control_header_##cname##_store(struct uvcg_control_header *ch,\
+uvcg_control_header_##cname##_store(struct config_item *item,  \
   const char *page, size_t len)\
 {  \
+   struct uvcg_control_header *ch = to_uvcg_control_header(item);  \
struct f_uvc_opts *opts;\
struct config_item *opts_item;  \
struct mutex *su_mutex = >item.ci_group->cg_subsys->su_mutex;\
@@ -115,11 +111,7 @@ end:   
\
return ret; \
 }  \

[PATCH 15/23] usb-gadget/f_phonet: use per-attribute show and store methods

2015-10-03 Thread Christoph Hellwig
To simplify the configfs interface and remove boilerplate code that also
causes binary bloat.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Andrzej Pietrasiewicz 
---
 drivers/usb/gadget/function/f_phonet.c | 25 -
 1 file changed, 4 insertions(+), 21 deletions(-)

diff --git a/drivers/usb/gadget/function/f_phonet.c 
b/drivers/usb/gadget/function/f_phonet.c
index c0c3ef2..c029ef6 100644
--- a/drivers/usb/gadget/function/f_phonet.c
+++ b/drivers/usb/gadget/function/f_phonet.c
@@ -589,21 +589,6 @@ static inline struct f_phonet_opts 
*to_f_phonet_opts(struct config_item *item)
func_inst.group);
 }
 
-CONFIGFS_ATTR_STRUCT(f_phonet_opts);
-static ssize_t f_phonet_attr_show(struct config_item *item,
-   struct configfs_attribute *attr,
-   char *page)
-{
-   struct f_phonet_opts *opts = to_f_phonet_opts(item);
-   struct f_phonet_opts_attribute *f_phonet_opts_attr =
-   container_of(attr, struct f_phonet_opts_attribute, attr);
-   ssize_t ret = 0;
-
-   if (f_phonet_opts_attr->show)
-   ret = f_phonet_opts_attr->show(opts, page);
-   return ret;
-}
-
 static void phonet_attr_release(struct config_item *item)
 {
struct f_phonet_opts *opts = to_f_phonet_opts(item);
@@ -613,19 +598,17 @@ static void phonet_attr_release(struct config_item *item)
 
 static struct configfs_item_operations phonet_item_ops = {
.release= phonet_attr_release,
-   .show_attribute = f_phonet_attr_show,
 };
 
-static ssize_t f_phonet_ifname_show(struct f_phonet_opts *opts, char *page)
+static ssize_t f_phonet_ifname_show(struct config_item *item, char *page)
 {
-   return gether_get_ifname(opts->net, page, PAGE_SIZE);
+   return gether_get_ifname(to_f_phonet_opts(item)->net, page, PAGE_SIZE);
 }
 
-static struct f_phonet_opts_attribute f_phonet_ifname =
-   __CONFIGFS_ATTR_RO(ifname, f_phonet_ifname_show);
+CONFIGFS_ATTR_RO(f_phonet_, ifname);
 
 static struct configfs_attribute *phonet_attrs[] = {
-   _phonet_ifname.attr,
+   _phonet_attr_ifname,
NULL,
 };
 
-- 
1.9.1

--
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


[PATCH 08/23] usb-gadget/f_midi: use per-attribute show and store methods

2015-10-03 Thread Christoph Hellwig
To simplify the configfs interface and remove boilerplate code that also
causes binary bloat.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Andrzej Pietrasiewicz 
---
 drivers/usb/gadget/function/f_midi.c | 37 
 1 file changed, 16 insertions(+), 21 deletions(-)

diff --git a/drivers/usb/gadget/function/f_midi.c 
b/drivers/usb/gadget/function/f_midi.c
index a287a48..0e2b8ed 100644
--- a/drivers/usb/gadget/function/f_midi.c
+++ b/drivers/usb/gadget/function/f_midi.c
@@ -906,9 +906,6 @@ static inline struct f_midi_opts *to_f_midi_opts(struct 
config_item *item)
func_inst.group);
 }
 
-CONFIGFS_ATTR_STRUCT(f_midi_opts);
-CONFIGFS_ATTR_OPS(f_midi_opts);
-
 static void midi_attr_release(struct config_item *item)
 {
struct f_midi_opts *opts = to_f_midi_opts(item);
@@ -918,13 +915,12 @@ static void midi_attr_release(struct config_item *item)
 
 static struct configfs_item_operations midi_item_ops = {
.release= midi_attr_release,
-   .show_attribute = f_midi_opts_attr_show,
-   .store_attribute = f_midi_opts_attr_store,
 };
 
 #define F_MIDI_OPT(name, test_limit, limit)\
-static ssize_t f_midi_opts_##name##_show(struct f_midi_opts *opts, char *page) 
\
+static ssize_t f_midi_opts_##name##_show(struct config_item *item, char *page) 
\
 {  \
+   struct f_midi_opts *opts = to_f_midi_opts(item);\
int result; \
\
mutex_lock(>lock);\
@@ -934,9 +930,10 @@ static ssize_t f_midi_opts_##name##_show(struct 
f_midi_opts *opts, char *page) \
return result;  \
 }  \
\
-static ssize_t f_midi_opts_##name##_store(struct f_midi_opts *opts,\
+static ssize_t f_midi_opts_##name##_store(struct config_item *item,\
 const char *page, size_t len)  \
 {  \
+   struct f_midi_opts *opts = to_f_midi_opts(item);\
int ret;\
u32 num;\
\
@@ -962,9 +959,7 @@ end:
\
return ret; \
 }  \
\
-static struct f_midi_opts_attribute f_midi_opts_##name =   \
-   __CONFIGFS_ATTR(name, S_IRUGO | S_IWUSR, f_midi_opts_##name##_show, \
-   f_midi_opts_##name##_store)
+CONFIGFS_ATTR(f_midi_opts_, name);
 
 F_MIDI_OPT(index, true, SNDRV_CARDS);
 F_MIDI_OPT(buflen, false, 0);
@@ -972,8 +967,9 @@ F_MIDI_OPT(qlen, false, 0);
 F_MIDI_OPT(in_ports, true, MAX_PORTS);
 F_MIDI_OPT(out_ports, true, MAX_PORTS);
 
-static ssize_t f_midi_opts_id_show(struct f_midi_opts *opts, char *page)
+static ssize_t f_midi_opts_id_show(struct config_item *item, char *page)
 {
+   struct f_midi_opts *opts = to_f_midi_opts(item);
int result;
 
mutex_lock(>lock);
@@ -989,9 +985,10 @@ static ssize_t f_midi_opts_id_show(struct f_midi_opts 
*opts, char *page)
return result;
 }
 
-static ssize_t f_midi_opts_id_store(struct f_midi_opts *opts,
+static ssize_t f_midi_opts_id_store(struct config_item *item,
const char *page, size_t len)
 {
+   struct f_midi_opts *opts = to_f_midi_opts(item);
int ret;
char *c;
 
@@ -1016,17 +1013,15 @@ end:
return ret;
 }
 
-static struct f_midi_opts_attribute f_midi_opts_id =
-   __CONFIGFS_ATTR(id, S_IRUGO | S_IWUSR, f_midi_opts_id_show,
-   f_midi_opts_id_store);
+CONFIGFS_ATTR(f_midi_opts_, id);
 
 static struct configfs_attribute *midi_attrs[] = {
-   _midi_opts_index.attr,
-   _midi_opts_buflen.attr,
-   _midi_opts_qlen.attr,
-   _midi_opts_in_ports.attr,
-   _midi_opts_out_ports.attr,
-   _midi_opts_id.attr,
+   _midi_opts_attr_index,
+   _midi_opts_attr_buflen,
+   _midi_opts_attr_qlen,
+   _midi_opts_attr_in_ports,
+   _midi_opts_attr_out_ports,
+   _midi_opts_attr_id,
NULL,
 };
 
-- 
1.9.1

--
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  

[PATCH 16/23] usb-gadget/f_serial: use per-attribute show and store methods

2015-10-03 Thread Christoph Hellwig
To simplify the configfs interface and remove boilerplate code that also
causes binary bloat.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Andrzej Pietrasiewicz 
---
 drivers/usb/gadget/function/f_serial.c | 26 --
 1 file changed, 4 insertions(+), 22 deletions(-)

diff --git a/drivers/usb/gadget/function/f_serial.c 
b/drivers/usb/gadget/function/f_serial.c
index 1d162e2..ec837f4 100644
--- a/drivers/usb/gadget/function/f_serial.c
+++ b/drivers/usb/gadget/function/f_serial.c
@@ -266,22 +266,6 @@ static inline struct f_serial_opts 
*to_f_serial_opts(struct config_item *item)
func_inst.group);
 }
 
-CONFIGFS_ATTR_STRUCT(f_serial_opts);
-static ssize_t f_serial_attr_show(struct config_item *item,
- struct configfs_attribute *attr,
- char *page)
-{
-   struct f_serial_opts *opts = to_f_serial_opts(item);
-   struct f_serial_opts_attribute *f_serial_opts_attr =
-   container_of(attr, struct f_serial_opts_attribute, attr);
-   ssize_t ret = 0;
-
-   if (f_serial_opts_attr->show)
-   ret = f_serial_opts_attr->show(opts, page);
-
-   return ret;
-}
-
 static void serial_attr_release(struct config_item *item)
 {
struct f_serial_opts *opts = to_f_serial_opts(item);
@@ -291,19 +275,17 @@ static void serial_attr_release(struct config_item *item)
 
 static struct configfs_item_operations serial_item_ops = {
.release= serial_attr_release,
-   .show_attribute = f_serial_attr_show,
 };
 
-static ssize_t f_serial_port_num_show(struct f_serial_opts *opts, char *page)
+static ssize_t f_serial_port_num_show(struct config_item *item, char *page)
 {
-   return sprintf(page, "%u\n", opts->port_num);
+   return sprintf(page, "%u\n", to_f_serial_opts(item)->port_num);
 }
 
-static struct f_serial_opts_attribute f_serial_port_num =
-   __CONFIGFS_ATTR_RO(port_num, f_serial_port_num_show);
+CONFIGFS_ATTR_RO(f_serial_, port_num);
 
 static struct configfs_attribute *acm_attrs[] = {
-   _serial_port_num.attr,
+   _serial_attr_port_num,
NULL,
 };
 
-- 
1.9.1

--
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


[PATCH 14/23] usb-gadget/f_obex: use per-attribute show and store methods

2015-10-03 Thread Christoph Hellwig
To simplify the configfs interface and remove boilerplate code that also
causes binary bloat.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Andrzej Pietrasiewicz 
---
 drivers/usb/gadget/function/f_obex.c | 26 --
 1 file changed, 4 insertions(+), 22 deletions(-)

diff --git a/drivers/usb/gadget/function/f_obex.c 
b/drivers/usb/gadget/function/f_obex.c
index 5460426..f6f1e6b 100644
--- a/drivers/usb/gadget/function/f_obex.c
+++ b/drivers/usb/gadget/function/f_obex.c
@@ -395,22 +395,6 @@ static inline struct f_serial_opts 
*to_f_serial_opts(struct config_item *item)
func_inst.group);
 }
 
-CONFIGFS_ATTR_STRUCT(f_serial_opts);
-static ssize_t f_obex_attr_show(struct config_item *item,
-   struct configfs_attribute *attr,
-   char *page)
-{
-   struct f_serial_opts *opts = to_f_serial_opts(item);
-   struct f_serial_opts_attribute *f_serial_opts_attr =
-   container_of(attr, struct f_serial_opts_attribute, attr);
-   ssize_t ret = 0;
-
-   if (f_serial_opts_attr->show)
-   ret = f_serial_opts_attr->show(opts, page);
-
-   return ret;
-}
-
 static void obex_attr_release(struct config_item *item)
 {
struct f_serial_opts *opts = to_f_serial_opts(item);
@@ -420,19 +404,17 @@ static void obex_attr_release(struct config_item *item)
 
 static struct configfs_item_operations obex_item_ops = {
.release= obex_attr_release,
-   .show_attribute = f_obex_attr_show,
 };
 
-static ssize_t f_obex_port_num_show(struct f_serial_opts *opts, char *page)
+static ssize_t f_obex_port_num_show(struct config_item *item, char *page)
 {
-   return sprintf(page, "%u\n", opts->port_num);
+   return sprintf(page, "%u\n", to_f_serial_opts(item)->port_num);
 }
 
-static struct f_serial_opts_attribute f_obex_port_num =
-   __CONFIGFS_ATTR_RO(port_num, f_obex_port_num_show);
+CONFIGFS_ATTR_RO(f_obex_, port_num);
 
 static struct configfs_attribute *acm_attrs[] = {
-   _obex_port_num.attr,
+   _obex_attr_port_num,
NULL,
 };
 
-- 
1.9.1

--
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


[PATCH 01/23] configfs: add show and store methods to struct configfs_attribute

2015-10-03 Thread Christoph Hellwig
Add methods to struct configfs_attribute to directly show and store
attributes without adding boilerplate code to every user.  In addition
to the methods this also adds 3 helper macros to define read/write,
read-only and write-only attributes with a single line of code.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Nicholas Bellinger 
Acked-by: Greg Kroah-Hartman 
---
 fs/configfs/file.c   | 17 -
 include/linux/configfs.h | 27 +++
 2 files changed, 39 insertions(+), 5 deletions(-)

diff --git a/fs/configfs/file.c b/fs/configfs/file.c
index 403269f..106ca58 100644
--- a/fs/configfs/file.c
+++ b/fs/configfs/file.c
@@ -74,7 +74,11 @@ static int fill_read_buffer(struct dentry * dentry, struct 
configfs_buffer * buf
if (!buffer->page)
return -ENOMEM;
 
-   count = ops->show_attribute(item,attr,buffer->page);
+   if (ops->show_attribute)
+   count = ops->show_attribute(item, attr, buffer->page);
+   else
+   count = attr->show(item, buffer->page);
+
buffer->needs_read_fill = 0;
BUG_ON(count > (ssize_t)SIMPLE_ATTR_SIZE);
if (count >= 0)
@@ -173,7 +177,9 @@ flush_write_buffer(struct dentry * dentry, struct 
configfs_buffer * buffer, size
struct config_item * item = to_item(dentry->d_parent);
struct configfs_item_operations * ops = buffer->ops;
 
-   return ops->store_attribute(item,attr,buffer->page,count);
+   if (ops->store_attribute)
+   return ops->store_attribute(item, attr, buffer->page, count);
+   return attr->store(item, buffer->page, count);
 }
 
 
@@ -237,8 +243,8 @@ static int check_perm(struct inode * inode, struct file * 
file)
 * and we must have a store method.
 */
if (file->f_mode & FMODE_WRITE) {
-
-   if (!(inode->i_mode & S_IWUGO) || !ops->store_attribute)
+   if (!(inode->i_mode & S_IWUGO) ||
+   (!ops->store_attribute && !attr->store))
goto Eaccess;
 
}
@@ -248,7 +254,8 @@ static int check_perm(struct inode * inode, struct file * 
file)
 * must be a show method for it.
 */
if (file->f_mode & FMODE_READ) {
-   if (!(inode->i_mode & S_IRUGO) || !ops->show_attribute)
+   if (!(inode->i_mode & S_IRUGO) ||
+   (!ops->show_attribute && !attr->show))
goto Eaccess;
}
 
diff --git a/include/linux/configfs.h b/include/linux/configfs.h
index 63a36e8..85e9956 100644
--- a/include/linux/configfs.h
+++ b/include/linux/configfs.h
@@ -125,8 +125,35 @@ struct configfs_attribute {
const char  *ca_name;
struct module   *ca_owner;
umode_t ca_mode;
+   ssize_t (*show)(struct config_item *, char *);
+   ssize_t (*store)(struct config_item *, const char *, size_t);
 };
 
+#define CONFIGFS_ATTR(_pfx, _name) \
+static struct configfs_attribute _pfx##attr_##_name = {\
+   .ca_name= __stringify(_name),   \
+   .ca_mode= S_IRUGO | S_IWUSR,\
+   .ca_owner   = THIS_MODULE,  \
+   .show   = _pfx##_name##_show,   \
+   .store  = _pfx##_name##_store,  \
+}
+
+#define CONFIGFS_ATTR_RO(_pfx, _name)  \
+static struct configfs_attribute _pfx##attr_##_name = {\
+   .ca_name= __stringify(_name),   \
+   .ca_mode= S_IRUGO,  \
+   .ca_owner   = THIS_MODULE,  \
+   .show   = _pfx##_name##_show,   \
+}
+
+#define CONFIGFS_ATTR_WO(_pfx, _name)  \
+static struct configfs_attribute _pfx##attr_##_name = {\
+   .ca_name= __stringify(_name),   \
+   .ca_mode= S_IWUSR,  \
+   .ca_owner   = THIS_MODULE,  \
+   .store  = _pfx##_name##_store,  \
+}
+
 /*
  * Users often need to create attribute structures for their configurable
  * attributes, containing a configfs_attribute member and function pointers
-- 
1.9.1

--
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


simplify configfs attributes V2

2015-10-03 Thread Christoph Hellwig
This series consolidates the code to implement configfs attributes
by providing the ->show and ->store method in common code and using
container_of in the methods to access the containing structure.

This reduces source and binary size of configfs consumers a lot.

Changes since V1:
 - a couple fixes for unintended changes in the uvc driver
 - moved a few CONFIG_ATTR() statements around
 - fixed up the documentation and samples in the last patch
 - added a little rather pointless blurb to the patch description for
   various patches

--
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


[PATCH 04/23] usb-gadget/f_hid: use per-attribute show and store methods

2015-10-03 Thread Christoph Hellwig
To simplify the configfs interface and remove boilerplate code that also
causes binary bloat.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Andrzej Pietrasiewicz 
---
 drivers/usb/gadget/function/f_hid.c | 34 ++
 1 file changed, 14 insertions(+), 20 deletions(-)

diff --git a/drivers/usb/gadget/function/f_hid.c 
b/drivers/usb/gadget/function/f_hid.c
index 6df9715..d15b061 100644
--- a/drivers/usb/gadget/function/f_hid.c
+++ b/drivers/usb/gadget/function/f_hid.c
@@ -713,9 +713,6 @@ static inline struct f_hid_opts *to_f_hid_opts(struct 
config_item *item)
func_inst.group);
 }
 
-CONFIGFS_ATTR_STRUCT(f_hid_opts);
-CONFIGFS_ATTR_OPS(f_hid_opts);
-
 static void hid_attr_release(struct config_item *item)
 {
struct f_hid_opts *opts = to_f_hid_opts(item);
@@ -725,13 +722,12 @@ static void hid_attr_release(struct config_item *item)
 
 static struct configfs_item_operations hidg_item_ops = {
.release= hid_attr_release,
-   .show_attribute = f_hid_opts_attr_show,
-   .store_attribute = f_hid_opts_attr_store,
 };
 
 #define F_HID_OPT(name, prec, limit)   \
-static ssize_t f_hid_opts_##name##_show(struct f_hid_opts *opts, char *page)\
+static ssize_t f_hid_opts_##name##_show(struct config_item *item, char *page)\
 {  \
+   struct f_hid_opts *opts = to_f_hid_opts(item);  \
int result; \
\
mutex_lock(>lock);\
@@ -741,9 +737,10 @@ static ssize_t f_hid_opts_##name##_show(struct f_hid_opts 
*opts, char *page)\
return result;  \
 }  \
\
-static ssize_t f_hid_opts_##name##_store(struct f_hid_opts *opts,  \
+static ssize_t f_hid_opts_##name##_store(struct config_item *item, \
 const char *page, size_t len)  \
 {  \
+   struct f_hid_opts *opts = to_f_hid_opts(item);  \
int ret;\
u##prec num;\
\
@@ -769,16 +766,15 @@ end:  
\
return ret; \
 }  \
\
-static struct f_hid_opts_attribute f_hid_opts_##name = \
-   __CONFIGFS_ATTR(name, S_IRUGO | S_IWUSR, f_hid_opts_##name##_show,\
-   f_hid_opts_##name##_store)
+CONFIGFS_ATTR(f_hid_opts_, name)
 
 F_HID_OPT(subclass, 8, 255);
 F_HID_OPT(protocol, 8, 255);
 F_HID_OPT(report_length, 16, 65535);
 
-static ssize_t f_hid_opts_report_desc_show(struct f_hid_opts *opts, char *page)
+static ssize_t f_hid_opts_report_desc_show(struct config_item *item, char 
*page)
 {
+   struct f_hid_opts *opts = to_f_hid_opts(item);
int result;
 
mutex_lock(>lock);
@@ -789,9 +785,10 @@ static ssize_t f_hid_opts_report_desc_show(struct 
f_hid_opts *opts, char *page)
return result;
 }
 
-static ssize_t f_hid_opts_report_desc_store(struct f_hid_opts *opts,
+static ssize_t f_hid_opts_report_desc_store(struct config_item *item,
const char *page, size_t len)
 {
+   struct f_hid_opts *opts = to_f_hid_opts(item);
int ret = -EBUSY;
char *d;
 
@@ -818,16 +815,13 @@ end:
return ret;
 }
 
-static struct f_hid_opts_attribute f_hid_opts_report_desc =
-   __CONFIGFS_ATTR(report_desc, S_IRUGO | S_IWUSR,
-   f_hid_opts_report_desc_show,
-   f_hid_opts_report_desc_store);
+CONFIGFS_ATTR(f_hid_opts_, report_desc);
 
 static struct configfs_attribute *hid_attrs[] = {
-   _hid_opts_subclass.attr,
-   _hid_opts_protocol.attr,
-   _hid_opts_report_length.attr,
-   _hid_opts_report_desc.attr,
+   _hid_opts_attr_subclass,
+   _hid_opts_attr_protocol,
+   _hid_opts_attr_report_length,
+   _hid_opts_attr_report_desc,
NULL,
 };
 
-- 
1.9.1

--
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


[PATCH 06/23] usb-gadget/ether: use per-attribute show and store methods

2015-10-03 Thread Christoph Hellwig
To simplify the configfs interface and remove boilerplate code that also
causes binary bloat.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Andrzej Pietrasiewicz 
---
 drivers/usb/gadget/function/f_ecm.c|  8 ++---
 drivers/usb/gadget/function/f_eem.c|  8 ++---
 drivers/usb/gadget/function/f_ncm.c|  8 ++---
 drivers/usb/gadget/function/f_rndis.c  |  8 ++---
 drivers/usb/gadget/function/f_subset.c |  8 ++---
 drivers/usb/gadget/function/u_ether_configfs.h | 44 +++---
 6 files changed, 38 insertions(+), 46 deletions(-)

diff --git a/drivers/usb/gadget/function/f_ecm.c 
b/drivers/usb/gadget/function/f_ecm.c
index 7b7424f..0106de8 100644
--- a/drivers/usb/gadget/function/f_ecm.c
+++ b/drivers/usb/gadget/function/f_ecm.c
@@ -855,10 +855,10 @@ USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(ecm);
 USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(ecm);
 
 static struct configfs_attribute *ecm_attrs[] = {
-   _ecm_opts_dev_addr.attr,
-   _ecm_opts_host_addr.attr,
-   _ecm_opts_qmult.attr,
-   _ecm_opts_ifname.attr,
+   _opts_attr_dev_addr,
+   _opts_attr_host_addr,
+   _opts_attr_qmult,
+   _opts_attr_ifname,
NULL,
 };
 
diff --git a/drivers/usb/gadget/function/f_eem.c 
b/drivers/usb/gadget/function/f_eem.c
index c9e90de..f965403 100644
--- a/drivers/usb/gadget/function/f_eem.c
+++ b/drivers/usb/gadget/function/f_eem.c
@@ -555,10 +555,10 @@ USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(eem);
 USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(eem);
 
 static struct configfs_attribute *eem_attrs[] = {
-   _eem_opts_dev_addr.attr,
-   _eem_opts_host_addr.attr,
-   _eem_opts_qmult.attr,
-   _eem_opts_ifname.attr,
+   _opts_attr_dev_addr,
+   _opts_attr_host_addr,
+   _opts_attr_qmult,
+   _opts_attr_ifname,
NULL,
 };
 
diff --git a/drivers/usb/gadget/function/f_ncm.c 
b/drivers/usb/gadget/function/f_ncm.c
index 3f05c6bd..01a99e5 100644
--- a/drivers/usb/gadget/function/f_ncm.c
+++ b/drivers/usb/gadget/function/f_ncm.c
@@ -1503,10 +1503,10 @@ USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(ncm);
 USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(ncm);
 
 static struct configfs_attribute *ncm_attrs[] = {
-   _ncm_opts_dev_addr.attr,
-   _ncm_opts_host_addr.attr,
-   _ncm_opts_qmult.attr,
-   _ncm_opts_ifname.attr,
+   _opts_attr_dev_addr,
+   _opts_attr_host_addr,
+   _opts_attr_qmult,
+   _opts_attr_ifname,
NULL,
 };
 
diff --git a/drivers/usb/gadget/function/f_rndis.c 
b/drivers/usb/gadget/function/f_rndis.c
index 32985da..a04b526 100644
--- a/drivers/usb/gadget/function/f_rndis.c
+++ b/drivers/usb/gadget/function/f_rndis.c
@@ -878,10 +878,10 @@ USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(rndis);
 USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(rndis);
 
 static struct configfs_attribute *rndis_attrs[] = {
-   _rndis_opts_dev_addr.attr,
-   _rndis_opts_host_addr.attr,
-   _rndis_opts_qmult.attr,
-   _rndis_opts_ifname.attr,
+   _opts_attr_dev_addr,
+   _opts_attr_host_addr,
+   _opts_attr_qmult,
+   _opts_attr_ifname,
NULL,
 };
 
diff --git a/drivers/usb/gadget/function/f_subset.c 
b/drivers/usb/gadget/function/f_subset.c
index e3dfa67..055e4ea 100644
--- a/drivers/usb/gadget/function/f_subset.c
+++ b/drivers/usb/gadget/function/f_subset.c
@@ -413,10 +413,10 @@ USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(gether);
 USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(gether);
 
 static struct configfs_attribute *gether_attrs[] = {
-   _gether_opts_dev_addr.attr,
-   _gether_opts_host_addr.attr,
-   _gether_opts_qmult.attr,
-   _gether_opts_ifname.attr,
+   _opts_attr_dev_addr,
+   _opts_attr_host_addr,
+   _opts_attr_qmult,
+   _opts_attr_ifname,
NULL,
 };
 
diff --git a/drivers/usb/gadget/function/u_ether_configfs.h 
b/drivers/usb/gadget/function/u_ether_configfs.h
index bcbd301..4f47289 100644
--- a/drivers/usb/gadget/function/u_ether_configfs.h
+++ b/drivers/usb/gadget/function/u_ether_configfs.h
@@ -17,9 +17,6 @@
 #define __U_ETHER_CONFIGFS_H
 
 #define USB_ETHERNET_CONFIGFS_ITEM(_f_)
\
-   CONFIGFS_ATTR_STRUCT(f_##_f_##_opts);   \
-   CONFIGFS_ATTR_OPS(f_##_f_##_opts);  \
-   \
static void _f_##_attr_release(struct config_item *item)\
{   \
struct f_##_f_##_opts *opts = to_f_##_f_##_opts(item);  \
@@ -29,14 +26,13 @@
\
static struct configfs_item_operations _f_##_item_ops = {   \
.release= _f_##_attr_release,   \
-   .show_attribute = f_##_f_##_opts_attr_show, \
-   .store_attribute 

[PATCH v2 3/5] net: dsa: complete dsa_switch_destroy

2015-10-03 Thread Neil Armstrong
When unbinding dsa, complete the dsa_switch_destroy to unregister the
fixed link phy then cleanly unregister and destroy the net devices.

Signed-off-by: Neil Armstrong 
---
 net/dsa/dsa.c | 36 
 1 file changed, 36 insertions(+)

diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 91918a3..f937f7a 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "dsa_priv.h"

 char dsa_driver_version[] = "0.1";
@@ -420,10 +421,45 @@ dsa_switch_setup(struct dsa_switch_tree *dst, int index,

 static void dsa_switch_destroy(struct dsa_switch *ds)
 {
+   struct device_node *port_dn;
+   struct phy_device *phydev;
+   struct dsa_chip_data *cd = ds->pd;
+   int port;
+
 #ifdef CONFIG_NET_DSA_HWMON
if (ds->hwmon_dev)
hwmon_device_unregister(ds->hwmon_dev);
 #endif
+
+   /* Disable configuration of the CPU and DSA ports */
+   for (port = 0; port < DSA_MAX_PORTS; port++) {
+   if (!(dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port)))
+   continue;
+
+   port_dn = cd->port_dn[port];
+   if (of_phy_is_fixed_link(port_dn)) {
+   phydev = of_phy_find_device(port_dn);
+   if (phydev) {
+   int addr = phydev->addr;
+   phy_device_free(phydev);
+   of_node_put(port_dn);
+   fixed_phy_del(addr);
+   }
+   }
+   }
+
+   /* Destroy network devices for physical switch ports. */
+   for (port = 0; port < DSA_MAX_PORTS; port++) {
+   if (!(ds->phys_port_mask & (1 << port)))
+   continue;
+
+   if (!ds->ports[port])
+   continue;
+
+   unregister_netdev(ds->ports[port]);
+   free_netdev(ds->ports[port]);
+   }
+
mdiobus_unregister(ds->slave_mii_bus);
mdiobus_free(ds->slave_mii_bus);
 }
-- 
1.9.1

--
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


[PATCH v2 0/5] net: dsa: complete and fix the dsa unbinding

2015-10-03 Thread Neil Armstrong
In order to cleanly unbind the dsa core, either as a module removal,
or a platform device unbind, switch the allocation the their devm_
counterparts and complete the destroy functions.

First, the missing kfree were added, the remove function were
completed then kfree were removed in favor to devm_ calls.

The last patch is an way to cleanly exit the probe when no
switch is found in the discover process.

The patches are based on the current net.

Neil Armstrong (5):
  net: dsa: add missing kfree on remove
  net: dsa: add missing dsa_switch mdiobus remove
  net: dsa: complete dsa_switch_destroy
  net: dsa: switch to devm_ calls and remove kfree calls
  net: dsa: exit probe if no switch were found

 net/dsa/dsa.c | 67 +--
 1 file changed, 56 insertions(+), 11 deletions(-)

-- 
1.9.1

--
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


Re: [PATCH v2 1/5] net: dsa: add missing kfree on remove

2015-10-03 Thread Neil Armstrong
On 10/03/2015 04:33 PM, Sergei Shtylyov wrote:
> Hello.
> 
> On 10/3/2015 5:25 PM, Neil Armstrong wrote:
> 
>> To prevent memory leakage on unbinding, add missing kfree calls.
>>
>> Signed-off-by: Neil Armstrong 
>> ---
>>   net/dsa/dsa.c | 5 -
>>   1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
>> index c59fa5d..12cec40 100644
>> --- a/net/dsa/dsa.c
>> +++ b/net/dsa/dsa.c
>> @@ -914,8 +914,10 @@ static void dsa_remove_dst(struct dsa_switch_tree *dst)
>>   for (i = 0; i < dst->pd->nr_chips; i++) {
>>   struct dsa_switch *ds = dst->ds[i];
>>
>> -if (ds != NULL)
>> +if (ds != NULL) {
> 
>Didn;t scripts/checkpatch.pl complain here? just if (ds) is preferred in 
> the networking code.
> 
> MBR, Sergei
> 
Yes,

But I considered the cosmetic changes are not the subject of this serie.

Neil
--
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


[PATCH 10/15] nouveau: don't call pci_dma_supported

2015-10-03 Thread Christoph Hellwig
Just try to set a 64-bit DMA mask first and retry with the smaller dma_mask
if dma_set_mask failed.

Signed-off-by: Christoph Hellwig 
---
 drivers/gpu/drm/nouveau/nouveau_ttm.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c 
b/drivers/gpu/drm/nouveau/nouveau_ttm.c
index 3f0fb55..bb030e6 100644
--- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
@@ -350,11 +350,14 @@ nouveau_ttm_init(struct nouveau_drm *drm)
 
bits = nvxx_mmu(>device)->dma_bits;
if (nvxx_device(>device)->func->pci) {
-   if (drm->agp.bridge ||
-!pci_dma_supported(dev->pdev, DMA_BIT_MASK(bits)))
+   if (drm->agp.bridge)
bits = 32;
 
ret = pci_set_dma_mask(dev->pdev, DMA_BIT_MASK(bits));
+   if (ret && bits != 32) {
+   bits = 32;
+   ret = pci_set_dma_mask(dev->pdev, DMA_BIT_MASK(bits));
+   }
if (ret)
return ret;
 
-- 
1.9.1

--
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


[PATCH 13/15] usbnet: remove ifdefed out call to dma_supported

2015-10-03 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig 
---
 drivers/net/usb/usbnet.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index b4cf107..9497d51 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -1661,12 +1661,6 @@ usbnet_probe (struct usb_interface *udev, const struct 
usb_device_id *prod)
 * bind() should set rx_urb_size in that case.
 */
dev->hard_mtu = net->mtu + net->hard_header_len;
-#if 0
-// dma_supported() is deeply broken on almost all architectures
-   // possible with some EHCI controllers
-   if (dma_supported (>dev, DMA_BIT_MASK(64)))
-   net->features |= NETIF_F_HIGHDMA;
-#endif
 
net->netdev_ops = _netdev_ops;
net->watchdog_timeo = TX_TIMEOUT_JIFFIES;
-- 
1.9.1

--
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


[PATCH 08/15] netup_unidvb: use pci_set_dma_mask insted of pci_dma_supported

2015-10-03 Thread Christoph Hellwig
This ensures the dma mask that is supported by the driver is recorded
in the device structure.

Signed-off-by: Christoph Hellwig 
---
 drivers/media/pci/netup_unidvb/netup_unidvb_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/netup_unidvb/netup_unidvb_core.c 
b/drivers/media/pci/netup_unidvb/netup_unidvb_core.c
index 6d8bf627..511144f 100644
--- a/drivers/media/pci/netup_unidvb/netup_unidvb_core.c
+++ b/drivers/media/pci/netup_unidvb/netup_unidvb_core.c
@@ -809,7 +809,7 @@ static int netup_unidvb_initdev(struct pci_dev *pci_dev,
"%s(): board vendor 0x%x, revision 0x%x\n",
__func__, board_vendor, board_revision);
pci_set_master(pci_dev);
-   if (!pci_dma_supported(pci_dev, 0x)) {
+   if (!pci_set_dma_mask(pci_dev, 0x)) {
dev_err(_dev->dev,
"%s(): 32bit PCI DMA is not supported\n", __func__);
goto pci_detect_err;
-- 
1.9.1

--
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


[PATCH 11/15] sfc: don't call dma_supported

2015-10-03 Thread Christoph Hellwig
dma_set_mask already checks for a supported DMA mask before updating it,
the call to dma_supported is redundant.

Signed-off-by: Christoph Hellwig 
---
 drivers/net/ethernet/sfc/efx.c | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c
index 974637d..4abe886 100644
--- a/drivers/net/ethernet/sfc/efx.c
+++ b/drivers/net/ethernet/sfc/efx.c
@@ -1247,11 +1247,9 @@ static int efx_init_io(struct efx_nic *efx)
 * masks event though they reject 46 bit masks.
 */
while (dma_mask > 0x7fffUL) {
-   if (dma_supported(_dev->dev, dma_mask)) {
-   rc = dma_set_mask_and_coherent(_dev->dev, dma_mask);
-   if (rc == 0)
-   break;
-   }
+   rc = dma_set_mask_and_coherent(_dev->dev, dma_mask);
+   if (rc == 0)
+   break;
dma_mask >>= 1;
}
if (rc) {
-- 
1.9.1

--
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


[PATCH 07/15] cx23885: use pci_set_dma_mask insted of pci_dma_supported

2015-10-03 Thread Christoph Hellwig
This ensures the dma mask that is supported by the driver is recorded
in the device structure.

Signed-off-by: Christoph Hellwig 
---
 drivers/media/pci/cx23885/cx23885-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/cx23885/cx23885-core.c 
b/drivers/media/pci/cx23885/cx23885-core.c
index 7aee76a..8194052 100644
--- a/drivers/media/pci/cx23885/cx23885-core.c
+++ b/drivers/media/pci/cx23885/cx23885-core.c
@@ -1990,7 +1990,7 @@ static int cx23885_initdev(struct pci_dev *pci_dev,
(unsigned long long)pci_resource_start(pci_dev, 0));
 
pci_set_master(pci_dev);
-   if (!pci_dma_supported(pci_dev, 0x)) {
+   if (!pci_set_dma_mask(pci_dev, 0x)) {
printk("%s/0: Oops: no 32bit PCI DMA ???\n", dev->name);
err = -EIO;
goto fail_context;
-- 
1.9.1

--
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


[PATCH 12/15] kaweth: remove ifdefed out call to dma_supported

2015-10-03 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig 
---
 drivers/net/usb/kaweth.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/drivers/net/usb/kaweth.c b/drivers/net/usb/kaweth.c
index 1e9cdca..f64b25c 100644
--- a/drivers/net/usb/kaweth.c
+++ b/drivers/net/usb/kaweth.c
@@ -1177,12 +1177,6 @@ err_fw:
INIT_DELAYED_WORK(>lowmem_work, kaweth_resubmit_tl);
usb_set_intfdata(intf, kaweth);
 
-#if 0
-// dma_supported() is deeply broken on almost all architectures
-   if (dma_supported (dev, 0xULL))
-   kaweth->net->features |= NETIF_F_HIGHDMA;
-#endif
-
SET_NETDEV_DEV(netdev, dev);
if (register_netdev(netdev) != 0) {
dev_err(dev, "Error registering netdev.\n");
-- 
1.9.1

--
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


[PATCH 09/15] mpsc: use dma_set_mask insted of dma_supported

2015-10-03 Thread Christoph Hellwig
This ensures the dma mask that is supported by the driver is recorded
in the device structure.

Signed-off-by: Christoph Hellwig 
---
 drivers/tty/serial/mpsc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/mpsc.c b/drivers/tty/serial/mpsc.c
index 82bb6d1..11e084e 100644
--- a/drivers/tty/serial/mpsc.c
+++ b/drivers/tty/serial/mpsc.c
@@ -755,7 +755,7 @@ static int mpsc_alloc_ring_mem(struct mpsc_port_info *pi)
pi->port.line);
 
if (!pi->dma_region) {
-   if (!dma_supported(pi->port.dev, 0x)) {
+   if (!dma_set_mask(pi->port.dev, 0x)) {
printk(KERN_ERR "MPSC: Inadequate DMA support\n");
rc = -ENXIO;
} else if ((pi->dma_region = dma_alloc_noncoherent(pi->port.dev,
-- 
1.9.1

--
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


[PATCH 06/15] cx25821: use pci_set_dma_mask insted of pci_dma_supported

2015-10-03 Thread Christoph Hellwig
This ensures the dma mask that is supported by the driver is recorded
in the device structure.

Signed-off-by: Christoph Hellwig 
---
 drivers/media/pci/cx25821/cx25821-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/cx25821/cx25821-core.c 
b/drivers/media/pci/cx25821/cx25821-core.c
index 559f829..dbc695f 100644
--- a/drivers/media/pci/cx25821/cx25821-core.c
+++ b/drivers/media/pci/cx25821/cx25821-core.c
@@ -1319,7 +1319,7 @@ static int cx25821_initdev(struct pci_dev *pci_dev,
dev->pci_lat, (unsigned long long)dev->base_io_addr);
 
pci_set_master(pci_dev);
-   if (!pci_dma_supported(pci_dev, 0x)) {
+   if (!pci_set_dma_mask(pci_dev, 0x)) {
pr_err("%s/0: Oops: no 32bit PCI DMA ???\n", dev->name);
err = -EIO;
goto fail_irq;
-- 
1.9.1

--
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


Re: [PATCH net-next 00/17] tcp/dccp: lockless listener

2015-10-03 Thread David Miller
From: Eric Dumazet 
Date: Fri,  2 Oct 2015 11:43:22 -0700

> TCP listener refactoring : this is becoming interesting !
> 
> This patch series takes the steps to use normal TCP/DCCP ehash
> table to store SYN_RECV requests, instead of the private per-listener
> hash table we had until now.
> 
> SYNACK skb are now attached to their syn_recv request socket,
> so that we no longer heavily modify listener sk_wmem_alloc.
> 
> listener lock is no longer held in fast path, including
> SYNCOOKIE mode.
> 
> During my tests, my server was able to process 3,500,000
> SYN packets per second on one listener and still had available
> cpu cycles.
> 
> That is about 2 to 3 order of magnitude what we had with older kernels.
> 
> This effort started two years ago and I am pleased to reach expectations.
> 
> We'll probably extend SO_REUSEPORT to add proper cpu/numa affinities,
> so that heavy duty TCP servers can get proper siloing thanks to multi-queues
> NIC.

This looks amazing, series applied, thanks Eric!
--
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


Re: [patch net-next v2 0/6] switchdev: bring back switchdev_obj

2015-10-03 Thread David Miller
From: Jiri Pirko 
Date: Thu,  1 Oct 2015 11:03:40 +0200

> Second version of the patch extends to a patchset. Basically this patchset
> brings object structure back which disappeared with recent Vivien's patchset.
> Also it does a bit of naming changes in order to get the things in line.
> Also, object id is put back into object structure.
> Thanks to Scott and Vivien for review and suggestions.

Series applied, thanks Jiri.
--
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


Re: [PATCH v2 1/3] unix: fix use-after-free in unix_dgram_poll()

2015-10-03 Thread Rainer Weikusat
Mathias Krause  writes:
> On 2 October 2015 at 22:43, Jason Baron  wrote:
>> The unix_dgram_poll() routine calls sock_poll_wait() not only for the wait
>> queue associated with the socket s that we are poll'ing against, but also 
>> calls

[useless full-quote removed]

> My reproducer runs on this patch for more than 3 days now without
> triggering anything anymore.

Since the behaviour of your program is random, using it to "test"
anything doesn't really provide any insight: It could have been
executing the same codepath which doesn't happen to trigger any problems
for all of these three days. Nobody can tell.
--
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


Re: [PATCH v2 3/5] net: dsa: complete dsa_switch_destroy

2015-10-03 Thread Florian Fainelli
Le 03/10/2015 07:26, Neil Armstrong a écrit :
> When unbinding dsa, complete the dsa_switch_destroy to unregister the
> fixed link phy then cleanly unregister and destroy the net devices.
> 
> Signed-off-by: Neil Armstrong 
> ---

[snip]

> + port_dn = cd->port_dn[port];
> + if (of_phy_is_fixed_link(port_dn)) {
> + phydev = of_phy_find_device(port_dn);
> + if (phydev) {
> + int addr = phydev->addr;
> + phy_device_free(phydev);
> + of_node_put(port_dn);
> + fixed_phy_del(addr);

fixed_phy_del() removes the fixed PHY from the platform fixed MDIO bus
list of PHYs, so we should be okay even with switch drivers which
register a link_update callback via fixed_phy_set_link_update(), but I
have not checked that. The sequence of call looks (phy_device_free then
fixed_phy_del) looks sane though.

Eventually this logic might be better moved into net/dsa/slave.c such
that it is easy to see how it balances dsa_slave_phy_setup().

Reviewed-by: Florian Fainelli 
-- 
Florian
--
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


Re: 4.3-rc3: `telnet ::1 ' hangs in SYN-SENT

2015-10-03 Thread Andreas Schwab
Ok, that is already fixed by 31b33df.

Andreas.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."
--
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


[PATCH] net: dsa: mv88e6xxx: remove link polling

2015-10-03 Thread Russell King
The link status is polled by the generic phy layer, there's no need to
duplicate that polling with additional polling.  This additional polling
adds additional MDIO traffic, and races with the generic phy layer,
resulting in missing or duplicated link status messages.

Tested-by: Andrew Lunn 
Signed-off-by: Russell King 
---
 drivers/net/dsa/mv88e6123_61_65.c |  1 -
 drivers/net/dsa/mv88e6131.c   |  1 -
 drivers/net/dsa/mv88e6171.c   |  1 -
 drivers/net/dsa/mv88e6352.c   |  1 -
 drivers/net/dsa/mv88e6xxx.c   | 67 ---
 drivers/net/dsa/mv88e6xxx.h   |  1 -
 6 files changed, 72 deletions(-)

diff --git a/drivers/net/dsa/mv88e6123_61_65.c 
b/drivers/net/dsa/mv88e6123_61_65.c
index 3de2a6d73fdc..4bcfd683bbea 100644
--- a/drivers/net/dsa/mv88e6123_61_65.c
+++ b/drivers/net/dsa/mv88e6123_61_65.c
@@ -125,7 +125,6 @@ struct dsa_switch_driver mv88e6123_61_65_switch_driver = {
.set_addr   = mv88e6xxx_set_addr_indirect,
.phy_read   = mv88e6xxx_phy_read,
.phy_write  = mv88e6xxx_phy_write,
-   .poll_link  = mv88e6xxx_poll_link,
.get_strings= mv88e6xxx_get_strings,
.get_ethtool_stats  = mv88e6xxx_get_ethtool_stats,
.get_sset_count = mv88e6xxx_get_sset_count,
diff --git a/drivers/net/dsa/mv88e6131.c b/drivers/net/dsa/mv88e6131.c
index 3e8386529965..c73121c8f155 100644
--- a/drivers/net/dsa/mv88e6131.c
+++ b/drivers/net/dsa/mv88e6131.c
@@ -178,7 +178,6 @@ struct dsa_switch_driver mv88e6131_switch_driver = {
.set_addr   = mv88e6xxx_set_addr_direct,
.phy_read   = mv88e6131_phy_read,
.phy_write  = mv88e6131_phy_write,
-   .poll_link  = mv88e6xxx_poll_link,
.get_strings= mv88e6xxx_get_strings,
.get_ethtool_stats  = mv88e6xxx_get_ethtool_stats,
.get_sset_count = mv88e6xxx_get_sset_count,
diff --git a/drivers/net/dsa/mv88e6171.c b/drivers/net/dsa/mv88e6171.c
index c2daaf087761..c95cfab56a4f 100644
--- a/drivers/net/dsa/mv88e6171.c
+++ b/drivers/net/dsa/mv88e6171.c
@@ -104,7 +104,6 @@ struct dsa_switch_driver mv88e6171_switch_driver = {
.set_addr   = mv88e6xxx_set_addr_indirect,
.phy_read   = mv88e6xxx_phy_read_indirect,
.phy_write  = mv88e6xxx_phy_write_indirect,
-   .poll_link  = mv88e6xxx_poll_link,
.get_strings= mv88e6xxx_get_strings,
.get_ethtool_stats  = mv88e6xxx_get_ethtool_stats,
.get_sset_count = mv88e6xxx_get_sset_count,
diff --git a/drivers/net/dsa/mv88e6352.c b/drivers/net/dsa/mv88e6352.c
index 1f5129c105fb..37367060676f 100644
--- a/drivers/net/dsa/mv88e6352.c
+++ b/drivers/net/dsa/mv88e6352.c
@@ -324,7 +324,6 @@ struct dsa_switch_driver mv88e6352_switch_driver = {
.set_addr   = mv88e6xxx_set_addr_indirect,
.phy_read   = mv88e6xxx_phy_read_indirect,
.phy_write  = mv88e6xxx_phy_write_indirect,
-   .poll_link  = mv88e6xxx_poll_link,
.get_strings= mv88e6xxx_get_strings,
.get_ethtool_stats  = mv88e6xxx_get_ethtool_stats,
.get_sset_count = mv88e6xxx_get_sset_count,
diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
index f8baa897d1a0..c6683f65b125 100644
--- a/drivers/net/dsa/mv88e6xxx.c
+++ b/drivers/net/dsa/mv88e6xxx.c
@@ -388,73 +388,6 @@ int mv88e6xxx_phy_write_ppu(struct dsa_switch *ds, int 
addr,
 }
 #endif
 
-void mv88e6xxx_poll_link(struct dsa_switch *ds)
-{
-   int i;
-
-   for (i = 0; i < DSA_MAX_PORTS; i++) {
-   struct net_device *dev;
-   int uninitialized_var(port_status);
-   int pcs_ctrl;
-   int link;
-   int speed;
-   int duplex;
-   int fc;
-
-   dev = ds->ports[i];
-   if (dev == NULL)
-   continue;
-
-   pcs_ctrl = mv88e6xxx_reg_read(ds, REG_PORT(i), PORT_PCS_CTRL);
-   if (pcs_ctrl < 0 || pcs_ctrl & PORT_PCS_CTRL_FORCE_LINK)
-   continue;
-
-   link = 0;
-   if (dev->flags & IFF_UP) {
-   port_status = mv88e6xxx_reg_read(ds, REG_PORT(i),
-PORT_STATUS);
-   if (port_status < 0)
-   continue;
-
-   link = !!(port_status & PORT_STATUS_LINK);
-   }
-
-   if (!link) {
-   if (netif_carrier_ok(dev)) {
-   netdev_info(dev, "link down\n");
-   netif_carrier_off(dev);
-   }
-   continue;
-   }
-
-   

[PATCH] net: dsa: better error reporting

2015-10-03 Thread Russell King
Add additional error reporting to the generic DSA code, so it's easier
to debug when things go wrong.  This was useful when initially bringing
up 88e6176 on a new board.

Signed-off-by: Russell King 
---
 net/dsa/dsa.c   |  4 ++--
 net/dsa/slave.c | 24 
 2 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index c59fa5d9c22c..aa398bcef9e3 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -326,8 +326,8 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, 
struct device *parent)
 
ret = dsa_slave_create(ds, parent, i, pd->port_names[i]);
if (ret < 0) {
-   netdev_err(dst->master_netdev, "[%d]: can't create dsa 
slave device for port %d(%s)\n",
-  index, i, pd->port_names[i]);
+   netdev_err(dst->master_netdev, "[%d]: can't create dsa 
slave device for port %d(%s): %d\n",
+  index, i, pd->port_names[i], ret);
ret = 0;
}
}
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index cce97385f743..115a3fda36b3 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -1010,8 +1010,10 @@ static int dsa_slave_phy_connect(struct dsa_slave_priv 
*p,
struct dsa_switch *ds = p->parent;
 
p->phy = ds->slave_mii_bus->phy_map[addr];
-   if (!p->phy)
+   if (!p->phy) {
+   netdev_err(slave_dev, "no phy at %d\n", addr);
return -ENODEV;
+   }
 
/* Use already configured phy mode */
if (p->phy_interface == PHY_INTERFACE_MODE_NA)
@@ -1045,7 +1047,7 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p,
 */
ret = of_phy_register_fixed_link(port_dn);
if (ret) {
-   netdev_err(slave_dev, "failed to register fixed PHY\n");
+   netdev_err(slave_dev, "failed to register fixed PHY: 
%d\n", ret);
return ret;
}
phy_is_fixed = true;
@@ -1056,17 +1058,20 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p,
phy_flags = ds->drv->get_phy_flags(ds, p->port);
 
if (phy_dn) {
-   ret = of_mdio_parse_addr(_dev->dev, phy_dn);
+   int phy_id = of_mdio_parse_addr(_dev->dev, phy_dn);
+
/* If this PHY address is part of phys_mii_mask, which means
 * that we need to divert reads and writes to/from it, then we
 * want to bind this device using the slave MII bus created by
 * DSA to make that happen.
 */
-   if (!phy_is_fixed && ret >= 0 &&
-   (ds->phys_mii_mask & (1 << ret))) {
-   ret = dsa_slave_phy_connect(p, slave_dev, ret);
-   if (ret)
+   if (!phy_is_fixed && phy_id >= 0 &&
+   (ds->phys_mii_mask & (1 << phy_id))) {
+   ret = dsa_slave_phy_connect(p, slave_dev, phy_id);
+   if (ret) {
+   netdev_err(slave_dev, "failed to connect to 
phy%d: %d\n", phy_id, ret);
return ret;
+   }
} else {
p->phy = of_phy_connect(slave_dev, phy_dn,
dsa_slave_adjust_link,
@@ -1083,8 +1088,10 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p,
 */
if (!p->phy) {
ret = dsa_slave_phy_connect(p, slave_dev, p->port);
-   if (ret)
+   if (ret) {
+   netdev_err(slave_dev, "failed to connect to port %d: 
%d\n", p->port, ret);
return ret;
+   }
} else {
netdev_info(slave_dev, "attached PHY at address %d [%s]\n",
p->phy->addr, p->phy->drv->name);
@@ -1195,6 +1202,7 @@ int dsa_slave_create(struct dsa_switch *ds, struct device 
*parent,
 
ret = dsa_slave_phy_setup(p, slave_dev);
if (ret) {
+   netdev_err(master, "error %d setting up slave phy\n", ret);
free_netdev(slave_dev);
return ret;
}
-- 
2.1.0

--
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


[patch - Nicholas's tree] netconsole: Missing unlock on error path

2015-10-03 Thread Dan Carpenter
We added new locking to this function but we missed one error path which
needs an unlock.

Fixes: cdacad4993f4 ('netconsole: use per-attribute show and store methods')
Signed-off-by: Dan Carpenter 
---
This is going through Nicholas Bellinger's tree not net-next.

diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index 8783169..06ee639 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -535,7 +535,7 @@ static ssize_t remote_ip_store(struct config_item *item, 
const char *buf,
if (in6_pton(buf, count, nt->np.remote_ip.in6.s6_addr, -1, 
) > 0) {
if (*end && *end != '\n') {
pr_err("invalid IPv6 address at: <%c>\n", *end);
-   return -EINVAL;
+   goto out_unlock;
}
nt->np.ipv6 = true;
} else
--
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


Re: [PATCH] net: dsa: better error reporting

2015-10-03 Thread Andrew Lunn
On Sat, Oct 03, 2015 at 06:09:07PM +0100, Russell King wrote:
> Add additional error reporting to the generic DSA code, so it's easier
> to debug when things go wrong.  This was useful when initially bringing
> up 88e6176 on a new board.
> 
> Signed-off-by: Russell King 

Reviewed-by: Andrew Lunn 

Thanks
Andrew

> ---
>  net/dsa/dsa.c   |  4 ++--
>  net/dsa/slave.c | 24 
>  2 files changed, 18 insertions(+), 10 deletions(-)
> 
> diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
> index c59fa5d9c22c..aa398bcef9e3 100644
> --- a/net/dsa/dsa.c
> +++ b/net/dsa/dsa.c
> @@ -326,8 +326,8 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, 
> struct device *parent)
>  
>   ret = dsa_slave_create(ds, parent, i, pd->port_names[i]);
>   if (ret < 0) {
> - netdev_err(dst->master_netdev, "[%d]: can't create dsa 
> slave device for port %d(%s)\n",
> -index, i, pd->port_names[i]);
> + netdev_err(dst->master_netdev, "[%d]: can't create dsa 
> slave device for port %d(%s): %d\n",
> +index, i, pd->port_names[i], ret);
>   ret = 0;
>   }
>   }
> diff --git a/net/dsa/slave.c b/net/dsa/slave.c
> index cce97385f743..115a3fda36b3 100644
> --- a/net/dsa/slave.c
> +++ b/net/dsa/slave.c
> @@ -1010,8 +1010,10 @@ static int dsa_slave_phy_connect(struct dsa_slave_priv 
> *p,
>   struct dsa_switch *ds = p->parent;
>  
>   p->phy = ds->slave_mii_bus->phy_map[addr];
> - if (!p->phy)
> + if (!p->phy) {
> + netdev_err(slave_dev, "no phy at %d\n", addr);
>   return -ENODEV;
> + }
>  
>   /* Use already configured phy mode */
>   if (p->phy_interface == PHY_INTERFACE_MODE_NA)
> @@ -1045,7 +1047,7 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p,
>*/
>   ret = of_phy_register_fixed_link(port_dn);
>   if (ret) {
> - netdev_err(slave_dev, "failed to register fixed PHY\n");
> + netdev_err(slave_dev, "failed to register fixed PHY: 
> %d\n", ret);
>   return ret;
>   }
>   phy_is_fixed = true;
> @@ -1056,17 +1058,20 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv 
> *p,
>   phy_flags = ds->drv->get_phy_flags(ds, p->port);
>  
>   if (phy_dn) {
> - ret = of_mdio_parse_addr(_dev->dev, phy_dn);
> + int phy_id = of_mdio_parse_addr(_dev->dev, phy_dn);
> +
>   /* If this PHY address is part of phys_mii_mask, which means
>* that we need to divert reads and writes to/from it, then we
>* want to bind this device using the slave MII bus created by
>* DSA to make that happen.
>*/
> - if (!phy_is_fixed && ret >= 0 &&
> - (ds->phys_mii_mask & (1 << ret))) {
> - ret = dsa_slave_phy_connect(p, slave_dev, ret);
> - if (ret)
> + if (!phy_is_fixed && phy_id >= 0 &&
> + (ds->phys_mii_mask & (1 << phy_id))) {
> + ret = dsa_slave_phy_connect(p, slave_dev, phy_id);
> + if (ret) {
> + netdev_err(slave_dev, "failed to connect to 
> phy%d: %d\n", phy_id, ret);
>   return ret;
> + }
>   } else {
>   p->phy = of_phy_connect(slave_dev, phy_dn,
>   dsa_slave_adjust_link,
> @@ -1083,8 +1088,10 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv 
> *p,
>*/
>   if (!p->phy) {
>   ret = dsa_slave_phy_connect(p, slave_dev, p->port);
> - if (ret)
> + if (ret) {
> + netdev_err(slave_dev, "failed to connect to port %d: 
> %d\n", p->port, ret);
>   return ret;
> + }
>   } else {
>   netdev_info(slave_dev, "attached PHY at address %d [%s]\n",
>   p->phy->addr, p->phy->drv->name);
> @@ -1195,6 +1202,7 @@ int dsa_slave_create(struct dsa_switch *ds, struct 
> device *parent,
>  
>   ret = dsa_slave_phy_setup(p, slave_dev);
>   if (ret) {
> + netdev_err(master, "error %d setting up slave phy\n", ret);
>   free_netdev(slave_dev);
>   return ret;
>   }
> -- 
> 2.1.0
> 
--
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


[PATCH net-next] net: Add support for filtering neigh dump by device index

2015-10-03 Thread David Ahern
Add support for filtering neighbor dumps by device by adding the
NDA_IFINDEX attribute to the dump request. When set the kernel only
sends neighbor entries for the given device.

Signed-off-by: David Ahern 
---
 net/core/neighbour.c | 17 +++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index 8c57fdf4d68e..f7786eaef613 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -2249,6 +2249,14 @@ static bool neigh_master_filtered(struct net_device 
*dev, int master_idx)
return false;
 }
 
+static bool neigh_ifindex_filtered(struct net_device *dev, int filter_idx)
+{
+   if (filter_idx && dev->ifindex != filter_idx)
+   return true;
+
+   return false;
+}
+
 static int neigh_dump_table(struct neigh_table *tbl, struct sk_buff *skb,
struct netlink_callback *cb)
 {
@@ -2259,16 +2267,19 @@ static int neigh_dump_table(struct neigh_table *tbl, 
struct sk_buff *skb,
int rc, h, s_h = cb->args[1];
int idx, s_idx = idx = cb->args[2];
struct neigh_hash_table *nht;
-   int filter_master_idx = 0;
+   int filter_master_idx = 0, filter_idx = 0;
unsigned int flags = NLM_F_MULTI;
int err;
 
err = nlmsg_parse(nlh, sizeof(struct ndmsg), tb, NDA_MAX, NULL);
if (!err) {
+   if (tb[NDA_IFINDEX])
+   filter_idx = nla_get_u32(tb[NDA_IFINDEX]);
+
if (tb[NDA_MASTER])
filter_master_idx = nla_get_u32(tb[NDA_MASTER]);
 
-   if (filter_master_idx)
+   if (filter_idx | filter_master_idx)
flags |= NLM_F_DUMP_FILTERED;
}
 
@@ -2283,6 +2294,8 @@ static int neigh_dump_table(struct neigh_table *tbl, 
struct sk_buff *skb,
 n = rcu_dereference_bh(n->next)) {
if (!net_eq(dev_net(n->dev), net))
continue;
+   if (neigh_ifindex_filtered(n->dev, filter_idx))
+   continue;
if (neigh_master_filtered(n->dev, filter_master_idx))
continue;
if (idx < s_idx)
-- 
1.9.1

--
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


Re: [PATCH net-next] tcp/dccp: add SLAB_DESTROY_BY_RCU flag for request sockets

2015-10-03 Thread David Miller
From: Eric Dumazet 
Date: Sat, 03 Oct 2015 06:27:28 -0700

> From: Eric Dumazet 
> 
> Before letting request sockets being put in TCP/DCCP regular
> ehash table, we need to add either :
> 
> - SLAB_DESTROY_BY_RCU flag to their kmem_cache
> - add RCU grace period before freeing them.
> 
> Since we carefully respected the SLAB_DESTROY_BY_RCU protocol
> like ESTABLISH and TIMEWAIT sockets, use it here.
> 
> req_prot_init() being only used by TCP and DCCP, I did not add
> a new slab_flags into their rsk_prot, but reuse prot->slab_flags
> 
> Since all reqsk_alloc() users are correctly dealing with a failure,
> add the __GFP_NOWARN flag to avoid traces under pressure.
> 
> Fixes: 079096f103fa ("tcp/dccp: install syn_recv requests into ehash table")
> Signed-off-by: Eric Dumazet 

Applied, thanks Eric.
--
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


Re: [PATCH] Bluetooth: hci_smd: Qualcomm WCNSS HCI driver

2015-10-03 Thread Marcel Holtmann
Hi Bjorn,

>>> The Qualcomm WCNSS chip provides two SMD channels to the BT core; one
>>> for command and one for event packets. This driver exposes the two
>>> channels as a hci device.
>>> 
> [..]
>>> diff --git a/drivers/bluetooth/Makefile b/drivers/bluetooth/Makefile
>>> index 07c9cf381e5a..43c7dc8641ff 100644
>>> --- a/drivers/bluetooth/Makefile
>>> +++ b/drivers/bluetooth/Makefile
>>> @@ -14,6 +14,7 @@ obj-$(CONFIG_BT_HCIBTUART)+= btuart_cs.o
>>> 
>>> obj-$(CONFIG_BT_HCIBTUSB)   += btusb.o
>>> obj-$(CONFIG_BT_HCIBTSDIO)  += btsdio.o
>>> +obj-$(CONFIG_BT_HCISMD)+= hci_smd.o
>> 
>> I wonder if choosing a name like btqcomsmd.ko would not be better
>> here. For now I am fine with keeping hci_smd.ko since there are other
>> issues here to be fixed first.
> 
> I had some problems figuring out the naming scheme here, but btqcomsmd
> does seem reasonable, I'll update it in the next set.
> 
>> Especially the kbuild test robot complained loudly.
>> 
> 
> Sorry, I forgot to mention in the patch that the patch depends on the
> qcom_smd_id patch - that's available in linux-next. I will take another
> look, but I think that was the cause of all the issues.

which means, I can only merge this driver when this other patch has hit 
net-next tree. Unless I take the qcom_smd_id through bluetooth-next tree which 
doesn't look like a good idea.

>>> obj-$(CONFIG_BT_INTEL)  += btintel.o
>>> obj-$(CONFIG_BT_ATH3K)  += ath3k.o
>>> diff --git a/drivers/bluetooth/hci_smd.c b/drivers/bluetooth/hci_smd.c
> [..]
>>> +#include 
>> 
>> The hci.h include is not needed. If you do, then you are doing
>> something fishy.
>> 
> 
> Nothing fishy going on here, so I'll drop it.
> 
>>> +
>>> +static struct {
>>> +   struct qcom_smd_channel *acl_channel;
>>> +   struct qcom_smd_channel *cmd_channel;
>>> +
>>> +   struct hci_dev *hci;
>>> +} smd_hci;
>> 
>> A driver that only supports a single instance of a device and uses a
>> global variable to do so is not a good idea. There should be no reason
>> for this. Why is this done this way.
>> 
> 
> There's two channels coming up, each probing the associated driver that
> combines these into 1 hci device.
> 
> So I have two options;
> 
> * the original idea was to implement multi-channel-per-device support in
>  SMD, but as this is the only known case where that's needed I really
>  don't want to add all the extra complexity to SMD.
> 
> * I can accept the fact that this is silicon inside the MSM SoC and
>  should never exist in more than one instance and make this hack. The
>  first version I implemented had this structure allocated on the first
>  probe, but that didn't really add any value to the static struct.
> 
> I picked the second option due to the fact that the patch to SMD was way
> bigger then this patch, and full of nasty logic.

Writing a driver that assume it is a single instance of a given device is never 
a good idea. While you might find some instances in the kernel if you look hard 
enough, but that doesn't mean we should keep doing this. So this needs 
addressing.

> 
>>> +
>>> +static int smd_hci_recv(unsigned type, const void *data, size_t count)
>>> +{
>>> +   struct sk_buff *skb;
>>> +   void *buf;
>>> +   int ret;
>>> +
>>> +   skb = bt_skb_alloc(count, GFP_ATOMIC);
>> 
>> Is it required that this is GFP_ATOMIC or can this actually be
>> GFP_KERNEL?
>> 
> 
> This is being called from IRQ context upon receiving data on the
> channels.

I wonder why that is needed, but seems an issue in the SMD subsystem. So this 
is fine, might want to add a comment above the bt_skb_alloc to remind us.

> 
>>> +   if (!skb)
>>> +   return -ENOMEM;
>>> +
>>> +   buf = skb_put(skb, count);
>>> +   memcpy_fromio(buf, data, count);
>> 
>> Why is this a memcpy_fromio here?
>> 
> 
> A memcpy here doesn't seem to work on ARM64, probably because the
> pointer references ioremapped memory. We are discussing either marking
> the data __iomem or perhaps using memremap rather then ioremap.

I would add a comment here as well to remind everybody why this is used. And 
marking up the pointers is a good idea as well.

>>> +
>>> +   skb->dev = (void *)smd_hci.hci;
>> 
>> This is no longer needed.
>> 
> 
> Thanks
> 
>>> +   bt_cb(skb)->pkt_type = type;
>>> +   skb_orphan(skb);
>>> +
>>> +   ret = hci_recv_frame(smd_hci.hci, skb);
>>> +   if (ret < 0)
>>> +   kfree_skb(skb);
>> 
>> This is a double kfree_skb here. The hci_recv_frame will consume the
>> skb no matter what.
>> 
> 
> Thanks
> 
>>> +
>>> +   return ret;
>>> +}
>>> +
> [..]
>>> +
>>> +static int smd_hci_send(struct hci_dev *hdev, struct sk_buff *skb)
>>> +{
>>> +   int ret;
>>> +
>>> +   switch (bt_cb(skb)->pkt_type) {
>>> +   case HCI_ACLDATA_PKT:
>>> +   case HCI_SCODATA_PKT:
>>> +   ret = qcom_smd_send(smd_hci.acl_channel, skb->data, skb->len);
>>> +   break;
>>> +   case HCI_COMMAND_PKT:
>>> +   ret = qcom_smd_send(smd_hci.cmd_channel, skb->data, skb->len);

[PATCH net-next v2] net: Add support for filtering neigh dump by device index

2015-10-03 Thread David Ahern
Add support for filtering neighbor dumps by device by adding the
NDA_IFINDEX attribute to the dump request.

Signed-off-by: David Ahern 
---
v2
- fix or on the index as noticed by Eagle-Eye Nikolay

 net/core/neighbour.c | 17 +++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index 8c57fdf4d68e..f7786eaef613 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -2249,6 +2249,14 @@ static bool neigh_master_filtered(struct net_device 
*dev, int master_idx)
return false;
 }
 
+static bool neigh_ifindex_filtered(struct net_device *dev, int filter_idx)
+{
+   if (filter_idx && dev->ifindex != filter_idx)
+   return true;
+
+   return false;
+}
+
 static int neigh_dump_table(struct neigh_table *tbl, struct sk_buff *skb,
struct netlink_callback *cb)
 {
@@ -2259,16 +2267,19 @@ static int neigh_dump_table(struct neigh_table *tbl, 
struct sk_buff *skb,
int rc, h, s_h = cb->args[1];
int idx, s_idx = idx = cb->args[2];
struct neigh_hash_table *nht;
-   int filter_master_idx = 0;
+   int filter_master_idx = 0, filter_idx = 0;
unsigned int flags = NLM_F_MULTI;
int err;
 
err = nlmsg_parse(nlh, sizeof(struct ndmsg), tb, NDA_MAX, NULL);
if (!err) {
+   if (tb[NDA_IFINDEX])
+   filter_idx = nla_get_u32(tb[NDA_IFINDEX]);
+
if (tb[NDA_MASTER])
filter_master_idx = nla_get_u32(tb[NDA_MASTER]);
 
-   if (filter_master_idx)
+   if (filter_idx || filter_master_idx)
flags |= NLM_F_DUMP_FILTERED;
}
 
@@ -2283,6 +2294,8 @@ static int neigh_dump_table(struct neigh_table *tbl, 
struct sk_buff *skb,
 n = rcu_dereference_bh(n->next)) {
if (!net_eq(dev_net(n->dev), net))
continue;
+   if (neigh_ifindex_filtered(n->dev, filter_idx))
+   continue;
if (neigh_master_filtered(n->dev, filter_master_idx))
continue;
if (idx < s_idx)
-- 
1.9.1

--
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


Re: [patch - Nicholas's tree] netconsole: Missing unlock on error path

2015-10-03 Thread kbuild test robot
Hi Dan,

[auto build test results on v4.3-rc3 -- if it's inappropriate base, please 
ignore]

config: x86_64-allmodconfig (attached as .config)
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 

All error/warnings (new ones prefixed by >>):

   drivers/net/netconsole.c:507:33: sparse: label 'out_unlock' was not declared
   drivers/net/netconsole.c: In function 'store_remote_ip':
>> drivers/net/netconsole.c:507:5: error: label 'out_unlock' used but not 
>> defined
goto out_unlock;
^

sparse warnings: (new ones prefixed by >>)

>> drivers/net/netconsole.c:507:33: sparse: label 'out_unlock' was not declared
   drivers/net/netconsole.c: In function 'store_remote_ip':
   drivers/net/netconsole.c:507:5: error: label 'out_unlock' used but not 
defined
goto out_unlock;
^

vim +/out_unlock +507 drivers/net/netconsole.c

   501  
   502  if (strnchr(buf, count, ':')) {
   503  const char *end;
   504  if (in6_pton(buf, count, nt->np.remote_ip.in6.s6_addr, 
-1, ) > 0) {
   505  if (*end && *end != '\n') {
   506  pr_err("invalid IPv6 address at: 
<%c>\n", *end);
 > 507  goto out_unlock;
   508  }
   509  nt->np.ipv6 = true;
   510  } else

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data


Re: [PATCH 05/15] cx88: use pci_set_dma_mask insted of pci_dma_supported

2015-10-03 Thread Mauro Carvalho Chehab
Hi Christoph,


Em Sat,  3 Oct 2015 17:19:29 +0200
Christoph Hellwig  escreveu:

> This ensures the dma mask that is supported by the driver is recorded
> in the device structure.


For this and the other patches touching at drivers/media:

Acked-by: Mauro Carvalho Chehab 

> 
> Signed-off-by: Christoph Hellwig 
> ---
>  drivers/media/pci/cx88/cx88-alsa.c  | 2 +-
>  drivers/media/pci/cx88/cx88-mpeg.c  | 2 +-
>  drivers/media/pci/cx88/cx88-video.c | 2 +-
>  3 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/media/pci/cx88/cx88-alsa.c 
> b/drivers/media/pci/cx88/cx88-alsa.c
> index 7f8dc60..0703a81 100644
> --- a/drivers/media/pci/cx88/cx88-alsa.c
> +++ b/drivers/media/pci/cx88/cx88-alsa.c
> @@ -890,7 +890,7 @@ static int snd_cx88_create(struct snd_card *card, struct 
> pci_dev *pci,
>   return err;
>   }
>  
> - if (!pci_dma_supported(pci,DMA_BIT_MASK(32))) {
> + if (!pci_set_dma_mask(pci,DMA_BIT_MASK(32))) {
>   dprintk(0, "%s/1: Oops: no 32bit PCI DMA ???\n",core->name);
>   err = -EIO;
>   cx88_core_put(core, pci);
> diff --git a/drivers/media/pci/cx88/cx88-mpeg.c 
> b/drivers/media/pci/cx88/cx88-mpeg.c
> index 34f5057..9b3b565 100644
> --- a/drivers/media/pci/cx88/cx88-mpeg.c
> +++ b/drivers/media/pci/cx88/cx88-mpeg.c
> @@ -393,7 +393,7 @@ static int cx8802_init_common(struct cx8802_dev *dev)
>   if (pci_enable_device(dev->pci))
>   return -EIO;
>   pci_set_master(dev->pci);
> - if (!pci_dma_supported(dev->pci,DMA_BIT_MASK(32))) {
> + if (!pci_set_dma_mask(dev->pci,DMA_BIT_MASK(32))) {
>   printk("%s/2: Oops: no 32bit PCI DMA ???\n",dev->core->name);
>   return -EIO;
>   }
> diff --git a/drivers/media/pci/cx88/cx88-video.c 
> b/drivers/media/pci/cx88/cx88-video.c
> index 400e5ca..f12af31 100644
> --- a/drivers/media/pci/cx88/cx88-video.c
> +++ b/drivers/media/pci/cx88/cx88-video.c
> @@ -1311,7 +1311,7 @@ static int cx8800_initdev(struct pci_dev *pci_dev,
>  dev->pci_lat,(unsigned long long)pci_resource_start(pci_dev,0));
>  
>   pci_set_master(pci_dev);
> - if (!pci_dma_supported(pci_dev,DMA_BIT_MASK(32))) {
> + if (!pci_set_dma_mask(pci_dev,DMA_BIT_MASK(32))) {
>   printk("%s/0: Oops: no 32bit PCI DMA ???\n",core->name);
>   err = -EIO;
>   goto fail_core;
--
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


Re: [PATCH net-next] net: Add support for filtering neigh dump by device index

2015-10-03 Thread Nikolay Aleksandrov
On 10/03/2015 08:25 PM, David Ahern wrote:
> Add support for filtering neighbor dumps by device by adding the
> NDA_IFINDEX attribute to the dump request. When set the kernel only
> sends neighbor entries for the given device.
> 
> Signed-off-by: David Ahern 
> ---
>  net/core/neighbour.c | 17 +++--
>  1 file changed, 15 insertions(+), 2 deletions(-)
> 
> diff --git a/net/core/neighbour.c b/net/core/neighbour.c
> index 8c57fdf4d68e..f7786eaef613 100644
> --- a/net/core/neighbour.c
> +++ b/net/core/neighbour.c
> @@ -2249,6 +2249,14 @@ static bool neigh_master_filtered(struct net_device 
> *dev, int master_idx)
>   return false;
>  }
>  
> +static bool neigh_ifindex_filtered(struct net_device *dev, int filter_idx)
> +{
> + if (filter_idx && dev->ifindex != filter_idx)
> + return true;
> +
> + return false;
> +}
> +
>  static int neigh_dump_table(struct neigh_table *tbl, struct sk_buff *skb,
>   struct netlink_callback *cb)
>  {
> @@ -2259,16 +2267,19 @@ static int neigh_dump_table(struct neigh_table *tbl, 
> struct sk_buff *skb,
>   int rc, h, s_h = cb->args[1];
>   int idx, s_idx = idx = cb->args[2];
>   struct neigh_hash_table *nht;
> - int filter_master_idx = 0;
> + int filter_master_idx = 0, filter_idx = 0;
>   unsigned int flags = NLM_F_MULTI;
>   int err;
>  
>   err = nlmsg_parse(nlh, sizeof(struct ndmsg), tb, NDA_MAX, NULL);
>   if (!err) {
> + if (tb[NDA_IFINDEX])
> + filter_idx = nla_get_u32(tb[NDA_IFINDEX]);
> +
>   if (tb[NDA_MASTER])
>   filter_master_idx = nla_get_u32(tb[NDA_MASTER]);
>  
> - if (filter_master_idx)
> + if (filter_idx | filter_master_idx)
|| ? :-)

>   flags |= NLM_F_DUMP_FILTERED;
>   }
>  
> @@ -2283,6 +2294,8 @@ static int neigh_dump_table(struct neigh_table *tbl, 
> struct sk_buff *skb,
>n = rcu_dereference_bh(n->next)) {
>   if (!net_eq(dev_net(n->dev), net))
>   continue;
> + if (neigh_ifindex_filtered(n->dev, filter_idx))
> + continue;
>   if (neigh_master_filtered(n->dev, filter_master_idx))
>   continue;
>   if (idx < s_idx)
> 

--
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


Re: Soft lockup issue in Linux 4.1.9

2015-10-03 Thread Thomas D.
Hi,

Holger Hoffstätte wrote:
> Greg, any chance you can drop this into the pending 4.1.10? Otherwise people
> will get another broken release.

For me it looks like the request was too late, the patch is not included
in 4.1.10. So don't forget to re-apply the patch when doing the upgrade.

Greg, do you need a dedicated inclusion request for
http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=83fccfc3940c4a2db90fd7e7079f5b465cd8c6af
in 4.1.x or is it already on your list?


-Thomas



--
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


Re: [PATCH] net/unix: fix logic about sk_peek_offset

2015-10-03 Thread Andrey Vagin
2015-10-02 15:17 GMT+03:00 Aaron Conole :
> Andrey Vagin  writes:
>
>> 2015-10-02 0:05 GMT+03:00 Andrey Vagin :
>>> From: Andrey Vagin 
>>>
>>> Now send with MSG_PEEK can return data from multiple SKBs.
>>>
>>> Unfortunately we take into account the peek offset for each skb,
>>> that is wrong. We need to apply the peek offset only once.
>>>
>>> In addition, the peek offset should be used only if MSG_PEEK is set.
> <>
> Agreed here, the behavior is off in the peek offset case.
>
> I was unable to apply your patch, for some reason, but will manually
> try to apply it and test.

It's strange. I've checked that this patch can be applied to
davem/net.git and next/linux-next.git,

[avagin@laptop linux-next]$ git checkout net/master
HEAD is now at 36f8daf... Merge tag 'mmc-v4.3-rc3' of
git://git.linaro.org/people/ulf.hansson/mmc
[avagin@laptop linux-next]$ wget https://patchwork.ozlabs.org/patch/525310/mbox/
--2015-10-03 22:46:44--  https://patchwork.ozlabs.org/patch/525310/mbox/
Resolving patchwork.ozlabs.org (patchwork.ozlabs.org)...
103.22.144.67, 2401:3900:2:1::2
Connecting to patchwork.ozlabs.org
(patchwork.ozlabs.org)|103.22.144.67|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/plain]
Saving to: ‘index.html’

index.html  [ <=>
  ]   2.06K
--.-KB/s   in 0s

2015-10-03 22:46:47 (122 MB/s) - ‘index.html’ saved [2106]

[avagin@laptop linux-next]$ git am index.html
Applying: net/unix: fix logic about sk_peek_offset

>
> Thanks very much!
--
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


Re: [PATCH v2 2/5] net: dsa: add missing dsa_switch mdiobus remove

2015-10-03 Thread Florian Fainelli
Le 03/10/2015 07:26, Neil Armstrong a écrit :
> To prevent memory leakage on unbinding, add missing mdiobus unregister
> and free calls.
> 
> Signed-off-by: Neil Armstrong 

Reviewed-by: Florian Fainelli 
-- 
Florian
--
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


Re: Slow ramp-up for single-stream TCP throughput on 4.2 kernel.

2015-10-03 Thread Neal Cardwell
On Fri, Oct 2, 2015 at 8:21 PM, Ben Greear  wrote:
> Gah, seems 'cubic' related.  That is the default tcp cong ctrl
> I was using (same in 3.17, for that matter).

There have been recent changes to CUBIC that may account for this. If
you could repeat your test with more instrumentation, eg "nstat", that
would be very helpful.

nstat > /dev/null
# run one test
nstat

Also, if you could take a sender-side tcpdump trace of the test, that
would be very useful (default capture length, grabbing just headers,
is fine).

Thanks!

neal
--
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


4.3-rc3: `telnet ::1 ' hangs in SYN-SENT

2015-10-03 Thread Andreas Schwab
Trying to connect to ::1 on any port (whether or not anything listens)
causes the connection to hang in SYN-SENT state.

Andreas.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."
--
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


Re: [PATCH] net: dsa: better error reporting

2015-10-03 Thread Florian Fainelli
Le 03/10/2015 10:09, Russell King a écrit :
> Add additional error reporting to the generic DSA code, so it's easier
> to debug when things go wrong.  This was useful when initially bringing
> up 88e6176 on a new board.
> 
> Signed-off-by: Russell King 
> ---

[snip]

>   } else {
>   netdev_info(slave_dev, "attached PHY at address %d [%s]\n",
>   p->phy->addr, p->phy->drv->name);
> @@ -1195,6 +1202,7 @@ int dsa_slave_create(struct dsa_switch *ds, struct 
> device *parent,
>  
>   ret = dsa_slave_phy_setup(p, slave_dev);
>   if (ret) {
> + netdev_err(master, "error %d setting up slave phy\n", ret);
>   free_netdev(slave_dev);
>   return ret;

All of these debug messages are going to happen prior to the slave
network device being registered, so you would get these error messages
to be printed with an extraneous " (unregistered)" which is fine, just a
tad annoying sometimes.

Acked-by: Florian Fainelli 
-- 
Florian
--
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


Re: [PATCH v2 5/5] net: dsa: exit probe if no switch were found

2015-10-03 Thread Florian Fainelli
Le 03/10/2015 07:26, Neil Armstrong a écrit :
> If no switch were found in dsa_setup_dst, return -ENODEV and
> exit the dsa_probe cleanly.
> 
> Tested-by: Andrew Lunn 
> Tested-by: Florian Fainelli 
> Signed-off-by: Neil Armstrong 
> ---

[snip]

>  static int dsa_probe(struct platform_device *pdev)
> @@ -926,9 +937,9 @@ static int dsa_probe(struct platform_device *pdev)
> 
>   platform_set_drvdata(pdev, dst);
> 
> - dsa_setup_dst(dst, dev, >dev, pd);
> -
> - return 0;
> + ret = dsa_setup_dst(dst, dev, >dev, pd);
> + if (!ret)
> + return 0;

That logic is a little weird, I would just go with something like this:

ret = dsa_setup_dst(ds, dev, >dev, pd);
if (ret)
goto out;

return 0;
-- 
Florian
--
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


Re: [PATCH v2 4/5] net: dsa: switch to devm_ calls and remove kfree calls

2015-10-03 Thread Florian Fainelli
Le 03/10/2015 07:26, Neil Armstrong a écrit :
> Now the kfree calls exists in the the remove functions, remove them in all
> places except the of_probe functions and replace allocation calls
> with their devm_ counterparts.
> 
> Signed-off-by: Neil Armstrong 

Reviewed-by: Florian Fainelli 
-- 
Florian
--
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


[net] i40e/i40evf: set AQ count after memory allocation

2015-10-03 Thread Jeff Kirsher
From: Mitch Williams 

The standard way to check if the AQ is enabled is to look at the
count field. So we should only set this field after we have
successfully allocated memory. To do otherwise is to incite
panic among the populace.

Signed-off-by: Mitch Williams 
Signed-off-by: Jeff Kirsher 
---
 drivers/net/ethernet/intel/i40e/i40e_adminq.c   | 4 ++--
 drivers/net/ethernet/intel/i40evf/i40e_adminq.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_adminq.c 
b/drivers/net/ethernet/intel/i40e/i40e_adminq.c
index 62488a6..c0e943a 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_adminq.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_adminq.c
@@ -386,7 +386,6 @@ static i40e_status i40e_init_asq(struct i40e_hw *hw)
 
hw->aq.asq.next_to_use = 0;
hw->aq.asq.next_to_clean = 0;
-   hw->aq.asq.count = hw->aq.num_asq_entries;
 
/* allocate the ring memory */
ret_code = i40e_alloc_adminq_asq_ring(hw);
@@ -404,6 +403,7 @@ static i40e_status i40e_init_asq(struct i40e_hw *hw)
goto init_adminq_free_rings;
 
/* success! */
+   hw->aq.asq.count = hw->aq.num_asq_entries;
goto init_adminq_exit;
 
 init_adminq_free_rings:
@@ -445,7 +445,6 @@ static i40e_status i40e_init_arq(struct i40e_hw *hw)
 
hw->aq.arq.next_to_use = 0;
hw->aq.arq.next_to_clean = 0;
-   hw->aq.arq.count = hw->aq.num_arq_entries;
 
/* allocate the ring memory */
ret_code = i40e_alloc_adminq_arq_ring(hw);
@@ -463,6 +462,7 @@ static i40e_status i40e_init_arq(struct i40e_hw *hw)
goto init_adminq_free_rings;
 
/* success! */
+   hw->aq.arq.count = hw->aq.num_arq_entries;
goto init_adminq_exit;
 
 init_adminq_free_rings:
diff --git a/drivers/net/ethernet/intel/i40evf/i40e_adminq.c 
b/drivers/net/ethernet/intel/i40evf/i40e_adminq.c
index 929d471..a23ebfd 100644
--- a/drivers/net/ethernet/intel/i40evf/i40e_adminq.c
+++ b/drivers/net/ethernet/intel/i40evf/i40e_adminq.c
@@ -373,7 +373,6 @@ static i40e_status i40e_init_asq(struct i40e_hw *hw)
 
hw->aq.asq.next_to_use = 0;
hw->aq.asq.next_to_clean = 0;
-   hw->aq.asq.count = hw->aq.num_asq_entries;
 
/* allocate the ring memory */
ret_code = i40e_alloc_adminq_asq_ring(hw);
@@ -391,6 +390,7 @@ static i40e_status i40e_init_asq(struct i40e_hw *hw)
goto init_adminq_free_rings;
 
/* success! */
+   hw->aq.asq.count = hw->aq.num_asq_entries;
goto init_adminq_exit;
 
 init_adminq_free_rings:
@@ -432,7 +432,6 @@ static i40e_status i40e_init_arq(struct i40e_hw *hw)
 
hw->aq.arq.next_to_use = 0;
hw->aq.arq.next_to_clean = 0;
-   hw->aq.arq.count = hw->aq.num_arq_entries;
 
/* allocate the ring memory */
ret_code = i40e_alloc_adminq_arq_ring(hw);
@@ -450,6 +449,7 @@ static i40e_status i40e_init_arq(struct i40e_hw *hw)
goto init_adminq_free_rings;
 
/* success! */
+   hw->aq.arq.count = hw->aq.num_arq_entries;
goto init_adminq_exit;
 
 init_adminq_free_rings:
-- 
2.4.3

--
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


Re: Slow ramp-up for single-stream TCP throughput on 4.2 kernel.

2015-10-03 Thread Ben Greear



On 10/03/2015 09:29 AM, Neal Cardwell wrote:

On Fri, Oct 2, 2015 at 8:21 PM, Ben Greear  wrote:

Gah, seems 'cubic' related.  That is the default tcp cong ctrl
I was using (same in 3.17, for that matter).


There have been recent changes to CUBIC that may account for this. If
you could repeat your test with more instrumentation, eg "nstat", that
would be very helpful.

nstat > /dev/null
# run one test
nstat

Also, if you could take a sender-side tcpdump trace of the test, that
would be very useful (default capture length, grabbing just headers,
is fine).


Here is nstat output:

[root@ben-ota-1 ~]# nstat
#kernel
IpInReceives14507  0.0
IpInDelivers14507  0.0
IpOutRequests   49531  0.0
TcpActiveOpens  3  0.0
TcpPassiveOpens 2  0.0
TcpInSegs   14498  0.0
TcpOutSegs  50269  0.0
UdpInDatagrams  9  0.0
UdpOutDatagrams 1  0.0
TcpExtDelayedACKs   43 0.0
TcpExtDelayedACKLost5  0.0
TcpExtTCPHPHits 4830.0
TcpExtTCPPureAcks   9180.0
TcpExtTCPHPAcks 12758  0.0
TcpExtTCPDSACKOldSent   5  0.0
TcpExtTCPRcvCoalesce49 0.0
TcpExtTCPAutoCorking3  0.0
TcpExtTCPOrigDataSent   49776  0.0
TcpExtTCPHystartTrainDetect 1  0.0
TcpExtTCPHystartTrainCwnd   16 0.0
IpExtInBcastPkts8  0.0
IpExtInOctets   29342740.0
IpExtOutOctets  74817312   0.0
IpExtInBcastOctets  6400.0
IpExtInNoECTPkts14911  0.0
[root@ben-ota-1 ~]#


And, you can find the pcap here:

http://www.candelatech.com/downloads/cubic.pcap.bz2

Let me know if you need anything else.

Thanks,
Ben

--
Ben Greear 
Candela Technologies Inc  http://www.candelatech.com
--
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


Re: [PATCH v2 1/5] net: dsa: add missing kfree on remove

2015-10-03 Thread Sergei Shtylyov

On 10/3/2015 6:20 PM, Neil Armstrong wrote:


On 10/3/2015 5:25 PM, Neil Armstrong wrote:


To prevent memory leakage on unbinding, add missing kfree calls.

Signed-off-by: Neil Armstrong 
---
   net/dsa/dsa.c | 5 -
   1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index c59fa5d..12cec40 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -914,8 +914,10 @@ static void dsa_remove_dst(struct dsa_switch_tree *dst)
   for (i = 0; i < dst->pd->nr_chips; i++) {
   struct dsa_switch *ds = dst->ds[i];

-if (ds != NULL)
+if (ds != NULL) {


Didn;t scripts/checkpatch.pl complain here? just if (ds) is preferred in 
the networking code.

MBR, Sergei


Yes,

But I considered the cosmetic changes are not the subject of this serie.


   Formally, all the patches should be checkpatch-clean...


Neil


MBR, Sergei

--
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


Re: Slow ramp-up for single-stream TCP throughput on 4.2 kernel.

2015-10-03 Thread Neal Cardwell
On Sat, Oct 3, 2015 at 6:46 PM, Ben Greear  wrote:
>
>
> On 10/03/2015 09:29 AM, Neal Cardwell wrote:
>>
>> On Fri, Oct 2, 2015 at 8:21 PM, Ben Greear 
>> wrote:
>>>
>>> Gah, seems 'cubic' related.  That is the default tcp cong ctrl
>>> I was using (same in 3.17, for that matter).
>>
>>
>> There have been recent changes to CUBIC that may account for this. If
>> you could repeat your test with more instrumentation, eg "nstat", that
>> would be very helpful.
>>
>> nstat > /dev/null
>> # run one test
>> nstat
>>
>> Also, if you could take a sender-side tcpdump trace of the test, that
>> would be very useful (default capture length, grabbing just headers,
>> is fine).
>
>
> Here is nstat output:
>
> [root@ben-ota-1 ~]# nstat
> #kernel
> IpInReceives14507  0.0
> IpInDelivers14507  0.0
> IpOutRequests   49531  0.0
> TcpActiveOpens  3  0.0
> TcpPassiveOpens 2  0.0
> TcpInSegs   14498  0.0
> TcpOutSegs  50269  0.0
> UdpInDatagrams  9  0.0
> UdpOutDatagrams 1  0.0
> TcpExtDelayedACKs   43 0.0
> TcpExtDelayedACKLost5  0.0
> TcpExtTCPHPHits 4830.0
> TcpExtTCPPureAcks   9180.0
> TcpExtTCPHPAcks 12758  0.0
> TcpExtTCPDSACKOldSent   5  0.0
> TcpExtTCPRcvCoalesce49 0.0
> TcpExtTCPAutoCorking3  0.0
> TcpExtTCPOrigDataSent   49776  0.0
> TcpExtTCPHystartTrainDetect 1  0.0
> TcpExtTCPHystartTrainCwnd   16 0.0
> IpExtInBcastPkts8  0.0
> IpExtInOctets   29342740.0
> IpExtOutOctets  74817312   0.0
> IpExtInBcastOctets  6400.0
> IpExtInNoECTPkts14911  0.0
> [root@ben-ota-1 ~]#
>
>
> And, you can find the pcap here:
>
> http://www.candelatech.com/downloads/cubic.pcap.bz2
>
> Let me know if you need anything else.

Thanks! This is very useful. It looks like the sender is sending 3
(and later 4) packets every ~1.5ms for the entirety of the trace. 3
packets per burst is usually a hint that this may be related to TSQ.

This slow-and-steady behavior triggers CUBIC's Hystart Train Detection
to enter congestion avoidance at a cwnd of 16, which probably in turn
leads to slow cwnd growth, since the sending is not cwnd-limited, but
probably TSQ-limited, so cwnd does not grow in congestion avoidance
mode. Probably most of the other congestion control modules do better
because they stay in slow-start, which has a more aggressive criterion
for growing cwnd.

So this is probably at root due to the known issue with an interaction
between the ath10k driver and the following change in 3.19:

  605ad7f tcp: refine TSO autosizing

There has been a lot of discussion about how to address the
TSQ-related issues with this driver. For example, you might consider:

  https://patchwork.ozlabs.org/patch/438322/

But I am not sure of the latest status of that effort. Perhaps someone
on the ath10k list will know.

neal
--
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


[net-next 3/5] i40e: Fix a memory leak in X722 rss config path

2015-10-03 Thread Jeff Kirsher
From: Anjali Singhai 

In any case free the memory allocated before exiting.

Reported-by: Dan Carpenter 
Signed-off-by: Anjali Singhai Jain 
Tested-by: Andrew Bowers 
Signed-off-by: Jeff Kirsher 
---
 drivers/net/ethernet/intel/i40e/i40e_main.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c 
b/drivers/net/ethernet/intel/i40e/i40e_main.c
index 4345fc5..5646ee8 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -7625,7 +7625,7 @@ static int i40e_config_rss_aq(struct i40e_vsi *vsi, const 
u8 *seed)
 "Cannot set RSS key, err %s aq_err %s\n",
 i40e_stat_str(>hw, ret),
 i40e_aq_str(>hw, pf->hw.aq.asq_last_status));
-   return ret;
+   goto config_rss_aq_out;
}
 
if (vsi->type == I40E_VSI_MAIN)
@@ -7639,6 +7639,8 @@ static int i40e_config_rss_aq(struct i40e_vsi *vsi, const 
u8 *seed)
 i40e_stat_str(>hw, ret),
 i40e_aq_str(>hw, pf->hw.aq.asq_last_status));
 
+config_rss_aq_out:
+   kfree(rss_lut);
return ret;
 }
 
-- 
2.4.3

--
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


[net-next 4/5] i40e/i40evf: grab the AQ spinlocks before clearing registers

2015-10-03 Thread Jeff Kirsher
From: Shannon Nelson 

Make sure we have the spinlocks before we clear the ARQ and ASQ management
registers.  Also, widen the locked portion and make a sanity check earlier
in the send function to be sure we're working with safe register values.

Change-ID: I34b56044b33461ed780f3d2de8d62826cdf933f9
Signed-off-by: Shannon Nelson 
Tested-by: Andrew Bowers 
Signed-off-by: Jeff Kirsher 
---
 drivers/net/ethernet/intel/i40e/i40e_adminq.c   | 45 +
 drivers/net/ethernet/intel/i40evf/i40e_adminq.c | 45 +
 2 files changed, 46 insertions(+), 44 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_adminq.c 
b/drivers/net/ethernet/intel/i40e/i40e_adminq.c
index e59ffb2..34a64e0 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_adminq.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_adminq.c
@@ -482,8 +482,12 @@ static i40e_status i40e_shutdown_asq(struct i40e_hw *hw)
 {
i40e_status ret_code = 0;
 
-   if (hw->aq.asq.count == 0)
-   return I40E_ERR_NOT_READY;
+   mutex_lock(>aq.asq_mutex);
+
+   if (hw->aq.asq.count == 0) {
+   ret_code = I40E_ERR_NOT_READY;
+   goto shutdown_asq_out;
+   }
 
/* Stop firmware AdminQ processing */
wr32(hw, hw->aq.asq.head, 0);
@@ -492,16 +496,13 @@ static i40e_status i40e_shutdown_asq(struct i40e_hw *hw)
wr32(hw, hw->aq.asq.bal, 0);
wr32(hw, hw->aq.asq.bah, 0);
 
-   /* make sure lock is available */
-   mutex_lock(>aq.asq_mutex);
-
hw->aq.asq.count = 0; /* to indicate uninitialized queue */
 
/* free ring buffers */
i40e_free_asq_bufs(hw);
 
+shutdown_asq_out:
mutex_unlock(>aq.asq_mutex);
-
return ret_code;
 }
 
@@ -515,8 +516,12 @@ static i40e_status i40e_shutdown_arq(struct i40e_hw *hw)
 {
i40e_status ret_code = 0;
 
-   if (hw->aq.arq.count == 0)
-   return I40E_ERR_NOT_READY;
+   mutex_lock(>aq.arq_mutex);
+
+   if (hw->aq.arq.count == 0) {
+   ret_code = I40E_ERR_NOT_READY;
+   goto shutdown_arq_out;
+   }
 
/* Stop firmware AdminQ processing */
wr32(hw, hw->aq.arq.head, 0);
@@ -525,16 +530,13 @@ static i40e_status i40e_shutdown_arq(struct i40e_hw *hw)
wr32(hw, hw->aq.arq.bal, 0);
wr32(hw, hw->aq.arq.bah, 0);
 
-   /* make sure lock is available */
-   mutex_lock(>aq.arq_mutex);
-
hw->aq.arq.count = 0; /* to indicate uninitialized queue */
 
/* free ring buffers */
i40e_free_arq_bufs(hw);
 
+shutdown_arq_out:
mutex_unlock(>aq.arq_mutex);
-
return ret_code;
 }
 
@@ -745,19 +747,21 @@ i40e_status i40e_asq_send_command(struct i40e_hw *hw,
u16  retval = 0;
u32  val = 0;
 
-   val = rd32(hw, hw->aq.asq.head);
-   if (val >= hw->aq.num_asq_entries) {
+   mutex_lock(>aq.asq_mutex);
+
+   if (hw->aq.asq.count == 0) {
i40e_debug(hw, I40E_DEBUG_AQ_MESSAGE,
-  "AQTX: head overrun at %d\n", val);
+  "AQTX: Admin queue not initialized.\n");
status = I40E_ERR_QUEUE_EMPTY;
-   goto asq_send_command_exit;
+   goto asq_send_command_error;
}
 
-   if (hw->aq.asq.count == 0) {
+   val = rd32(hw, hw->aq.asq.head);
+   if (val >= hw->aq.num_asq_entries) {
i40e_debug(hw, I40E_DEBUG_AQ_MESSAGE,
-  "AQTX: Admin queue not initialized.\n");
+  "AQTX: head overrun at %d\n", val);
status = I40E_ERR_QUEUE_EMPTY;
-   goto asq_send_command_exit;
+   goto asq_send_command_error;
}
 
details = I40E_ADMINQ_DETAILS(hw->aq.asq, hw->aq.asq.next_to_use);
@@ -782,8 +786,6 @@ i40e_status i40e_asq_send_command(struct i40e_hw *hw,
desc->flags &= ~cpu_to_le16(details->flags_dis);
desc->flags |= cpu_to_le16(details->flags_ena);
 
-   mutex_lock(>aq.asq_mutex);
-
if (buff_size > hw->aq.asq_buf_size) {
i40e_debug(hw,
   I40E_DEBUG_AQ_MESSAGE,
@@ -907,7 +909,6 @@ i40e_status i40e_asq_send_command(struct i40e_hw *hw,
 
 asq_send_command_error:
mutex_unlock(>aq.asq_mutex);
-asq_send_command_exit:
return status;
 }
 
diff --git a/drivers/net/ethernet/intel/i40evf/i40e_adminq.c 
b/drivers/net/ethernet/intel/i40evf/i40e_adminq.c
index 5026773..c7f59e0 100644
--- a/drivers/net/ethernet/intel/i40evf/i40e_adminq.c
+++ b/drivers/net/ethernet/intel/i40evf/i40e_adminq.c
@@ -469,8 +469,12 @@ static i40e_status i40e_shutdown_asq(struct i40e_hw *hw)
 {
i40e_status ret_code = 0;
 
-   if (hw->aq.asq.count == 0)
-   return I40E_ERR_NOT_READY;
+   mutex_lock(>aq.asq_mutex);
+
+   if (hw->aq.asq.count == 0) {
+   

[net-next 1/5] i40e: Use numa_mem_id() to better support memoryless node

2015-10-03 Thread Jeff Kirsher
From: Jiang Liu 

Function i40e_clean_rx_irq() tries to reuse memory pages allocated
from the nearest node. To better support memoryless node, use
numa_mem_id() instead of numa_node_id() to get the nearest node with
memory.

This change should only affect performance.

Signed-off-by: Jiang Liu 
Tested-by: Andrew Bowers 
Signed-off-by: Jeff Kirsher 
---
 drivers/net/ethernet/intel/i40e/i40e_txrx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.c 
b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
index 0d692dd..85e61b0 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_txrx.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
@@ -1443,7 +1443,7 @@ static int i40e_clean_rx_irq_ps(struct i40e_ring 
*rx_ring, int budget)
unsigned int total_rx_bytes = 0, total_rx_packets = 0;
u16 rx_packet_len, rx_header_len, rx_sph, rx_hbo;
u16 cleaned_count = I40E_DESC_UNUSED(rx_ring);
-   const int current_node = numa_node_id();
+   const int current_node = numa_mem_id();
struct i40e_vsi *vsi = rx_ring->vsi;
u16 i = rx_ring->next_to_clean;
union i40e_rx_desc *rx_desc;
-- 
2.4.3

--
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


[net-next 2/5] i40evf: Use numa_mem_id() to better support memoryless node

2015-10-03 Thread Jeff Kirsher
From: Jiang Liu 

Function i40e_clean_rx_irq() tries to reuse memory pages allocated
from the nearest node. To better support memoryless node, use
numa_mem_id() instead of numa_node_id() to get the nearest node with
memory.

This change should only affect performance.

Signed-off-by: Jiang Liu 
Tested-by: Andrew Bowers 
Signed-off-by: Jeff Kirsher 
---
 drivers/net/ethernet/intel/i40evf/i40e_txrx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/i40evf/i40e_txrx.c 
b/drivers/net/ethernet/intel/i40evf/i40e_txrx.c
index aaee89f..0e1a4d6 100644
--- a/drivers/net/ethernet/intel/i40evf/i40e_txrx.c
+++ b/drivers/net/ethernet/intel/i40evf/i40e_txrx.c
@@ -917,7 +917,7 @@ static int i40e_clean_rx_irq_ps(struct i40e_ring *rx_ring, 
int budget)
unsigned int total_rx_bytes = 0, total_rx_packets = 0;
u16 rx_packet_len, rx_header_len, rx_sph, rx_hbo;
u16 cleaned_count = I40E_DESC_UNUSED(rx_ring);
-   const int current_node = numa_node_id();
+   const int current_node = numa_mem_id();
struct i40e_vsi *vsi = rx_ring->vsi;
u16 i = rx_ring->next_to_clean;
union i40e_rx_desc *rx_desc;
-- 
2.4.3

--
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


[net-next 0/5][pull request] Intel Wired LAN Driver Updates 2015-10-03

2015-10-03 Thread Jeff Kirsher
This series contains updates to i40e and i40evf, some of which are to
resolve more Red Hat bugzilla issues.

Jiang Liu updates the i40e and i40evf drivers to use numa_mem_id()
instead of numa_node_id() to get the nearest node with memory which
better supports memoryless nodes.

Anjali fixes an issue from Dan Carpenter ,
to resolve a memory leak in X722 RSS configuration path, where we should
free the memory allocated before exiting.

Shannon modifies the drivers to ensure we have the spinlocks before we
clear the ARQ and ASQ management registers.  In addition, we widen the
locked portion insert a sanity check to ensure we are working with safe
register values.

Mitch fixes an issue where under certain circumstances, we can get an
extra VF_RESOURCES message from the PF driver at runtime.  When this
occurs, we need to parse it because our VSI may have changed and that
will affect the relationship with the PF driver.  But this parsing also
blows away our current MAC address, so resolve the issue by restoring
the current MAC address from the netdev struct after we parse the
resource message.

The following are changes since commit e96f78ab2703f3b0d512f6b469bc685d2ef20475:
  tcp/dccp: add SLAB_DESTROY_BY_RCU flag for request sockets
and are available in the git repository at:
  git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/next-queue master

Anjali Singhai (1):
  i40e: Fix a memory leak in X722 rss config path

Jiang Liu (2):
  i40e: Use numa_mem_id() to better support memoryless node
  i40evf: Use numa_mem_id() to better support memoryless node

Mitch Williams (1):
  i40evf: don't blow away MAC address

Shannon Nelson (1):
  i40e/i40evf: grab the AQ spinlocks before clearing registers

 drivers/net/ethernet/intel/i40e/i40e_adminq.c  | 45 +++---
 drivers/net/ethernet/intel/i40e/i40e_main.c|  4 +-
 drivers/net/ethernet/intel/i40e/i40e_txrx.c|  2 +-
 drivers/net/ethernet/intel/i40evf/i40e_adminq.c| 45 +++---
 drivers/net/ethernet/intel/i40evf/i40e_txrx.c  |  2 +-
 .../net/ethernet/intel/i40evf/i40evf_virtchnl.c|  2 +
 6 files changed, 53 insertions(+), 47 deletions(-)

-- 
2.4.3

--
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


[net-next 5/5] i40evf: don't blow away MAC address

2015-10-03 Thread Jeff Kirsher
From: Mitch Williams 

Under certain circumstances, we can get an extra VF_RESOURCES message
from the PF driver at runtime. When this happens, we need to parse it
because our VSI may have changed out from underneath us, and that will
affect our relationship with the PF driver.

However, parsing the resources message also blows away our current MAC
address in the hardware struct, usually with all zeros. When this
happens, the next time the interface is opened, it will have no MAC
address and will a) not work and b) complain.

Fix this issue by restoring the current MAC address from the netdev
struct after we parse the resource message.

Change-ID: I6cd1b624fc20432f81dc901166c8de195b8e0e65
Signed-off-by: Mitch Williams 
Tested-by: Andrew Bowers 
Signed-off-by: Jeff Kirsher 
---
 drivers/net/ethernet/intel/i40evf/i40evf_virtchnl.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/intel/i40evf/i40evf_virtchnl.c 
b/drivers/net/ethernet/intel/i40evf/i40evf_virtchnl.c
index d4eb1a5..fbf2a1c 100644
--- a/drivers/net/ethernet/intel/i40evf/i40evf_virtchnl.c
+++ b/drivers/net/ethernet/intel/i40evf/i40evf_virtchnl.c
@@ -756,6 +756,8 @@ void i40evf_virtchnl_completion(struct i40evf_adapter 
*adapter,
  sizeof(struct i40e_virtchnl_vsi_resource);
memcpy(adapter->vf_res, msg, min(msglen, len));
i40e_vf_parse_hw_config(>hw, adapter->vf_res);
+   /* restore current mac address */
+   ether_addr_copy(adapter->hw.mac.addr, netdev->dev_addr);
i40evf_process_config(adapter);
}
break;
-- 
2.4.3

--
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