RE: [EXT] [PATCH net-next v2 0/2] phylink: API changes

2018-03-28 Thread Yan Markman
Hi Florian
Please keep CC  Yelena Krivosheev 
for changes withdrivers/net/ethernet/marvell/mvneta.c
Thanks
Yan Markman
Tel. 05-44732819


-Original Message-
From: Florian Fainelli [mailto:f.faine...@gmail.com] 
Sent: Thursday, March 29, 2018 1:44 AM
To: net...@vger.kernel.org
Cc: Florian Fainelli ; Thomas Petazzoni 
; Andrew Lunn ; David S. 
Miller ; Russell King ; open 
list ; Antoine Tenart 
; Yan Markman ; Stefan 
Chulski ; Maxime Chevallier 
; Miquel Raynal 
; Marcin Wojtas 
Subject: [EXT] [PATCH net-next v2 0/2] phylink: API changes

External Email

--
Hi all,

This patch series contains two API changes to PHYLINK which will later be used 
by DSA to migrate to PHYLINK. Because these are API changes that impact other 
outstanding work (e.g: MVPP2) I would rather get them included sooner to 
minimize conflicts.

Thank you!

Changes in v2:

- added missing documentation to mac_link_{up,down} that the interface
  must be configured in mac_config()

- added Russell's, Andrew's and my tags

Florian Fainelli (1):
  net: phy: phylink: Provide PHY interface to mac_link_{up,down}

Russell King (1):
  sfp/phylink: move module EEPROM ethtool access into netdev core
ethtool

 drivers/net/ethernet/marvell/mvneta.c | 22 +++---
 drivers/net/phy/phylink.c | 32 +++-
 drivers/net/phy/sfp-bus.c |  6 ++
 include/linux/netdevice.h |  3 +++
 include/linux/phylink.h   | 17 +++--
 net/core/ethtool.c|  7 +++
 6 files changed, 29 insertions(+), 58 deletions(-)

--
2.14.1



RE: [EXT] [PATCH net-next v2 0/2] phylink: API changes

2018-03-28 Thread Yan Markman
Hi Florian
Please keep CC  Yelena Krivosheev 
for changes withdrivers/net/ethernet/marvell/mvneta.c
Thanks
Yan Markman
Tel. 05-44732819


-Original Message-
From: Florian Fainelli [mailto:f.faine...@gmail.com] 
Sent: Thursday, March 29, 2018 1:44 AM
To: net...@vger.kernel.org
Cc: Florian Fainelli ; Thomas Petazzoni 
; Andrew Lunn ; David S. 
Miller ; Russell King ; open 
list ; Antoine Tenart 
; Yan Markman ; Stefan 
Chulski ; Maxime Chevallier 
; Miquel Raynal 
; Marcin Wojtas 
Subject: [EXT] [PATCH net-next v2 0/2] phylink: API changes

External Email

--
Hi all,

This patch series contains two API changes to PHYLINK which will later be used 
by DSA to migrate to PHYLINK. Because these are API changes that impact other 
outstanding work (e.g: MVPP2) I would rather get them included sooner to 
minimize conflicts.

Thank you!

Changes in v2:

- added missing documentation to mac_link_{up,down} that the interface
  must be configured in mac_config()

- added Russell's, Andrew's and my tags

Florian Fainelli (1):
  net: phy: phylink: Provide PHY interface to mac_link_{up,down}

Russell King (1):
  sfp/phylink: move module EEPROM ethtool access into netdev core
ethtool

 drivers/net/ethernet/marvell/mvneta.c | 22 +++---
 drivers/net/phy/phylink.c | 32 +++-
 drivers/net/phy/sfp-bus.c |  6 ++
 include/linux/netdevice.h |  3 +++
 include/linux/phylink.h   | 17 +++--
 net/core/ethtool.c|  7 +++
 6 files changed, 29 insertions(+), 58 deletions(-)

--
2.14.1



RE: [EXT] [PATCH net-next v2 1/2] net: phy: phylink: Provide PHY interface to mac_link_{up,down}

2018-03-28 Thread Yan Markman
Hi Florian
Please keep CC  Yelena Krivosheev 
for changes withdrivers/net/ethernet/marvell/mvneta.c
Thanks
Yan Markman
Tel. 05-44732819


-Original Message-
From: Florian Fainelli [mailto:f.faine...@gmail.com] 
Sent: Thursday, March 29, 2018 1:44 AM
To: net...@vger.kernel.org
Cc: Florian Fainelli ; Thomas Petazzoni 
; Andrew Lunn ; David S. 
Miller ; Russell King ; open 
list ; Antoine Tenart 
; Yan Markman ; Stefan 
Chulski ; Maxime Chevallier 
; Miquel Raynal 
; Marcin Wojtas 
Subject: [EXT] [PATCH net-next v2 1/2] net: phy: phylink: Provide PHY interface 
to mac_link_{up,down}

External Email

--
In preparation for having DSA transition entirely to PHYLINK, we need to pass a 
PHY interface type to the mac_link_{up,down} callbacks because we may have to 
make decisions on that (e.g: turn on/off RGMII interfaces etc.). We do not pass 
an entire phylink_link_state because not all parameters (pause, duplex etc.) 
are defined when the link is down, only link and interface are.

Update mvneta accordingly since it currently implements phylink_mac_ops.

Acked-by: Russell King 
Signed-off-by: Florian Fainelli 
---
 drivers/net/ethernet/marvell/mvneta.c |  4 +++-
 drivers/net/phy/phylink.c |  4 +++-
 include/linux/phylink.h   | 14 +++---
 3 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvneta.c 
b/drivers/net/ethernet/marvell/mvneta.c
index eaa4bb80f1c9..cd09bde55596 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -3396,7 +3396,8 @@ static void mvneta_set_eee(struct mvneta_port *pp, bool 
enable)
mvreg_write(pp, MVNETA_LPI_CTRL_1, lpi_ctl1);  }
 
