[PATCH 1/3] Add BOOT_PARTITION_ENABLE definition to MMC EXT_CSD PART_CONFIG

2013-04-19 Thread Neil Armstrong
Add bit mask for the BOOT_PARTITION_ENABLE values.

Signed-off-by: Neil Armstrong narmstr...@neotion.com
---
 include/linux/mmc/mmc.h |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/include/linux/mmc/mmc.h b/include/linux/mmc/mmc.h
index 50bcde3..eb5b361 100644
--- a/include/linux/mmc/mmc.h
+++ b/include/linux/mmc/mmc.h
@@ -347,6 +347,7 @@ struct _mmc_csd {
 #define EXT_CSD_PART_CONFIG_ACC_BOOT0(0x1)
 #define EXT_CSD_PART_CONFIG_ACC_RPMB(0x3)
 #define EXT_CSD_PART_CONFIG_ACC_GP0(0x4)
+#define EXT_CSD_PART_CONFIG_EN_MASK(0x38)
 
 #define EXT_CSD_PART_SUPPORT_PART_EN(0x1)
 
-- 
1.7.0.4


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


[PATCH 0/3] Add boot_enable attribute to eMMC device for boot mode operation selection

2013-04-19 Thread Neil Armstrong
Since eMMC 4.3 a special boot mode operation was introduced to retrieve
data from the eMMC device with a very simple procedure. Since the Linux
kernel exports these device boot partitions, it may be useful to select
the boot partition from the user space.

The patch has been tested on a Toshiba eMMC conforming with eMMC 4.5
specifications.

Neil Armstrong (3):
  Add BOOT_PARTITION_ENABLE definition to MMC EXT_CSD PART_CONFIG
  Add boot_enable sysfs attribute to select MMC boot operation
partition
  Add Documentation for MMC boot_enable attribute

 Documentation/mmc/mmc-dev-parts.txt |6 +++
 drivers/mmc/card/block.c|   72
++-
 include/linux/mmc/mmc.h |1 +
 3 files changed, 78 insertions(+), 1 deletions(-)


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


[PATCH 2/3] Add boot_enable sysfs attribute to select MMC boot operation partition

2013-04-19 Thread Neil Armstrong
Add sysfs attribute to select the eMMC boot mode operation according to
the eMMC 4.5 specifications.
Valid values are : 0 for disabled, 1 for first boot partition, 2 for
second boot partition, 7 for user area.

Signed-off-by: Neil Armstrong narmstr...@neotion.com
---
 drivers/mmc/card/block.c |   72
+-
 1 files changed, 71 insertions(+), 1 deletions(-)

diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index 5bab73b..e11c42e 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -114,6 +114,7 @@ struct mmc_blk_data {
  */
 unsigned intpart_curr;
 struct device_attribute force_ro;
+struct device_attribute boot_enable;
 struct device_attribute power_ro_lock;
 intarea_type;
 };
@@ -264,6 +265,23 @@ static ssize_t force_ro_show(struct device *dev,
struct device_attribute *attr,
 return ret;
 }
 
+static ssize_t boot_enable_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+int ret;
+struct mmc_card *card;
+struct mmc_blk_data *md = mmc_blk_get(dev_to_disk(dev));
+
+md = mmc_blk_get(dev_to_disk(dev));
+card = md-queue.card;
+
+ret = snprintf(buf, PAGE_SIZE, %d,
+(card-ext_csd.part_config 
+ EXT_CSD_PART_CONFIG_EN_MASK)  3);
+mmc_blk_put(md);
+return ret;
+}
+
 static ssize_t force_ro_store(struct device *dev, struct
device_attribute *attr,
   const char *buf, size_t count)
 {
@@ -283,6 +301,48 @@ out:
 return ret;
 }
 
+static ssize_t boot_enable_store(struct device *dev,
+  struct device_attribute *attr, const char *buf,
+  size_t count)
+{
+int ret;
+char *end;
+u8 part_config;
+struct mmc_card *card;
+struct mmc_blk_data *md = mmc_blk_get(dev_to_disk(dev));
+unsigned long set = simple_strtoul(buf, end, 0);
+if (end == buf) {
+ret = -EINVAL;
+goto out;
+}
+
+md = mmc_blk_get(dev_to_disk(dev));
+card = md-queue.card;
+
+part_config = card-ext_csd.part_config;
+
+part_config = EXT_CSD_PART_CONFIG_EN_MASK;
+part_config |= (set  3)  EXT_CSD_PART_CONFIG_EN_MASK;
+
+mmc_claim_host(card-host);
+
+ret = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
+ EXT_CSD_PART_CONFIG, part_config,
+ card-ext_csd.part_time);
+
+mmc_release_host(card-host);
+
+if (ret)
+return ret;
+
+card-ext_csd.part_config = part_config;
+
+ret = count;
+out:
+mmc_blk_put(md);
+return ret;
+}
+
 static int mmc_blk_open(struct block_device *bdev, fmode_t mode)
 {
 struct mmc_blk_data *md = mmc_blk_get(bdev-bd_disk);
@@ -2202,6 +2262,15 @@ static int mmc_add_disk(struct mmc_blk_data *md)
 if (ret)
 goto force_ro_fail;
 
+md-boot_enable.show = boot_enable_show;
+md-boot_enable.store = boot_enable_store;
+sysfs_attr_init(md-boot_enable.attr);
+md-boot_enable.attr.name = boot_enable;
+md-boot_enable.attr.mode = S_IRUGO | S_IWUSR;
+ret = device_create_file(disk_to_dev(md-disk), md-boot_enable);
+if (ret)
+goto boot_enable_fail;
+
 if ((md-area_type  MMC_BLK_DATA_AREA_BOOT) 
  card-ext_csd.boot_ro_lockable) {
 umode_t mode;
@@ -2225,6 +2294,8 @@ static int mmc_add_disk(struct mmc_blk_data *md)
 return ret;
 
 power_ro_lock_fail:
+device_remove_file(disk_to_dev(md-disk), md-boot_enable);
+boot_enable_fail:
 device_remove_file(disk_to_dev(md-disk), md-force_ro);
 force_ro_fail:
 del_gendisk(md-disk);
@@ -2434,4 +2505,3 @@ module_exit(mmc_blk_exit);
 
 MODULE_LICENSE(GPL);
 MODULE_DESCRIPTION(Multimedia Card (MMC) block device driver);
-
-- 
1.7.0.4

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


[PATCH 3/3] Add Documentation for MMC boot_enable attribute

2013-04-19 Thread Neil Armstrong
Add documentation on the enable_boot sysfs attribute.

Signed-off-by: Neil Armstrong narmstr...@neotion.com
---
 Documentation/mmc/mmc-dev-parts.txt |6 ++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/Documentation/mmc/mmc-dev-parts.txt
b/Documentation/mmc/mmc-dev-parts.txt
index f08d078..78228de 100644
--- a/Documentation/mmc/mmc-dev-parts.txt
+++ b/Documentation/mmc/mmc-dev-parts.txt
@@ -38,3 +38,9 @@ feature has been disabled on the card, the file will
be read-only.
 The boot partitions can also be locked permanently, but this feature is
 not accessible through sysfs in order to avoid accidental or malicious
 bricking.
+
+A special attribute named boot_enable is available to configure the
+selected partition for the eMMC 4.3+ boot operation mode.
+When selected between the two factory boot partitions and the main
+user partition, at boot time a special sequence enables makes the
+eMMC device to output the content of the selected partition.
-- 
1.7.0.4

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


Re: [PATCH 0/3] Add boot_enable attribute to eMMC device for boot mode operation selection

2013-04-22 Thread Neil Armstrong
On 04/22/2013 06:55 AM, Namjae Jeon wrote:
 2013/4/19, Neil Armstrong narmstr...@neotion.com:
 Since eMMC 4.3 a special boot mode operation was introduced to retrieve
 data from the eMMC device with a very simple procedure. Since the Linux
 kernel exports these device boot partitions, it may be useful to select
 the boot partition from the user space.

 The patch has been tested on a Toshiba eMMC conforming with eMMC 4.5
 specifications.
 Hi Neil.
 We can be enable boot partition using mmc-utils.
 See this address.
 https://git.kernel.org/cgit/linux/kernel/git/cjb/mmc-utils.git/commit/?id=7bd1320b2cb38f040ab5cf017d17e283496690bf
 
 So, I don't think this patch is useful.
 If you consider to be disable boot partition, you can try to update
 mmc-utils base on the address I shared.
 
 Thanks.

 Neil Armstrong (3):
   Add BOOT_PARTITION_ENABLE definition to MMC EXT_CSD PART_CONFIG
   Add boot_enable sysfs attribute to select MMC boot operation
 partition
   Add Documentation for MMC boot_enable attribute

  Documentation/mmc/mmc-dev-parts.txt |6 +++
  drivers/mmc/card/block.c|   72
 ++-
  include/linux/mmc/mmc.h |1 +
  3 files changed, 78 insertions(+), 1 deletions(-)



 

Hi,
Thanks for the reply, I was not aware of the mmc-utils tools. I think
the tool and the MMC_IOC_CMD interface should be documented in the kernel.

Please ignore my patch.

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


[PATCH] Fix coding style issue in xlr_net.c

2014-03-28 Thread Neil Armstrong
checkpatch script returns the following warning:
WARNING: line over 80 characters
310: FILE: drivers/staging/netlogic/xlr_net.c:310:
+   void *accel_priv, select_queue_fallback_t fallback)

This patch fixes the coding style issue.

Signed-off-by: Neil Armstrong superna9...@gmail.com
---
 drivers/staging/netlogic/xlr_net.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/netlogic/xlr_net.c
b/drivers/staging/netlogic/xlr_net.c
index 31b269a..cef0b8a 100644
--- a/drivers/staging/netlogic/xlr_net.c
+++ b/drivers/staging/netlogic/xlr_net.c
@@ -307,7 +307,8 @@ static netdev_tx_t xlr_net_start_xmit(struct sk_buff
*skb,
 }

 static u16 xlr_net_select_queue(struct net_device *ndev, struct sk_buff
*skb,
-   void *accel_priv, select_queue_fallback_t 
fallback)
+   struct sk_buff *skb, void *accel_priv,
+   select_queue_fallback_t fallback)
 {
return (u16)smp_processor_id();
 }
-- 
1.7.0.4
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] Staging: netlogic: long lines in xlr_net.c

2014-03-28 Thread Neil Armstrong
checkpatch script returns the following warning:
WARNING: line over 80 characters
310: FILE: drivers/staging/netlogic/xlr_net.c:310:
+   void *accel_priv, select_queue_fallback_t fallback)

This patch fixes the coding style issue.

Signed-off-by: Neil Armstrong superna9...@gmail.com
---
 drivers/staging/netlogic/xlr_net.c |5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/netlogic/xlr_net.c 
b/drivers/staging/netlogic/xlr_net.c
index 31b269a..5e7d271 100644
--- a/drivers/staging/netlogic/xlr_net.c
+++ b/drivers/staging/netlogic/xlr_net.c
@@ -306,8 +306,9 @@ static netdev_tx_t xlr_net_start_xmit(struct sk_buff *skb,
return NETDEV_TX_OK;
 }
 
-static u16 xlr_net_select_queue(struct net_device *ndev, struct sk_buff *skb,
-   void *accel_priv, select_queue_fallback_t 
fallback)
+static u16 xlr_net_select_queue(struct net_device *ndev,
+   struct sk_buff *skb, void *accel_priv,
+   select_queue_fallback_t fallback)
 {
return (u16)smp_processor_id();
 }
-- 
1.7.0.4
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] staging: rts5139: fix bad symbol declaration

2014-04-11 Thread Neil Armstrong
With sparse, the following error appears :
  CHECK   drivers/staging/rts5139/ms_mg.c
drivers/staging/rts5139/ms_mg.c:82:5: warning: symbol 'mg_set_tpc_para_sub' was 
not declared. Should it be static?

Rename function with correct prefix and move declaration to coherent internal 
header file.

Signed-off-by: Neil 'Superna' Armstrong superna9...@gmail.com
---
 drivers/staging/rts5139/ms.c|7 ++-
 drivers/staging/rts5139/ms_mg.c |2 +-
 drivers/staging/rts5139/ms_mg.h |1 +
 3 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/rts5139/ms.c b/drivers/staging/rts5139/ms.c
index 390292a..a843a2f 100644
--- a/drivers/staging/rts5139/ms.c
+++ b/drivers/staging/rts5139/ms.c
@@ -36,6 +36,7 @@
 #include rts51x_scsi.h
 #include rts51x_card.h
 #include ms.h
+#include ms_mg.h
 
 static inline void ms_set_err_code(struct rts51x_chip *chip, u8 err_code)
 {
@@ -1183,10 +1184,6 @@ static int ms_read_attribute_info(struct rts51x_chip 
*chip)
return STATUS_SUCCESS;
 }
 
-#ifdef SUPPORT_MAGIC_GATE
-int mg_set_tpc_para_sub(struct rts51x_chip *chip, int type, u8 mg_entry_num);
-#endif
-
 static int reset_ms_pro(struct rts51x_chip *chip)
 {
struct ms_info *ms_card = (chip-ms_card);
@@ -1232,7 +1229,7 @@ Retry:
 #endif
 
 #ifdef SUPPORT_MAGIC_GATE
-   retval = mg_set_tpc_para_sub(chip, 0, 0);
+   retval = rts51x_mg_set_tpc_para_sub(chip, 0, 0);
if (retval != STATUS_SUCCESS)
TRACE_RET(chip, retval);
 #endif
diff --git a/drivers/staging/rts5139/ms_mg.c b/drivers/staging/rts5139/ms_mg.c
index 00862c1..c8f2606 100644
--- a/drivers/staging/rts5139/ms_mg.c
+++ b/drivers/staging/rts5139/ms_mg.c
@@ -79,7 +79,7 @@ static int mg_send_ex_cmd(struct rts51x_chip *chip, u8 cmd, 
u8 entry_num)
return STATUS_SUCCESS;
 }
 
-int mg_set_tpc_para_sub(struct rts51x_chip *chip, int type, u8 mg_entry_num)
+int rts51x_mg_set_tpc_para_sub(struct rts51x_chip *chip, int type, u8 
mg_entry_num)
 {
int retval;
u8 buf[6];
diff --git a/drivers/staging/rts5139/ms_mg.h b/drivers/staging/rts5139/ms_mg.h
index d15733a..109c712 100644
--- a/drivers/staging/rts5139/ms_mg.h
+++ b/drivers/staging/rts5139/ms_mg.h
@@ -30,6 +30,7 @@
 #include rts51x_chip.h
 #include ms.h
 
+int rts51x_mg_set_tpc_para_sub(struct rts51x_chip *chip, int type, u8 
mg_entry_num);
 int rts51x_mg_set_leaf_id(struct scsi_cmnd *srb, struct rts51x_chip *chip);
 int rts51x_mg_get_local_EKB(struct scsi_cmnd *srb, struct rts51x_chip *chip);
 int rts51x_mg_chg(struct scsi_cmnd *srb, struct rts51x_chip *chip);
-- 
1.7.10.4
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] staging: vt6656: fix bad symbol declaration

2014-04-11 Thread Neil Armstrong
With sparse, the following error appears :
  CHECK   drivers/staging/vt6656/aes_ccmp.c
drivers/staging/vt6656/aes_ccmp.c:221:6: warning: symbol 'AESbGenCCMP' was not 
declared. Should it be static?

Add correct include header in order to have function declaration.

Signed-off-by: Neil 'Superna' Armstrong superna9...@gmail.com
---
 drivers/staging/vt6656/aes_ccmp.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/vt6656/aes_ccmp.c 
b/drivers/staging/vt6656/aes_ccmp.c
index e2bfa8d..a9d5168 100644
--- a/drivers/staging/vt6656/aes_ccmp.c
+++ b/drivers/staging/vt6656/aes_ccmp.c
@@ -32,6 +32,7 @@
 
 #include device.h
 #include 80211hdr.h
+#include aes_ccmp.h
 
 /*
  * SBOX Table
-- 
1.7.10.4
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] staging: wlan-ng: fix bad symbol declaration

2014-04-11 Thread Neil Armstrong
With sparse, the following error appears :
  CHECK   drivers/staging/wlan-ng/p80211netdev.c
drivers/staging/wlan-ng/cfg80211.c:710:6: warning: symbol 
'prism2_connect_result' was not declared. Should it be static?
drivers/staging/wlan-ng/cfg80211.c:719:6: warning: symbol 'prism2_disconnected' 
was not declared. Should it be static?
drivers/staging/wlan-ng/cfg80211.c:725:6: warning: symbol 'prism2_roamed' was 
not declared. Should it be static?

Move functions declaration to coherent internal header file.

Signed-off-by: Neil 'Superna' Armstrong superna9...@gmail.com
---
 drivers/staging/wlan-ng/prism2mgmt.h |5 +
 drivers/staging/wlan-ng/prism2sta.c  |4 
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/wlan-ng/prism2mgmt.h 
b/drivers/staging/wlan-ng/prism2mgmt.h
index 190d390..b62fdcb 100644
--- a/drivers/staging/wlan-ng/prism2mgmt.h
+++ b/drivers/staging/wlan-ng/prism2mgmt.h
@@ -109,4 +109,9 @@ void prism2sta_processing_defer(struct work_struct *data);
 void prism2sta_commsqual_defer(struct work_struct *data);
 void prism2sta_commsqual_timer(unsigned long data);
 
+/* Interface callback functions, passing data back up to the cfg80211 layer */
+void prism2_connect_result(wlandevice_t *wlandev, u8 failed);
+void prism2_disconnected(wlandevice_t *wlandev);
+void prism2_roamed(wlandevice_t *wlandev);
+
 #endif
diff --git a/drivers/staging/wlan-ng/prism2sta.c 
b/drivers/staging/wlan-ng/prism2sta.c
index f9ccf23..3fd4538 100644
--- a/drivers/staging/wlan-ng/prism2sta.c
+++ b/drivers/staging/wlan-ng/prism2sta.c
@@ -120,10 +120,6 @@ MODULE_PARM_DESC(prism2_reset_settletime, reset settle 
time in ms);
 
 MODULE_LICENSE(Dual MPL/GPL);
 
-void prism2_connect_result(wlandevice_t *wlandev, u8 failed);
-void prism2_disconnected(wlandevice_t *wlandev);
-void prism2_roamed(wlandevice_t *wlandev);
-
 static int prism2sta_open(wlandevice_t *wlandev);
 static int prism2sta_close(wlandevice_t *wlandev);
 static void prism2sta_reset(wlandevice_t *wlandev);
-- 
1.7.10.4
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] Staging: silicom: fix dangerous if condition in bpctl_mod.c

2014-04-01 Thread Neil Armstrong
checkpatch script returns the following warning:
ERROR: do not use assignment in if condition
+   if (((dev_num = get_dev_idx(dev-ifindex)) ==
-1) |

This patch fixes the if condition by splitting it.

Signed-off-by: Neil Armstrong superna9...@gmail.com
---
 drivers/staging/silicom/bpctl_mod.c |8 ++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/silicom/bpctl_mod.c 
b/drivers/staging/silicom/bpctl_mod.c
index 6b9365b..3b4db2a 100644
--- a/drivers/staging/silicom/bpctl_mod.c
+++ b/drivers/staging/silicom/bpctl_mod.c
@@ -220,8 +220,12 @@ static int bp_device_event(struct notifier_block *unused,
if (netif_carrier_ok(dev))
return NOTIFY_DONE;
 
-   if (((dev_num = get_dev_idx(dev-ifindex)) == -1) ||
-   (!(pbpctl_dev = bpctl_dev_arr[dev_num])))
+   dev_num = get_dev_idx(dev-ifindex);
+   if (dev_num == -1)
+   return NOTIFY_DONE;
+
+   pbpctl_dev = bpctl_dev_arr[dev_num];
+   if (!pbpctl_dev)
return NOTIFY_DONE;
 
if ((is_bypass_fn(pbpctl_dev)) == 1)
-- 
1.7.0.4
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/2] net: macb: Handle RX errors

2014-07-18 Thread Neil Armstrong
On our hardware, the MACB connected to a heavilly used AXI bus, fails to
correctly write RX descriptors.

This leds to RX ring errors that can be managed.

These patchs add RX error management according to the Cadence MACB User Guide.

The first patch separates the RX and TX rings init in order to reuse the RX 
ring init.

Neil Armstrong (2):
  net: macb: Separate rx and tx ring init function
  net: macb: Handle errors in RX path

 drivers/net/ethernet/cadence/macb.c |   88 +--
 drivers/net/ethernet/cadence/macb.h |3 +-
 2 files changed, 76 insertions(+), 15 deletions(-)
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/2] net: macb: Handle errors in RX path

2014-07-18 Thread Neil Armstrong
In certain circumstances, the MACB fails to write correct RX ring
descriptor, and lead to actually managed by BUG_ON() error cases.

Handle these two cases by returning error values, while resetting
the RX ring and RX HW path in the poll methos.

In the same time, check and handle BNA and OVR into poll method
by using the same error management.

Signed-off-by: Neil Armstrong narmstr...@neotion.com
---
 drivers/net/ethernet/cadence/macb.c |   55 +++---
 1 files changed, 50 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/cadence/macb.c 
b/drivers/net/ethernet/cadence/macb.c
index 20ad483..c94355d 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -755,6 +755,17 @@ static int macb_rx_frame(struct macb *bp, unsigned int 
first_frag,
macb_rx_ring_wrap(first_frag),
macb_rx_ring_wrap(last_frag), len);
 
+   if (!(desc-ctrl  MACB_BIT(RX_EOF))) {
+   netdev_vdbg(bp-dev, macb_rx_frame missing EOF\n);
+   return -EIO;
+   }
+
+   desc = macb_rx_desc(bp, first_frag);
+   if (!(desc-ctrl  MACB_BIT(RX_SOF))) {
+   netdev_vdbg(bp-dev, macb_rx_frame missing SOF\n);
+   return -EIO;
+   }
+
/*
 * The ethernet header starts NET_IP_ALIGN bytes into the
 * first buffer. Since the header is 14 bytes, this makes the
@@ -789,7 +800,10 @@ static int macb_rx_frame(struct macb *bp, unsigned int 
first_frag,
unsigned int frag_len = bp-rx_buffer_size;
 
if (offset + frag_len  len) {
-   BUG_ON(frag != last_frag);
+   if(frag != last_frag) {
+   dev_kfree_skb_any(skb);
+   return -EIO;
+   }
frag_len = len - offset;
}
skb_copy_to_linear_data_offset(skb, offset,
@@ -844,9 +858,13 @@ static int macb_rx(struct macb *bp, int budget)
 
if (ctrl  MACB_BIT(RX_EOF)) {
int dropped;
-   BUG_ON(first_frag == -1);
+   if (first_frag == -1)
+   return -EIO;
 
dropped = macb_rx_frame(bp, first_frag, tail);
+   if (dropped  0)
+   return dropped;
+
first_frag = -1;
if (!dropped) {
received++;
@@ -872,12 +890,22 @@ static int macb_poll(struct napi_struct *napi, int budget)
status = macb_readl(bp, RSR);
macb_writel(bp, RSR, status);
 
-   work_done = 0;
+   work_done = -EIO;
 
netdev_vdbg(bp-dev, poll: status = %08lx, budget = %d\n,
-  (unsigned long)status, budget);
+   (unsigned long)status, budget);
+
+   if (status  (MACB_BIT(OVR) | MACB_BIT(BNA)) ||
+   !(status  MACB_BIT(REC))) {
+   netdev_err(bp-dev, RX error, status = %02lx\n,
+   (unsigned long)status);
+   goto rx_out;
+   }
 
work_done = bp-macbgem_ops.mog_rx(bp, budget);
+   if (work_done  0)
+   goto rx_out;
+
if (work_done  budget) {
napi_complete(napi);
 
@@ -892,7 +920,24 @@ static int macb_poll(struct napi_struct *napi, int budget)
}
}
 
-   /* TODO: Handle errors */
+   return work_done;
+
+rx_out:
+   /* 
+* In case of error, disable RX and reset
+* the descriptor ring before re-enabling RX.
+*/
+   macb_writel(bp, NCR, macb_readl(bp, NCR)  ~MACB_BIT(RE));
+
+   bp-macbgem_ops.mog_init_rx_rings(bp);
+   macb_writel(bp, RBQP, bp-rx_ring_dma);
+
+   /* Re-enable RX and get notified for new packets */
+   macb_writel(bp, NCR, macb_readl(bp, NCR) | MACB_BIT(RE));
+
+   napi_complete(napi);
+
+   macb_writel(bp, IER, MACB_RX_INT_FLAGS);
 
return work_done;
 }
-- 
1.7.0.4
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/2] net: macb: Separate rx and tx ring init function

2014-07-18 Thread Neil Armstrong
A single method is called to initialize the TX and RX
rings. Separate the methods into distinct ones for
MACB and GEM context.

Signed-off-by: Neil Armstrong narmstr...@neotion.com
---
 drivers/net/ethernet/cadence/macb.c |   33 -
 drivers/net/ethernet/cadence/macb.h |3 ++-
 2 files changed, 26 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/cadence/macb.c 
b/drivers/net/ethernet/cadence/macb.c
index e9daa07..20ad483 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -1219,7 +1219,14 @@ out_err:
return -ENOMEM;
 }
 
-static void gem_init_rings(struct macb *bp)
+static void gem_init_rx_rings(struct macb *bp)
+{
+   bp-rx_tail = bp-rx_prepared_head = 0;
+
+   gem_rx_refill(bp);
+}
+
+static void gem_init_tx_rings(struct macb *bp)
 {
int i;
 
@@ -1229,12 +1236,10 @@ static void gem_init_rings(struct macb *bp)
}
bp-tx_ring[TX_RING_SIZE - 1].ctrl |= MACB_BIT(TX_WRAP);
 
-   bp-rx_tail = bp-rx_prepared_head = bp-tx_head = bp-tx_tail = 0;
-
-   gem_rx_refill(bp);
+   bp-tx_head = bp-tx_tail = 0;
 }
 
-static void macb_init_rings(struct macb *bp)
+static void macb_init_rx_rings(struct macb *bp)
 {
int i;
dma_addr_t addr;
@@ -1247,13 +1252,20 @@ static void macb_init_rings(struct macb *bp)
}
bp-rx_ring[RX_RING_SIZE - 1].addr |= MACB_BIT(RX_WRAP);
 
+   bp-rx_tail = 0;
+}
+
+static void macb_init_tx_rings(struct macb *bp)
+{
+   int i;
+
for (i = 0; i  TX_RING_SIZE; i++) {
bp-tx_ring[i].addr = 0;
bp-tx_ring[i].ctrl = MACB_BIT(TX_USED);
}
bp-tx_ring[TX_RING_SIZE - 1].ctrl |= MACB_BIT(TX_WRAP);
 
-   bp-rx_tail = bp-tx_head = bp-tx_tail = 0;
+   bp-tx_head = bp-tx_tail = 0;
 }
 
 static void macb_reset_hw(struct macb *bp)
@@ -1554,7 +1566,8 @@ static int macb_open(struct net_device *dev)
 
napi_enable(bp-napi);
 
-   bp-macbgem_ops.mog_init_rings(bp);
+   bp-macbgem_ops.mog_init_rx_rings(bp);
+   bp-macbgem_ops.mog_init_tx_rings(bp);
macb_init_hw(bp);
 
/* schedule a link state check */
@@ -1901,12 +1914,14 @@ static int __init macb_probe(struct platform_device 
*pdev)
if (macb_is_gem(bp)) {
bp-macbgem_ops.mog_alloc_rx_buffers = gem_alloc_rx_buffers;
bp-macbgem_ops.mog_free_rx_buffers = gem_free_rx_buffers;
-   bp-macbgem_ops.mog_init_rings = gem_init_rings;
+   bp-macbgem_ops.mog_init_rx_rings = gem_init_rx_rings;
+   bp-macbgem_ops.mog_init_tx_rings = gem_init_tx_rings;
bp-macbgem_ops.mog_rx = gem_rx;
} else {
bp-macbgem_ops.mog_alloc_rx_buffers = macb_alloc_rx_buffers;
bp-macbgem_ops.mog_free_rx_buffers = macb_free_rx_buffers;
-   bp-macbgem_ops.mog_init_rings = macb_init_rings;
+   bp-macbgem_ops.mog_init_rx_rings = macb_init_rx_rings;
+   bp-macbgem_ops.mog_init_tx_rings = macb_init_tx_rings;
bp-macbgem_ops.mog_rx = macb_rx;
}
 
diff --git a/drivers/net/ethernet/cadence/macb.h 
b/drivers/net/ethernet/cadence/macb.h
index 51c0244..8016d08 100644
--- a/drivers/net/ethernet/cadence/macb.h
+++ b/drivers/net/ethernet/cadence/macb.h
@@ -550,7 +550,8 @@ struct macb;
 struct macb_or_gem_ops {
int (*mog_alloc_rx_buffers)(struct macb *bp);
void(*mog_free_rx_buffers)(struct macb *bp);
-   void(*mog_init_rings)(struct macb *bp);
+   void(*mog_init_rx_rings)(struct macb *bp);
+   void(*mog_init_tx_rings)(struct macb *bp);
int (*mog_rx)(struct macb *bp, int budget);
 };
 
-- 
1.7.0.4
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/2] net: macb: Separate rx and tx ring init function

2014-07-18 Thread Neil Armstrong
Le 18/07/2014 12:10, Varka Bhadram a écrit :
 On 07/18/2014 03:22 PM, Neil Armstrong wrote:
 A single method is called to initialize the TX and RX
 rings. Separate the methods into distinct ones for
 MACB and GEM context.

 Signed-off-by: Neil Armstrong narmstr...@neotion.com
 ---
   drivers/net/ethernet/cadence/macb.c |   33 
 -
   drivers/net/ethernet/cadence/macb.h |3 ++-
   2 files changed, 26 insertions(+), 10 deletions(-)

 diff --git a/drivers/net/ethernet/cadence/macb.c 
 b/drivers/net/ethernet/cadence/macb.c
 index e9daa07..20ad483 100644
 --- a/drivers/net/ethernet/cadence/macb.c
 +++ b/drivers/net/ethernet/cadence/macb.c
 @@ -1219,7 +1219,14 @@ out_err:
  return -ENOMEM;
   }
   
 -static void gem_init_rings(struct macb *bp)
 +static void gem_init_rx_rings(struct macb *bp)
 +{
 +bp-rx_tail = bp-rx_prepared_head = 0;
 +
 +gem_rx_refill(bp);
 +}
 +
 +static void gem_init_tx_rings(struct macb *bp)
   {
  int i;
   
 @@ -1229,12 +1236,10 @@ static void gem_init_rings(struct macb *bp)
  }
  bp-tx_ring[TX_RING_SIZE - 1].ctrl |= MACB_BIT(TX_WRAP);
   
 -bp-rx_tail = bp-rx_prepared_head = bp-tx_head = bp-tx_tail = 0;
 -
 -gem_rx_refill(bp);
 +bp-tx_head = bp-tx_tail = 0;
 
 This is not the preferred way of doing it
 
 multiple assignments should be avoided
Should I change it ? I only moved the lines, the logic hasn't changed.
 
   }
   
 -static void macb_init_rings(struct macb *bp)
 +static void macb_init_rx_rings(struct macb *bp)
   {
  int i;
  dma_addr_t addr;
 @@ -1247,13 +1252,20 @@ static void macb_init_rings(struct macb *bp)
  }
  bp-rx_ring[RX_RING_SIZE - 1].addr |= MACB_BIT(RX_WRAP);
   
 +bp-rx_tail = 0;
 +}
 +
 +static void macb_init_tx_rings(struct macb *bp)
 +{
 +int i;
 +
  for (i = 0; i  TX_RING_SIZE; i++) {
  bp-tx_ring[i].addr = 0;
  bp-tx_ring[i].ctrl = MACB_BIT(TX_USED);
  }
  bp-tx_ring[TX_RING_SIZE - 1].ctrl |= MACB_BIT(TX_WRAP);
   
 -bp-rx_tail = bp-tx_head = bp-tx_tail = 0;
 +bp-tx_head = bp-tx_tail = 0;
 
 Dto...
Idem, it was like this before.
 
   }
   
   static void macb_reset_hw(struct macb *bp)
 @@ -1554,7 +1566,8 @@ static int macb_open(struct net_device *dev)
   
  napi_enable(bp-napi);
   
 -bp-macbgem_ops.mog_init_rings(bp);
 +bp-macbgem_ops.mog_init_rx_rings(bp);
 +bp-macbgem_ops.mog_init_tx_rings(bp);
  macb_init_hw(bp);
   
  /* schedule a link state check */
 @@ -1901,12 +1914,14 @@ static int __init macb_probe(struct platform_device 
 *pdev)
  if (macb_is_gem(bp)) {
  bp-macbgem_ops.mog_alloc_rx_buffers = gem_alloc_rx_buffers;
  bp-macbgem_ops.mog_free_rx_buffers = gem_free_rx_buffers;
 -bp-macbgem_ops.mog_init_rings = gem_init_rings;
 +bp-macbgem_ops.mog_init_rx_rings = gem_init_rx_rings;
 +bp-macbgem_ops.mog_init_tx_rings = gem_init_tx_rings;
  bp-macbgem_ops.mog_rx = gem_rx;
  } else {
  bp-macbgem_ops.mog_alloc_rx_buffers = macb_alloc_rx_buffers;
  bp-macbgem_ops.mog_free_rx_buffers = macb_free_rx_buffers;
 -bp-macbgem_ops.mog_init_rings = macb_init_rings;
 +bp-macbgem_ops.mog_init_rx_rings = macb_init_rx_rings;
 +bp-macbgem_ops.mog_init_tx_rings = macb_init_tx_rings;
  bp-macbgem_ops.mog_rx = macb_rx;
  }
   
 diff --git a/drivers/net/ethernet/cadence/macb.h 
 b/drivers/net/ethernet/cadence/macb.h
 index 51c0244..8016d08 100644
 --- a/drivers/net/ethernet/cadence/macb.h
 +++ b/drivers/net/ethernet/cadence/macb.h
 @@ -550,7 +550,8 @@ struct macb;
   struct macb_or_gem_ops {
  int (*mog_alloc_rx_buffers)(struct macb *bp);
  void(*mog_free_rx_buffers)(struct macb *bp);
 -void(*mog_init_rings)(struct macb *bp);
 +void(*mog_init_rx_rings)(struct macb *bp);
 +void(*mog_init_tx_rings)(struct macb *bp);
  int (*mog_rx)(struct macb *bp, int budget);
   };
   
 
 

Do I need to make a corrective patch for multiple assignments before ?
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/2 v2] net: macb: Handle errors in RX path

2014-07-18 Thread Neil Armstrong
In certain circumstances, the MACB fails to write correct RX ring
descriptor, and lead to actually managed by BUG_ON() error cases.

Handle these two cases by returning error values, while resetting
the RX ring and RX HW path in the poll methos.

In the same time, check and handle BNA and OVR into poll method
by using the same error management.

Signed-off-by: Neil Armstrong narmstr...@neotion.com
---
 drivers/net/ethernet/cadence/macb.c |   54 +++---
 1 files changed, 49 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/cadence/macb.c 
b/drivers/net/ethernet/cadence/macb.c
index 20ad483..f88ebc9 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -755,6 +755,17 @@ static int macb_rx_frame(struct macb *bp, unsigned int 
first_frag,
macb_rx_ring_wrap(first_frag),
macb_rx_ring_wrap(last_frag), len);
 
+   if (!(desc-ctrl  MACB_BIT(RX_EOF))) {
+   netdev_vdbg(bp-dev, macb_rx_frame missing EOF\n);
+   return -EIO;
+   }
+
+   desc = macb_rx_desc(bp, first_frag);
+   if (!(desc-ctrl  MACB_BIT(RX_SOF))) {
+   netdev_vdbg(bp-dev, macb_rx_frame missing SOF\n);
+   return -EIO;
+   }
+
/*
 * The ethernet header starts NET_IP_ALIGN bytes into the
 * first buffer. Since the header is 14 bytes, this makes the
@@ -789,7 +800,10 @@ static int macb_rx_frame(struct macb *bp, unsigned int 
first_frag,
unsigned int frag_len = bp-rx_buffer_size;
 
if (offset + frag_len  len) {
-   BUG_ON(frag != last_frag);
+   if (frag != last_frag) {
+   dev_kfree_skb_any(skb);
+   return -EIO;
+   }
frag_len = len - offset;
}
skb_copy_to_linear_data_offset(skb, offset,
@@ -844,9 +858,13 @@ static int macb_rx(struct macb *bp, int budget)
 
if (ctrl  MACB_BIT(RX_EOF)) {
int dropped;
-   BUG_ON(first_frag == -1);
+   if (first_frag == -1)
+   return -EIO;
 
dropped = macb_rx_frame(bp, first_frag, tail);
+   if (dropped  0)
+   return dropped;
+
first_frag = -1;
if (!dropped) {
received++;
@@ -872,12 +890,22 @@ static int macb_poll(struct napi_struct *napi, int budget)
status = macb_readl(bp, RSR);
macb_writel(bp, RSR, status);
 
-   work_done = 0;
+   work_done = -EIO;
 
netdev_vdbg(bp-dev, poll: status = %08lx, budget = %d\n,
-  (unsigned long)status, budget);
+   (unsigned long)status, budget);
+
+   if (status  (MACB_BIT(OVR) | MACB_BIT(BNA)) ||
+   !(status  MACB_BIT(REC))) {
+   netdev_err(bp-dev, RX error, status = %02lx\n,
+  (unsigned long)status);
+   goto rx_out;
+   }
 
work_done = bp-macbgem_ops.mog_rx(bp, budget);
+   if (work_done  0)
+   goto rx_out;
+
if (work_done  budget) {
napi_complete(napi);
 
@@ -892,7 +920,23 @@ static int macb_poll(struct napi_struct *napi, int budget)
}
}
 
-   /* TODO: Handle errors */
+   return work_done;
+
+rx_out:
+   /* In case of error, disable RX and reset
+* the descriptor ring before re-enabling RX.
+*/
+   macb_writel(bp, NCR, macb_readl(bp, NCR)  ~MACB_BIT(RE));
+
+   bp-macbgem_ops.mog_init_rx_rings(bp);
+   macb_writel(bp, RBQP, bp-rx_ring_dma);
+
+   /* Re-enable RX and get notified for new packets */
+   macb_writel(bp, NCR, macb_readl(bp, NCR) | MACB_BIT(RE));
+
+   napi_complete(napi);
+
+   macb_writel(bp, IER, MACB_RX_INT_FLAGS);
 
return work_done;
 }
-- 
1.7.0.4

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


[PATCH v2 1/2] net: macb: Separate rx and tx ring init function

2014-07-18 Thread Neil Armstrong
A single method is called to initialize the TX and RX rings.
Separate the methods into distinct ones for MACB and GEM contexts.
Also remove the multiple assignments from the original code.

Signed-off-by: Neil Armstrong narmstr...@neotion.com
---
 drivers/net/ethernet/cadence/macb.c |   36 ++
 drivers/net/ethernet/cadence/macb.h |3 +-
 2 files changed, 29 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/cadence/macb.c 
b/drivers/net/ethernet/cadence/macb.c
index e9daa07..4d73110 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -1219,7 +1219,15 @@ out_err:
return -ENOMEM;
 }
 
-static void gem_init_rings(struct macb *bp)
+static void gem_init_rx_rings(struct macb *bp)
+{
+   bp-rx_tail = 0;
+   bp-rx_prepared_head = 0;
+
+   gem_rx_refill(bp);
+}
+
+static void gem_init_tx_rings(struct macb *bp)
 {
int i;
 
@@ -1229,12 +1237,11 @@ static void gem_init_rings(struct macb *bp)
}
bp-tx_ring[TX_RING_SIZE - 1].ctrl |= MACB_BIT(TX_WRAP);
 
-   bp-rx_tail = bp-rx_prepared_head = bp-tx_head = bp-tx_tail = 0;
-
-   gem_rx_refill(bp);
+   bp-tx_head = 0;
+   bp-tx_tail = 0;
 }
 
-static void macb_init_rings(struct macb *bp)
+static void macb_init_rx_rings(struct macb *bp)
 {
int i;
dma_addr_t addr;
@@ -1247,13 +1254,21 @@ static void macb_init_rings(struct macb *bp)
}
bp-rx_ring[RX_RING_SIZE - 1].addr |= MACB_BIT(RX_WRAP);
 
+   bp-rx_tail = 0;
+}
+
+static void macb_init_tx_rings(struct macb *bp)
+{
+   int i;
+
for (i = 0; i  TX_RING_SIZE; i++) {
bp-tx_ring[i].addr = 0;
bp-tx_ring[i].ctrl = MACB_BIT(TX_USED);
}
bp-tx_ring[TX_RING_SIZE - 1].ctrl |= MACB_BIT(TX_WRAP);
 
-   bp-rx_tail = bp-tx_head = bp-tx_tail = 0;
+   bp-tx_head = 0;
+   bp-tx_tail = 0;
 }
 
 static void macb_reset_hw(struct macb *bp)
@@ -1554,7 +1569,8 @@ static int macb_open(struct net_device *dev)
 
napi_enable(bp-napi);
 
-   bp-macbgem_ops.mog_init_rings(bp);
+   bp-macbgem_ops.mog_init_rx_rings(bp);
+   bp-macbgem_ops.mog_init_tx_rings(bp);
macb_init_hw(bp);
 
/* schedule a link state check */
@@ -1901,12 +1917,14 @@ static int __init macb_probe(struct platform_device 
*pdev)
if (macb_is_gem(bp)) {
bp-macbgem_ops.mog_alloc_rx_buffers = gem_alloc_rx_buffers;
bp-macbgem_ops.mog_free_rx_buffers = gem_free_rx_buffers;
-   bp-macbgem_ops.mog_init_rings = gem_init_rings;
+   bp-macbgem_ops.mog_init_rx_rings = gem_init_rx_rings;
+   bp-macbgem_ops.mog_init_tx_rings = gem_init_tx_rings;
bp-macbgem_ops.mog_rx = gem_rx;
} else {
bp-macbgem_ops.mog_alloc_rx_buffers = macb_alloc_rx_buffers;
bp-macbgem_ops.mog_free_rx_buffers = macb_free_rx_buffers;
-   bp-macbgem_ops.mog_init_rings = macb_init_rings;
+   bp-macbgem_ops.mog_init_rx_rings = macb_init_rx_rings;
+   bp-macbgem_ops.mog_init_tx_rings = macb_init_tx_rings;
bp-macbgem_ops.mog_rx = macb_rx;
}
 
diff --git a/drivers/net/ethernet/cadence/macb.h 
b/drivers/net/ethernet/cadence/macb.h
index 51c0244..8016d08 100644
--- a/drivers/net/ethernet/cadence/macb.h
+++ b/drivers/net/ethernet/cadence/macb.h
@@ -550,7 +550,8 @@ struct macb;
 struct macb_or_gem_ops {
int (*mog_alloc_rx_buffers)(struct macb *bp);
void(*mog_free_rx_buffers)(struct macb *bp);
-   void(*mog_init_rings)(struct macb *bp);
+   void(*mog_init_rx_rings)(struct macb *bp);
+   void(*mog_init_tx_rings)(struct macb *bp);
int (*mog_rx)(struct macb *bp, int budget);
 };
 
-- 
1.7.0.4

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


[PATCH v2 2/2] net: macb: Handle errors in RX path

2014-07-18 Thread Neil Armstrong
In certain circumstances, the MACB fails to write correct RX ring
descriptor, and lead to actually managed by BUG_ON() error cases.

Handle these two cases by returning error values, while resetting
the RX ring and RX HW path in the poll methos.

In the same time, check and handle BNA and OVR into poll method
by using the same error management.

Signed-off-by: Neil Armstrong narmstr...@neotion.com
---
 drivers/net/ethernet/cadence/macb.c |   54 +++---
 1 files changed, 49 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/cadence/macb.c 
b/drivers/net/ethernet/cadence/macb.c
index 4d73110..81429df 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -755,6 +755,17 @@ static int macb_rx_frame(struct macb *bp, unsigned int 
first_frag,
macb_rx_ring_wrap(first_frag),
macb_rx_ring_wrap(last_frag), len);
 
+   if (!(desc-ctrl  MACB_BIT(RX_EOF))) {
+   netdev_vdbg(bp-dev, macb_rx_frame missing EOF\n);
+   return -EIO;
+   }
+
+   desc = macb_rx_desc(bp, first_frag);
+   if (!(desc-ctrl  MACB_BIT(RX_SOF))) {
+   netdev_vdbg(bp-dev, macb_rx_frame missing SOF\n);
+   return -EIO;
+   }
+
/*
 * The ethernet header starts NET_IP_ALIGN bytes into the
 * first buffer. Since the header is 14 bytes, this makes the
@@ -789,7 +800,10 @@ static int macb_rx_frame(struct macb *bp, unsigned int 
first_frag,
unsigned int frag_len = bp-rx_buffer_size;
 
if (offset + frag_len  len) {
-   BUG_ON(frag != last_frag);
+   if (frag != last_frag) {
+   dev_kfree_skb_any(skb);
+   return -EIO;
+   }
frag_len = len - offset;
}
skb_copy_to_linear_data_offset(skb, offset,
@@ -844,9 +858,13 @@ static int macb_rx(struct macb *bp, int budget)
 
if (ctrl  MACB_BIT(RX_EOF)) {
int dropped;
-   BUG_ON(first_frag == -1);
+   if (first_frag == -1)
+   return -EIO;
 
dropped = macb_rx_frame(bp, first_frag, tail);
+   if (dropped  0)
+   return dropped;
+
first_frag = -1;
if (!dropped) {
received++;
@@ -872,12 +890,22 @@ static int macb_poll(struct napi_struct *napi, int budget)
status = macb_readl(bp, RSR);
macb_writel(bp, RSR, status);
 
-   work_done = 0;
+   work_done = -EIO;
 
netdev_vdbg(bp-dev, poll: status = %08lx, budget = %d\n,
-  (unsigned long)status, budget);
+   (unsigned long)status, budget);
+
+   if (status  (MACB_BIT(OVR) | MACB_BIT(BNA)) ||
+   !(status  MACB_BIT(REC))) {
+   netdev_err(bp-dev, RX error, status = %02lx\n,
+  (unsigned long)status);
+   goto rx_out;
+   }
 
work_done = bp-macbgem_ops.mog_rx(bp, budget);
+   if (work_done  0)
+   goto rx_out;
+
if (work_done  budget) {
napi_complete(napi);
 
@@ -892,7 +920,23 @@ static int macb_poll(struct napi_struct *napi, int budget)
}
}
 
-   /* TODO: Handle errors */
+   return work_done;
+
+rx_out:
+   /* In case of error, disable RX and reset
+* the descriptor ring before re-enabling RX.
+*/
+   macb_writel(bp, NCR, macb_readl(bp, NCR)  ~MACB_BIT(RE));
+
+   bp-macbgem_ops.mog_init_rx_rings(bp);
+   macb_writel(bp, RBQP, bp-rx_ring_dma);
+
+   /* Re-enable RX and get notified for new packets */
+   macb_writel(bp, NCR, macb_readl(bp, NCR) | MACB_BIT(RE));
+
+   napi_complete(napi);
+
+   macb_writel(bp, IER, MACB_RX_INT_FLAGS);
 
return work_done;
 }
-- 
1.7.0.4

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


[PATCH v2 0/2] net: macb: Handle RX errors

2014-07-18 Thread Neil Armstrong
On our hardware, the MACB connected to a heavilly used AXI bus, fails to
correctly write RX descriptors.

This leds to RX ring errors that can be managed.

These patchs add RX error management according to the Cadence MACB User Guide.

The first patch separates the RX and TX rings init in order to reuse the RX 
ring init.

v2: fix multiple assignments in first patch, fix checkpatch errors in second 
patch.

Neil Armstrong (2):
  net: macb: Separate rx and tx ring init function
  net: macb: Handle errors in RX path

 drivers/net/ethernet/cadence/macb.c |   90 +-
 drivers/net/ethernet/cadence/macb.h |3 +-
 2 files changed, 78 insertions(+), 15 deletions(-)


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


[PATCH RFC] usb: gadget: dwc2: make driver run on a version 3.10a instance of DWC_OTG