-static void mvneta_mac_link_down(struct net_device *ndev, unsigned int mode)
+static void mvneta_mac_link_down(struct net_device *ndev, unsigned int mode,
+phy_interface_t interface)
 {
struct mvneta_port *pp = netdev_priv(ndev);
u32 val;
@@ -3415,6 +3416,7 @@ static void mvneta_mac_link_down(struct net_device *ndev, 
unsigned int mode)  }
 
 static void mvneta_mac_link_up(struct net_device *ndev, unsigned int mode,
+  phy_interface_t interface,
   struct phy_device *phy)
 {
struct mvneta_port *pp = netdev_priv(ndev); diff --git 
a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 
51a011a349fe..9b1e4721ea3a 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -470,10 +470,12 @@ static void phylink_resolve(struct work_struct *w)
if (link_state.link != netif_carrier_ok(ndev)) {
if (!link_state.link) {
netif_carrier_off(ndev);
-   pl->ops->mac_link_down(ndev, pl->link_an_mode);
+   pl->ops->mac_link_down(ndev, pl->link_an_mode,
+  pl->phy_state.interface);
netdev_info(ndev, "Link is Down\n");
} else {
pl->ops->mac_link_up(ndev, pl->link_an_mode,
+pl->phy_state.interface,
 pl->phydev);
 
netif_carrier_on(ndev);
diff --git a/include/linux/phylink.h b/include/linux/phylink.h index 
bd137c273d38..e95cc12030fa 100644
--- a/include/linux/phylink.h
+++ b/include/linux/phylink.h
@@ -73,8 +73,10 @@ struct phylink_mac_ops {
void (*mac_config)(struct net_device *ndev, unsigned int mode,
   const struct phylink_link_state *state);
void (*mac_an_restart)(struct net_device *ndev);
-   void (*mac_link_down)(struct net_device *ndev, unsigned int mode);
+   void (*mac_link_down)(struct net_device *ndev, unsigned int mode,
+ phy_interface_t interface);
void (*mac_link_up)(struct net_device *ndev, unsigned int mode,
+   phy_interface_t interface,
struct phy_device *phy);
 };
 
@@ -161,25 +163,31 @@ void mac_an_restart(struct net_device *ndev);
  * mac_link_down() - take the link down
  * @ndev: a pointer to a  net_device for the MAC.
  * @mode: link autonegotiation mode
+ * @interface: link  phy_interface_t mode
  *
  * If @mode is not an in-band negotiation mode (as defined by
  * phylink_autoneg_inband()), force the link down and disable any
- * Energy Efficient Ethernet MAC configuration.
+ * Energy Efficient 

RE: [EXT] [PATCH net-next v2 1/2] net: phy: phylink: Provide PHY interface to mac_link_{up,down}

2018-03-28 Thread Yan Markman
Hi Florian
Please keep CC  Yelena Krivosheev 
for changes withdrivers/net/ethernet/marvell/mvneta.c
Thanks
Yan Markman
Tel. 05-44732819


-Original Message-
From: Florian Fainelli [mailto:f.faine...@gmail.com] 
Sent: Thursday, March 29, 2018 1:44 AM
To: net...@vger.kernel.org
Cc: Florian Fainelli ; Thomas Petazzoni 
; Andrew Lunn ; David S. 
Miller ; Russell King ; open 
list ; Antoine Tenart 
; Yan Markman ; Stefan 
Chulski ; Maxime Chevallier 
; Miquel Raynal 
; Marcin Wojtas 
Subject: [EXT] [PATCH net-next v2 1/2] net: phy: phylink: Provide PHY interface 
to mac_link_{up,down}

External Email

--
In preparation for having DSA transition entirely to PHYLINK, we need to pass a 
PHY interface type to the mac_link_{up,down} callbacks because we may have to 
make decisions on that (e.g: turn on/off RGMII interfaces etc.). We do not pass 
an entire phylink_link_state because not all parameters (pause, duplex etc.) 
are defined when the link is down, only link and interface are.

Update mvneta accordingly since it currently implements phylink_mac_ops.

Acked-by: Russell King 
Signed-off-by: Florian Fainelli 
---
 drivers/net/ethernet/marvell/mvneta.c |  4 +++-
 drivers/net/phy/phylink.c |  4 +++-
 include/linux/phylink.h   | 14 +++---
 3 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvneta.c 
b/drivers/net/ethernet/marvell/mvneta.c
index eaa4bb80f1c9..cd09bde55596 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -3396,7 +3396,8 @@ static void mvneta_set_eee(struct mvneta_port *pp, bool 
enable)
mvreg_write(pp, MVNETA_LPI_CTRL_1, lpi_ctl1);  }
 
-static void mvneta_mac_link_down(struct net_device *ndev, unsigned int mode)
+static void mvneta_mac_link_down(struct net_device *ndev, unsigned int mode,
+phy_interface_t interface)
 {
struct mvneta_port *pp = netdev_priv(ndev);
u32 val;
@@ -3415,6 +3416,7 @@ static void mvneta_mac_link_down(struct net_device *ndev, 
unsigned int mode)  }
 
 static void mvneta_mac_link_up(struct net_device *ndev, unsigned int mode,
+  phy_interface_t interface,
   struct phy_device *phy)
 {
struct mvneta_port *pp = netdev_priv(ndev); diff --git 
a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 
51a011a349fe..9b1e4721ea3a 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -470,10 +470,12 @@ static void phylink_resolve(struct work_struct *w)
if (link_state.link != netif_carrier_ok(ndev)) {
if (!link_state.link) {
netif_carrier_off(ndev);
-   pl->ops->mac_link_down(ndev, pl->link_an_mode);
+   pl->ops->mac_link_down(ndev, pl->link_an_mode,
+  pl->phy_state.interface);
netdev_info(ndev, "Link is Down\n");
} else {
pl->ops->mac_link_up(ndev, pl->link_an_mode,
+pl->phy_state.interface,
 pl->phydev);
 
netif_carrier_on(ndev);
diff --git a/include/linux/phylink.h b/include/linux/phylink.h index 
bd137c273d38..e95cc12030fa 100644
--- a/include/linux/phylink.h
+++ b/include/linux/phylink.h
@@ -73,8 +73,10 @@ struct phylink_mac_ops {
void (*mac_config)(struct net_device *ndev, unsigned int mode,
   const struct phylink_link_state *state);
void (*mac_an_restart)(struct net_device *ndev);
-   void (*mac_link_down)(struct net_device *ndev, unsigned int mode);
+   void (*mac_link_down)(struct net_device *ndev, unsigned int mode,
+ phy_interface_t interface);
void (*mac_link_up)(struct net_device *ndev, unsigned int mode,
+   phy_interface_t interface,
struct phy_device *phy);
 };
 
@@ -161,25 +163,31 @@ void mac_an_restart(struct net_device *ndev);
  * mac_link_down() - take the link down
  * @ndev: a pointer to a  net_device for the MAC.
  * @mode: link autonegotiation mode
+ * @interface: link  phy_interface_t mode
  *
  * If @mode is not an in-band negotiation mode (as defined by
  * phylink_autoneg_inband()), force the link down and disable any
- * Energy Efficient Ethernet MAC configuration.
+ * Energy Efficient Ethernet MAC configuration. Interface type
+ * selection must be done in mac_config().
  */
-void mac_link_down(struct net_device *ndev, unsigned int mode);
+void mac_link_down(struct net_device *ndev, unsigned int mode,
+  phy_interface_t interface);
 
 /**
  * mac_link_up() - allow the link to come up
  * @ndev: a pointer to a  net_device for the MAC.
  * @mode: 

[PATCH 3/9] staging: ks7010: Reorder ks_wlan_netdev_ops members.

2018-03-28 Thread Quytelda Kahja
Reorder the members of 'ks_wlan_netdev_ops' to reflect the order
of their counterparts in the kernel's 'struct net_device_ops'.

Signed-off-by: Quytelda Kahja 
---
 drivers/staging/ks7010/ks_wlan_net.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index 544bfa403d9f..2f84c5dc1324 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -70,14 +70,14 @@ static const struct iw_handler_def ks_wlan_handler_def;
  * function prototypes
  */
 static int ks_wlan_open(struct net_device *dev);
-static void ks_wlan_tx_timeout(struct net_device *dev);
-static int ks_wlan_start_xmit(struct sk_buff *skb, struct net_device *dev);
 static int ks_wlan_close(struct net_device *dev);
+static int ks_wlan_start_xmit(struct sk_buff *skb, struct net_device *dev);
 static void ks_wlan_set_multicast_list(struct net_device *dev);
-static struct net_device_stats *ks_wlan_get_stats(struct net_device *dev);
 static int ks_wlan_set_mac_address(struct net_device *dev, void *addr);
 static int ks_wlan_netdev_ioctl(struct net_device *dev, struct ifreq *rq,
int cmd);
+static void ks_wlan_tx_timeout(struct net_device *dev);
+static struct net_device_stats *ks_wlan_get_stats(struct net_device *dev);
 
 static atomic_t update_phyinfo;
 static struct timer_list update_phyinfo_timer;
@@ -2874,14 +2874,14 @@ static const unsigned char dummy_addr[] = {
 };
 
 static const struct net_device_ops ks_wlan_netdev_ops = {
-   .ndo_start_xmit = ks_wlan_start_xmit,
.ndo_open = ks_wlan_open,
.ndo_stop = ks_wlan_close,
-   .ndo_do_ioctl = ks_wlan_netdev_ioctl,
+   .ndo_start_xmit = ks_wlan_start_xmit,
+   .ndo_set_rx_mode = ks_wlan_set_multicast_list,
.ndo_set_mac_address = ks_wlan_set_mac_address,
-   .ndo_get_stats = ks_wlan_get_stats,
+   .ndo_do_ioctl = ks_wlan_netdev_ioctl,
.ndo_tx_timeout = ks_wlan_tx_timeout,
-   .ndo_set_rx_mode = ks_wlan_set_multicast_list,
+   .ndo_get_stats = ks_wlan_get_stats,
 };
 
 int ks_wlan_net_start(struct net_device *dev)
-- 
2.16.3



[PATCH 3/9] staging: ks7010: Reorder ks_wlan_netdev_ops members.

2018-03-28 Thread Quytelda Kahja
Reorder the members of 'ks_wlan_netdev_ops' to reflect the order
of their counterparts in the kernel's 'struct net_device_ops'.

Signed-off-by: Quytelda Kahja 
---
 drivers/staging/ks7010/ks_wlan_net.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index 544bfa403d9f..2f84c5dc1324 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -70,14 +70,14 @@ static const struct iw_handler_def ks_wlan_handler_def;
  * function prototypes
  */
 static int ks_wlan_open(struct net_device *dev);
-static void ks_wlan_tx_timeout(struct net_device *dev);
-static int ks_wlan_start_xmit(struct sk_buff *skb, struct net_device *dev);
 static int ks_wlan_close(struct net_device *dev);
+static int ks_wlan_start_xmit(struct sk_buff *skb, struct net_device *dev);
 static void ks_wlan_set_multicast_list(struct net_device *dev);
-static struct net_device_stats *ks_wlan_get_stats(struct net_device *dev);
 static int ks_wlan_set_mac_address(struct net_device *dev, void *addr);
 static int ks_wlan_netdev_ioctl(struct net_device *dev, struct ifreq *rq,
int cmd);
+static void ks_wlan_tx_timeout(struct net_device *dev);
+static struct net_device_stats *ks_wlan_get_stats(struct net_device *dev);
 
 static atomic_t update_phyinfo;
 static struct timer_list update_phyinfo_timer;
@@ -2874,14 +2874,14 @@ static const unsigned char dummy_addr[] = {
 };
 
 static const struct net_device_ops ks_wlan_netdev_ops = {
-   .ndo_start_xmit = ks_wlan_start_xmit,
.ndo_open = ks_wlan_open,
.ndo_stop = ks_wlan_close,
-   .ndo_do_ioctl = ks_wlan_netdev_ioctl,
+   .ndo_start_xmit = ks_wlan_start_xmit,
+   .ndo_set_rx_mode = ks_wlan_set_multicast_list,
.ndo_set_mac_address = ks_wlan_set_mac_address,
-   .ndo_get_stats = ks_wlan_get_stats,
+   .ndo_do_ioctl = ks_wlan_netdev_ioctl,
.ndo_tx_timeout = ks_wlan_tx_timeout,
-   .ndo_set_rx_mode = ks_wlan_set_multicast_list,
+   .ndo_get_stats = ks_wlan_get_stats,
 };
 
 int ks_wlan_net_start(struct net_device *dev)
-- 
2.16.3



[PATCH 4/9] staging: ks7010: Rename ks_wlan_set_multicast_list()

2018-03-28 Thread Quytelda Kahja
All of the net_device_ops callbacks are named after their counterparts
in the kernel's 'struct net_device_ops', except
ks_wlan_set_multicast_list().  Rename it to ks_wlan_set_rx_mode() for
greater consistency.

Signed-off-by: Quytelda Kahja 
---
 drivers/staging/ks7010/ks_wlan_net.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index 2f84c5dc1324..41f89f930f50 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -72,7 +72,7 @@ static const struct iw_handler_def ks_wlan_handler_def;
 static int ks_wlan_open(struct net_device *dev);
 static int ks_wlan_close(struct net_device *dev);
 static int ks_wlan_start_xmit(struct sk_buff *skb, struct net_device *dev);
-static void ks_wlan_set_multicast_list(struct net_device *dev);
+static void ks_wlan_set_rx_mode(struct net_device *dev);
 static int ks_wlan_set_mac_address(struct net_device *dev, void *addr);
 static int ks_wlan_netdev_ioctl(struct net_device *dev, struct ifreq *rq,
int cmd);
@@ -2833,7 +2833,7 @@ void send_packet_complete(struct ks_wlan_private *priv, 
struct sk_buff *skb)
  * This routine is not state sensitive and need not be SMP locked.
  */
 static
-void ks_wlan_set_multicast_list(struct net_device *dev)
+void ks_wlan_set_rx_mode(struct net_device *dev)
 {
struct ks_wlan_private *priv = netdev_priv(dev);
 
@@ -2877,7 +2877,7 @@ static const struct net_device_ops ks_wlan_netdev_ops = {
.ndo_open = ks_wlan_open,
.ndo_stop = ks_wlan_close,
.ndo_start_xmit = ks_wlan_start_xmit,
-   .ndo_set_rx_mode = ks_wlan_set_multicast_list,
+   .ndo_set_rx_mode = ks_wlan_set_rx_mode,
.ndo_set_mac_address = ks_wlan_set_mac_address,
.ndo_do_ioctl = ks_wlan_netdev_ioctl,
.ndo_tx_timeout = ks_wlan_tx_timeout,
-- 
2.16.3



[PATCH 2/9] staging: ks7010: Remove unecessary cast.

2018-03-28 Thread Quytelda Kahja
The driver casts '_wlan_handler_def' to 'struct iw_handler_def *',
but it is already of that type.

Signed-off-by: Quytelda Kahja 
---
 drivers/staging/ks7010/ks_wlan_net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index f6e496aa68de..544bfa403d9f 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -2904,7 +2904,7 @@ int ks_wlan_net_start(struct net_device *dev)
 
/* The ks_wlan-specific entries in the device structure. */
dev->netdev_ops = _wlan_netdev_ops;
-   dev->wireless_handlers = (struct iw_handler_def *)_wlan_handler_def;
+   dev->wireless_handlers = _wlan_handler_def;
dev->watchdog_timeo = TX_TIMEOUT;
 
netif_carrier_off(dev);
-- 
2.16.3



Re: [PATCH v3 1/2] of_net: Implement of_get_nvmem_mac_address helper

2018-03-28 Thread Mike Looijmans

On 28-03-18 00:50, Florian Fainelli wrote:

On 03/27/2018 02:52 AM, Mike Looijmans wrote:

It's common practice to store MAC addresses for network interfaces into
nvmem devices. However the code to actually do this in the kernel lacks,
so this patch adds of_get_nvmem_mac_address() for drivers to obtain the
address from an nvmem cell provider.

This is particulary useful on devices where the ethernet interface cannot
be configured by the bootloader, for example because it's in an FPGA.

Signed-off-by: Mike Looijmans 
---
  Documentation/devicetree/bindings/net/ethernet.txt |  2 ++
  drivers/of/of_net.c| 40 ++
  include/linux/of_net.h |  6 
  3 files changed, 48 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/ethernet.txt 
b/Documentation/devicetree/bindings/net/ethernet.txt
index 2974e63..cfc376b 100644
--- a/Documentation/devicetree/bindings/net/ethernet.txt
+++ b/Documentation/devicetree/bindings/net/ethernet.txt
@@ -10,6 +10,8 @@ Documentation/devicetree/bindings/phy/phy-bindings.txt.
the boot program; should be used in cases where the MAC address assigned to
the device by the boot program is different from the "local-mac-address"
property;
+- nvmem-cells: phandle, reference to an nvmem node for the MAC address;
+- nvmem-cell-names: string, should be "mac-address" if nvmem is to be used;
  - max-speed: number, specifies maximum speed in Mbit/s supported by the 
device;
  - max-frame-size: number, maximum transfer unit (IEEE defined MTU), rather 
than
the maximum frame size (there's contradiction in the Devicetree
diff --git a/drivers/of/of_net.c b/drivers/of/of_net.c
index d820f3e..1c5d372 100644
--- a/drivers/of/of_net.c
+++ b/drivers/of/of_net.c
@@ -7,6 +7,7 @@
   */
  #include 
  #include 
+#include 
  #include 
  #include 
  #include 
@@ -80,3 +81,42 @@ const void *of_get_mac_address(struct device_node *np)
return of_get_mac_addr(np, "address");
  }
  EXPORT_SYMBOL(of_get_mac_address);
+
+/**
+ * Obtain the MAC address from an nvmem provider named 'mac-address' through
+ * device tree.
+ * On success, copies the new address into memory pointed to by addr and
+ * returns 0. Returns a negative error code otherwise.
+ * @np:Device tree node containing the nvmem-cells phandle
+ * @addr:  Pointer to receive the MAC address using ether_addr_copy()
+ */
+int of_get_nvmem_mac_address(struct device_node *np, void *addr)
+{
+   struct nvmem_cell *cell;
+   const void *mac;
+   size_t len;
+   int ret;
+
+   cell = of_nvmem_cell_get(np, "mac-address");
+   if (IS_ERR(cell))
+   return PTR_ERR(cell);
+
+   mac = nvmem_cell_read(cell, );
+
+   nvmem_cell_put(cell);
+
+   if (IS_ERR(mac))
+   return PTR_ERR(mac);
+
+   if (len < 6 || !is_valid_ether_addr(mac)) {
+   ret = -EINVAL;


Just one nit here, can you use ETH_ALEN instead of 6? With that fixed:

Reviewed-by: Florian Fainelli 



Ok, implemented and tested it, and v4 is on the way with that change.


Kind regards,

Mike Looijmans
System Expert

TOPIC Products
Materiaalweg 4, NL-5681 RJ Best
Postbus 440, NL-5680 AK Best
Telefoon: +31 (0) 499 33 69 79
E-mail: mike.looijm...@topicproducts.com
Website: www.topicproducts.com

Please consider the environment before printing this e-mail





[PATCH 1/9] staging: ks7010: Replace manual array copy with ether_addr_copy().

2018-03-28 Thread Quytelda Kahja
Copying the dummy HW address into the struct net_device doesn't need
to be done byte by byte; use ether_addr_copy() instead.
Additionally, dev->dev_addr is not eight bytes long.
ether_setup() sets the dev->addr_len to ETH_ALEN (defined as 6)
in the net core code.

Signed-off-by: Quytelda Kahja 
---
 drivers/staging/ks7010/ks_wlan_net.c | 10 +-
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index 6106e79c5163..f6e496aa68de 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -2900,15 +2900,7 @@ int ks_wlan_net_start(struct net_device *dev)
timer_setup(_phyinfo_timer, ks_wlan_update_phyinfo_timeout, 0);
 
/* dummy address set */
-   memcpy(priv->eth_addr, dummy_addr, ETH_ALEN);
-   dev->dev_addr[0] = priv->eth_addr[0];
-   dev->dev_addr[1] = priv->eth_addr[1];
-   dev->dev_addr[2] = priv->eth_addr[2];
-   dev->dev_addr[3] = priv->eth_addr[3];
-   dev->dev_addr[4] = priv->eth_addr[4];
-   dev->dev_addr[5] = priv->eth_addr[5];
-   dev->dev_addr[6] = 0x00;
-   dev->dev_addr[7] = 0x00;
+   ether_addr_copy(dev->dev_addr, priv->eth_addr);
 
/* The ks_wlan-specific entries in the device structure. */
dev->netdev_ops = _wlan_netdev_ops;
-- 
2.16.3



[PATCH 4/9] staging: ks7010: Rename ks_wlan_set_multicast_list()

2018-03-28 Thread Quytelda Kahja
All of the net_device_ops callbacks are named after their counterparts
in the kernel's 'struct net_device_ops', except
ks_wlan_set_multicast_list().  Rename it to ks_wlan_set_rx_mode() for
greater consistency.

Signed-off-by: Quytelda Kahja 
---
 drivers/staging/ks7010/ks_wlan_net.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index 2f84c5dc1324..41f89f930f50 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -72,7 +72,7 @@ static const struct iw_handler_def ks_wlan_handler_def;
 static int ks_wlan_open(struct net_device *dev);
 static int ks_wlan_close(struct net_device *dev);
 static int ks_wlan_start_xmit(struct sk_buff *skb, struct net_device *dev);
-static void ks_wlan_set_multicast_list(struct net_device *dev);
+static void ks_wlan_set_rx_mode(struct net_device *dev);
 static int ks_wlan_set_mac_address(struct net_device *dev, void *addr);
 static int ks_wlan_netdev_ioctl(struct net_device *dev, struct ifreq *rq,
int cmd);
@@ -2833,7 +2833,7 @@ void send_packet_complete(struct ks_wlan_private *priv, 
struct sk_buff *skb)
  * This routine is not state sensitive and need not be SMP locked.
  */
 static
-void ks_wlan_set_multicast_list(struct net_device *dev)
+void ks_wlan_set_rx_mode(struct net_device *dev)
 {
struct ks_wlan_private *priv = netdev_priv(dev);
 
@@ -2877,7 +2877,7 @@ static const struct net_device_ops ks_wlan_netdev_ops = {
.ndo_open = ks_wlan_open,
.ndo_stop = ks_wlan_close,
.ndo_start_xmit = ks_wlan_start_xmit,
-   .ndo_set_rx_mode = ks_wlan_set_multicast_list,
+   .ndo_set_rx_mode = ks_wlan_set_rx_mode,
.ndo_set_mac_address = ks_wlan_set_mac_address,
.ndo_do_ioctl = ks_wlan_netdev_ioctl,
.ndo_tx_timeout = ks_wlan_tx_timeout,
-- 
2.16.3



[PATCH 2/9] staging: ks7010: Remove unecessary cast.

2018-03-28 Thread Quytelda Kahja
The driver casts '_wlan_handler_def' to 'struct iw_handler_def *',
but it is already of that type.

Signed-off-by: Quytelda Kahja 
---
 drivers/staging/ks7010/ks_wlan_net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index f6e496aa68de..544bfa403d9f 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -2904,7 +2904,7 @@ int ks_wlan_net_start(struct net_device *dev)
 
/* The ks_wlan-specific entries in the device structure. */
dev->netdev_ops = _wlan_netdev_ops;
-   dev->wireless_handlers = (struct iw_handler_def *)_wlan_handler_def;
+   dev->wireless_handlers = _wlan_handler_def;
dev->watchdog_timeo = TX_TIMEOUT;
 
netif_carrier_off(dev);
-- 
2.16.3



Re: [PATCH v3 1/2] of_net: Implement of_get_nvmem_mac_address helper

2018-03-28 Thread Mike Looijmans

On 28-03-18 00:50, Florian Fainelli wrote:

On 03/27/2018 02:52 AM, Mike Looijmans wrote:

It's common practice to store MAC addresses for network interfaces into
nvmem devices. However the code to actually do this in the kernel lacks,
so this patch adds of_get_nvmem_mac_address() for drivers to obtain the
address from an nvmem cell provider.

This is particulary useful on devices where the ethernet interface cannot
be configured by the bootloader, for example because it's in an FPGA.

Signed-off-by: Mike Looijmans 
---
  Documentation/devicetree/bindings/net/ethernet.txt |  2 ++
  drivers/of/of_net.c| 40 ++
  include/linux/of_net.h |  6 
  3 files changed, 48 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/ethernet.txt 
b/Documentation/devicetree/bindings/net/ethernet.txt
index 2974e63..cfc376b 100644
--- a/Documentation/devicetree/bindings/net/ethernet.txt
+++ b/Documentation/devicetree/bindings/net/ethernet.txt
@@ -10,6 +10,8 @@ Documentation/devicetree/bindings/phy/phy-bindings.txt.
the boot program; should be used in cases where the MAC address assigned to
the device by the boot program is different from the "local-mac-address"
property;
+- nvmem-cells: phandle, reference to an nvmem node for the MAC address;
+- nvmem-cell-names: string, should be "mac-address" if nvmem is to be used;
  - max-speed: number, specifies maximum speed in Mbit/s supported by the 
device;
  - max-frame-size: number, maximum transfer unit (IEEE defined MTU), rather 
than
the maximum frame size (there's contradiction in the Devicetree
diff --git a/drivers/of/of_net.c b/drivers/of/of_net.c
index d820f3e..1c5d372 100644
--- a/drivers/of/of_net.c
+++ b/drivers/of/of_net.c
@@ -7,6 +7,7 @@
   */
  #include 
  #include 
+#include 
  #include 
  #include 
  #include 
@@ -80,3 +81,42 @@ const void *of_get_mac_address(struct device_node *np)
return of_get_mac_addr(np, "address");
  }
  EXPORT_SYMBOL(of_get_mac_address);
+
+/**
+ * Obtain the MAC address from an nvmem provider named 'mac-address' through
+ * device tree.
+ * On success, copies the new address into memory pointed to by addr and
+ * returns 0. Returns a negative error code otherwise.
+ * @np:Device tree node containing the nvmem-cells phandle
+ * @addr:  Pointer to receive the MAC address using ether_addr_copy()
+ */
+int of_get_nvmem_mac_address(struct device_node *np, void *addr)
+{
+   struct nvmem_cell *cell;
+   const void *mac;
+   size_t len;
+   int ret;
+
+   cell = of_nvmem_cell_get(np, "mac-address");
+   if (IS_ERR(cell))
+   return PTR_ERR(cell);
+
+   mac = nvmem_cell_read(cell, );
+
+   nvmem_cell_put(cell);
+
+   if (IS_ERR(mac))
+   return PTR_ERR(mac);
+
+   if (len < 6 || !is_valid_ether_addr(mac)) {
+   ret = -EINVAL;


Just one nit here, can you use ETH_ALEN instead of 6? With that fixed:

Reviewed-by: Florian Fainelli 



Ok, implemented and tested it, and v4 is on the way with that change.


Kind regards,

Mike Looijmans
System Expert

TOPIC Products
Materiaalweg 4, NL-5681 RJ Best
Postbus 440, NL-5680 AK Best
Telefoon: +31 (0) 499 33 69 79
E-mail: mike.looijm...@topicproducts.com
Website: www.topicproducts.com

Please consider the environment before printing this e-mail





[PATCH 1/9] staging: ks7010: Replace manual array copy with ether_addr_copy().

2018-03-28 Thread Quytelda Kahja
Copying the dummy HW address into the struct net_device doesn't need
to be done byte by byte; use ether_addr_copy() instead.
Additionally, dev->dev_addr is not eight bytes long.
ether_setup() sets the dev->addr_len to ETH_ALEN (defined as 6)
in the net core code.

Signed-off-by: Quytelda Kahja 
---
 drivers/staging/ks7010/ks_wlan_net.c | 10 +-
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index 6106e79c5163..f6e496aa68de 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -2900,15 +2900,7 @@ int ks_wlan_net_start(struct net_device *dev)
timer_setup(_phyinfo_timer, ks_wlan_update_phyinfo_timeout, 0);
 
/* dummy address set */
-   memcpy(priv->eth_addr, dummy_addr, ETH_ALEN);
-   dev->dev_addr[0] = priv->eth_addr[0];
-   dev->dev_addr[1] = priv->eth_addr[1];
-   dev->dev_addr[2] = priv->eth_addr[2];
-   dev->dev_addr[3] = priv->eth_addr[3];
-   dev->dev_addr[4] = priv->eth_addr[4];
-   dev->dev_addr[5] = priv->eth_addr[5];
-   dev->dev_addr[6] = 0x00;
-   dev->dev_addr[7] = 0x00;
+   ether_addr_copy(dev->dev_addr, priv->eth_addr);
 
/* The ks_wlan-specific entries in the device structure. */
dev->netdev_ops = _wlan_netdev_ops;
-- 
2.16.3



[PATCH 7/9] staging: ks7010: Remove trailing "_t" from all structure names.

2018-03-28 Thread Quytelda Kahja
The "_t" suffix is not needed for structure names in this driver,
and is a reflection of an older typedef system that is no longer
in place.  Remove the "_t" suffix from every structure defined in this
driver.

Signed-off-by: Quytelda Kahja 
---
 drivers/staging/ks7010/ks7010_sdio.c |   2 +-
 drivers/staging/ks7010/ks_hostif.c   |  80 ++--
 drivers/staging/ks7010/ks_hostif.h   | 142 +--
 drivers/staging/ks7010/ks_wlan.h |  68 -
 drivers/staging/ks7010/ks_wlan_net.c |  12 +--
 drivers/staging/ks7010/michael_mic.c |   8 +-
 drivers/staging/ks7010/michael_mic.h |   4 +-
 7 files changed, 158 insertions(+), 158 deletions(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index b8f55a11ee1c..d083bf8d238e 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -950,7 +950,7 @@ static int ks7010_sdio_probe(struct sdio_func *func,
 /* send stop request to MAC */
 static int send_stop_request(struct sdio_func *func)
 {
-   struct hostif_stop_request_t *pp;
+   struct hostif_stop_request *pp;
struct ks_sdio_card *card;
size_t size;
 
diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index 79d21a64ffa2..a4020eeaac18 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -107,16 +107,16 @@ int ks_wlan_do_power_save(struct ks_wlan_private *priv)
 }
 
 static
-int get_current_ap(struct ks_wlan_private *priv, struct link_ap_info_t 
*ap_info)
+int get_current_ap(struct ks_wlan_private *priv, struct link_ap_info *ap_info)
 {
-   struct local_ap_t *ap;
+   struct local_ap *ap;
union iwreq_data wrqu;
struct net_device *netdev = priv->net_dev;
 
ap = >current_ap;
 
if (is_disconnect_status(priv->connect_status)) {
-   memset(ap, 0, sizeof(struct local_ap_t));
+   memset(ap, 0, sizeof(struct local_ap));
return -EPERM;
}
 
@@ -223,13 +223,13 @@ static u8 read_ie(unsigned char *bp, u8 max, u8 *body)
 
 
 static
-int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info,
-  struct local_ap_t *ap)
+int get_ap_information(struct ks_wlan_private *priv, struct ap_info *ap_info,
+  struct local_ap *ap)
 {
unsigned char *bp;
int bsize, offset;
 
-   memset(ap, 0, sizeof(struct local_ap_t));
+   memset(ap, 0, sizeof(struct local_ap));
 
/* bssid */
memcpy(ap->bssid, ap_info->bssid, ETH_ALEN);
@@ -314,11 +314,11 @@ int hostif_data_indication_wpa(struct ks_wlan_private 
*priv,
unsigned char recv_mic[8];
char buf[128];
unsigned long now;
-   struct mic_failure_t *mic_failure;
-   struct michael_mic_t michael_mic;
+   struct mic_failure *mic_failure;
+   struct michael_mic michael_mic;
union iwreq_data wrqu;
unsigned int key_index = auth_type - 1;
-   struct wpa_key_t *key = >wpa.key[key_index];
+   struct wpa_key *key = >wpa.key[key_index];
 
eth_hdr = (struct ether_hdr *)(priv->rxp);
eth_proto = ntohs(eth_hdr->h_proto);
@@ -745,7 +745,7 @@ void hostif_connect_indication(struct ks_wlan_private *priv)
break;
}
 
-   get_current_ap(priv, (struct link_ap_info_t *)priv->rxp);
+   get_current_ap(priv, (struct link_ap_info *)priv->rxp);
if (is_connect_status(priv->connect_status) &&
is_disconnect_status(old_status)) {
/* for power save */
@@ -771,10 +771,10 @@ static
 void hostif_scan_indication(struct ks_wlan_private *priv)
 {
int i;
-   struct ap_info_t *ap_info;
+   struct ap_info *ap_info;
 
netdev_dbg(priv->net_dev, "scan_ind_count = %d\n", 
priv->scan_ind_count);
-   ap_info = (struct ap_info_t *)(priv->rxp);
+   ap_info = (struct ap_info *)(priv->rxp);
 
if (priv->scan_ind_count) {
/* bssid check */
@@ -794,7 +794,7 @@ void hostif_scan_indication(struct ks_wlan_private *priv)
if (priv->scan_ind_count < LOCAL_APLIST_MAX + 1) {
netdev_dbg(priv->net_dev, " scan_ind_count=%d :: 
aplist.size=%d\n",
priv->scan_ind_count, priv->aplist.size);
-   get_ap_information(priv, (struct ap_info_t *)(priv->rxp),
+   get_ap_information(priv, (struct ap_info *)(priv->rxp),
   &(priv->aplist.ap[priv->scan_ind_count - 
1]));
priv->aplist.size = priv->scan_ind_count;
} else {
@@ -863,8 +863,8 @@ void hostif_adhoc_set_confirm(struct ks_wlan_private *priv)
 static
 void hostif_associate_indication(struct ks_wlan_private *priv)
 {
-   struct association_request_t *assoc_req;
-   struct association_response_t *assoc_resp;
+   struct association_request *assoc_req;
+   

[PATCH 7/9] staging: ks7010: Remove trailing "_t" from all structure names.

2018-03-28 Thread Quytelda Kahja
The "_t" suffix is not needed for structure names in this driver,
and is a reflection of an older typedef system that is no longer
in place.  Remove the "_t" suffix from every structure defined in this
driver.

Signed-off-by: Quytelda Kahja 
---
 drivers/staging/ks7010/ks7010_sdio.c |   2 +-
 drivers/staging/ks7010/ks_hostif.c   |  80 ++--
 drivers/staging/ks7010/ks_hostif.h   | 142 +--
 drivers/staging/ks7010/ks_wlan.h |  68 -
 drivers/staging/ks7010/ks_wlan_net.c |  12 +--
 drivers/staging/ks7010/michael_mic.c |   8 +-
 drivers/staging/ks7010/michael_mic.h |   4 +-
 7 files changed, 158 insertions(+), 158 deletions(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index b8f55a11ee1c..d083bf8d238e 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -950,7 +950,7 @@ static int ks7010_sdio_probe(struct sdio_func *func,
 /* send stop request to MAC */
 static int send_stop_request(struct sdio_func *func)
 {
-   struct hostif_stop_request_t *pp;
+   struct hostif_stop_request *pp;
struct ks_sdio_card *card;
size_t size;
 
diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index 79d21a64ffa2..a4020eeaac18 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -107,16 +107,16 @@ int ks_wlan_do_power_save(struct ks_wlan_private *priv)
 }
 
 static
-int get_current_ap(struct ks_wlan_private *priv, struct link_ap_info_t 
*ap_info)
+int get_current_ap(struct ks_wlan_private *priv, struct link_ap_info *ap_info)
 {
-   struct local_ap_t *ap;
+   struct local_ap *ap;
union iwreq_data wrqu;
struct net_device *netdev = priv->net_dev;
 
ap = >current_ap;
 
if (is_disconnect_status(priv->connect_status)) {
-   memset(ap, 0, sizeof(struct local_ap_t));
+   memset(ap, 0, sizeof(struct local_ap));
return -EPERM;
}
 
@@ -223,13 +223,13 @@ static u8 read_ie(unsigned char *bp, u8 max, u8 *body)
 
 
 static
-int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info,
-  struct local_ap_t *ap)
+int get_ap_information(struct ks_wlan_private *priv, struct ap_info *ap_info,
+  struct local_ap *ap)
 {
unsigned char *bp;
int bsize, offset;
 
-   memset(ap, 0, sizeof(struct local_ap_t));
+   memset(ap, 0, sizeof(struct local_ap));
 
/* bssid */
memcpy(ap->bssid, ap_info->bssid, ETH_ALEN);
@@ -314,11 +314,11 @@ int hostif_data_indication_wpa(struct ks_wlan_private 
*priv,
unsigned char recv_mic[8];
char buf[128];
unsigned long now;
-   struct mic_failure_t *mic_failure;
-   struct michael_mic_t michael_mic;
+   struct mic_failure *mic_failure;
+   struct michael_mic michael_mic;
union iwreq_data wrqu;
unsigned int key_index = auth_type - 1;
-   struct wpa_key_t *key = >wpa.key[key_index];
+   struct wpa_key *key = >wpa.key[key_index];
 
eth_hdr = (struct ether_hdr *)(priv->rxp);
eth_proto = ntohs(eth_hdr->h_proto);
@@ -745,7 +745,7 @@ void hostif_connect_indication(struct ks_wlan_private *priv)
break;
}
 
-   get_current_ap(priv, (struct link_ap_info_t *)priv->rxp);
+   get_current_ap(priv, (struct link_ap_info *)priv->rxp);
if (is_connect_status(priv->connect_status) &&
is_disconnect_status(old_status)) {
/* for power save */
@@ -771,10 +771,10 @@ static
 void hostif_scan_indication(struct ks_wlan_private *priv)
 {
int i;
-   struct ap_info_t *ap_info;
+   struct ap_info *ap_info;
 
netdev_dbg(priv->net_dev, "scan_ind_count = %d\n", 
priv->scan_ind_count);
-   ap_info = (struct ap_info_t *)(priv->rxp);
+   ap_info = (struct ap_info *)(priv->rxp);
 
if (priv->scan_ind_count) {
/* bssid check */
@@ -794,7 +794,7 @@ void hostif_scan_indication(struct ks_wlan_private *priv)
if (priv->scan_ind_count < LOCAL_APLIST_MAX + 1) {
netdev_dbg(priv->net_dev, " scan_ind_count=%d :: 
aplist.size=%d\n",
priv->scan_ind_count, priv->aplist.size);
-   get_ap_information(priv, (struct ap_info_t *)(priv->rxp),
+   get_ap_information(priv, (struct ap_info *)(priv->rxp),
   &(priv->aplist.ap[priv->scan_ind_count - 
1]));
priv->aplist.size = priv->scan_ind_count;
} else {
@@ -863,8 +863,8 @@ void hostif_adhoc_set_confirm(struct ks_wlan_private *priv)
 static
 void hostif_associate_indication(struct ks_wlan_private *priv)
 {
-   struct association_request_t *assoc_req;
-   struct association_response_t *assoc_resp;
+   struct association_request *assoc_req;
+   struct 

[PATCH 9/9] staging: ks7010: Remove extra blank line between functions.

2018-03-28 Thread Quytelda Kahja
Remove an extra blank line indicated by checkpatch.

Signed-off-by: Quytelda Kahja 
---
 drivers/staging/ks7010/ks7010_sdio.c | 3 ++-
 drivers/staging/ks7010/ks_hostif.c   | 1 -
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index d083bf8d238e..930d1f7d7dbf 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -305,7 +305,8 @@ static void tx_device_task(struct ks_wlan_private *priv)
if (priv->dev_state >= DEVICE_STATE_BOOT) {
ret = write_to_device(priv, sp->sendp, sp->size);
if (ret) {
-   netdev_err(priv->net_dev, "write_to_device error 
!!(%d)\n", ret);
+   netdev_err(priv->net_dev,
+  "write_to_device() error (%d)!\n", ret);
queue_delayed_work(priv->wq, >rw_dwork, 1);
return;
}
diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index 7bb0a6dffe61..de68dbdf7e2d 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -221,7 +221,6 @@ static u8 read_ie(unsigned char *bp, u8 max, u8 *body)
return size;
 }
 
-
 static
 int get_ap_information(struct ks_wlan_private *priv, struct ap_info *ap_info,
   struct local_ap *ap)
-- 
2.16.3



[PATCH 8/9] staging: ks7010: Remove 'eth_addr' field from 'struct ks_wlan_private'.

2018-03-28 Thread Quytelda Kahja
The ethernet address of the network device is already stored in the
'dev_addr' field of 'struct net_device'.  Since 'struct ks_wlan_private'
keeps a pointer to the driver's 'struct net_device', there is no reason
to duplicate this information in 'struct ks_wlan_private'.

Signed-off-by: Quytelda Kahja 
---
 drivers/staging/ks7010/ks_hostif.c   | 29 +++--
 drivers/staging/ks7010/ks_wlan.h |  2 --
 drivers/staging/ks7010/ks_wlan_net.c |  5 ++---
 3 files changed, 13 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index a4020eeaac18..7bb0a6dffe61 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -388,6 +388,7 @@ int hostif_data_indication_wpa(struct ks_wlan_private *priv,
 static
 void hostif_data_indication(struct ks_wlan_private *priv)
 {
+   struct net_device * dev = priv->net_dev;
unsigned int rx_ind_size;   /* indicate data size */
struct sk_buff *skb;
unsigned short auth_type;
@@ -411,9 +412,9 @@ void hostif_data_indication(struct ks_wlan_private *priv)
eth_proto = ntohs(eth_hdr->h_proto);
 
/* source address check */
-   if (memcmp(>eth_addr[0], eth_hdr->h_source, ETH_ALEN) == 0) {
-   netdev_err(priv->net_dev, "invalid : source is own mac address 
!!\n");
-   netdev_err(priv->net_dev,
+   if (memcmp(dev->dev_addr, eth_hdr->h_source, ETH_ALEN) == 0) {
+   netdev_err(dev, "invalid : source is own mac address !!\n");
+   netdev_err(dev,
   
"eth_hdrernet->h_dest=%02X:%02X:%02X:%02X:%02X:%02X\n",
   eth_hdr->h_source[0], eth_hdr->h_source[1],
   eth_hdr->h_source[2], eth_hdr->h_source[3],
@@ -443,7 +444,7 @@ void hostif_data_indication(struct ks_wlan_private *priv)
priv->nstats.rx_dropped++;
return;
}
-   netdev_dbg(priv->net_dev, "SNAP, rx_ind_size = %d\n",
+   netdev_dbg(dev, "SNAP, rx_ind_size = %d\n",
   rx_ind_size);
 
size = ETH_ALEN * 2;
@@ -463,7 +464,7 @@ void hostif_data_indication(struct ks_wlan_private *priv)
priv->nstats.rx_dropped++;
return;
}
-   netdev_dbg(priv->net_dev, "NETBEUI/NetBIOS rx_ind_size=%d\n",
+   netdev_dbg(dev, "NETBEUI/NetBIOS rx_ind_size=%d\n",
   rx_ind_size);
 
/* 8802/FDDI MAC copy */
@@ -480,7 +481,7 @@ void hostif_data_indication(struct ks_wlan_private *priv)
aa1x_hdr = (struct ieee802_1x_hdr *)(priv->rxp + 14);
break;
default:/* other rx data */
-   netdev_err(priv->net_dev, "invalid data format\n");
+   netdev_err(dev, "invalid data format\n");
priv->nstats.rx_errors++;
return;
}
@@ -522,17 +523,9 @@ void hostif_mib_get_confirm(struct ks_wlan_private *priv)
case DOT11_MAC_ADDRESS:
/* MAC address */
hostif_sme_enqueue(priv, SME_GET_MAC_ADDRESS);
-   memcpy(priv->eth_addr, priv->rxp, ETH_ALEN);
+   memcpy(dev->dev_addr, priv->rxp, ETH_ALEN);
priv->mac_address_valid = true;
-   dev->dev_addr[0] = priv->eth_addr[0];
-   dev->dev_addr[1] = priv->eth_addr[1];
-   dev->dev_addr[2] = priv->eth_addr[2];
-   dev->dev_addr[3] = priv->eth_addr[3];
-   dev->dev_addr[4] = priv->eth_addr[4];
-   dev->dev_addr[5] = priv->eth_addr[5];
-   dev->dev_addr[6] = 0x00;
-   dev->dev_addr[7] = 0x00;
-   netdev_info(dev, "MAC ADDRESS = %pM\n", priv->eth_addr);
+   netdev_info(dev, "MAC ADDRESS = %pM\n", dev->dev_addr);
break;
case DOT11_PRODUCT_VERSION:
/* firmware version */
@@ -,7 +1104,7 @@ int hostif_data_request(struct ks_wlan_private *priv, 
struct sk_buff *skb)
 
/* skb check */
eth = (struct ethhdr *)skb->data;
-   if (memcmp(>eth_addr[0], eth->h_source, ETH_ALEN) != 0) {
+   if (memcmp(priv->net_dev->dev_addr, eth->h_source, ETH_ALEN) != 0) {
netdev_err(priv->net_dev, "invalid mac address !!\n");
netdev_err(priv->net_dev, "ethernet->h_source=%pM\n", 
eth->h_source);
ret = -ENXIO;
@@ -2167,7 +2160,7 @@ void hostif_sme_execute(struct ks_wlan_private *priv, int 
event)
case SME_MACADDRESS_SET_REQUEST:
hostif_mib_set_request(priv, LOCAL_CURRENTADDRESS, ETH_ALEN,
   MIB_VALUE_TYPE_OSTRING,
-  >eth_addr[0]);
+  priv->net_dev->dev_addr);

[PATCH 6/9] staging: ks7010: Remove unused member 'reg_net' from 'ks_wlan_private'.

2018-03-28 Thread Quytelda Kahja
'reg_net' is never used in this driver.

Signed-off-by: Quytelda Kahja x
---
 drivers/staging/ks7010/ks_wlan.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/ks7010/ks_wlan.h b/drivers/staging/ks7010/ks_wlan.h
index 846bb1041850..1b7036c32d1c 100644
--- a/drivers/staging/ks7010/ks_wlan.h
+++ b/drivers/staging/ks7010/ks_wlan.h
@@ -406,7 +406,6 @@ struct ks_wlan_private {
struct tasklet_struct rx_bh_task;
 
struct net_device *net_dev;
-   int reg_net;/* register_netdev */
struct net_device_stats nstats;
struct iw_statistics wstats;
 
-- 
2.16.3



[PATCH 8/9] staging: ks7010: Remove 'eth_addr' field from 'struct ks_wlan_private'.

2018-03-28 Thread Quytelda Kahja
The ethernet address of the network device is already stored in the
'dev_addr' field of 'struct net_device'.  Since 'struct ks_wlan_private'
keeps a pointer to the driver's 'struct net_device', there is no reason
to duplicate this information in 'struct ks_wlan_private'.

Signed-off-by: Quytelda Kahja 
---
 drivers/staging/ks7010/ks_hostif.c   | 29 +++--
 drivers/staging/ks7010/ks_wlan.h |  2 --
 drivers/staging/ks7010/ks_wlan_net.c |  5 ++---
 3 files changed, 13 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index a4020eeaac18..7bb0a6dffe61 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -388,6 +388,7 @@ int hostif_data_indication_wpa(struct ks_wlan_private *priv,
 static
 void hostif_data_indication(struct ks_wlan_private *priv)
 {
+   struct net_device * dev = priv->net_dev;
unsigned int rx_ind_size;   /* indicate data size */
struct sk_buff *skb;
unsigned short auth_type;
@@ -411,9 +412,9 @@ void hostif_data_indication(struct ks_wlan_private *priv)
eth_proto = ntohs(eth_hdr->h_proto);
 
/* source address check */
-   if (memcmp(>eth_addr[0], eth_hdr->h_source, ETH_ALEN) == 0) {
-   netdev_err(priv->net_dev, "invalid : source is own mac address 
!!\n");
-   netdev_err(priv->net_dev,
+   if (memcmp(dev->dev_addr, eth_hdr->h_source, ETH_ALEN) == 0) {
+   netdev_err(dev, "invalid : source is own mac address !!\n");
+   netdev_err(dev,
   
"eth_hdrernet->h_dest=%02X:%02X:%02X:%02X:%02X:%02X\n",
   eth_hdr->h_source[0], eth_hdr->h_source[1],
   eth_hdr->h_source[2], eth_hdr->h_source[3],
@@ -443,7 +444,7 @@ void hostif_data_indication(struct ks_wlan_private *priv)
priv->nstats.rx_dropped++;
return;
}
-   netdev_dbg(priv->net_dev, "SNAP, rx_ind_size = %d\n",
+   netdev_dbg(dev, "SNAP, rx_ind_size = %d\n",
   rx_ind_size);
 
size = ETH_ALEN * 2;
@@ -463,7 +464,7 @@ void hostif_data_indication(struct ks_wlan_private *priv)
priv->nstats.rx_dropped++;
return;
}
-   netdev_dbg(priv->net_dev, "NETBEUI/NetBIOS rx_ind_size=%d\n",
+   netdev_dbg(dev, "NETBEUI/NetBIOS rx_ind_size=%d\n",
   rx_ind_size);
 
/* 8802/FDDI MAC copy */
@@ -480,7 +481,7 @@ void hostif_data_indication(struct ks_wlan_private *priv)
aa1x_hdr = (struct ieee802_1x_hdr *)(priv->rxp + 14);
break;
default:/* other rx data */
-   netdev_err(priv->net_dev, "invalid data format\n");
+   netdev_err(dev, "invalid data format\n");
priv->nstats.rx_errors++;
return;
}
@@ -522,17 +523,9 @@ void hostif_mib_get_confirm(struct ks_wlan_private *priv)
case DOT11_MAC_ADDRESS:
/* MAC address */
hostif_sme_enqueue(priv, SME_GET_MAC_ADDRESS);
-   memcpy(priv->eth_addr, priv->rxp, ETH_ALEN);
+   memcpy(dev->dev_addr, priv->rxp, ETH_ALEN);
priv->mac_address_valid = true;
-   dev->dev_addr[0] = priv->eth_addr[0];
-   dev->dev_addr[1] = priv->eth_addr[1];
-   dev->dev_addr[2] = priv->eth_addr[2];
-   dev->dev_addr[3] = priv->eth_addr[3];
-   dev->dev_addr[4] = priv->eth_addr[4];
-   dev->dev_addr[5] = priv->eth_addr[5];
-   dev->dev_addr[6] = 0x00;
-   dev->dev_addr[7] = 0x00;
-   netdev_info(dev, "MAC ADDRESS = %pM\n", priv->eth_addr);
+   netdev_info(dev, "MAC ADDRESS = %pM\n", dev->dev_addr);
break;
case DOT11_PRODUCT_VERSION:
/* firmware version */
@@ -,7 +1104,7 @@ int hostif_data_request(struct ks_wlan_private *priv, 
struct sk_buff *skb)
 
/* skb check */
eth = (struct ethhdr *)skb->data;
-   if (memcmp(>eth_addr[0], eth->h_source, ETH_ALEN) != 0) {
+   if (memcmp(priv->net_dev->dev_addr, eth->h_source, ETH_ALEN) != 0) {
netdev_err(priv->net_dev, "invalid mac address !!\n");
netdev_err(priv->net_dev, "ethernet->h_source=%pM\n", 
eth->h_source);
ret = -ENXIO;
@@ -2167,7 +2160,7 @@ void hostif_sme_execute(struct ks_wlan_private *priv, int 
event)
case SME_MACADDRESS_SET_REQUEST:
hostif_mib_set_request(priv, LOCAL_CURRENTADDRESS, ETH_ALEN,
   MIB_VALUE_TYPE_OSTRING,
-  >eth_addr[0]);
+  priv->net_dev->dev_addr);
break;
case 

[PATCH 6/9] staging: ks7010: Remove unused member 'reg_net' from 'ks_wlan_private'.

2018-03-28 Thread Quytelda Kahja
'reg_net' is never used in this driver.

Signed-off-by: Quytelda Kahja x
---
 drivers/staging/ks7010/ks_wlan.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/ks7010/ks_wlan.h b/drivers/staging/ks7010/ks_wlan.h
index 846bb1041850..1b7036c32d1c 100644
--- a/drivers/staging/ks7010/ks_wlan.h
+++ b/drivers/staging/ks7010/ks_wlan.h
@@ -406,7 +406,6 @@ struct ks_wlan_private {
struct tasklet_struct rx_bh_task;
 
struct net_device *net_dev;
-   int reg_net;/* register_netdev */
struct net_device_stats nstats;
struct iw_statistics wstats;
 
-- 
2.16.3



[PATCH 9/9] staging: ks7010: Remove extra blank line between functions.

2018-03-28 Thread Quytelda Kahja
Remove an extra blank line indicated by checkpatch.

Signed-off-by: Quytelda Kahja 
---
 drivers/staging/ks7010/ks7010_sdio.c | 3 ++-
 drivers/staging/ks7010/ks_hostif.c   | 1 -
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index d083bf8d238e..930d1f7d7dbf 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -305,7 +305,8 @@ static void tx_device_task(struct ks_wlan_private *priv)
if (priv->dev_state >= DEVICE_STATE_BOOT) {
ret = write_to_device(priv, sp->sendp, sp->size);
if (ret) {
-   netdev_err(priv->net_dev, "write_to_device error 
!!(%d)\n", ret);
+   netdev_err(priv->net_dev,
+  "write_to_device() error (%d)!\n", ret);
queue_delayed_work(priv->wq, >rw_dwork, 1);
return;
}
diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index 7bb0a6dffe61..de68dbdf7e2d 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -221,7 +221,6 @@ static u8 read_ie(unsigned char *bp, u8 max, u8 *body)
return size;
 }
 
-
 static
 int get_ap_information(struct ks_wlan_private *priv, struct ap_info *ap_info,
   struct local_ap *ap)
-- 
2.16.3



[PATCH 5/9] staging: ks7010: Change mac_address_valid to a bool instead of int.

2018-03-28 Thread Quytelda Kahja
'mac_address_valid' is only ever assigned 0 or 1, so it makes more sense
to use a bool type for this variable.

Signed-off-by: Quytelda Kahja 
---
 drivers/staging/ks7010/ks_hostif.c   | 4 ++--
 drivers/staging/ks7010/ks_wlan.h | 2 +-
 drivers/staging/ks7010/ks_wlan_net.c | 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index a02b73e4e81f..79d21a64ffa2 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -523,7 +523,7 @@ void hostif_mib_get_confirm(struct ks_wlan_private *priv)
/* MAC address */
hostif_sme_enqueue(priv, SME_GET_MAC_ADDRESS);
memcpy(priv->eth_addr, priv->rxp, ETH_ALEN);
-   priv->mac_address_valid = 1;
+   priv->mac_address_valid = true;
dev->dev_addr[0] = priv->eth_addr[0];
dev->dev_addr[1] = priv->eth_addr[1];
dev->dev_addr[2] = priv->eth_addr[2];
@@ -638,7 +638,7 @@ void hostif_mib_set_confirm(struct ks_wlan_private *priv)
hostif_sme_enqueue(priv, SME_MULTICAST_CONFIRM);
break;
case LOCAL_CURRENTADDRESS:
-   priv->mac_address_valid = 1;
+   priv->mac_address_valid = true;
break;
case DOT11_RSN_CONFIG_MULTICAST_CIPHER:
hostif_sme_enqueue(priv, SME_RSN_MCAST_CONFIRM);
diff --git a/drivers/staging/ks7010/ks_wlan.h b/drivers/staging/ks7010/ks_wlan.h
index f1f6c88adcca..846bb1041850 100644
--- a/drivers/staging/ks7010/ks_wlan.h
+++ b/drivers/staging/ks7010/ks_wlan.h
@@ -456,7 +456,7 @@ struct ks_wlan_private {
unsigned char firmware_version[128 + 1];
int version_size;
 
-   int mac_address_valid;  /* Mac Address Status */
+   bool mac_address_valid; /* Mac Address Status */
 
int dev_state;
 
diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index 41f89f930f50..df6192be8a3e 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -2767,7 +2767,7 @@ int ks_wlan_set_mac_address(struct net_device *dev, void 
*addr)
memcpy(dev->dev_addr, mac_addr->sa_data, dev->addr_len);
memcpy(priv->eth_addr, mac_addr->sa_data, ETH_ALEN);
 
-   priv->mac_address_valid = 0;
+   priv->mac_address_valid = false;
hostif_sme_enqueue(priv, SME_MACADDRESS_SET_REQUEST);
netdev_info(dev, "ks_wlan:  MAC ADDRESS = %pM\n", priv->eth_addr);
return 0;
@@ -2890,7 +2890,7 @@ int ks_wlan_net_start(struct net_device *dev)
/* int rc; */
 
priv = netdev_priv(dev);
-   priv->mac_address_valid = 0;
+   priv->mac_address_valid = false;
priv->need_commit = 0;
 
priv->device_open_status = 1;
-- 
2.16.3



[PATCH 5/9] staging: ks7010: Change mac_address_valid to a bool instead of int.

2018-03-28 Thread Quytelda Kahja
'mac_address_valid' is only ever assigned 0 or 1, so it makes more sense
to use a bool type for this variable.

Signed-off-by: Quytelda Kahja 
---
 drivers/staging/ks7010/ks_hostif.c   | 4 ++--
 drivers/staging/ks7010/ks_wlan.h | 2 +-
 drivers/staging/ks7010/ks_wlan_net.c | 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index a02b73e4e81f..79d21a64ffa2 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -523,7 +523,7 @@ void hostif_mib_get_confirm(struct ks_wlan_private *priv)
/* MAC address */
hostif_sme_enqueue(priv, SME_GET_MAC_ADDRESS);
memcpy(priv->eth_addr, priv->rxp, ETH_ALEN);
-   priv->mac_address_valid = 1;
+   priv->mac_address_valid = true;
dev->dev_addr[0] = priv->eth_addr[0];
dev->dev_addr[1] = priv->eth_addr[1];
dev->dev_addr[2] = priv->eth_addr[2];
@@ -638,7 +638,7 @@ void hostif_mib_set_confirm(struct ks_wlan_private *priv)
hostif_sme_enqueue(priv, SME_MULTICAST_CONFIRM);
break;
case LOCAL_CURRENTADDRESS:
-   priv->mac_address_valid = 1;
+   priv->mac_address_valid = true;
break;
case DOT11_RSN_CONFIG_MULTICAST_CIPHER:
hostif_sme_enqueue(priv, SME_RSN_MCAST_CONFIRM);
diff --git a/drivers/staging/ks7010/ks_wlan.h b/drivers/staging/ks7010/ks_wlan.h
index f1f6c88adcca..846bb1041850 100644
--- a/drivers/staging/ks7010/ks_wlan.h
+++ b/drivers/staging/ks7010/ks_wlan.h
@@ -456,7 +456,7 @@ struct ks_wlan_private {
unsigned char firmware_version[128 + 1];
int version_size;
 
-   int mac_address_valid;  /* Mac Address Status */
+   bool mac_address_valid; /* Mac Address Status */
 
int dev_state;
 
diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index 41f89f930f50..df6192be8a3e 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -2767,7 +2767,7 @@ int ks_wlan_set_mac_address(struct net_device *dev, void 
*addr)
memcpy(dev->dev_addr, mac_addr->sa_data, dev->addr_len);
memcpy(priv->eth_addr, mac_addr->sa_data, ETH_ALEN);
 
-   priv->mac_address_valid = 0;
+   priv->mac_address_valid = false;
hostif_sme_enqueue(priv, SME_MACADDRESS_SET_REQUEST);
netdev_info(dev, "ks_wlan:  MAC ADDRESS = %pM\n", priv->eth_addr);
return 0;
@@ -2890,7 +2890,7 @@ int ks_wlan_net_start(struct net_device *dev)
/* int rc; */
 
priv = netdev_priv(dev);
-   priv->mac_address_valid = 0;
+   priv->mac_address_valid = false;
priv->need_commit = 0;
 
priv->device_open_status = 1;
-- 
2.16.3



Re: [PATCH 2/2] rhashtable: improve rhashtable_walk stability when stop/start used.

2018-03-28 Thread Herbert Xu
On Thu, Mar 29, 2018 at 12:19:10PM +1100, NeilBrown wrote:
> When a walk of an rhashtable is interrupted with rhastable_walk_stop()
> and then rhashtable_walk_start(), the location to restart from is based
> on a 'skip' count in the current hash chain, and this can be incorrect
> if insertions or deletions have happened.  This does not happen when
> the walk is not stopped and started as iter->p is a placeholder which
> is safe to use while holding the RCU read lock.
> 
> In rhashtable_walk_start() we can revalidate that 'p' is still in the
> same hash chain.  If it isn't then the current method is still used.
> 
> With this patch, if a rhashtable walker ensures that the current
> object remains in the table over a stop/start period (possibly by
> elevating the reference count if that is sufficient), it can be sure
> that a walk will not miss objects that were in the hashtable for the
> whole time of the walk.
> 
> rhashtable_walk_start() may not find the object even though it is
> still in the hashtable if a rehash has moved it to a new table.  In
> this case it will (eventually) get -EAGAIN and will need to proceed
> through the whole table again to be sure to see everything at least
> once.
> 
> Signed-off-by: NeilBrown 

Very nice!

Acked-by: Herbert Xu 
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt


Re: [PATCH 2/2] rhashtable: improve rhashtable_walk stability when stop/start used.

2018-03-28 Thread Herbert Xu
On Thu, Mar 29, 2018 at 12:19:10PM +1100, NeilBrown wrote:
> When a walk of an rhashtable is interrupted with rhastable_walk_stop()
> and then rhashtable_walk_start(), the location to restart from is based
> on a 'skip' count in the current hash chain, and this can be incorrect
> if insertions or deletions have happened.  This does not happen when
> the walk is not stopped and started as iter->p is a placeholder which
> is safe to use while holding the RCU read lock.
> 
> In rhashtable_walk_start() we can revalidate that 'p' is still in the
> same hash chain.  If it isn't then the current method is still used.
> 
> With this patch, if a rhashtable walker ensures that the current
> object remains in the table over a stop/start period (possibly by
> elevating the reference count if that is sufficient), it can be sure
> that a walk will not miss objects that were in the hashtable for the
> whole time of the walk.
> 
> rhashtable_walk_start() may not find the object even though it is
> still in the hashtable if a rehash has moved it to a new table.  In
> this case it will (eventually) get -EAGAIN and will need to proceed
> through the whole table again to be sure to see everything at least
> once.
> 
> Signed-off-by: NeilBrown 

Very nice!

Acked-by: Herbert Xu 
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt


[RFC PATCH] sdhci: arasan: Add runtime PM support

2018-03-28 Thread naranimanish
From: Manish Narani 

This patch adds runtime PM support in Arasan SD driver.

Signed-off-by: Manish Narani 
---
 drivers/mmc/host/sdhci-of-arasan.c | 83 +-
 1 file changed, 81 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/sdhci-of-arasan.c 
b/drivers/mmc/host/sdhci-of-arasan.c
index c33a5f7..47196b5 100644
--- a/drivers/mmc/host/sdhci-of-arasan.c
+++ b/drivers/mmc/host/sdhci-of-arasan.c
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -349,6 +350,75 @@ static const struct sdhci_pltfm_data 
sdhci_arasan_cqe_pdata = {
SDHCI_QUIRK2_CLOCK_DIV_ZERO_BROKEN,
 };
 
+#ifdef CONFIG_PM
+/**
+ * sdhci_arasan_runtime_suspend - Suspend method for the driver
+ * @dev:   Address of the device structure
+ * Returns 0 on success and error value on error
+ *
+ * Put the device in a low power state.
+ */
+static int sdhci_arasan_runtime_suspend(struct device *dev)
+{
+   struct platform_device *pdev = to_platform_device(dev);
+   struct sdhci_host *host = platform_get_drvdata(pdev);
+   struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+   struct sdhci_arasan_data *sdhci_arasan = sdhci_pltfm_priv(pltfm_host);
+   int ret;
+
+   ret = sdhci_runtime_suspend_host(host);
+   if (ret)
+   return ret;
+
+   if (host->tuning_mode != SDHCI_TUNING_MODE_3)
+   mmc_retune_needed(host->mmc);
+
+   clk_disable(pltfm_host->clk);
+   clk_disable(sdhci_arasan->clk_ahb);
+
+   return 0;
+}
+
+/**
+ * sdhci_arasan_runtime_resume - Resume method for the driver
+ * @dev:   Address of the device structure
+ * Returns 0 on success and error value on error
+ *
+ * Resume operation after suspend
+ */
+static int sdhci_arasan_runtime_resume(struct device *dev)
+{
+   struct platform_device *pdev = to_platform_device(dev);
+   struct sdhci_host *host = platform_get_drvdata(pdev);
+   struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+   struct sdhci_arasan_data *sdhci_arasan = sdhci_pltfm_priv(pltfm_host);
+   int ret;
+
+   ret = clk_enable(sdhci_arasan->clk_ahb);
+   if (ret) {
+   dev_err(dev, "Cannot enable AHB clock.\n");
+   return ret;
+   }
+
+   ret = clk_enable(pltfm_host->clk);
+   if (ret) {
+   dev_err(dev, "Cannot enable SD clock.\n");
+   return ret;
+   }
+
+   ret = sdhci_runtime_resume_host(host);
+   if (ret)
+   goto out;
+
+   return 0;
+out:
+   clk_disable(pltfm_host->clk);
+   clk_disable(sdhci_arasan->clk_ahb);
+
+   return ret;
+}
+#endif /* ! CONFIG_PM */
+
 #ifdef CONFIG_PM_SLEEP
 /**
  * sdhci_arasan_suspend - Suspend method for the driver
@@ -443,8 +513,11 @@ static int sdhci_arasan_resume(struct device *dev)
 }
 #endif /* ! CONFIG_PM_SLEEP */
 
-static SIMPLE_DEV_PM_OPS(sdhci_arasan_dev_pm_ops, sdhci_arasan_suspend,
-sdhci_arasan_resume);
+static const struct dev_pm_ops sdhci_arasan_dev_pm_ops = {
+   SET_SYSTEM_SLEEP_PM_OPS(sdhci_arasan_suspend, sdhci_arasan_resume)
+   SET_RUNTIME_PM_OPS(sdhci_arasan_runtime_suspend,
+  sdhci_arasan_runtime_resume, NULL)
+};
 
 static const struct of_device_id sdhci_arasan_of_match[] = {
/* SoC-specific compatible strings w/ soc_ctl_map */
@@ -806,6 +879,12 @@ static int sdhci_arasan_probe(struct platform_device *pdev)
if (ret)
goto err_add_host;
 
+   pm_runtime_set_active(>dev);
+   pm_runtime_enable(>dev);
+   pm_runtime_set_autosuspend_delay(>dev, 2000);
+   pm_runtime_mark_last_busy(>dev);
+   pm_runtime_use_autosuspend(>dev);
+
return 0;
 
 err_add_host:
-- 
2.7.4



[RFC PATCH] sdhci: arasan: Add runtime PM support

2018-03-28 Thread naranimanish
From: Manish Narani 

This patch adds runtime PM support in Arasan SD driver.

Signed-off-by: Manish Narani 
---
 drivers/mmc/host/sdhci-of-arasan.c | 83 +-
 1 file changed, 81 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/sdhci-of-arasan.c 
b/drivers/mmc/host/sdhci-of-arasan.c
index c33a5f7..47196b5 100644
--- a/drivers/mmc/host/sdhci-of-arasan.c
+++ b/drivers/mmc/host/sdhci-of-arasan.c
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -349,6 +350,75 @@ static const struct sdhci_pltfm_data 
sdhci_arasan_cqe_pdata = {
SDHCI_QUIRK2_CLOCK_DIV_ZERO_BROKEN,
 };
 
+#ifdef CONFIG_PM
+/**
+ * sdhci_arasan_runtime_suspend - Suspend method for the driver
+ * @dev:   Address of the device structure
+ * Returns 0 on success and error value on error
+ *
+ * Put the device in a low power state.
+ */
+static int sdhci_arasan_runtime_suspend(struct device *dev)
+{
+   struct platform_device *pdev = to_platform_device(dev);
+   struct sdhci_host *host = platform_get_drvdata(pdev);
+   struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+   struct sdhci_arasan_data *sdhci_arasan = sdhci_pltfm_priv(pltfm_host);
+   int ret;
+
+   ret = sdhci_runtime_suspend_host(host);
+   if (ret)
+   return ret;
+
+   if (host->tuning_mode != SDHCI_TUNING_MODE_3)
+   mmc_retune_needed(host->mmc);
+
+   clk_disable(pltfm_host->clk);
+   clk_disable(sdhci_arasan->clk_ahb);
+
+   return 0;
+}
+
+/**
+ * sdhci_arasan_runtime_resume - Resume method for the driver
+ * @dev:   Address of the device structure
+ * Returns 0 on success and error value on error
+ *
+ * Resume operation after suspend
+ */
+static int sdhci_arasan_runtime_resume(struct device *dev)
+{
+   struct platform_device *pdev = to_platform_device(dev);
+   struct sdhci_host *host = platform_get_drvdata(pdev);
+   struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+   struct sdhci_arasan_data *sdhci_arasan = sdhci_pltfm_priv(pltfm_host);
+   int ret;
+
+   ret = clk_enable(sdhci_arasan->clk_ahb);
+   if (ret) {
+   dev_err(dev, "Cannot enable AHB clock.\n");
+   return ret;
+   }
+
+   ret = clk_enable(pltfm_host->clk);
+   if (ret) {
+   dev_err(dev, "Cannot enable SD clock.\n");
+   return ret;
+   }
+
+   ret = sdhci_runtime_resume_host(host);
+   if (ret)
+   goto out;
+
+   return 0;
+out:
+   clk_disable(pltfm_host->clk);
+   clk_disable(sdhci_arasan->clk_ahb);
+
+   return ret;
+}
+#endif /* ! CONFIG_PM */
+
 #ifdef CONFIG_PM_SLEEP
 /**
  * sdhci_arasan_suspend - Suspend method for the driver
@@ -443,8 +513,11 @@ static int sdhci_arasan_resume(struct device *dev)
 }
 #endif /* ! CONFIG_PM_SLEEP */
 
-static SIMPLE_DEV_PM_OPS(sdhci_arasan_dev_pm_ops, sdhci_arasan_suspend,
-sdhci_arasan_resume);
+static const struct dev_pm_ops sdhci_arasan_dev_pm_ops = {
+   SET_SYSTEM_SLEEP_PM_OPS(sdhci_arasan_suspend, sdhci_arasan_resume)
+   SET_RUNTIME_PM_OPS(sdhci_arasan_runtime_suspend,
+  sdhci_arasan_runtime_resume, NULL)
+};
 
 static const struct of_device_id sdhci_arasan_of_match[] = {
/* SoC-specific compatible strings w/ soc_ctl_map */
@@ -806,6 +879,12 @@ static int sdhci_arasan_probe(struct platform_device *pdev)
if (ret)
goto err_add_host;
 
+   pm_runtime_set_active(>dev);
+   pm_runtime_enable(>dev);
+   pm_runtime_set_autosuspend_delay(>dev, 2000);
+   pm_runtime_mark_last_busy(>dev);
+   pm_runtime_use_autosuspend(>dev);
+
return 0;
 
 err_add_host:
-- 
2.7.4



Re: [PATCH 1/2] rhashtable: fix insertion of in rhltable when duplicate found.

2018-03-28 Thread Herbert Xu
On Thu, Mar 29, 2018 at 12:19:09PM +1100, NeilBrown wrote:
> When rhltable_insert() finds an entry with the same key,
> it splices the new entry at the start of a list of entries with the
> same key.
> It stores the address of the new object in *pprev, but in general this
> is *not* the location where the match was found (though in a common
> case where the hash chain has one element, it will be).
> To fix this, pprev should be updated every time we find an object that
> doesn't match.
> 
> This patch changes the behaviour for non-slow insertion in that now
> insertion happens at the end of a chain rather than at the head.
> I don't think this is an important change.
> 
> Signed-off-by: NeilBrown 

Thanks.  But Paul Blakey beat you to it :)

https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git/commit/?id=d3dcf8eb615537526bd42ff27a081d46d337816e
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt


Re: [PATCH 1/2] rhashtable: fix insertion of in rhltable when duplicate found.

2018-03-28 Thread Herbert Xu
On Thu, Mar 29, 2018 at 12:19:09PM +1100, NeilBrown wrote:
> When rhltable_insert() finds an entry with the same key,
> it splices the new entry at the start of a list of entries with the
> same key.
> It stores the address of the new object in *pprev, but in general this
> is *not* the location where the match was found (though in a common
> case where the hash chain has one element, it will be).
> To fix this, pprev should be updated every time we find an object that
> doesn't match.
> 
> This patch changes the behaviour for non-slow insertion in that now
> insertion happens at the end of a chain rather than at the head.
> I don't think this is an important change.
> 
> Signed-off-by: NeilBrown 

Thanks.  But Paul Blakey beat you to it :)

https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git/commit/?id=d3dcf8eb615537526bd42ff27a081d46d337816e
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt


[PATCH v2] media: i2c: wm9090: replace codec to component

2018-03-28 Thread Kuninori Morimoto

From: Kuninori Morimoto 

Now we can replace Codec to Component. Let's do it.

Note:
xxx_codec_xxx() ->  xxx_component_xxx()
.idle_bias_off = 0  ->  .idle_bias_on = 1
.ignore_pmdown_time = 0 ->  .use_pmdown_time = 1
-   ->  .endianness = 1
-   ->  .non_legacy_dai_naming = 1

Signed-off-by: Kuninori Morimoto 
---
v1 -> v2

 - fixup .remove return

 drivers/media/i2c/tda1997x.c | 21 +++--
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/drivers/media/i2c/tda1997x.c b/drivers/media/i2c/tda1997x.c
index 3021913..2dc4df5 100644
--- a/drivers/media/i2c/tda1997x.c
+++ b/drivers/media/i2c/tda1997x.c
@@ -2444,7 +2444,7 @@ static int tda1997x_pcm_startup(struct snd_pcm_substream 
*substream,
struct snd_soc_dai *dai)
 {
struct tda1997x_state *state = snd_soc_dai_get_drvdata(dai);
-   struct snd_soc_codec *codec = dai->codec;
+   struct snd_soc_component *component = dai->component;
struct snd_pcm_runtime *rtd = substream->runtime;
int rate, err;
 
@@ -2452,11 +2452,11 @@ static int tda1997x_pcm_startup(struct 
snd_pcm_substream *substream,
err = snd_pcm_hw_constraint_minmax(rtd, SNDRV_PCM_HW_PARAM_RATE,
   rate, rate);
if (err < 0) {
-   dev_err(codec->dev, "failed to constrain samplerate to %dHz\n",
+   dev_err(component->dev, "failed to constrain samplerate to 
%dHz\n",
rate);
return err;
}
-   dev_info(codec->dev, "set samplerate constraint to %dHz\n", rate);
+   dev_info(component->dev, "set samplerate constraint to %dHz\n", rate);
 
return 0;
 }
@@ -2479,20 +2479,22 @@ static int tda1997x_pcm_startup(struct 
snd_pcm_substream *substream,
.ops = _dai_ops,
 };
 
-static int tda1997x_codec_probe(struct snd_soc_codec *codec)
+static int tda1997x_codec_probe(struct snd_soc_component *component)
 {
return 0;
 }
 
-static int tda1997x_codec_remove(struct snd_soc_codec *codec)
+static void tda1997x_codec_remove(struct snd_soc_component *component)
 {
-   return 0;
 }
 
-static struct snd_soc_codec_driver tda1997x_codec_driver = {
+static struct snd_soc_component_driver tda1997x_codec_driver = {
.probe = tda1997x_codec_probe,
.remove = tda1997x_codec_remove,
-   .reg_word_size = sizeof(u16),
+   .idle_bias_on   = 1,
+   .use_pmdown_time= 1,
+   .endianness = 1,
+   .non_legacy_dai_naming  = 1,
 };
 
 static int tda1997x_probe(struct i2c_client *client,
@@ -2737,7 +2739,7 @@ static int tda1997x_probe(struct i2c_client *client,
else
formats = SNDRV_PCM_FMTBIT_S16_LE;
tda1997x_audio_dai.capture.formats = formats;
-   ret = snd_soc_register_codec(>client->dev,
+   ret = devm_snd_soc_register_component(>client->dev,
 _codec_driver,
 _audio_dai, 1);
if (ret) {
@@ -2782,7 +2784,6 @@ static int tda1997x_remove(struct i2c_client *client)
struct tda1997x_platform_data *pdata = >pdata;
 
if (pdata->audout_format) {
-   snd_soc_unregister_codec(>dev);
mutex_destroy(>audio_lock);
}
 
-- 
1.9.1



[PATCH v2] media: i2c: wm9090: replace codec to component

2018-03-28 Thread Kuninori Morimoto

From: Kuninori Morimoto 

Now we can replace Codec to Component. Let's do it.

Note:
xxx_codec_xxx() ->  xxx_component_xxx()
.idle_bias_off = 0  ->  .idle_bias_on = 1
.ignore_pmdown_time = 0 ->  .use_pmdown_time = 1
-   ->  .endianness = 1
-   ->  .non_legacy_dai_naming = 1

Signed-off-by: Kuninori Morimoto 
---
v1 -> v2

 - fixup .remove return

 drivers/media/i2c/tda1997x.c | 21 +++--
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/drivers/media/i2c/tda1997x.c b/drivers/media/i2c/tda1997x.c
index 3021913..2dc4df5 100644
--- a/drivers/media/i2c/tda1997x.c
+++ b/drivers/media/i2c/tda1997x.c
@@ -2444,7 +2444,7 @@ static int tda1997x_pcm_startup(struct snd_pcm_substream 
*substream,
struct snd_soc_dai *dai)
 {
struct tda1997x_state *state = snd_soc_dai_get_drvdata(dai);
-   struct snd_soc_codec *codec = dai->codec;
+   struct snd_soc_component *component = dai->component;
struct snd_pcm_runtime *rtd = substream->runtime;
int rate, err;
 
@@ -2452,11 +2452,11 @@ static int tda1997x_pcm_startup(struct 
snd_pcm_substream *substream,
err = snd_pcm_hw_constraint_minmax(rtd, SNDRV_PCM_HW_PARAM_RATE,
   rate, rate);
if (err < 0) {
-   dev_err(codec->dev, "failed to constrain samplerate to %dHz\n",
+   dev_err(component->dev, "failed to constrain samplerate to 
%dHz\n",
rate);
return err;
}
-   dev_info(codec->dev, "set samplerate constraint to %dHz\n", rate);
+   dev_info(component->dev, "set samplerate constraint to %dHz\n", rate);
 
return 0;
 }
@@ -2479,20 +2479,22 @@ static int tda1997x_pcm_startup(struct 
snd_pcm_substream *substream,
.ops = _dai_ops,
 };
 
-static int tda1997x_codec_probe(struct snd_soc_codec *codec)
+static int tda1997x_codec_probe(struct snd_soc_component *component)
 {
return 0;
 }
 
-static int tda1997x_codec_remove(struct snd_soc_codec *codec)
+static void tda1997x_codec_remove(struct snd_soc_component *component)
 {
-   return 0;
 }
 
-static struct snd_soc_codec_driver tda1997x_codec_driver = {
+static struct snd_soc_component_driver tda1997x_codec_driver = {
.probe = tda1997x_codec_probe,
.remove = tda1997x_codec_remove,
-   .reg_word_size = sizeof(u16),
+   .idle_bias_on   = 1,
+   .use_pmdown_time= 1,
+   .endianness = 1,
+   .non_legacy_dai_naming  = 1,
 };
 
 static int tda1997x_probe(struct i2c_client *client,
@@ -2737,7 +2739,7 @@ static int tda1997x_probe(struct i2c_client *client,
else
formats = SNDRV_PCM_FMTBIT_S16_LE;
tda1997x_audio_dai.capture.formats = formats;
-   ret = snd_soc_register_codec(>client->dev,
+   ret = devm_snd_soc_register_component(>client->dev,
 _codec_driver,
 _audio_dai, 1);
if (ret) {
@@ -2782,7 +2784,6 @@ static int tda1997x_remove(struct i2c_client *client)
struct tda1997x_platform_data *pdata = >pdata;
 
if (pdata->audout_format) {
-   snd_soc_unregister_codec(>dev);
mutex_destroy(>audio_lock);
}
 
-- 
1.9.1



Re: [PATCH v2] pcm_native: Remove VLA usage

2018-03-28 Thread Takashi Iwai
On Thu, 29 Mar 2018 00:24:00 +0200,
Kyle Spiers wrote:
> 
> As part of the effort to remove VLAs from the kernel[1], this changes
> the allocation of the rstamps array from being on the stack to being
> kcalloc()ed. This also allows for the removal of the explicit zeroing
> loop.
> 
> Signed-off-by: Kyle Spiers 

It's been already fixed weeks ago...


thanks,

Takashi


Re: [PATCH v2] pcm_native: Remove VLA usage

2018-03-28 Thread Takashi Iwai
On Thu, 29 Mar 2018 00:24:00 +0200,
Kyle Spiers wrote:
> 
> As part of the effort to remove VLAs from the kernel[1], this changes
> the allocation of the rstamps array from being on the stack to being
> kcalloc()ed. This also allows for the removal of the explicit zeroing
> loop.
> 
> Signed-off-by: Kyle Spiers 

It's been already fixed weeks ago...


thanks,

Takashi


Re: [PATCH] media: i2c: wm9090: replace codec to component

2018-03-28 Thread Kuninori Morimoto
Hi

Thank you for this report.
I will post v2 patch, soon

kbuild test robot wrote:
> 
> [1  ]
> Hi Kuninori,
> 
> Thank you for the patch! Yet something to improve:
> 
> [auto build test ERROR on linuxtv-media/master]
> [also build test ERROR on next-20180328]
> [cannot apply to v4.16-rc7]
> [if your patch is applied to the wrong git tree, please drop us a note to 
> help improve the system]
> 
> url:
> https://github.com/0day-ci/linux/commits/Kuninori-Morimoto/media-i2c-wm9090-replace-codec-to-component/20180329-082843
> base:   git://linuxtv.org/media_tree.git master
> config: i386-allmodconfig (attached as .config)
> compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
> reproduce:
> # save the attached .config to linux build tree
> make ARCH=i386 
> 
> All errors (new ones prefixed by >>):
> 
> >> drivers/media/i2c/tda1997x.c:2494:12: error: initialization from 
> >> incompatible pointer type [-Werror=incompatible-pointer-types]
>  .remove = tda1997x_codec_remove,
>^
>drivers/media/i2c/tda1997x.c:2494:12: note: (near initialization for 
> 'tda1997x_codec_driver.remove')
>cc1: some warnings being treated as errors
> 
> vim +2494 drivers/media/i2c/tda1997x.c
> 
> 9ac0038d Tim Harvey2018-02-15  2491  
> b534b135 Kuninori Morimoto 2018-03-28  2492  static struct 
> snd_soc_component_driver tda1997x_codec_driver = {
> 9ac0038d Tim Harvey2018-02-15  2493   .probe = tda1997x_codec_probe,
> 9ac0038d Tim Harvey2018-02-15 @2494   .remove = tda1997x_codec_remove,
> b534b135 Kuninori Morimoto 2018-03-28  2495   .idle_bias_on   = 1,
> b534b135 Kuninori Morimoto 2018-03-28  2496   .use_pmdown_time= 1,
> b534b135 Kuninori Morimoto 2018-03-28  2497   .endianness = 1,
> b534b135 Kuninori Morimoto 2018-03-28  2498   .non_legacy_dai_naming  = 1,
> 9ac0038d Tim Harvey2018-02-15  2499  };
> 9ac0038d Tim Harvey2018-02-15  2500  
> 
> :: The code at line 2494 was first introduced by commit
> :: 9ac0038db9a7e10fc8f425010ec98b7afc2ff621 media: i2c: Add TDA1997x HDMI 
> receiver driver
> 
> :: TO: Tim Harvey <thar...@gateworks.com>
> :: CC: Mauro Carvalho Chehab <mche...@s-opensource.com>
> 
> ---
> 0-DAY kernel test infrastructureOpen Source Technology Center
> https://lists.01.org/pipermail/kbuild-all   Intel Corporation
> [2 .config.gz ]
> 


Re: [PATCH] media: i2c: wm9090: replace codec to component

2018-03-28 Thread Kuninori Morimoto
Hi

Thank you for this report.
I will post v2 patch, soon

kbuild test robot wrote:
> 
> [1  ]
> Hi Kuninori,
> 
> Thank you for the patch! Yet something to improve:
> 
> [auto build test ERROR on linuxtv-media/master]
> [also build test ERROR on next-20180328]
> [cannot apply to v4.16-rc7]
> [if your patch is applied to the wrong git tree, please drop us a note to 
> help improve the system]
> 
> url:
> https://github.com/0day-ci/linux/commits/Kuninori-Morimoto/media-i2c-wm9090-replace-codec-to-component/20180329-082843
> base:   git://linuxtv.org/media_tree.git master
> config: i386-allmodconfig (attached as .config)
> compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
> reproduce:
> # save the attached .config to linux build tree
> make ARCH=i386 
> 
> All errors (new ones prefixed by >>):
> 
> >> drivers/media/i2c/tda1997x.c:2494:12: error: initialization from 
> >> incompatible pointer type [-Werror=incompatible-pointer-types]
>  .remove = tda1997x_codec_remove,
>^
>drivers/media/i2c/tda1997x.c:2494:12: note: (near initialization for 
> 'tda1997x_codec_driver.remove')
>cc1: some warnings being treated as errors
> 
> vim +2494 drivers/media/i2c/tda1997x.c
> 
> 9ac0038d Tim Harvey2018-02-15  2491  
> b534b135 Kuninori Morimoto 2018-03-28  2492  static struct 
> snd_soc_component_driver tda1997x_codec_driver = {
> 9ac0038d Tim Harvey2018-02-15  2493   .probe = tda1997x_codec_probe,
> 9ac0038d Tim Harvey2018-02-15 @2494   .remove = tda1997x_codec_remove,
> b534b135 Kuninori Morimoto 2018-03-28  2495   .idle_bias_on   = 1,
> b534b135 Kuninori Morimoto 2018-03-28  2496   .use_pmdown_time= 1,
> b534b135 Kuninori Morimoto 2018-03-28  2497   .endianness = 1,
> b534b135 Kuninori Morimoto 2018-03-28  2498   .non_legacy_dai_naming  = 1,
> 9ac0038d Tim Harvey2018-02-15  2499  };
> 9ac0038d Tim Harvey2018-02-15  2500  
> 
> :: The code at line 2494 was first introduced by commit
> :: 9ac0038db9a7e10fc8f425010ec98b7afc2ff621 media: i2c: Add TDA1997x HDMI 
> receiver driver
> 
> :: TO: Tim Harvey 
> :: CC: Mauro Carvalho Chehab 
> 
> ---
> 0-DAY kernel test infrastructureOpen Source Technology Center
> https://lists.01.org/pipermail/kbuild-all   Intel Corporation
> [2 .config.gz ]
> 


Re: [PATCHv2 08/14] mm/page_ext: Drop definition of unused PAGE_EXT_DEBUG_POISON

2018-03-28 Thread Vinayak Menon
On 3/28/2018 10:25 PM, Kirill A. Shutemov wrote:
> After bd33ef368135 ("mm: enable page poisoning early at boot")
> PAGE_EXT_DEBUG_POISON is not longer used. Remove it.
>
> Signed-off-by: Kirill A. Shutemov 
> Cc: Vinayak Menon 
> ---
>  include/linux/page_ext.h | 11 ---
>  1 file changed, 11 deletions(-)
>
> diff --git a/include/linux/page_ext.h b/include/linux/page_ext.h
> index ca5461efae2f..bbec618a614b 100644
> --- a/include/linux/page_ext.h
> +++ b/include/linux/page_ext.h
> @@ -16,18 +16,7 @@ struct page_ext_operations {
>  
>  #ifdef CONFIG_PAGE_EXTENSION
>  
> -/*
> - * page_ext->flags bits:
> - *
> - * PAGE_EXT_DEBUG_POISON is set for poisoned pages. This is used to
> - * implement generic debug pagealloc feature. The pages are filled with
> - * poison patterns and set this flag after free_pages(). The poisoned
> - * pages are verified whether the patterns are not corrupted and clear
> - * the flag before alloc_pages().
> - */
> -
>  enum page_ext_flags {
> - PAGE_EXT_DEBUG_POISON,  /* Page is poisoned */
>   PAGE_EXT_DEBUG_GUARD,
>   PAGE_EXT_OWNER,
>  #if defined(CONFIG_IDLE_PAGE_TRACKING) && !defined(CONFIG_64BIT)

Reviewed-by: Vinayak Menon 



Re: [PATCHv2 08/14] mm/page_ext: Drop definition of unused PAGE_EXT_DEBUG_POISON

2018-03-28 Thread Vinayak Menon
On 3/28/2018 10:25 PM, Kirill A. Shutemov wrote:
> After bd33ef368135 ("mm: enable page poisoning early at boot")
> PAGE_EXT_DEBUG_POISON is not longer used. Remove it.
>
> Signed-off-by: Kirill A. Shutemov 
> Cc: Vinayak Menon 
> ---
>  include/linux/page_ext.h | 11 ---
>  1 file changed, 11 deletions(-)
>
> diff --git a/include/linux/page_ext.h b/include/linux/page_ext.h
> index ca5461efae2f..bbec618a614b 100644
> --- a/include/linux/page_ext.h
> +++ b/include/linux/page_ext.h
> @@ -16,18 +16,7 @@ struct page_ext_operations {
>  
>  #ifdef CONFIG_PAGE_EXTENSION
>  
> -/*
> - * page_ext->flags bits:
> - *
> - * PAGE_EXT_DEBUG_POISON is set for poisoned pages. This is used to
> - * implement generic debug pagealloc feature. The pages are filled with
> - * poison patterns and set this flag after free_pages(). The poisoned
> - * pages are verified whether the patterns are not corrupted and clear
> - * the flag before alloc_pages().
> - */
> -
>  enum page_ext_flags {
> - PAGE_EXT_DEBUG_POISON,  /* Page is poisoned */
>   PAGE_EXT_DEBUG_GUARD,
>   PAGE_EXT_OWNER,
>  #if defined(CONFIG_IDLE_PAGE_TRACKING) && !defined(CONFIG_64BIT)

Reviewed-by: Vinayak Menon 



Re: [PATCH] serial: 8250: omap: Provide ability to enable/disable UART as wakeup source

2018-03-28 Thread Vignesh R


On Thursday 29 March 2018 04:00 AM, Tony Lindgren wrote:
> * Vignesh R  [180327 12:03]:
>> Enable/Clear module level UART wakeup in UART_OMAP_WER register based on
>> return value of device_may_wakeup() in .suspend(). This allows
>> userspace to use sysfs to control the ability of UART to wakeup the
>> system from deep sleep state. Register is restored back in .startup()
>> call that happens as part of resume sequence.
>> 
>> With this patch, userspace can control UART wakeup capability via sysfs:
>> To enable wakeup capability:
>> echo enabled >  /sys/class/tty/ttyXX/device/power/wakeup
>> For disabling wakeup capability:
>> echo disabled > /sys/class/tty/ttyXX/device/power/wakeup
> 
> To avoid confusion, can you please add this to the description:
> 
> Note that the UART wakeup events configured in the 8250 hardware only
> work for idle modes that do not cut off power for the UART. For deeper
> idle states, dedicated padconf wakeirqs must be used. Or in some cases
> the UART RX pin can be remuxed to GPIO input if the GPIO block stays
> powered.
> 

That makes sense, I will add it to patch description in v2.

> I tested this briefly and the dedicated wakeirqs still work for me,
> so from that point of view:
> 
> Tested-by: Tony Lindgren 

Thanks for testing!

-- 
Regards
Vignesh


Re: [PATCH] serial: 8250: omap: Provide ability to enable/disable UART as wakeup source

2018-03-28 Thread Vignesh R


On Thursday 29 March 2018 04:00 AM, Tony Lindgren wrote:
> * Vignesh R  [180327 12:03]:
>> Enable/Clear module level UART wakeup in UART_OMAP_WER register based on
>> return value of device_may_wakeup() in .suspend(). This allows
>> userspace to use sysfs to control the ability of UART to wakeup the
>> system from deep sleep state. Register is restored back in .startup()
>> call that happens as part of resume sequence.
>> 
>> With this patch, userspace can control UART wakeup capability via sysfs:
>> To enable wakeup capability:
>> echo enabled >  /sys/class/tty/ttyXX/device/power/wakeup
>> For disabling wakeup capability:
>> echo disabled > /sys/class/tty/ttyXX/device/power/wakeup
> 
> To avoid confusion, can you please add this to the description:
> 
> Note that the UART wakeup events configured in the 8250 hardware only
> work for idle modes that do not cut off power for the UART. For deeper
> idle states, dedicated padconf wakeirqs must be used. Or in some cases
> the UART RX pin can be remuxed to GPIO input if the GPIO block stays
> powered.
> 

That makes sense, I will add it to patch description in v2.

> I tested this briefly and the dedicated wakeirqs still work for me,
> so from that point of view:
> 
> Tested-by: Tony Lindgren 

Thanks for testing!

-- 
Regards
Vignesh


[PATCH v4 1/2] of_net: Implement of_get_nvmem_mac_address helper

2018-03-28 Thread Mike Looijmans
It's common practice to store MAC addresses for network interfaces into
nvmem devices. However the code to actually do this in the kernel lacks,
so this patch adds of_get_nvmem_mac_address() for drivers to obtain the
address from an nvmem cell provider.

This is particulary useful on devices where the ethernet interface cannot
be configured by the bootloader, for example because it's in an FPGA.

Signed-off-by: Mike Looijmans 
Reviewed-by: Florian Fainelli 
Reviewed-by: Andrew Lunn 
---
 Documentation/devicetree/bindings/net/ethernet.txt |  2 ++
 drivers/of/of_net.c| 40 ++
 include/linux/of_net.h |  6 
 3 files changed, 48 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/ethernet.txt 
b/Documentation/devicetree/bindings/net/ethernet.txt
index 2974e63..cfc376b 100644
--- a/Documentation/devicetree/bindings/net/ethernet.txt
+++ b/Documentation/devicetree/bindings/net/ethernet.txt
@@ -10,6 +10,8 @@ Documentation/devicetree/bindings/phy/phy-bindings.txt.
   the boot program; should be used in cases where the MAC address assigned to
   the device by the boot program is different from the "local-mac-address"
   property;
+- nvmem-cells: phandle, reference to an nvmem node for the MAC address;
+- nvmem-cell-names: string, should be "mac-address" if nvmem is to be used;
 - max-speed: number, specifies maximum speed in Mbit/s supported by the device;
 - max-frame-size: number, maximum transfer unit (IEEE defined MTU), rather than
   the maximum frame size (there's contradiction in the Devicetree
diff --git a/drivers/of/of_net.c b/drivers/of/of_net.c
index d820f3e..53189d4 100644
--- a/drivers/of/of_net.c
+++ b/drivers/of/of_net.c
@@ -7,6 +7,7 @@
  */
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -80,3 +81,42 @@ const void *of_get_mac_address(struct device_node *np)
return of_get_mac_addr(np, "address");
 }
 EXPORT_SYMBOL(of_get_mac_address);
+
+/**
+ * Obtain the MAC address from an nvmem provider named 'mac-address' through
+ * device tree.
+ * On success, copies the new address into memory pointed to by addr and
+ * returns 0. Returns a negative error code otherwise.
+ * @np:Device tree node containing the nvmem-cells phandle
+ * @addr:  Pointer to receive the MAC address using ether_addr_copy()
+ */
+int of_get_nvmem_mac_address(struct device_node *np, void *addr)
+{
+   struct nvmem_cell *cell;
+   const void *mac;
+   size_t len;
+   int ret;
+
+   cell = of_nvmem_cell_get(np, "mac-address");
+   if (IS_ERR(cell))
+   return PTR_ERR(cell);
+
+   mac = nvmem_cell_read(cell, );
+
+   nvmem_cell_put(cell);
+
+   if (IS_ERR(mac))
+   return PTR_ERR(mac);
+
+   if (len < ETH_ALEN || !is_valid_ether_addr(mac)) {
+   ret = -EINVAL;
+   } else {
+   ether_addr_copy(addr, mac);
+   ret = 0;
+   }
+
+   kfree(mac);
+
+   return ret;
+}
+EXPORT_SYMBOL(of_get_nvmem_mac_address);
diff --git a/include/linux/of_net.h b/include/linux/of_net.h
index 9cd72aa..90d81ee 100644
--- a/include/linux/of_net.h
+++ b/include/linux/of_net.h
@@ -13,6 +13,7 @@
 struct net_device;
 extern int of_get_phy_mode(struct device_node *np);
 extern const void *of_get_mac_address(struct device_node *np);
+extern int of_get_nvmem_mac_address(struct device_node *np, void *addr);
 extern struct net_device *of_find_net_device_by_node(struct device_node *np);
 #else
 static inline int of_get_phy_mode(struct device_node *np)
@@ -25,6 +26,11 @@ static inline const void *of_get_mac_address(struct 
device_node *np)
return NULL;
 }
 
+static inline int of_get_nvmem_mac_address(struct device_node *np, void *addr)
+{
+   return -ENODEV;
+}
+
 static inline struct net_device *of_find_net_device_by_node(struct device_node 
*np)
 {
return NULL;
-- 
1.9.1



[PATCH v4 1/2] of_net: Implement of_get_nvmem_mac_address helper

2018-03-28 Thread Mike Looijmans
It's common practice to store MAC addresses for network interfaces into
nvmem devices. However the code to actually do this in the kernel lacks,
so this patch adds of_get_nvmem_mac_address() for drivers to obtain the
address from an nvmem cell provider.

This is particulary useful on devices where the ethernet interface cannot
be configured by the bootloader, for example because it's in an FPGA.

Signed-off-by: Mike Looijmans 
Reviewed-by: Florian Fainelli 
Reviewed-by: Andrew Lunn 
---
 Documentation/devicetree/bindings/net/ethernet.txt |  2 ++
 drivers/of/of_net.c| 40 ++
 include/linux/of_net.h |  6 
 3 files changed, 48 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/ethernet.txt 
b/Documentation/devicetree/bindings/net/ethernet.txt
index 2974e63..cfc376b 100644
--- a/Documentation/devicetree/bindings/net/ethernet.txt
+++ b/Documentation/devicetree/bindings/net/ethernet.txt
@@ -10,6 +10,8 @@ Documentation/devicetree/bindings/phy/phy-bindings.txt.
   the boot program; should be used in cases where the MAC address assigned to
   the device by the boot program is different from the "local-mac-address"
   property;
+- nvmem-cells: phandle, reference to an nvmem node for the MAC address;
+- nvmem-cell-names: string, should be "mac-address" if nvmem is to be used;
 - max-speed: number, specifies maximum speed in Mbit/s supported by the device;
 - max-frame-size: number, maximum transfer unit (IEEE defined MTU), rather than
   the maximum frame size (there's contradiction in the Devicetree
diff --git a/drivers/of/of_net.c b/drivers/of/of_net.c
index d820f3e..53189d4 100644
--- a/drivers/of/of_net.c
+++ b/drivers/of/of_net.c
@@ -7,6 +7,7 @@
  */
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -80,3 +81,42 @@ const void *of_get_mac_address(struct device_node *np)
return of_get_mac_addr(np, "address");
 }
 EXPORT_SYMBOL(of_get_mac_address);
+
+/**
+ * Obtain the MAC address from an nvmem provider named 'mac-address' through
+ * device tree.
+ * On success, copies the new address into memory pointed to by addr and
+ * returns 0. Returns a negative error code otherwise.
+ * @np:Device tree node containing the nvmem-cells phandle
+ * @addr:  Pointer to receive the MAC address using ether_addr_copy()
+ */
+int of_get_nvmem_mac_address(struct device_node *np, void *addr)
+{
+   struct nvmem_cell *cell;
+   const void *mac;
+   size_t len;
+   int ret;
+
+   cell = of_nvmem_cell_get(np, "mac-address");
+   if (IS_ERR(cell))
+   return PTR_ERR(cell);
+
+   mac = nvmem_cell_read(cell, );
+
+   nvmem_cell_put(cell);
+
+   if (IS_ERR(mac))
+   return PTR_ERR(mac);
+
+   if (len < ETH_ALEN || !is_valid_ether_addr(mac)) {
+   ret = -EINVAL;
+   } else {
+   ether_addr_copy(addr, mac);
+   ret = 0;
+   }
+
+   kfree(mac);
+
+   return ret;
+}
+EXPORT_SYMBOL(of_get_nvmem_mac_address);
diff --git a/include/linux/of_net.h b/include/linux/of_net.h
index 9cd72aa..90d81ee 100644
--- a/include/linux/of_net.h
+++ b/include/linux/of_net.h
@@ -13,6 +13,7 @@
 struct net_device;
 extern int of_get_phy_mode(struct device_node *np);
 extern const void *of_get_mac_address(struct device_node *np);
+extern int of_get_nvmem_mac_address(struct device_node *np, void *addr);
 extern struct net_device *of_find_net_device_by_node(struct device_node *np);
 #else
 static inline int of_get_phy_mode(struct device_node *np)
@@ -25,6 +26,11 @@ static inline const void *of_get_mac_address(struct 
device_node *np)
return NULL;
 }
 
+static inline int of_get_nvmem_mac_address(struct device_node *np, void *addr)
+{
+   return -ENODEV;
+}
+
 static inline struct net_device *of_find_net_device_by_node(struct device_node 
*np)
 {
return NULL;
-- 
1.9.1



[PATCH v4 2/2] net: macb: Try to retrieve MAC addess from nvmem provider

2018-03-28 Thread Mike Looijmans
Call of_get_nvmem_mac_address() to fetch the MAC address from an nvmem
cell, if one is provided in the device tree. This allows the address to
be stored in an I2C EEPROM device for example.

Signed-off-by: Mike Looijmans 
Acked-by: Nicolas Ferre 
---
 drivers/net/ethernet/cadence/macb_main.c | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/cadence/macb_main.c 
b/drivers/net/ethernet/cadence/macb_main.c
index e84afcf..eabe14f 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -3950,10 +3950,16 @@ static int macb_probe(struct platform_device *pdev)
dev->max_mtu = ETH_DATA_LEN;
 
mac = of_get_mac_address(np);
-   if (mac)
+   if (mac) {
ether_addr_copy(bp->dev->dev_addr, mac);
-   else
-   macb_get_hwaddr(bp);
+   } else {
+   err = of_get_nvmem_mac_address(np, bp->dev->dev_addr);
+   if (err) {
+   if (err == -EPROBE_DEFER)
+   goto err_out_free_netdev;
+   macb_get_hwaddr(bp);
+   }
+   }
 
err = of_get_phy_mode(np);
if (err < 0) {
-- 
1.9.1



[PATCH v4 2/2] net: macb: Try to retrieve MAC addess from nvmem provider

2018-03-28 Thread Mike Looijmans
Call of_get_nvmem_mac_address() to fetch the MAC address from an nvmem
cell, if one is provided in the device tree. This allows the address to
be stored in an I2C EEPROM device for example.

Signed-off-by: Mike Looijmans 
Acked-by: Nicolas Ferre 
---
 drivers/net/ethernet/cadence/macb_main.c | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/cadence/macb_main.c 
b/drivers/net/ethernet/cadence/macb_main.c
index e84afcf..eabe14f 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -3950,10 +3950,16 @@ static int macb_probe(struct platform_device *pdev)
dev->max_mtu = ETH_DATA_LEN;
 
mac = of_get_mac_address(np);
-   if (mac)
+   if (mac) {
ether_addr_copy(bp->dev->dev_addr, mac);
-   else
-   macb_get_hwaddr(bp);
+   } else {
+   err = of_get_nvmem_mac_address(np, bp->dev->dev_addr);
+   if (err) {
+   if (err == -EPROBE_DEFER)
+   goto err_out_free_netdev;
+   macb_get_hwaddr(bp);
+   }
+   }
 
err = of_get_phy_mode(np);
if (err < 0) {
-- 
1.9.1



[PATCH v4 0/2] of_net: Implement of_get_nvmem_mac_address helper

2018-03-28 Thread Mike Looijmans
Posted this as a small set now, with an (optional) second patch that shows
how the changes work and what I've used to test the code on a Topic Miami board.
I've taken the liberty to add appropriate "Acked" and "Review" tags.

v4: Replaced "6" with ETH_ALEN

v3: Add patch that implements mac in nvmem for the Cadence MACB controller
Remove the integrated of_get_mac_address call

v2: Use of_nvmem_cell_get to avoid needing the assiciated device
Use void* instead of char*
Add devicetree binding doc


Mike Looijmans (2):
  of_net: Implement of_get_nvmem_mac_address helper
  net: macb: Try to retrieve MAC addess from nvmem provider

 Documentation/devicetree/bindings/net/ethernet.txt |  2 ++
 drivers/net/ethernet/cadence/macb_main.c   | 12 +--
 drivers/of/of_net.c| 40 ++
 include/linux/of_net.h |  6 
 4 files changed, 57 insertions(+), 3 deletions(-)

-- 
1.9.1



[PATCH v4 0/2] of_net: Implement of_get_nvmem_mac_address helper

2018-03-28 Thread Mike Looijmans
Posted this as a small set now, with an (optional) second patch that shows
how the changes work and what I've used to test the code on a Topic Miami board.
I've taken the liberty to add appropriate "Acked" and "Review" tags.

v4: Replaced "6" with ETH_ALEN

v3: Add patch that implements mac in nvmem for the Cadence MACB controller
Remove the integrated of_get_mac_address call

v2: Use of_nvmem_cell_get to avoid needing the assiciated device
Use void* instead of char*
Add devicetree binding doc


Mike Looijmans (2):
  of_net: Implement of_get_nvmem_mac_address helper
  net: macb: Try to retrieve MAC addess from nvmem provider

 Documentation/devicetree/bindings/net/ethernet.txt |  2 ++
 drivers/net/ethernet/cadence/macb_main.c   | 12 +--
 drivers/of/of_net.c| 40 ++
 include/linux/of_net.h |  6 
 4 files changed, 57 insertions(+), 3 deletions(-)

-- 
1.9.1



Re: [PATCH 5/6] rhashtable: support guaranteed successful insertion.

2018-03-28 Thread Herbert Xu
On Thu, Mar 29, 2018 at 08:26:21AM +1100, NeilBrown wrote:
>
> I say "astronomically unlikely", you say "probability .. is extremely
> low".  I think we are in agreement here.
> 
> The point remains that if an error *can* be returned then I have to
> write code to handle it and test that code.  I'd rather not.

You have be able to handle errors anyway because of memory allocation
failures.  Ultimately if you keep inserting you will eventually
fail with ENOMEM.  So I don't see the issue with an additional
error value.

> > Even if it does happen we won't fail because we will perform
> > an immediate rehash.  We only fail if it happens right away
> > after the rehash (that is, at least another 16 elements have
> > been inserted and you're trying to insert a 17th element, all
> > while the new hash table has not been completely populated),
> > which means that somebody has figured out our hash secret and
> > failing in that case makes sense.

BTW, you didn't acknowledge this bit which I think is crucial to
how likely such an error is.

> I never suggested retrying, but I would have to handle it somehow.  I'd
> rather not.

...

> While I have no doubt that there are hashtables where someone could try
> to attack the hash, I am quite sure there are others where is such an
> attack is meaningless - any code which could generate the required range of
> keys, could do far worse things more easily.

Our network hashtable has to be secure against adversaries.  I
understand that this may not be important to your use-case.  However,
given the fact that the failure would only occur if an adversary
is present and actively attacking your hash table, I don't think
it has that much of a negative effect on your use-case either.

Of course if you can reproduce the EBUSY error without your
disable_count patch or even after you have fixed the issue I
have pointed out in your disable_count patch you can still reproduce
it then that would suggest a real bug and we would need to fix it,
for everyone.

> Yes, storing a sharded count in the spinlock table does seem like an
> appropriate granularity.  However that leads me to ask: why do we have
> the spinlock table?  Why not bit spinlocks in the hashchain head like
> include/linux/list_bl uses?

The spinlock table predates rhashtable.  Perhaps Thomas/Eric/Dave
can elucidate this.

> I don't understand how it can ever be "too late", though I appreciate
> that in some cases "sooner" is better than "later"
> If we give up on the single atomic_t counter, then we must accept that
> the number of elements could exceed any given value.  The only promise
> we can provide is that it wont exceed N% of the table size for more than
> T seconds.

Sure.  However, assuming we use an estimate that is hash-based,
that *should* be fairly accurate assuming that your hash function
is working in the first place.  It's completely different vs.
estimating based on a per-cpu count which could be wildly inaccurate.

Cheers,
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt


Re: [PATCH 5/6] rhashtable: support guaranteed successful insertion.

2018-03-28 Thread Herbert Xu
On Thu, Mar 29, 2018 at 08:26:21AM +1100, NeilBrown wrote:
>
> I say "astronomically unlikely", you say "probability .. is extremely
> low".  I think we are in agreement here.
> 
> The point remains that if an error *can* be returned then I have to
> write code to handle it and test that code.  I'd rather not.

You have be able to handle errors anyway because of memory allocation
failures.  Ultimately if you keep inserting you will eventually
fail with ENOMEM.  So I don't see the issue with an additional
error value.

> > Even if it does happen we won't fail because we will perform
> > an immediate rehash.  We only fail if it happens right away
> > after the rehash (that is, at least another 16 elements have
> > been inserted and you're trying to insert a 17th element, all
> > while the new hash table has not been completely populated),
> > which means that somebody has figured out our hash secret and
> > failing in that case makes sense.

BTW, you didn't acknowledge this bit which I think is crucial to
how likely such an error is.

> I never suggested retrying, but I would have to handle it somehow.  I'd
> rather not.

...

> While I have no doubt that there are hashtables where someone could try
> to attack the hash, I am quite sure there are others where is such an
> attack is meaningless - any code which could generate the required range of
> keys, could do far worse things more easily.

Our network hashtable has to be secure against adversaries.  I
understand that this may not be important to your use-case.  However,
given the fact that the failure would only occur if an adversary
is present and actively attacking your hash table, I don't think
it has that much of a negative effect on your use-case either.

Of course if you can reproduce the EBUSY error without your
disable_count patch or even after you have fixed the issue I
have pointed out in your disable_count patch you can still reproduce
it then that would suggest a real bug and we would need to fix it,
for everyone.

> Yes, storing a sharded count in the spinlock table does seem like an
> appropriate granularity.  However that leads me to ask: why do we have
> the spinlock table?  Why not bit spinlocks in the hashchain head like
> include/linux/list_bl uses?

The spinlock table predates rhashtable.  Perhaps Thomas/Eric/Dave
can elucidate this.

> I don't understand how it can ever be "too late", though I appreciate
> that in some cases "sooner" is better than "later"
> If we give up on the single atomic_t counter, then we must accept that
> the number of elements could exceed any given value.  The only promise
> we can provide is that it wont exceed N% of the table size for more than
> T seconds.

Sure.  However, assuming we use an estimate that is hash-based,
that *should* be fairly accurate assuming that your hash function
is working in the first place.  It's completely different vs.
estimating based on a per-cpu count which could be wildly inaccurate.

Cheers,
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt


Re: linux-next: manual merge of the kvm-arm tree with the arm64 tree

2018-03-28 Thread Stephen Rothwell
Hi all,

On Wed, 28 Mar 2018 16:05:41 +1100 Stephen Rothwell  
wrote:
>
> Today's linux-next merge of the kvm-arm tree got a conflict in:
> 
>   arch/arm64/kernel/cpufeature.c
> 
> between commits:
> 
>   143ba05d867a ("arm64: capabilities: Prepare for fine grained capabilities")
>   12eb369125ab ("arm64: cpufeature: Avoid warnings due to unused symbols")
> 
> from the arm64 tree and commit:
> 
>   a1efdff442ec ("arm64: cpufeatures: Drop the ARM64_HYP_OFFSET_LOW feature 
> flag")
> 
> from the kvm-arm tree.
> 
> I fixed it up (see below) and can carry the fix as necessary. This
> is now fixed as far as linux-next is concerned, but any non trivial
> conflicts should be mentioned to your upstream maintainer when your tree
> is submitted for merging.  You may also want to consider cooperating
> with the maintainer of the conflicting tree to minimise any particularly
> complex conflicts.
> 
> -- 
> Cheers,
> Stephen Rothwell
> 
> diff --cc arch/arm64/kernel/cpufeature.c
> index 96b15d7b10a8,5b25d56bccfd..
> --- a/arch/arm64/kernel/cpufeature.c
> +++ b/arch/arm64/kernel/cpufeature.c
> @@@ -838,19 -826,11 +838,6 @@@ static bool has_no_hw_prefetch(const st
>   MIDR_CPU_VAR_REV(1, MIDR_REVISION_MASK));
>   }
>   
> - static bool hyp_offset_low(const struct arm64_cpu_capabilities *entry,
> -int __unused)
>  -static bool runs_at_el2(const struct arm64_cpu_capabilities *entry, int 
> __unused)
> --{
> - phys_addr_t idmap_addr = __pa_symbol(__hyp_idmap_text_start);
> - 
> - /*
> -  * Activate the lower HYP offset only if:
> -  * - the idmap doesn't clash with it,
> -  * - the kernel is not running at EL2.
> -  */
> - return idmap_addr > GENMASK(VA_BITS - 2, 0) && !is_kernel_in_hyp_mode();
>  -return is_kernel_in_hyp_mode();
> --}
> --
>   static bool has_no_fpsimd(const struct arm64_cpu_capabilities *entry, int 
> __unused)
>   {
>   u64 pfr0 = read_sanitised_ftr_reg(SYS_ID_AA64PFR0_EL1);

This is now a conflict between the kvm tree and the arm64 tree.

-- 
Cheers,
Stephen Rothwell


pgpeAykeHDCCn.pgp
Description: OpenPGP digital signature


Re: linux-next: manual merge of the kvm-arm tree with the arm64 tree

2018-03-28 Thread Stephen Rothwell
Hi all,

On Wed, 28 Mar 2018 16:05:41 +1100 Stephen Rothwell  
wrote:
>
> Today's linux-next merge of the kvm-arm tree got a conflict in:
> 
>   arch/arm64/kernel/cpufeature.c
> 
> between commits:
> 
>   143ba05d867a ("arm64: capabilities: Prepare for fine grained capabilities")
>   12eb369125ab ("arm64: cpufeature: Avoid warnings due to unused symbols")
> 
> from the arm64 tree and commit:
> 
>   a1efdff442ec ("arm64: cpufeatures: Drop the ARM64_HYP_OFFSET_LOW feature 
> flag")
> 
> from the kvm-arm tree.
> 
> I fixed it up (see below) and can carry the fix as necessary. This
> is now fixed as far as linux-next is concerned, but any non trivial
> conflicts should be mentioned to your upstream maintainer when your tree
> is submitted for merging.  You may also want to consider cooperating
> with the maintainer of the conflicting tree to minimise any particularly
> complex conflicts.
> 
> -- 
> Cheers,
> Stephen Rothwell
> 
> diff --cc arch/arm64/kernel/cpufeature.c
> index 96b15d7b10a8,5b25d56bccfd..
> --- a/arch/arm64/kernel/cpufeature.c
> +++ b/arch/arm64/kernel/cpufeature.c
> @@@ -838,19 -826,11 +838,6 @@@ static bool has_no_hw_prefetch(const st
>   MIDR_CPU_VAR_REV(1, MIDR_REVISION_MASK));
>   }
>   
> - static bool hyp_offset_low(const struct arm64_cpu_capabilities *entry,
> -int __unused)
>  -static bool runs_at_el2(const struct arm64_cpu_capabilities *entry, int 
> __unused)
> --{
> - phys_addr_t idmap_addr = __pa_symbol(__hyp_idmap_text_start);
> - 
> - /*
> -  * Activate the lower HYP offset only if:
> -  * - the idmap doesn't clash with it,
> -  * - the kernel is not running at EL2.
> -  */
> - return idmap_addr > GENMASK(VA_BITS - 2, 0) && !is_kernel_in_hyp_mode();
>  -return is_kernel_in_hyp_mode();
> --}
> --
>   static bool has_no_fpsimd(const struct arm64_cpu_capabilities *entry, int 
> __unused)
>   {
>   u64 pfr0 = read_sanitised_ftr_reg(SYS_ID_AA64PFR0_EL1);

This is now a conflict between the kvm tree and the arm64 tree.

-- 
Cheers,
Stephen Rothwell


pgpeAykeHDCCn.pgp
Description: OpenPGP digital signature


Re: General protection fault with use_blk_mq=1.

2018-03-28 Thread Paolo Valente


> Il giorno 29 mar 2018, alle ore 05:22, Jens Axboe  ha 
> scritto:
> 
> On 3/28/18 9:13 PM, Zephaniah E. Loss-Cutler-Hull wrote:
>> On 03/28/2018 06:02 PM, Jens Axboe wrote:
>>> On 3/28/18 5:03 PM, Zephaniah E. Loss-Cutler-Hull wrote:
 I am not subscribed to any of the lists on the To list here, please CC
 me on any replies.
 
 I am encountering a fairly consistent crash anywhere from 15 minutes to
 12 hours after boot with scsi_mod.use_blk_mq=1 dm_mod.use_blk_mq=1> 
 The crash looks like:
 
>> 
 
 Looking through the code, I'd guess that this is dying inside
 blkg_rwstat_add, which calls percpu_counter_add_batch, which is what RIP
 is pointing at.
>>> 
>>> Leaving the whole thing here for Paolo - it's crashing off insertion of
>>> a request coming out of SG_IO. Don't think we've seen this BFQ failure
>>> case before.
>>> 
>>> You can mitigate this by switching the scsi-mq devices to mq-deadline
>>> instead.
>>> 
>> 
>> I'm thinking that I should also be able to mitigate it by disabling
>> CONFIG_DEBUG_BLK_CGROUP.
>> 
>> That should remove that entire chunk of code.
>> 
>> Of course, that won't help if this is actually a symptom of a bigger
>> problem.
> 
> Yes, it's not a given that it will fully mask the issue at hand. But
> turning off BFQ has a much higher chance of working for you.
> 
> This time actually CC'ing Paolo.
> 

Hi Zephaniah,
if you are actually interested in the benefits of BFQ (low latency,
high responsiveness, fairness, ...) then it may be worth to try what
you yourself suggest: disabling CONFIG_DEBUG_BLK_CGROUP.  Also because
this option activates the heavy computation of debug cgroup statistics,
which probably you don't use.

In addition, the outcome of your attempt without
CONFIG_DEBUG_BLK_CGROUP would give us useful bisection information:
- if no failure occurs, then the issue is likely to be confined in
that debugging code (which, on the bright side, is likely to be of
occasional interest, for only a handful of developers)
- if the issue still shows up, then we may have new hints on this odd
failure

Finally, consider that this issue has been reported to disappear from
4.16 [1], and, as a plus, that the service quality of BFQ had a
further boost exactly from 4.16.

Looking forward to your feedback, in case you try BFQ without
CONFIG_DEBUG_BLK_CGROUP,
Paolo

[1] https://www.spinics.net/lists/linux-block/msg21422.html

> 
> -- 
> Jens Axboe



Re: General protection fault with use_blk_mq=1.

2018-03-28 Thread Paolo Valente


> Il giorno 29 mar 2018, alle ore 05:22, Jens Axboe  ha 
> scritto:
> 
> On 3/28/18 9:13 PM, Zephaniah E. Loss-Cutler-Hull wrote:
>> On 03/28/2018 06:02 PM, Jens Axboe wrote:
>>> On 3/28/18 5:03 PM, Zephaniah E. Loss-Cutler-Hull wrote:
 I am not subscribed to any of the lists on the To list here, please CC
 me on any replies.
 
 I am encountering a fairly consistent crash anywhere from 15 minutes to
 12 hours after boot with scsi_mod.use_blk_mq=1 dm_mod.use_blk_mq=1> 
 The crash looks like:
 
>> 
 
 Looking through the code, I'd guess that this is dying inside
 blkg_rwstat_add, which calls percpu_counter_add_batch, which is what RIP
 is pointing at.
>>> 
>>> Leaving the whole thing here for Paolo - it's crashing off insertion of
>>> a request coming out of SG_IO. Don't think we've seen this BFQ failure
>>> case before.
>>> 
>>> You can mitigate this by switching the scsi-mq devices to mq-deadline
>>> instead.
>>> 
>> 
>> I'm thinking that I should also be able to mitigate it by disabling
>> CONFIG_DEBUG_BLK_CGROUP.
>> 
>> That should remove that entire chunk of code.
>> 
>> Of course, that won't help if this is actually a symptom of a bigger
>> problem.
> 
> Yes, it's not a given that it will fully mask the issue at hand. But
> turning off BFQ has a much higher chance of working for you.
> 
> This time actually CC'ing Paolo.
> 

Hi Zephaniah,
if you are actually interested in the benefits of BFQ (low latency,
high responsiveness, fairness, ...) then it may be worth to try what
you yourself suggest: disabling CONFIG_DEBUG_BLK_CGROUP.  Also because
this option activates the heavy computation of debug cgroup statistics,
which probably you don't use.

In addition, the outcome of your attempt without
CONFIG_DEBUG_BLK_CGROUP would give us useful bisection information:
- if no failure occurs, then the issue is likely to be confined in
that debugging code (which, on the bright side, is likely to be of
occasional interest, for only a handful of developers)
- if the issue still shows up, then we may have new hints on this odd
failure

Finally, consider that this issue has been reported to disappear from
4.16 [1], and, as a plus, that the service quality of BFQ had a
further boost exactly from 4.16.

Looking forward to your feedback, in case you try BFQ without
CONFIG_DEBUG_BLK_CGROUP,
Paolo

[1] https://www.spinics.net/lists/linux-block/msg21422.html

> 
> -- 
> Jens Axboe



linux-next: manual merge of the kvm tree with the kvm-fixes tree

2018-03-28 Thread Stephen Rothwell
Hi all,

Today's linux-next merge of the kvm tree got a conflict in:

  arch/x86/kvm/vmx.c

between commit:

  9d1887ef3252 ("KVM: nVMX: sync vmcs02 segment regs prior to vmx_set_cr0")

from the kvm-fixes tree and commit:

  2bb8cafea80b ("KVM: vVMX: signal failure for nested VMEntry if 
emulation_required")

from the kvm tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc arch/x86/kvm/vmx.c
index 92496b9b5f2b,9bc05f5349c8..
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@@ -10952,6 -11081,21 +11092,16 @@@ static int prepare_vmcs02(struct kvm_vc
/* Note: modifies VM_ENTRY/EXIT_CONTROLS and GUEST/HOST_IA32_EFER */
vmx_set_efer(vcpu, vcpu->arch.efer);
  
 -  if (vmx->nested.dirty_vmcs12) {
 -  prepare_vmcs02_full(vcpu, vmcs12, from_vmentry);
 -  vmx->nested.dirty_vmcs12 = false;
 -  }
 -
+   /*
+* Guest state is invalid and unrestricted guest is disabled,
+* which means L1 attempted VMEntry to L2 with invalid state.
+* Fail the VMEntry.
+*/
+   if (vmx->emulation_required) {
+   *entry_failure_code = ENTRY_FAIL_DEFAULT;
+   return 1;
+   }
+ 
/* Shadow page tables on either EPT or shadow page tables. */
if (nested_vmx_load_cr3(vcpu, vmcs12->guest_cr3, 
nested_cpu_has_ept(vmcs12),
entry_failure_code))


pgpyL1d08Z8Ab.pgp
Description: OpenPGP digital signature


linux-next: manual merge of the kvm tree with the kvm-fixes tree

2018-03-28 Thread Stephen Rothwell
Hi all,

Today's linux-next merge of the kvm tree got a conflict in:

  arch/x86/kvm/vmx.c

between commit:

  9d1887ef3252 ("KVM: nVMX: sync vmcs02 segment regs prior to vmx_set_cr0")

from the kvm-fixes tree and commit:

  2bb8cafea80b ("KVM: vVMX: signal failure for nested VMEntry if 
emulation_required")

from the kvm tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc arch/x86/kvm/vmx.c
index 92496b9b5f2b,9bc05f5349c8..
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@@ -10952,6 -11081,21 +11092,16 @@@ static int prepare_vmcs02(struct kvm_vc
/* Note: modifies VM_ENTRY/EXIT_CONTROLS and GUEST/HOST_IA32_EFER */
vmx_set_efer(vcpu, vcpu->arch.efer);
  
 -  if (vmx->nested.dirty_vmcs12) {
 -  prepare_vmcs02_full(vcpu, vmcs12, from_vmentry);
 -  vmx->nested.dirty_vmcs12 = false;
 -  }
 -
+   /*
+* Guest state is invalid and unrestricted guest is disabled,
+* which means L1 attempted VMEntry to L2 with invalid state.
+* Fail the VMEntry.
+*/
+   if (vmx->emulation_required) {
+   *entry_failure_code = ENTRY_FAIL_DEFAULT;
+   return 1;
+   }
+ 
/* Shadow page tables on either EPT or shadow page tables. */
if (nested_vmx_load_cr3(vcpu, vmcs12->guest_cr3, 
nested_cpu_has_ept(vmcs12),
entry_failure_code))


pgpyL1d08Z8Ab.pgp
Description: OpenPGP digital signature


Re: kernel BUG at lib/string.c:LINE! (3)

2018-03-28 Thread syzbot

syzbot has found reproducer for the following crash on upstream commit
a2601d78b77aacc5dd790f488188f9556f4a9eb2 (Wed Mar 28 23:54:03 2018 +)
Merge tag 'powerpc-4.16-6' of  
git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux
syzbot dashboard link:  
https://syzkaller.appspot.com/bug?extid=6800425d54ed3ed8135d


So far this crash happened 3 times on upstream.
C reproducer: https://syzkaller.appspot.com/x/repro.c?id=4970341969428480
syzkaller reproducer:  
https://syzkaller.appspot.com/x/repro.syz?id=5526256363765760
Raw console output:  
https://syzkaller.appspot.com/x/log.txt?id=5692795733934080
Kernel config:  
https://syzkaller.appspot.com/x/.config?id=-8440362230543204781

compiler: gcc (GCC) 7.1.1 20170620

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+6800425d54ed3ed81...@syzkaller.appspotmail.com
It will help syzbot understand when the bug is fixed.

detected buffer overflow in memcpy
[ cut here ]
kernel BUG at lib/string.c:1052!
invalid opcode:  [#1] SMP KASAN
Dumping ftrace buffer:
   (ftrace buffer empty)
Modules linked in:
CPU: 1 PID: 4420 Comm: syzkaller185831 Not tainted 4.16.0-rc7+ #4
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS  
Google 01/01/2011

RIP: 0010:fortify_panic+0x13/0x20 lib/string.c:1051
RSP: 0018:8801b02bf940 EFLAGS: 00010282
RAX: 0022 RBX: 110036057f2d RCX: 
RDX: 0022 RSI: 110036057edd RDI: ed0036057f1c
RBP: 8801b02bf940 R08:  R09: 
R10: 0006 R11:  R12: 8801b02bf9e8
R13: 8801b02bf988 R14: 8801b02bfaa8 R15: fa00
FS:  019ff880() GS:8801db30() knlGS:
CS:  0010 DS:  ES:  CR0: 80050033
CR2: 2140 CR3: 0001b0f1b005 CR4: 001606e0
DR0:  DR1:  DR2: 
DR3:  DR6: fffe0ff0 DR7: 0400
Call Trace:
 memcpy include/linux/string.h:344 [inline]
 ucma_join_ip_multicast+0x37a/0x3c0 drivers/infiniband/core/ucma.c:1434
 ucma_write+0x2d6/0x3d0 drivers/infiniband/core/ucma.c:1649
 __vfs_write+0xef/0x970 fs/read_write.c:480
 vfs_write+0x189/0x510 fs/read_write.c:544
 SYSC_write fs/read_write.c:589 [inline]
 SyS_write+0xef/0x220 fs/read_write.c:581
 do_syscall_64+0x281/0x940 arch/x86/entry/common.c:287
 entry_SYSCALL_64_after_hwframe+0x42/0xb7
RIP: 0033:0x43fd29
RSP: 002b:7ffed3ea1058 EFLAGS: 0213 ORIG_RAX: 0001
RAX: ffda RBX: 004002c8 RCX: 0043fd29
RDX: 0118 RSI: 2f80 RDI: 0003
RBP: 006ca018 R08: 004002c8 R09: 004002c8
R10: 004002c8 R11: 0213 R12: 00401650
R13: 004016e0 R14:  R15: 
Code: 08 5b 41 5c 41 5d 41 5e 41 5f 5d c3 0f 0b 48 89 df e8 d2 a7 3f fb eb  
de 55 48 89 fe 48 c7 c7 c0 43 44 87 48 89 e5 e8 d5 05 f1 fa <0f> 0b 90 90  
90 90 90 90 90 90 90 90 90 55 48 89 e5 41 57 41 56

RIP: fortify_panic+0x13/0x20 lib/string.c:1051 RSP: 8801b02bf940
---[ end trace 71f07011b6e6886b ]---
Kernel panic - not syncing: Fatal exception
Dumping ftrace buffer:
   (ftrace buffer empty)
Kernel Offset: disabled
Rebooting in 86400 seconds..



Re: kernel BUG at lib/string.c:LINE! (3)

2018-03-28 Thread syzbot

syzbot has found reproducer for the following crash on upstream commit
a2601d78b77aacc5dd790f488188f9556f4a9eb2 (Wed Mar 28 23:54:03 2018 +)
Merge tag 'powerpc-4.16-6' of  
git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux
syzbot dashboard link:  
https://syzkaller.appspot.com/bug?extid=6800425d54ed3ed8135d


So far this crash happened 3 times on upstream.
C reproducer: https://syzkaller.appspot.com/x/repro.c?id=4970341969428480
syzkaller reproducer:  
https://syzkaller.appspot.com/x/repro.syz?id=5526256363765760
Raw console output:  
https://syzkaller.appspot.com/x/log.txt?id=5692795733934080
Kernel config:  
https://syzkaller.appspot.com/x/.config?id=-8440362230543204781

compiler: gcc (GCC) 7.1.1 20170620

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+6800425d54ed3ed81...@syzkaller.appspotmail.com
It will help syzbot understand when the bug is fixed.

detected buffer overflow in memcpy
[ cut here ]
kernel BUG at lib/string.c:1052!
invalid opcode:  [#1] SMP KASAN
Dumping ftrace buffer:
   (ftrace buffer empty)
Modules linked in:
CPU: 1 PID: 4420 Comm: syzkaller185831 Not tainted 4.16.0-rc7+ #4
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS  
Google 01/01/2011

RIP: 0010:fortify_panic+0x13/0x20 lib/string.c:1051
RSP: 0018:8801b02bf940 EFLAGS: 00010282
RAX: 0022 RBX: 110036057f2d RCX: 
RDX: 0022 RSI: 110036057edd RDI: ed0036057f1c
RBP: 8801b02bf940 R08:  R09: 
R10: 0006 R11:  R12: 8801b02bf9e8
R13: 8801b02bf988 R14: 8801b02bfaa8 R15: fa00
FS:  019ff880() GS:8801db30() knlGS:
CS:  0010 DS:  ES:  CR0: 80050033
CR2: 2140 CR3: 0001b0f1b005 CR4: 001606e0
DR0:  DR1:  DR2: 
DR3:  DR6: fffe0ff0 DR7: 0400
Call Trace:
 memcpy include/linux/string.h:344 [inline]
 ucma_join_ip_multicast+0x37a/0x3c0 drivers/infiniband/core/ucma.c:1434
 ucma_write+0x2d6/0x3d0 drivers/infiniband/core/ucma.c:1649
 __vfs_write+0xef/0x970 fs/read_write.c:480
 vfs_write+0x189/0x510 fs/read_write.c:544
 SYSC_write fs/read_write.c:589 [inline]
 SyS_write+0xef/0x220 fs/read_write.c:581
 do_syscall_64+0x281/0x940 arch/x86/entry/common.c:287
 entry_SYSCALL_64_after_hwframe+0x42/0xb7
RIP: 0033:0x43fd29
RSP: 002b:7ffed3ea1058 EFLAGS: 0213 ORIG_RAX: 0001
RAX: ffda RBX: 004002c8 RCX: 0043fd29
RDX: 0118 RSI: 2f80 RDI: 0003
RBP: 006ca018 R08: 004002c8 R09: 004002c8
R10: 004002c8 R11: 0213 R12: 00401650
R13: 004016e0 R14:  R15: 
Code: 08 5b 41 5c 41 5d 41 5e 41 5f 5d c3 0f 0b 48 89 df e8 d2 a7 3f fb eb  
de 55 48 89 fe 48 c7 c7 c0 43 44 87 48 89 e5 e8 d5 05 f1 fa <0f> 0b 90 90  
90 90 90 90 90 90 90 90 90 55 48 89 e5 41 57 41 56

RIP: fortify_panic+0x13/0x20 lib/string.c:1051 RSP: 8801b02bf940
---[ end trace 71f07011b6e6886b ]---
Kernel panic - not syncing: Fatal exception
Dumping ftrace buffer:
   (ftrace buffer empty)
Kernel Offset: disabled
Rebooting in 86400 seconds..



linux-next: manual merge of the kvm tree with the kvm-fixes tree

2018-03-28 Thread Stephen Rothwell
Hi all,

Today's linux-next merge of the kvm tree got conflicts in:

  arch/x86/kernel/kvm.c

between commit:

  17a1079d9c63 ("KVM: x86: Fix pv tlb flush dependencies")

from the kvm-fixes tree and commit:

  6beacf74c257 ("KVM: X86: Don't use PV TLB flush with dedicated physical CPUs")

from the kvm tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc arch/x86/kernel/kvm.c
index fae86e36e399,4ccbff63cb86..
--- a/arch/x86/kernel/kvm.c
+++ b/arch/x86/kernel/kvm.c
@@@ -546,7 -546,8 +546,8 @@@ static void __init kvm_guest_init(void
}
  
if (kvm_para_has_feature(KVM_FEATURE_PV_TLB_FLUSH) &&
+   !kvm_para_has_hint(KVM_HINTS_DEDICATED) &&
 -  !kvm_para_has_feature(KVM_FEATURE_STEAL_TIME))
 +  kvm_para_has_feature(KVM_FEATURE_STEAL_TIME))
pv_mmu_ops.flush_tlb_others = kvm_flush_tlb_others;
  
if (kvm_para_has_feature(KVM_FEATURE_PV_EOI))
@@@ -635,7 -641,8 +641,8 @@@ static __init int kvm_setup_pv_tlb_flus
int cpu;
  
if (kvm_para_has_feature(KVM_FEATURE_PV_TLB_FLUSH) &&
+   !kvm_para_has_hint(KVM_HINTS_DEDICATED) &&
 -  !kvm_para_has_feature(KVM_FEATURE_STEAL_TIME)) {
 +  kvm_para_has_feature(KVM_FEATURE_STEAL_TIME)) {
for_each_possible_cpu(cpu) {
zalloc_cpumask_var_node(per_cpu_ptr(&__pv_tlb_mask, 
cpu),
GFP_KERNEL, cpu_to_node(cpu));


pgp6fEKOClamC.pgp
Description: OpenPGP digital signature


linux-next: manual merge of the kvm tree with the kvm-fixes tree

2018-03-28 Thread Stephen Rothwell
Hi all,

Today's linux-next merge of the kvm tree got conflicts in:

  arch/x86/kernel/kvm.c

between commit:

  17a1079d9c63 ("KVM: x86: Fix pv tlb flush dependencies")

from the kvm-fixes tree and commit:

  6beacf74c257 ("KVM: X86: Don't use PV TLB flush with dedicated physical CPUs")

from the kvm tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc arch/x86/kernel/kvm.c
index fae86e36e399,4ccbff63cb86..
--- a/arch/x86/kernel/kvm.c
+++ b/arch/x86/kernel/kvm.c
@@@ -546,7 -546,8 +546,8 @@@ static void __init kvm_guest_init(void
}
  
if (kvm_para_has_feature(KVM_FEATURE_PV_TLB_FLUSH) &&
+   !kvm_para_has_hint(KVM_HINTS_DEDICATED) &&
 -  !kvm_para_has_feature(KVM_FEATURE_STEAL_TIME))
 +  kvm_para_has_feature(KVM_FEATURE_STEAL_TIME))
pv_mmu_ops.flush_tlb_others = kvm_flush_tlb_others;
  
if (kvm_para_has_feature(KVM_FEATURE_PV_EOI))
@@@ -635,7 -641,8 +641,8 @@@ static __init int kvm_setup_pv_tlb_flus
int cpu;
  
if (kvm_para_has_feature(KVM_FEATURE_PV_TLB_FLUSH) &&
+   !kvm_para_has_hint(KVM_HINTS_DEDICATED) &&
 -  !kvm_para_has_feature(KVM_FEATURE_STEAL_TIME)) {
 +  kvm_para_has_feature(KVM_FEATURE_STEAL_TIME)) {
for_each_possible_cpu(cpu) {
zalloc_cpumask_var_node(per_cpu_ptr(&__pv_tlb_mask, 
cpu),
GFP_KERNEL, cpu_to_node(cpu));


pgp6fEKOClamC.pgp
Description: OpenPGP digital signature


Re: [PATCH v4 2/8] openrisc: Set CONFIG_MULTI_IRQ_HANDLER

2018-03-28 Thread Stafford Horne
On Tue, Mar 27, 2018 at 09:19:05AM -0700, Palmer Dabbelt wrote:
> arm has an optional MULTI_IRQ_HANDLER, which openrisc copied but didn't
> make optional.  I'm converting this to generic code, but in order to
> ensure everything stays bisectable I want this defined on openrisc for
> now.  This will go away by the end of the patch set.
> 
> Signed-off-by: Palmer Dabbelt 

Hi Palmer,
Thanks for doing this work, its always nice to see generic code pulled out of
architecture ports.

Acked-by: Stafford Horne 

> ---
>  arch/openrisc/Kconfig | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git a/arch/openrisc/Kconfig b/arch/openrisc/Kconfig
> index 339df7324e9c..9ecad05bfc73 100644
> --- a/arch/openrisc/Kconfig
> +++ b/arch/openrisc/Kconfig
> @@ -27,6 +27,7 @@ config OPENRISC
>   select GENERIC_STRNLEN_USER
>   select GENERIC_SMP_IDLE_THREAD
>   select MODULES_USE_ELF_RELA
> + select MULTI_IRQ_HANDLER
>   select HAVE_DEBUG_STACKOVERFLOW
>   select OR1K_PIC
>   select CPU_NO_EFFICIENT_FFS if !OPENRISC_HAVE_INST_FF1
> @@ -68,6 +69,9 @@ config STACKTRACE_SUPPORT
>  config LOCKDEP_SUPPORT
>   def_bool  y
>  
> +config MULTI_IRQ_HANDLER
> + def_bool y
> +
>  source "init/Kconfig"
>  
>  source "kernel/Kconfig.freezer"
> -- 
> 2.16.1
> 


Re: [PATCH v4 2/8] openrisc: Set CONFIG_MULTI_IRQ_HANDLER

2018-03-28 Thread Stafford Horne
On Tue, Mar 27, 2018 at 09:19:05AM -0700, Palmer Dabbelt wrote:
> arm has an optional MULTI_IRQ_HANDLER, which openrisc copied but didn't
> make optional.  I'm converting this to generic code, but in order to
> ensure everything stays bisectable I want this defined on openrisc for
> now.  This will go away by the end of the patch set.
> 
> Signed-off-by: Palmer Dabbelt 

Hi Palmer,
Thanks for doing this work, its always nice to see generic code pulled out of
architecture ports.

Acked-by: Stafford Horne 

> ---
>  arch/openrisc/Kconfig | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git a/arch/openrisc/Kconfig b/arch/openrisc/Kconfig
> index 339df7324e9c..9ecad05bfc73 100644
> --- a/arch/openrisc/Kconfig
> +++ b/arch/openrisc/Kconfig
> @@ -27,6 +27,7 @@ config OPENRISC
>   select GENERIC_STRNLEN_USER
>   select GENERIC_SMP_IDLE_THREAD
>   select MODULES_USE_ELF_RELA
> + select MULTI_IRQ_HANDLER
>   select HAVE_DEBUG_STACKOVERFLOW
>   select OR1K_PIC
>   select CPU_NO_EFFICIENT_FFS if !OPENRISC_HAVE_INST_FF1
> @@ -68,6 +69,9 @@ config STACKTRACE_SUPPORT
>  config LOCKDEP_SUPPORT
>   def_bool  y
>  
> +config MULTI_IRQ_HANDLER
> + def_bool y
> +
>  source "init/Kconfig"
>  
>  source "kernel/Kconfig.freezer"
> -- 
> 2.16.1
> 


Re: General protection fault with use_blk_mq=1.

2018-03-28 Thread Paolo Valente


> Il giorno 29 mar 2018, alle ore 03:02, Jens Axboe  ha 
> scritto:
> 
> On 3/28/18 5:03 PM, Zephaniah E. Loss-Cutler-Hull wrote:
>> I am not subscribed to any of the lists on the To list here, please CC
>> me on any replies.
>> 
>> I am encountering a fairly consistent crash anywhere from 15 minutes to
>> 12 hours after boot with scsi_mod.use_blk_mq=1 dm_mod.use_blk_mq=1> 
>> The crash looks like:
>> 
>> [ 5466.075993] general protection fault:  [#1] PREEMPT SMP PTI
>> [ 5466.075997] Modules linked in: esp4 xfrm4_mode_tunnel fuse usblp
>> uvcvideo pci_stub vboxpci(O) vboxnetadp(O) vboxnetflt(O) vboxdrv(O)
>> ip6table_filter ip6_tables xt_tcpudp nf_conntrack_ipv4 nf_defrag_ipv4
>> xt_conntrack nf_conntrack iptable_filter ip_tables x_tables intel_rapl
>> joydev serio_raw wmi_bmof iwldvm iwlwifi shpchp kvm_intel kvm irqbypass
>> autofs4 algif_skcipher nls_iso8859_1 nls_cp437 crc32_pclmul
>> ghash_clmulni_intel
>> [ 5466.076022] CPU: 3 PID: 10573 Comm: pool Tainted: G   O
>> 4.15.13-f1-dirty #148
>> [ 5466.076024] Hardware name: Hewlett-Packard HP EliteBook Folio
>> 9470m/18DF, BIOS 68IBD Ver. F.44 05/22/2013
>> [ 5466.076029] RIP: 0010:percpu_counter_add_batch+0x2b/0xb0
>> [ 5466.076031] RSP: 0018:a556c47afb58 EFLAGS: 00010002
>> [ 5466.076033] RAX: 95cda87ce018 RBX: 95cda87cdb68 RCX:
>> 
>> [ 5466.076034] RDX: 3fff RSI: 896495c4 RDI:
>> 895b2bed
>> [ 5466.076036] RBP: 3fff R08:  R09:
>> 95cb7d5f8148
>> [ 5466.076037] R10: 0200 R11:  R12:
>> 0001
>> [ 5466.076038] R13: 95cda87ce088 R14: 95cda6ebd100 R15:
>> a556c47afc58
>> [ 5466.076040] FS:  7f25f5305700() GS:95cdbeac()
>> knlGS:
>> [ 5466.076042] CS:  0010 DS:  ES:  CR0: 80050033
>> [ 5466.076043] CR2: 7f25e807e0a8 CR3: 0003ed5a6001 CR4:
>> 001606e0
>> [ 5466.076044] Call Trace:
>> [ 5466.076050]  bfqg_stats_update_io_add+0x58/0x100
>> [ 5466.076055]  bfq_insert_requests+0xec/0xd80
>> [ 5466.076059]  ? blk_rq_append_bio+0x8f/0xa0
>> [ 5466.076061]  ? blk_rq_map_user_iov+0xc3/0x1d0
>> [ 5466.076065]  blk_mq_sched_insert_request+0xa3/0x130
>> [ 5466.076068]  blk_execute_rq+0x3a/0x50
>> [ 5466.076070]  sg_io+0x197/0x3e0
>> [ 5466.076073]  ? dput+0xca/0x210
>> [ 5466.076077]  ? mntput_no_expire+0x11/0x1a0
>> [ 5466.076079]  scsi_cmd_ioctl+0x289/0x400
>> [ 5466.076082]  ? filename_lookup+0xe1/0x170
>> [ 5466.076085]  sd_ioctl+0xc7/0x1a0
>> [ 5466.076088]  blkdev_ioctl+0x4d4/0x8c0
>> [ 5466.076091]  block_ioctl+0x39/0x40
>> [ 5466.076094]  do_vfs_ioctl+0x92/0x5e0
>> [ 5466.076097]  ? __fget+0x73/0xc0
>> [ 5466.076099]  SyS_ioctl+0x74/0x80
>> [ 5466.076102]  do_syscall_64+0x60/0x110
>> [ 5466.076106]  entry_SYSCALL_64_after_hwframe+0x3d/0xa2
>> [ 5466.076109] RIP: 0033:0x7f25f75fef47
>> [ 5466.076110] RSP: 002b:7f25f53049a8 EFLAGS: 0246 ORIG_RAX:
>> 0010
>> [ 5466.076112] RAX: ffda RBX: 000c RCX:
>> 7f25f75fef47
>> [ 5466.076114] RDX: 7f25f53049b0 RSI: 2285 RDI:
>> 000c
>> [ 5466.076115] RBP: 0010 R08: 7f25e8007818 R09:
>> 0200
>> [ 5466.076116] R10: 0001 R11: 0246 R12:
>> 
>> [ 5466.076118] R13:  R14: 7f25f8a6b5e0 R15:
>> 7f25e80173e0
>> [ 5466.076120] Code: 41 55 49 89 fd bf 01 00 00 00 41 54 49 89 f4 55 89
>> d5 53 e8 18 e1 bb ff 48 c7 c7 c4 95 64 89 e8 dc e9 fb ff 49 8b 45 20 48
>> 63 d5 <65> 8b 18 48 63 db 4c 01 e3 48 39 d3 7d 0a f7 dd 48 63 ed 48 39
>> [ 5466.076147] RIP: percpu_counter_add_batch+0x2b/0xb0 RSP: a556c47afb58
>> [ 5466.076149] ---[ end trace 8d7eb80aafef4494 ]---
>> [ 5466.670153] note: pool[10573] exited with preempt_count 2
>> 
>> (I only have the one instance right this minute as a result of not
>> having remote syslog setup before now.)
>> 
>> This is clearly deep in the blk_mq code, and it goes away when I remove
>> the use_blk_mq kernel command line parameters.
>> 
>> My next obvious step is to try and disable the load of the vbox modules.
>> 
>> I can include the full dmesg output if it would be helpful.
>> 
>> The system is an older HP Ultrabook, and the root partition is, sda1 (a
>> SSD) -> a LUKS encrypted partition -> LVM -> BTRFS.
>> 
>> The kernel is a stock 4.15.11, however I only recently added the blk_mq
>> options, so while I can state that I have seen this on multiple kernels
>> in the 4.15.x series, I have not tested earlier kernels in this
>> configuration.
>> 
>> Looking through the code, I'd guess that this is dying inside
>> blkg_rwstat_add, which calls percpu_counter_add_batch, which is what RIP
>> is pointing at.
> 
> Leaving the whole thing here for Paolo - it's crashing off insertion of
> a request coming out of SG_IO. Don't think we've seen this BFQ failure
> case before.
> 

Actually, we have.  Found and 

Re: General protection fault with use_blk_mq=1.

2018-03-28 Thread Paolo Valente


> Il giorno 29 mar 2018, alle ore 03:02, Jens Axboe  ha 
> scritto:
> 
> On 3/28/18 5:03 PM, Zephaniah E. Loss-Cutler-Hull wrote:
>> I am not subscribed to any of the lists on the To list here, please CC
>> me on any replies.
>> 
>> I am encountering a fairly consistent crash anywhere from 15 minutes to
>> 12 hours after boot with scsi_mod.use_blk_mq=1 dm_mod.use_blk_mq=1> 
>> The crash looks like:
>> 
>> [ 5466.075993] general protection fault:  [#1] PREEMPT SMP PTI
>> [ 5466.075997] Modules linked in: esp4 xfrm4_mode_tunnel fuse usblp
>> uvcvideo pci_stub vboxpci(O) vboxnetadp(O) vboxnetflt(O) vboxdrv(O)
>> ip6table_filter ip6_tables xt_tcpudp nf_conntrack_ipv4 nf_defrag_ipv4
>> xt_conntrack nf_conntrack iptable_filter ip_tables x_tables intel_rapl
>> joydev serio_raw wmi_bmof iwldvm iwlwifi shpchp kvm_intel kvm irqbypass
>> autofs4 algif_skcipher nls_iso8859_1 nls_cp437 crc32_pclmul
>> ghash_clmulni_intel
>> [ 5466.076022] CPU: 3 PID: 10573 Comm: pool Tainted: G   O
>> 4.15.13-f1-dirty #148
>> [ 5466.076024] Hardware name: Hewlett-Packard HP EliteBook Folio
>> 9470m/18DF, BIOS 68IBD Ver. F.44 05/22/2013
>> [ 5466.076029] RIP: 0010:percpu_counter_add_batch+0x2b/0xb0
>> [ 5466.076031] RSP: 0018:a556c47afb58 EFLAGS: 00010002
>> [ 5466.076033] RAX: 95cda87ce018 RBX: 95cda87cdb68 RCX:
>> 
>> [ 5466.076034] RDX: 3fff RSI: 896495c4 RDI:
>> 895b2bed
>> [ 5466.076036] RBP: 3fff R08:  R09:
>> 95cb7d5f8148
>> [ 5466.076037] R10: 0200 R11:  R12:
>> 0001
>> [ 5466.076038] R13: 95cda87ce088 R14: 95cda6ebd100 R15:
>> a556c47afc58
>> [ 5466.076040] FS:  7f25f5305700() GS:95cdbeac()
>> knlGS:
>> [ 5466.076042] CS:  0010 DS:  ES:  CR0: 80050033
>> [ 5466.076043] CR2: 7f25e807e0a8 CR3: 0003ed5a6001 CR4:
>> 001606e0
>> [ 5466.076044] Call Trace:
>> [ 5466.076050]  bfqg_stats_update_io_add+0x58/0x100
>> [ 5466.076055]  bfq_insert_requests+0xec/0xd80
>> [ 5466.076059]  ? blk_rq_append_bio+0x8f/0xa0
>> [ 5466.076061]  ? blk_rq_map_user_iov+0xc3/0x1d0
>> [ 5466.076065]  blk_mq_sched_insert_request+0xa3/0x130
>> [ 5466.076068]  blk_execute_rq+0x3a/0x50
>> [ 5466.076070]  sg_io+0x197/0x3e0
>> [ 5466.076073]  ? dput+0xca/0x210
>> [ 5466.076077]  ? mntput_no_expire+0x11/0x1a0
>> [ 5466.076079]  scsi_cmd_ioctl+0x289/0x400
>> [ 5466.076082]  ? filename_lookup+0xe1/0x170
>> [ 5466.076085]  sd_ioctl+0xc7/0x1a0
>> [ 5466.076088]  blkdev_ioctl+0x4d4/0x8c0
>> [ 5466.076091]  block_ioctl+0x39/0x40
>> [ 5466.076094]  do_vfs_ioctl+0x92/0x5e0
>> [ 5466.076097]  ? __fget+0x73/0xc0
>> [ 5466.076099]  SyS_ioctl+0x74/0x80
>> [ 5466.076102]  do_syscall_64+0x60/0x110
>> [ 5466.076106]  entry_SYSCALL_64_after_hwframe+0x3d/0xa2
>> [ 5466.076109] RIP: 0033:0x7f25f75fef47
>> [ 5466.076110] RSP: 002b:7f25f53049a8 EFLAGS: 0246 ORIG_RAX:
>> 0010
>> [ 5466.076112] RAX: ffda RBX: 000c RCX:
>> 7f25f75fef47
>> [ 5466.076114] RDX: 7f25f53049b0 RSI: 2285 RDI:
>> 000c
>> [ 5466.076115] RBP: 0010 R08: 7f25e8007818 R09:
>> 0200
>> [ 5466.076116] R10: 0001 R11: 0246 R12:
>> 
>> [ 5466.076118] R13:  R14: 7f25f8a6b5e0 R15:
>> 7f25e80173e0
>> [ 5466.076120] Code: 41 55 49 89 fd bf 01 00 00 00 41 54 49 89 f4 55 89
>> d5 53 e8 18 e1 bb ff 48 c7 c7 c4 95 64 89 e8 dc e9 fb ff 49 8b 45 20 48
>> 63 d5 <65> 8b 18 48 63 db 4c 01 e3 48 39 d3 7d 0a f7 dd 48 63 ed 48 39
>> [ 5466.076147] RIP: percpu_counter_add_batch+0x2b/0xb0 RSP: a556c47afb58
>> [ 5466.076149] ---[ end trace 8d7eb80aafef4494 ]---
>> [ 5466.670153] note: pool[10573] exited with preempt_count 2
>> 
>> (I only have the one instance right this minute as a result of not
>> having remote syslog setup before now.)
>> 
>> This is clearly deep in the blk_mq code, and it goes away when I remove
>> the use_blk_mq kernel command line parameters.
>> 
>> My next obvious step is to try and disable the load of the vbox modules.
>> 
>> I can include the full dmesg output if it would be helpful.
>> 
>> The system is an older HP Ultrabook, and the root partition is, sda1 (a
>> SSD) -> a LUKS encrypted partition -> LVM -> BTRFS.
>> 
>> The kernel is a stock 4.15.11, however I only recently added the blk_mq
>> options, so while I can state that I have seen this on multiple kernels
>> in the 4.15.x series, I have not tested earlier kernels in this
>> configuration.
>> 
>> Looking through the code, I'd guess that this is dying inside
>> blkg_rwstat_add, which calls percpu_counter_add_batch, which is what RIP
>> is pointing at.
> 
> Leaving the whole thing here for Paolo - it's crashing off insertion of
> a request coming out of SG_IO. Don't think we've seen this BFQ failure
> case before.
> 

Actually, we have.  Found and reported by Ming 

Re: [PATCH RFC tools/memory-model] Add s390.{cfg,cat}

2018-03-28 Thread Paul E. McKenney
On Wed, Mar 28, 2018 at 02:04:07PM -0400, Alan Stern wrote:
> On Wed, 28 Mar 2018, Paul E. McKenney wrote:
> 
> > On Wed, Mar 28, 2018 at 11:01:25AM -0400, Alan Stern wrote:
> > > On Wed, 28 Mar 2018, Paul E. McKenney wrote:
> > > 
> > > > Hello!
> > > > 
> > > > The prototype patch shown below provides files required to allow herd7 
> > > > to
> > > > evaluate C-language litmus tests for the multicopy-atomic TSO ordering
> > > > provided by s390.  This patch should be viewed with great suspicion.
> > > > It does what I expect it to do on SB (with and without barriers),
> > > > IRIW without barriers, and Alan's SB with read-of-write added, but my
> > > > expectations are quite likely faulty, and my test cases are very few
> > > > in number.
> > > > 
> > > > Either way, this is the easy part.  The hard part (which I am happy
> > > > to leave to others) is making litmus7 and klitmus7 able to do tests
> > > > on actual hardware, as well as enabling herd to handle litmus tests
> > > > containing BAL.  ;-)
> > > > 
> > > > Note that CPU architectures already supported by herd might well need
> > > > only a .cfg file that refers to herd's pre-existing support.
> > > > 
> > > > Thoughts?
> > > 
> > > I don't quite see the point of this.  You're not suggesting that we
> > > have one Linux Kernel Memory Consistency Model for s390 and another
> > > one for all the other architectures, are you?
> > 
> > Certainly not for common code!
> > 
> > > If the idea is merely to provide a herd model for s390 then it should 
> > > go into the DIY repository, not into the LKMM repository.
> > 
> > Makes sense.
> > 
> > In the meantime, does the cat file look to you like it correctly
> > models the combination of TSO and multicopy atomicity?  Do the
> > fences really work, or did I just get lucky with my choice of
> > litmus tests?
> 
> You got lucky.  Try creating an SB litmus test where, instead of an
> smp_mb() fence between the write and the read, each thread executes
> some other kind of fence.

Ah, it does indeed get "Never" in that case, which I do not believe
to e correct.

> The acyclicity condition should have been written more like this:
> 
> let po_ghb = ([R] ; po ; [M]) | ([M] ; po ; [W])
> 
> acyclic mfence | po_ghb | rf | fr | co as tso-mca
> 
> I don't know what the fence instruction is on s390; change the "mfence"
> above accordingly.  The main difference between this and the
> corresponding expression in x86tso.cat is that I replaced rfe with rf.

The s390 fence instruction is "bcr 14,0" or "bcr 15,0", depending on
how recent of hardware you are running.  The latter works everywhere,
if I recall correctly.  But I do not believe that herd knows about either
instruction yet.  Ah, and I need to lose the "empty rmw & (fre;coe)".
That appears to be where my spurious ordering was coming from, strange
though that seems to me.

And your use of "rf" instead of "rfe" makes sense, as that is what makes
the read-from-write provide ordering, correct?  And that should also cover
the "Uniproc check" that would otherwise be required, right?

Except that I get "Sometimes" on CoWR+poonceonce+Once.litmus...
Which I can fix by unioning po-loc into po-ghb.  Or is there some
better way to do this?

> This doesn't account for atomic operations properly; see the "implied" 
> term in x86tso.cat.

I will look at this more later, reaching end of both battery and useful
attention span...

Thanx, Paul



Re: [PATCH RFC tools/memory-model] Add s390.{cfg,cat}

2018-03-28 Thread Paul E. McKenney
On Wed, Mar 28, 2018 at 07:51:36PM +0200, Peter Zijlstra wrote:
> On Wed, Mar 28, 2018 at 11:01:25AM -0400, Alan Stern wrote:
> > I don't quite see the point of this.  You're not suggesting that we
> > have one Linux Kernel Memory Consistency Model for s390 and another
> > one for all the other architectures, are you?
> > 
> > If the idea is merely to provide a herd model for s390 then it should 
> > go into the DIY repository, not into the LKMM repository.
> 
> I suspect the use-case was validating s390 arch code which might not
> have followed all the regular linux rules because they know its TSO. But
> yes, I'm tempted to agree that even arch specific code ought to follow
> the regular rules, just to avoid completely messing up the reader.

Another use case is testing an s390 .cat file without having to teach
herd about s390 assembly.  ;-)

Thanx, Paul



Re: [PATCH RFC tools/memory-model] Add s390.{cfg,cat}

2018-03-28 Thread Paul E. McKenney
On Wed, Mar 28, 2018 at 02:04:07PM -0400, Alan Stern wrote:
> On Wed, 28 Mar 2018, Paul E. McKenney wrote:
> 
> > On Wed, Mar 28, 2018 at 11:01:25AM -0400, Alan Stern wrote:
> > > On Wed, 28 Mar 2018, Paul E. McKenney wrote:
> > > 
> > > > Hello!
> > > > 
> > > > The prototype patch shown below provides files required to allow herd7 
> > > > to
> > > > evaluate C-language litmus tests for the multicopy-atomic TSO ordering
> > > > provided by s390.  This patch should be viewed with great suspicion.
> > > > It does what I expect it to do on SB (with and without barriers),
> > > > IRIW without barriers, and Alan's SB with read-of-write added, but my
> > > > expectations are quite likely faulty, and my test cases are very few
> > > > in number.
> > > > 
> > > > Either way, this is the easy part.  The hard part (which I am happy
> > > > to leave to others) is making litmus7 and klitmus7 able to do tests
> > > > on actual hardware, as well as enabling herd to handle litmus tests
> > > > containing BAL.  ;-)
> > > > 
> > > > Note that CPU architectures already supported by herd might well need
> > > > only a .cfg file that refers to herd's pre-existing support.
> > > > 
> > > > Thoughts?
> > > 
> > > I don't quite see the point of this.  You're not suggesting that we
> > > have one Linux Kernel Memory Consistency Model for s390 and another
> > > one for all the other architectures, are you?
> > 
> > Certainly not for common code!
> > 
> > > If the idea is merely to provide a herd model for s390 then it should 
> > > go into the DIY repository, not into the LKMM repository.
> > 
> > Makes sense.
> > 
> > In the meantime, does the cat file look to you like it correctly
> > models the combination of TSO and multicopy atomicity?  Do the
> > fences really work, or did I just get lucky with my choice of
> > litmus tests?
> 
> You got lucky.  Try creating an SB litmus test where, instead of an
> smp_mb() fence between the write and the read, each thread executes
> some other kind of fence.

Ah, it does indeed get "Never" in that case, which I do not believe
to e correct.

> The acyclicity condition should have been written more like this:
> 
> let po_ghb = ([R] ; po ; [M]) | ([M] ; po ; [W])
> 
> acyclic mfence | po_ghb | rf | fr | co as tso-mca
> 
> I don't know what the fence instruction is on s390; change the "mfence"
> above accordingly.  The main difference between this and the
> corresponding expression in x86tso.cat is that I replaced rfe with rf.

The s390 fence instruction is "bcr 14,0" or "bcr 15,0", depending on
how recent of hardware you are running.  The latter works everywhere,
if I recall correctly.  But I do not believe that herd knows about either
instruction yet.  Ah, and I need to lose the "empty rmw & (fre;coe)".
That appears to be where my spurious ordering was coming from, strange
though that seems to me.

And your use of "rf" instead of "rfe" makes sense, as that is what makes
the read-from-write provide ordering, correct?  And that should also cover
the "Uniproc check" that would otherwise be required, right?

Except that I get "Sometimes" on CoWR+poonceonce+Once.litmus...
Which I can fix by unioning po-loc into po-ghb.  Or is there some
better way to do this?

> This doesn't account for atomic operations properly; see the "implied" 
> term in x86tso.cat.

I will look at this more later, reaching end of both battery and useful
attention span...

Thanx, Paul



Re: [PATCH RFC tools/memory-model] Add s390.{cfg,cat}

2018-03-28 Thread Paul E. McKenney
On Wed, Mar 28, 2018 at 07:51:36PM +0200, Peter Zijlstra wrote:
> On Wed, Mar 28, 2018 at 11:01:25AM -0400, Alan Stern wrote:
> > I don't quite see the point of this.  You're not suggesting that we
> > have one Linux Kernel Memory Consistency Model for s390 and another
> > one for all the other architectures, are you?
> > 
> > If the idea is merely to provide a herd model for s390 then it should 
> > go into the DIY repository, not into the LKMM repository.
> 
> I suspect the use-case was validating s390 arch code which might not
> have followed all the regular linux rules because they know its TSO. But
> yes, I'm tempted to agree that even arch specific code ought to follow
> the regular rules, just to avoid completely messing up the reader.

Another use case is testing an s390 .cat file without having to teach
herd about s390 assembly.  ;-)

Thanx, Paul



Re: [PATCH][next] wil6210: fix potential null dereference of ndev before null check

2018-03-28 Thread Kalle Valo
me...@codeaurora.org writes:

> On 2018-03-28 20:40, Colin King wrote:
>> From: Colin Ian King 
>>
>> The pointer ndev is being dereferenced before it is being null checked,
>> hence there is a potential null pointer deference. Fix this by only
>> dereferencing ndev after it has been null checked
>>
>> Detected by CoverityScan, CID#1467010 ("Dereference before null check")
>>
>> Fixes: e00243fab84b ("wil6210: infrastructure for multiple virtual
>> interfaces")
>> Signed-off-by: Colin Ian King 

[...]

> Reviewed-by: Maya Erez 

Maya, as you are the wil6210 maintainer you can actually use Acked-by
instead of Reviewed-by. Not that it really matters which one you use,
both of them indicate me that you have checked and agree the patch, but
wanted to point out this anyway :)

-- 
Kalle Valo


Re: [PATCH][next] wil6210: fix potential null dereference of ndev before null check

2018-03-28 Thread Kalle Valo
me...@codeaurora.org writes:

> On 2018-03-28 20:40, Colin King wrote:
>> From: Colin Ian King 
>>
>> The pointer ndev is being dereferenced before it is being null checked,
>> hence there is a potential null pointer deference. Fix this by only
>> dereferencing ndev after it has been null checked
>>
>> Detected by CoverityScan, CID#1467010 ("Dereference before null check")
>>
>> Fixes: e00243fab84b ("wil6210: infrastructure for multiple virtual
>> interfaces")
>> Signed-off-by: Colin Ian King 

[...]

> Reviewed-by: Maya Erez 

Maya, as you are the wil6210 maintainer you can actually use Acked-by
instead of Reviewed-by. Not that it really matters which one you use,
both of them indicate me that you have checked and agree the patch, but
wanted to point out this anyway :)

-- 
Kalle Valo


Re: [PATCH 2/2] usb: dwc3: add clock and resets

2018-03-28 Thread Masahiro Yamada
2018-03-19 7:37 GMT+09:00 Masahiro Yamada :
> Hi Rob,
>
> 2018-03-18 21:52 GMT+09:00 Rob Herring :
>> On Thu, Mar 15, 2018 at 08:39:58PM +0900, Masahiro Yamada wrote:
>>> dwc3-of-simple.c only handles arbitrary number of clocks and resets.
>>> They are both generic enough to be put into the dwc3 core.  For simple
>>> cases, a nested node structure like follows:
>>>
>>>   dwc3-glue {
>>>   compatible = "foo,dwc3";
>>>   clocks = ...;
>>>   resets = ...;
>>>   ...
>>>
>>>   dwc3 {
>>>   compatible = "snps,dwc3";
>>>   ...
>>>   };
>>
>> I'm not a fan of how this was done.
>>
>>
>>>   }
>>>
>>> would be turned into a single node:
>>>
>>>   dwc3 {
>>>   compatible = "foo,dwc3", "snps,dwc3";
>>>   clocks = ...;
>>>   resets = ...;
>>>   ...
>>>   }
>>
>> And yes, this is what I'd prefer.
>
>
>
> Not only dwc3-of-simple.c, but all dwc3 nodes are
> written like this.
>
>
> omap_dwc3_1: omap_dwc3_1@4888 {
> compatible = "ti,dwc3";
> reg = <0x4888 0x1>;
> #address-cells = <1>;
> #size-cells = <1>;
> ranges;
> ...
>
> usb1: usb@4889 {
> compatible = "snps,dwc3";
> reg = <0x4889 0x17000>;
> ...
> };
> };
>
>
> The glue layer initializes SoC-specific things,
> then populates the child "snps,dwc3".
>
>
> I think the following structure should work
> by handling EPROBE_DEFER properly.
>
> omap_dwc3_1: omap_dwc3_1@4888 {
> compatible = "ti,dwc3"; (should be "ti,dwc3-glue" or something)
> reg = <0x4888 0x1>;
> ...
> };
>
> usb1: usb@4889 {
> compatible = "snps,dwc3";
> reg = <0x4889 0x17000>;
> ...
> };
>
>
>
>>>
>>> I inserted reset_control_deassert() and clk_enable() before the first
>>> register access, i.e. dwc3_cache_hwparams().
>>>
>>> Signed-off-by: Masahiro Yamada 
>>> ---
>>>
>>>  Documentation/devicetree/bindings/usb/dwc3.txt |   2 +
>>>  drivers/usb/dwc3/core.c| 127 
>>> -
>>>  drivers/usb/dwc3/core.h|   5 +
>>>  3 files changed, 132 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt 
>>> b/Documentation/devicetree/bindings/usb/dwc3.txt
>>> index 44e8bab..67e9cfb 100644
>>> --- a/Documentation/devicetree/bindings/usb/dwc3.txt
>>> +++ b/Documentation/devicetree/bindings/usb/dwc3.txt
>>> @@ -9,12 +9,14 @@ Required properties:
>>>   - interrupts: Interrupts used by the dwc3 controller.
>>>
>>>  Optional properties:
>>> + - clocks: list of phandle and clock specifier pairs
>>
>> However, this should be specific as to how many clocks and their
>> function. This should be readily available to someone with access to
>> Synopsys datasheet. The number of clocks should generally be the same
>> across SoCs, it is just some SoCs either tie clocks together or don't
>> provide s/w control of some of the clocks.
>
>
> Make sense.
> You also implies this property is mandatory.
> The number of clocks should be available in the datasheet
> and no hardware can work with zero clock.
>
> However, making it mandatory breaks the binding
> since the existing DT files do not specify clocks at all
> in the "snps,dwc3" node.
>
>
>
> Anyway, our current situation:
>
> - We have the dwc3-core under the glue layer node
>   despite they are independent in the CPU address view
> - We add all sorts of clocks and resets in the glue layer node,
>   and nothing in the dwc3-core node.
>
> If these are design mistake, what should we do?
>
> Continue development based on it?
> If we fix it, how to change the course?
>

Any insight about this?


I think this is rather a general question.

If somebody upstreams a driver without clocks,
then later it turns out clocks are necessary,
adding required clocks would break existing platforms
since clk_get() fails.


-- 
Best Regards
Masahiro Yamada


Re: [PATCH 2/2] usb: dwc3: add clock and resets

2018-03-28 Thread Masahiro Yamada
2018-03-19 7:37 GMT+09:00 Masahiro Yamada :
> Hi Rob,
>
> 2018-03-18 21:52 GMT+09:00 Rob Herring :
>> On Thu, Mar 15, 2018 at 08:39:58PM +0900, Masahiro Yamada wrote:
>>> dwc3-of-simple.c only handles arbitrary number of clocks and resets.
>>> They are both generic enough to be put into the dwc3 core.  For simple
>>> cases, a nested node structure like follows:
>>>
>>>   dwc3-glue {
>>>   compatible = "foo,dwc3";
>>>   clocks = ...;
>>>   resets = ...;
>>>   ...
>>>
>>>   dwc3 {
>>>   compatible = "snps,dwc3";
>>>   ...
>>>   };
>>
>> I'm not a fan of how this was done.
>>
>>
>>>   }
>>>
>>> would be turned into a single node:
>>>
>>>   dwc3 {
>>>   compatible = "foo,dwc3", "snps,dwc3";
>>>   clocks = ...;
>>>   resets = ...;
>>>   ...
>>>   }
>>
>> And yes, this is what I'd prefer.
>
>
>
> Not only dwc3-of-simple.c, but all dwc3 nodes are
> written like this.
>
>
> omap_dwc3_1: omap_dwc3_1@4888 {
> compatible = "ti,dwc3";
> reg = <0x4888 0x1>;
> #address-cells = <1>;
> #size-cells = <1>;
> ranges;
> ...
>
> usb1: usb@4889 {
> compatible = "snps,dwc3";
> reg = <0x4889 0x17000>;
> ...
> };
> };
>
>
> The glue layer initializes SoC-specific things,
> then populates the child "snps,dwc3".
>
>
> I think the following structure should work
> by handling EPROBE_DEFER properly.
>
> omap_dwc3_1: omap_dwc3_1@4888 {
> compatible = "ti,dwc3"; (should be "ti,dwc3-glue" or something)
> reg = <0x4888 0x1>;
> ...
> };
>
> usb1: usb@4889 {
> compatible = "snps,dwc3";
> reg = <0x4889 0x17000>;
> ...
> };
>
>
>
>>>
>>> I inserted reset_control_deassert() and clk_enable() before the first
>>> register access, i.e. dwc3_cache_hwparams().
>>>
>>> Signed-off-by: Masahiro Yamada 
>>> ---
>>>
>>>  Documentation/devicetree/bindings/usb/dwc3.txt |   2 +
>>>  drivers/usb/dwc3/core.c| 127 
>>> -
>>>  drivers/usb/dwc3/core.h|   5 +
>>>  3 files changed, 132 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt 
>>> b/Documentation/devicetree/bindings/usb/dwc3.txt
>>> index 44e8bab..67e9cfb 100644
>>> --- a/Documentation/devicetree/bindings/usb/dwc3.txt
>>> +++ b/Documentation/devicetree/bindings/usb/dwc3.txt
>>> @@ -9,12 +9,14 @@ Required properties:
>>>   - interrupts: Interrupts used by the dwc3 controller.
>>>
>>>  Optional properties:
>>> + - clocks: list of phandle and clock specifier pairs
>>
>> However, this should be specific as to how many clocks and their
>> function. This should be readily available to someone with access to
>> Synopsys datasheet. The number of clocks should generally be the same
>> across SoCs, it is just some SoCs either tie clocks together or don't
>> provide s/w control of some of the clocks.
>
>
> Make sense.
> You also implies this property is mandatory.
> The number of clocks should be available in the datasheet
> and no hardware can work with zero clock.
>
> However, making it mandatory breaks the binding
> since the existing DT files do not specify clocks at all
> in the "snps,dwc3" node.
>
>
>
> Anyway, our current situation:
>
> - We have the dwc3-core under the glue layer node
>   despite they are independent in the CPU address view
> - We add all sorts of clocks and resets in the glue layer node,
>   and nothing in the dwc3-core node.
>
> If these are design mistake, what should we do?
>
> Continue development based on it?
> If we fix it, how to change the course?
>

Any insight about this?


I think this is rather a general question.

If somebody upstreams a driver without clocks,
then later it turns out clocks are necessary,
adding required clocks would break existing platforms
since clk_get() fails.


-- 
Best Regards
Masahiro Yamada


[PATCH 0/3] mfd: axp20x: driver cleanup

2018-03-28 Thread Chen-Yu Tsai
Hi Lee,

Here are some cleanup patches for the axp20x mfd driver.

Patch 1 const-ifies all the struct mfd_cell and struct resource
instances found throughout the driver. Not sure why they weren't
set to const before.

Patch 2 replaces all the openly declared interrupt resources with
nice to read one-line DEFINE_RES_IRQ macros.

Patch 3 corrects the prefix for four of the AXP806 interrupt enums.
"POK" was incorrectly expanded to "PWROK".

These are all simple cleanups. No functionality is changed.

Regards
ChenYu

Chen-Yu Tsai (3):
  mfd: axp20x: Const-ify struct mfd_cell and struct resource
  mfd: axp20x: Use DEFINE_RES_IRQ to declare resources for mfd_cells
  mfd: axp20x: Correct AXP806 POK interrupt prefix

 drivers/mfd/axp20x.c   | 239 +++--
 include/linux/mfd/axp20x.h |  10 +-
 2 files changed, 61 insertions(+), 188 deletions(-)

-- 
2.16.3



[PATCH 0/3] mfd: axp20x: driver cleanup

2018-03-28 Thread Chen-Yu Tsai
Hi Lee,

Here are some cleanup patches for the axp20x mfd driver.

Patch 1 const-ifies all the struct mfd_cell and struct resource
instances found throughout the driver. Not sure why they weren't
set to const before.

Patch 2 replaces all the openly declared interrupt resources with
nice to read one-line DEFINE_RES_IRQ macros.

Patch 3 corrects the prefix for four of the AXP806 interrupt enums.
"POK" was incorrectly expanded to "PWROK".

These are all simple cleanups. No functionality is changed.

Regards
ChenYu

Chen-Yu Tsai (3):
  mfd: axp20x: Const-ify struct mfd_cell and struct resource
  mfd: axp20x: Use DEFINE_RES_IRQ to declare resources for mfd_cells
  mfd: axp20x: Correct AXP806 POK interrupt prefix

 drivers/mfd/axp20x.c   | 239 +++--
 include/linux/mfd/axp20x.h |  10 +-
 2 files changed, 61 insertions(+), 188 deletions(-)

-- 
2.16.3



[PATCH 1/3] mfd: axp20x: Const-ify struct mfd_cell and struct resource

2018-03-28 Thread Chen-Yu Tsai
The axp20x driver has lots of mfd_cell and resource structs.
These can all be const-ified.

Signed-off-by: Chen-Yu Tsai 
---
 drivers/mfd/axp20x.c   | 44 ++--
 include/linux/mfd/axp20x.h |  2 +-
 2 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
index aaf2acbef701..14be0f658d74 100644
--- a/drivers/mfd/axp20x.c
+++ b/drivers/mfd/axp20x.c
@@ -169,18 +169,18 @@ static const struct regmap_access_table 
axp806_volatile_table = {
.n_yes_ranges   = ARRAY_SIZE(axp806_volatile_ranges),
 };
 
-static struct resource axp152_pek_resources[] = {
+static const struct resource axp152_pek_resources[] = {
DEFINE_RES_IRQ_NAMED(AXP152_IRQ_PEK_RIS_EDGE, "PEK_DBR"),
DEFINE_RES_IRQ_NAMED(AXP152_IRQ_PEK_FAL_EDGE, "PEK_DBF"),
 };
 
-static struct resource axp20x_ac_power_supply_resources[] = {
+static const struct resource axp20x_ac_power_supply_resources[] = {
DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_ACIN_PLUGIN, "ACIN_PLUGIN"),
DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_ACIN_REMOVAL, "ACIN_REMOVAL"),
DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_ACIN_OVER_V, "ACIN_OVER_V"),
 };
 
-static struct resource axp20x_pek_resources[] = {
+static const struct resource axp20x_pek_resources[] = {
{
.name   = "PEK_DBR",
.start  = AXP20X_IRQ_PEK_RIS_EDGE,
@@ -194,19 +194,19 @@ static struct resource axp20x_pek_resources[] = {
},
 };
 
-static struct resource axp20x_usb_power_supply_resources[] = {
+static const struct resource axp20x_usb_power_supply_resources[] = {
DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_VBUS_PLUGIN, "VBUS_PLUGIN"),
DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_VBUS_REMOVAL, "VBUS_REMOVAL"),
DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_VBUS_VALID, "VBUS_VALID"),
DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_VBUS_NOT_VALID, "VBUS_NOT_VALID"),
 };
 
-static struct resource axp22x_usb_power_supply_resources[] = {
+static const struct resource axp22x_usb_power_supply_resources[] = {
DEFINE_RES_IRQ_NAMED(AXP22X_IRQ_VBUS_PLUGIN, "VBUS_PLUGIN"),
DEFINE_RES_IRQ_NAMED(AXP22X_IRQ_VBUS_REMOVAL, "VBUS_REMOVAL"),
 };
 
-static struct resource axp22x_pek_resources[] = {
+static const struct resource axp22x_pek_resources[] = {
{
.name   = "PEK_DBR",
.start  = AXP22X_IRQ_PEK_RIS_EDGE,
@@ -220,7 +220,7 @@ static struct resource axp22x_pek_resources[] = {
},
 };
 
-static struct resource axp288_power_button_resources[] = {
+static const struct resource axp288_power_button_resources[] = {
{
.name   = "PEK_DBR",
.start  = AXP288_IRQ_POKP,
@@ -235,7 +235,7 @@ static struct resource axp288_power_button_resources[] = {
},
 };
 
-static struct resource axp288_fuel_gauge_resources[] = {
+static const struct resource axp288_fuel_gauge_resources[] = {
{
.start = AXP288_IRQ_QWBTU,
.end   = AXP288_IRQ_QWBTU,
@@ -268,7 +268,7 @@ static struct resource axp288_fuel_gauge_resources[] = {
},
 };
 
-static struct resource axp803_pek_resources[] = {
+static const struct resource axp803_pek_resources[] = {
{
.name   = "PEK_DBR",
.start  = AXP803_IRQ_PEK_RIS_EDGE,
@@ -282,7 +282,7 @@ static struct resource axp803_pek_resources[] = {
},
 };
 
-static struct resource axp809_pek_resources[] = {
+static const struct resource axp809_pek_resources[] = {
{
.name   = "PEK_DBR",
.start  = AXP809_IRQ_PEK_RIS_EDGE,
@@ -648,7 +648,7 @@ static const struct regmap_irq_chip axp809_regmap_irq_chip 
= {
.num_regs   = 5,
 };
 
-static struct mfd_cell axp20x_cells[] = {
+static const struct mfd_cell axp20x_cells[] = {
{
.name   = "axp20x-gpio",
.of_compatible  = "x-powers,axp209-gpio",
@@ -677,7 +677,7 @@ static struct mfd_cell axp20x_cells[] = {
},
 };
 
-static struct mfd_cell axp221_cells[] = {
+static const struct mfd_cell axp221_cells[] = {
{
.name   = "axp221-pek",
.num_resources  = ARRAY_SIZE(axp22x_pek_resources),
@@ -703,7 +703,7 @@ static struct mfd_cell axp221_cells[] = {
},
 };
 
-static struct mfd_cell axp223_cells[] = {
+static const struct mfd_cell axp223_cells[] = {
{
.name   = "axp221-pek",
.num_resources  = ARRAY_SIZE(axp22x_pek_resources),
@@ -729,7 +729,7 @@ static struct mfd_cell axp223_cells[] = {
},
 };
 
-static struct mfd_cell axp152_cells[] = {
+static const struct mfd_cell axp152_cells[] = {
{
.name   = "axp20x-pek",
.num_resources  = ARRAY_SIZE(axp152_pek_resources),
@@ -737,7 +737,7 @@ static struct mfd_cell axp152_cells[] = {
},
 };
 
-static struct resource 

[PATCH 2/3] mfd: axp20x: Use DEFINE_RES_IRQ to declare resources for mfd_cells

2018-03-28 Thread Chen-Yu Tsai
Previously we were open coding the interrupts for the various mfd
cells. This made the code somewhat long due to pretty-formatting.

This patch convert those into one-line declarations with DEFINE_RES_IRQ,
making the code shorter and easier to read.

Signed-off-by: Chen-Yu Tsai 
---
 drivers/mfd/axp20x.c | 187 +--
 1 file changed, 30 insertions(+), 157 deletions(-)

diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
index 14be0f658d74..b3051e1c3ddc 100644
--- a/drivers/mfd/axp20x.c
+++ b/drivers/mfd/axp20x.c
@@ -181,17 +181,8 @@ static const struct resource 
axp20x_ac_power_supply_resources[] = {
 };
 
 static const struct resource axp20x_pek_resources[] = {
-   {
-   .name   = "PEK_DBR",
-   .start  = AXP20X_IRQ_PEK_RIS_EDGE,
-   .end= AXP20X_IRQ_PEK_RIS_EDGE,
-   .flags  = IORESOURCE_IRQ,
-   }, {
-   .name   = "PEK_DBF",
-   .start  = AXP20X_IRQ_PEK_FAL_EDGE,
-   .end= AXP20X_IRQ_PEK_FAL_EDGE,
-   .flags  = IORESOURCE_IRQ,
-   },
+   DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_PEK_RIS_EDGE, "PEK_DBR"),
+   DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_PEK_FAL_EDGE, "PEK_DBF"),
 };
 
 static const struct resource axp20x_usb_power_supply_resources[] = {
@@ -207,93 +198,32 @@ static const struct resource 
axp22x_usb_power_supply_resources[] = {
 };
 
 static const struct resource axp22x_pek_resources[] = {
-   {
-   .name   = "PEK_DBR",
-   .start  = AXP22X_IRQ_PEK_RIS_EDGE,
-   .end= AXP22X_IRQ_PEK_RIS_EDGE,
-   .flags  = IORESOURCE_IRQ,
-   }, {
-   .name   = "PEK_DBF",
-   .start  = AXP22X_IRQ_PEK_FAL_EDGE,
-   .end= AXP22X_IRQ_PEK_FAL_EDGE,
-   .flags  = IORESOURCE_IRQ,
-   },
+   DEFINE_RES_IRQ_NAMED(AXP22X_IRQ_PEK_RIS_EDGE, "PEK_DBR"),
+   DEFINE_RES_IRQ_NAMED(AXP22X_IRQ_PEK_FAL_EDGE, "PEK_DBF"),
 };
 
 static const struct resource axp288_power_button_resources[] = {
-   {
-   .name   = "PEK_DBR",
-   .start  = AXP288_IRQ_POKP,
-   .end= AXP288_IRQ_POKP,
-   .flags  = IORESOURCE_IRQ,
-   },
-   {
-   .name   = "PEK_DBF",
-   .start  = AXP288_IRQ_POKN,
-   .end= AXP288_IRQ_POKN,
-   .flags  = IORESOURCE_IRQ,
-   },
+   DEFINE_RES_IRQ_NAMED(AXP288_IRQ_POKP, "PEK_DBR"),
+   DEFINE_RES_IRQ_NAMED(AXP288_IRQ_POKN, "PEK_DBF"),
 };
 
 static const struct resource axp288_fuel_gauge_resources[] = {
-   {
-   .start = AXP288_IRQ_QWBTU,
-   .end   = AXP288_IRQ_QWBTU,
-   .flags = IORESOURCE_IRQ,
-   },
-   {
-   .start = AXP288_IRQ_WBTU,
-   .end   = AXP288_IRQ_WBTU,
-   .flags = IORESOURCE_IRQ,
-   },
-   {
-   .start = AXP288_IRQ_QWBTO,
-   .end   = AXP288_IRQ_QWBTO,
-   .flags = IORESOURCE_IRQ,
-   },
-   {
-   .start = AXP288_IRQ_WBTO,
-   .end   = AXP288_IRQ_WBTO,
-   .flags = IORESOURCE_IRQ,
-   },
-   {
-   .start = AXP288_IRQ_WL2,
-   .end   = AXP288_IRQ_WL2,
-   .flags = IORESOURCE_IRQ,
-   },
-   {
-   .start = AXP288_IRQ_WL1,
-   .end   = AXP288_IRQ_WL1,
-   .flags = IORESOURCE_IRQ,
-   },
+   DEFINE_RES_IRQ(AXP288_IRQ_QWBTU),
+   DEFINE_RES_IRQ(AXP288_IRQ_WBTU),
+   DEFINE_RES_IRQ(AXP288_IRQ_QWBTO),
+   DEFINE_RES_IRQ(AXP288_IRQ_WBTO),
+   DEFINE_RES_IRQ(AXP288_IRQ_WL2),
+   DEFINE_RES_IRQ(AXP288_IRQ_WL1),
 };
 
 static const struct resource axp803_pek_resources[] = {
-   {
-   .name   = "PEK_DBR",
-   .start  = AXP803_IRQ_PEK_RIS_EDGE,
-   .end= AXP803_IRQ_PEK_RIS_EDGE,
-   .flags  = IORESOURCE_IRQ,
-   }, {
-   .name   = "PEK_DBF",
-   .start  = AXP803_IRQ_PEK_FAL_EDGE,
-   .end= AXP803_IRQ_PEK_FAL_EDGE,
-   .flags  = IORESOURCE_IRQ,
-   },
+   DEFINE_RES_IRQ_NAMED(AXP803_IRQ_PEK_RIS_EDGE, "PEK_DBR"),
+   DEFINE_RES_IRQ_NAMED(AXP803_IRQ_PEK_FAL_EDGE, "PEK_DBF"),
 };
 
 static const struct resource axp809_pek_resources[] = {
-   {
-   .name   = "PEK_DBR",
-   .start  = AXP809_IRQ_PEK_RIS_EDGE,
-   .end= AXP809_IRQ_PEK_RIS_EDGE,
-   .flags  = IORESOURCE_IRQ,
-   }, {
-   .name   = "PEK_DBF",
-   .start  = AXP809_IRQ_PEK_FAL_EDGE,
-   .end= AXP809_IRQ_PEK_FAL_EDGE,
-   .flags  = IORESOURCE_IRQ,
-   },
+   DEFINE_RES_IRQ_NAMED(AXP809_IRQ_PEK_RIS_EDGE, "PEK_DBR"),
+   DEFINE_RES_IRQ_NAMED(AXP809_IRQ_PEK_FAL_EDGE, "PEK_DBF"),
 };
 
 static const struct regmap_config 

[PATCH 1/3] mfd: axp20x: Const-ify struct mfd_cell and struct resource

2018-03-28 Thread Chen-Yu Tsai
The axp20x driver has lots of mfd_cell and resource structs.
These can all be const-ified.

Signed-off-by: Chen-Yu Tsai 
---
 drivers/mfd/axp20x.c   | 44 ++--
 include/linux/mfd/axp20x.h |  2 +-
 2 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
index aaf2acbef701..14be0f658d74 100644
--- a/drivers/mfd/axp20x.c
+++ b/drivers/mfd/axp20x.c
@@ -169,18 +169,18 @@ static const struct regmap_access_table 
axp806_volatile_table = {
.n_yes_ranges   = ARRAY_SIZE(axp806_volatile_ranges),
 };
 
-static struct resource axp152_pek_resources[] = {
+static const struct resource axp152_pek_resources[] = {
DEFINE_RES_IRQ_NAMED(AXP152_IRQ_PEK_RIS_EDGE, "PEK_DBR"),
DEFINE_RES_IRQ_NAMED(AXP152_IRQ_PEK_FAL_EDGE, "PEK_DBF"),
 };
 
-static struct resource axp20x_ac_power_supply_resources[] = {
+static const struct resource axp20x_ac_power_supply_resources[] = {
DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_ACIN_PLUGIN, "ACIN_PLUGIN"),
DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_ACIN_REMOVAL, "ACIN_REMOVAL"),
DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_ACIN_OVER_V, "ACIN_OVER_V"),
 };
 
-static struct resource axp20x_pek_resources[] = {
+static const struct resource axp20x_pek_resources[] = {
{
.name   = "PEK_DBR",
.start  = AXP20X_IRQ_PEK_RIS_EDGE,
@@ -194,19 +194,19 @@ static struct resource axp20x_pek_resources[] = {
},
 };
 
-static struct resource axp20x_usb_power_supply_resources[] = {
+static const struct resource axp20x_usb_power_supply_resources[] = {
DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_VBUS_PLUGIN, "VBUS_PLUGIN"),
DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_VBUS_REMOVAL, "VBUS_REMOVAL"),
DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_VBUS_VALID, "VBUS_VALID"),
DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_VBUS_NOT_VALID, "VBUS_NOT_VALID"),
 };
 
-static struct resource axp22x_usb_power_supply_resources[] = {
+static const struct resource axp22x_usb_power_supply_resources[] = {
DEFINE_RES_IRQ_NAMED(AXP22X_IRQ_VBUS_PLUGIN, "VBUS_PLUGIN"),
DEFINE_RES_IRQ_NAMED(AXP22X_IRQ_VBUS_REMOVAL, "VBUS_REMOVAL"),
 };
 
-static struct resource axp22x_pek_resources[] = {
+static const struct resource axp22x_pek_resources[] = {
{
.name   = "PEK_DBR",
.start  = AXP22X_IRQ_PEK_RIS_EDGE,
@@ -220,7 +220,7 @@ static struct resource axp22x_pek_resources[] = {
},
 };
 
-static struct resource axp288_power_button_resources[] = {
+static const struct resource axp288_power_button_resources[] = {
{
.name   = "PEK_DBR",
.start  = AXP288_IRQ_POKP,
@@ -235,7 +235,7 @@ static struct resource axp288_power_button_resources[] = {
},
 };
 
-static struct resource axp288_fuel_gauge_resources[] = {
+static const struct resource axp288_fuel_gauge_resources[] = {
{
.start = AXP288_IRQ_QWBTU,
.end   = AXP288_IRQ_QWBTU,
@@ -268,7 +268,7 @@ static struct resource axp288_fuel_gauge_resources[] = {
},
 };
 
-static struct resource axp803_pek_resources[] = {
+static const struct resource axp803_pek_resources[] = {
{
.name   = "PEK_DBR",
.start  = AXP803_IRQ_PEK_RIS_EDGE,
@@ -282,7 +282,7 @@ static struct resource axp803_pek_resources[] = {
},
 };
 
-static struct resource axp809_pek_resources[] = {
+static const struct resource axp809_pek_resources[] = {
{
.name   = "PEK_DBR",
.start  = AXP809_IRQ_PEK_RIS_EDGE,
@@ -648,7 +648,7 @@ static const struct regmap_irq_chip axp809_regmap_irq_chip 
= {
.num_regs   = 5,
 };
 
-static struct mfd_cell axp20x_cells[] = {
+static const struct mfd_cell axp20x_cells[] = {
{
.name   = "axp20x-gpio",
.of_compatible  = "x-powers,axp209-gpio",
@@ -677,7 +677,7 @@ static struct mfd_cell axp20x_cells[] = {
},
 };
 
-static struct mfd_cell axp221_cells[] = {
+static const struct mfd_cell axp221_cells[] = {
{
.name   = "axp221-pek",
.num_resources  = ARRAY_SIZE(axp22x_pek_resources),
@@ -703,7 +703,7 @@ static struct mfd_cell axp221_cells[] = {
},
 };
 
-static struct mfd_cell axp223_cells[] = {
+static const struct mfd_cell axp223_cells[] = {
{
.name   = "axp221-pek",
.num_resources  = ARRAY_SIZE(axp22x_pek_resources),
@@ -729,7 +729,7 @@ static struct mfd_cell axp223_cells[] = {
},
 };
 
-static struct mfd_cell axp152_cells[] = {
+static const struct mfd_cell axp152_cells[] = {
{
.name   = "axp20x-pek",
.num_resources  = ARRAY_SIZE(axp152_pek_resources),
@@ -737,7 +737,7 @@ static struct mfd_cell axp152_cells[] = {
},
 };
 
-static struct resource axp288_adc_resources[] = {

[PATCH 2/3] mfd: axp20x: Use DEFINE_RES_IRQ to declare resources for mfd_cells

2018-03-28 Thread Chen-Yu Tsai
Previously we were open coding the interrupts for the various mfd
cells. This made the code somewhat long due to pretty-formatting.

This patch convert those into one-line declarations with DEFINE_RES_IRQ,
making the code shorter and easier to read.

Signed-off-by: Chen-Yu Tsai 
---
 drivers/mfd/axp20x.c | 187 +--
 1 file changed, 30 insertions(+), 157 deletions(-)

diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
index 14be0f658d74..b3051e1c3ddc 100644
--- a/drivers/mfd/axp20x.c
+++ b/drivers/mfd/axp20x.c
@@ -181,17 +181,8 @@ static const struct resource 
axp20x_ac_power_supply_resources[] = {
 };
 
 static const struct resource axp20x_pek_resources[] = {
-   {
-   .name   = "PEK_DBR",
-   .start  = AXP20X_IRQ_PEK_RIS_EDGE,
-   .end= AXP20X_IRQ_PEK_RIS_EDGE,
-   .flags  = IORESOURCE_IRQ,
-   }, {
-   .name   = "PEK_DBF",
-   .start  = AXP20X_IRQ_PEK_FAL_EDGE,
-   .end= AXP20X_IRQ_PEK_FAL_EDGE,
-   .flags  = IORESOURCE_IRQ,
-   },
+   DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_PEK_RIS_EDGE, "PEK_DBR"),
+   DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_PEK_FAL_EDGE, "PEK_DBF"),
 };
 
 static const struct resource axp20x_usb_power_supply_resources[] = {
@@ -207,93 +198,32 @@ static const struct resource 
axp22x_usb_power_supply_resources[] = {
 };
 
 static const struct resource axp22x_pek_resources[] = {
-   {
-   .name   = "PEK_DBR",
-   .start  = AXP22X_IRQ_PEK_RIS_EDGE,
-   .end= AXP22X_IRQ_PEK_RIS_EDGE,
-   .flags  = IORESOURCE_IRQ,
-   }, {
-   .name   = "PEK_DBF",
-   .start  = AXP22X_IRQ_PEK_FAL_EDGE,
-   .end= AXP22X_IRQ_PEK_FAL_EDGE,
-   .flags  = IORESOURCE_IRQ,
-   },
+   DEFINE_RES_IRQ_NAMED(AXP22X_IRQ_PEK_RIS_EDGE, "PEK_DBR"),
+   DEFINE_RES_IRQ_NAMED(AXP22X_IRQ_PEK_FAL_EDGE, "PEK_DBF"),
 };
 
 static const struct resource axp288_power_button_resources[] = {
-   {
-   .name   = "PEK_DBR",
-   .start  = AXP288_IRQ_POKP,
-   .end= AXP288_IRQ_POKP,
-   .flags  = IORESOURCE_IRQ,
-   },
-   {
-   .name   = "PEK_DBF",
-   .start  = AXP288_IRQ_POKN,
-   .end= AXP288_IRQ_POKN,
-   .flags  = IORESOURCE_IRQ,
-   },
+   DEFINE_RES_IRQ_NAMED(AXP288_IRQ_POKP, "PEK_DBR"),
+   DEFINE_RES_IRQ_NAMED(AXP288_IRQ_POKN, "PEK_DBF"),
 };
 
 static const struct resource axp288_fuel_gauge_resources[] = {
-   {
-   .start = AXP288_IRQ_QWBTU,
-   .end   = AXP288_IRQ_QWBTU,
-   .flags = IORESOURCE_IRQ,
-   },
-   {
-   .start = AXP288_IRQ_WBTU,
-   .end   = AXP288_IRQ_WBTU,
-   .flags = IORESOURCE_IRQ,
-   },
-   {
-   .start = AXP288_IRQ_QWBTO,
-   .end   = AXP288_IRQ_QWBTO,
-   .flags = IORESOURCE_IRQ,
-   },
-   {
-   .start = AXP288_IRQ_WBTO,
-   .end   = AXP288_IRQ_WBTO,
-   .flags = IORESOURCE_IRQ,
-   },
-   {
-   .start = AXP288_IRQ_WL2,
-   .end   = AXP288_IRQ_WL2,
-   .flags = IORESOURCE_IRQ,
-   },
-   {
-   .start = AXP288_IRQ_WL1,
-   .end   = AXP288_IRQ_WL1,
-   .flags = IORESOURCE_IRQ,
-   },
+   DEFINE_RES_IRQ(AXP288_IRQ_QWBTU),
+   DEFINE_RES_IRQ(AXP288_IRQ_WBTU),
+   DEFINE_RES_IRQ(AXP288_IRQ_QWBTO),
+   DEFINE_RES_IRQ(AXP288_IRQ_WBTO),
+   DEFINE_RES_IRQ(AXP288_IRQ_WL2),
+   DEFINE_RES_IRQ(AXP288_IRQ_WL1),
 };
 
 static const struct resource axp803_pek_resources[] = {
-   {
-   .name   = "PEK_DBR",
-   .start  = AXP803_IRQ_PEK_RIS_EDGE,
-   .end= AXP803_IRQ_PEK_RIS_EDGE,
-   .flags  = IORESOURCE_IRQ,
-   }, {
-   .name   = "PEK_DBF",
-   .start  = AXP803_IRQ_PEK_FAL_EDGE,
-   .end= AXP803_IRQ_PEK_FAL_EDGE,
-   .flags  = IORESOURCE_IRQ,
-   },
+   DEFINE_RES_IRQ_NAMED(AXP803_IRQ_PEK_RIS_EDGE, "PEK_DBR"),
+   DEFINE_RES_IRQ_NAMED(AXP803_IRQ_PEK_FAL_EDGE, "PEK_DBF"),
 };
 
 static const struct resource axp809_pek_resources[] = {
-   {
-   .name   = "PEK_DBR",
-   .start  = AXP809_IRQ_PEK_RIS_EDGE,
-   .end= AXP809_IRQ_PEK_RIS_EDGE,
-   .flags  = IORESOURCE_IRQ,
-   }, {
-   .name   = "PEK_DBF",
-   .start  = AXP809_IRQ_PEK_FAL_EDGE,
-   .end= AXP809_IRQ_PEK_FAL_EDGE,
-   .flags  = IORESOURCE_IRQ,
-   },
+   DEFINE_RES_IRQ_NAMED(AXP809_IRQ_PEK_RIS_EDGE, "PEK_DBR"),
+   DEFINE_RES_IRQ_NAMED(AXP809_IRQ_PEK_FAL_EDGE, "PEK_DBF"),
 };
 
 static const struct regmap_config 

[PATCH 3/3] mfd: axp20x: Correct AXP806 POK interrupt prefix

2018-03-28 Thread Chen-Yu Tsai
When AXP806 support was added, POK was incorrectly expanded to PWROK.
However, the datasheet lists them as POK[LSNP], which is the same as
on the AXP288. Furthermore, the registers associated with POK functions
are the same as the PEK on the other AXP PMICs. This suggests that
"POK" means "Power On Key", much like "PEK" means "Power Enable Key",
instead of "Power OK".

This patch changes the "PWROK" prefix to "POK" for these interrupts.

Signed-off-by: Chen-Yu Tsai 
---
 drivers/mfd/axp20x.c   | 8 
 include/linux/mfd/axp20x.h | 8 
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
index b3051e1c3ddc..9a2ef3d9b8f8 100644
--- a/drivers/mfd/axp20x.c
+++ b/drivers/mfd/axp20x.c
@@ -450,11 +450,11 @@ static const struct regmap_irq axp806_regmap_irqs[] = {
INIT_REGMAP_IRQ(AXP806, DCDCC_V_LOW,0, 5),
INIT_REGMAP_IRQ(AXP806, DCDCD_V_LOW,0, 6),
INIT_REGMAP_IRQ(AXP806, DCDCE_V_LOW,0, 7),
-   INIT_REGMAP_IRQ(AXP806, PWROK_LONG, 1, 0),
-   INIT_REGMAP_IRQ(AXP806, PWROK_SHORT,1, 1),
+   INIT_REGMAP_IRQ(AXP806, POK_LONG,   1, 0),
+   INIT_REGMAP_IRQ(AXP806, POK_SHORT,  1, 1),
INIT_REGMAP_IRQ(AXP806, WAKEUP, 1, 4),
-   INIT_REGMAP_IRQ(AXP806, PWROK_FALL, 1, 5),
-   INIT_REGMAP_IRQ(AXP806, PWROK_RISE, 1, 6),
+   INIT_REGMAP_IRQ(AXP806, POK_FALL,   1, 5),
+   INIT_REGMAP_IRQ(AXP806, POK_RISE,   1, 6),
 };
 
 static const struct regmap_irq axp809_regmap_irqs[] = {
diff --git a/include/linux/mfd/axp20x.h b/include/linux/mfd/axp20x.h
index a2489363a998..517e60eecbcb 100644
--- a/include/linux/mfd/axp20x.h
+++ b/include/linux/mfd/axp20x.h
@@ -592,11 +592,11 @@ enum axp806_irqs {
AXP806_IRQ_DCDCC_V_LOW,
AXP806_IRQ_DCDCD_V_LOW,
AXP806_IRQ_DCDCE_V_LOW,
-   AXP806_IRQ_PWROK_LONG,
-   AXP806_IRQ_PWROK_SHORT,
+   AXP806_IRQ_POK_LONG,
+   AXP806_IRQ_POK_SHORT,
AXP806_IRQ_WAKEUP,
-   AXP806_IRQ_PWROK_FALL,
-   AXP806_IRQ_PWROK_RISE,
+   AXP806_IRQ_POK_FALL,
+   AXP806_IRQ_POK_RISE,
 };
 
 enum axp809_irqs {
-- 
2.16.3



[PATCH 3/3] mfd: axp20x: Correct AXP806 POK interrupt prefix

2018-03-28 Thread Chen-Yu Tsai
When AXP806 support was added, POK was incorrectly expanded to PWROK.
However, the datasheet lists them as POK[LSNP], which is the same as
on the AXP288. Furthermore, the registers associated with POK functions
are the same as the PEK on the other AXP PMICs. This suggests that
"POK" means "Power On Key", much like "PEK" means "Power Enable Key",
instead of "Power OK".

This patch changes the "PWROK" prefix to "POK" for these interrupts.

Signed-off-by: Chen-Yu Tsai 
---
 drivers/mfd/axp20x.c   | 8 
 include/linux/mfd/axp20x.h | 8 
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
index b3051e1c3ddc..9a2ef3d9b8f8 100644
--- a/drivers/mfd/axp20x.c
+++ b/drivers/mfd/axp20x.c
@@ -450,11 +450,11 @@ static const struct regmap_irq axp806_regmap_irqs[] = {
INIT_REGMAP_IRQ(AXP806, DCDCC_V_LOW,0, 5),
INIT_REGMAP_IRQ(AXP806, DCDCD_V_LOW,0, 6),
INIT_REGMAP_IRQ(AXP806, DCDCE_V_LOW,0, 7),
-   INIT_REGMAP_IRQ(AXP806, PWROK_LONG, 1, 0),
-   INIT_REGMAP_IRQ(AXP806, PWROK_SHORT,1, 1),
+   INIT_REGMAP_IRQ(AXP806, POK_LONG,   1, 0),
+   INIT_REGMAP_IRQ(AXP806, POK_SHORT,  1, 1),
INIT_REGMAP_IRQ(AXP806, WAKEUP, 1, 4),
-   INIT_REGMAP_IRQ(AXP806, PWROK_FALL, 1, 5),
-   INIT_REGMAP_IRQ(AXP806, PWROK_RISE, 1, 6),
+   INIT_REGMAP_IRQ(AXP806, POK_FALL,   1, 5),
+   INIT_REGMAP_IRQ(AXP806, POK_RISE,   1, 6),
 };
 
 static const struct regmap_irq axp809_regmap_irqs[] = {
diff --git a/include/linux/mfd/axp20x.h b/include/linux/mfd/axp20x.h
index a2489363a998..517e60eecbcb 100644
--- a/include/linux/mfd/axp20x.h
+++ b/include/linux/mfd/axp20x.h
@@ -592,11 +592,11 @@ enum axp806_irqs {
AXP806_IRQ_DCDCC_V_LOW,
AXP806_IRQ_DCDCD_V_LOW,
AXP806_IRQ_DCDCE_V_LOW,
-   AXP806_IRQ_PWROK_LONG,
-   AXP806_IRQ_PWROK_SHORT,
+   AXP806_IRQ_POK_LONG,
+   AXP806_IRQ_POK_SHORT,
AXP806_IRQ_WAKEUP,
-   AXP806_IRQ_PWROK_FALL,
-   AXP806_IRQ_PWROK_RISE,
+   AXP806_IRQ_POK_FALL,
+   AXP806_IRQ_POK_RISE,
 };
 
 enum axp809_irqs {
-- 
2.16.3



[PATCH 17/17] staging: lustre: remove cruft from libcfs/linux/libcfs.h

2018-03-28 Thread NeilBrown
These defines are unused or nearly unused, and do not
help at all.

Signed-off-by: NeilBrown 
---
 .../staging/lustre/include/linux/libcfs/curproc.h  |2 --
 .../lustre/include/linux/libcfs/linux/libcfs.h |   17 -
 drivers/staging/lustre/lnet/libcfs/tracefile.c |2 +-
 3 files changed, 1 insertion(+), 20 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/curproc.h 
b/drivers/staging/lustre/include/linux/libcfs/curproc.h
index 4702956805a6..d6e4f47b5daf 100644
--- a/drivers/staging/lustre/include/linux/libcfs/curproc.h
+++ b/drivers/staging/lustre/include/linux/libcfs/curproc.h
@@ -43,8 +43,6 @@
 /*
  * Plus, platform-specific constant
  *
- * CFS_CURPROC_COMM_MAX,
- *
  * and opaque scalar type
  *
  * kernel_cap_t
diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h 
b/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
index c39c34d74382..0dbd01617865 100644
--- a/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
@@ -81,8 +81,6 @@
 #include 
 #include "linux-cpu.h"
 
-#define LUSTRE_TRACE_SIZE (THREAD_SIZE >> 5)
-
 #if !defined(__x86_64__)
 # ifdef __ia64__
 #  define CDEBUG_STACK() (THREAD_SIZE - \
@@ -114,19 +112,4 @@ do {   
\
 #define CDEBUG_STACK() (0L)
 #endif /* __x86_64__ */
 
-#define __current_nesting_level() (0)
-
-/**
- * Platform specific declarations for cfs_curproc API (libcfs/curproc.h)
- *
- * Implementation is in linux-curproc.c
- */
-#define CFS_CURPROC_COMM_MAX (sizeof((struct task_struct *)0)->comm)
-
-#include 
-
-#ifndef WITH_WATCHDOG
-#define WITH_WATCHDOG
-#endif
-
 #endif /* _LINUX_LIBCFS_H */
diff --git a/drivers/staging/lustre/lnet/libcfs/tracefile.c 
b/drivers/staging/lustre/lnet/libcfs/tracefile.c
index 129430e74d00..514e1845740e 100644
--- a/drivers/staging/lustre/lnet/libcfs/tracefile.c
+++ b/drivers/staging/lustre/lnet/libcfs/tracefile.c
@@ -328,7 +328,7 @@ int libcfs_debug_vmsg2(struct libcfs_debug_msg_data 
*msgdata,
goto console;
}
 
-   depth = __current_nesting_level();
+   depth = 0;
known_size = strlen(file) + 1 + depth;
if (msgdata->msg_fn)
known_size += strlen(msgdata->msg_fn) + 1;




[PATCH 14/17] staging: lustre: discard cfs_duration_sec()

2018-03-28 Thread NeilBrown
cfs_duration_sec() simply divides by HZ.
It is mostly used to report durations in debug messages.
Remove and just use X/HZ.

Signed-off-by: NeilBrown 
---
 .../lustre/include/linux/libcfs/linux/linux-time.h |5 -
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c|2 +-
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c |5 ++---
 .../staging/lustre/lnet/klnds/socklnd/socklnd.c|4 ++--
 .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c |4 ++--
 drivers/staging/lustre/lnet/libcfs/debug.c |2 +-
 drivers/staging/lustre/lnet/lnet/router.c  |2 +-
 drivers/staging/lustre/lnet/lnet/router_proc.c |6 +++---
 drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |2 +-
 9 files changed, 13 insertions(+), 19 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h 
b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
index ecb2126a9e6f..9a353c6cb85a 100644
--- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
+++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
@@ -60,11 +60,6 @@
  * Generic kernel stuff
  */
 
-static inline long cfs_duration_sec(long d)
-{
-   return d / msecs_to_jiffies(MSEC_PER_SEC);
-}
-
 static inline int cfs_time_before_64(u64 t1, u64 t2)
 {
return (__s64)t2 - (__s64)t1 > 0;
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c 
b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
index d0ce37d72571..959e119384df 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
@@ -1068,7 +1068,7 @@ static void kiblnd_query(struct lnet_ni *ni, lnet_nid_t 
nid,
 
CDEBUG(D_NET, "Peer %s %p, alive %ld secs ago\n",
   libcfs_nid2str(nid), peer,
-  last_alive ? cfs_duration_sec(now - last_alive) : -1);
+  last_alive ? (now - last_alive) / HZ : -1);
 }
 
 static void kiblnd_free_pages(struct kib_pages *p)
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c 
b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
index 563ff5c972bf..b4a182d87ae7 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
@@ -3144,7 +3144,7 @@ kiblnd_check_txs_locked(struct kib_conn *conn, struct 
list_head *txs)
if (time_after_eq(jiffies, tx->tx_deadline)) {
CERROR("Timed out tx: %s, %lu seconds\n",
   kiblnd_queue2str(conn, txs),
-  cfs_duration_sec(jiffies - tx->tx_deadline));
+  (jiffies - tx->tx_deadline) / HZ);
return 1;
}
}
@@ -3206,8 +3206,7 @@ kiblnd_check_conns(int idx)
if (timedout) {
CERROR("Timed out RDMA with %s (%lu): c: %u, 
oc: %u, rc: %u\n",
   libcfs_nid2str(peer->ibp_nid),
-  cfs_duration_sec(jiffies -
-   peer->ibp_last_alive),
+  (jiffies - peer->ibp_last_alive) / HZ,
   conn->ibc_credits,
   conn->ibc_outstanding_credits,
   conn->ibc_reserved_credits);
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c 
b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
index 16c1ab0b0bd9..79b98cdd0f9d 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
@@ -1682,7 +1682,7 @@ ksocknal_destroy_conn(struct ksock_conn *conn)
   libcfs_id2str(conn->ksnc_peer->ksnp_id), conn->ksnc_type,
   >ksnc_ipaddr, conn->ksnc_port,
   iov_iter_count(>ksnc_rx_to), 
conn->ksnc_rx_nob_left,
-  cfs_duration_sec(jiffies - last_rcv));
+  (jiffies - last_rcv) / HZ);
lnet_finalize(conn->ksnc_peer->ksnp_ni,
  conn->ksnc_cookie, -EIO);
break;
@@ -1870,7 +1870,7 @@ ksocknal_query(struct lnet_ni *ni, lnet_nid_t nid, 
unsigned long *when)
 
CDEBUG(D_NET, "Peer %s %p, alive %ld secs ago, connect %d\n",
   libcfs_nid2str(nid), peer,
-  last_alive ? cfs_duration_sec(now - last_alive) : -1,
+  last_alive ? (now - last_alive) / HZ : -1,
   connect);
 
if (!connect)
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c 
b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
index 8ead1e02e854..14450fd5957a 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
@@ -751,7 +751,7 @@ 

[PATCH 17/17] staging: lustre: remove cruft from libcfs/linux/libcfs.h

2018-03-28 Thread NeilBrown
These defines are unused or nearly unused, and do not
help at all.

Signed-off-by: NeilBrown 
---
 .../staging/lustre/include/linux/libcfs/curproc.h  |2 --
 .../lustre/include/linux/libcfs/linux/libcfs.h |   17 -
 drivers/staging/lustre/lnet/libcfs/tracefile.c |2 +-
 3 files changed, 1 insertion(+), 20 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/curproc.h 
b/drivers/staging/lustre/include/linux/libcfs/curproc.h
index 4702956805a6..d6e4f47b5daf 100644
--- a/drivers/staging/lustre/include/linux/libcfs/curproc.h
+++ b/drivers/staging/lustre/include/linux/libcfs/curproc.h
@@ -43,8 +43,6 @@
 /*
  * Plus, platform-specific constant
  *
- * CFS_CURPROC_COMM_MAX,
- *
  * and opaque scalar type
  *
  * kernel_cap_t
diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h 
b/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
index c39c34d74382..0dbd01617865 100644
--- a/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
@@ -81,8 +81,6 @@
 #include 
 #include "linux-cpu.h"
 
-#define LUSTRE_TRACE_SIZE (THREAD_SIZE >> 5)
-
 #if !defined(__x86_64__)
 # ifdef __ia64__
 #  define CDEBUG_STACK() (THREAD_SIZE - \
@@ -114,19 +112,4 @@ do {   
\
 #define CDEBUG_STACK() (0L)
 #endif /* __x86_64__ */
 
-#define __current_nesting_level() (0)
-
-/**
- * Platform specific declarations for cfs_curproc API (libcfs/curproc.h)
- *
- * Implementation is in linux-curproc.c
- */
-#define CFS_CURPROC_COMM_MAX (sizeof((struct task_struct *)0)->comm)
-
-#include 
-
-#ifndef WITH_WATCHDOG
-#define WITH_WATCHDOG
-#endif
-
 #endif /* _LINUX_LIBCFS_H */
diff --git a/drivers/staging/lustre/lnet/libcfs/tracefile.c 
b/drivers/staging/lustre/lnet/libcfs/tracefile.c
index 129430e74d00..514e1845740e 100644
--- a/drivers/staging/lustre/lnet/libcfs/tracefile.c
+++ b/drivers/staging/lustre/lnet/libcfs/tracefile.c
@@ -328,7 +328,7 @@ int libcfs_debug_vmsg2(struct libcfs_debug_msg_data 
*msgdata,
goto console;
}
 
-   depth = __current_nesting_level();
+   depth = 0;
known_size = strlen(file) + 1 + depth;
if (msgdata->msg_fn)
known_size += strlen(msgdata->msg_fn) + 1;




[PATCH 14/17] staging: lustre: discard cfs_duration_sec()

2018-03-28 Thread NeilBrown
cfs_duration_sec() simply divides by HZ.
It is mostly used to report durations in debug messages.
Remove and just use X/HZ.

Signed-off-by: NeilBrown 
---
 .../lustre/include/linux/libcfs/linux/linux-time.h |5 -
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c|2 +-
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c |5 ++---
 .../staging/lustre/lnet/klnds/socklnd/socklnd.c|4 ++--
 .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c |4 ++--
 drivers/staging/lustre/lnet/libcfs/debug.c |2 +-
 drivers/staging/lustre/lnet/lnet/router.c  |2 +-
 drivers/staging/lustre/lnet/lnet/router_proc.c |6 +++---
 drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |2 +-
 9 files changed, 13 insertions(+), 19 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h 
b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
index ecb2126a9e6f..9a353c6cb85a 100644
--- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
+++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
@@ -60,11 +60,6 @@
  * Generic kernel stuff
  */
 
-static inline long cfs_duration_sec(long d)
-{
-   return d / msecs_to_jiffies(MSEC_PER_SEC);
-}
-
 static inline int cfs_time_before_64(u64 t1, u64 t2)
 {
return (__s64)t2 - (__s64)t1 > 0;
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c 
b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
index d0ce37d72571..959e119384df 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
@@ -1068,7 +1068,7 @@ static void kiblnd_query(struct lnet_ni *ni, lnet_nid_t 
nid,
 
CDEBUG(D_NET, "Peer %s %p, alive %ld secs ago\n",
   libcfs_nid2str(nid), peer,
-  last_alive ? cfs_duration_sec(now - last_alive) : -1);
+  last_alive ? (now - last_alive) / HZ : -1);
 }
 
 static void kiblnd_free_pages(struct kib_pages *p)
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c 
b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
index 563ff5c972bf..b4a182d87ae7 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
@@ -3144,7 +3144,7 @@ kiblnd_check_txs_locked(struct kib_conn *conn, struct 
list_head *txs)
if (time_after_eq(jiffies, tx->tx_deadline)) {
CERROR("Timed out tx: %s, %lu seconds\n",
   kiblnd_queue2str(conn, txs),
-  cfs_duration_sec(jiffies - tx->tx_deadline));
+  (jiffies - tx->tx_deadline) / HZ);
return 1;
}
}
@@ -3206,8 +3206,7 @@ kiblnd_check_conns(int idx)
if (timedout) {
CERROR("Timed out RDMA with %s (%lu): c: %u, 
oc: %u, rc: %u\n",
   libcfs_nid2str(peer->ibp_nid),
-  cfs_duration_sec(jiffies -
-   peer->ibp_last_alive),
+  (jiffies - peer->ibp_last_alive) / HZ,
   conn->ibc_credits,
   conn->ibc_outstanding_credits,
   conn->ibc_reserved_credits);
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c 
b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
index 16c1ab0b0bd9..79b98cdd0f9d 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
@@ -1682,7 +1682,7 @@ ksocknal_destroy_conn(struct ksock_conn *conn)
   libcfs_id2str(conn->ksnc_peer->ksnp_id), conn->ksnc_type,
   >ksnc_ipaddr, conn->ksnc_port,
   iov_iter_count(>ksnc_rx_to), 
conn->ksnc_rx_nob_left,
-  cfs_duration_sec(jiffies - last_rcv));
+  (jiffies - last_rcv) / HZ);
lnet_finalize(conn->ksnc_peer->ksnp_ni,
  conn->ksnc_cookie, -EIO);
break;
@@ -1870,7 +1870,7 @@ ksocknal_query(struct lnet_ni *ni, lnet_nid_t nid, 
unsigned long *when)
 
CDEBUG(D_NET, "Peer %s %p, alive %ld secs ago, connect %d\n",
   libcfs_nid2str(nid), peer,
-  last_alive ? cfs_duration_sec(now - last_alive) : -1,
+  last_alive ? (now - last_alive) / HZ : -1,
   connect);
 
if (!connect)
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c 
b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
index 8ead1e02e854..14450fd5957a 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
@@ -751,7 +751,7 @@ ksocknal_find_connectable_route_locked(struct 

[PATCH 13/17] staging: lustre: libcfs: remove cfs_timeout_cap()

2018-03-28 Thread NeilBrown
This wrapper is only used once, so open-code it as max().

This allows us to remove the libcfs_time.h include file.

Signed-off-by: NeilBrown 
---
 .../staging/lustre/include/linux/libcfs/libcfs.h   |1 
 .../lustre/include/linux/libcfs/libcfs_time.h  |   50 
 .../lustre/include/linux/libcfs/linux/linux-time.h |2 -
 drivers/staging/lustre/lustre/ptlrpc/import.c  |4 +-
 4 files changed, 3 insertions(+), 54 deletions(-)
 delete mode 100644 drivers/staging/lustre/include/linux/libcfs/libcfs_time.h

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
index 3b751c436b3d..3d3fa52858e5 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
@@ -43,7 +43,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
deleted file mode 100644
index 172a8872e3f3..
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
+++ /dev/null
@@ -1,50 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.gnu.org/licenses/gpl-2.0.html
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * libcfs/include/libcfs/libcfs_time.h
- *
- * Time functions.
- *
- */
-
-#ifndef __LIBCFS_TIME_H__
-#define __LIBCFS_TIME_H__
-/*
- * return valid time-out based on user supplied one. Currently we only check
- * that time-out is not shorted than allowed.
- */
-static inline long cfs_timeout_cap(long timeout)
-{
-   if (timeout < CFS_TICK)
-   timeout = CFS_TICK;
-   return timeout;
-}
-
-#endif
diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h 
b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
index ff3aae2f1231..ecb2126a9e6f 100644
--- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
+++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
@@ -78,7 +78,7 @@ static inline int cfs_time_beforeq_64(u64 t1, u64 t2)
 /*
  * One jiffy
  */
-#define CFS_TICK   (1)
+#define CFS_TICK   (1UL)
 
 #define CFS_DURATION_T   "%ld"
 
diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c 
b/drivers/staging/lustre/lustre/ptlrpc/import.c
index 4a9d1f189d01..dd4fd54128dd 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/import.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/import.c
@@ -1486,7 +1486,7 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int 
noclose)
}
 
if (ptlrpc_import_in_recovery(imp)) {
-   long timeout;
+   unsigned long timeout;
 
if (AT_OFF) {
if (imp->imp_server_timeout)
@@ -1501,7 +1501,7 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int 
noclose)
 
if (wait_event_idle_timeout(imp->imp_recovery_waitq,
!ptlrpc_import_in_recovery(imp),
-   cfs_timeout_cap(timeout)) == 0)
+   max(timeout, CFS_TICK)) == 0)
l_wait_event_abortable(
imp->imp_recovery_waitq,
!ptlrpc_import_in_recovery(imp));




[PATCH 16/17] staging: lustre: discard linux-time.h

2018-03-28 Thread NeilBrown
Very little is left in linux-time.h.
Move CFS_TICK to libcfs.h discard the test.

Signed-off-by: NeilBrown 
---
 .../staging/lustre/include/linux/libcfs/libcfs.h   |5 ++
 .../lustre/include/linux/libcfs/linux/libcfs.h |1 
 .../lustre/include/linux/libcfs/linux/linux-time.h |   66 
 drivers/staging/lustre/lustre/ptlrpc/pinger.c  |2 -
 4 files changed, 6 insertions(+), 68 deletions(-)
 delete mode 100644 
drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
index 3d3fa52858e5..f183f31da387 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
@@ -52,6 +52,11 @@
 
 #define LOWEST_BIT_SET(x)   ((x) & ~((x) - 1))
 
+/*
+ * One jiffy
+ */
+#define CFS_TICK   (1UL)
+
 /*
  * Lustre Error Checksum: calculates checksum
  * of Hex number by XORing each bit.
diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h 
b/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
index 30e333af8d0d..c39c34d74382 100644
--- a/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
@@ -80,7 +80,6 @@
 #include 
 #include 
 #include "linux-cpu.h"
-#include "linux-time.h"
 
 #define LUSTRE_TRACE_SIZE (THREAD_SIZE >> 5)
 
diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h 
b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
deleted file mode 100644
index ecdebccf2b44..
--- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
+++ /dev/null
@@ -1,66 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.gnu.org/licenses/gpl-2.0.html
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * libcfs/include/libcfs/linux/linux-time.h
- *
- * Implementation of portable time API for Linux (kernel and user-level).
- *
- * Author: Nikita Danilov 
- */
-
-#ifndef __LIBCFS_LINUX_LINUX_TIME_H__
-#define __LIBCFS_LINUX_LINUX_TIME_H__
-
-#ifndef __LIBCFS_LIBCFS_H__
-#error Do not #include this file directly. #include  
instead
-#endif
-
-#define ONE_BILLION ((u_int64_t)10)
-#define ONE_MILLION 100
-
-#include 
-#include 
-#include 
-#include 
-
-/*
- * post 2.5 kernels.
- */
-
-#include 
-
-/*
- * One jiffy
- */
-#define CFS_TICK   (1UL)
-
-#define CFS_DURATION_T   "%ld"
-
-#endif /* __LIBCFS_LINUX_LINUX_TIME_H__ */
diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c 
b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
index 3f17c673d1b8..89eef8ec7df4 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
@@ -251,7 +251,7 @@ static void ptlrpc_pinger_main(struct work_struct *ws)
 * we will SKIP the next ping at next_ping, and the
 * ping will get sent 2 timeouts from now!  Beware.
 */
-   CDEBUG(D_INFO, "next wakeup in " CFS_DURATION_T " (%ld)\n",
+   CDEBUG(D_INFO, "next wakeup in %ld (%ld)\n",
   time_to_next_wake,
   this_ping + PING_INTERVAL * HZ);
} while (time_to_next_wake <= 0);




[PATCH 15/17] staging: lustre: discard cfs_time_before_64()

2018-03-28 Thread NeilBrown
cfs_time_before_64 is the same as time_before64()
similarly cfs_time_beforeq_64() matsches time_before_eq64()
So just use the standard interfaces.

Signed-off-by: NeilBrown 
---
 .../lustre/include/linux/libcfs/linux/linux-time.h |   14 --
 drivers/staging/lustre/lustre/include/obd_class.h  |4 ++--
 drivers/staging/lustre/lustre/ptlrpc/import.c  |4 ++--
 3 files changed, 4 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h 
b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
index 9a353c6cb85a..ecdebccf2b44 100644
--- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
+++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
@@ -56,20 +56,6 @@
 
 #include 
 
-/*
- * Generic kernel stuff
- */
-
-static inline int cfs_time_before_64(u64 t1, u64 t2)
-{
-   return (__s64)t2 - (__s64)t1 > 0;
-}
-
-static inline int cfs_time_beforeq_64(u64 t1, u64 t2)
-{
-   return (__s64)t2 - (__s64)t1 >= 0;
-}
-
 /*
  * One jiffy
  */
diff --git a/drivers/staging/lustre/lustre/include/obd_class.h 
b/drivers/staging/lustre/lustre/include/obd_class.h
index 7cfc3c8d100c..176b63e2c9a7 100644
--- a/drivers/staging/lustre/lustre/include/obd_class.h
+++ b/drivers/staging/lustre/lustre/include/obd_class.h
@@ -932,7 +932,7 @@ static inline int obd_statfs_async(struct obd_export *exp,
 
CDEBUG(D_SUPER, "%s: osfs %p age %llu, max_age %llu\n",
   obd->obd_name, >obd_osfs, obd->obd_osfs_age, max_age);
-   if (cfs_time_before_64(obd->obd_osfs_age, max_age)) {
+   if (time_before64(obd->obd_osfs_age, max_age)) {
rc = OBP(obd, statfs_async)(exp, oinfo, max_age, rqset);
} else {
CDEBUG(D_SUPER,
@@ -992,7 +992,7 @@ static inline int obd_statfs(const struct lu_env *env, 
struct obd_export *exp,
 
CDEBUG(D_SUPER, "osfs %llu, max_age %llu\n",
   obd->obd_osfs_age, max_age);
-   if (cfs_time_before_64(obd->obd_osfs_age, max_age)) {
+   if (time_before64(obd->obd_osfs_age, max_age)) {
rc = OBP(obd, statfs)(env, exp, osfs, max_age, flags);
if (rc == 0) {
spin_lock(>obd_osfs_lock);
diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c 
b/drivers/staging/lustre/lustre/ptlrpc/import.c
index dd4fd54128dd..537a9e2ed467 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/import.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/import.c
@@ -463,7 +463,7 @@ static int import_select_connection(struct obd_import *imp)
 * the last successful attempt, go with this one
 */
if ((conn->oic_last_attempt == 0) ||
-   cfs_time_beforeq_64(conn->oic_last_attempt,
+   time_before_eq64(conn->oic_last_attempt,
imp->imp_last_success_conn)) {
imp_conn = conn;
tried_all = 0;
@@ -476,7 +476,7 @@ static int import_select_connection(struct obd_import *imp)
 */
if (!imp_conn)
imp_conn = conn;
-   else if (cfs_time_before_64(conn->oic_last_attempt,
+   else if (time_before64(conn->oic_last_attempt,
imp_conn->oic_last_attempt))
imp_conn = conn;
}




[PATCH 16/17] staging: lustre: discard linux-time.h

2018-03-28 Thread NeilBrown
Very little is left in linux-time.h.
Move CFS_TICK to libcfs.h discard the test.

Signed-off-by: NeilBrown 
---
 .../staging/lustre/include/linux/libcfs/libcfs.h   |5 ++
 .../lustre/include/linux/libcfs/linux/libcfs.h |1 
 .../lustre/include/linux/libcfs/linux/linux-time.h |   66 
 drivers/staging/lustre/lustre/ptlrpc/pinger.c  |2 -
 4 files changed, 6 insertions(+), 68 deletions(-)
 delete mode 100644 
drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
index 3d3fa52858e5..f183f31da387 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
@@ -52,6 +52,11 @@
 
 #define LOWEST_BIT_SET(x)   ((x) & ~((x) - 1))
 
+/*
+ * One jiffy
+ */
+#define CFS_TICK   (1UL)
+
 /*
  * Lustre Error Checksum: calculates checksum
  * of Hex number by XORing each bit.
diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h 
b/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
index 30e333af8d0d..c39c34d74382 100644
--- a/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
@@ -80,7 +80,6 @@
 #include 
 #include 
 #include "linux-cpu.h"
-#include "linux-time.h"
 
 #define LUSTRE_TRACE_SIZE (THREAD_SIZE >> 5)
 
diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h 
b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
deleted file mode 100644
index ecdebccf2b44..
--- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
+++ /dev/null
@@ -1,66 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.gnu.org/licenses/gpl-2.0.html
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * libcfs/include/libcfs/linux/linux-time.h
- *
- * Implementation of portable time API for Linux (kernel and user-level).
- *
- * Author: Nikita Danilov 
- */
-
-#ifndef __LIBCFS_LINUX_LINUX_TIME_H__
-#define __LIBCFS_LINUX_LINUX_TIME_H__
-
-#ifndef __LIBCFS_LIBCFS_H__
-#error Do not #include this file directly. #include  
instead
-#endif
-
-#define ONE_BILLION ((u_int64_t)10)
-#define ONE_MILLION 100
-
-#include 
-#include 
-#include 
-#include 
-
-/*
- * post 2.5 kernels.
- */
-
-#include 
-
-/*
- * One jiffy
- */
-#define CFS_TICK   (1UL)
-
-#define CFS_DURATION_T   "%ld"
-
-#endif /* __LIBCFS_LINUX_LINUX_TIME_H__ */
diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c 
b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
index 3f17c673d1b8..89eef8ec7df4 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
@@ -251,7 +251,7 @@ static void ptlrpc_pinger_main(struct work_struct *ws)
 * we will SKIP the next ping at next_ping, and the
 * ping will get sent 2 timeouts from now!  Beware.
 */
-   CDEBUG(D_INFO, "next wakeup in " CFS_DURATION_T " (%ld)\n",
+   CDEBUG(D_INFO, "next wakeup in %ld (%ld)\n",
   time_to_next_wake,
   this_ping + PING_INTERVAL * HZ);
} while (time_to_next_wake <= 0);




[PATCH 15/17] staging: lustre: discard cfs_time_before_64()

2018-03-28 Thread NeilBrown
cfs_time_before_64 is the same as time_before64()
similarly cfs_time_beforeq_64() matsches time_before_eq64()
So just use the standard interfaces.

Signed-off-by: NeilBrown 
---
 .../lustre/include/linux/libcfs/linux/linux-time.h |   14 --
 drivers/staging/lustre/lustre/include/obd_class.h  |4 ++--
 drivers/staging/lustre/lustre/ptlrpc/import.c  |4 ++--
 3 files changed, 4 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h 
b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
index 9a353c6cb85a..ecdebccf2b44 100644
--- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
+++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
@@ -56,20 +56,6 @@
 
 #include 
 
-/*
- * Generic kernel stuff
- */
-
-static inline int cfs_time_before_64(u64 t1, u64 t2)
-{
-   return (__s64)t2 - (__s64)t1 > 0;
-}
-
-static inline int cfs_time_beforeq_64(u64 t1, u64 t2)
-{
-   return (__s64)t2 - (__s64)t1 >= 0;
-}
-
 /*
  * One jiffy
  */
diff --git a/drivers/staging/lustre/lustre/include/obd_class.h 
b/drivers/staging/lustre/lustre/include/obd_class.h
index 7cfc3c8d100c..176b63e2c9a7 100644
--- a/drivers/staging/lustre/lustre/include/obd_class.h
+++ b/drivers/staging/lustre/lustre/include/obd_class.h
@@ -932,7 +932,7 @@ static inline int obd_statfs_async(struct obd_export *exp,
 
CDEBUG(D_SUPER, "%s: osfs %p age %llu, max_age %llu\n",
   obd->obd_name, >obd_osfs, obd->obd_osfs_age, max_age);
-   if (cfs_time_before_64(obd->obd_osfs_age, max_age)) {
+   if (time_before64(obd->obd_osfs_age, max_age)) {
rc = OBP(obd, statfs_async)(exp, oinfo, max_age, rqset);
} else {
CDEBUG(D_SUPER,
@@ -992,7 +992,7 @@ static inline int obd_statfs(const struct lu_env *env, 
struct obd_export *exp,
 
CDEBUG(D_SUPER, "osfs %llu, max_age %llu\n",
   obd->obd_osfs_age, max_age);
-   if (cfs_time_before_64(obd->obd_osfs_age, max_age)) {
+   if (time_before64(obd->obd_osfs_age, max_age)) {
rc = OBP(obd, statfs)(env, exp, osfs, max_age, flags);
if (rc == 0) {
spin_lock(>obd_osfs_lock);
diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c 
b/drivers/staging/lustre/lustre/ptlrpc/import.c
index dd4fd54128dd..537a9e2ed467 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/import.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/import.c
@@ -463,7 +463,7 @@ static int import_select_connection(struct obd_import *imp)
 * the last successful attempt, go with this one
 */
if ((conn->oic_last_attempt == 0) ||
-   cfs_time_beforeq_64(conn->oic_last_attempt,
+   time_before_eq64(conn->oic_last_attempt,
imp->imp_last_success_conn)) {
imp_conn = conn;
tried_all = 0;
@@ -476,7 +476,7 @@ static int import_select_connection(struct obd_import *imp)
 */
if (!imp_conn)
imp_conn = conn;
-   else if (cfs_time_before_64(conn->oic_last_attempt,
+   else if (time_before64(conn->oic_last_attempt,
imp_conn->oic_last_attempt))
imp_conn = conn;
}




[PATCH 13/17] staging: lustre: libcfs: remove cfs_timeout_cap()

2018-03-28 Thread NeilBrown
This wrapper is only used once, so open-code it as max().

This allows us to remove the libcfs_time.h include file.

Signed-off-by: NeilBrown 
---
 .../staging/lustre/include/linux/libcfs/libcfs.h   |1 
 .../lustre/include/linux/libcfs/libcfs_time.h  |   50 
 .../lustre/include/linux/libcfs/linux/linux-time.h |2 -
 drivers/staging/lustre/lustre/ptlrpc/import.c  |4 +-
 4 files changed, 3 insertions(+), 54 deletions(-)
 delete mode 100644 drivers/staging/lustre/include/linux/libcfs/libcfs_time.h

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
index 3b751c436b3d..3d3fa52858e5 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
@@ -43,7 +43,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
deleted file mode 100644
index 172a8872e3f3..
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
+++ /dev/null
@@ -1,50 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.gnu.org/licenses/gpl-2.0.html
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * libcfs/include/libcfs/libcfs_time.h
- *
- * Time functions.
- *
- */
-
-#ifndef __LIBCFS_TIME_H__
-#define __LIBCFS_TIME_H__
-/*
- * return valid time-out based on user supplied one. Currently we only check
- * that time-out is not shorted than allowed.
- */
-static inline long cfs_timeout_cap(long timeout)
-{
-   if (timeout < CFS_TICK)
-   timeout = CFS_TICK;
-   return timeout;
-}
-
-#endif
diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h 
b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
index ff3aae2f1231..ecb2126a9e6f 100644
--- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
+++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
@@ -78,7 +78,7 @@ static inline int cfs_time_beforeq_64(u64 t1, u64 t2)
 /*
  * One jiffy
  */
-#define CFS_TICK   (1)
+#define CFS_TICK   (1UL)
 
 #define CFS_DURATION_T   "%ld"
 
diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c 
b/drivers/staging/lustre/lustre/ptlrpc/import.c
index 4a9d1f189d01..dd4fd54128dd 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/import.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/import.c
@@ -1486,7 +1486,7 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int 
noclose)
}
 
if (ptlrpc_import_in_recovery(imp)) {
-   long timeout;
+   unsigned long timeout;
 
if (AT_OFF) {
if (imp->imp_server_timeout)
@@ -1501,7 +1501,7 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int 
noclose)
 
if (wait_event_idle_timeout(imp->imp_recovery_waitq,
!ptlrpc_import_in_recovery(imp),
-   cfs_timeout_cap(timeout)) == 0)
+   max(timeout, CFS_TICK)) == 0)
l_wait_event_abortable(
imp->imp_recovery_waitq,
!ptlrpc_import_in_recovery(imp));




[PATCH 07/17] staging: lustre: ldlm: free resource when ldlm_lock_create() fails.

2018-03-28 Thread NeilBrown
ldlm_lock_create() gets a resource, but don't put it on
all failure paths. It should.

Signed-off-by: NeilBrown 
---
 drivers/staging/lustre/lustre/ldlm/ldlm_lock.c |6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c 
b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
index b8fd778d9832..614caa4a9b0e 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
@@ -1551,8 +1551,10 @@ struct ldlm_lock *ldlm_lock_create(struct ldlm_namespace 
*ns,
return ERR_CAST(res);
 
lock = ldlm_lock_new(res);
-   if (!lock)
+   if (!lock) {
+   ldlm_resource_putref(res);
return ERR_PTR(-ENOMEM);
+   }
 
lock->l_req_mode = mode;
lock->l_ast_data = data;
@@ -1595,6 +1597,8 @@ struct ldlm_lock *ldlm_lock_create(struct ldlm_namespace 
*ns,
return ERR_PTR(rc);
 }
 
+
+
 /**
  * Enqueue (request) a lock.
  * On the client this is called from ldlm_cli_enqueue_fini




[PATCH 08/17] staging: lustre: add container_of_safe()

2018-03-28 Thread NeilBrown
Luster has a container_of0() function which is similar to
container_of() but passes an IS_ERR_OR_NULL() pointer through
unchanged.
This could be generally useful: bcache at last has a similar function.

Naming is hard, but the precedent set by hlist_entry_safe() suggests
a _safe suffix might be most consistent.

So add container_of_safe() to kernel.h, and replace all occurrences of
container_of0() with one of
  - list_first_entry, list_next_entry, when that is a better fit,
  - container_of(), when the pointer is used as a validpointer in
surrounding code,
  - container_of_safe() when there is no obviously better alternative.

Signed-off-by: NeilBrown 
---
 .../staging/lustre/include/linux/libcfs/libcfs.h   |   11 ---
 drivers/staging/lustre/lustre/include/cl_object.h  |   10 +-
 drivers/staging/lustre/lustre/include/lu_object.h  |6 +++---
 drivers/staging/lustre/lustre/llite/llite_nfs.c|2 +-
 drivers/staging/lustre/lustre/llite/vvp_internal.h |8 
 drivers/staging/lustre/lustre/lmv/lmv_internal.h   |2 +-
 .../staging/lustre/lustre/lov/lov_cl_internal.h|   18 +-
 drivers/staging/lustre/lustre/lov/lov_internal.h   |2 +-
 drivers/staging/lustre/lustre/obdclass/lu_object.c |8 
 .../staging/lustre/lustre/obdecho/echo_client.c|2 +-
 .../staging/lustre/lustre/osc/osc_cl_internal.h|   10 +-
 drivers/staging/lustre/lustre/osc/osc_internal.h   |2 +-
 drivers/staging/lustre/lustre/osc/osc_io.c |2 +-
 drivers/staging/lustre/lustre/osc/osc_object.c |2 +-
 include/linux/kernel.h |   16 
 15 files changed, 53 insertions(+), 48 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
index 392793582956..3b751c436b3d 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
@@ -99,17 +99,6 @@ int libcfs_ioctl_getdata(struct libcfs_ioctl_hdr **hdr_pp,
 int libcfs_ioctl_data_adjust(struct libcfs_ioctl_data *data);
 int libcfs_ioctl(unsigned long cmd, void __user *arg);
 
-/* container_of depends on "likely" which is defined in libcfs_private.h */
-static inline void *__container_of(void *ptr, unsigned long shift)
-{
-   if (IS_ERR_OR_NULL(ptr))
-   return ptr;
-   return (char *)ptr - shift;
-}
-
-#define container_of0(ptr, type, member) \
-   ((type *)__container_of((void *)(ptr), offsetof(type, member)))
-
 #define _LIBCFS_H
 
 extern struct miscdevice libcfs_dev;
diff --git a/drivers/staging/lustre/lustre/include/cl_object.h 
b/drivers/staging/lustre/lustre/include/cl_object.h
index 341a145c3331..6f7b991be809 100644
--- a/drivers/staging/lustre/lustre/include/cl_object.h
+++ b/drivers/staging/lustre/lustre/include/cl_object.h
@@ -1941,7 +1941,7 @@ static inline int lu_device_is_cl(const struct lu_device 
*d)
 static inline struct cl_device *lu2cl_dev(const struct lu_device *d)
 {
LASSERT(!d || IS_ERR(d) || lu_device_is_cl(d));
-   return container_of0(d, struct cl_device, cd_lu_dev);
+   return container_of_safe(d, struct cl_device, cd_lu_dev);
 }
 
 static inline struct lu_device *cl2lu_dev(struct cl_device *d)
@@ -1952,13 +1952,13 @@ static inline struct lu_device *cl2lu_dev(struct 
cl_device *d)
 static inline struct cl_object *lu2cl(const struct lu_object *o)
 {
LASSERT(!o || IS_ERR(o) || lu_device_is_cl(o->lo_dev));
-   return container_of0(o, struct cl_object, co_lu);
+   return container_of_safe(o, struct cl_object, co_lu);
 }
 
 static inline const struct cl_object_conf *
 lu2cl_conf(const struct lu_object_conf *conf)
 {
-   return container_of0(conf, struct cl_object_conf, coc_lu);
+   return container_of_safe(conf, struct cl_object_conf, coc_lu);
 }
 
 static inline struct cl_object *cl_object_next(const struct cl_object *obj)
@@ -1969,12 +1969,12 @@ static inline struct cl_object *cl_object_next(const 
struct cl_object *obj)
 static inline struct cl_device *cl_object_device(const struct cl_object *o)
 {
LASSERT(!o || IS_ERR(o) || lu_device_is_cl(o->co_lu.lo_dev));
-   return container_of0(o->co_lu.lo_dev, struct cl_device, cd_lu_dev);
+   return container_of_safe(o->co_lu.lo_dev, struct cl_device, cd_lu_dev);
 }
 
 static inline struct cl_object_header *luh2coh(const struct lu_object_header 
*h)
 {
-   return container_of0(h, struct cl_object_header, coh_lu);
+   return container_of_safe(h, struct cl_object_header, coh_lu);
 }
 
 static inline struct cl_site *cl_object_site(const struct cl_object *obj)
diff --git a/drivers/staging/lustre/lustre/include/lu_object.h 
b/drivers/staging/lustre/lustre/include/lu_object.h
index 35c7b582f36d..c3b0ed518819 100644
--- a/drivers/staging/lustre/lustre/include/lu_object.h
+++ b/drivers/staging/lustre/lustre/include/lu_object.h
@@ -745,15 +745,15 @@ struct 

[PATCH 06/17] staging: lustre: tidy up ldlm_resource_putref()

2018-03-28 Thread NeilBrown
1/ the return value of ldlm_resource_putref() is never
  used, so change it to return 'void'.
2/ Move all of the code to run on the last putref to
   __ldlm_resource_putref_final().  This means a lock
   is taken in one function and dropped in another, but
   that isn't too uncommon, and will disappear in a future
   patch.
   Now that the code it together, it becomes apparent that
   we are dropping a ref on the namespace *before* the last
   use.  So keep the ref until after.

Signed-off-by: NeilBrown 
---
 drivers/staging/lustre/lustre/include/lustre_dlm.h |2 +-
 drivers/staging/lustre/lustre/ldlm/ldlm_resource.c |   21 +---
 2 files changed, 10 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h 
b/drivers/staging/lustre/lustre/include/lustre_dlm.h
index 5a355fbab401..d668d86423a4 100644
--- a/drivers/staging/lustre/lustre/include/lustre_dlm.h
+++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h
@@ -1190,7 +1190,7 @@ struct ldlm_resource *ldlm_resource_get(struct 
ldlm_namespace *ns,
struct ldlm_resource *parent,
const struct ldlm_res_id *,
enum ldlm_type type, int create);
-int ldlm_resource_putref(struct ldlm_resource *res);
+void ldlm_resource_putref(struct ldlm_resource *res);
 void ldlm_resource_add_lock(struct ldlm_resource *res,
struct list_head *head,
struct ldlm_lock *lock);
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c 
b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
index 4c44603ab6f9..8841a1bb2c0a 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
@@ -1195,6 +1195,7 @@ static void __ldlm_resource_putref_final(struct 
cfs_hash_bd *bd,
 struct ldlm_resource *res)
 {
struct ldlm_ns_bucket *nsb = res->lr_ns_bucket;
+   struct ldlm_namespace *ns = nsb->nsb_namespace;
 
if (!list_empty(>lr_granted)) {
ldlm_resource_dump(D_ERROR, res);
@@ -1206,15 +1207,18 @@ static void __ldlm_resource_putref_final(struct 
cfs_hash_bd *bd,
LBUG();
}
 
-   cfs_hash_bd_del_locked(nsb->nsb_namespace->ns_rs_hash,
+   cfs_hash_bd_del_locked(ns->ns_rs_hash,
   bd, >lr_hash);
lu_ref_fini(>lr_reference);
+   cfs_hash_bd_unlock(ns->ns_rs_hash, bd, 1);
+   if (ns->ns_lvbo && ns->ns_lvbo->lvbo_free)
+   ns->ns_lvbo->lvbo_free(res);
if (cfs_hash_bd_count_get(bd) == 0)
-   ldlm_namespace_put(nsb->nsb_namespace);
+   ldlm_namespace_put(ns);
+   kmem_cache_free(ldlm_resource_slab, res);
 }
 
-/* Returns 1 if the resource was freed, 0 if it remains. */
-int ldlm_resource_putref(struct ldlm_resource *res)
+void ldlm_resource_putref(struct ldlm_resource *res)
 {
struct ldlm_namespace *ns = ldlm_res_to_ns(res);
struct cfs_hash_bd   bd;
@@ -1224,15 +1228,8 @@ int ldlm_resource_putref(struct ldlm_resource *res)
   res, atomic_read(>lr_refcount) - 1);
 
cfs_hash_bd_get(ns->ns_rs_hash, >lr_name, );
-   if (cfs_hash_bd_dec_and_lock(ns->ns_rs_hash, , >lr_refcount)) {
+   if (cfs_hash_bd_dec_and_lock(ns->ns_rs_hash, , >lr_refcount))
__ldlm_resource_putref_final(, res);
-   cfs_hash_bd_unlock(ns->ns_rs_hash, , 1);
-   if (ns->ns_lvbo && ns->ns_lvbo->lvbo_free)
-   ns->ns_lvbo->lvbo_free(res);
-   kmem_cache_free(ldlm_resource_slab, res);
-   return 1;
-   }
-   return 0;
 }
 EXPORT_SYMBOL(ldlm_resource_putref);
 




[PATCH 07/17] staging: lustre: ldlm: free resource when ldlm_lock_create() fails.

2018-03-28 Thread NeilBrown
ldlm_lock_create() gets a resource, but don't put it on
all failure paths. It should.

Signed-off-by: NeilBrown 
---
 drivers/staging/lustre/lustre/ldlm/ldlm_lock.c |6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c 
b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
index b8fd778d9832..614caa4a9b0e 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
@@ -1551,8 +1551,10 @@ struct ldlm_lock *ldlm_lock_create(struct ldlm_namespace 
*ns,
return ERR_CAST(res);
 
lock = ldlm_lock_new(res);
-   if (!lock)
+   if (!lock) {
+   ldlm_resource_putref(res);
return ERR_PTR(-ENOMEM);
+   }
 
lock->l_req_mode = mode;
lock->l_ast_data = data;
@@ -1595,6 +1597,8 @@ struct ldlm_lock *ldlm_lock_create(struct ldlm_namespace 
*ns,
return ERR_PTR(rc);
 }
 
+
+
 /**
  * Enqueue (request) a lock.
  * On the client this is called from ldlm_cli_enqueue_fini




[PATCH 08/17] staging: lustre: add container_of_safe()

2018-03-28 Thread NeilBrown
Luster has a container_of0() function which is similar to
container_of() but passes an IS_ERR_OR_NULL() pointer through
unchanged.
This could be generally useful: bcache at last has a similar function.

Naming is hard, but the precedent set by hlist_entry_safe() suggests
a _safe suffix might be most consistent.

So add container_of_safe() to kernel.h, and replace all occurrences of
container_of0() with one of
  - list_first_entry, list_next_entry, when that is a better fit,
  - container_of(), when the pointer is used as a validpointer in
surrounding code,
  - container_of_safe() when there is no obviously better alternative.

Signed-off-by: NeilBrown 
---
 .../staging/lustre/include/linux/libcfs/libcfs.h   |   11 ---
 drivers/staging/lustre/lustre/include/cl_object.h  |   10 +-
 drivers/staging/lustre/lustre/include/lu_object.h  |6 +++---
 drivers/staging/lustre/lustre/llite/llite_nfs.c|2 +-
 drivers/staging/lustre/lustre/llite/vvp_internal.h |8 
 drivers/staging/lustre/lustre/lmv/lmv_internal.h   |2 +-
 .../staging/lustre/lustre/lov/lov_cl_internal.h|   18 +-
 drivers/staging/lustre/lustre/lov/lov_internal.h   |2 +-
 drivers/staging/lustre/lustre/obdclass/lu_object.c |8 
 .../staging/lustre/lustre/obdecho/echo_client.c|2 +-
 .../staging/lustre/lustre/osc/osc_cl_internal.h|   10 +-
 drivers/staging/lustre/lustre/osc/osc_internal.h   |2 +-
 drivers/staging/lustre/lustre/osc/osc_io.c |2 +-
 drivers/staging/lustre/lustre/osc/osc_object.c |2 +-
 include/linux/kernel.h |   16 
 15 files changed, 53 insertions(+), 48 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
index 392793582956..3b751c436b3d 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
@@ -99,17 +99,6 @@ int libcfs_ioctl_getdata(struct libcfs_ioctl_hdr **hdr_pp,
 int libcfs_ioctl_data_adjust(struct libcfs_ioctl_data *data);
 int libcfs_ioctl(unsigned long cmd, void __user *arg);
 
-/* container_of depends on "likely" which is defined in libcfs_private.h */
-static inline void *__container_of(void *ptr, unsigned long shift)
-{
-   if (IS_ERR_OR_NULL(ptr))
-   return ptr;
-   return (char *)ptr - shift;
-}
-
-#define container_of0(ptr, type, member) \
-   ((type *)__container_of((void *)(ptr), offsetof(type, member)))
-
 #define _LIBCFS_H
 
 extern struct miscdevice libcfs_dev;
diff --git a/drivers/staging/lustre/lustre/include/cl_object.h 
b/drivers/staging/lustre/lustre/include/cl_object.h
index 341a145c3331..6f7b991be809 100644
--- a/drivers/staging/lustre/lustre/include/cl_object.h
+++ b/drivers/staging/lustre/lustre/include/cl_object.h
@@ -1941,7 +1941,7 @@ static inline int lu_device_is_cl(const struct lu_device 
*d)
 static inline struct cl_device *lu2cl_dev(const struct lu_device *d)
 {
LASSERT(!d || IS_ERR(d) || lu_device_is_cl(d));
-   return container_of0(d, struct cl_device, cd_lu_dev);
+   return container_of_safe(d, struct cl_device, cd_lu_dev);
 }
 
 static inline struct lu_device *cl2lu_dev(struct cl_device *d)
@@ -1952,13 +1952,13 @@ static inline struct lu_device *cl2lu_dev(struct 
cl_device *d)
 static inline struct cl_object *lu2cl(const struct lu_object *o)
 {
LASSERT(!o || IS_ERR(o) || lu_device_is_cl(o->lo_dev));
-   return container_of0(o, struct cl_object, co_lu);
+   return container_of_safe(o, struct cl_object, co_lu);
 }
 
 static inline const struct cl_object_conf *
 lu2cl_conf(const struct lu_object_conf *conf)
 {
-   return container_of0(conf, struct cl_object_conf, coc_lu);
+   return container_of_safe(conf, struct cl_object_conf, coc_lu);
 }
 
 static inline struct cl_object *cl_object_next(const struct cl_object *obj)
@@ -1969,12 +1969,12 @@ static inline struct cl_object *cl_object_next(const 
struct cl_object *obj)
 static inline struct cl_device *cl_object_device(const struct cl_object *o)
 {
LASSERT(!o || IS_ERR(o) || lu_device_is_cl(o->co_lu.lo_dev));
-   return container_of0(o->co_lu.lo_dev, struct cl_device, cd_lu_dev);
+   return container_of_safe(o->co_lu.lo_dev, struct cl_device, cd_lu_dev);
 }
 
 static inline struct cl_object_header *luh2coh(const struct lu_object_header 
*h)
 {
-   return container_of0(h, struct cl_object_header, coh_lu);
+   return container_of_safe(h, struct cl_object_header, coh_lu);
 }
 
 static inline struct cl_site *cl_object_site(const struct cl_object *obj)
diff --git a/drivers/staging/lustre/lustre/include/lu_object.h 
b/drivers/staging/lustre/lustre/include/lu_object.h
index 35c7b582f36d..c3b0ed518819 100644
--- a/drivers/staging/lustre/lustre/include/lu_object.h
+++ b/drivers/staging/lustre/lustre/include/lu_object.h
@@ -745,15 +745,15 @@ struct lu_object 

[PATCH 06/17] staging: lustre: tidy up ldlm_resource_putref()

2018-03-28 Thread NeilBrown
1/ the return value of ldlm_resource_putref() is never
  used, so change it to return 'void'.
2/ Move all of the code to run on the last putref to
   __ldlm_resource_putref_final().  This means a lock
   is taken in one function and dropped in another, but
   that isn't too uncommon, and will disappear in a future
   patch.
   Now that the code it together, it becomes apparent that
   we are dropping a ref on the namespace *before* the last
   use.  So keep the ref until after.

Signed-off-by: NeilBrown 
---
 drivers/staging/lustre/lustre/include/lustre_dlm.h |2 +-
 drivers/staging/lustre/lustre/ldlm/ldlm_resource.c |   21 +---
 2 files changed, 10 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h 
b/drivers/staging/lustre/lustre/include/lustre_dlm.h
index 5a355fbab401..d668d86423a4 100644
--- a/drivers/staging/lustre/lustre/include/lustre_dlm.h
+++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h
@@ -1190,7 +1190,7 @@ struct ldlm_resource *ldlm_resource_get(struct 
ldlm_namespace *ns,
struct ldlm_resource *parent,
const struct ldlm_res_id *,
enum ldlm_type type, int create);
-int ldlm_resource_putref(struct ldlm_resource *res);
+void ldlm_resource_putref(struct ldlm_resource *res);
 void ldlm_resource_add_lock(struct ldlm_resource *res,
struct list_head *head,
struct ldlm_lock *lock);
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c 
b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
index 4c44603ab6f9..8841a1bb2c0a 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
@@ -1195,6 +1195,7 @@ static void __ldlm_resource_putref_final(struct 
cfs_hash_bd *bd,
 struct ldlm_resource *res)
 {
struct ldlm_ns_bucket *nsb = res->lr_ns_bucket;
+   struct ldlm_namespace *ns = nsb->nsb_namespace;
 
if (!list_empty(>lr_granted)) {
ldlm_resource_dump(D_ERROR, res);
@@ -1206,15 +1207,18 @@ static void __ldlm_resource_putref_final(struct 
cfs_hash_bd *bd,
LBUG();
}
 
-   cfs_hash_bd_del_locked(nsb->nsb_namespace->ns_rs_hash,
+   cfs_hash_bd_del_locked(ns->ns_rs_hash,
   bd, >lr_hash);
lu_ref_fini(>lr_reference);
+   cfs_hash_bd_unlock(ns->ns_rs_hash, bd, 1);
+   if (ns->ns_lvbo && ns->ns_lvbo->lvbo_free)
+   ns->ns_lvbo->lvbo_free(res);
if (cfs_hash_bd_count_get(bd) == 0)
-   ldlm_namespace_put(nsb->nsb_namespace);
+   ldlm_namespace_put(ns);
+   kmem_cache_free(ldlm_resource_slab, res);
 }
 
-/* Returns 1 if the resource was freed, 0 if it remains. */
-int ldlm_resource_putref(struct ldlm_resource *res)
+void ldlm_resource_putref(struct ldlm_resource *res)
 {
struct ldlm_namespace *ns = ldlm_res_to_ns(res);
struct cfs_hash_bd   bd;
@@ -1224,15 +1228,8 @@ int ldlm_resource_putref(struct ldlm_resource *res)
   res, atomic_read(>lr_refcount) - 1);
 
cfs_hash_bd_get(ns->ns_rs_hash, >lr_name, );
-   if (cfs_hash_bd_dec_and_lock(ns->ns_rs_hash, , >lr_refcount)) {
+   if (cfs_hash_bd_dec_and_lock(ns->ns_rs_hash, , >lr_refcount))
__ldlm_resource_putref_final(, res);
-   cfs_hash_bd_unlock(ns->ns_rs_hash, , 1);
-   if (ns->ns_lvbo && ns->ns_lvbo->lvbo_free)
-   ns->ns_lvbo->lvbo_free(res);
-   kmem_cache_free(ldlm_resource_slab, res);
-   return 1;
-   }
-   return 0;
 }
 EXPORT_SYMBOL(ldlm_resource_putref);
 




[PATCH 11/17] staging: lustre: libcfs: discard cfs_time_shift().

2018-03-28 Thread NeilBrown
This function simply multiplies by HZ and adds jiffies.
This is simple enough to be opencoded, and doing so
makes the code easier to read.

Same for cfs_time_shift_64()

Signed-off-by: NeilBrown 
---
 .../lustre/include/linux/libcfs/libcfs_time.h  |5 
 .../lustre/include/linux/libcfs/linux/linux-time.h |5 
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c|   12 +
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c |4 ++-
 .../staging/lustre/lnet/klnds/socklnd/socklnd.c|4 ++-
 .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c |   12 +
 drivers/staging/lustre/lnet/lnet/net_fault.c   |   26 ++--
 drivers/staging/lustre/lnet/lnet/router.c  |2 +-
 drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |2 +-
 drivers/staging/lustre/lustre/ldlm/ldlm_resource.c |2 +-
 drivers/staging/lustre/lustre/llite/llite_lib.c|4 ++-
 drivers/staging/lustre/lustre/llite/lproc_llite.c  |   12 +
 drivers/staging/lustre/lustre/llite/statahead.c|2 +-
 drivers/staging/lustre/lustre/lmv/lmv_obd.c|2 +-
 drivers/staging/lustre/lustre/lov/lov_obd.c|2 +-
 drivers/staging/lustre/lustre/mdc/mdc_request.c|2 +-
 .../lustre/lustre/obdclass/lprocfs_status.c|   12 +
 .../staging/lustre/lustre/obdclass/obd_config.c|2 +-
 drivers/staging/lustre/lustre/osc/osc_request.c|2 +-
 drivers/staging/lustre/lustre/ptlrpc/pinger.c  |6 ++---
 drivers/staging/lustre/lustre/ptlrpc/service.c |2 +-
 21 files changed, 56 insertions(+), 66 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
index 7b41a129f041..0ebbde4ec8e8 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
@@ -50,11 +50,6 @@ static inline int cfs_time_aftereq(unsigned long t1, 
unsigned long t2)
return time_before_eq(t2, t1);
 }
 
-static inline unsigned long cfs_time_shift(int seconds)
-{
-   return jiffies + seconds * HZ;
-}
-
 /*
  * return valid time-out based on user supplied one. Currently we only check
  * that time-out is not shorted than allowed.
diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h 
b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
index b3a80531bd71..ff3aae2f1231 100644
--- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
+++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
@@ -65,11 +65,6 @@ static inline long cfs_duration_sec(long d)
return d / msecs_to_jiffies(MSEC_PER_SEC);
 }
 
-static inline u64 cfs_time_shift_64(int seconds)
-{
-   return get_jiffies_64() + (u64)seconds * HZ;
-}
-
 static inline int cfs_time_before_64(u64 t1, u64 t2)
 {
return (__s64)t2 - (__s64)t1 > 0;
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c 
b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
index 7df07f39b849..276bf486f64b 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
@@ -1446,7 +1446,7 @@ static int kiblnd_create_fmr_pool(struct kib_fmr_poolset 
*fps,
if (rc)
goto out_fpo;
 
-   fpo->fpo_deadline = cfs_time_shift(IBLND_POOL_DEADLINE);
+   fpo->fpo_deadline = jiffies + IBLND_POOL_DEADLINE * HZ;
fpo->fpo_owner = fps;
*pp_fpo = fpo;
 
@@ -1619,7 +1619,7 @@ int kiblnd_fmr_pool_map(struct kib_fmr_poolset *fps, 
struct kib_tx *tx,
spin_lock(>fps_lock);
version = fps->fps_version;
list_for_each_entry(fpo, >fps_pool_list, fpo_list) {
-   fpo->fpo_deadline = cfs_time_shift(IBLND_POOL_DEADLINE);
+   fpo->fpo_deadline = jiffies + IBLND_POOL_DEADLINE * HZ;
fpo->fpo_map_count++;
 
if (fpo->fpo_is_fmr) {
@@ -1743,7 +1743,7 @@ int kiblnd_fmr_pool_map(struct kib_fmr_poolset *fps, 
struct kib_tx *tx,
fps->fps_version++;
list_add_tail(>fpo_list, >fps_pool_list);
} else {
-   fps->fps_next_retry = cfs_time_shift(IBLND_POOL_RETRY);
+   fps->fps_next_retry = jiffies + IBLND_POOL_RETRY * HZ;
}
spin_unlock(>fps_lock);
 
@@ -1764,7 +1764,7 @@ static void kiblnd_init_pool(struct kib_poolset *ps, 
struct kib_pool *pool, int
 
memset(pool, 0, sizeof(*pool));
INIT_LIST_HEAD(>po_free_list);
-   pool->po_deadline = cfs_time_shift(IBLND_POOL_DEADLINE);
+   pool->po_deadline = jiffies + IBLND_POOL_DEADLINE * HZ;
pool->po_owner= ps;
pool->po_size = size;
 }
@@ -1899,7 +1899,7 @@ struct list_head *kiblnd_pool_alloc_node(struct 
kib_poolset *ps)
continue;
 
pool->po_allocated++;
-   pool->po_deadline = cfs_time_shift(IBLND_POOL_DEADLINE);
+   

[PATCH 12/17] staging: lustre: libcfs: discard cfs_time_after()

2018-03-28 Thread NeilBrown
cfs_time_after() behaves exactly like time_after()
similarly cfs_time_aftereq() matches time_after_eq()

so discard the cfs versions.

Signed-off-by: NeilBrown 
---
 .../lustre/include/linux/libcfs/libcfs_time.h  |   14 -
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c|4 +--
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h|6 ++--
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c |2 +
 .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c |   32 ++--
 drivers/staging/lustre/lnet/libcfs/tracefile.c |8 +++--
 drivers/staging/lustre/lnet/lnet/lib-move.c|4 +--
 drivers/staging/lustre/lnet/lnet/net_fault.c   |8 +++--
 drivers/staging/lustre/lnet/lnet/router.c  |6 ++--
 drivers/staging/lustre/lnet/selftest/conrpc.c  |4 +--
 drivers/staging/lustre/lnet/selftest/timer.c   |2 +
 drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c|4 +--
 drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |4 +--
 drivers/staging/lustre/lustre/osc/osc_object.c |2 +
 drivers/staging/lustre/lustre/osc/osc_request.c|2 +
 drivers/staging/lustre/lustre/ptlrpc/pinger.c  |6 ++--
 16 files changed, 47 insertions(+), 61 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
index 0ebbde4ec8e8..172a8872e3f3 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
@@ -36,20 +36,6 @@
 
 #ifndef __LIBCFS_TIME_H__
 #define __LIBCFS_TIME_H__
-/*
- * generic time manipulation functions.
- */
-
-static inline int cfs_time_after(unsigned long t1, unsigned long t2)
-{
-   return time_before(t2, t1);
-}
-
-static inline int cfs_time_aftereq(unsigned long t1, unsigned long t2)
-{
-   return time_before_eq(t2, t1);
-}
-
 /*
  * return valid time-out based on user supplied one. Currently we only check
  * that time-out is not shorted than allowed.
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c 
b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
index 276bf486f64b..d0ce37d72571 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
@@ -1522,7 +1522,7 @@ static int kiblnd_fmr_pool_is_idle(struct kib_fmr_pool 
*fpo, unsigned long now)
return 0;
if (fpo->fpo_failed)
return 1;
-   return cfs_time_aftereq(now, fpo->fpo_deadline);
+   return time_after_eq(now, fpo->fpo_deadline);
 }
 
 static int
@@ -1850,7 +1850,7 @@ static int kiblnd_pool_is_idle(struct kib_pool *pool, 
unsigned long now)
return 0;
if (pool->po_failed)
return 1;
-   return cfs_time_aftereq(now, pool->po_deadline);
+   return time_after_eq(now, pool->po_deadline);
 }
 
 void kiblnd_pool_free_node(struct kib_pool *pool, struct list_head *node)
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h 
b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
index b18911d09e9a..ca6e09de0872 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
@@ -754,9 +754,9 @@ static inline int
 kiblnd_send_keepalive(struct kib_conn *conn)
 {
return (*kiblnd_tunables.kib_keepalive > 0) &&
-   cfs_time_after(jiffies, conn->ibc_last_send +
-  msecs_to_jiffies(*kiblnd_tunables.kib_keepalive *
-   MSEC_PER_SEC));
+   time_after(jiffies, conn->ibc_last_send +
+  msecs_to_jiffies(*kiblnd_tunables.kib_keepalive *
+   MSEC_PER_SEC));
 }
 
 static inline int
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c 
b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
index f9761d8f2e3e..563ff5c972bf 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
@@ -3141,7 +3141,7 @@ kiblnd_check_txs_locked(struct kib_conn *conn, struct 
list_head *txs)
LASSERT(tx->tx_waiting || tx->tx_sending);
}
 
-   if (cfs_time_aftereq(jiffies, tx->tx_deadline)) {
+   if (time_after_eq(jiffies, tx->tx_deadline)) {
CERROR("Timed out tx: %s, %lu seconds\n",
   kiblnd_queue2str(conn, txs),
   cfs_duration_sec(jiffies - tx->tx_deadline));
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c 
b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
index 1ace54c9b133..8ead1e02e854 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
@@ -481,7 +481,7 @@ ksocknal_process_transmit(struct 

[PATCH 11/17] staging: lustre: libcfs: discard cfs_time_shift().

2018-03-28 Thread NeilBrown
This function simply multiplies by HZ and adds jiffies.
This is simple enough to be opencoded, and doing so
makes the code easier to read.

Same for cfs_time_shift_64()

Signed-off-by: NeilBrown 
---
 .../lustre/include/linux/libcfs/libcfs_time.h  |5 
 .../lustre/include/linux/libcfs/linux/linux-time.h |5 
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c|   12 +
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c |4 ++-
 .../staging/lustre/lnet/klnds/socklnd/socklnd.c|4 ++-
 .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c |   12 +
 drivers/staging/lustre/lnet/lnet/net_fault.c   |   26 ++--
 drivers/staging/lustre/lnet/lnet/router.c  |2 +-
 drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |2 +-
 drivers/staging/lustre/lustre/ldlm/ldlm_resource.c |2 +-
 drivers/staging/lustre/lustre/llite/llite_lib.c|4 ++-
 drivers/staging/lustre/lustre/llite/lproc_llite.c  |   12 +
 drivers/staging/lustre/lustre/llite/statahead.c|2 +-
 drivers/staging/lustre/lustre/lmv/lmv_obd.c|2 +-
 drivers/staging/lustre/lustre/lov/lov_obd.c|2 +-
 drivers/staging/lustre/lustre/mdc/mdc_request.c|2 +-
 .../lustre/lustre/obdclass/lprocfs_status.c|   12 +
 .../staging/lustre/lustre/obdclass/obd_config.c|2 +-
 drivers/staging/lustre/lustre/osc/osc_request.c|2 +-
 drivers/staging/lustre/lustre/ptlrpc/pinger.c  |6 ++---
 drivers/staging/lustre/lustre/ptlrpc/service.c |2 +-
 21 files changed, 56 insertions(+), 66 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
index 7b41a129f041..0ebbde4ec8e8 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
@@ -50,11 +50,6 @@ static inline int cfs_time_aftereq(unsigned long t1, 
unsigned long t2)
return time_before_eq(t2, t1);
 }
 
-static inline unsigned long cfs_time_shift(int seconds)
-{
-   return jiffies + seconds * HZ;
-}
-
 /*
  * return valid time-out based on user supplied one. Currently we only check
  * that time-out is not shorted than allowed.
diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h 
b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
index b3a80531bd71..ff3aae2f1231 100644
--- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
+++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
@@ -65,11 +65,6 @@ static inline long cfs_duration_sec(long d)
return d / msecs_to_jiffies(MSEC_PER_SEC);
 }
 
-static inline u64 cfs_time_shift_64(int seconds)
-{
-   return get_jiffies_64() + (u64)seconds * HZ;
-}
-
 static inline int cfs_time_before_64(u64 t1, u64 t2)
 {
return (__s64)t2 - (__s64)t1 > 0;
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c 
b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
index 7df07f39b849..276bf486f64b 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
@@ -1446,7 +1446,7 @@ static int kiblnd_create_fmr_pool(struct kib_fmr_poolset 
*fps,
if (rc)
goto out_fpo;
 
-   fpo->fpo_deadline = cfs_time_shift(IBLND_POOL_DEADLINE);
+   fpo->fpo_deadline = jiffies + IBLND_POOL_DEADLINE * HZ;
fpo->fpo_owner = fps;
*pp_fpo = fpo;
 
@@ -1619,7 +1619,7 @@ int kiblnd_fmr_pool_map(struct kib_fmr_poolset *fps, 
struct kib_tx *tx,
spin_lock(>fps_lock);
version = fps->fps_version;
list_for_each_entry(fpo, >fps_pool_list, fpo_list) {
-   fpo->fpo_deadline = cfs_time_shift(IBLND_POOL_DEADLINE);
+   fpo->fpo_deadline = jiffies + IBLND_POOL_DEADLINE * HZ;
fpo->fpo_map_count++;
 
if (fpo->fpo_is_fmr) {
@@ -1743,7 +1743,7 @@ int kiblnd_fmr_pool_map(struct kib_fmr_poolset *fps, 
struct kib_tx *tx,
fps->fps_version++;
list_add_tail(>fpo_list, >fps_pool_list);
} else {
-   fps->fps_next_retry = cfs_time_shift(IBLND_POOL_RETRY);
+   fps->fps_next_retry = jiffies + IBLND_POOL_RETRY * HZ;
}
spin_unlock(>fps_lock);
 
@@ -1764,7 +1764,7 @@ static void kiblnd_init_pool(struct kib_poolset *ps, 
struct kib_pool *pool, int
 
memset(pool, 0, sizeof(*pool));
INIT_LIST_HEAD(>po_free_list);
-   pool->po_deadline = cfs_time_shift(IBLND_POOL_DEADLINE);
+   pool->po_deadline = jiffies + IBLND_POOL_DEADLINE * HZ;
pool->po_owner= ps;
pool->po_size = size;
 }
@@ -1899,7 +1899,7 @@ struct list_head *kiblnd_pool_alloc_node(struct 
kib_poolset *ps)
continue;
 
pool->po_allocated++;
-   pool->po_deadline = cfs_time_shift(IBLND_POOL_DEADLINE);
+   

[PATCH 12/17] staging: lustre: libcfs: discard cfs_time_after()

2018-03-28 Thread NeilBrown
cfs_time_after() behaves exactly like time_after()
similarly cfs_time_aftereq() matches time_after_eq()

so discard the cfs versions.

Signed-off-by: NeilBrown 
---
 .../lustre/include/linux/libcfs/libcfs_time.h  |   14 -
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c|4 +--
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h|6 ++--
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c |2 +
 .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c |   32 ++--
 drivers/staging/lustre/lnet/libcfs/tracefile.c |8 +++--
 drivers/staging/lustre/lnet/lnet/lib-move.c|4 +--
 drivers/staging/lustre/lnet/lnet/net_fault.c   |8 +++--
 drivers/staging/lustre/lnet/lnet/router.c  |6 ++--
 drivers/staging/lustre/lnet/selftest/conrpc.c  |4 +--
 drivers/staging/lustre/lnet/selftest/timer.c   |2 +
 drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c|4 +--
 drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |4 +--
 drivers/staging/lustre/lustre/osc/osc_object.c |2 +
 drivers/staging/lustre/lustre/osc/osc_request.c|2 +
 drivers/staging/lustre/lustre/ptlrpc/pinger.c  |6 ++--
 16 files changed, 47 insertions(+), 61 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
index 0ebbde4ec8e8..172a8872e3f3 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
@@ -36,20 +36,6 @@
 
 #ifndef __LIBCFS_TIME_H__
 #define __LIBCFS_TIME_H__
-/*
- * generic time manipulation functions.
- */
-
-static inline int cfs_time_after(unsigned long t1, unsigned long t2)
-{
-   return time_before(t2, t1);
-}
-
-static inline int cfs_time_aftereq(unsigned long t1, unsigned long t2)
-{
-   return time_before_eq(t2, t1);
-}
-
 /*
  * return valid time-out based on user supplied one. Currently we only check
  * that time-out is not shorted than allowed.
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c 
b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
index 276bf486f64b..d0ce37d72571 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
@@ -1522,7 +1522,7 @@ static int kiblnd_fmr_pool_is_idle(struct kib_fmr_pool 
*fpo, unsigned long now)
return 0;
if (fpo->fpo_failed)
return 1;
-   return cfs_time_aftereq(now, fpo->fpo_deadline);
+   return time_after_eq(now, fpo->fpo_deadline);
 }
 
 static int
@@ -1850,7 +1850,7 @@ static int kiblnd_pool_is_idle(struct kib_pool *pool, 
unsigned long now)
return 0;
if (pool->po_failed)
return 1;
-   return cfs_time_aftereq(now, pool->po_deadline);
+   return time_after_eq(now, pool->po_deadline);
 }
 
 void kiblnd_pool_free_node(struct kib_pool *pool, struct list_head *node)
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h 
b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
index b18911d09e9a..ca6e09de0872 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
@@ -754,9 +754,9 @@ static inline int
 kiblnd_send_keepalive(struct kib_conn *conn)
 {
return (*kiblnd_tunables.kib_keepalive > 0) &&
-   cfs_time_after(jiffies, conn->ibc_last_send +
-  msecs_to_jiffies(*kiblnd_tunables.kib_keepalive *
-   MSEC_PER_SEC));
+   time_after(jiffies, conn->ibc_last_send +
+  msecs_to_jiffies(*kiblnd_tunables.kib_keepalive *
+   MSEC_PER_SEC));
 }
 
 static inline int
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c 
b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
index f9761d8f2e3e..563ff5c972bf 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
@@ -3141,7 +3141,7 @@ kiblnd_check_txs_locked(struct kib_conn *conn, struct 
list_head *txs)
LASSERT(tx->tx_waiting || tx->tx_sending);
}
 
-   if (cfs_time_aftereq(jiffies, tx->tx_deadline)) {
+   if (time_after_eq(jiffies, tx->tx_deadline)) {
CERROR("Timed out tx: %s, %lu seconds\n",
   kiblnd_queue2str(conn, txs),
   cfs_duration_sec(jiffies - tx->tx_deadline));
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c 
b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
index 1ace54c9b133..8ead1e02e854 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
@@ -481,7 +481,7 @@ ksocknal_process_transmit(struct ksock_conn *conn, 

[PATCH 09/17] staging: lustre: cfs_time_current() -> jiffies.

2018-03-28 Thread NeilBrown
Discard cfs_time_current() and cfs_time_current64()
and use jiffies and get_jiffies_64() like the rest of the kernel.

Signed-off-by: NeilBrown 
---
 .../lustre/include/linux/libcfs/libcfs_time.h  |2 -
 .../lustre/include/linux/libcfs/linux/linux-time.h |9 
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c|   14 +++---
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c |8 ++--
 .../staging/lustre/lnet/klnds/socklnd/socklnd.c|9 ++--
 .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c |   44 ++--
 drivers/staging/lustre/lnet/libcfs/tracefile.c |6 +--
 drivers/staging/lustre/lnet/lnet/lib-move.c|4 +-
 drivers/staging/lustre/lnet/lnet/net_fault.c   |6 +--
 drivers/staging/lustre/lnet/lnet/peer.c|2 -
 drivers/staging/lustre/lnet/lnet/router.c  |6 +--
 drivers/staging/lustre/lnet/lnet/router_proc.c |4 +-
 drivers/staging/lustre/lnet/selftest/conrpc.c  |6 +--
 drivers/staging/lustre/lnet/selftest/console.c |4 +-
 drivers/staging/lustre/lnet/selftest/framework.c   |2 -
 drivers/staging/lustre/lustre/include/lustre_net.h |2 -
 drivers/staging/lustre/lustre/include/obd_class.h  |6 +--
 drivers/staging/lustre/lustre/ldlm/ldlm_lock.c |2 -
 drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c|2 -
 drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |   10 ++---
 drivers/staging/lustre/lustre/ldlm/ldlm_resource.c |2 -
 .../staging/lustre/lustre/llite/llite_internal.h   |2 -
 drivers/staging/lustre/lustre/llite/statahead.c|2 -
 drivers/staging/lustre/lustre/lov/lov_request.c|4 +-
 drivers/staging/lustre/lustre/osc/osc_cache.c  |2 -
 drivers/staging/lustre/lustre/osc/osc_object.c |4 +-
 drivers/staging/lustre/lustre/osc/osc_page.c   |4 +-
 drivers/staging/lustre/lustre/osc/osc_request.c|2 -
 drivers/staging/lustre/lustre/ptlrpc/client.c  |4 +-
 drivers/staging/lustre/lustre/ptlrpc/import.c  |2 -
 drivers/staging/lustre/lustre/ptlrpc/pinger.c  |4 +-
 drivers/staging/lustre/lustre/ptlrpc/service.c |4 +-
 32 files changed, 88 insertions(+), 96 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
index c4f25be78268..df7a3f13f3b3 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
@@ -62,7 +62,7 @@ static inline int cfs_time_aftereq(unsigned long t1, unsigned 
long t2)
 
 static inline unsigned long cfs_time_shift(int seconds)
 {
-   return cfs_time_add(cfs_time_current(), seconds * HZ);
+   return cfs_time_add(jiffies, seconds * HZ);
 }
 
 /*
diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h 
b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
index 805cb326af86..ba115e8c820f 100644
--- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
+++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
@@ -60,18 +60,11 @@
  * Generic kernel stuff
  */
 
-static inline unsigned long cfs_time_current(void)
-{
-   return jiffies;
-}
-
 static inline long cfs_duration_sec(long d)
 {
return d / msecs_to_jiffies(MSEC_PER_SEC);
 }
 
-#define cfs_time_current_64 get_jiffies_64
-
 static inline u64 cfs_time_add_64(u64 t, u64 d)
 {
return t + d;
@@ -79,7 +72,7 @@ static inline u64 cfs_time_add_64(u64 t, u64 d)
 
 static inline u64 cfs_time_shift_64(int seconds)
 {
-   return cfs_time_add_64(cfs_time_current_64(),
+   return cfs_time_add_64(get_jiffies_64(),
   seconds * HZ);
 }
 
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c 
b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
index 7ae2955c4db6..7df07f39b849 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
@@ -1043,7 +1043,7 @@ static void kiblnd_query(struct lnet_ni *ni, lnet_nid_t 
nid,
 unsigned long *when)
 {
unsigned long last_alive = 0;
-   unsigned long now = cfs_time_current();
+   unsigned long now = jiffies;
rwlock_t *glock = _data.kib_global_lock;
struct kib_peer *peer;
unsigned long flags;
@@ -1552,7 +1552,7 @@ void kiblnd_fmr_pool_unmap(struct kib_fmr *fmr, int 
status)
LIST_HEAD(zombies);
struct kib_fmr_pool *fpo = fmr->fmr_pool;
struct kib_fmr_poolset *fps;
-   unsigned long now = cfs_time_current();
+   unsigned long now = jiffies;
struct kib_fmr_pool *tmp;
int rc;
 
@@ -1726,7 +1726,7 @@ int kiblnd_fmr_pool_map(struct kib_fmr_poolset *fps, 
struct kib_tx *tx,
goto again;
}
 
-   if (time_before(cfs_time_current(), fps->fps_next_retry)) {
+   if (time_before(jiffies, fps->fps_next_retry)) {
 

[PATCH 10/17] staging: lustre: libcfs: discard cfs_time_add/sub

2018-03-28 Thread NeilBrown
cfs_time_add adds its arguments.
cfs_time_sub subtracts finds the difference.
Discard these and use '+' and '-' directly.

This change highlighted a type error.  The structure field
cr_queued_time was used to store jiffies, but was declared
as time_t (meant for seconds).  So the time is changed to
"unsigned long".

Signed-off-by: NeilBrown 
---
 .../lustre/include/linux/libcfs/libcfs_time.h  |   12 +-
 .../lustre/include/linux/libcfs/linux/linux-time.h |8 +--
 .../staging/lustre/lnet/klnds/socklnd/socklnd.c|2 +-
 .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c |   23 +++-
 drivers/staging/lustre/lnet/lnet/lib-move.c|6 ++---
 drivers/staging/lustre/lnet/lnet/router.c  |5 ++--
 drivers/staging/lustre/lnet/lnet/router_proc.c |7 +++---
 drivers/staging/lustre/lnet/selftest/conrpc.c  |4 ++-
 drivers/staging/lustre/lnet/selftest/timer.c   |2 +-
 drivers/staging/lustre/lustre/include/lustre_net.h |5 ++--
 drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c|3 +--
 drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |8 +++
 drivers/staging/lustre/lustre/osc/osc_object.c |3 +--
 drivers/staging/lustre/lustre/ptlrpc/pinger.c  |9 +++-
 drivers/staging/lustre/lustre/ptlrpc/service.c |2 +-
 15 files changed, 32 insertions(+), 67 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
index df7a3f13f3b3..7b41a129f041 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
@@ -40,16 +40,6 @@
  * generic time manipulation functions.
  */
 
-static inline unsigned long cfs_time_add(unsigned long t, long d)
-{
-   return (unsigned long)(t + d);
-}
-
-static inline unsigned long cfs_time_sub(unsigned long t1, unsigned long t2)
-{
-   return (unsigned long)(t1 - t2);
-}
-
 static inline int cfs_time_after(unsigned long t1, unsigned long t2)
 {
return time_before(t2, t1);
@@ -62,7 +52,7 @@ static inline int cfs_time_aftereq(unsigned long t1, unsigned 
long t2)
 
 static inline unsigned long cfs_time_shift(int seconds)
 {
-   return cfs_time_add(jiffies, seconds * HZ);
+   return jiffies + seconds * HZ;
 }
 
 /*
diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h 
b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
index ba115e8c820f..b3a80531bd71 100644
--- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
+++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
@@ -65,15 +65,9 @@ static inline long cfs_duration_sec(long d)
return d / msecs_to_jiffies(MSEC_PER_SEC);
 }
 
-static inline u64 cfs_time_add_64(u64 t, u64 d)
-{
-   return t + d;
-}
-
 static inline u64 cfs_time_shift_64(int seconds)
 {
-   return cfs_time_add_64(get_jiffies_64(),
-  seconds * HZ);
+   return get_jiffies_64() + (u64)seconds * HZ;
 }
 
 static inline int cfs_time_before_64(u64 t1, u64 t2)
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c 
b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
index 0efde0009a15..4546618c1c12 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
@@ -1682,7 +1682,7 @@ ksocknal_destroy_conn(struct ksock_conn *conn)
   libcfs_id2str(conn->ksnc_peer->ksnp_id), conn->ksnc_type,
   >ksnc_ipaddr, conn->ksnc_port,
   iov_iter_count(>ksnc_rx_to), 
conn->ksnc_rx_nob_left,
-  cfs_duration_sec(cfs_time_sub(jiffies, last_rcv)));
+  cfs_duration_sec(jiffies - last_rcv));
lnet_finalize(conn->ksnc_peer->ksnp_ni,
  conn->ksnc_cookie, -EIO);
break;
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c 
b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
index f97da4540b51..5b34c7c030ad 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
@@ -481,8 +481,7 @@ ksocknal_process_transmit(struct ksock_conn *conn, struct 
ksock_tx *tx)
LASSERT(conn->ksnc_tx_scheduled);
list_add_tail(>ksnc_tx_list,
  _data.ksnd_enomem_conns);
-   if (!cfs_time_aftereq(cfs_time_add(jiffies,
-  SOCKNAL_ENOMEM_RETRY),
+   if (!cfs_time_aftereq(jiffies + SOCKNAL_ENOMEM_RETRY,
   ksocknal_data.ksnd_reaper_waketime))
wake_up(_data.ksnd_reaper_waitq);
 
@@ -1777,8 +1776,7 @@ ksocknal_connect(struct ksock_route *route)
int retry_later = 0;
int rc = 0;
 
-   deadline = 

  1   2   3   4   5   6   7   8   9   10   >