2014-08-13 Thread Neil Armstrong
We are trying to make a driver run on our PCD only instance of Synopsys
DWC_OTG IP with the following parameters :
- Dedicated Fifos : Yes
- Descriptor DMA : Yes
- PHY : 8bit UTMI+ (may need also support for ULPI)
- Endpoints : 6 (7 with ep0)
- Periodic IN Endpoints : 0
- IN Endpoints : 3 (4 with ep0)
- EP repartition : INOUT, IN, OUT, IN , OUT, IN, OUT
- DFifo Depth : 1844

I do not know what is the original s3c hsotg IP config, but to
correctly support the Dedicated Fifos you need to attribute a FIFO
index for each IN endpoints, and on the 3.10a release we only have
4 TX FIFOS, so we just cannot give the EP number as fifo index.

It impacts the FIFO repartition, it is not perfect since we do
not take into account the Isochronous needs, so it needs some
rework.

To managed these FIFOs, I load from the registers the EP
repartition, HW fifo depth and HW revision.
It also impacts that hw_cfg must be done before init call.

Same for the num_of_eps value, in the Synopsys documentation,
it specifies it is the count of non-ep0 endpoints, but the
driver for loops where like :
for(i = 1 ; i  hsotg-num_of_eps ; ++i)
which is absolutely invalid and ignores the last EP.

We never managed to make the driver work in FIFO mode, but in DMA
mode it works like a charm, and to support all the gadget drivers,
we implemented a silly Bounce Buffer mode.

The PHY configuration was also rewritten according to the
documentation.

Fo the descripto DMA mode, I tried to add missing parts, but I get stuck
with weird HW beheviours

Signed-off-by: Neil Armstrong narmstr...@neotion.com
---
 drivers/usb/dwc2/core.h   |   14 +++
 drivers/usb/dwc2/gadget.c |  267 +++--
 2 files changed, 221 insertions(+), 60 deletions(-)

This is mainly an RFC in order to make this driver run with recent HW.
This is why the patch is not 100% clean.

diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index 1efd10c..21c136e 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -102,6 +102,7 @@ struct s3c_hsotg_req;
  * @dir_in: Set to true if this endpoint is of the IN direction, which
  *  means that it is sending data to the Host.
  * @index: The index for the endpoint registers.
+ * @txfnum: The TX fifo index.
  * @mc: Multi Count - number of transactions per microframe
  * @interval - Interval for periodic endpoints
  * @name: The name array passed to the USB core.
@@ -142,6 +143,7 @@ struct s3c_hsotg_ep {
 
 unsigned char   dir_in;
 unsigned char   index;
+unsigned inttxfnum;
 unsigned char   mc;
 unsigned char   interval;
 
@@ -167,6 +169,10 @@ struct s3c_hsotg_ep {
  * @phyif: PHY interface width
  * @dedicated_fifos: Set if the hardware has dedicated IN-EP fifos.
  * @num_of_eps: Number of available EPs (excluding EP0)
+ * @dfifo_depth: depth of HW DFIFO
+ * @dir_of_eps: direction of each endpoint
+ * @hw_major: Hardware Major number
+ * @hw_minor: Hardware minor ID
  * @debug_root: root directrory for debugfs.
  * @debug_file: main status file for debugfs.
  * @debug_fifo: FIFO status file for debugfs.
@@ -195,7 +201,12 @@ struct s3c_hsotg {
 
 u32 phyif;
 unsigned intdedicated_fifos:1;
+unsigned intdfifo_depth;
 unsigned char   num_of_eps;
+unsigned intdma_enable:1;
+unsigned char   dir_of_eps[16];
+unsigned inthw_major;
+unsigned inthw_minor[3];
 
 struct dentry   *debug_root;
 struct dentry   *debug_file;
@@ -224,6 +235,9 @@ struct s3c_hsotg_req {
 struct list_headqueue;
 unsigned char   in_progress;
 unsigned char   mapped;
+unsignedbounced_dma;
+dma_addr_t  bounce_phys;
+void* bounce;
 };
 
 #define call_gadget(_hs, _entry) \
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 392b373..1f3f9b9 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -89,7 +89,7 @@ static void s3c_hsotg_dump(struct s3c_hsotg *hsotg);
  */
 static inline bool using_dma(struct s3c_hsotg *hsotg)
 {
-return false;/* support is not complete */
+return hsotg-dma_enable;
 }
 
 /**
@@ -163,17 +163,30 @@ static void s3c_hsotg_ctrl_epint(struct s3c_hsotg *hsotg,
  */
 static void s3c_hsotg_init_fifo(struct s3c_hsotg *hsotg)
 {
+unsigned int rxfifo_size;
 unsigned int ep;
 unsigned int addr;
 unsigned int size;
+unsigned int txfifonum;
 int timeout;
 u32 val;
 
-/* set FIFO sizes to 2048/1024 */
+rxfifo_size = (4 * 1) + 6; // (4 * number of control endpoint + 6)
+rxfifo_size += (1024 / 4) + 1; // (largest packet / 4) + 1
+rxfifo_size += 2; // for ep0 as OUT endpoint
+for (ep = 1; ep = hsotg-num_of_eps; ep++)
+if(hsotg-dir_of_eps[ep]  1)
+rxfifo_size += 2; // OUT endpoint

[PATCH 1/3] net: phy: Add nested variants of mdiobus read/write

2015-10-22 Thread Neil Armstrong
Since nested variants of mdiobus_read/write are used in multiple
drivers, add nested variants in the mdiobus core.

Suggested-by: Andrew Lunn <and...@lunn.ch>
Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
---
 drivers/net/phy/mdio_bus.c | 55 ++
 include/linux/phy.h|  2 ++
 2 files changed, 57 insertions(+)

diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 12f44c5..88cb459 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -372,6 +372,33 @@ struct phy_device *mdiobus_scan(struct mii_bus *bus, int 
addr)
 EXPORT_SYMBOL(mdiobus_scan);

 /**
+ * mdiobus_read_nested - Nested version of the mdiobus_read function
+ * @bus: the mii_bus struct
+ * @addr: the phy address
+ * @regnum: register number to read
+ *
+ * In case of nested MDIO bus access avoid lockdep false positives by
+ * using mutex_lock_nested().
+ *
+ * NOTE: MUST NOT be called from interrupt context,
+ * because the bus read/write functions may wait for an interrupt
+ * to conclude the operation.
+ */
+int mdiobus_read_nested(struct mii_bus *bus, int addr, u32 regnum)
+{
+   int retval;
+
+   BUG_ON(in_interrupt());
+
+   mutex_lock_nested(>mdio_lock, SINGLE_DEPTH_NESTING);
+   retval = bus->read(bus, addr, regnum);
+   mutex_unlock(>mdio_lock);
+
+   return retval;
+}
+EXPORT_SYMBOL(mdiobus_read_nested);
+
+/**
  * mdiobus_read - Convenience function for reading a given MII mgmt register
  * @bus: the mii_bus struct
  * @addr: the phy address
@@ -396,6 +423,34 @@ int mdiobus_read(struct mii_bus *bus, int addr, u32 regnum)
 EXPORT_SYMBOL(mdiobus_read);

 /**
+ * mdiobus_write_nested - Nested version of the mdiobus_write function
+ * @bus: the mii_bus struct
+ * @addr: the phy address
+ * @regnum: register number to write
+ * @val: value to write to @regnum
+ *
+ * In case of nested MDIO bus access avoid lockdep false positives by
+ * using mutex_lock_nested().
+ *
+ * NOTE: MUST NOT be called from interrupt context,
+ * because the bus read/write functions may wait for an interrupt
+ * to conclude the operation.
+ */
+int mdiobus_write_nested(struct mii_bus *bus, int addr, u32 regnum, u16 val)
+{
+   int err;
+
+   BUG_ON(in_interrupt());
+
+   mutex_lock_nested(>mdio_lock, SINGLE_DEPTH_NESTING);
+   err = bus->write(bus, addr, regnum, val);
+   mutex_unlock(>mdio_lock);
+
+   return err;
+}
+EXPORT_SYMBOL(mdiobus_write_nested);
+
+/**
  * mdiobus_write - Convenience function for writing a given MII mgmt register
  * @bus: the mii_bus struct
  * @addr: the phy address
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 4c477e6..05fde31 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -213,7 +213,9 @@ static inline struct mii_bus *devm_mdiobus_alloc(struct 
device *dev)
 void devm_mdiobus_free(struct device *dev, struct mii_bus *bus);
 struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr);
 int mdiobus_read(struct mii_bus *bus, int addr, u32 regnum);
+int mdiobus_read_nested(struct mii_bus *bus, int addr, u32 regnum);
 int mdiobus_write(struct mii_bus *bus, int addr, u32 regnum, u16 val);
+int mdiobus_write_nested(struct mii_bus *bus, int addr, u32 regnum, u16 val);


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


[PATCH 0/3] Refactor nested mdiobus read/write functions

2015-10-22 Thread Neil Armstrong
In order to avoid locked signal false positive for nested mdiobus
read/write calls, nested code was introduced in mv88e6xxx and
mdio-mux.
But mv88e6060 also needs such nested mdiobus read/write calls.
For sake of refactoring, introduce nested variants of mdiobus read/write
and make them used by mv88e6xxx and mv88e6060.
In a next patch, mdio-mux should also use these variant calls.

Neil Armstrong (3):
  net: phy: Add nested variants of mdiobus read/write
  net: dsa: Make mv88e6xxx use nested mdiobus read/write
  net: dsa: Make mv88e6060 use nested mdiobus read/write

 drivers/net/dsa/mv88e6060.c |  4 ++--
 drivers/net/dsa/mv88e6xxx.c | 46 -
 drivers/net/phy/mdio_bus.c  | 55 +
 include/linux/phy.h |  2 ++
 4 files changed, 68 insertions(+), 39 deletions(-)

-- 
1.9.1

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


Re: [PATCH] net: dsa: mv88e6060: Fix false positive lockdep splat

2015-10-22 Thread Neil Armstrong
On 10/21/2015 06:14 PM, Andrew Lunn wrote:
> On Wed, Oct 21, 2015 at 05:37:45PM +0200, Neil Armstrong wrote:
>> Like the change made for mv88e6xxx, use mutex_lock_nested() to avoid
>> lockdep to give false positives because of nested MDIO busses.
> 
> Hi Neil
> 
> We now have three instances of this, since mdio-mux.c has the same
> code. Maybe now would be a good time to refactor this code into
> mdiobus_read_nested() and mdiobus_write_nested() in mdio_bus.c?  At
> the same time, add BUG_ON(in_interrupt()) similar to the non-nested
> versions?
> 
>   Andrew
> 
Well, mdio-mux also calls switch_fn inside the mdio_lock, clean refactoring
would introduce a separate lock and call the nested variants.
Is that ok ? Can someone test mdio-mux is I make the change ?


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


Re: [PATCH] net: dsa: mv88e6060: Fix false positive lockdep splat

2015-10-22 Thread Neil Armstrong
On 10/21/2015 06:14 PM, Andrew Lunn wrote:
> On Wed, Oct 21, 2015 at 05:37:45PM +0200, Neil Armstrong wrote:
>> Like the change made for mv88e6xxx, use mutex_lock_nested() to avoid
>> lockdep to give false positives because of nested MDIO busses.
> 
> Hi Neil
> 
> We now have three instances of this, since mdio-mux.c has the same
> code. Maybe now would be a good time to refactor this code into
> mdiobus_read_nested() and mdiobus_write_nested() in mdio_bus.c?  At
> the same time, add BUG_ON(in_interrupt()) similar to the non-nested
> versions?
> 
>   Andrew
> 
Well, mdio-mux also calls switch_fn inside the mdio_lock, clean refactoring
would introduce a separate lock and call the nested variants.
Is that ok ? Can someone test mdio-mux if I make the change ?


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


Re: [PATCH] net: dsa: mv88e6060: Fix false positive lockdep splat

2015-10-22 Thread Neil Armstrong
Hi Andrew,

On 10/21/2015 06:14 PM, Andrew Lunn wrote:
> On Wed, Oct 21, 2015 at 05:37:45PM +0200, Neil Armstrong wrote:
>> Like the change made for mv88e6xxx, use mutex_lock_nested() to avoid
>> lockdep to give false positives because of nested MDIO busses.
> 
> Hi Neil
> 
> We now have three instances of this, since mdio-mux.c has the same
> code. Maybe now would be a good time to refactor this code into
> mdiobus_read_nested() and mdiobus_write_nested() in mdio_bus.c?  At
> the same time, add BUG_ON(in_interrupt()) similar to the non-nested
> versions?
> 
>   Andrew
> 
Indeed, you are right, I will post a serie with this refactoring.

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


[PATCH] net: dsa: mv88e6060: Fix false positive lockdep splat

2015-10-21 Thread Neil Armstrong
Like the change made for mv88e6xxx, use mutex_lock_nested() to avoid
lockdep to give false positives because of nested MDIO busses.

The false positive was observed using a mv88e6060 from a TI816X SoC.

Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
---
 drivers/net/dsa/mv88e6060.c | 19 +--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/drivers/net/dsa/mv88e6060.c b/drivers/net/dsa/mv88e6060.c
index c29aebe..b1db460 100644
--- a/drivers/net/dsa/mv88e6060.c
+++ b/drivers/net/dsa/mv88e6060.c
@@ -19,14 +19,24 @@
 #define REG_PORT(p)(8 + (p))
 #define REG_GLOBAL 0x0f

+/* MDIO bus access can be nested in the case of PHYs connected to the
+ * internal MDIO bus of the switch, which is accessed via MDIO bus of
+ * the Ethernet interface. Avoid lockdep false positives by using
+ * mutex_lock_nested().
+ */
 static int reg_read(struct dsa_switch *ds, int addr, int reg)
 {
+   int ret;
struct mii_bus *bus = dsa_host_dev_to_mii_bus(ds->master_dev);

if (bus == NULL)
return -EINVAL;

-   return mdiobus_read(bus, ds->pd->sw_addr + addr, reg);
+   mutex_lock_nested(>mdio_lock, SINGLE_DEPTH_NESTING);
+   ret = bus->read(bus, ds->pd->sw_addr, reg);
+   mutex_unlock(>mdio_lock);
+
+   return ret;
 }

 #define REG_READ(addr, reg)\
@@ -42,12 +52,17 @@ static int reg_read(struct dsa_switch *ds, int addr, int 
reg)

 static int reg_write(struct dsa_switch *ds, int addr, int reg, u16 val)
 {
+   int ret;
struct mii_bus *bus = dsa_host_dev_to_mii_bus(ds->master_dev);

if (bus == NULL)
return -EINVAL;

-   return mdiobus_write(bus, ds->pd->sw_addr + addr, reg, val);
+   mutex_lock_nested(>mdio_lock, SINGLE_DEPTH_NESTING);
+   ret = bus->write(bus, ds->pd->sw_addr, reg, val);
+   mutex_unlock(>mdio_lock);
+
+   return ret;
 }

 #define REG_WRITE(addr, reg, val)  \
-- 
1.9.1

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


[PATCH 3/3] net: dsa: Make mv88e6060 use nested mdiobus read/write

2015-10-22 Thread Neil Armstrong
Like mv88e6xxx and mdio-mux, to avoid lockdep give false positives
because of nested MDIO busses, switch to previously introduced
nested mdiobus_read/write variants.

Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
---
 drivers/net/dsa/mv88e6060.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/dsa/mv88e6060.c b/drivers/net/dsa/mv88e6060.c
index c29aebe..9093577 100644
--- a/drivers/net/dsa/mv88e6060.c
+++ b/drivers/net/dsa/mv88e6060.c
@@ -26,7 +26,7 @@ static int reg_read(struct dsa_switch *ds, int addr, int reg)
if (bus == NULL)
return -EINVAL;

-   return mdiobus_read(bus, ds->pd->sw_addr + addr, reg);
+   return mdiobus_read_nested(bus, ds->pd->sw_addr + addr, reg);
 }

 #define REG_READ(addr, reg)\
@@ -47,7 +47,7 @@ static int reg_write(struct dsa_switch *ds, int addr, int 
reg, u16 val)
if (bus == NULL)
return -EINVAL;

-   return mdiobus_write(bus, ds->pd->sw_addr + addr, reg, val);
+   return mdiobus_write_nested(bus, ds->pd->sw_addr + addr, reg, val);
 }

 #define REG_WRITE(addr, reg, val)  \
-- 
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/4] arm: dts: add dm816x pwm property to timers

2015-10-22 Thread Neil Armstrong
Adds ti,timer-pwm property to timers 4 to 7 to permit usage of their
PWM output fonctionnality via the dmtimer driver.

Cc: Brian Hutchinson <b.hutch...@gmail.com>
Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
---
 arch/arm/boot/dts/dm816x.dtsi | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/boot/dts/dm816x.dtsi b/arch/arm/boot/dts/dm816x.dtsi
index eee636d..51ad4a9 100644
--- a/arch/arm/boot/dts/dm816x.dtsi
+++ b/arch/arm/boot/dts/dm816x.dtsi
@@ -323,6 +323,7 @@
reg = <0x48044000 0x2000>;
interrupts = <92>;
ti,hwmods = "timer4";
+   ti,timer-pwm;
};

timer5: timer@48046000 {
@@ -330,6 +331,7 @@
reg = <0x48046000 0x2000>;
interrupts = <93>;
ti,hwmods = "timer5";
+   ti,timer-pwm;
};

timer6: timer@48048000 {
@@ -337,6 +339,7 @@
reg = <0x48048000 0x2000>;
interrupts = <94>;
ti,hwmods = "timer6";
+   ti,timer-pwm;
};

timer7: timer@4804a000 {
@@ -344,6 +347,7 @@
reg = <0x4804a000 0x2000>;
interrupts = <95>;
ti,hwmods = "timer7";
+   ti,timer-pwm;
};

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


[PATCH 1/4] arm: omap2+: add missing HWMOD_NO_IDLEST in 81xx hwmod data

2015-10-22 Thread Neil Armstrong
Add missing HWMOD_NO_IDLEST hwmod flag for entries no
having omap4 clkctrl values.

Cc: Brian Hutchinson <b.hutch...@gmail.com>
Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
---
 arch/arm/mach-omap2/omap_hwmod_81xx_data.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm/mach-omap2/omap_hwmod_81xx_data.c 
b/arch/arm/mach-omap2/omap_hwmod_81xx_data.c
index b1288f5..6256052 100644
--- a/arch/arm/mach-omap2/omap_hwmod_81xx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_81xx_data.c
@@ -144,6 +144,7 @@ static struct omap_hwmod dm81xx_l4_ls_hwmod = {
.name   = "l4_ls",
.clkdm_name = "alwon_l3s_clkdm",
.class  = _hwmod_class,
+   .flags  = HWMOD_NO_IDLEST,
 };

 /*
@@ -155,6 +156,7 @@ static struct omap_hwmod dm81xx_l4_hs_hwmod = {
.name   = "l4_hs",
.clkdm_name = "alwon_l3_med_clkdm",
.class  = _hwmod_class,
+   .flags  = HWMOD_NO_IDLEST,
 };

 /* L3 slow -> L4 ls peripheral interface running at 125MHz */
@@ -850,6 +852,7 @@ static struct omap_hwmod dm816x_emac0_hwmod = {
.name   = "emac0",
.clkdm_name = "alwon_ethernet_clkdm",
.class  = _emac_hwmod_class,
+   .flags  = HWMOD_NO_IDLEST,
 };

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


[PATCH 4/4] arm: omap2+: Add hwmod spinbox support for dm816x

2015-10-22 Thread Neil Armstrong
Add dm81xx hwmod data entries for dm816x spinbox support.

Cc: Brian Hutchinson <b.hutch...@gmail.com>
Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
---
 arch/arm/mach-omap2/omap_hwmod_81xx_data.c | 35 ++
 1 file changed, 35 insertions(+)

diff --git a/arch/arm/mach-omap2/omap_hwmod_81xx_data.c 
b/arch/arm/mach-omap2/omap_hwmod_81xx_data.c
index 6256052..275b16c 100644
--- a/arch/arm/mach-omap2/omap_hwmod_81xx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_81xx_data.c
@@ -1036,6 +1036,40 @@ static struct omap_hwmod_ocp_if dm81xx_l4_ls__mailbox = {
.user   = OCP_USER_MPU,
 };

+static struct omap_hwmod_class_sysconfig dm81xx_spinbox_sysc = {
+   .rev_offs   = 0x000,
+   .sysc_offs  = 0x010,
+   .syss_offs  = 0x014,
+   .sysc_flags = SYSC_HAS_CLOCKACTIVITY | SYSC_HAS_SIDLEMODE |
+   SYSC_HAS_SOFTRESET | SYSC_HAS_AUTOIDLE,
+   .idlemodes  = SIDLE_FORCE | SIDLE_NO | SIDLE_SMART,
+   .sysc_fields= _hwmod_sysc_type1,
+};
+
+static struct omap_hwmod_class dm81xx_spinbox_hwmod_class = {
+   .name = "spinbox",
+   .sysc = _spinbox_sysc,
+};
+
+static struct omap_hwmod dm81xx_spinbox_hwmod = {
+   .name   = "spinbox",
+   .clkdm_name = "alwon_l3s_clkdm",
+   .class  = _spinbox_hwmod_class,
+   .main_clk   = "sysclk6_ck",
+   .prcm   = {
+   .omap4 = {
+   .clkctrl_offs = DM81XX_CM_ALWON_SPINBOX_CLKCTRL,
+   .modulemode = MODULEMODE_SWCTRL,
+   },
+   },
+};
+
+static struct omap_hwmod_ocp_if dm81xx_l4_ls__spinbox = {
+   .master = _l4_ls_hwmod,
+   .slave  = _spinbox_hwmod,
+   .user   = OCP_USER_MPU,
+};
+
 static struct omap_hwmod_class dm81xx_tpcc_hwmod_class = {
.name   = "tpcc",
 };
@@ -1298,6 +1332,7 @@ static struct omap_hwmod_ocp_if *dm816x_hwmod_ocp_ifs[] 
__initdata = {
_l4_ls__timer7,
_l4_ls__mcspi1,
_l4_ls__mailbox,
+   _l4_ls__spinbox,
_l4_hs__emac0,
_emac0__mdio,
_l4_hs__emac1,
-- 
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/4] clk: ti816x: Add missing dmtimer clkdev entries

2015-10-22 Thread Neil Armstrong
Add missing clkdev dmtimer related entries for dm816x.
32Khz and ext sources were missing.

Cc: Brian Hutchinson <b.hutch...@gmail.com>
Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
---
 drivers/clk/ti/clk-816x.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/clk/ti/clk-816x.c b/drivers/clk/ti/clk-816x.c
index 1dfad0c..2a5d84f 100644
--- a/drivers/clk/ti/clk-816x.c
+++ b/drivers/clk/ti/clk-816x.c
@@ -20,6 +20,8 @@ static struct ti_dt_clk dm816x_clks[] = {
DT_CLK(NULL, "sys_clkin", "sys_clkin_ck"),
DT_CLK(NULL, "timer_sys_ck", "sys_clkin_ck"),
DT_CLK(NULL, "sys_32k_ck", "sys_32k_ck"),
+   DT_CLK(NULL, "timer_32k_ck", "sysclk18_ck"),
+   DT_CLK(NULL, "timer_ext_ck", "tclkin_ck"),
DT_CLK(NULL, "mpu_ck", "mpu_ck"),
DT_CLK(NULL, "timer1_fck", "timer1_fck"),
DT_CLK(NULL, "timer2_fck", "timer2_fck"),
-- 
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/4] arm: dts: complete dm816x device tree

2015-10-22 Thread Neil Armstrong
In order to fix support for the dm816x platform, add missing bits in
the dm816x dtsi.

The last patch adds support for the omap4-hwspinlock.

Neil Armstrong (4):
  arm: dts: add dm816x missing #mbox-cells
  arm: dts: add dm816x missing spi DT dma handles
  arm: dts: add dm816x pwm property to timers
  arm: dts: Add omap4-hwspinlock support in dm816x

 arch/arm/boot/dts/dm816x.dtsi | 19 +--
 1 file changed, 17 insertions(+), 2 deletions(-)

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


[PATCH 1/4] arm: dts: add dm816x missing #mbox-cells

2015-10-22 Thread Neil Armstrong
Add missing #mbox-cells for dm816x mbox DT node.

Cc: Brian Hutchinson <b.hutch...@gmail.com>
Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
---
 arch/arm/boot/dts/dm816x.dtsi | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/boot/dts/dm816x.dtsi b/arch/arm/boot/dts/dm816x.dtsi
index 3c99cfa..a7a34e4 100644
--- a/arch/arm/boot/dts/dm816x.dtsi
+++ b/arch/arm/boot/dts/dm816x.dtsi
@@ -218,6 +218,7 @@
reg = <0x480c8000 0x2000>;
interrupts = <77>;
ti,hwmods = "mailbox";
+   #mbox-cells = <1>;
ti,mbox-num-users = <4>;
ti,mbox-num-fifos = <12>;
mbox_dsp: mbox_dsp {
-- 
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/4] arm: dts: add dm816x missing spi DT dma handles

2015-10-22 Thread Neil Armstrong
Add the missing SPI controller DMA handler in the dm816x DT
node, only properties for the two channels on four were present.

Cc: Brian Hutchinson <b.hutch...@gmail.com>
Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
---
 arch/arm/boot/dts/dm816x.dtsi | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/dm816x.dtsi b/arch/arm/boot/dts/dm816x.dtsi
index a7a34e4..eee636d 100644
--- a/arch/arm/boot/dts/dm816x.dtsi
+++ b/arch/arm/boot/dts/dm816x.dtsi
@@ -280,8 +280,11 @@
ti,spi-num-cs = <4>;
ti,hwmods = "mcspi1";
dmas = < 16  17
-18  19>;
-   dma-names = "tx0", "rx0", "tx1", "rx1";
+18  19
+20  21
+22  23>;
+   dma-names = "tx0", "rx0", "tx1", "rx1",
+   "tx2", "rx2", "tx3", "rx3";
};

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


[PATCH 4/4] arm: dts: Add omap4-hwspinlock support in dm816x

2015-10-22 Thread Neil Armstrong
Add dm816x DT entries for omap4-hwspinlock support as hwmod spinbox.

Cc: Brian Hutchinson <b.hutch...@gmail.com>
Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
---
 arch/arm/boot/dts/dm816x.dtsi | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm/boot/dts/dm816x.dtsi b/arch/arm/boot/dts/dm816x.dtsi
index 51ad4a9..f655ce1 100644
--- a/arch/arm/boot/dts/dm816x.dtsi
+++ b/arch/arm/boot/dts/dm816x.dtsi
@@ -227,6 +227,13 @@
};
};

+   spinbox: spinbox@480ca000 {
+   compatible = "ti,omap4-hwspinlock";
+   reg = <0x480ca000 0x2000>;
+   ti,hwmods = "spinbox";
+   #hwlock-cells = <1>;
+   };
+
mdio: mdio@4a100800 {
compatible = "ti,davinci_mdio";
#address-cells = <1>;
-- 
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/4] arm: omap2+: complete dm816x hwmod and clkdev

2015-10-22 Thread Neil Armstrong
In order to fix support for the dm816x platform, add missing bits in
the 81xx hwmod data.

The clk related patch adds the missing clkdev entries to fix all source
selection in the dmtimer driver.

The last patch adds hwmod support of the spinbox module.

Neil Armstrong (4):
  arm: omap2+: add missing HWMOD_NO_IDLEST in 81xx hwmod data
  clk: ti816x: Add missing dmtimer clkdev entries
  arm: plat-omap: add DT support for ti,dm816-timer
  arm: omap2+: Add hwmod spinbox support for dm816x

 arch/arm/mach-omap2/omap_hwmod_81xx_data.c | 38 ++
 arch/arm/plat-omap/dmtimer.c   |  4 
 drivers/clk/ti/clk-816x.c  |  2 ++
 3 files changed, 44 insertions(+)

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


[PATCH 3/4] arm: plat-omap: add DT support for ti,dm816-timer

2015-10-22 Thread Neil Armstrong
Adds ti,dm816-timer to the dmtimer OF match table.

Cc: Brian Hutchinson <b.hutch...@gmail.com>
Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
---
 arch/arm/plat-omap/dmtimer.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/plat-omap/dmtimer.c b/arch/arm/plat-omap/dmtimer.c
index 8ca94d3..28a6550 100644
--- a/arch/arm/plat-omap/dmtimer.c
+++ b/arch/arm/plat-omap/dmtimer.c
@@ -943,6 +943,10 @@ static const struct of_device_id omap_timer_match[] = {
.compatible = "ti,am335x-timer-1ms",
.data = _pdata,
},
+   {
+   .compatible = "ti,dm816-timer",
+   .data = _pdata,
+   },
{},
 };
 MODULE_DEVICE_TABLE(of, omap_timer_match);
-- 
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 5/6] net: dsa: add missing calls in dsa_switch_destroy

2015-10-29 Thread Neil Armstrong
On 10/29/2015 03:00 PM, Andrew Lunn wrote:
> On Thu, Oct 29, 2015 at 02:23:25PM +0100, Neil Armstrong wrote:
>>
>> +netif_carrier_off(ds->ports[port]);
>>  unregister_netdev(ds->ports[port]);
>> +phy_disconnect(p->phy);
>>  free_netdev(ds->ports[port]);
>>  }
> 
> Once you make it actually compile
> 
> I'm not sure this is safe. The loop above this one has just destroyed
> some phys, and now you are potentially disconnecting a phy you just
> destroyed, causing it to be accessed?
> 
> I would suggest you first fix the ordering in dsa_switch_destroy()
> and then add the missing netif_carrier_off() and phy_disconnect().
> 
> Thanks
>   Andrew
> 

Yes, you are right, I will submit a cleaned up version.
I forgot the fixed phy case actually.

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


[PATCH v2 1/6] net: dsa: Use delayed work instead of timer+work for polling

2015-10-29 Thread Neil Armstrong
Simplifies the code and avoids a crash when removing the
module:
 dsa dsa ethmv2 (unregistering): Link is Down
 device eth1 left promiscuous mode
 Unable to handle kernel paging request at virtual address bacc5cf6
 ...
 (run_timer_softirq) from [] (__do_softirq+0xcc/0x320)
 (__do_softirq) from [] (irq_exit+0xac/0x10c)
 (irq_exit) from [] (__handle_domain_irq+0x50/0xa8)

Signed-off-by: Frode Isaksen <fisak...@baylibre.com>
Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
---
 include/net/dsa.h |  3 +--
 net/dsa/dsa.c | 28 
 2 files changed, 9 insertions(+), 22 deletions(-)

diff --git a/include/net/dsa.h b/include/net/dsa.h
index 98ccbde..d4d13f7 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -112,8 +112,7 @@ struct dsa_switch_tree {
 * Link state polling.
 */
int link_poll_needed;
-   struct work_struct  link_poll_work;
-   struct timer_list   link_poll_timer;
+   struct delayed_work link_poll_work;

/*
 * Data for the individual switch chips.
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 1eba07f..aeb6a7c 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -513,7 +513,7 @@ static void dsa_link_poll_work(struct work_struct *ugly)
struct dsa_switch_tree *dst;
int i;

-   dst = container_of(ugly, struct dsa_switch_tree, link_poll_work);
+   dst = container_of(ugly, struct dsa_switch_tree, link_poll_work.work);

for (i = 0; i < dst->pd->nr_chips; i++) {
struct dsa_switch *ds = dst->ds[i];
@@ -522,17 +522,9 @@ static void dsa_link_poll_work(struct work_struct *ugly)
ds->drv->poll_link(ds);
}

-   mod_timer(>link_poll_timer, round_jiffies(jiffies + HZ));
+   schedule_delayed_work(>link_poll_work, round_jiffies_relative(HZ));
 }

-static void dsa_link_poll_timer(unsigned long _dst)
-{
-   struct dsa_switch_tree *dst = (void *)_dst;
-
-   schedule_work(>link_poll_work);
-}
-
-
 /* platform driver init and cleanup */
 static int dev_is_class(struct device *dev, void *class)
 {
@@ -880,12 +872,8 @@ static int dsa_setup_dst(struct dsa_switch_tree *dst, 
struct net_device *dev,
dev->dsa_ptr = (void *)dst;

if (dst->link_poll_needed) {
-   INIT_WORK(>link_poll_work, dsa_link_poll_work);
-   init_timer(>link_poll_timer);
-   dst->link_poll_timer.data = (unsigned long)dst;
-   dst->link_poll_timer.function = dsa_link_poll_timer;
-   dst->link_poll_timer.expires = round_jiffies(jiffies + HZ);
-   add_timer(>link_poll_timer);
+   INIT_DELAYED_WORK(>link_poll_work, dsa_link_poll_work);
+   schedule_delayed_work(>link_poll_work, 
round_jiffies_relative(HZ));
}

return 0;
@@ -954,10 +942,10 @@ static void dsa_remove_dst(struct dsa_switch_tree *dst)
 {
int i;

-   if (dst->link_poll_needed)
-   del_timer_sync(>link_poll_timer);
-
-   flush_work(>link_poll_work);
+   if (dst->link_poll_needed) {
+   cancel_delayed_work_sync(>link_poll_work);
+   flush_delayed_work(>link_poll_work);
+   }

for (i = 0; i < dst->pd->nr_chips; i++) {
struct dsa_switch *ds = dst->ds[i];
-- 
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 4/6] net: dsa: Add missing master netdev dev_put() calls

2015-10-29 Thread Neil Armstrong
Upon probe failure or unbinding, add missing dev_put() calls on
master netdev.

Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
---
 net/dsa/dsa.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index b2f696c..597a462 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -928,8 +928,10 @@ static int dsa_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, dst);

ret = dsa_setup_dst(dst, dev, >dev, pd);
-   if (ret)
+   if (ret) {
+   dev_put(dev);
goto out;
+   }

return 0;

@@ -963,6 +965,8 @@ static void dsa_remove_dst(struct dsa_switch_tree *dst)
if (ds)
dsa_switch_destroy(ds);
}
+
+   dev_put(dst->master_netdev);
 }

 static int dsa_remove(struct platform_device *pdev)
-- 
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 6/6] net: dsa: move dsa slave destroy code to slave.c

2015-10-29 Thread Neil Armstrong
Move dsa slave dedicated code from dsa_switch_destroy to a new
dsa_slave_destroy function in slave.c

Signed-off-by: Frode Isaksen <fisak...@baylibre.com>
Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
---
 net/dsa/dsa.c  |  5 +
 net/dsa/dsa_priv.h |  1 +
 net/dsa/slave.c| 10 ++
 3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 11452e4..cf6b092 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -454,10 +454,7 @@ static void dsa_switch_destroy(struct dsa_switch *ds)
if (!ds->ports[port])
continue;

-   netif_carrier_off(ds->ports[port]);
-   unregister_netdev(ds->ports[port]);
-   phy_disconnect(p->phy);
-   free_netdev(ds->ports[port]);
+   dsa_slave_destroy(ds->ports[port]);
}

mdiobus_unregister(ds->slave_mii_bus);
diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h
index 311796c8..1d1a546 100644
--- a/net/dsa/dsa_priv.h
+++ b/net/dsa/dsa_priv.h
@@ -61,6 +61,7 @@ extern const struct dsa_device_ops notag_netdev_ops;
 void dsa_slave_mii_bus_init(struct dsa_switch *ds);
 int dsa_slave_create(struct dsa_switch *ds, struct device *parent,
 int port, char *name);
+void dsa_slave_destroy(struct net_device *slave_dev);
 int dsa_slave_suspend(struct net_device *slave_dev);
 int dsa_slave_resume(struct net_device *slave_dev);
 int dsa_slave_netdevice_event(struct notifier_block *unused,
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 481754e..f77e5bd 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -1223,6 +1223,16 @@ int dsa_slave_create(struct dsa_switch *ds, struct 
device *parent,
return 0;
 }

+void dsa_slave_destroy(struct net_device *slave_dev)
+{
+   struct dsa_slave_priv *p = netdev_priv(slave_dev);
+
+   netif_carrier_off(slave_dev);
+   unregister_netdev(slave_dev);
+   phy_disconnect(p->phy);
+   free_netdev(slave_dev);
+}
+
 static bool dsa_slave_dev_check(struct net_device *dev)
 {
return dev->netdev_ops == _slave_netdev_ops;
-- 
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 5/6] net: dsa: add missing calls in dsa_switch_destroy

2015-10-29 Thread Neil Armstrong
Add missing netif_carrier_off and phy_disconnect calls to the
dsa_switch_destroy function to make sure the netdev and phy
ressources are clean before complete removal.

Signed-off-by: Frode Isaksen <fisak...@baylibre.com>
Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
---
 net/dsa/dsa.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 597a462..11452e4 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -454,7 +454,9 @@ static void dsa_switch_destroy(struct dsa_switch *ds)
if (!ds->ports[port])
continue;

+   netif_carrier_off(ds->ports[port]);
unregister_netdev(ds->ports[port]);
+   phy_disconnect(p->phy);
free_netdev(ds->ports[port]);
}

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


[PATCH v2 0/6] Further fix for dsa unbinding

2015-10-29 Thread Neil Armstrong
This serie fixes further issues for DSA dynamic unbinding.
Frode Isaksen's patches make usage of delayed work and fixes kernel
crashes when dsa is unbind.
The other patches are simple fixes to permit cleanup and avoid netdev
related crashes.

v2: remove phy fix and add missing calls in dsa_switch_destroy
then add dedicated dsa_slave_destroy

Frode Isaksen (4):
  net: dsa: Use delayed work instead of timer+work for polling
  net: dsa: Do not reschedule polling if driver removed
  net: dsa: add missing calls in dsa_switch_destroy
  net: dsa: move dsa slave destroy code to slave.c

Neil Armstrong (2):
  net: dsa: cleanup resources upon module removal
  net: dsa: Add missing master netdev dev_put() calls

 include/net/dsa.h  |  3 +--
 net/dsa/dsa.c  | 45 +++--
 net/dsa/dsa_priv.h |  1 +
 net/dsa/slave.c| 10 ++
 4 files changed, 35 insertions(+), 24 deletions(-)

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


Re: [PATCH v2 1/6] net: dsa: Use delayed work instead of timer+work for polling

2015-10-29 Thread Neil Armstrong
On 10/29/2015 02:51 PM, Andrew Lunn wrote:
> On Thu, Oct 29, 2015 at 02:22:41PM +0100, Neil Armstrong wrote:
> Hi Neil, Frode
> 
> I assume you have see:
> 
> http://permalink.gmane.org/gmane.linux.network/380777
> 
> which is now in net-next.
> 
> The only driver making use of poll_link is mv88e6060.c. The argument
> from removing it from the other mv88e6xxx drivers is that it is not
> needed. The phylib will be polling the phys and looking for state
> changes. mv88e6060.c implements phy_read() and phy_write() so it
> should also allow the use of phylib.
> 
> Could you try 6060 without .poll_link. If that works, we should be
> able to remove all this code, rather than fix it up.
> 
>  Andrew
> 
Hi Andrew,

Thanks for the hint, I will test this, but while reviewing the datasheet,
the port 5 has no PHY, so must only be used as cpu port.

I also have another patchset which fixes 2 setup registers writes and
adds a shiny new mv88e6060.h based on mv88e6xxx.h.
I think the removal of the poll_link in mv88e6060 should be in this patchset.

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


[PATCH v2 2/6] net: dsa: Do not reschedule polling if driver removed

2015-10-29 Thread Neil Armstrong
Do not reschedule the delayed work used for polling when
the driver is removed, by testing the 'poll_link_needed'
flag.
Avoids this crash:
 dsa dsa ethmv2 (unregistering): Link is Down
 device eth1 left promiscuous mode
 Unable to handle kernel paging request at virtual address bacc5cf6
 ...
 (run_timer_softirq) from [] (__do_softirq+0xcc/0x320)
 (__do_softirq) from [] (irq_exit+0xac/0x10c)
 (irq_exit) from [] (__handle_domain_irq+0x50/0xa8)

Signed-off-by: Frode Isaksen <fisak...@baylibre.com>
Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
---
 net/dsa/dsa.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index aeb6a7c..19cff8f 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -522,7 +522,8 @@ static void dsa_link_poll_work(struct work_struct *ugly)
ds->drv->poll_link(ds);
}

-   schedule_delayed_work(>link_poll_work, round_jiffies_relative(HZ));
+   if (dst->link_poll_needed)
+   schedule_delayed_work(>link_poll_work, 
round_jiffies_relative(HZ));
 }

 /* platform driver init and cleanup */
@@ -943,6 +944,7 @@ static void dsa_remove_dst(struct dsa_switch_tree *dst)
int i;

if (dst->link_poll_needed) {
+   dst->link_poll_needed = 0;
cancel_delayed_work_sync(>link_poll_work);
flush_delayed_work(>link_poll_work);
}
-- 
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 3/6] net: dsa: cleanup resources upon module removal

2015-10-29 Thread Neil Armstrong
Make sure that we unassign the master_netdev dsa_ptr to make the packet
processing go through the regulard Ethernet receive path.

Suggested-by: Florian Fainelli <f.faine...@gmail.com>
Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
---
 net/dsa/dsa.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 19cff8f..b2f696c 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -949,6 +949,14 @@ static void dsa_remove_dst(struct dsa_switch_tree *dst)
flush_delayed_work(>link_poll_work);
}

+   dst->master_netdev->dsa_ptr = NULL;
+
+   /* If we used a tagging format that doesn't have an ethertype
+* field, make sure that all packets from this point get sent
+* without the tag and go through the regular receive path.
+*/
+   wmb();
+
for (i = 0; i < dst->pd->nr_chips; i++) {
struct dsa_switch *ds = dst->ds[i];

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


[RFC PATCH v2 1/4] net: dsa: allow switch drivers to cleanup their resources

2015-10-28 Thread Neil Armstrong
Some switch drivers might request interrupts, remap register ranges,
allow such drivers to implement a "remove" callback doing just that.

Signed-off-by: Florian Fainelli <f.faine...@gmail.com>
Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
---
 include/net/dsa.h | 1 +
 net/dsa/dsa.c | 4 
 2 files changed, 5 insertions(+)

diff --git a/include/net/dsa.h b/include/net/dsa.h
index 98ccbde..0e1502c 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -212,6 +212,7 @@ struct dsa_switch_driver {
 */
char*(*probe)(struct device *host_dev, int sw_addr);
int (*setup)(struct dsa_switch *ds);
+   void(*remove)(struct dsa_switch *ds);
int (*set_addr)(struct dsa_switch *ds, u8 *addr);
u32 (*get_phy_flags)(struct dsa_switch *ds, int port);

diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 1eba07f..f462fc5 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -459,6 +459,10 @@ static void dsa_switch_destroy(struct dsa_switch *ds)
}

mdiobus_unregister(ds->slave_mii_bus);
+
+   /* Leave a chance to the driver to cleanup */
+   if (ds->drv->remove)
+   ds->drv->remove(ds);
 }

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


[RFC PATCH v2 2/4] net: dsa: bcm_sf2: cleanup resources in remove callback

2015-10-28 Thread Neil Armstrong
Implement a remove callback allowing the switch driver to cleanup
resources it used: interrupts and remapped register ranges.

Signed-off-by: Florian Fainelli <f.faine...@gmail.com>
Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
---
 drivers/net/dsa/bcm_sf2.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
index 6f946fe..e0be318 100644
--- a/drivers/net/dsa/bcm_sf2.c
+++ b/drivers/net/dsa/bcm_sf2.c
@@ -1054,6 +1054,25 @@ out_unmap:
return ret;
 }

+static void bcm_sf2_sw_remove(struct dsa_switch *ds)
+{
+   struct bcm_sf2_priv *priv = ds_to_priv(ds);
+   void __iomem **base;
+   unsigned int i;
+
+   /* Disable all interrupts and free them */
+   bcm_sf2_intr_disable(priv);
+
+   free_irq(priv->irq0, priv);
+   free_irq(priv->irq1, priv);
+
+   base = >core;
+   for (i = 0; i < BCM_SF2_REGS_NUM; i++) {
+   iounmap(*base);
+   base++;
+   }
+}
+
 static int bcm_sf2_sw_set_addr(struct dsa_switch *ds, u8 *addr)
 {
return 0;
@@ -1367,6 +1386,7 @@ static struct dsa_switch_driver bcm_sf2_switch_driver = {
.tag_protocol   = DSA_TAG_PROTO_BRCM,
.priv_size  = sizeof(struct bcm_sf2_priv),
.probe  = bcm_sf2_sw_probe,
+   .remove = bcm_sf2_sw_remove,
.setup  = bcm_sf2_sw_setup,
.set_addr   = bcm_sf2_sw_set_addr,
.get_phy_flags  = bcm_sf2_sw_get_phy_flags,
-- 
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2 0/4] net: dsa: cleanup dsa driver

2015-10-28 Thread Neil Armstrong
Introduce a new remove callback to allow DSA drivers to cleanup their
ressources.
Then add a remove implementation for bcm_sf2 and mv88e6xxx.

This patch was not tested due of a lack of hardware.

v2: add remove callback patch to the serie

Neil Armstrong (4):
  net: dsa: allow switch drivers to cleanup their resources
  net: dsa: bcm_sf2: cleanup resources in remove callback
  net: dsa: mv88e6xxx: add common and ppu remove function
  net: dsa: make usage of mv88e6xxx common remove function

 drivers/net/dsa/bcm_sf2.c | 20 
 drivers/net/dsa/mv88e6123_61_65.c |  1 +
 drivers/net/dsa/mv88e6131.c   |  8 
 drivers/net/dsa/mv88e6171.c   |  1 +
 drivers/net/dsa/mv88e6352.c   |  1 +
 drivers/net/dsa/mv88e6xxx.c   | 18 ++
 drivers/net/dsa/mv88e6xxx.h   |  2 ++
 include/net/dsa.h |  1 +
 net/dsa/dsa.c |  4 
 9 files changed, 56 insertions(+)

-- 
1.9.1

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


Re: [PATCH 6/6] net: phy: Stop 'phy-state-machine' and 'phy_change' work on remove

2015-10-28 Thread Neil Armstrong
> > void phy_disconnect(struct phy_device *phydev)
> > {
> > if (phydev->irq > 0)
> > phy_stop_interrupts(phydev);
> >
> > phy_stop_machine(phydev);
> >
> > phydev->adjust_link = NULL;
> >
> > phy_detach(phydev);
> > }
> 
> And this does not yet get called. It probably needs to be in
> dsa_switch_destroy() just before unregister_netdev() of the slave
> devices.
> 
> However, the ordering in dsa_switch_destroy() looks wrong. The fixed
> phys are destroyed before the slave devices. They should probably be
> destroyed after the slave devices, or at least after the
> phy_disconnect() is called.
> 
>  Andrew
> 

Andrew, Florian,

Thanks for the review, a call to phy_disconnect was missing in 
dsa_switch_destroy.

I will post a new patchset with the correct fix, a switch to delayed_work and
a separate dsa_slave_destroy function for sake of maintenance ease.

Neil

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


Re: [RFC PATCH v2 3/4] net: dsa: mv88e6xxx: add common and ppu remove function

2015-10-28 Thread Neil Armstrong
Hi Andrew,

On 10/28/2015 03:35 PM, Andrew Lunn wrote:
> On Wed, Oct 28, 2015 at 03:13:16PM +0100, Neil Armstrong wrote:
>> diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
>> index b1b14f5..6287096 100644
>> --- a/drivers/net/dsa/mv88e6xxx.c
>> +++ b/drivers/net/dsa/mv88e6xxx.c
>> @@ -331,6 +331,16 @@ void mv88e6xxx_ppu_state_init(struct dsa_switch *ds)
>>  ps->ppu_timer.function = mv88e6xxx_ppu_reenable_timer;
>>  }
>>
>> +void mv88e6xxx_ppu_state_remove(struct dsa_switch *ds)
>> +{
>> +struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
>> +
>> +del_timer_sync(>ppu_timer);
>> +
>> +cancel_work_sync(>bridge_work);
>> +flush_work(>bridge_work);
>> +}
>> +
> 
> You add this function, but you don't use it anywhere?  Also, why
> cancel bridge work, not ppu_work? Or has that been consolidated
> in some patch i'm missing?
> 
>Andrew
> 

It's called in the next patch, in mv88e6131_remove for mv88e6131.

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


Re: [PATCH 2/6] net: dsa: allow switch drivers to cleanup their resources

2015-10-28 Thread Neil Armstrong
On 10/27/2015 05:59 PM, Vivien Didelot wrote:
> On Oct. Tuesday 27 (44) 04:43 PM, Neil Armstrong wrote:
>>
>> Yes, I didn't know how to handle this since it was part of a larger patch.
>>
>> I forgot to add this into the cover-letter but I wanted to send an RFC serie 
>> with
>> your bcm remove patch and a mv88e6xxx remove experimental code.
>>
>> Yet, the mv88e6060 does not make usage of this.
> 
> So this patch must be part of your RFC for module removal instead of
> this patchset.
> 
> Thanks,
> -v
> 

Vivien, Florian,

Thanks for the review, I will integrate it in the other RFC patchset with the 
correct Signed-off-by tag.

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


[RFC PATCH v2 3/4] net: dsa: mv88e6xxx: add common and ppu remove function

2015-10-28 Thread Neil Armstrong
With the previously introduced remove callback, add a
mv88e6xxx common remove function to cleanup all resources.

Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
---
 drivers/net/dsa/mv88e6xxx.c | 18 ++
 drivers/net/dsa/mv88e6xxx.h |  2 ++
 2 files changed, 20 insertions(+)

diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
index b1b14f5..6287096 100644
--- a/drivers/net/dsa/mv88e6xxx.c
+++ b/drivers/net/dsa/mv88e6xxx.c
@@ -331,6 +331,16 @@ void mv88e6xxx_ppu_state_init(struct dsa_switch *ds)
ps->ppu_timer.function = mv88e6xxx_ppu_reenable_timer;
 }

+void mv88e6xxx_ppu_state_remove(struct dsa_switch *ds)
+{
+   struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
+   
+   del_timer_sync(>ppu_timer);
+
+   cancel_work_sync(>bridge_work);
+   flush_work(>bridge_work);
+}
+
 int mv88e6xxx_phy_read_ppu(struct dsa_switch *ds, int addr, int regnum)
 {
int ret;
@@ -2083,6 +2093,14 @@ int mv88e6xxx_setup_common(struct dsa_switch *ds)
return 0;
 }

+void mv88e6xxx_remove_common(struct dsa_switch *ds)
+{
+   struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
+
+   cancel_work_sync(>bridge_work);
+   flush_work(>bridge_work);
+}
+
 int mv88e6xxx_setup_global(struct dsa_switch *ds)
 {
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
diff --git a/drivers/net/dsa/mv88e6xxx.h b/drivers/net/dsa/mv88e6xxx.h
index 6f9ed5d..64d37a0 100644
--- a/drivers/net/dsa/mv88e6xxx.h
+++ b/drivers/net/dsa/mv88e6xxx.h
@@ -417,6 +417,7 @@ struct mv88e6xxx_hw_stat {
 int mv88e6xxx_switch_reset(struct dsa_switch *ds, bool ppu_active);
 int mv88e6xxx_setup_ports(struct dsa_switch *ds);
 int mv88e6xxx_setup_common(struct dsa_switch *ds);
+void mv88e6xxx_remove_common(struct dsa_switch *ds);
 int mv88e6xxx_setup_global(struct dsa_switch *ds);
 int __mv88e6xxx_reg_read(struct mii_bus *bus, int sw_addr, int addr, int reg);
 int mv88e6xxx_reg_read(struct dsa_switch *ds, int addr, int reg);
@@ -431,6 +432,7 @@ int mv88e6xxx_phy_read_indirect(struct dsa_switch *ds, int 
port, int regnum);
 int mv88e6xxx_phy_write_indirect(struct dsa_switch *ds, int port, int regnum,
 u16 val);
 void mv88e6xxx_ppu_state_init(struct dsa_switch *ds);
+void mv88e6xxx_ppu_state_remove(struct dsa_switch *ds);
 int mv88e6xxx_phy_read_ppu(struct dsa_switch *ds, int addr, int regnum);
 int mv88e6xxx_phy_write_ppu(struct dsa_switch *ds, int addr,
int regnum, u16 val);
-- 
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2 4/4] net: dsa: make usage of mv88e6xxx common remove function

2015-10-28 Thread Neil Armstrong
Make usage of previously introduced mv88e6xxx common remove
function in all mv88e6xxx drivers.

Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
---
 drivers/net/dsa/mv88e6123_61_65.c | 1 +
 drivers/net/dsa/mv88e6131.c   | 8 
 drivers/net/dsa/mv88e6171.c   | 1 +
 drivers/net/dsa/mv88e6352.c   | 1 +
 4 files changed, 11 insertions(+)

diff --git a/drivers/net/dsa/mv88e6123_61_65.c 
b/drivers/net/dsa/mv88e6123_61_65.c
index 4bcfd68..1773c99 100644
--- a/drivers/net/dsa/mv88e6123_61_65.c
+++ b/drivers/net/dsa/mv88e6123_61_65.c
@@ -122,6 +122,7 @@ struct dsa_switch_driver mv88e6123_61_65_switch_driver = {
.priv_size  = sizeof(struct mv88e6xxx_priv_state),
.probe  = mv88e6123_61_65_probe,
.setup  = mv88e6123_61_65_setup,
+   .remove = mv88e6xxx_remove_common,
.set_addr   = mv88e6xxx_set_addr_indirect,
.phy_read   = mv88e6xxx_phy_read,
.phy_write  = mv88e6xxx_phy_write,
diff --git a/drivers/net/dsa/mv88e6131.c b/drivers/net/dsa/mv88e6131.c
index c73121c..0f559b4 100644
--- a/drivers/net/dsa/mv88e6131.c
+++ b/drivers/net/dsa/mv88e6131.c
@@ -137,6 +137,13 @@ static int mv88e6131_setup(struct dsa_switch *ds)
return mv88e6xxx_setup_ports(ds);
 }

+static void mv88e6131_remove(struct dsa_switch *ds)
+{
+   mv88e6xxx_ppu_state_remove(ds);
+
+   mv88e6xxx_remove_common(ds);
+}
+
 static int mv88e6131_port_to_phy_addr(struct dsa_switch *ds, int port)
 {
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
@@ -175,6 +182,7 @@ struct dsa_switch_driver mv88e6131_switch_driver = {
.priv_size  = sizeof(struct mv88e6xxx_priv_state),
.probe  = mv88e6131_probe,
.setup  = mv88e6131_setup,
+   .remove = mv88e6131_remove,
.set_addr   = mv88e6xxx_set_addr_direct,
.phy_read   = mv88e6131_phy_read,
.phy_write  = mv88e6131_phy_write,
diff --git a/drivers/net/dsa/mv88e6171.c b/drivers/net/dsa/mv88e6171.c
index 2c8eb6f..382529b 100644
--- a/drivers/net/dsa/mv88e6171.c
+++ b/drivers/net/dsa/mv88e6171.c
@@ -101,6 +101,7 @@ struct dsa_switch_driver mv88e6171_switch_driver = {
.priv_size  = sizeof(struct mv88e6xxx_priv_state),
.probe  = mv88e6171_probe,
.setup  = mv88e6171_setup,
+   .remove = mv88e6xxx_remove_common,
.set_addr   = mv88e6xxx_set_addr_indirect,
.phy_read   = mv88e6xxx_phy_read_indirect,
.phy_write  = mv88e6xxx_phy_write_indirect,
diff --git a/drivers/net/dsa/mv88e6352.c b/drivers/net/dsa/mv88e6352.c
index cbf4dd8..7938901 100644
--- a/drivers/net/dsa/mv88e6352.c
+++ b/drivers/net/dsa/mv88e6352.c
@@ -321,6 +321,7 @@ struct dsa_switch_driver mv88e6352_switch_driver = {
.priv_size  = sizeof(struct mv88e6xxx_priv_state),
.probe  = mv88e6352_probe,
.setup  = mv88e6352_setup,
+   .remove = mv88e6xxx_remove_common,
.set_addr   = mv88e6xxx_set_addr_indirect,
.phy_read   = mv88e6xxx_phy_read_indirect,
.phy_write  = mv88e6xxx_phy_write_indirect,
-- 
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v3 5/5] net: dsa: add mv88e6xxx ppu remove function for mv88e6131

2015-10-29 Thread Neil Armstrong
The mv88e6131 also need to call remove for the ppu part of mv88e6xxx.
Add the ppu remove function and add a mv88e6131 specific remove
callback calling the ppu remove function.

Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
---
 drivers/net/dsa/mv88e6131.c |  9 -
 drivers/net/dsa/mv88e6xxx.c | 10 ++
 drivers/net/dsa/mv88e6xxx.h |  1 +
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/drivers/net/dsa/mv88e6131.c b/drivers/net/dsa/mv88e6131.c
index 677a6cb..0f559b4 100644
--- a/drivers/net/dsa/mv88e6131.c
+++ b/drivers/net/dsa/mv88e6131.c
@@ -137,6 +137,13 @@ static int mv88e6131_setup(struct dsa_switch *ds)
return mv88e6xxx_setup_ports(ds);
 }

+static void mv88e6131_remove(struct dsa_switch *ds)
+{
+   mv88e6xxx_ppu_state_remove(ds);
+
+   mv88e6xxx_remove_common(ds);
+}
+
 static int mv88e6131_port_to_phy_addr(struct dsa_switch *ds, int port)
 {
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
@@ -175,7 +182,7 @@ struct dsa_switch_driver mv88e6131_switch_driver = {
.priv_size  = sizeof(struct mv88e6xxx_priv_state),
.probe  = mv88e6131_probe,
.setup  = mv88e6131_setup,
-   .remove = mv88e6xxx_remove_common,
+   .remove = mv88e6131_remove,
.set_addr   = mv88e6xxx_set_addr_direct,
.phy_read   = mv88e6131_phy_read,
.phy_write  = mv88e6131_phy_write,
diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
index 3bd63f1..820b651 100644
--- a/drivers/net/dsa/mv88e6xxx.c
+++ b/drivers/net/dsa/mv88e6xxx.c
@@ -331,6 +331,16 @@ void mv88e6xxx_ppu_state_init(struct dsa_switch *ds)
ps->ppu_timer.function = mv88e6xxx_ppu_reenable_timer;
 }

+void mv88e6xxx_ppu_state_remove(struct dsa_switch *ds)
+{
+   struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
+
+   del_timer_sync(>ppu_timer);
+
+   cancel_work_sync(>ppu_work);
+   flush_work(>ppu_work);
+}
+
 int mv88e6xxx_phy_read_ppu(struct dsa_switch *ds, int addr, int regnum)
 {
int ret;
diff --git a/drivers/net/dsa/mv88e6xxx.h b/drivers/net/dsa/mv88e6xxx.h
index 60acaaf..64d37a0 100644
--- a/drivers/net/dsa/mv88e6xxx.h
+++ b/drivers/net/dsa/mv88e6xxx.h
@@ -432,6 +432,7 @@ int mv88e6xxx_phy_read_indirect(struct dsa_switch *ds, int 
port, int regnum);
 int mv88e6xxx_phy_write_indirect(struct dsa_switch *ds, int port, int regnum,
 u16 val);
 void mv88e6xxx_ppu_state_init(struct dsa_switch *ds);
+void mv88e6xxx_ppu_state_remove(struct dsa_switch *ds);
 int mv88e6xxx_phy_read_ppu(struct dsa_switch *ds, int addr, int regnum);
 int mv88e6xxx_phy_write_ppu(struct dsa_switch *ds, int addr,
int regnum, u16 val);
-- 
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v3 3/5] net: dsa: mv88e6xxx: add common remove function

2015-10-29 Thread Neil Armstrong
With the previously introduced remove callback, add a
mv88e6xxx common remove function to cleanup all resources.

Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
---
 drivers/net/dsa/mv88e6xxx.c | 8 
 drivers/net/dsa/mv88e6xxx.h | 1 +
 2 files changed, 9 insertions(+)

diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
index b1b14f5..3bd63f1 100644
--- a/drivers/net/dsa/mv88e6xxx.c
+++ b/drivers/net/dsa/mv88e6xxx.c
@@ -2083,6 +2083,14 @@ int mv88e6xxx_setup_common(struct dsa_switch *ds)
return 0;
 }

+void mv88e6xxx_remove_common(struct dsa_switch *ds)
+{
+   struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
+
+   cancel_work_sync(>bridge_work);
+   flush_work(>bridge_work);
+}
+
 int mv88e6xxx_setup_global(struct dsa_switch *ds)
 {
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
diff --git a/drivers/net/dsa/mv88e6xxx.h b/drivers/net/dsa/mv88e6xxx.h
index 6f9ed5d..60acaaf 100644
--- a/drivers/net/dsa/mv88e6xxx.h
+++ b/drivers/net/dsa/mv88e6xxx.h
@@ -417,6 +417,7 @@ struct mv88e6xxx_hw_stat {
 int mv88e6xxx_switch_reset(struct dsa_switch *ds, bool ppu_active);
 int mv88e6xxx_setup_ports(struct dsa_switch *ds);
 int mv88e6xxx_setup_common(struct dsa_switch *ds);
+void mv88e6xxx_remove_common(struct dsa_switch *ds);
 int mv88e6xxx_setup_global(struct dsa_switch *ds);
 int __mv88e6xxx_reg_read(struct mii_bus *bus, int sw_addr, int addr, int reg);
 int mv88e6xxx_reg_read(struct dsa_switch *ds, int addr, int reg);
-- 
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v3 4/5] net: dsa: make usage of mv88e6xxx common remove function

2015-10-29 Thread Neil Armstrong
Make usage of previously introduced mv88e6xxx common remove
function in all mv88e6xxx drivers.

Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
---
 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 +
 4 files changed, 4 insertions(+)

diff --git a/drivers/net/dsa/mv88e6123_61_65.c 
b/drivers/net/dsa/mv88e6123_61_65.c
index 4bcfd68..1773c99 100644
--- a/drivers/net/dsa/mv88e6123_61_65.c
+++ b/drivers/net/dsa/mv88e6123_61_65.c
@@ -122,6 +122,7 @@ struct dsa_switch_driver mv88e6123_61_65_switch_driver = {
.priv_size  = sizeof(struct mv88e6xxx_priv_state),
.probe  = mv88e6123_61_65_probe,
.setup  = mv88e6123_61_65_setup,
+   .remove = mv88e6xxx_remove_common,
.set_addr   = mv88e6xxx_set_addr_indirect,
.phy_read   = mv88e6xxx_phy_read,
.phy_write  = mv88e6xxx_phy_write,
diff --git a/drivers/net/dsa/mv88e6131.c b/drivers/net/dsa/mv88e6131.c
index c73121c..677a6cb 100644
--- a/drivers/net/dsa/mv88e6131.c
+++ b/drivers/net/dsa/mv88e6131.c
@@ -175,6 +175,7 @@ struct dsa_switch_driver mv88e6131_switch_driver = {
.priv_size  = sizeof(struct mv88e6xxx_priv_state),
.probe  = mv88e6131_probe,
.setup  = mv88e6131_setup,
+   .remove = mv88e6xxx_remove_common,
.set_addr   = mv88e6xxx_set_addr_direct,
.phy_read   = mv88e6131_phy_read,
.phy_write  = mv88e6131_phy_write,
diff --git a/drivers/net/dsa/mv88e6171.c b/drivers/net/dsa/mv88e6171.c
index 2c8eb6f..382529b 100644
--- a/drivers/net/dsa/mv88e6171.c
+++ b/drivers/net/dsa/mv88e6171.c
@@ -101,6 +101,7 @@ struct dsa_switch_driver mv88e6171_switch_driver = {
.priv_size  = sizeof(struct mv88e6xxx_priv_state),
.probe  = mv88e6171_probe,
.setup  = mv88e6171_setup,
+   .remove = mv88e6xxx_remove_common,
.set_addr   = mv88e6xxx_set_addr_indirect,
.phy_read   = mv88e6xxx_phy_read_indirect,
.phy_write  = mv88e6xxx_phy_write_indirect,
diff --git a/drivers/net/dsa/mv88e6352.c b/drivers/net/dsa/mv88e6352.c
index cbf4dd8..7938901 100644
--- a/drivers/net/dsa/mv88e6352.c
+++ b/drivers/net/dsa/mv88e6352.c
@@ -321,6 +321,7 @@ struct dsa_switch_driver mv88e6352_switch_driver = {
.priv_size  = sizeof(struct mv88e6xxx_priv_state),
.probe  = mv88e6352_probe,
.setup  = mv88e6352_setup,
+   .remove = mv88e6xxx_remove_common,
.set_addr   = mv88e6xxx_set_addr_indirect,
.phy_read   = mv88e6xxx_phy_read_indirect,
.phy_write  = mv88e6xxx_phy_write_indirect,
-- 
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v3 2/5] net: dsa: bcm_sf2: cleanup resources in remove callback

2015-10-29 Thread Neil Armstrong
Implement a remove callback allowing the switch driver to cleanup
resources it used: interrupts and remapped register ranges.

Signed-off-by: Florian Fainelli <f.faine...@gmail.com>
Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
---
 drivers/net/dsa/bcm_sf2.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
index 6f946fe..e0be318 100644
--- a/drivers/net/dsa/bcm_sf2.c
+++ b/drivers/net/dsa/bcm_sf2.c
@@ -1054,6 +1054,25 @@ out_unmap:
return ret;
 }

+static void bcm_sf2_sw_remove(struct dsa_switch *ds)
+{
+   struct bcm_sf2_priv *priv = ds_to_priv(ds);
+   void __iomem **base;
+   unsigned int i;
+
+   /* Disable all interrupts and free them */
+   bcm_sf2_intr_disable(priv);
+
+   free_irq(priv->irq0, priv);
+   free_irq(priv->irq1, priv);
+
+   base = >core;
+   for (i = 0; i < BCM_SF2_REGS_NUM; i++) {
+   iounmap(*base);
+   base++;
+   }
+}
+
 static int bcm_sf2_sw_set_addr(struct dsa_switch *ds, u8 *addr)
 {
return 0;
@@ -1367,6 +1386,7 @@ static struct dsa_switch_driver bcm_sf2_switch_driver = {
.tag_protocol   = DSA_TAG_PROTO_BRCM,
.priv_size  = sizeof(struct bcm_sf2_priv),
.probe  = bcm_sf2_sw_probe,
+   .remove = bcm_sf2_sw_remove,
.setup  = bcm_sf2_sw_setup,
.set_addr   = bcm_sf2_sw_set_addr,
.get_phy_flags  = bcm_sf2_sw_get_phy_flags,
-- 
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v3 1/5] net: dsa: allow switch drivers to cleanup their resources

2015-10-29 Thread Neil Armstrong
Some switch drivers might request interrupts, remap register ranges,
allow such drivers to implement a "remove" callback doing just that.

Signed-off-by: Florian Fainelli <f.faine...@gmail.com>
Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
---
 include/net/dsa.h | 1 +
 net/dsa/dsa.c | 4 
 2 files changed, 5 insertions(+)

diff --git a/include/net/dsa.h b/include/net/dsa.h
index 98ccbde..0e1502c 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -212,6 +212,7 @@ struct dsa_switch_driver {
 */
char*(*probe)(struct device *host_dev, int sw_addr);
int (*setup)(struct dsa_switch *ds);
+   void(*remove)(struct dsa_switch *ds);
int (*set_addr)(struct dsa_switch *ds, u8 *addr);
u32 (*get_phy_flags)(struct dsa_switch *ds, int port);

diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 1eba07f..f462fc5 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -459,6 +459,10 @@ static void dsa_switch_destroy(struct dsa_switch *ds)
}

mdiobus_unregister(ds->slave_mii_bus);
+
+   /* Leave a chance to the driver to cleanup */
+   if (ds->drv->remove)
+   ds->drv->remove(ds);
 }

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


[RFC PATCH v3 0/5] net: dsa: cleanup dsa driver

2015-10-29 Thread Neil Armstrong
Introduce a new remove callback to allow DSA drivers to cleanup their
ressources.
Then add a remove implementation for bcm_sf2 and mv88e6xxx.

This patch was not tested due of a lack of hardware.

v2: add remove callback patch to the serie
v3: separate & fix ppu remove callback into a proper patch

Neil Armstrong (5):
  net: dsa: allow switch drivers to cleanup their resources
  net: dsa: bcm_sf2: cleanup resources in remove callback
  net: dsa: mv88e6xxx: add common remove function
  net: dsa: make usage of mv88e6xxx common remove function
  net: dsa: add mv88e6xxx ppu remove function for mv88e6131

 drivers/net/dsa/bcm_sf2.c | 20 
 drivers/net/dsa/mv88e6123_61_65.c |  1 +
 drivers/net/dsa/mv88e6131.c   |  8 
 drivers/net/dsa/mv88e6171.c   |  1 +
 drivers/net/dsa/mv88e6352.c   |  1 +
 drivers/net/dsa/mv88e6xxx.c   | 18 ++
 drivers/net/dsa/mv88e6xxx.h   |  2 ++
 include/net/dsa.h |  1 +
 net/dsa/dsa.c |  4 
 9 files changed, 56 insertions(+)

-- 
1.9.1

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


Re: [RFC PATCH v3 1/5] net: dsa: allow switch drivers to cleanup their resources

2015-10-29 Thread Neil Armstrong
On 10/29/2015 03:50 PM, Andrew Lunn wrote:
> On Thu, Oct 29, 2015 at 03:45:24PM +0100, Neil Armstrong wrote:
>> --- a/net/dsa/dsa.c
>> +++ b/net/dsa/dsa.c
>> @@ -459,6 +459,10 @@ static void dsa_switch_destroy(struct dsa_switch *ds)
>>  }
>>
>>  mdiobus_unregister(ds->slave_mii_bus);
>> +
>> +/* Leave a chance to the driver to cleanup */
>> +if (ds->drv->remove)
>> +ds->drv->remove(ds);
>>  }
> 
> https://lkml.org/lkml/2015/10/28/532 ???
> 
>  Andrew
> 
Well, sorry, I did the change but it got lost when refactoring the ppu stuff.

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


Re: [PATCH 1/4] arm: omap2+: add missing HWMOD_NO_IDLEST in 81xx hwmod data

2015-10-24 Thread Neil Armstrong
Hi,

2015-10-24 3:21 GMT+02:00 Tony Lindgren <t...@atomide.com>:
>
> Hi,
>
> * Neil Armstrong <narmstr...@baylibre.com> [151022 02:19]:
> > Add missing HWMOD_NO_IDLEST hwmod flag for entries no
> > having omap4 clkctrl values.
>
> Have you checked this is the case both in dm814x and dm816x TRM?
> Also the documentation may not be complete FYI, might be also
> worth checking the legacy TI kernel tree to be sure.
>
> Regards,
>
> Tony
>
> > Cc: Brian Hutchinson <b.hutch...@gmail.com>
> > Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
> > ---
> >  arch/arm/mach-omap2/omap_hwmod_81xx_data.c | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/arch/arm/mach-omap2/omap_hwmod_81xx_data.c 
> > b/arch/arm/mach-omap2/omap_hwmod_81xx_data.c
> > index b1288f5..6256052 100644
> > --- a/arch/arm/mach-omap2/omap_hwmod_81xx_data.c
> > +++ b/arch/arm/mach-omap2/omap_hwmod_81xx_data.c
> > @@ -144,6 +144,7 @@ static struct omap_hwmod dm81xx_l4_ls_hwmod = {
> >   .name   = "l4_ls",
> >   .clkdm_name = "alwon_l3s_clkdm",
> >   .class  = _hwmod_class,
> > + .flags  = HWMOD_NO_IDLEST,
> >  };
In DM814x TRM, the CM_ALWON_L3_SLOW_CLKSTCTRL does not have IDLEST field.
Same in DM816x TRM.

> >
> >  /*
> > @@ -155,6 +156,7 @@ static struct omap_hwmod dm81xx_l4_hs_hwmod = {
> >   .name   = "l4_hs",
> >   .clkdm_name = "alwon_l3_med_clkdm",
> >   .class  = _hwmod_class,
> > + .flags  = HWMOD_NO_IDLEST,
> >  };
In DM814x TRM, the CM_ALWON_L3_MED_CLKSTCTRL does not have IDLEST field.
Same in DM816x TRM.

> >
> >  /* L3 slow -> L4 ls peripheral interface running at 125MHz */
> > @@ -850,6 +852,7 @@ static struct omap_hwmod dm816x_emac0_hwmod = {
> >   .name   = "emac0",
> >   .clkdm_name = "alwon_ethernet_clkdm",
> >   .class  = _emac_hwmod_class,
> > + .flags  = HWMOD_NO_IDLEST,
> >  };
In this particular case, the IDLEST is handled in the MDIO hwmod.

> >
> >  static struct omap_hwmod_ocp_if dm81xx_l4_hs__emac0 = {
> > --
> > 1.9.1

I'll check the TI tree to be sure...

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


[PATCH 6/6] net: phy: Stop 'phy-state-machine' and 'phy_change' work on remove

2015-10-27 Thread Neil Armstrong
Avoids:
 Unable to handle kernel NULL pointer dereference at virtual address 0064
 Workqueue: events_power_efficient phy_state_machine
 PC is at phy_state_machine+0x28/0x480

Signed-off-by: Frode Isaksen <fisak...@baylibre.com>
Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
---
 drivers/net/phy/phy_device.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 3833891..b5b6c1b 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -1348,6 +1348,12 @@ static int phy_remove(struct device *dev)
phydev->state = PHY_DOWN;
mutex_unlock(>lock);

+   cancel_delayed_work_sync(>state_queue);
+   flush_delayed_work(>state_queue);
+
+   cancel_work_sync(>phy_queue);
+   flush_work(>phy_queue);
+
if (phydev->drv->remove)
phydev->drv->remove(phydev);
phydev->drv = NULL;
-- 
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/6] net: dsa: cleanup resources upon module removal

2015-10-27 Thread Neil Armstrong
Make sure that we unassign the master_netdev dsa_ptr to make the packet
processing go through the regular Ethernet receive path.

Suggested-by: Florian Fainelli <f.faine...@gmail.com>
Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
---
 net/dsa/dsa.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 7c9914b..acbf854 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -951,6 +951,14 @@ static void dsa_remove_dst(struct dsa_switch_tree *dst)
flush_delayed_work(>link_poll_work);
}

+   dst->master_netdev->dsa_ptr = NULL;
+
+   /* If we used a tagging format that doesn't have an ethertype
+* field, make sure that all packets from this point get sent
+* without the tag and go through the regular receive path.
+*/
+   wmb();
+
for (i = 0; i < dst->pd->nr_chips; i++) {
struct dsa_switch *ds = dst->ds[i];

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


[PATCH 1/6] net: dsa: Use delayed work instead of timer+work for polling

2015-10-27 Thread Neil Armstrong
Simplifies the code and avoids a crash when removing the
module:
 dsa dsa ethmv2 (unregistering): Link is Down
 device eth1 left promiscuous mode
 Unable to handle kernel paging request at virtual address bacc5cf6
 ...
 (run_timer_softirq) from [] (__do_softirq+0xcc/0x320)
 (__do_softirq) from [] (irq_exit+0xac/0x10c)
 (irq_exit) from [] (__handle_domain_irq+0x50/0xa8)

Signed-off-by: Frode Isaksen <fisak...@baylibre.com>
Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
---
 include/net/dsa.h |  3 +--
 net/dsa/dsa.c | 28 
 2 files changed, 9 insertions(+), 22 deletions(-)

diff --git a/include/net/dsa.h b/include/net/dsa.h
index 98ccbde..d4d13f7 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -112,8 +112,7 @@ struct dsa_switch_tree {
 * Link state polling.
 */
int link_poll_needed;
-   struct work_struct  link_poll_work;
-   struct timer_list   link_poll_timer;
+   struct delayed_work link_poll_work;

/*
 * Data for the individual switch chips.
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 1eba07f..aeb6a7c 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -513,7 +513,7 @@ static void dsa_link_poll_work(struct work_struct *ugly)
struct dsa_switch_tree *dst;
int i;

-   dst = container_of(ugly, struct dsa_switch_tree, link_poll_work);
+   dst = container_of(ugly, struct dsa_switch_tree, link_poll_work.work);

for (i = 0; i < dst->pd->nr_chips; i++) {
struct dsa_switch *ds = dst->ds[i];
@@ -522,17 +522,9 @@ static void dsa_link_poll_work(struct work_struct *ugly)
ds->drv->poll_link(ds);
}

-   mod_timer(>link_poll_timer, round_jiffies(jiffies + HZ));
+   schedule_delayed_work(>link_poll_work, round_jiffies_relative(HZ));
 }

-static void dsa_link_poll_timer(unsigned long _dst)
-{
-   struct dsa_switch_tree *dst = (void *)_dst;
-
-   schedule_work(>link_poll_work);
-}
-
-
 /* platform driver init and cleanup */
 static int dev_is_class(struct device *dev, void *class)
 {
@@ -880,12 +872,8 @@ static int dsa_setup_dst(struct dsa_switch_tree *dst, 
struct net_device *dev,
dev->dsa_ptr = (void *)dst;

if (dst->link_poll_needed) {
-   INIT_WORK(>link_poll_work, dsa_link_poll_work);
-   init_timer(>link_poll_timer);
-   dst->link_poll_timer.data = (unsigned long)dst;
-   dst->link_poll_timer.function = dsa_link_poll_timer;
-   dst->link_poll_timer.expires = round_jiffies(jiffies + HZ);
-   add_timer(>link_poll_timer);
+   INIT_DELAYED_WORK(>link_poll_work, dsa_link_poll_work);
+   schedule_delayed_work(>link_poll_work, 
round_jiffies_relative(HZ));
}

return 0;
@@ -954,10 +942,10 @@ static void dsa_remove_dst(struct dsa_switch_tree *dst)
 {
int i;

-   if (dst->link_poll_needed)
-   del_timer_sync(>link_poll_timer);
-
-   flush_work(>link_poll_work);
+   if (dst->link_poll_needed) {
+   cancel_delayed_work_sync(>link_poll_work);
+   flush_delayed_work(>link_poll_work);
+   }

for (i = 0; i < dst->pd->nr_chips; i++) {
struct dsa_switch *ds = dst->ds[i];
-- 
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/6] net: dsa: allow switch drivers to cleanup their resources

2015-10-27 Thread Neil Armstrong
Some switch drivers might request interrupts, remap register ranges,
allow such drivers to implement a "remove" callback doing just that.

Suggested-by: Florian Fainelli <f.faine...@gmail.com>
Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
---
 include/net/dsa.h | 1 +
 net/dsa/dsa.c | 4 
 2 files changed, 5 insertions(+)

diff --git a/include/net/dsa.h b/include/net/dsa.h
index d4d13f7..725b11f 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -211,6 +211,7 @@ struct dsa_switch_driver {
 */
char*(*probe)(struct device *host_dev, int sw_addr);
int (*setup)(struct dsa_switch *ds);
+   void(*remove)(struct dsa_switch *ds);
int (*set_addr)(struct dsa_switch *ds, u8 *addr);
u32 (*get_phy_flags)(struct dsa_switch *ds, int port);

diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index aeb6a7c..7c9914b 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -459,6 +459,10 @@ static void dsa_switch_destroy(struct dsa_switch *ds)
}

mdiobus_unregister(ds->slave_mii_bus);
+
+   /* Leave a chance to the driver to cleanup */
+   if (ds->drv->remove)
+   ds->drv->remove(ds);
 }

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


[PATCH 4/6] net: dsa: Add missing master netdev dev_put() calls

2015-10-27 Thread Neil Armstrong
Upon probe failure or unbinding, add missing dev_put() calls.

Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
---
 net/dsa/dsa.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index acbf854..9240a46 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -931,8 +931,10 @@ static int dsa_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, dst);

ret = dsa_setup_dst(dst, dev, >dev, pd);
-   if (ret)
+   if (ret) {
+   dev_put(dev);
goto out;
+   }

return 0;

@@ -965,6 +967,8 @@ static void dsa_remove_dst(struct dsa_switch_tree *dst)
if (ds)
dsa_switch_destroy(ds);
}
+
+   dev_put(dst->master_netdev);
 }

 static int dsa_remove(struct platform_device *pdev)
-- 
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/6] net: dsa: allow switch drivers to cleanup their resources

2015-10-27 Thread Neil Armstrong
Hi,
On 10/27/2015 04:39 PM, Florian Fainelli wrote:
> On 27/10/15 07:48, Neil Armstrong wrote:
>> Some switch drivers might request interrupts, remap register ranges,
>> allow such drivers to implement a "remove" callback doing just that.
>>
>> Suggested-by: Florian Fainelli <f.faine...@gmail.com>
> 
> This should probably be a Signed-off-by tag, but there is nothing using
> this, so you would want to introduce an user of this function in the
> same patch series so we see how you intend to use it?
> 
>> Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>

Yes, I didn't know how to handle this since it was part of a larger patch.

I forgot to add this into the cover-letter but I wanted to send an RFC serie 
with
your bcm remove patch and a mv88e6xxx remove experimental code.

Yet, the mv88e6060 does not make usage of this.

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


[PATCH 5/6] net: dsa: Do not reschedule polling if driver removed

2015-10-27 Thread Neil Armstrong
Do not reschedule the delayed work used for polling when
the driver is removed, by testing the 'poll_link_needed'
flag.
Avoids this crash:
 dsa dsa ethmv2 (unregistering): Link is Down
 device eth1 left promiscuous mode
 Unable to handle kernel paging request at virtual address bacc5cf6
 ...
 (run_timer_softirq) from [] (__do_softirq+0xcc/0x320)
 (__do_softirq) from [] (irq_exit+0xac/0x10c)
 (irq_exit) from [] (__handle_domain_irq+0x50/0xa8)

Signed-off-by: Frode Isaksen <fisak...@baylibre.com>
Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
---
 net/dsa/dsa.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 9240a46..9881b17 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -526,7 +526,8 @@ static void dsa_link_poll_work(struct work_struct *ugly)
ds->drv->poll_link(ds);
}

-   schedule_delayed_work(>link_poll_work, round_jiffies_relative(HZ));
+   if (dst->link_poll_needed)
+   schedule_delayed_work(>link_poll_work, 
round_jiffies_relative(HZ));
 }

 /* platform driver init and cleanup */
@@ -949,6 +950,7 @@ static void dsa_remove_dst(struct dsa_switch_tree *dst)
int i;

if (dst->link_poll_needed) {
+   dst->link_poll_needed = 0;
cancel_delayed_work_sync(>link_poll_work);
flush_delayed_work(>link_poll_work);
}
-- 
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/6] Further fix for dsa unbinding

2015-10-27 Thread Neil Armstrong
This serie fixes further issues for DSA dynamic unbinding.
Frode Isaksen's patches make usage of delayed work and fixes kernel
crashes when dsa is unbind.
The other patches are simple fixes to permit cleanup and avoid netdev
related crashes.

Frode Isaksen (3):
  net: dsa: Use delayed work instead of timer+work for polling
  net: dsa: Do not reschedule polling if driver removed
  net: phy: Stop 'phy-state-machine' and 'phy_change' work on remove

Neil Armstrong (3):
  net: dsa: allow switch drivers to cleanup their resources
  net: dsa: cleanup resources upon module removal
  net: dsa: Add missing master netdev dev_put() calls

 drivers/net/phy/phy_device.c |  6 ++
 include/net/dsa.h|  4 ++--
 net/dsa/dsa.c| 46 +---
 3 files changed, 34 insertions(+), 22 deletions(-)

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


[RFC PATCH 3/3] net: dsa: make usage of mv88e6xxx common remove function

2015-10-27 Thread Neil Armstrong
Make usage of previously introduced mv88e6xxx common remove
function in all mv88e6xxx drivers.

Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
---
 drivers/net/dsa/mv88e6123_61_65.c | 1 +
 drivers/net/dsa/mv88e6131.c   | 8 
 drivers/net/dsa/mv88e6171.c   | 1 +
 drivers/net/dsa/mv88e6352.c   | 1 +
 4 files changed, 11 insertions(+)

diff --git a/drivers/net/dsa/mv88e6123_61_65.c 
b/drivers/net/dsa/mv88e6123_61_65.c
index 4bcfd68..1773c99 100644
--- a/drivers/net/dsa/mv88e6123_61_65.c
+++ b/drivers/net/dsa/mv88e6123_61_65.c
@@ -122,6 +122,7 @@ struct dsa_switch_driver mv88e6123_61_65_switch_driver = {
.priv_size  = sizeof(struct mv88e6xxx_priv_state),
.probe  = mv88e6123_61_65_probe,
.setup  = mv88e6123_61_65_setup,
+   .remove = mv88e6xxx_remove_common,
.set_addr   = mv88e6xxx_set_addr_indirect,
.phy_read   = mv88e6xxx_phy_read,
.phy_write  = mv88e6xxx_phy_write,
diff --git a/drivers/net/dsa/mv88e6131.c b/drivers/net/dsa/mv88e6131.c
index c73121c..0f559b4 100644
--- a/drivers/net/dsa/mv88e6131.c
+++ b/drivers/net/dsa/mv88e6131.c
@@ -137,6 +137,13 @@ static int mv88e6131_setup(struct dsa_switch *ds)
return mv88e6xxx_setup_ports(ds);
 }

+static void mv88e6131_remove(struct dsa_switch *ds)
+{
+   mv88e6xxx_ppu_state_remove(ds);
+
+   mv88e6xxx_remove_common(ds);
+}
+
 static int mv88e6131_port_to_phy_addr(struct dsa_switch *ds, int port)
 {
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
@@ -175,6 +182,7 @@ struct dsa_switch_driver mv88e6131_switch_driver = {
.priv_size  = sizeof(struct mv88e6xxx_priv_state),
.probe  = mv88e6131_probe,
.setup  = mv88e6131_setup,
+   .remove = mv88e6131_remove,
.set_addr   = mv88e6xxx_set_addr_direct,
.phy_read   = mv88e6131_phy_read,
.phy_write  = mv88e6131_phy_write,
diff --git a/drivers/net/dsa/mv88e6171.c b/drivers/net/dsa/mv88e6171.c
index 2c8eb6f..382529b 100644
--- a/drivers/net/dsa/mv88e6171.c
+++ b/drivers/net/dsa/mv88e6171.c
@@ -101,6 +101,7 @@ struct dsa_switch_driver mv88e6171_switch_driver = {
.priv_size  = sizeof(struct mv88e6xxx_priv_state),
.probe  = mv88e6171_probe,
.setup  = mv88e6171_setup,
+   .remove = mv88e6xxx_remove_common,
.set_addr   = mv88e6xxx_set_addr_indirect,
.phy_read   = mv88e6xxx_phy_read_indirect,
.phy_write  = mv88e6xxx_phy_write_indirect,
diff --git a/drivers/net/dsa/mv88e6352.c b/drivers/net/dsa/mv88e6352.c
index cbf4dd8..7938901 100644
--- a/drivers/net/dsa/mv88e6352.c
+++ b/drivers/net/dsa/mv88e6352.c
@@ -321,6 +321,7 @@ struct dsa_switch_driver mv88e6352_switch_driver = {
.priv_size  = sizeof(struct mv88e6xxx_priv_state),
.probe  = mv88e6352_probe,
.setup  = mv88e6352_setup,
+   .remove = mv88e6xxx_remove_common,
.set_addr   = mv88e6xxx_set_addr_indirect,
.phy_read   = mv88e6xxx_phy_read_indirect,
.phy_write  = mv88e6xxx_phy_write_indirect,
-- 
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH 1/3] net: dsa: bcm_sf2: cleanup resources in remove callback

2015-10-27 Thread Neil Armstrong
Implement a remove callback allowing the switch driver to cleanup
resources it used: interrupts and remapped register ranges.

Signed-off-by: Florian Fainelli <f.faine...@gmail.com>
Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
---
 drivers/net/dsa/bcm_sf2.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
index 6f946fe..e0be318 100644
--- a/drivers/net/dsa/bcm_sf2.c
+++ b/drivers/net/dsa/bcm_sf2.c
@@ -1054,6 +1054,25 @@ out_unmap:
return ret;
 }

+static void bcm_sf2_sw_remove(struct dsa_switch *ds)
+{
+   struct bcm_sf2_priv *priv = ds_to_priv(ds);
+   void __iomem **base;
+   unsigned int i;
+
+   /* Disable all interrupts and free them */
+   bcm_sf2_intr_disable(priv);
+
+   free_irq(priv->irq0, priv);
+   free_irq(priv->irq1, priv);
+
+   base = >core;
+   for (i = 0; i < BCM_SF2_REGS_NUM; i++) {
+   iounmap(*base);
+   base++;
+   }
+}
+
 static int bcm_sf2_sw_set_addr(struct dsa_switch *ds, u8 *addr)
 {
return 0;
@@ -1367,6 +1386,7 @@ static struct dsa_switch_driver bcm_sf2_switch_driver = {
.tag_protocol   = DSA_TAG_PROTO_BRCM,
.priv_size  = sizeof(struct bcm_sf2_priv),
.probe  = bcm_sf2_sw_probe,
+   .remove = bcm_sf2_sw_remove,
.setup  = bcm_sf2_sw_setup,
.set_addr   = bcm_sf2_sw_set_addr,
.get_phy_flags  = bcm_sf2_sw_get_phy_flags,
-- 
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH 2/3] net: dsa: mv88e6xxx: add common and ppu remove function

2015-10-27 Thread Neil Armstrong
With the previously introduced remove callback, add a
mv88e6xxx common remove function to cleanup all ressources.

Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
---
 drivers/net/dsa/mv88e6xxx.c | 18 ++
 drivers/net/dsa/mv88e6xxx.h |  2 ++
 2 files changed, 20 insertions(+)

diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
index b1b14f5..6287096 100644
--- a/drivers/net/dsa/mv88e6xxx.c
+++ b/drivers/net/dsa/mv88e6xxx.c
@@ -331,6 +331,16 @@ void mv88e6xxx_ppu_state_init(struct dsa_switch *ds)
ps->ppu_timer.function = mv88e6xxx_ppu_reenable_timer;
 }

+void mv88e6xxx_ppu_state_remove(struct dsa_switch *ds)
+{
+   struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
+   
+   del_timer_sync(>ppu_timer);
+
+   cancel_work_sync(>bridge_work);
+   flush_work(>bridge_work);
+}
+
 int mv88e6xxx_phy_read_ppu(struct dsa_switch *ds, int addr, int regnum)
 {
int ret;
@@ -2083,6 +2093,14 @@ int mv88e6xxx_setup_common(struct dsa_switch *ds)
return 0;
 }

+void mv88e6xxx_remove_common(struct dsa_switch *ds)
+{
+   struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
+
+   cancel_work_sync(>bridge_work);
+   flush_work(>bridge_work);
+}
+
 int mv88e6xxx_setup_global(struct dsa_switch *ds)
 {
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
diff --git a/drivers/net/dsa/mv88e6xxx.h b/drivers/net/dsa/mv88e6xxx.h
index 6f9ed5d..64d37a0 100644
--- a/drivers/net/dsa/mv88e6xxx.h
+++ b/drivers/net/dsa/mv88e6xxx.h
@@ -417,6 +417,7 @@ struct mv88e6xxx_hw_stat {
 int mv88e6xxx_switch_reset(struct dsa_switch *ds, bool ppu_active);
 int mv88e6xxx_setup_ports(struct dsa_switch *ds);
 int mv88e6xxx_setup_common(struct dsa_switch *ds);
+void mv88e6xxx_remove_common(struct dsa_switch *ds);
 int mv88e6xxx_setup_global(struct dsa_switch *ds);
 int __mv88e6xxx_reg_read(struct mii_bus *bus, int sw_addr, int addr, int reg);
 int mv88e6xxx_reg_read(struct dsa_switch *ds, int addr, int reg);
@@ -431,6 +432,7 @@ int mv88e6xxx_phy_read_indirect(struct dsa_switch *ds, int 
port, int regnum);
 int mv88e6xxx_phy_write_indirect(struct dsa_switch *ds, int port, int regnum,
 u16 val);
 void mv88e6xxx_ppu_state_init(struct dsa_switch *ds);
+void mv88e6xxx_ppu_state_remove(struct dsa_switch *ds);
 int mv88e6xxx_phy_read_ppu(struct dsa_switch *ds, int addr, int regnum);
 int mv88e6xxx_phy_write_ppu(struct dsa_switch *ds, int addr,
int regnum, u16 val);
-- 
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH 0/3] net: dsa: cleanup dsa driver

2015-10-27 Thread Neil Armstrong
With the previously introduced remove callback for DSA driver  in :
http://marc.info/?i=562F8ED7.2000804%40baylibre.com
Add remove callback for bcm_sf2 and mv88e6xxx drivers.

This patch was not tested due of a lack of hardware.

Neil Armstrong (3):
  net: dsa: bcm_sf2: cleanup resources in remove callback
  net: dsa: mv88e6xxx: add common and ppu remove function
  net: dsa: make usage of mv88e6xxx common remove function

 drivers/net/dsa/bcm_sf2.c | 20 
 drivers/net/dsa/mv88e6123_61_65.c |  1 +
 drivers/net/dsa/mv88e6131.c   |  8 
 drivers/net/dsa/mv88e6171.c   |  1 +
 drivers/net/dsa/mv88e6352.c   |  1 +
 drivers/net/dsa/mv88e6xxx.c   | 18 ++
 drivers/net/dsa/mv88e6xxx.h   |  2 ++
 7 files changed, 51 insertions(+)

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


[PATCH 2/3] net: dsa: Make mv88e6xxx use nested mdiobus read/write

2015-10-22 Thread Neil Armstrong
Make the mv88e6xxx driver use the previously introduced nested
variants of mdiobus_read/write functions.

Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
---
 drivers/net/dsa/mv88e6xxx.c | 46 +
 1 file changed, 9 insertions(+), 37 deletions(-)

diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
index 4591240..e3cc66e 100644
--- a/drivers/net/dsa/mv88e6xxx.c
+++ b/drivers/net/dsa/mv88e6xxx.c
@@ -26,34 +26,6 @@
 #include 
 #include "mv88e6xxx.h"

-/* MDIO bus access can be nested in the case of PHYs connected to the
- * internal MDIO bus of the switch, which is accessed via MDIO bus of
- * the Ethernet interface. Avoid lockdep false positives by using
- * mutex_lock_nested().
- */
-static int mv88e6xxx_mdiobus_read(struct mii_bus *bus, int addr, u32 regnum)
-{
-   int ret;
-
-   mutex_lock_nested(>mdio_lock, SINGLE_DEPTH_NESTING);
-   ret = bus->read(bus, addr, regnum);
-   mutex_unlock(>mdio_lock);
-
-   return ret;
-}
-
-static int mv88e6xxx_mdiobus_write(struct mii_bus *bus, int addr, u32 regnum,
-  u16 val)
-{
-   int ret;
-
-   mutex_lock_nested(>mdio_lock, SINGLE_DEPTH_NESTING);
-   ret = bus->write(bus, addr, regnum, val);
-   mutex_unlock(>mdio_lock);
-
-   return ret;
-}
-
 /* If the switch's ADDR[4:0] strap pins are strapped to zero, it will
  * use all 32 SMI bus addresses on its SMI bus, and all switch registers
  * will be directly accessible on some {device address,register address}
@@ -68,7 +40,7 @@ static int mv88e6xxx_reg_wait_ready(struct mii_bus *bus, int 
sw_addr)
int i;

for (i = 0; i < 16; i++) {
-   ret = mv88e6xxx_mdiobus_read(bus, sw_addr, SMI_CMD);
+   ret = mdiobus_read_nested(bus, sw_addr, SMI_CMD);
if (ret < 0)
return ret;

@@ -84,7 +56,7 @@ int __mv88e6xxx_reg_read(struct mii_bus *bus, int sw_addr, 
int addr, int reg)
int ret;

if (sw_addr == 0)
-   return mv88e6xxx_mdiobus_read(bus, addr, reg);
+   return mdiobus_read_nested(bus, addr, reg);

/* Wait for the bus to become free. */
ret = mv88e6xxx_reg_wait_ready(bus, sw_addr);
@@ -92,8 +64,8 @@ int __mv88e6xxx_reg_read(struct mii_bus *bus, int sw_addr, 
int addr, int reg)
return ret;

/* Transmit the read command. */
-   ret = mv88e6xxx_mdiobus_write(bus, sw_addr, SMI_CMD,
- SMI_CMD_OP_22_READ | (addr << 5) | reg);
+   ret = mdiobus_write_nested(bus, sw_addr, SMI_CMD,
+  SMI_CMD_OP_22_READ | (addr << 5) | reg);
if (ret < 0)
return ret;

@@ -103,7 +75,7 @@ int __mv88e6xxx_reg_read(struct mii_bus *bus, int sw_addr, 
int addr, int reg)
return ret;

/* Read the data. */
-   ret = mv88e6xxx_mdiobus_read(bus, sw_addr, SMI_DATA);
+   ret = mdiobus_read_nested(bus, sw_addr, SMI_DATA);
if (ret < 0)
return ret;

@@ -147,7 +119,7 @@ int __mv88e6xxx_reg_write(struct mii_bus *bus, int sw_addr, 
int addr,
int ret;

if (sw_addr == 0)
-   return mv88e6xxx_mdiobus_write(bus, addr, reg, val);
+   return mdiobus_write_nested(bus, addr, reg, val);

/* Wait for the bus to become free. */
ret = mv88e6xxx_reg_wait_ready(bus, sw_addr);
@@ -155,13 +127,13 @@ int __mv88e6xxx_reg_write(struct mii_bus *bus, int 
sw_addr, int addr,
return ret;

/* Transmit the data to write. */
-   ret = mv88e6xxx_mdiobus_write(bus, sw_addr, SMI_DATA, val);
+   ret = mdiobus_write_nested(bus, sw_addr, SMI_DATA, val);
if (ret < 0)
return ret;

/* Transmit the write command. */
-   ret = mv88e6xxx_mdiobus_write(bus, sw_addr, SMI_CMD,
- SMI_CMD_OP_22_WRITE | (addr << 5) | reg);
+   ret = mdiobus_write_nested(bus, sw_addr, SMI_CMD,
+  SMI_CMD_OP_22_WRITE | (addr << 5) | reg);
if (ret < 0)
return ret;

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


[PATCH v2 3/6] net: dsa: mv88e6060: use the correct MaxFrameSize bit

2015-11-10 Thread Neil Armstrong
According to the mv88e6060 datasheet, the MaxFrameSize bit position
is 10 instead of 11 which is reserved.
Use the bit correctly to setup max frame size to 1536.

Acked-by: Andrew Lunn <and...@lunn.ch>
Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
---
 drivers/net/dsa/mv88e6060.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/dsa/mv88e6060.c b/drivers/net/dsa/mv88e6060.c
index eff5e18..10647ad 100644
--- a/drivers/net/dsa/mv88e6060.c
+++ b/drivers/net/dsa/mv88e6060.c
@@ -119,7 +119,7 @@ static int mv88e6060_setup_global(struct dsa_switch *ds)
 * set the maximum frame size to 1536 bytes, and mask all
 * interrupt sources.
 */
-   REG_WRITE(REG_GLOBAL, 0x04, 0x0800);
+   REG_WRITE(REG_GLOBAL, 0x04, 0x400);

/* Enable automatic address learning, set the address
 * database size to 1024 entries, and set the default aging
-- 
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 6/6] net: dsa: mv88e6060: replace magic values with register defines

2015-11-10 Thread Neil Armstrong
To align with the mv88e6xxx code, use the register defines to
access all the register addresses and bit fields.

Acked-by: Andrew Lunn <and...@lunn.ch>
Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
---
 drivers/net/dsa/mv88e6060.c | 64 ++---
 1 file changed, 37 insertions(+), 27 deletions(-)

diff --git a/drivers/net/dsa/mv88e6060.c b/drivers/net/dsa/mv88e6060.c
index cd08079..0527f48 100644
--- a/drivers/net/dsa/mv88e6060.c
+++ b/drivers/net/dsa/mv88e6060.c
@@ -15,9 +15,7 @@
 #include 
 #include 
 #include 
-
-#define REG_PORT(p)(8 + (p))
-#define REG_GLOBAL 0x0f
+#include "mv88e6060.h"

 static int reg_read(struct dsa_switch *ds, int addr, int reg)
 {
@@ -67,13 +65,14 @@ static char *mv88e6060_probe(struct device *host_dev, int 
sw_addr)
if (bus == NULL)
return NULL;

-   ret = mdiobus_read(bus, sw_addr + REG_PORT(0), 0x03);
+   ret = mdiobus_read(bus, sw_addr + REG_PORT(0), PORT_SWITCH_ID);
if (ret >= 0) {
-   if (ret == 0x0600)
+   if (ret == PORT_SWITCH_ID_6060)
return "Marvell 88E6060 (A0)";
-   if (ret == 0x0601 || ret == 0x0602)
+   if (ret == PORT_SWITCH_ID_6060_R1 ||
+   ret == PORT_SWITCH_ID_6060_R2)
return "Marvell 88E6060 (B0)";
-   if ((ret & 0xfff0) == 0x0600)
+   if ((ret & PORT_SWITCH_ID_6060_MASK) == PORT_SWITCH_ID_6060)
return "Marvell 88E6060";
}

@@ -87,22 +86,26 @@ static int mv88e6060_switch_reset(struct dsa_switch *ds)
unsigned long timeout;

/* Set all ports to the disabled state. */
-   for (i = 0; i < 6; i++) {
-   ret = REG_READ(REG_PORT(i), 0x04);
-   REG_WRITE(REG_PORT(i), 0x04, ret & 0xfffc);
+   for (i = 0; i < MV88E6060_PORTS; i++) {
+   ret = REG_READ(REG_PORT(i), PORT_CONTROL);
+   REG_WRITE(REG_PORT(i), PORT_CONTROL,
+ ret & ~PORT_CONTROL_STATE_MASK);
}

/* Wait for transmit queues to drain. */
usleep_range(2000, 4000);

/* Reset the switch. */
-   REG_WRITE(REG_GLOBAL, 0x0a, 0xa130);
+   REG_WRITE(REG_GLOBAL, GLOBAL_ATU_CONTROL,
+ GLOBAL_ATU_CONTROL_SWRESET |
+ GLOBAL_ATU_CONTROL_ATUSIZE_1024 |
+ GLOBAL_ATU_CONTROL_ATE_AGE_5MIN);

/* Wait up to one second for reset to complete. */
timeout = jiffies + 1 * HZ;
while (time_before(jiffies, timeout)) {
-   ret = REG_READ(REG_GLOBAL, 0x00);
-   if (ret & 0x800)
+   ret = REG_READ(REG_GLOBAL, GLOBAL_STATUS);
+   if (ret & GLOBAL_STATUS_INIT_READY)
break;

usleep_range(1000, 2000);
@@ -119,13 +122,15 @@ static int mv88e6060_setup_global(struct dsa_switch *ds)
 * set the maximum frame size to 1536 bytes, and mask all
 * interrupt sources.
 */
-   REG_WRITE(REG_GLOBAL, 0x04, 0x400);
+   REG_WRITE(REG_GLOBAL, GLOBAL_CONTROL, GLOBAL_CONTROL_MAX_FRAME_1536);

/* Enable automatic address learning, set the address
 * database size to 1024 entries, and set the default aging
 * time to 5 minutes.
 */
-   REG_WRITE(REG_GLOBAL, 0x0a, 0x2130);
+   REG_WRITE(REG_GLOBAL, GLOBAL_ATU_CONTROL,
+ GLOBAL_ATU_CONTROL_ATUSIZE_1024 |
+ GLOBAL_ATU_CONTROL_ATE_AGE_5MIN);

return 0;
 }
@@ -139,25 +144,30 @@ static int mv88e6060_setup_port(struct dsa_switch *ds, 
int p)
 * state to Forwarding.  Additionally, if this is the CPU
 * port, enable Ingress and Egress Trailer tagging mode.
 */
-   REG_WRITE(addr, 0x04, dsa_is_cpu_port(ds, p) ?  0x4103 : 0x0003);
+   REG_WRITE(addr, PORT_CONTROL,
+ dsa_is_cpu_port(ds, p) ?
+   PORT_CONTROL_TRAILER |
+   PORT_CONTROL_INGRESS_MODE |
+   PORT_CONTROL_STATE_FORWARDING :
+   PORT_CONTROL_STATE_FORWARDING);

/* Port based VLAN map: give each port its own address
 * database, allow the CPU port to talk to each of the 'real'
 * ports, and allow each of the 'real' ports to only talk to
 * the CPU port.
 */
-   REG_WRITE(addr, 0x06,
-   ((p & 0xf) << 12) |
-(dsa_is_cpu_port(ds, p) ?
-   ds->phys_port_mask :
-   (1 << ds->dst->cpu_port)));
+   REG_WRITE(addr, PORT_VLAN_MAP,
+ ((p & 0xf) << PORT_VLAN_MAP_DBNUM_SHIFT) |
+  (dsa_is_cpu_port(ds, p) ?
+   ds->phys_port_mask :
+

[PATCH v2 5/6] net: dsa: mv88e6060: add register defines header file

2015-11-10 Thread Neil Armstrong
To align with the mv88e6xxx code, add a similar header file
with all the register defines.
The file is based on the mv88e6xxx header for coherency.

Acked-by: Andrew Lunn <and...@lunn.ch>
Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
---
 drivers/net/dsa/mv88e6060.h | 111 
 1 file changed, 111 insertions(+)
 create mode 100644 drivers/net/dsa/mv88e6060.h

diff --git a/drivers/net/dsa/mv88e6060.h b/drivers/net/dsa/mv88e6060.h
new file mode 100644
index 000..46c92b6
--- /dev/null
+++ b/drivers/net/dsa/mv88e6060.h
@@ -0,0 +1,111 @@
+/*
+ * drivers/net/dsa/mv88e6060.h - Marvell 88e6060 switch chip support
+ * Copyright (c) 2015 Neil Armstrong
+ *
+ * Based on mv88e6xxx.h
+ * Copyright (c) 2008 Marvell Semiconductor
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef __MV88E6060_H
+#define __MV88E6060_H
+
+#define MV88E6060_PORTS6
+
+#define REG_PORT(p)(0x8 + (p))
+#define PORT_STATUS0x00
+#define PORT_STATUS_PAUSE_EN   BIT(15)
+#define PORT_STATUS_MY_PAUSE   BIT(14)
+#define PORT_STATUS_FC (PORT_STATUS_MY_PAUSE | PORT_STATUS_PAUSE_EN)
+#define PORT_STATUS_RESOLVED   BIT(13)
+#define PORT_STATUS_LINK   BIT(12)
+#define PORT_STATUS_PORTMODE   BIT(11)
+#define PORT_STATUS_PHYMODEBIT(10)
+#define PORT_STATUS_DUPLEX BIT(9)
+#define PORT_STATUS_SPEED  BIT(8)
+#define PORT_SWITCH_ID 0x03
+#define PORT_SWITCH_ID_60600x0600
+#define PORT_SWITCH_ID_6060_MASK   0xfff0
+#define PORT_SWITCH_ID_6060_R1 0x0601
+#define PORT_SWITCH_ID_6060_R2 0x0602
+#define PORT_CONTROL   0x04
+#define PORT_CONTROL_FORCE_FLOW_CTRL   BIT(15)
+#define PORT_CONTROL_TRAILER   BIT(14)
+#define PORT_CONTROL_HEADERBIT(11)
+#define PORT_CONTROL_INGRESS_MODE  BIT(8)
+#define PORT_CONTROL_VLAN_TUNNEL   BIT(7)
+#define PORT_CONTROL_STATE_MASK0x03
+#define PORT_CONTROL_STATE_DISABLED0x00
+#define PORT_CONTROL_STATE_BLOCKING0x01
+#define PORT_CONTROL_STATE_LEARNING0x02
+#define PORT_CONTROL_STATE_FORWARDING  0x03
+#define PORT_VLAN_MAP  0x06
+#define PORT_VLAN_MAP_DBNUM_SHIFT  12
+#define PORT_VLAN_MAP_TABLE_MASK   0x1f
+#define PORT_ASSOC_VECTOR  0x0b
+#define PORT_ASSOC_VECTOR_MONITOR  BIT(15)
+#define PORT_ASSOC_VECTOR_PAV_MASK 0x1f
+#define PORT_RX_CNTR   0x10
+#define PORT_TX_CNTR   0x11
+
+#define REG_GLOBAL 0x0f
+#define GLOBAL_STATUS  0x00
+#define GLOBAL_STATUS_SW_MODE_MASK (0x3 << 12)
+#define GLOBAL_STATUS_SW_MODE_0(0x0 << 12)
+#define GLOBAL_STATUS_SW_MODE_1(0x1 << 12)
+#define GLOBAL_STATUS_SW_MODE_2(0x2 << 12)
+#define GLOBAL_STATUS_SW_MODE_3(0x3 << 12)
+#define GLOBAL_STATUS_INIT_READY   BIT(11)
+#define GLOBAL_STATUS_ATU_FULL BIT(3)
+#define GLOBAL_STATUS_ATU_DONE BIT(2)
+#define GLOBAL_STATUS_PHY_INT  BIT(1)
+#define GLOBAL_STATUS_EEINTBIT(0)
+#define GLOBAL_MAC_01  0x01
+#define GLOBAL_MAC_01_DIFF_ADDRBIT(8)
+#define GLOBAL_MAC_23  0x02
+#define GLOBAL_MAC_45  0x03
+#define GLOBAL_CONTROL 0x04
+#define GLOBAL_CONTROL_DISCARD_EXCESS  BIT(13)
+#define GLOBAL_CONTROL_MAX_FRAME_1536  BIT(10)
+#define GLOBAL_CONTROL_RELOAD_EEPROM   BIT(9)
+#define GLOBAL_CONTROL_CTRMODE BIT(8)
+#define GLOBAL_CONTROL_ATU_FULL_EN BIT(3)
+#define GLOBAL_CONTROL_ATU_DONE_EN BIT(2)
+#define GLOBAL_CONTROL_PHYINT_EN   BIT(1)
+#define GLOBAL_CONTROL_EEPROM_DONE_EN  BIT(0)
+#define GLOBAL_ATU_CONTROL 0x0a
+#define GLOBAL_ATU_CONTROL_SWRESET BIT(15)
+#define GLOBAL_ATU_CONTROL_LEARNDISBIT(14)
+#define GLOBAL_ATU_CONTROL_ATUSIZE_256 (0x0 << 12)
+#define GLOBAL_ATU_CONTROL_ATUSIZE_512 (0x1 << 12)
+#define GLOBAL_ATU_CONTROL_ATUSIZE_1024(0x2 << 12)
+#define GLOBAL_ATU_CONTROL_ATE_AGE_SHIFT   4
+#define GLOBAL_ATU_CONTROL_ATE_AGE_MASK(0xff << 4)
+#define GLOBAL_ATU_CONTROL_ATE_AGE_5MIN(0x13 << 4)
+#define GLOBAL_ATU_OP  0x0b
+#define GLOBAL_ATU_OP_BUSY BIT(15)
+#define GLOBAL_ATU_OP_NOP  (0 << 12)
+#define GLOBAL_ATU_OP_FLUSH_ALL((1 << 12) | GLOBAL_ATU_OP_BUSY)
+#define GLOBAL_ATU_OP_FLUSH_UNLOCKED   ((2 << 12) | GLOBAL_ATU_OP_BUSY)
+#define GLOBAL_ATU_OP_LOAD_DB  ((3 << 12) | GLOBAL_ATU_OP_BUSY)
+#define GLOBAL_ATU_OP_GET_NEXT_DB  ((4 << 12) | GLOBAL_ATU_OP_BUSY)
+#define GLOBAL_ATU_OP_FLUSH_DB ((5 << 12) | GLOBAL_ATU_OP_BUSY)
+#define GLOBAL_ATU_OP_FLUSH_UNLOCKED_DB ((6 << 12) | GLOBAL_ATU_OP_BUSY)
+#define GLOBAL_ATU_DATA0x0c
+#define GLOBAL_ATU_DATA_PORT_VECTOR_MASK   0x3

[PATCH v2 0/6] net: dsa: mv88e6060: cleanup and fix setup

2015-11-10 Thread Neil Armstrong
This patchset introduces some fixes and a registers addressing cleanup for
the mv88e6060 DSA driver.

The first patch removes the poll_link as mv88e6xxx.
The 3 following patches fixes the setup in regards of the datasheet.
The 2 last patches introduces a clean header and replaces all magic values.

v2: cleanup InitReady patch, add missing Acked-by and fix header copyright 
notice

Neil Armstrong (6):
  net: dsa: mv88e6060: remove poll_link callback
  net: dsa: mv88e6060: use the correct InitReady bit
  net: dsa: mv88e6060: use the correct MaxFrameSize bit
  net: dsa: mv88e6060: use the correct bit shift for mac0
  net: dsa: mv88e6060: add register defines header file
  net: dsa: mv88e6060: replace magic values with register defines

 drivers/net/dsa/mv88e6060.c | 114 +++-
 drivers/net/dsa/mv88e6060.h | 111 ++
 2 files changed, 149 insertions(+), 76 deletions(-)
 create mode 100644 drivers/net/dsa/mv88e6060.h

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


[PATCH v2 1/6] net: dsa: mv88e6060: remove poll_link callback

2015-11-10 Thread Neil Armstrong
As of mv88e6xxx remove the poll_link callback since the link
state change polling is now handled by the phylib.

Tested on a mv88e6060 B0 device with a TI DM816X SoC.

Suggested-by: Andrew Lunn <and...@lunn.ch>
Acked-by: Andrew Lunn <and...@lunn.ch>
Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
---
 drivers/net/dsa/mv88e6060.c | 49 -
 1 file changed, 49 deletions(-)

diff --git a/drivers/net/dsa/mv88e6060.c b/drivers/net/dsa/mv88e6060.c
index 9093577..6885ef5 100644
--- a/drivers/net/dsa/mv88e6060.c
+++ b/drivers/net/dsa/mv88e6060.c
@@ -225,54 +225,6 @@ mv88e6060_phy_write(struct dsa_switch *ds, int port, int 
regnum, u16 val)
return reg_write(ds, addr, regnum, val);
 }

-static void mv88e6060_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 link;
-   int speed;
-   int duplex;
-   int fc;
-
-   dev = ds->ports[i];
-   if (dev == NULL)
-   continue;
-
-   link = 0;
-   if (dev->flags & IFF_UP) {
-   port_status = reg_read(ds, REG_PORT(i), 0x00);
-   if (port_status < 0)
-   continue;
-
-   link = !!(port_status & 0x1000);
-   }
-
-   if (!link) {
-   if (netif_carrier_ok(dev)) {
-   netdev_info(dev, "link down\n");
-   netif_carrier_off(dev);
-   }
-   continue;
-   }
-
-   speed = (port_status & 0x0100) ? 100 : 10;
-   duplex = (port_status & 0x0200) ? 1 : 0;
-   fc = ((port_status & 0xc000) == 0xc000) ? 1 : 0;
-
-   if (!netif_carrier_ok(dev)) {
-   netdev_info(dev,
-   "link up, %d Mb/s, %s duplex, flow control 
%sabled\n",
-   speed,
-   duplex ? "full" : "half",
-   fc ? "en" : "dis");
-   netif_carrier_on(dev);
-   }
-   }
-}
-
 static struct dsa_switch_driver mv88e6060_switch_driver = {
.tag_protocol   = DSA_TAG_PROTO_TRAILER,
.probe  = mv88e6060_probe,
@@ -280,7 +232,6 @@ static struct dsa_switch_driver mv88e6060_switch_driver = {
.set_addr   = mv88e6060_set_addr,
.phy_read   = mv88e6060_phy_read,
.phy_write  = mv88e6060_phy_write,
-   .poll_link  = mv88e6060_poll_link,
 };

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


[PATCH v2 2/6] net: dsa: mv88e6060: use the correct InitReady bit

2015-11-10 Thread Neil Armstrong
According to the mv88e6060 datasheet, the InitReady bit position
is 11 and the polarity is inverted.
Use the bit correctly to detect the end of initialization.

Acked-by: Andrew Lunn <and...@lunn.ch>
Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
---
 drivers/net/dsa/mv88e6060.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/dsa/mv88e6060.c b/drivers/net/dsa/mv88e6060.c
index 6885ef5..eff5e18 100644
--- a/drivers/net/dsa/mv88e6060.c
+++ b/drivers/net/dsa/mv88e6060.c
@@ -102,7 +102,7 @@ static int mv88e6060_switch_reset(struct dsa_switch *ds)
timeout = jiffies + 1 * HZ;
while (time_before(jiffies, timeout)) {
ret = REG_READ(REG_GLOBAL, 0x00);
-   if ((ret & 0x8000) == 0x)
+   if (ret & 0x800)
break;

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


[PATCH v2 4/6] net: dsa: mv88e6060: use the correct bit shift for mac0

2015-11-10 Thread Neil Armstrong
According to the mv88e6060 datasheet, the first mac byte must
be at position 9 instead of 8 since the bit 8 is used to select
if the mac address must differ for each port for Pause frames.
Use the correct shift and set the same mac address for all port.

Acked-by: Andrew Lunn <and...@lunn.ch>
Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
---
 drivers/net/dsa/mv88e6060.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/dsa/mv88e6060.c b/drivers/net/dsa/mv88e6060.c
index 10647ad..cd08079 100644
--- a/drivers/net/dsa/mv88e6060.c
+++ b/drivers/net/dsa/mv88e6060.c
@@ -188,7 +188,8 @@ static int mv88e6060_setup(struct dsa_switch *ds)

 static int mv88e6060_set_addr(struct dsa_switch *ds, u8 *addr)
 {
-   REG_WRITE(REG_GLOBAL, 0x01, (addr[0] << 8) | addr[1]);
+   /* Use the same MAC Address as FD Pause frames for all ports */
+   REG_WRITE(REG_GLOBAL, 0x01, (addr[0] << 9) | addr[1]);
REG_WRITE(REG_GLOBAL, 0x02, (addr[2] << 8) | addr[3]);
REG_WRITE(REG_GLOBAL, 0x03, (addr[4] << 8) | addr[5]);

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


[RFC PATCH v3 1/2] base: dma-coherent: Add DT property for non exclusive shared-dma-pool

2015-11-10 Thread Neil Armstrong
In order to have the ability to declare a non exclusive shared-dma-pool,
i.e. without the DMA_MEMORY_EXCLUSIVE flag, add the 'no-exclusive' DT
optional parameter to initialize the coherent memory without the flag.

Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
---
 drivers/base/dma-coherent.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/base/dma-coherent.c b/drivers/base/dma-coherent.c
index 55b8398..b57478f 100644
--- a/drivers/base/dma-coherent.c
+++ b/drivers/base/dma-coherent.c
@@ -279,10 +279,14 @@ EXPORT_SYMBOL(dma_mmap_from_coherent);
 static int rmem_dma_device_init(struct reserved_mem *rmem, struct device *dev)
 {
struct dma_coherent_mem *mem = rmem->priv;
+   unsigned flags = 0;
+
+   if (!of_get_flat_dt_prop(rmem->fdt_node, "no-exclusive", NULL))
+   flags |= DMA_MEMORY_EXCLUSIVE;

if (!mem &&
dma_init_coherent_memory(rmem->base, rmem->base, rmem->size,
-DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE,
+DMA_MEMORY_MAP | flags,
 ) != DMA_MEMORY_MAP) {
pr_err("Reserved memory: failed to init DMA memory pool at %pa, 
size %ld MiB\n",
>base, (unsigned long)rmem->size / SZ_1M);
-- 
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v3 0/2] Expose DMA_MEMORY_EXCLUSIVE through shared-dma-pool

2015-11-10 Thread Neil Armstrong
The shared-dma-pool dt node only exposes exclusive memory, but in order to 
export
non-exclusive coherent memory, add the no-exclusive property and document it.

v3: use correct of_get_flat_dt_prop helper
v2: simplify patch by looking for DT attribute in callback

Neil Armstrong (2):
  base: dma-coherent: Add DT property for non exclusive shared-dma-pool
  devicetree: reserved-memory: document the optional no-exclusive parameter

 .../devicetree/bindings/reserved-memory/reserved-memory.txt | 3 +++
 drivers/base/dma-coherent.c | 6 +-
 2 files changed, 8 insertions(+), 1 deletion(-)

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


[RFC PATCH v3 2/2] devicetree: reserved-memory: document the optional no-exclusive parameter

2015-11-10 Thread Neil Armstrong
Document the 'no-exclusive' parameter used for the 'shared-dma-pool'
compatible reserved-memory type.

Acked-by: Rob Herring <r...@kernel.org>
Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
---
 Documentation/devicetree/bindings/reserved-memory/reserved-memory.txt | 3 +++
 1 file changed, 3 insertions(+)

diff --git 
a/Documentation/devicetree/bindings/reserved-memory/reserved-memory.txt 
b/Documentation/devicetree/bindings/reserved-memory/reserved-memory.txt
index 3da0ebd..897aada 100644
--- a/Documentation/devicetree/bindings/reserved-memory/reserved-memory.txt
+++ b/Documentation/devicetree/bindings/reserved-memory/reserved-memory.txt
@@ -63,6 +63,9 @@ reusable (optional) - empty property
   able to reclaim it back. Typically that means that the operating
   system can use that region to store volatile or cached data that
   can be otherwise regenerated or migrated elsewhere.
+no-exclusive (optional) - empty property
+- Indicates the operating system can fall back to the default allocation
+  mechanism if no more enough memory is available from this pool.

 Linux implementation note:
 - If a "linux,cma-default" property is present, then Linux will use the
-- 
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 5/5] arm: dts: Add omap4-hwspinlock support in dm816x

2015-11-12 Thread Neil Armstrong
Add dm816x DT entries for omap4-hwspinlock support as hwmod spinbox.

Cc: Brian Hutchinson <b.hutch...@gmail.com>
Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
---
 arch/arm/boot/dts/dm816x.dtsi | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm/boot/dts/dm816x.dtsi b/arch/arm/boot/dts/dm816x.dtsi
index b9feeea..eb9bea1 100644
--- a/arch/arm/boot/dts/dm816x.dtsi
+++ b/arch/arm/boot/dts/dm816x.dtsi
@@ -226,6 +226,13 @@
};
};

+   spinbox: spinbox@480ca000 {
+   compatible = "ti,omap4-hwspinlock";
+   reg = <0x480ca000 0x2000>;
+   ti,hwmods = "spinbox";
+   #hwlock-cells = <1>;
+   };
+
mdio: mdio@4a100800 {
compatible = "ti,davinci_mdio";
#address-cells = <1>;
-- 
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 3/5] arm: dts: add dm816x pwm property to timers

2015-11-12 Thread Neil Armstrong
Adds ti,timer-pwm property to timers 4 to 7 to permit usage of their
PWM output fonctionnality via the dmtimer driver.

Cc: Brian Hutchinson <b.hutch...@gmail.com>
Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
---
 arch/arm/boot/dts/dm816x.dtsi | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/boot/dts/dm816x.dtsi b/arch/arm/boot/dts/dm816x.dtsi
index eee636d..51ad4a9 100644
--- a/arch/arm/boot/dts/dm816x.dtsi
+++ b/arch/arm/boot/dts/dm816x.dtsi
@@ -323,6 +323,7 @@
reg = <0x48044000 0x2000>;
interrupts = <92>;
ti,hwmods = "timer4";
+   ti,timer-pwm;
};

timer5: timer@48046000 {
@@ -330,6 +331,7 @@
reg = <0x48046000 0x2000>;
interrupts = <93>;
ti,hwmods = "timer5";
+   ti,timer-pwm;
};

timer6: timer@48048000 {
@@ -337,6 +339,7 @@
reg = <0x48048000 0x2000>;
interrupts = <94>;
ti,hwmods = "timer6";
+   ti,timer-pwm;
};

timer7: timer@4804a000 {
@@ -344,6 +347,7 @@
reg = <0x4804a000 0x2000>;
interrupts = <95>;
ti,hwmods = "timer7";
+   ti,timer-pwm;
};

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


[PATCH v2 2/5] arm: dts: add dm816x missing spi DT dma handles

2015-11-12 Thread Neil Armstrong
Add the missing SPI controller DMA handler in the dm816x DT
node, only properties for the two channels on four were present.

Cc: Brian Hutchinson <b.hutch...@gmail.com>
Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
---
 arch/arm/boot/dts/dm816x.dtsi | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/dm816x.dtsi b/arch/arm/boot/dts/dm816x.dtsi
index a7a34e4..eee636d 100644
--- a/arch/arm/boot/dts/dm816x.dtsi
+++ b/arch/arm/boot/dts/dm816x.dtsi
@@ -280,8 +280,11 @@
ti,spi-num-cs = <4>;
ti,hwmods = "mcspi1";
dmas = < 16  17
-18  19>;
-   dma-names = "tx0", "rx0", "tx1", "rx1";
+18  19
+20  21
+22  23>;
+   dma-names = "tx0", "rx0", "tx1", "rx1",
+   "tx2", "rx2", "tx3", "rx3";
};

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


[PATCH v2 0/5] arm: dts: complete dm816x device tree

2015-11-12 Thread Neil Armstrong
In order to fix support for the dm816x platform, add missing bits in
the dm816x dtsi and cleanup OCP.

The last patch adds support for the omap4-hwspinlock.

v2: add ocp hwmod cleanup

Neil Armstrong (5):
  arm: dts: add dm816x missing #mbox-cells
  arm: dts: add dm816x missing spi DT dma handles
  arm: dts: add dm816x pwm property to timers
  arm: dts: remove dm816x invalid DT l3_main hwmod
  arm: dts: Add omap4-hwspinlock support in dm816x

 arch/arm/boot/dts/dm816x.dtsi | 20 +---
 1 file changed, 17 insertions(+), 3 deletions(-)

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


[PATCH v2 4/5] arm: dts: remove dm816x invalid DT l3_main hwmod

2015-11-12 Thread Neil Armstrong
Remove invalid l3_main hwmod entry from dm816x DT ocp node.

Cc: Brian Hutchinson <b.hutch...@gmail.com>
Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
---
 arch/arm/boot/dts/dm816x.dtsi | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/arm/boot/dts/dm816x.dtsi b/arch/arm/boot/dts/dm816x.dtsi
index 51ad4a9..b9feeea 100644
--- a/arch/arm/boot/dts/dm816x.dtsi
+++ b/arch/arm/boot/dts/dm816x.dtsi
@@ -64,7 +64,6 @@
#address-cells = <1>;
#size-cells = <1>;
ranges;
-   ti,hwmods = "l3_main";

prcm: prcm@4818 {
compatible = "ti,dm816-prcm";
-- 
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 0/6] net: dsa: mv88e6060: cleanup and fix setup

2015-11-12 Thread Neil Armstrong
On 11/10/2015 05:14 PM, Andrew Lunn wrote:
> On Tue, Nov 10, 2015 at 04:51:09PM +0100, Neil Armstrong wrote:
>> This patchset introduces some fixes and a registers addressing cleanup for
>> the mv88e6060 DSA driver.
> 
> Hi Neil
> 
> It is normal for netdev to put into the email subject of patches which
> tree these patches are for. "net" would be the latest -rcX and is for
> fixes only. "net-next" would be for new work aimed at the next merge
> window.
> 
> So long as Dave does not complain, leave them as they are now. But
> please try to follow this for your next patches.
> 
> Thanks
>Andrew
> 
Andrew,

Understood, I'll be careful for the next submissions.

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


[PATCH v2 1/5] arm: dts: add dm816x missing #mbox-cells

2015-11-12 Thread Neil Armstrong
Add missing #mbox-cells for dm816x mbox DT node.

Cc: Brian Hutchinson <b.hutch...@gmail.com>
Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
---
 arch/arm/boot/dts/dm816x.dtsi | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/boot/dts/dm816x.dtsi b/arch/arm/boot/dts/dm816x.dtsi
index 3c99cfa..a7a34e4 100644
--- a/arch/arm/boot/dts/dm816x.dtsi
+++ b/arch/arm/boot/dts/dm816x.dtsi
@@ -218,6 +218,7 @@
reg = <0x480c8000 0x2000>;
interrupts = <77>;
ti,hwmods = "mailbox";
+   #mbox-cells = <1>;
ti,mbox-num-users = <4>;
ti,mbox-num-fifos = <12>;
mbox_dsp: mbox_dsp {
-- 
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/4] arm: omap2+: add missing HWMOD_NO_IDLEST in 81xx hwmod data

2015-11-12 Thread Neil Armstrong
On 10/24/2015 12:09 PM, Neil Armstrong wrote:
> Hi,
> 
> 2015-10-24 3:21 GMT+02:00 Tony Lindgren <t...@atomide.com>:
>>
>> Hi,
>>
>> * Neil Armstrong <narmstr...@baylibre.com> [151022 02:19]:
>>> Add missing HWMOD_NO_IDLEST hwmod flag for entries no
>>> having omap4 clkctrl values.
>>
>> Have you checked this is the case both in dm814x and dm816x TRM?
>> Also the documentation may not be complete FYI, might be also
>> worth checking the legacy TI kernel tree to be sure.
>>
>> Regards,
>>
>> Tony
>>
>>> Cc: Brian Hutchinson <b.hutch...@gmail.com>
>>> Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
>>> ---
>>>  arch/arm/mach-omap2/omap_hwmod_81xx_data.c | 3 +++
>>>  1 file changed, 3 insertions(+)
>>>
>>> diff --git a/arch/arm/mach-omap2/omap_hwmod_81xx_data.c 
>>> b/arch/arm/mach-omap2/omap_hwmod_81xx_data.c
>>> index b1288f5..6256052 100644
>>> --- a/arch/arm/mach-omap2/omap_hwmod_81xx_data.c
>>> +++ b/arch/arm/mach-omap2/omap_hwmod_81xx_data.c
>>> @@ -144,6 +144,7 @@ static struct omap_hwmod dm81xx_l4_ls_hwmod = {
>>>   .name   = "l4_ls",
>>>   .clkdm_name = "alwon_l3s_clkdm",
>>>   .class  = _hwmod_class,
>>> + .flags  = HWMOD_NO_IDLEST,
>>>  };
> In DM814x TRM, the CM_ALWON_L3_SLOW_CLKSTCTRL does not have IDLEST field.
> Same in DM816x TRM.
> 
>>>
>>>  /*
>>> @@ -155,6 +156,7 @@ static struct omap_hwmod dm81xx_l4_hs_hwmod = {
>>>   .name   = "l4_hs",
>>>   .clkdm_name = "alwon_l3_med_clkdm",
>>>   .class  = _hwmod_class,
>>> + .flags  = HWMOD_NO_IDLEST,
>>>  };
> In DM814x TRM, the CM_ALWON_L3_MED_CLKSTCTRL does not have IDLEST field.
> Same in DM816x TRM.
> 
>>>
>>>  /* L3 slow -> L4 ls peripheral interface running at 125MHz */
>>> @@ -850,6 +852,7 @@ static struct omap_hwmod dm816x_emac0_hwmod = {
>>>   .name   = "emac0",
>>>   .clkdm_name = "alwon_ethernet_clkdm",
>>>   .class  = _emac_hwmod_class,
>>> + .flags  = HWMOD_NO_IDLEST,
>>>  };
> In this particular case, the IDLEST is handled in the MDIO hwmod.
> 
>>>
>>>  static struct omap_hwmod_ocp_if dm81xx_l4_hs__emac0 = {
>>> --
>>> 1.9.1
> 
> I'll check the TI tree to be sure...
> 
> Regards,
> Neil
> 
Tony,

In TI's tree, there is no L3_MED hwmod but the L3_SLOW hwmod has NO_IDLEST flag.

Is there any other issue about this patchset ?

Neil

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


Re: [PATCH v2 0/5] arm: dts: complete dm816x device tree

2015-11-13 Thread Neil Armstrong
On 11/12/2015 06:47 PM, Tony Lindgren wrote:
> * Neil Armstrong <narmstr...@baylibre.com> [151112 06:08]:
>> In order to fix support for the dm816x platform, add missing bits in
>> the dm816x dtsi and cleanup OCP.
> 
> Which ones are needed as fixes for the v4.4-rc kernel?
> 
> Regards,
> 
> Tony
> 
>> The last patch adds support for the omap4-hwspinlock.
>>
>> v2: add ocp hwmod cleanup
>>
>> Neil Armstrong (5):
>>   arm: dts: add dm816x missing #mbox-cells
>>   arm: dts: add dm816x missing spi DT dma handles
Tony,

The two first are fixes for v4.4-rc.

>>   arm: dts: add dm816x pwm property to timers
>>   arm: dts: remove dm816x invalid DT l3_main hwmod
>>   arm: dts: Add omap4-hwspinlock support in dm816x

the 3 following can wait.

>>
>>  arch/arm/boot/dts/dm816x.dtsi | 20 +---
>>  1 file changed, 17 insertions(+), 3 deletions(-)
>>
>> -- 
>> 1.9.1

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


[PATCH v2 4/4] arm: omap2+: Add hwmod spinbox support for dm816x

2015-11-13 Thread Neil Armstrong
Add dm81xx hwmod data entries for dm816x spinbox support.

Cc: Brian Hutchinson <b.hutch...@gmail.com>
Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
---
 arch/arm/mach-omap2/omap_hwmod_81xx_data.c | 35 ++
 1 file changed, 35 insertions(+)

diff --git a/arch/arm/mach-omap2/omap_hwmod_81xx_data.c 
b/arch/arm/mach-omap2/omap_hwmod_81xx_data.c
index 6256052..275b16c 100644
--- a/arch/arm/mach-omap2/omap_hwmod_81xx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_81xx_data.c
@@ -1036,6 +1036,40 @@ static struct omap_hwmod_ocp_if dm81xx_l4_ls__mailbox = {
.user   = OCP_USER_MPU,
 };

+static struct omap_hwmod_class_sysconfig dm81xx_spinbox_sysc = {
+   .rev_offs   = 0x000,
+   .sysc_offs  = 0x010,
+   .syss_offs  = 0x014,
+   .sysc_flags = SYSC_HAS_CLOCKACTIVITY | SYSC_HAS_SIDLEMODE |
+   SYSC_HAS_SOFTRESET | SYSC_HAS_AUTOIDLE,
+   .idlemodes  = SIDLE_FORCE | SIDLE_NO | SIDLE_SMART,
+   .sysc_fields= _hwmod_sysc_type1,
+};
+
+static struct omap_hwmod_class dm81xx_spinbox_hwmod_class = {
+   .name = "spinbox",
+   .sysc = _spinbox_sysc,
+};
+
+static struct omap_hwmod dm81xx_spinbox_hwmod = {
+   .name   = "spinbox",
+   .clkdm_name = "alwon_l3s_clkdm",
+   .class  = _spinbox_hwmod_class,
+   .main_clk   = "sysclk6_ck",
+   .prcm   = {
+   .omap4 = {
+   .clkctrl_offs = DM81XX_CM_ALWON_SPINBOX_CLKCTRL,
+   .modulemode = MODULEMODE_SWCTRL,
+   },
+   },
+};
+
+static struct omap_hwmod_ocp_if dm81xx_l4_ls__spinbox = {
+   .master = _l4_ls_hwmod,
+   .slave  = _spinbox_hwmod,
+   .user   = OCP_USER_MPU,
+};
+
 static struct omap_hwmod_class dm81xx_tpcc_hwmod_class = {
.name   = "tpcc",
 };
@@ -1298,6 +1332,7 @@ static struct omap_hwmod_ocp_if *dm816x_hwmod_ocp_ifs[] 
__initdata = {
_l4_ls__timer7,
_l4_ls__mcspi1,
_l4_ls__mailbox,
+   _l4_ls__spinbox,
_l4_hs__emac0,
_emac0__mdio,
_l4_hs__emac1,
-- 
1.9.1

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


[PATCH v2 1/4] arm: omap2+: add missing HWMOD_NO_IDLEST in 81xx hwmod data

2015-11-13 Thread Neil Armstrong
Add missing HWMOD_NO_IDLEST hwmod flag for entries not
having omap4 clkctrl values.
The emac0 hwmod flag fixes the davinci_emac driver probe
since the return of pm_resume() call is now checked.

This solves the following boot errors :
[0.121429] omap_hwmod: l4_ls: _wait_target_ready failed: -16
[0.121441] omap_hwmod: l4_ls: cannot be enabled for reset (3)
[0.124342] omap_hwmod: l4_hs: _wait_target_ready failed: -16
[0.124352] omap_hwmod: l4_hs: cannot be enabled for reset (3)
[1.967228] omap_hwmod: emac0: _wait_target_ready failed: -16

Cc: Brian Hutchinson <b.hutch...@gmail.com>
Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
---
 arch/arm/mach-omap2/omap_hwmod_81xx_data.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm/mach-omap2/omap_hwmod_81xx_data.c 
b/arch/arm/mach-omap2/omap_hwmod_81xx_data.c
index b1288f5..6256052 100644
--- a/arch/arm/mach-omap2/omap_hwmod_81xx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_81xx_data.c
@@ -144,6 +144,7 @@ static struct omap_hwmod dm81xx_l4_ls_hwmod = {
.name   = "l4_ls",
.clkdm_name = "alwon_l3s_clkdm",
.class  = _hwmod_class,
+   .flags  = HWMOD_NO_IDLEST,
 };

 /*
@@ -155,6 +156,7 @@ static struct omap_hwmod dm81xx_l4_hs_hwmod = {
.name   = "l4_hs",
.clkdm_name = "alwon_l3_med_clkdm",
.class  = _hwmod_class,
+   .flags  = HWMOD_NO_IDLEST,
 };

 /* L3 slow -> L4 ls peripheral interface running at 125MHz */
@@ -850,6 +852,7 @@ static struct omap_hwmod dm816x_emac0_hwmod = {
.name   = "emac0",
.clkdm_name = "alwon_ethernet_clkdm",
.class  = _emac_hwmod_class,
+   .flags  = HWMOD_NO_IDLEST,
 };

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


[PATCH v2 3/4] arm: plat-omap: add DT support for ti,dm816-timer

2015-11-13 Thread Neil Armstrong
Adds ti,dm816-timer to the dmtimer OF match table.

Cc: Brian Hutchinson <b.hutch...@gmail.com>
Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
---
 arch/arm/plat-omap/dmtimer.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/plat-omap/dmtimer.c b/arch/arm/plat-omap/dmtimer.c
index 8ca94d3..28a6550 100644
--- a/arch/arm/plat-omap/dmtimer.c
+++ b/arch/arm/plat-omap/dmtimer.c
@@ -943,6 +943,10 @@ static const struct of_device_id omap_timer_match[] = {
.compatible = "ti,am335x-timer-1ms",
.data = _pdata,
},
+   {
+   .compatible = "ti,dm816-timer",
+   .data = _pdata,
+   },
{},
 };
 MODULE_DEVICE_TABLE(of, omap_timer_match);
-- 
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 0/4] arm: omap2+: complete dm816x hwmod and clkdev

2015-11-13 Thread Neil Armstrong
In order to fix support for the dm816x platform, add missing bits in
the 81xx hwmod data.

The clk related patch adds the missing clkdev entries to fix all source
selection in the dmtimer driver.

The last patch adds hwmod support of the spinbox module.

v2: add error logs for first patch

Neil Armstrong (4):
  arm: omap2+: add missing HWMOD_NO_IDLEST in 81xx hwmod data
  clk: ti816x: Add missing dmtimer clkdev entries
  arm: plat-omap: add DT support for ti,dm816-timer
  arm: omap2+: Add hwmod spinbox support for dm816x

 arch/arm/mach-omap2/omap_hwmod_81xx_data.c | 38 ++
 arch/arm/plat-omap/dmtimer.c   |  4 
 drivers/clk/ti/clk-816x.c  |  2 ++
 3 files changed, 44 insertions(+)

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


[PATCH v2 2/4] clk: ti816x: Add missing dmtimer clkdev entries

2015-11-13 Thread Neil Armstrong
Add missing clkdev dmtimer related entries for dm816x.
32Khz and ext sources were missing.

Cc: Brian Hutchinson <b.hutch...@gmail.com>
Acked-by: Tony Lindgren <t...@atomide.com>
Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
---
 drivers/clk/ti/clk-816x.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/clk/ti/clk-816x.c b/drivers/clk/ti/clk-816x.c
index 1dfad0c..2a5d84f 100644
--- a/drivers/clk/ti/clk-816x.c
+++ b/drivers/clk/ti/clk-816x.c
@@ -20,6 +20,8 @@ static struct ti_dt_clk dm816x_clks[] = {
DT_CLK(NULL, "sys_clkin", "sys_clkin_ck"),
DT_CLK(NULL, "timer_sys_ck", "sys_clkin_ck"),
DT_CLK(NULL, "sys_32k_ck", "sys_32k_ck"),
+   DT_CLK(NULL, "timer_32k_ck", "sysclk18_ck"),
+   DT_CLK(NULL, "timer_ext_ck", "tclkin_ck"),
DT_CLK(NULL, "mpu_ck", "mpu_ck"),
DT_CLK(NULL, "timer1_fck", "timer1_fck"),
DT_CLK(NULL, "timer2_fck", "timer2_fck"),
-- 
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/4] arm: omap2+: add missing HWMOD_NO_IDLEST in 81xx hwmod data

2015-11-13 Thread Neil Armstrong
On 11/13/2015 03:41 PM, Tony Lindgren wrote:
> * Neil Armstrong <narmstr...@baylibre.com> [151112 06:16]:
>> On 10/24/2015 12:09 PM, Neil Armstrong wrote:
>>> Hi,
>>>
>>> 2015-10-24 3:21 GMT+02:00 Tony Lindgren <t...@atomide.com>:
>>>>
>>>> Hi,
>>>>
>>>> * Neil Armstrong <narmstr...@baylibre.com> [151022 02:19]:
>>>>> Add missing HWMOD_NO_IDLEST hwmod flag for entries no
>>>>> having omap4 clkctrl values.
>>>>
>>>> Have you checked this is the case both in dm814x and dm816x TRM?
>>>> Also the documentation may not be complete FYI, might be also
>>>> worth checking the legacy TI kernel tree to be sure.
>>>>
>>>> Regards,
>>>>
>>>> Tony
>>>>
>>>>> Cc: Brian Hutchinson <b.hutch...@gmail.com>
>>>>> Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
>>>>> ---
>>>>>  arch/arm/mach-omap2/omap_hwmod_81xx_data.c | 3 +++
>>>>>  1 file changed, 3 insertions(+)
>>>>>
>>>>> diff --git a/arch/arm/mach-omap2/omap_hwmod_81xx_data.c 
>>>>> b/arch/arm/mach-omap2/omap_hwmod_81xx_data.c
>>>>> index b1288f5..6256052 100644
>>>>> --- a/arch/arm/mach-omap2/omap_hwmod_81xx_data.c
>>>>> +++ b/arch/arm/mach-omap2/omap_hwmod_81xx_data.c
>>>>> @@ -144,6 +144,7 @@ static struct omap_hwmod dm81xx_l4_ls_hwmod = {
>>>>>   .name   = "l4_ls",
>>>>>   .clkdm_name = "alwon_l3s_clkdm",
>>>>>   .class  = _hwmod_class,
>>>>> + .flags  = HWMOD_NO_IDLEST,
>>>>>  };
>>> In DM814x TRM, the CM_ALWON_L3_SLOW_CLKSTCTRL does not have IDLEST field.
>>> Same in DM816x TRM.
>>>
>>>>>
>>>>>  /*
>>>>> @@ -155,6 +156,7 @@ static struct omap_hwmod dm81xx_l4_hs_hwmod = {
>>>>>   .name   = "l4_hs",
>>>>>   .clkdm_name = "alwon_l3_med_clkdm",
>>>>>   .class  = _hwmod_class,
>>>>> + .flags  = HWMOD_NO_IDLEST,
>>>>>  };
>>> In DM814x TRM, the CM_ALWON_L3_MED_CLKSTCTRL does not have IDLEST field.
>>> Same in DM816x TRM.
>>>
>>>>>
>>>>>  /* L3 slow -> L4 ls peripheral interface running at 125MHz */
>>>>> @@ -850,6 +852,7 @@ static struct omap_hwmod dm816x_emac0_hwmod = {
>>>>>   .name   = "emac0",
>>>>>   .clkdm_name = "alwon_ethernet_clkdm",
>>>>>   .class  = _emac_hwmod_class,
>>>>> + .flags  = HWMOD_NO_IDLEST,
>>>>>  };
>>> In this particular case, the IDLEST is handled in the MDIO hwmod.
>>>
>>>>>
>>>>>  static struct omap_hwmod_ocp_if dm81xx_l4_hs__emac0 = {
>>>>> --
>>>>> 1.9.1
>>>
>>> I'll check the TI tree to be sure...
>>>
>>> Regards,
>>> Neil
>>>
>> Tony,
>>
>> In TI's tree, there is no L3_MED hwmod but the L3_SLOW hwmod has NO_IDLEST 
>> flag.
>>
>> Is there any other issue about this patchset ?
> 
> Thanks for checking. Well one thing, if this is needed as fix, then a
> description of what happens without it would be good to have.
> 
> Regards,
> 
> Tony
> 
Tony,

I'll send a patchset with the error lines in a few minutes.

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


  1   2   3   4   5   6   7   8   9   10   >