Re: [kbuild-all] [PATCH v6 2/4] resource: Use list_head to link sibling resource

2018-07-09 Thread Baoquan He
On 07/10/18 at 08:59am, Ye Xiaolong wrote:
> Hi,
> 
> On 07/08, Baoquan He wrote:
> >Hi,
> >
> >On 07/05/18 at 01:00am, kbuild test robot wrote:
> >> Hi Baoquan,
> >> 
> >> I love your patch! Yet something to improve:
> >> 
> >> [auto build test ERROR on linus/master]
> >> [also build test ERROR on v4.18-rc3 next-20180704]
> >> [if your patch is applied to the wrong git tree, please drop us a note to 
> >> help improve the system]
> >
> >Thanks for telling. 
> >
> >I cloned 0day-ci/linut to my local pc.
> >https://github.com/0day-ci/linux.git
> >
> >However, I didn't find below branch. And tried to open it in web
> >broswer, also failed.
> >
> 
> Sorry for the inconvenience, 0day bot didn't push the branch to github 
> successfully,
> Just push it manually, you can have a try again.

Thanks, Xiaolong, I have applied them on top of linux-next/master, and
copy the config file attached, and run the command to reproduce as
suggested. Now I have fixed all those issues reported, will repost.

> 
> >
> >> url:
> >> https://github.com/0day-ci/linux/commits/Baoquan-He/resource-Use-list_head-to-link-sibling-resource/20180704-121402
> >> config: mips-rb532_defconfig (attached as .config)
> >> compiler: mipsel-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
> >> reproduce:
> >> wget 
> >> https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross 
> >> -O ~/bin/make.cross
> >> chmod +x ~/bin/make.cross
> >> # save the attached .config to linux build tree
> >> GCC_VERSION=7.2.0 make.cross ARCH=mips 
> >
> >I did find a old one which is for the old version 5 post.
> >
> >[bhe@linux]$ git remote -v
> >0day-ci  https://github.com/0day-ci/linux.git (fetch)
> >0day-ci  https://github.com/0day-ci/linux.git (push)
> >[bhe@dhcp-128-28 linux]$ git branch -a| grep Baoquan| grep resource
> >  
> > remotes/0day-ci/Baoquan-He/resource-Use-list_head-to-link-sibling-resource/20180612-113600
> >
> >Could you help have a look at this?
> >
> >Thanks
> >Baoquan
> >
> >> 
> >> All error/warnings (new ones prefixed by >>):
> >> 
> >> >> arch/mips/pci/pci-rc32434.c:57:11: error: initialization from 
> >> >> incompatible pointer type [-Werror=incompatible-pointer-types]
> >>  .child = _res_pci_mem2
> >>   ^
> >>arch/mips/pci/pci-rc32434.c:57:11: note: (near initialization for 
> >> 'rc32434_res_pci_mem1.child.next')
> >> >> arch/mips/pci/pci-rc32434.c:51:47: warning: missing braces around 
> >> >> initializer [-Wmissing-braces]
> >> static struct resource rc32434_res_pci_mem1 = {
> >>   ^
> >>arch/mips/pci/pci-rc32434.c:60:47: warning: missing braces around 
> >> initializer [-Wmissing-braces]
> >> static struct resource rc32434_res_pci_mem2 = {
> >>   ^
> >>cc1: some warnings being treated as errors
> >> 
> >> vim +57 arch/mips/pci/pci-rc32434.c
> >> 
> >> 73b4390f Ralf Baechle 2008-07-16  50  
> >> 73b4390f Ralf Baechle 2008-07-16 @51  static struct resource 
> >> rc32434_res_pci_mem1 = {
> >> 73b4390f Ralf Baechle 2008-07-16  52   .name = "PCI MEM1",
> >> 73b4390f Ralf Baechle 2008-07-16  53   .start = 0x5000,
> >> 73b4390f Ralf Baechle 2008-07-16  54   .end = 0x5FFF,
> >> 73b4390f Ralf Baechle 2008-07-16  55   .flags = IORESOURCE_MEM,
> >> 73b4390f Ralf Baechle 2008-07-16  56   .sibling = NULL,
> >> 73b4390f Ralf Baechle 2008-07-16 @57   .child = _res_pci_mem2
> >> 73b4390f Ralf Baechle 2008-07-16  58  };
> >> 73b4390f Ralf Baechle 2008-07-16  59  
> >> 
> >> :: The code at line 57 was first introduced by commit
> >> :: 73b4390fb23456964201abda79f1210fe337d01a [MIPS] Routerboard 532: 
> >> Support for base system
> >> 
> >> :: TO: Ralf Baechle 
> >> :: CC: Ralf Baechle 
> >> 
> >> ---
> >> 0-DAY kernel test infrastructureOpen Source Technology 
> >> Center
> >> https://lists.01.org/pipermail/kbuild-all   Intel 
> >> Corporation
> >
> >
> >___
> >kbuild-all mailing list
> >kbuild-...@lists.01.org
> >https://lists.01.org/mailman/listinfo/kbuild-all
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [kbuild-all] [PATCH v6 2/4] resource: Use list_head to link sibling resource

2018-07-09 Thread Ye Xiaolong
Hi,

On 07/08, Baoquan He wrote:
>Hi,
>
>On 07/05/18 at 01:00am, kbuild test robot wrote:
>> Hi Baoquan,
>> 
>> I love your patch! Yet something to improve:
>> 
>> [auto build test ERROR on linus/master]
>> [also build test ERROR on v4.18-rc3 next-20180704]
>> [if your patch is applied to the wrong git tree, please drop us a note to 
>> help improve the system]
>
>Thanks for telling. 
>
>I cloned 0day-ci/linut to my local pc.
>https://github.com/0day-ci/linux.git
>
>However, I didn't find below branch. And tried to open it in web
>broswer, also failed.
>

Sorry for the inconvenience, 0day bot didn't push the branch to github 
successfully,
Just push it manually, you can have a try again.

Thanks,
Xiaolong


>
>> url:
>> https://github.com/0day-ci/linux/commits/Baoquan-He/resource-Use-list_head-to-link-sibling-resource/20180704-121402
>> config: mips-rb532_defconfig (attached as .config)
>> compiler: mipsel-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
>> reproduce:
>> wget 
>> https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
>> ~/bin/make.cross
>> chmod +x ~/bin/make.cross
>> # save the attached .config to linux build tree
>> GCC_VERSION=7.2.0 make.cross ARCH=mips 
>
>I did find a old one which is for the old version 5 post.
>
>[bhe@linux]$ git remote -v
>0day-cihttps://github.com/0day-ci/linux.git (fetch)
>0day-cihttps://github.com/0day-ci/linux.git (push)
>[bhe@dhcp-128-28 linux]$ git branch -a| grep Baoquan| grep resource
>  
> remotes/0day-ci/Baoquan-He/resource-Use-list_head-to-link-sibling-resource/20180612-113600
>
>Could you help have a look at this?
>
>Thanks
>Baoquan
>
>> 
>> All error/warnings (new ones prefixed by >>):
>> 
>> >> arch/mips/pci/pci-rc32434.c:57:11: error: initialization from 
>> >> incompatible pointer type [-Werror=incompatible-pointer-types]
>>  .child = _res_pci_mem2
>>   ^
>>arch/mips/pci/pci-rc32434.c:57:11: note: (near initialization for 
>> 'rc32434_res_pci_mem1.child.next')
>> >> arch/mips/pci/pci-rc32434.c:51:47: warning: missing braces around 
>> >> initializer [-Wmissing-braces]
>> static struct resource rc32434_res_pci_mem1 = {
>>   ^
>>arch/mips/pci/pci-rc32434.c:60:47: warning: missing braces around 
>> initializer [-Wmissing-braces]
>> static struct resource rc32434_res_pci_mem2 = {
>>   ^
>>cc1: some warnings being treated as errors
>> 
>> vim +57 arch/mips/pci/pci-rc32434.c
>> 
>> 73b4390f Ralf Baechle 2008-07-16  50  
>> 73b4390f Ralf Baechle 2008-07-16 @51  static struct resource 
>> rc32434_res_pci_mem1 = {
>> 73b4390f Ralf Baechle 2008-07-16  52 .name = "PCI MEM1",
>> 73b4390f Ralf Baechle 2008-07-16  53 .start = 0x5000,
>> 73b4390f Ralf Baechle 2008-07-16  54 .end = 0x5FFF,
>> 73b4390f Ralf Baechle 2008-07-16  55 .flags = IORESOURCE_MEM,
>> 73b4390f Ralf Baechle 2008-07-16  56 .sibling = NULL,
>> 73b4390f Ralf Baechle 2008-07-16 @57 .child = _res_pci_mem2
>> 73b4390f Ralf Baechle 2008-07-16  58  };
>> 73b4390f Ralf Baechle 2008-07-16  59  
>> 
>> :: The code at line 57 was first introduced by commit
>> :: 73b4390fb23456964201abda79f1210fe337d01a [MIPS] Routerboard 532: 
>> Support for base system
>> 
>> :: TO: Ralf Baechle 
>> :: CC: Ralf Baechle 
>> 
>> ---
>> 0-DAY kernel test infrastructureOpen Source Technology Center
>> https://lists.01.org/pipermail/kbuild-all   Intel Corporation
>
>
>___
>kbuild-all mailing list
>kbuild-...@lists.01.org
>https://lists.01.org/mailman/listinfo/kbuild-all
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v6 08/17] media: imx: csi: Register a subdev notifier

2018-07-09 Thread Steve Longerbeam
Parse neighbor remote devices on the CSI port, and add them to a subdev
notifier, by calling v4l2_async_notifier_parse_fwnode_endpoints_by_port()
using the CSI's port id. And register the subdev notifier for the CSI.

Signed-off-by: Steve Longerbeam 
---
Changes since v5:
- add call to v4l2_async_notifier_init().
Changes since v4:
- none
Changes since v3:
- v4l2_async_register_fwnode_subdev() no longer supports parsing
  port sub-devices, so call
  v4l2_async_notifier_parse_fwnode_endpoints_by_port() directly.
---
 drivers/staging/media/imx/imx-media-csi.c | 57 ++-
 1 file changed, 56 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/media/imx/imx-media-csi.c 
b/drivers/staging/media/imx/imx-media-csi.c
index 4647206..19ef377 100644
--- a/drivers/staging/media/imx/imx-media-csi.c
+++ b/drivers/staging/media/imx/imx-media-csi.c
@@ -1780,6 +1780,61 @@ static const struct v4l2_subdev_internal_ops 
csi_internal_ops = {
.unregistered = csi_unregistered,
 };
 
+static int imx_csi_parse_endpoint(struct device *dev,
+ struct v4l2_fwnode_endpoint *vep,
+ struct v4l2_async_subdev *asd)
+{
+   return fwnode_device_is_available(asd->match.fwnode) ? 0 : -EINVAL;
+}
+
+static int imx_csi_async_register(struct csi_priv *priv)
+{
+   struct v4l2_async_notifier *notifier;
+   struct fwnode_handle *fwnode;
+   unsigned int port;
+   int ret;
+
+   notifier = kzalloc(sizeof(*notifier), GFP_KERNEL);
+   if (!notifier)
+   return -ENOMEM;
+
+   v4l2_async_notifier_init(notifier);
+
+   fwnode = dev_fwnode(priv->dev);
+
+   /* get this CSI's port id */
+   ret = fwnode_property_read_u32(fwnode, "reg", );
+   if (ret < 0)
+   goto out_free;
+
+   ret = v4l2_async_notifier_parse_fwnode_endpoints_by_port(
+   priv->dev->parent, notifier, sizeof(struct v4l2_async_subdev),
+   port, imx_csi_parse_endpoint);
+   if (ret < 0)
+   goto out_cleanup;
+
+   ret = v4l2_async_subdev_notifier_register(>sd, notifier);
+   if (ret < 0)
+   goto out_cleanup;
+
+   ret = v4l2_async_register_subdev(>sd);
+   if (ret < 0)
+   goto out_unregister;
+
+   priv->sd.subdev_notifier = notifier;
+
+   return 0;
+
+out_unregister:
+   v4l2_async_notifier_unregister(notifier);
+out_cleanup:
+   v4l2_async_notifier_cleanup(notifier);
+out_free:
+   kfree(notifier);
+
+   return ret;
+}
+
 static int imx_csi_probe(struct platform_device *pdev)
 {
struct ipu_client_platformdata *pdata;
@@ -1849,7 +1904,7 @@ static int imx_csi_probe(struct platform_device *pdev)
goto free;
}
 
-   ret = v4l2_async_register_subdev(>sd);
+   ret = imx_csi_async_register(priv);
if (ret)
goto free;
 
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v6 10/17] media: staging/imx: of: Remove recursive graph walk

2018-07-09 Thread Steve Longerbeam
After moving to subdev notifiers, it's no longer necessary to recursively
walk the OF graph, because the subdev notifiers will discover and add
devices from the graph for us.

So the recursive of_parse_subdev() function is gone, replaced with
of_add_csi() which adds only the CSI port fwnodes to the imx-media
root notifier.

Signed-off-by: Steve Longerbeam 
---
 drivers/staging/media/imx/imx-media-of.c | 106 +++
 1 file changed, 8 insertions(+), 98 deletions(-)

diff --git a/drivers/staging/media/imx/imx-media-of.c 
b/drivers/staging/media/imx/imx-media-of.c
index acde372..1c91754 100644
--- a/drivers/staging/media/imx/imx-media-of.c
+++ b/drivers/staging/media/imx/imx-media-of.c
@@ -20,74 +20,19 @@
 #include 
 #include "imx-media.h"
 
-static int of_get_port_count(const struct device_node *np)
+static int of_add_csi(struct imx_media_dev *imxmd, struct device_node *csi_np)
 {
-   struct device_node *ports, *child;
-   int num = 0;
-
-   /* check if this node has a ports subnode */
-   ports = of_get_child_by_name(np, "ports");
-   if (ports)
-   np = ports;
-
-   for_each_child_of_node(np, child)
-   if (of_node_cmp(child->name, "port") == 0)
-   num++;
-
-   of_node_put(ports);
-   return num;
-}
-
-/*
- * find the remote device node given local endpoint node
- */
-static bool of_get_remote(struct device_node *epnode,
- struct device_node **remote_node)
-{
-   struct device_node *rp, *rpp;
-   struct device_node *remote;
-   bool is_csi_port;
-
-   rp = of_graph_get_remote_port(epnode);
-   rpp = of_graph_get_remote_port_parent(epnode);
-
-   if (of_device_is_compatible(rpp, "fsl,imx6q-ipu")) {
-   /* the remote is one of the CSI ports */
-   remote = rp;
-   of_node_put(rpp);
-   is_csi_port = true;
-   } else {
-   remote = rpp;
-   of_node_put(rp);
-   is_csi_port = false;
-   }
-
-   if (!of_device_is_available(remote)) {
-   of_node_put(remote);
-   *remote_node = NULL;
-   } else {
-   *remote_node = remote;
-   }
-
-   return is_csi_port;
-}
-
-static int
-of_parse_subdev(struct imx_media_dev *imxmd, struct device_node *sd_np,
-   bool is_csi_port)
-{
-   int i, num_ports, ret;
+   int ret;
 
-   if (!of_device_is_available(sd_np)) {
+   if (!of_device_is_available(csi_np)) {
dev_dbg(imxmd->md.dev, "%s: %s not enabled\n", __func__,
-   sd_np->name);
+   csi_np->name);
/* unavailable is not an error */
return 0;
}
 
-   /* register this subdev with async notifier */
-   ret = imx_media_add_async_subdev(imxmd, of_fwnode_handle(sd_np),
-NULL);
+   /* add CSI fwnode to async notifier */
+   ret = imx_media_add_async_subdev(imxmd, of_fwnode_handle(csi_np), NULL);
if (ret) {
if (ret == -EEXIST) {
/* already added, everything is fine */
@@ -98,42 +43,7 @@ of_parse_subdev(struct imx_media_dev *imxmd, struct 
device_node *sd_np,
return ret;
}
 
-   /*
-* the ipu-csi has one sink port. The source pads are not
-* represented in the device tree by port nodes, but are
-* described by the internal pads and links later.
-*/
-   num_ports = is_csi_port ? 1 : of_get_port_count(sd_np);
-
-   for (i = 0; i < num_ports; i++) {
-   struct device_node *epnode = NULL, *port, *remote_np;
-
-   port = is_csi_port ? sd_np : of_graph_get_port_by_id(sd_np, i);
-   if (!port)
-   continue;
-
-   for_each_child_of_node(port, epnode) {
-   bool remote_is_csi;
-
-   remote_is_csi = of_get_remote(epnode, _np);
-   if (!remote_np)
-   continue;
-
-   ret = of_parse_subdev(imxmd, remote_np, remote_is_csi);
-   of_node_put(remote_np);
-   if (ret)
-   break;
-   }
-
-   if (port != sd_np)
-   of_node_put(port);
-   if (ret) {
-   of_node_put(epnode);
-   break;
-   }
-   }
-
-   return ret;
+   return 0;
 }
 
 int imx_media_add_of_subdevs(struct imx_media_dev *imxmd,
@@ -147,7 +57,7 @@ int imx_media_add_of_subdevs(struct imx_media_dev *imxmd,
if (!csi_np)
break;
 
-   ret = of_parse_subdev(imxmd, csi_np, true);
+   ret = of_add_csi(imxmd, csi_np);
of_node_put(csi_np);
if (ret)

[PATCH v6 12/17] media: staging/imx: Rename root notifier

2018-07-09 Thread Steve Longerbeam
Rename the imx-media root async notifier from "subdev_notifier" to
simply "notifier", so as not to confuse it with true subdev notifiers.
No functional changes.

Signed-off-by: Steve Longerbeam 
---
 drivers/staging/media/imx/imx-media-dev.c | 14 +++---
 drivers/staging/media/imx/imx-media.h |  2 +-
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/media/imx/imx-media-dev.c 
b/drivers/staging/media/imx/imx-media-dev.c
index ae87c81..982e455 100644
--- a/drivers/staging/media/imx/imx-media-dev.c
+++ b/drivers/staging/media/imx/imx-media-dev.c
@@ -29,7 +29,7 @@
 
 static inline struct imx_media_dev *notifier2dev(struct v4l2_async_notifier *n)
 {
-   return container_of(n, struct imx_media_dev, subdev_notifier);
+   return container_of(n, struct imx_media_dev, notifier);
 }
 
 /*
@@ -113,7 +113,7 @@ int imx_media_add_async_subdev(struct imx_media_dev *imxmd,
 
list_add_tail(>list, >asd_list);
 
-   imxmd->subdev_notifier.num_subdevs++;
+   imxmd->notifier.num_subdevs++;
 
dev_dbg(imxmd->md.dev, "%s: added %s, match type %s\n",
__func__, np ? np->name : devname, np ? "FWNODE" : "DEVNAME");
@@ -532,7 +532,7 @@ static int imx_media_probe(struct platform_device *pdev)
goto unreg_dev;
}
 
-   num_subdevs = imxmd->subdev_notifier.num_subdevs;
+   num_subdevs = imxmd->notifier.num_subdevs;
 
/* no subdevs? just bail */
if (num_subdevs == 0) {
@@ -552,10 +552,10 @@ static int imx_media_probe(struct platform_device *pdev)
subdevs[i++] = >asd;
 
/* prepare the async subdev notifier and register it */
-   imxmd->subdev_notifier.subdevs = subdevs;
-   imxmd->subdev_notifier.ops = _media_subdev_ops;
+   imxmd->notifier.subdevs = subdevs;
+   imxmd->notifier.ops = _media_subdev_ops;
ret = v4l2_async_notifier_register(>v4l2_dev,
-  >subdev_notifier);
+  >notifier);
if (ret) {
v4l2_err(>v4l2_dev,
 "v4l2_async_notifier_register failed with %d\n", ret);
@@ -580,7 +580,7 @@ static int imx_media_remove(struct platform_device *pdev)
 
v4l2_info(>v4l2_dev, "Removing imx-media\n");
 
-   v4l2_async_notifier_unregister(>subdev_notifier);
+   v4l2_async_notifier_unregister(>notifier);
imx_media_remove_internal_subdevs(imxmd);
v4l2_device_unregister(>v4l2_dev);
media_device_unregister(>md);
diff --git a/drivers/staging/media/imx/imx-media.h 
b/drivers/staging/media/imx/imx-media.h
index 57bd094..227b79c 100644
--- a/drivers/staging/media/imx/imx-media.h
+++ b/drivers/staging/media/imx/imx-media.h
@@ -150,7 +150,7 @@ struct imx_media_dev {
 
/* for async subdev registration */
struct list_head asd_list;
-   struct v4l2_async_notifier subdev_notifier;
+   struct v4l2_async_notifier notifier;
 };
 
 enum codespace_sel {
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v6 14/17] media: staging/imx: TODO: Remove one assumption about OF graph parsing

2018-07-09 Thread Steve Longerbeam
The move to subdev notifiers fixes one assumption of OF graph parsing.
If a subdevice has non-video related ports, the subdev driver knows not
to follow those ports when adding remote devices to its subdev notifier.

Signed-off-by: Steve Longerbeam 
---
 drivers/staging/media/imx/TODO | 29 +++--
 1 file changed, 7 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/media/imx/TODO b/drivers/staging/media/imx/TODO
index 9eb7326..aeeb154 100644
--- a/drivers/staging/media/imx/TODO
+++ b/drivers/staging/media/imx/TODO
@@ -17,29 +17,15 @@
   decided whether this feature is useful enough to make it generally
   available by exporting to v4l2-core.
 
-- The OF graph is walked at probe time to form the list of fwnodes to
-  be passed to v4l2_async_notifier_register(), starting from the IPU
-  CSI ports. And after all async subdevices have been bound,
-  v4l2_fwnode_parse_link() is used to form the media links between
-  the entities discovered by walking the OF graph.
+- After all async subdevices have been bound, v4l2_fwnode_parse_link()
+  is used to form the media links between the devices discovered in
+  the OF graph.
 
   While this approach allows support for arbitrary OF graphs, there
   are some assumptions for this to work:
 
-  1. All port parent nodes reachable in the graph from the IPU CSI
- ports bind to V4L2 async subdevice drivers.
-
- If a device has mixed-use ports such as video plus audio, the
- endpoints from the audio ports are followed to devices that must
- bind to V4L2 subdevice drivers, and not for example, to an ALSA
- driver or a non-V4L2 media driver. If the device were bound to
- such a driver, imx-media would never get an async completion
- notification because the device fwnode was added to the async
- list, but the driver does not interface with the V4L2 async
- framework.
-
-  2. Every port reachable in the graph is treated as a media pad,
- owned by the V4L2 subdevice that is bound to the port's parent.
+  1. If a port owned by a device in the graph has endpoint nodes, the
+ port is treated as a media pad.
 
  This presents problems for devices that don't make this port = pad
  assumption. Examples are SMIAPP compatible cameras which define only
@@ -54,9 +40,8 @@
  possible long-term solution is to implement a subdev API that
  maps a port id to a media pad index.
 
-  3. Every endpoint of a port reachable in the graph is treated as
- a media link, between V4L2 subdevices that are bound to the
- port parents of the local and remote endpoints.
+  2. Every endpoint of a port owned by a device in the graph is treated
+ as a media link.
 
  Which means a port must not contain mixed-use endpoints, they
  must all refer to media links between V4L2 subdevices.
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v6 13/17] media: staging/imx: Switch to v4l2_async_notifier_add_*_subdev

2018-07-09 Thread Steve Longerbeam
Switch to v4l2_async_notifier_add_*_subdev() when adding async subdevs
to the imx-media root notifier. This removes the need to check for
an already added asd, since v4l2_async_notifier_add_*_subdev() does this
check. Also no need to allocate a subdevs array when registering the
root notifier, or keeping an internal master asd_list, since this is
moved to the notifier's asd_list.

Signed-off-by: Steve Longerbeam 
---
Changes since v5:
- remove reference to notifier.num_subdevs and call
  v4l2_async_notifier_init(). Suggested by Sakari Ailus.
---
 drivers/staging/media/imx/imx-media-dev.c | 121 ++
 drivers/staging/media/imx/imx-media-internal-sd.c |   5 +-
 drivers/staging/media/imx/imx-media.h |   4 +-
 3 files changed, 36 insertions(+), 94 deletions(-)

diff --git a/drivers/staging/media/imx/imx-media-dev.c 
b/drivers/staging/media/imx/imx-media-dev.c
index 982e455..659420e 100644
--- a/drivers/staging/media/imx/imx-media-dev.c
+++ b/drivers/staging/media/imx/imx-media-dev.c
@@ -33,43 +33,10 @@ static inline struct imx_media_dev *notifier2dev(struct 
v4l2_async_notifier *n)
 }
 
 /*
- * Find an asd by fwnode or device name. This is called during
- * driver load to form the async subdev list and bind them.
- */
-static struct v4l2_async_subdev *
-find_async_subdev(struct imx_media_dev *imxmd,
- struct fwnode_handle *fwnode,
- const char *devname)
-{
-   struct imx_media_async_subdev *imxasd;
-   struct v4l2_async_subdev *asd;
-
-   list_for_each_entry(imxasd, >asd_list, list) {
-   asd = >asd;
-   switch (asd->match_type) {
-   case V4L2_ASYNC_MATCH_FWNODE:
-   if (fwnode && asd->match.fwnode == fwnode)
-   return asd;
-   break;
-   case V4L2_ASYNC_MATCH_DEVNAME:
-   if (devname && !strcmp(asd->match.device_name,
-  devname))
-   return asd;
-   break;
-   default:
-   break;
-   }
-   }
-
-   return NULL;
-}
-
-
-/*
- * Adds a subdev to the async subdev list. If fwnode is non-NULL, adds
- * the async as a V4L2_ASYNC_MATCH_FWNODE match type, otherwise as
- * a V4L2_ASYNC_MATCH_DEVNAME match type using the dev_name of the
- * given platform_device. This is called during driver load when
+ * Adds a subdev to the root notifier's async subdev list. If fwnode is
+ * non-NULL, adds the async as a V4L2_ASYNC_MATCH_FWNODE match type,
+ * otherwise as a V4L2_ASYNC_MATCH_DEVNAME match type using the dev_name
+ * of the given platform_device. This is called during driver load when
  * forming the async subdev list.
  */
 int imx_media_add_async_subdev(struct imx_media_dev *imxmd,
@@ -80,47 +47,34 @@ int imx_media_add_async_subdev(struct imx_media_dev *imxmd,
struct imx_media_async_subdev *imxasd;
struct v4l2_async_subdev *asd;
const char *devname = NULL;
-   int ret = 0;
-
-   mutex_lock(>mutex);
+   int ret;
 
-   if (pdev)
+   if (fwnode) {
+   asd = v4l2_async_notifier_add_fwnode_subdev(
+   >notifier, fwnode, sizeof(*imxasd));
+   } else {
devname = dev_name(>dev);
-
-   /* return -EEXIST if this asd already added */
-   if (find_async_subdev(imxmd, fwnode, devname)) {
-   dev_dbg(imxmd->md.dev, "%s: already added %s\n",
-   __func__, np ? np->name : devname);
-   ret = -EEXIST;
-   goto out;
+   asd = v4l2_async_notifier_add_devname_subdev(
+   >notifier, devname, sizeof(*imxasd));
}
 
-   imxasd = devm_kzalloc(imxmd->md.dev, sizeof(*imxasd), GFP_KERNEL);
-   if (!imxasd) {
-   ret = -ENOMEM;
-   goto out;
-   }
-   asd = >asd;
-
-   if (fwnode) {
-   asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
-   asd->match.fwnode = fwnode;
-   } else {
-   asd->match_type = V4L2_ASYNC_MATCH_DEVNAME;
-   asd->match.device_name = devname;
-   imxasd->pdev = pdev;
+   if (IS_ERR(asd)) {
+   ret = PTR_ERR(asd);
+   if (ret == -EEXIST)
+   dev_dbg(imxmd->md.dev, "%s: already added %s\n",
+   __func__, np ? np->name : devname);
+   return ret;
}
 
-   list_add_tail(>list, >asd_list);
+   imxasd = to_imx_media_asd(asd);
 
-   imxmd->notifier.num_subdevs++;
+   if (devname)
+   imxasd->pdev = pdev;
 
dev_dbg(imxmd->md.dev, "%s: added %s, match type %s\n",
__func__, np ? np->name : devname, np ? "FWNODE" : "DEVNAME");
 
-out:
-   mutex_unlock(>mutex);
-   return ret;
+   return 0;
 }
 
 /*
@@ -483,10 +437,8 @@ static 

[PATCH v6 09/17] media: imx: mipi csi-2: Register a subdev notifier

2018-07-09 Thread Steve Longerbeam
Parse neighbor remote devices on the MIPI CSI-2 input port, add
them to a subdev notifier, and register the subdev notifier for the
MIPI CSI-2 receiver, by calling v4l2_async_register_fwnode_subdev().

csi2_parse_endpoints() is modified to be the parse_endpoint callback.

Signed-off-by: Steve Longerbeam 
---
 drivers/staging/media/imx/imx6-mipi-csi2.c | 31 ++
 1 file changed, 14 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/media/imx/imx6-mipi-csi2.c 
b/drivers/staging/media/imx/imx6-mipi-csi2.c
index ceeeb30..94eb9a1 100644
--- a/drivers/staging/media/imx/imx6-mipi-csi2.c
+++ b/drivers/staging/media/imx/imx6-mipi-csi2.c
@@ -551,35 +551,34 @@ static const struct v4l2_subdev_internal_ops 
csi2_internal_ops = {
.registered = csi2_registered,
 };
 
-static int csi2_parse_endpoints(struct csi2_dev *csi2)
+static int csi2_parse_endpoint(struct device *dev,
+  struct v4l2_fwnode_endpoint *vep,
+  struct v4l2_async_subdev *asd)
 {
-   struct device_node *node = csi2->dev->of_node;
-   struct device_node *epnode;
-   struct v4l2_fwnode_endpoint ep;
+   struct v4l2_subdev *sd = dev_get_drvdata(dev);
+   struct csi2_dev *csi2 = sd_to_dev(sd);
 
-   epnode = of_graph_get_endpoint_by_regs(node, 0, -1);
-   if (!epnode) {
-   v4l2_err(>sd, "failed to get sink endpoint node\n");
+   if (!fwnode_device_is_available(asd->match.fwnode)) {
+   v4l2_err(>sd, "remote is not available\n");
return -EINVAL;
}
 
-   v4l2_fwnode_endpoint_parse(of_fwnode_handle(epnode), );
-   of_node_put(epnode);
-
-   if (ep.bus_type != V4L2_MBUS_CSI2) {
+   if (vep->bus_type != V4L2_MBUS_CSI2) {
v4l2_err(>sd, "invalid bus type, must be MIPI CSI2\n");
return -EINVAL;
}
 
-   csi2->bus = ep.bus.mipi_csi2;
+   csi2->bus = vep->bus.mipi_csi2;
 
dev_dbg(csi2->dev, "data lanes: %d\n", csi2->bus.num_data_lanes);
dev_dbg(csi2->dev, "flags: 0x%08x\n", csi2->bus.flags);
+
return 0;
 }
 
 static int csi2_probe(struct platform_device *pdev)
 {
+   unsigned int sink_port = 0;
struct csi2_dev *csi2;
struct resource *res;
int ret;
@@ -601,10 +600,6 @@ static int csi2_probe(struct platform_device *pdev)
csi2->sd.entity.function = MEDIA_ENT_F_VID_IF_BRIDGE;
csi2->sd.grp_id = IMX_MEDIA_GRP_ID_CSI2;
 
-   ret = csi2_parse_endpoints(csi2);
-   if (ret)
-   return ret;
-
csi2->pllref_clk = devm_clk_get(>dev, "ref");
if (IS_ERR(csi2->pllref_clk)) {
v4l2_err(>sd, "failed to get pll reference clock\n");
@@ -654,7 +649,9 @@ static int csi2_probe(struct platform_device *pdev)
 
platform_set_drvdata(pdev, >sd);
 
-   ret = v4l2_async_register_subdev(>sd);
+   ret = v4l2_async_register_fwnode_subdev(
+   >sd, sizeof(struct v4l2_async_subdev),
+   _port, 1, csi2_parse_endpoint);
if (ret)
goto dphy_off;
 
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v6 11/17] media: staging/imx: Loop through all registered subdevs for media links

2018-07-09 Thread Steve Longerbeam
The root imx-media notifier no longer sees all bound subdevices because
some of them will be bound to subdev notifiers. So imx_media_create_links()
now needs to loop through all subdevices registered with the v4l2-device,
not just the ones in the root notifier's done list. This should be safe
because imx_media_create_of_links() checks if a fwnode link already
exists before creating.

Signed-off-by: Steve Longerbeam 
---
 drivers/staging/media/imx/imx-media-dev.c | 16 ++--
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/media/imx/imx-media-dev.c 
b/drivers/staging/media/imx/imx-media-dev.c
index b0be80f..ae87c81 100644
--- a/drivers/staging/media/imx/imx-media-dev.c
+++ b/drivers/staging/media/imx/imx-media-dev.c
@@ -175,7 +175,7 @@ static int imx_media_subdev_bound(struct 
v4l2_async_notifier *notifier,
 }
 
 /*
- * create the media links for all subdevs that registered async.
+ * Create the media links for all subdevs that registered.
  * Called after all async subdevs have bound.
  */
 static int imx_media_create_links(struct v4l2_async_notifier *notifier)
@@ -184,14 +184,7 @@ static int imx_media_create_links(struct 
v4l2_async_notifier *notifier)
struct v4l2_subdev *sd;
int ret;
 
-   /*
-* Only links are created between subdevices that are known
-* to the async notifier. If there are other non-async subdevices,
-* they were created internally by some subdevice (smiapp is one
-* example). In those cases it is expected the subdevice is
-* responsible for creating those internal links.
-*/
-   list_for_each_entry(sd, >done, async_list) {
+   list_for_each_entry(sd, >v4l2_dev.subdevs, list) {
switch (sd->grp_id) {
case IMX_MEDIA_GRP_ID_VDIC:
case IMX_MEDIA_GRP_ID_IC_PRP:
@@ -211,7 +204,10 @@ static int imx_media_create_links(struct 
v4l2_async_notifier *notifier)
imx_media_create_csi_of_links(imxmd, sd);
break;
default:
-   /* this is an external fwnode subdev */
+   /*
+* if this subdev has fwnode links, create media
+* links for them.
+*/
imx_media_create_of_links(imxmd, sd);
break;
}
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH net] hv_netvsc: Fix napi reschedule while receive completion is busy

2018-07-09 Thread Stephen Hemminger
On Mon,  9 Jul 2018 16:43:19 +
Haiyang Zhang  wrote:

> From: Haiyang Zhang 
> 
> If out ring is full temporarily and receive completion cannot go out,
> we may still need to reschedule napi if other conditions are met.
> Otherwise the napi poll might be stopped forever, and cause network
> disconnect.
> 
> Fixes: 7426b1a51803 ("netvsc: optimize receive completions")
> Signed-off-by: Haiyang Zhang 

Maybe call reschedule?

diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index 8e9d0ee1572b..b5e92342e422 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -1285,14 +1285,20 @@ int netvsc_poll(struct napi_struct *napi, int budget)
nvchan->desc = hv_pkt_iter_next(channel, nvchan->desc);
}
 
-   /* If send of pending receive completions suceeded
-*   and did not exhaust NAPI budget this time
+   /* If all the receive completions could not be sent,
+* then we want to be scheduled again.
+*/
+   if (unlikely(send_recv_completions(ndev, net_device, nvchan))) {
+   napi_reschedule(napi);
+   goto out;
+   }
+
+   /* if did not exhaust NAPI budget this time
 *   and not doing busy poll
 * then re-enable host interrupts
 * and reschedule if ring is not empty.
 */
-   if (send_recv_completions(ndev, net_device, nvchan) == 0 &&
-   work_done < budget &&
+   if (work_done < budget &&
napi_complete_done(napi, work_done) &&
hv_end_read(>inbound) &&
napi_schedule_prep(napi)) {
@@ -1300,6 +1306,7 @@ int netvsc_poll(struct napi_struct *napi, int budget)
__napi_schedule(napi);
}
 
+out:
/* Driver may overshoot since multiple packets per descriptor */
return min(work_done, budget);
 }


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 23/23] staging: mt7621-pci: factor out mt7621_pci_init_gpios function

2018-07-09 Thread Sergio Paracuellos
In driver probe function there are some ugly initialization to
use gpios. Factor out to mt7621_pci_init_gpios function making
use of readl and writel to read and write memory.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-pci/pci-mt7621.c | 35 +++--
 1 file changed, 25 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c 
b/drivers/staging/mt7621-pci/pci-mt7621.c
index abfa589..94f3554 100644
--- a/drivers/staging/mt7621-pci/pci-mt7621.c
+++ b/drivers/staging/mt7621-pci/pci-mt7621.c
@@ -462,6 +462,26 @@ static void mt7621_pci_configure(u8 controller)
write_config(controller, 0x70c, val);
 }
 
+static void mt7621_pci_init_gpios(void)
+{
+   u32 val = readl((u32 *)0xbe60);
+
+   val &= ~(0x3 << 10 | 0x3 << 3);
+   val |= (0x1 << 10 | 0x1 << 3);
+   writel(val, (u32 *)0xbe60);
+   mdelay(100);
+   val = readl((u32 *)0xbe000600);
+   /* use GPIO19/GPIO8/GPIO7 (PERST_N/UART_RXD3/UART_TXD3) */
+   val |= (0x1 << 19 | 0x1 << 8 | 0x1 << 7);
+   writel(val, (u32 *)0xbe000600);
+   mdelay(100);
+   val = readl((u32 *)0xbe000620);
+   /* clear DATA */
+   val &= ~(0x1 << 19 | 0x1 << 8 | 0x1 << 7);
+   writel(val, (u32 *)0xbe000620);
+   mdelay(100);
+}
+
 static int mt7621_pci_probe(struct platform_device *pdev)
 {
int i;
@@ -477,14 +497,7 @@ static int mt7621_pci_probe(struct platform_device *pdev)
val = (RALINK_PCIE0_RST | RALINK_PCIE1_RST | RALINK_PCIE2_RST);
mt7621_pcie_assert_sysrst(val);
 
-   *(unsigned int *)(0xbe60) &= ~(0x3<<10 | 0x3<<3);
-   *(unsigned int *)(0xbe60) |= 0x1<<10 | 0x1<<3;
-   mdelay(100);
-   *(unsigned int *)(0xbe000600) |= 0x1<<19 | 0x1<<8 | 0x1<<7; // use 
GPIO19/GPIO8/GPIO7 (PERST_N/UART_RXD3/UART_TXD3)
-   mdelay(100);
-   *(unsigned int *)(0xbe000620) &= ~(0x1<<19 | 0x1<<8 | 0x1<<7);  
// clear DATA
-
-   mdelay(100);
+   mt7621_pci_init_gpios();
 
val = (RALINK_PCIE0_RST | RALINK_PCIE1_RST | RALINK_PCIE2_RST);
mt7621_pcie_deassert_sysrst(val);
@@ -509,10 +522,12 @@ static int mt7621_pci_probe(struct platform_device *pdev)
rt_sysc_m32(RALINK_PCIE_RST, 0, RALINK_RSTCTRL);
 
/* Use GPIO control instead of PERST_N */
-   *(unsigned int *)(0xbe000620) |= 0x1<<19 | 0x1<<8 | 0x1<<7; 
// set DATA
+   val = readl((u32 *)0xbe000620);
+   /* set DATA */
+   val |= (0x1 << 19 | 0x1 << 8 | 0x1 << 7);
+   writel(val, (u32 *)0xbe000620);
mdelay(1000);
 
-
for (i = 0; i < PCI_MAX_CONTROLLERS; i++)
mt7621_pci_enable_irqs(i);
 
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 11/23] staging: mt7621-pci: use BIT macro in definitions

2018-07-09 Thread Sergio Paracuellos
There are some definitions which are using its custom
implementation of BIT macro. Just just BIT macro instead.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-pci/pci-mt7621.c | 31 ---
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c 
b/drivers/staging/mt7621-pci/pci-mt7621.c
index 7cd8f8a..395a042 100644
--- a/drivers/staging/mt7621-pci/pci-mt7621.c
+++ b/drivers/staging/mt7621-pci/pci-mt7621.c
@@ -39,6 +39,7 @@
  **
  */
 
+#include 
 #include 
 #include 
 #include 
@@ -62,17 +63,17 @@
  * devices.
  */
 
-#define RALINK_PCIE0_CLK_EN(1<<24)
-#define RALINK_PCIE1_CLK_EN(1<<25)
-#define RALINK_PCIE2_CLK_EN(1<<26)
+#define RALINK_PCIE0_CLK_ENBIT(24)
+#define RALINK_PCIE1_CLK_ENBIT(25)
+#define RALINK_PCIE2_CLK_ENBIT(26)
 
 #define RALINK_PCI_CONFIG_ADDR 0x20
 #define RALINK_PCI_CONFIG_DATA_VIRTUAL_REG 0x24
 #define RALINK_PCI_MEMBASE 0x0028
 #define RALINK_PCI_IOBASE  0x002C
-#define RALINK_PCIE0_RST   (1<<24)
-#define RALINK_PCIE1_RST   (1<<25)
-#define RALINK_PCIE2_RST   (1<<26)
+#define RALINK_PCIE0_RST   BIT(24)
+#define RALINK_PCIE1_RST   BIT(25)
+#define RALINK_PCIE2_RST   BIT(26)
 
 #define RALINK_PCI_PCICFG_ADDR 0x
 #define RALINK_PCI_PCIMSK_ADDR 0x000C
@@ -122,20 +123,20 @@ static u16 pcie_controller_offsets[] = {
 #define PPLL_CFG1  0x9c
 #define PPLL_DRV   0xa0
 /* SYSC_REG_SYSTEM_CONFIG1 bits */
-#define RALINK_PCI_HOST_MODE_EN(1<<7)
-#define RALINK_PCIE_RC_MODE_EN (1<<8)
+#define RALINK_PCI_HOST_MODE_ENBIT(7)
+#define RALINK_PCIE_RC_MODE_EN BIT(8)
 //RALINK_RSTCTRL bit
-#define RALINK_PCIE_RST(1<<23)
-#define RALINK_PCI_RST (1<<24)
+#define RALINK_PCIE_RSTBIT(23)
+#define RALINK_PCI_RST BIT(24)
 //RALINK_CLKCFG1 bit
-#define RALINK_PCI_CLK_EN  (1<<19)
-#define RALINK_PCIE_CLK_EN (1<<21)
+#define RALINK_PCI_CLK_EN  BIT(19)
+#define RALINK_PCIE_CLK_EN BIT(21)
 //RALINK_GPIOMODE bit
-#define PCI_SLOTx2 (1<<11)
+#define PCI_SLOTx2 BIT(11)
 #define PCI_SLOTx1 (2<<11)
 //MTK PCIE PLL bit
-#define PDRV_SW_SET(1<<31)
-#define LC_CKDRVPD_(1<<19)
+#define PDRV_SW_SETBIT(31)
+#define LC_CKDRVPD_BIT(19)
 
 #define MEMORY_BASE 0x0
 static int pcie_link_status = 0;
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 16/23] staging: mt7621-pci: minor refactor in duplicated code

2018-07-09 Thread Sergio Paracuellos
Use a for loop to check pci port N_FTS in each controller.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-pci/pci-mt7621.c | 12 
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c 
b/drivers/staging/mt7621-pci/pci-mt7621.c
index 289d983..d7840af 100644
--- a/drivers/staging/mt7621-pci/pci-mt7621.c
+++ b/drivers/staging/mt7621-pci/pci-mt7621.c
@@ -486,14 +486,10 @@ static int mt7621_pci_probe(struct platform_device *pdev)
bypass_pipe_rst();
set_phy_for_ssc();
 
-   val = read_config(0, 0x70c);
-   printk("Port 0 N_FTS = %x\n", val);
-
-   val= read_config(1, 0x70c);
-   printk("Port 1 N_FTS = %x\n", val);
-
-   val = read_config(2, 0x70c);
-   printk("Port 2 N_FTS = %x\n", val);
+   for (i = 0; i < PCI_MAX_CONTROLLERS; i++) {
+   val = read_config(0, 0x70c);
+   printk("Port %d N_FTS = %x\n", i, val);
+   }
 
rt_sysc_m32(0, RALINK_PCIE_RST, RALINK_RSTCTRL);
rt_sysc_m32(0x30, 2 << 4, SYSC_REG_SYSTEM_CONFIG1);
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 14/23] staging: mt7621-pci: rewrite [read|write]_config functions

2018-07-09 Thread Sergio Paracuellos
This two functions are called with bus and func being always 0.
Remove non sensense 'bus' and 'func' parameters and pass '0' to
other calls inside the function. Review return and parameter types
also to be more proper with the rest of the code. Adapt properly
calls to those function to match the new prototypes.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-pci/pci-mt7621.c | 56 -
 1 file changed, 27 insertions(+), 29 deletions(-)

diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c 
b/drivers/staging/mt7621-pci/pci-mt7621.c
index efcc008..c9da849 100644
--- a/drivers/staging/mt7621-pci/pci-mt7621.c
+++ b/drivers/staging/mt7621-pci/pci-mt7621.c
@@ -233,28 +233,26 @@ static struct pci_controller mt7621_controller = {
.io_resource= _res_pci_io1,
 };
 
-static void
-read_config(unsigned long bus, unsigned long dev, unsigned long func,
-   unsigned long reg, unsigned long *val)
+static u32
+read_config(unsigned int dev, u32 reg)
 {
u32 address_reg, data_reg, address;
 
address_reg = RALINK_PCI_CONFIG_ADDR;
data_reg = RALINK_PCI_CONFIG_DATA_VIRTUAL_REG;
-   address = mt7621_pci_get_cfgaddr(bus, dev, func, reg);
+   address = mt7621_pci_get_cfgaddr(0, dev, 0, reg);
writel(address, mt7621_pci_base + address_reg);
-   *val = readl(mt7621_pci_base + data_reg);
+   return readl(mt7621_pci_base + data_reg);
 }
 
 static void
-write_config(unsigned long bus, unsigned long dev, unsigned long func,
-unsigned long reg, unsigned long val)
+write_config(unsigned int dev, u32 reg, u32 val)
 {
u32 address_reg, data_reg, address;
 
address_reg = RALINK_PCI_CONFIG_ADDR;
data_reg = RALINK_PCI_CONFIG_DATA_VIRTUAL_REG;
-   address = mt7621_pci_get_cfgaddr(bus, dev, func, reg);
+   address = mt7621_pci_get_cfgaddr(0, dev, 0, reg);
writel(address, mt7621_pci_base + address_reg);
writel(val, mt7621_pci_base + data_reg);
 }
@@ -267,8 +265,8 @@ pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
int irq;
 
if (dev->bus->number == 0) {
-   write_config(0, slot, 0, PCI_BASE_ADDRESS_0, MEMORY_BASE);
-   read_config(0, slot, 0, PCI_BASE_ADDRESS_0, (unsigned long 
*));
+   write_config(slot, PCI_BASE_ADDRESS_0, MEMORY_BASE);
+   val = read_config(slot, PCI_BASE_ADDRESS_0);
printk("BAR0 at slot %d = %x\n", slot, val);
}
 
@@ -409,7 +407,7 @@ void setup_cm_memory_region(struct resource *mem_resource)
 static int mt7621_pci_probe(struct platform_device *pdev)
 {
u32 mask;
-   unsigned long val = 0;
+   u32 val;
 
mt7621_pci_base = (void __iomem *)RALINK_PCI_BASE;
iomem_resource.start = 0;
@@ -442,14 +440,14 @@ static int mt7621_pci_probe(struct platform_device *pdev)
bypass_pipe_rst();
set_phy_for_ssc();
 
-   read_config(0, 0, 0, 0x70c, );
-   printk("Port 0 N_FTS = %x\n", (unsigned int)val);
+   val = read_config(0, 0x70c);
+   printk("Port 0 N_FTS = %x\n", val);
 
-   read_config(0, 1, 0, 0x70c, );
-   printk("Port 1 N_FTS = %x\n", (unsigned int)val);
+   val= read_config(1, 0x70c);
+   printk("Port 1 N_FTS = %x\n", val);
 
-   read_config(0, 2, 0, 0x70c, );
-   printk("Port 2 N_FTS = %x\n", (unsigned int)val);
+   val = read_config(2, 0x70c);
+   printk("Port 2 N_FTS = %x\n", val);
 
rt_sysc_m32(0, RALINK_PCIE_RST, RALINK_RSTCTRL);
rt_sysc_m32(0x30, 2 << 4, SYSC_REG_SYSTEM_CONFIG1);
@@ -580,28 +578,28 @@ pcie(2/1/0) link status   pcie2_num   pcie1_num   
pcie0_num
 
switch (pcie_link_status) {
case 7:
-   read_config(0, 2, 0, 0x4, );
-   write_config(0, 2, 0, 0x4, val|0x4);
-   read_config(0, 2, 0, 0x70c, );
+   val = read_config(2, 0x4);
+   write_config(2, 0x4, (val | 0x4));
+   val = read_config(2, 0x70c);
val &= ~(0xff)<<8;
val |= 0x50<<8;
-   write_config(0, 2, 0, 0x70c, val);
+   write_config(2, 0x70c, val);
case 3:
case 5:
case 6:
-   read_config(0, 1, 0, 0x4, );
-   write_config(0, 1, 0, 0x4, val|0x4);
-   read_config(0, 1, 0, 0x70c, );
+   val = read_config(1, 0x4);
+   write_config(1, 0x4, (val | 0x4));
+   val = read_config(1, 0x70c);
val &= ~(0xff)<<8;
val |= 0x50<<8;
-   write_config(0, 1, 0, 0x70c, val);
+   write_config(1, 0x70c, val);
default:
-   read_config(0, 0, 0, 0x4, );
-   write_config(0, 0, 0, 0x4, val|0x4); //bus master enable
-   read_config(0, 0, 0, 0x70c, );
+   val = read_config(0, 0x4);
+   write_config(0, 0x4, (val | 0x4)); //bus master enable
+

[PATCH v3 21/23] staging: mt7621-pci: rename RALINK_PCI_CONFIG_DATA_VIRTUAL_REG definition

2018-07-09 Thread Sergio Paracuellos
RALINK_PCI_CONFIG_DATA_VIRTUAL_REG is a very long name and makes
lines to be very long when it is used. Rename it to a shorter one
RALINK_PCI_CONFIG_DATA.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-pci/pci-mt7621.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c 
b/drivers/staging/mt7621-pci/pci-mt7621.c
index 3e2469a..3fc2d96 100644
--- a/drivers/staging/mt7621-pci/pci-mt7621.c
+++ b/drivers/staging/mt7621-pci/pci-mt7621.c
@@ -70,7 +70,7 @@
 #define RALINK_PCIE2_CLK_ENBIT(26)
 
 #define RALINK_PCI_CONFIG_ADDR 0x20
-#define RALINK_PCI_CONFIG_DATA_VIRTUAL_REG 0x24
+#define RALINK_PCI_CONFIG_DATA 0x24
 #define RALINK_PCI_MEMBASE 0x0028
 #define RALINK_PCI_IOBASE  0x002C
 #define RALINK_PCIE0_RST   BIT(24)
@@ -180,7 +180,7 @@ pci_config_read(struct pci_bus *bus, unsigned int devfn,
u32 address;
 
address_reg = RALINK_PCI_CONFIG_ADDR;
-   data_reg = RALINK_PCI_CONFIG_DATA_VIRTUAL_REG;
+   data_reg = RALINK_PCI_CONFIG_DATA;
 
address = mt7621_pci_get_cfgaddr(bus->number, PCI_SLOT(devfn),
 PCI_FUNC(devfn), where);
@@ -210,7 +210,7 @@ pci_config_write(struct pci_bus *bus, unsigned int devfn,
u32 address;
 
address_reg = RALINK_PCI_CONFIG_ADDR;
-   data_reg = RALINK_PCI_CONFIG_DATA_VIRTUAL_REG;
+   data_reg = RALINK_PCI_CONFIG_DATA;
 
address = mt7621_pci_get_cfgaddr(bus->number, PCI_SLOT(devfn),
 PCI_FUNC(devfn), where);
@@ -251,7 +251,7 @@ read_config(unsigned int dev, u32 reg)
u32 address_reg, data_reg, address;
 
address_reg = RALINK_PCI_CONFIG_ADDR;
-   data_reg = RALINK_PCI_CONFIG_DATA_VIRTUAL_REG;
+   data_reg = RALINK_PCI_CONFIG_DATA;
address = mt7621_pci_get_cfgaddr(0, dev, 0, reg);
writel(address, mt7621_pci_base + address_reg);
return readl(mt7621_pci_base + data_reg);
@@ -263,7 +263,7 @@ write_config(unsigned int dev, u32 reg, u32 val)
u32 address_reg, data_reg, address;
 
address_reg = RALINK_PCI_CONFIG_ADDR;
-   data_reg = RALINK_PCI_CONFIG_DATA_VIRTUAL_REG;
+   data_reg = RALINK_PCI_CONFIG_DATA;
address = mt7621_pci_get_cfgaddr(0, dev, 0, reg);
writel(address, mt7621_pci_base + address_reg);
writel(val, mt7621_pci_base + data_reg);
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 07/23] staging: mt7621-pci: use writel and readl instead of custom macros

2018-07-09 Thread Sergio Paracuellos
Functions 'read_config' and 'write_config' are using some custom
macros to write and read registers. Use kernel architecture functions
readl and writel instead.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-pci/pci-mt7621.c | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c 
b/drivers/staging/mt7621-pci/pci-mt7621.c
index ce8e39b..ca6c7ca 100644
--- a/drivers/staging/mt7621-pci/pci-mt7621.c
+++ b/drivers/staging/mt7621-pci/pci-mt7621.c
@@ -261,9 +261,8 @@ read_config(unsigned long bus, unsigned long dev, unsigned 
long func,
address_reg = RALINK_PCI_CONFIG_ADDR;
data_reg = RALINK_PCI_CONFIG_DATA_VIRTUAL_REG;
address = mt7621_pci_get_cfgaddr(bus, dev, func, reg);
-   MV_WRITE(address_reg, address);
-   MV_READ(data_reg, val);
-   return;
+   writel(address, mt7621_pci_base + address_reg);
+   *val = readl(mt7621_pci_base + data_reg);
 }
 
 static void
@@ -275,9 +274,8 @@ write_config(unsigned long bus, unsigned long dev, unsigned 
long func,
address_reg = RALINK_PCI_CONFIG_ADDR;
data_reg = RALINK_PCI_CONFIG_DATA_VIRTUAL_REG;
address = mt7621_pci_get_cfgaddr(bus, dev, func, reg);
-   MV_WRITE(address_reg, address);
-   MV_WRITE(data_reg, val);
-   return;
+   writel(address, mt7621_pci_base + address_reg);
+   writel(val, mt7621_pci_base + data_reg);
 }
 
 int
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 06/23] staging: mt7621-pci: avoid long lines in read_config and write_config functions

2018-07-09 Thread Sergio Paracuellos
This two prototypes are very long. Indent them in a proper way.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-pci/pci-mt7621.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c 
b/drivers/staging/mt7621-pci/pci-mt7621.c
index ed46d04..ce8e39b 100644
--- a/drivers/staging/mt7621-pci/pci-mt7621.c
+++ b/drivers/staging/mt7621-pci/pci-mt7621.c
@@ -253,7 +253,8 @@ static struct pci_controller mt7621_controller = {
 };
 
 static void
-read_config(unsigned long bus, unsigned long dev, unsigned long func, unsigned 
long reg, unsigned long *val)
+read_config(unsigned long bus, unsigned long dev, unsigned long func,
+   unsigned long reg, unsigned long *val)
 {
u32 address_reg, data_reg, address;
 
@@ -266,7 +267,8 @@ read_config(unsigned long bus, unsigned long dev, unsigned 
long func, unsigned l
 }
 
 static void
-write_config(unsigned long bus, unsigned long dev, unsigned long func, 
unsigned long reg, unsigned long val)
+write_config(unsigned long bus, unsigned long dev, unsigned long func,
+unsigned long reg, unsigned long val)
 {
u32 address_reg, data_reg, address;
 
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 17/23] staging: mt7621-pci: factor out mt7621_pci_enable function

2018-07-09 Thread Sergio Paracuellos
Factor out mt7621_pci_enable function to avoid duplicate code
in driver probe function. This increase readability.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-pci/pci-mt7621.c | 36 ++---
 1 file changed, 15 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c 
b/drivers/staging/mt7621-pci/pci-mt7621.c
index d7840af..17797c4 100644
--- a/drivers/staging/mt7621-pci/pci-mt7621.c
+++ b/drivers/staging/mt7621-pci/pci-mt7621.c
@@ -455,6 +455,15 @@ static void mt7621_pci_enable_irqs(u8 controller)
mt7621_pci_reg_write(mask, RALINK_PCI_PCIMSK_ADDR);
 }
 
+static void mt7621_pci_enable(u8 controller)
+{
+   /* open 7FFF:2G; ENABLE */
+   mt7621_pci_reg_write(0x7FFF0001, RALINK_PCI_BAR0SETUP_ADDR(controller));
+   mt7621_pci_reg_write(MEMORY_BASE, 
RALINK_PCI_IMBASEBAR0_ADDR(controller));
+   mt7621_pci_reg_write(0x06040001, RALINK_PCI_CLASS(controller));
+   printk("PCIE%d enabled\n", controller);
+}
+
 static int mt7621_pci_probe(struct platform_device *pdev)
 {
int i;
@@ -560,31 +569,16 @@ pcie(2/1/0) link status   pcie2_num   pcie1_num   
pcie0_num
mt7621_pci_reg_write(RALINK_PCI_IO_MAP_BASE, RALINK_PCI_IOBASE);
 
//PCIe0
-   if ((pcie_link_status & 0x1) != 0) {
-   /* open 7FFF:2G; ENABLE */
-   mt7621_pci_reg_write(0x7FFF0001, RALINK_PCI_BAR0SETUP_ADDR(0));
-   mt7621_pci_reg_write(MEMORY_BASE, 
RALINK_PCI_IMBASEBAR0_ADDR(0));
-   mt7621_pci_reg_write(0x06040001, RALINK_PCI_CLASS(0));
-   printk("PCIE0 enabled\n");
-   }
+   if ((pcie_link_status & 0x1) != 0)
+   mt7621_pci_enable(0);
 
//PCIe1
-   if ((pcie_link_status & 0x2) != 0) {
-   /* open 7FFF:2G; ENABLE */
-   mt7621_pci_reg_write(0x7FFF0001, RALINK_PCI_BAR0SETUP_ADDR(1));
-   mt7621_pci_reg_write(MEMORY_BASE, 
RALINK_PCI_IMBASEBAR0_ADDR(1));
-   mt7621_pci_reg_write(0x06040001, RALINK_PCI_CLASS(1));
-   printk("PCIE1 enabled\n");
-   }
+   if ((pcie_link_status & 0x2) != 0)
+   mt7621_pci_enable(1);
 
//PCIe2
-   if ((pcie_link_status & 0x4) != 0) {
-   /* open 7FFF:2G; ENABLE */
-   mt7621_pci_reg_write(0x7FFF0001, RALINK_PCI_BAR0SETUP_ADDR(2));
-   mt7621_pci_reg_write(MEMORY_BASE, 
RALINK_PCI_IMBASEBAR0_ADDR(2));
-   mt7621_pci_reg_write(0x06040001, RALINK_PCI_CLASS(2));
-   printk("PCIE2 enabled\n");
-   }
+   if ((pcie_link_status & 0x4) != 0)
+   mt7621_pci_enable(2);
 
switch (pcie_link_status) {
case 7:
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 15/23] staging: mt7621-pci: factor out mt7621_pci_enable_irqs and mt7621_pci_disable

2018-07-09 Thread Sergio Paracuellos
Driver probe function is a mess and need a very big refactor.
Factor out mt7621_pci_enable_irqs and mt7621_pci_disable to
handle interrupts if pci status is as expected. To get the correct
bits for each controller define a new 'pcie_controller_data'
including clk_en, rst, irq and offset fields. Controller number
will be the array index 'pcie_controllers' which subs the 'offsets'
array.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-pci/pci-mt7621.c | 120 ++--
 1 file changed, 67 insertions(+), 53 deletions(-)

diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c 
b/drivers/staging/mt7621-pci/pci-mt7621.c
index c9da849..289d983 100644
--- a/drivers/staging/mt7621-pci/pci-mt7621.c
+++ b/drivers/staging/mt7621-pci/pci-mt7621.c
@@ -63,6 +63,8 @@
  * devices.
  */
 
+#define PCI_MAX_CONTROLLERS3
+
 #define RALINK_PCIE0_CLK_ENBIT(24)
 #define RALINK_PCIE1_CLK_ENBIT(25)
 #define RALINK_PCIE2_CLK_ENBIT(26)
@@ -74,24 +76,50 @@
 #define RALINK_PCIE0_RST   BIT(24)
 #define RALINK_PCIE1_RST   BIT(25)
 #define RALINK_PCIE2_RST   BIT(26)
+#define RALINK_PCIE0_IRQ   BIT(20)
+#define RALINK_PCIE1_IRQ   BIT(21)
+#define RALINK_PCIE2_IRQ   BIT(22)
 
 #define RALINK_PCI_PCICFG_ADDR 0x
 #define RALINK_PCI_PCIMSK_ADDR 0x000C
 #define RALINK_PCI_BASE0xBE14
 
+struct pcie_controller_data {
+   u32 offset;
+   u32 clk_en;
+   u32 rst;
+   u32 irq;
+};
 
-static u16 pcie_controller_offsets[] = {
-   0x2000, 0x3000, 0x4000,
+static struct pcie_controller_data pcie_controllers[] = {
+   {
+   .offset = 0x2000,
+   .clk_en = RALINK_PCIE0_CLK_EN,
+   .rst = RALINK_PCIE0_RST,
+   .irq = RALINK_PCIE0_IRQ,
+   },
+   {
+   .offset = 0x3000,
+   .clk_en = RALINK_PCIE1_CLK_EN,
+   .rst = RALINK_PCIE1_RST,
+   .irq = RALINK_PCIE1_IRQ,
+   },
+   {
+   .offset = 0x4000,
+   .clk_en = RALINK_PCIE2_CLK_EN,
+   .rst = RALINK_PCIE2_RST,
+   .irq = RALINK_PCIE2_IRQ,
+   },
 };
 
-#define RALINK_PCI_BAR0SETUP_ADDR(dev) (pcie_controller_offsets[(dev)] + 
0x0010)
-#define RALINK_PCI_IMBASEBAR0_ADDR(dev)(pcie_controller_offsets[(dev)] 
+ 0x0018)
-#define RALINK_PCI_ID(dev) (pcie_controller_offsets[(dev)] + 
0x0030)
-#define RALINK_PCI_CLASS(dev)  (pcie_controller_offsets[(dev)] + 
0x0034)
-#define RALINK_PCI_SUBID(dev)  (pcie_controller_offsets[(dev)] + 
0x0038)
-#define RALINK_PCI_STATUS(dev) (pcie_controller_offsets[(dev)] + 
0x0050)
-#define RALINK_PCI_DERR(dev)   (pcie_controller_offsets[(dev)] + 
0x0060)
-#define RALINK_PCI_ECRC(dev)   (pcie_controller_offsets[(dev)] + 
0x0064)
+#define RALINK_PCI_BAR0SETUP_ADDR(dev) (pcie_controllers[(dev)].offset + 
0x0010)
+#define RALINK_PCI_IMBASEBAR0_ADDR(dev)(pcie_controllers[(dev)].offset 
+ 0x0018)
+#define RALINK_PCI_ID(dev) (pcie_controllers[(dev)].offset + 
0x0030)
+#define RALINK_PCI_CLASS(dev)  (pcie_controllers[(dev)].offset + 
0x0034)
+#define RALINK_PCI_SUBID(dev)  (pcie_controllers[(dev)].offset + 
0x0038)
+#define RALINK_PCI_STATUS(dev) (pcie_controllers[(dev)].offset + 
0x0050)
+#define RALINK_PCI_DERR(dev)   (pcie_controllers[(dev)].offset + 
0x0060)
+#define RALINK_PCI_ECRC(dev)   (pcie_controllers[(dev)].offset + 
0x0064)
 
 #define RALINK_PCIEPHY_P0P1_CTL_OFFSET 0x9000
 #define RALINK_PCIEPHY_P2_CTL_OFFSET   0xA000
@@ -404,8 +432,32 @@ void setup_cm_memory_region(struct resource *mem_resource)
}
 }
 
+static void mt7621_pci_disable(u8 controller)
+{
+   mt7621_pcie_assert_sysrst(pcie_controllers[controller].rst);
+   rt_sysc_m32(pcie_controllers[controller].clk_en, 0, RALINK_CLKCFG1);
+   pcie_link_status &= ~(1 << controller);
+}
+
+static void mt7621_pci_enable_irqs(u8 controller)
+{
+   u32 mask;
+
+   if ((mt7621_pci_reg_read(RALINK_PCI_STATUS(controller)) & 0x1) == 0) {
+   printk("PCIE0 no card, disable it(RST)\n");
+   mt7621_pci_disable(controller);
+   return;
+   }
+
+   pcie_link_status |= (1 << controller);
+   mask = mt7621_pci_reg_read(RALINK_PCI_PCIMSK_ADDR);
+   mask |= pcie_controllers[controller].irq;
+   mt7621_pci_reg_write(mask, RALINK_PCI_PCIMSK_ADDR);
+}
+
 static int mt7621_pci_probe(struct platform_device *pdev)
 {
+   int i;
u32 mask;
u32 val;
 
@@ -415,11 +467,8 @@ static int mt7621_pci_probe(struct platform_device *pdev)
ioport_resource.start = 0;
ioport_resource.end = ~0;
 
-   val = RALINK_PCIE0_RST;
-   val |= RALINK_PCIE1_RST;
-   val |= RALINK_PCIE2_RST;
-
-   mt7621_pcie_assert_sysrst(RALINK_PCIE0_RST | RALINK_PCIE1_RST | 

[PATCH v3 13/23] staging: mt7621-pci: make ASSERT_SYSRST_PCIE and DEASSERT_SYSRST_PCIE inline functions

2018-07-09 Thread Sergio Paracuellos
ASSERT_SYSRST_PCIE and DEASSERT_SYSRST_PCIE are defined as preprocessor
macros and can be defined as inline functions instead which are preferred.
Do it and rename to mt7621_pcie_assert_sysrst and mt7621_pcie_deassert_sysrst
respectively.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-pci/pci-mt7621.c | 41 +
 1 file changed, 21 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c 
b/drivers/staging/mt7621-pci/pci-mt7621.c
index 76916a6..efcc008 100644
--- a/drivers/staging/mt7621-pci/pci-mt7621.c
+++ b/drivers/staging/mt7621-pci/pci-mt7621.c
@@ -93,27 +93,12 @@ static u16 pcie_controller_offsets[] = {
 #define RALINK_PCI_DERR(dev)   (pcie_controller_offsets[(dev)] + 
0x0060)
 #define RALINK_PCI_ECRC(dev)   (pcie_controller_offsets[(dev)] + 
0x0064)
 
-
 #define RALINK_PCIEPHY_P0P1_CTL_OFFSET 0x9000
 #define RALINK_PCIEPHY_P2_CTL_OFFSET   0xA000
 
 #define RALINK_PCI_MM_MAP_BASE 0x6000
 #define RALINK_PCI_IO_MAP_BASE 0x1e16
 
-#define ASSERT_SYSRST_PCIE(val)\
-   do {\
-   if (rt_sysc_r32(SYSC_REG_CHIP_REV) == 0x00030101)   \
-   rt_sysc_m32(0, val, RALINK_RSTCTRL);\
-   else\
-   rt_sysc_m32(val, 0, RALINK_RSTCTRL);\
-   } while (0)
-#define DEASSERT_SYSRST_PCIE(val)  \
-   do {\
-   if (rt_sysc_r32(SYSC_REG_CHIP_REV) == 0x00030101)   \
-   rt_sysc_m32(val, 0, RALINK_RSTCTRL);\
-   else\
-   rt_sysc_m32(0, val, RALINK_RSTCTRL);\
-   } while (0)
 #define RALINK_CLKCFG1 0x30
 #define RALINK_RSTCTRL 0x34
 #define RALINK_GPIOMODE0x60
@@ -142,6 +127,22 @@ static int pcie_link_status = 0;
 
 static void __iomem *mt7621_pci_base;
 
+static inline void mt7621_pcie_assert_sysrst(u32 val)
+{
+   if (rt_sysc_r32(SYSC_REG_CHIP_REV) == 0x00030101)
+   rt_sysc_m32(0, val, RALINK_RSTCTRL);
+   else
+   rt_sysc_m32(val, 0, RALINK_RSTCTRL);
+}
+
+static inline void mt7621_pcie_deassert_sysrst(u32 val)
+{
+   if (rt_sysc_r32(SYSC_REG_CHIP_REV) == 0x00030101)
+   rt_sysc_m32(val, 0, RALINK_RSTCTRL);
+   else
+   rt_sysc_m32(0, val, RALINK_RSTCTRL);
+}
+
 static u32 mt7621_pci_reg_read(u32 reg)
 {
return readl(mt7621_pci_base + reg);
@@ -420,7 +421,7 @@ static int mt7621_pci_probe(struct platform_device *pdev)
val |= RALINK_PCIE1_RST;
val |= RALINK_PCIE2_RST;
 
-   ASSERT_SYSRST_PCIE(RALINK_PCIE0_RST | RALINK_PCIE1_RST | 
RALINK_PCIE2_RST);
+   mt7621_pcie_assert_sysrst(RALINK_PCIE0_RST | RALINK_PCIE1_RST | 
RALINK_PCIE2_RST);
 
*(unsigned int *)(0xbe60) &= ~(0x3<<10 | 0x3<<3);
*(unsigned int *)(0xbe60) |= 0x1<<10 | 0x1<<3;
@@ -435,7 +436,7 @@ static int mt7621_pci_probe(struct platform_device *pdev)
val |= RALINK_PCIE1_RST;
val |= RALINK_PCIE2_RST;
 
-   DEASSERT_SYSRST_PCIE(val);
+   mt7621_pcie_deassert_sysrst(val);
 
if ((*(unsigned int *)(0xbe0c)&0x) == 0x0101) // MT7621 E2
bypass_pipe_rst();
@@ -466,7 +467,7 @@ static int mt7621_pci_probe(struct platform_device *pdev)
 
if ((mt7621_pci_reg_read(RALINK_PCI_STATUS(0)) & 0x1) == 0) {
printk("PCIE0 no card, disable it(RST)\n");
-   ASSERT_SYSRST_PCIE(RALINK_PCIE0_RST);
+   mt7621_pcie_assert_sysrst(RALINK_PCIE0_RST);
rt_sysc_m32(RALINK_PCIE0_CLK_EN, 0, RALINK_CLKCFG1);
pcie_link_status &= ~(1<<0);
} else {
@@ -478,7 +479,7 @@ static int mt7621_pci_probe(struct platform_device *pdev)
 
if ((mt7621_pci_reg_read(RALINK_PCI_STATUS(1)) & 0x1) == 0) {
printk("PCIE1 no card, disable it(RST)\n");
-   ASSERT_SYSRST_PCIE(RALINK_PCIE1_RST);
+   mt7621_pcie_assert_sysrst(RALINK_PCIE1_RST);
rt_sysc_m32(RALINK_PCIE1_CLK_EN, 0, RALINK_CLKCFG1);
pcie_link_status &= ~(1<<1);
} else {
@@ -490,7 +491,7 @@ static int mt7621_pci_probe(struct platform_device *pdev)
 
if ((mt7621_pci_reg_read(RALINK_PCI_STATUS(2)) & 0x1) == 0) {
printk("PCIE2 no card, disable it(RST)\n");
-   ASSERT_SYSRST_PCIE(RALINK_PCIE2_RST);
+   mt7621_pcie_assert_sysrst(RALINK_PCIE2_RST);
rt_sysc_m32(RALINK_PCIE2_CLK_EN, 0, RALINK_CLKCFG1);
pcie_link_status &= ~(1<<2);
} else {
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org

[PATCH v3 22/23] staging: mt7621-pci: fix and remove some comments

2018-07-09 Thread Sergio Paracuellos
There are some comments not needed at all. Remove them.
Adjust one comment to follow kernel style.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-pci/pci-mt7621.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c 
b/drivers/staging/mt7621-pci/pci-mt7621.c
index 3fc2d96..abfa589 100644
--- a/drivers/staging/mt7621-pci/pci-mt7621.c
+++ b/drivers/staging/mt7621-pci/pci-mt7621.c
@@ -130,7 +130,6 @@ static struct pcie_controller_data pcie_controllers[] = {
 #define RALINK_PCIE_CLK_GEN0x7c
 #define RALINK_PCIE_CLK_GEN1   0x80
 
-//RALINK_RSTCTRL bit
 #define RALINK_PCIE_RSTBIT(23)
 
 #define MEMORY_BASE 0x0
@@ -282,8 +281,8 @@ pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
printk("BAR0 at slot %d = %x\n", slot, val);
}
 
-   pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, 0x14);  //configure 
cache line size 0x14
-   pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0xFF);  //configure 
latency timer 0x10
+   pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, 0x14);
+   pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0xFF);
pci_read_config_word(dev, PCI_COMMAND, );
cmd = cmd | PCI_COMMAND_MASTER | PCI_COMMAND_IO | PCI_COMMAND_MEMORY;
pci_write_config_word(dev, PCI_COMMAND, cmd);
@@ -404,9 +403,11 @@ void setup_cm_memory_region(struct resource *mem_resource)
resource_size_t mask;
 
if (mips_cps_numiocu(0)) {
-   /* FIXME: hardware doesn't accept mask values with 1s after
+   /*
+* FIXME: hardware doesn't accept mask values with 1s after
 * 0s (e.g. 0xffef), so it would be great to warn if that's
-* about to happen */
+* about to happen
+*/
mask = ~(mem_resource->end - mem_resource->start);
 
write_gcr_reg1_base(mem_resource->start);
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 04/23] staging: mt7621-pci: reimplement pci_config_[read|write] functions

2018-07-09 Thread Sergio Paracuellos
The logic for this functions is kind of mess calling to other
functions which ends up in using very ugly macros. Reimplement
this two using kernel write[b,w,l] and read[b,w,l] and the variable
'mt7621_pci_base'. Function prototypes have changed style to avoid
long lines.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-pci/pci-mt7621.c | 54 +++--
 1 file changed, 44 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c 
b/drivers/staging/mt7621-pci/pci-mt7621.c
index b745423..122c046 100644
--- a/drivers/staging/mt7621-pci/pci-mt7621.c
+++ b/drivers/staging/mt7621-pci/pci-mt7621.c
@@ -273,29 +273,63 @@ write_config_dword(struct pci_bus *bus, unsigned int 
devfn, int where, u32 val)
 }
 
 static int
-pci_config_read(struct pci_bus *bus, unsigned int devfn, int where, int size, 
u32 *val)
+pci_config_read(struct pci_bus *bus, unsigned int devfn,
+   int where, int size, u32 *val)
 {
+   u32 address_reg, data_reg;
+   u32 address;
+
+   address_reg = RALINK_PCI_CONFIG_ADDR;
+   data_reg = RALINK_PCI_CONFIG_DATA_VIRTUAL_REG;
+
+   address = mt7621_pci_get_cfgaddr(bus->number, PCI_SLOT(devfn),
+PCI_FUNC(devfn), where);
+
+   writel(address, mt7621_pci_base + address_reg);
+
switch (size) {
case 1:
-   return read_config_byte(bus, devfn, where, (u8 *) val);
+   *val = readb(mt7621_pci_base + data_reg + (where & 0x3));
+   break;
case 2:
-   return read_config_word(bus, devfn, where, (u16 *) val);
-   default:
-   return read_config_dword(bus, devfn, where, val);
+   *val = readw(mt7621_pci_base + data_reg + (where & 0x3));
+   break;
+   case 4:
+   *val = readl(mt7621_pci_base + data_reg);
+   break;
}
+
+   return PCIBIOS_SUCCESSFUL;
 }
 
 static int
-pci_config_write(struct pci_bus *bus, unsigned int devfn, int where, int size, 
u32 val)
+pci_config_write(struct pci_bus *bus, unsigned int devfn,
+int where, int size, u32 val)
 {
+   u32 address_reg, data_reg;
+   u32 address;
+
+   address_reg = RALINK_PCI_CONFIG_ADDR;
+   data_reg = RALINK_PCI_CONFIG_DATA_VIRTUAL_REG;
+
+   address = mt7621_pci_get_cfgaddr(bus->number, PCI_SLOT(devfn),
+PCI_FUNC(devfn), where);
+
+   writel(address, mt7621_pci_base + address_reg);
+
switch (size) {
case 1:
-   return write_config_byte(bus, devfn, where, (u8) val);
+   writeb((u8)val, mt7621_pci_base + data_reg + (where & 0x3));
+   break;
case 2:
-   return write_config_word(bus, devfn, where, (u16) val);
-   default:
-   return write_config_dword(bus, devfn, where, val);
+   writew((u16)val, mt7621_pci_base + data_reg + (where & 0x3));
+   break;
+   case 4:
+   writel(val, mt7621_pci_base + data_reg);
+   break;
}
+
+   return PCIBIOS_SUCCESSFUL;
 }
 
 struct pci_ops mt7621_pci_ops = {
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 12/23] staging: mt7621-pci: use read and writes in set_pcie_phy function

2018-07-09 Thread Sergio Paracuellos
set_pcie_phy can be refactor to use mt7621_pci_reg_write and
mt7621_pci_reg_read functions intead of use pointer arithmetics.
Use them and simplify implicated calls and definitions along the
code.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-pci/pci-mt7621.c | 122 
 1 file changed, 62 insertions(+), 60 deletions(-)

diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c 
b/drivers/staging/mt7621-pci/pci-mt7621.c
index 395a042..76916a6 100644
--- a/drivers/staging/mt7621-pci/pci-mt7621.c
+++ b/drivers/staging/mt7621-pci/pci-mt7621.c
@@ -79,7 +79,6 @@
 #define RALINK_PCI_PCIMSK_ADDR 0x000C
 #define RALINK_PCI_BASE0xBE14
 
-#define RALINK_PCIEPHY_P0P1_CTL_OFFSET (RALINK_PCI_BASE + 0x9000)
 
 static u16 pcie_controller_offsets[] = {
0x2000, 0x3000, 0x4000,
@@ -95,8 +94,8 @@ static u16 pcie_controller_offsets[] = {
 #define RALINK_PCI_ECRC(dev)   (pcie_controller_offsets[(dev)] + 
0x0064)
 
 
-#define RALINK_PCIEPHY_P0P1_CTL_OFFSET (RALINK_PCI_BASE + 0x9000)
-#define RALINK_PCIEPHY_P2_CTL_OFFSET   (RALINK_PCI_BASE + 0xA000)
+#define RALINK_PCIEPHY_P0P1_CTL_OFFSET 0x9000
+#define RALINK_PCIEPHY_P2_CTL_OFFSET   0xA000
 
 #define RALINK_PCI_MM_MAP_BASE 0x6000
 #define RALINK_PCI_IO_MAP_BASE 0x1e16
@@ -285,24 +284,27 @@ pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 
pin)
 }
 
 void
-set_pcie_phy(u32 *addr, int start_b, int bits, int val)
+set_pcie_phy(u32 offset, int start_b, int bits, int val)
 {
-   *(unsigned int *)(addr) &= ~(((1<> 6) & 0x7;
/* Set PCIe Port0 & Port1 PHY to disable SSC */
/* Debug Xtal Type */
-   set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x400),  8, 1, 
0x01); // rg_pe1_frc_h_xtal_type
-   set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x400),  9, 2, 
0x00); // rg_pe1_h_xtal_type
-   set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x000),  4, 1, 
0x01); // rg_pe1_frc_phy_en//Force Port 0 enable control
-   set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x100),  4, 1, 
0x01); // rg_pe1_frc_phy_en//Force Port 1 enable control
-   set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x000),  5, 1, 
0x00); // rg_pe1_phy_en//Port 0 disable
-   set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x100),  5, 1, 
0x00); // rg_pe1_phy_en//Port 1 disable
+   set_pcie_phy((RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x400),  8, 1, 0x01);
// rg_pe1_frc_h_xtal_type
+   set_pcie_phy((RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x400),  9, 2, 0x00);
// rg_pe1_h_xtal_type
+   set_pcie_phy((RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x000),  4, 1, 0x01);
// rg_pe1_frc_phy_en//Force Port 0 enable control
+   set_pcie_phy((RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x100),  4, 1, 0x01);
// rg_pe1_frc_phy_en//Force Port 1 enable control
+   set_pcie_phy((RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x000),  5, 1, 0x00);
// rg_pe1_phy_en//Port 0 disable
+   set_pcie_phy((RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x100),  5, 1, 0x00);
// rg_pe1_phy_en//Port 1 disable
if (reg <= 5 && reg >= 3) { // 40MHz Xtal
-   set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x490),  
6, 2, 0x01); // RG_PE1_H_PLL_PREDIV  //Pre-divider ratio (for host mode)
+   set_pcie_phy((RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x490),  6, 2, 
0x01);// RG_PE1_H_PLL_PREDIV  //Pre-divider ratio (for host mode)
printk("* Xtal 40MHz *\n");
} else {// 25MHz | 20MHz Xtal
-   set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x490),  
6, 2, 0x00); // RG_PE1_H_PLL_PREDIV  //Pre-divider ratio (for host mode)
+   set_pcie_phy((RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x490),  6, 2, 
0x00);// RG_PE1_H_PLL_PREDIV  //Pre-divider ratio (for host mode)
if (reg >= 6) {
printk("* Xtal 25MHz *\n");
-   set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 
0x4bc),  4, 2, 0x01); // RG_PE1_H_PLL_FBKSEL  //Feedback clock select
-   set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 
0x49c),  0, 31, 0x1800);  // RG_PE1_H_LCDDS_PCW_NCPO  //DDS NCPO 
PCW (for host mode)
-   set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 
0x4a4),  0, 16, 0x18d);   // RG_PE1_H_LCDDS_SSC_PRD   //DDS SSC dither 
period control
-   set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 
0x4a8),  0, 12, 0x4a);// RG_PE1_H_LCDDS_SSC_DELTA //DDS SSC dither 
amplitude control
-   set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 
0x4a8), 16, 12, 0x4a);// RG_PE1_H_LCDDS_SSC_DELTA1//DDS SSC dither 
amplitude control for initial
+   set_pcie_phy((RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x4bc),  
4, 2, 0x01);// 

[PATCH v3 18/23] staging: mt7621-pci: factor out mt7621_pci_configure function

2018-07-09 Thread Sergio Paracuellos
Factor out mt7621_pci_configure function to avoid a lot of
duplicated code in driver probe function.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-pci/pci-mt7621.c | 35 -
 1 file changed, 17 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c 
b/drivers/staging/mt7621-pci/pci-mt7621.c
index 17797c4..1be2a11 100644
--- a/drivers/staging/mt7621-pci/pci-mt7621.c
+++ b/drivers/staging/mt7621-pci/pci-mt7621.c
@@ -464,6 +464,18 @@ static void mt7621_pci_enable(u8 controller)
printk("PCIE%d enabled\n", controller);
 }
 
+static void mt7621_pci_configure(u8 controller)
+{
+   u32 val;
+
+   val = read_config(controller, 0x4);
+   write_config(controller, 0x4, (val | 0x4));
+   val = read_config(controller, 0x70c);
+   val &= ~(0xff) << 8;
+   val |= 0x50 << 8;
+   write_config(controller, 0x70c, val);
+}
+
 static int mt7621_pci_probe(struct platform_device *pdev)
 {
int i;
@@ -582,28 +594,15 @@ pcie(2/1/0) link status   pcie2_num   pcie1_num   
pcie0_num
 
switch (pcie_link_status) {
case 7:
-   val = read_config(2, 0x4);
-   write_config(2, 0x4, (val | 0x4));
-   val = read_config(2, 0x70c);
-   val &= ~(0xff)<<8;
-   val |= 0x50<<8;
-   write_config(2, 0x70c, val);
+   mt7621_pci_configure(2);
+   break;
case 3:
case 5:
case 6:
-   val = read_config(1, 0x4);
-   write_config(1, 0x4, (val | 0x4));
-   val = read_config(1, 0x70c);
-   val &= ~(0xff)<<8;
-   val |= 0x50<<8;
-   write_config(1, 0x70c, val);
+   mt7621_pci_configure(1);
+   break;
default:
-   val = read_config(0, 0x4);
-   write_config(0, 0x4, (val | 0x4)); //bus master enable
-   val = read_config(0, 0x70c);
-   val &= ~(0xff)<<8;
-   val |= 0x50<<8;
-   write_config(0, 0x70c, val);
+   mt7621_pci_configure(0);
}
 
pci_load_of_ranges(_controller, pdev->dev.of_node);
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 01/23] staging: mt7621-pci: remove unused macro MV_READ_DATA

2018-07-09 Thread Sergio Paracuellos
This macro is not being used at all along the code.
Just remove it.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-pci/pci-mt7621.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c 
b/drivers/staging/mt7621-pci/pci-mt7621.c
index c12447d..89a57a0 100644
--- a/drivers/staging/mt7621-pci/pci-mt7621.c
+++ b/drivers/staging/mt7621-pci/pci-mt7621.c
@@ -117,9 +117,6 @@
*(volatile u32 *)(RALINK_PCI_BASE+(ofs)) = cpu_to_le32(data)
 #define MV_READ(ofs, data) \
*(data) = le32_to_cpu(*(volatile u32 *)(RALINK_PCI_BASE+(ofs)))
-#define MV_READ_DATA(ofs)  \
-   le32_to_cpu(*(volatile u32 *)(RALINK_PCI_BASE+(ofs)))
-
 #define MV_WRITE_16(ofs, data) \
*(volatile u16 *)(RALINK_PCI_BASE+(ofs)) = cpu_to_le16(data)
 #define MV_READ_16(ofs, data)  \
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 08/23] staging: mt7621-pci: remove no more needed macros

2018-07-09 Thread Sergio Paracuellos
This macros are not being used anymore along the code.
Just remove all of them.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-pci/pci-mt7621.c | 14 --
 1 file changed, 14 deletions(-)

diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c 
b/drivers/staging/mt7621-pci/pci-mt7621.c
index ca6c7ca..a4cee1e 100644
--- a/drivers/staging/mt7621-pci/pci-mt7621.c
+++ b/drivers/staging/mt7621-pci/pci-mt7621.c
@@ -113,20 +113,6 @@
 #define RALINK_PCIEPHY_P0P1_CTL_OFFSET (RALINK_PCI_BASE + 0x9000)
 #define RALINK_PCIEPHY_P2_CTL_OFFSET   (RALINK_PCI_BASE + 0xA000)
 
-#define MV_WRITE(ofs, data)\
-   *(volatile u32 *)(RALINK_PCI_BASE+(ofs)) = cpu_to_le32(data)
-#define MV_READ(ofs, data) \
-   *(data) = le32_to_cpu(*(volatile u32 *)(RALINK_PCI_BASE+(ofs)))
-#define MV_WRITE_16(ofs, data) \
-   *(volatile u16 *)(RALINK_PCI_BASE+(ofs)) = cpu_to_le16(data)
-#define MV_READ_16(ofs, data)  \
-   *(data) = le16_to_cpu(*(volatile u16 *)(RALINK_PCI_BASE+(ofs)))
-
-#define MV_WRITE_8(ofs, data)  \
-   *(volatile u8 *)(RALINK_PCI_BASE+(ofs)) = data
-#define MV_READ_8(ofs, data)   \
-   *(data) = *(volatile u8 *)(RALINK_PCI_BASE+(ofs))
-
 #define RALINK_PCI_MM_MAP_BASE 0x6000
 #define RALINK_PCI_IO_MAP_BASE 0x1e16
 
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 02/23] staging: mt7621-pci: factor out mt7621_pci_get_cfgaddr function

2018-07-09 Thread Sergio Paracuellos
To get config address the same pattern is repeated in some functions
along the code. Factor out a new mt7621_pci_get_cfgaddr for calculate
it and use it in convenient places. Adjust types to match to u32 where
is neccesary.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-pci/pci-mt7621.c | 21 ++---
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c 
b/drivers/staging/mt7621-pci/pci-mt7621.c
index 89a57a0..4f56840 100644
--- a/drivers/staging/mt7621-pci/pci-mt7621.c
+++ b/drivers/staging/mt7621-pci/pci-mt7621.c
@@ -177,19 +177,26 @@ static int pcie_link_status = 0;
 #define PCI_ACCESS_WRITE_2 4
 #define PCI_ACCESS_WRITE_4 5
 
+static inline u32 mt7621_pci_get_cfgaddr(unsigned int bus, unsigned int slot,
+unsigned int func, unsigned int where)
+{
+   return (((where & 0xF00) >> 8) << 24) | (bus << 16) | (slot << 11) |
+   (func << 8) | (where & 0xfc) | 0x8000;
+}
+
 static int config_access(unsigned char access_type, struct pci_bus *bus,
unsigned int devfn, unsigned int where, u32 *data)
 {
unsigned int slot = PCI_SLOT(devfn);
u8 func = PCI_FUNC(devfn);
-   uint32_t address_reg, data_reg;
+   u32 address_reg, data_reg;
unsigned int address;
 
address_reg = RALINK_PCI_CONFIG_ADDR;
data_reg = RALINK_PCI_CONFIG_DATA_VIRTUAL_REG;
 
-   address = (((where&0xF00)>>8)<<24) |(bus->number << 16) | (slot << 11) |
-   (func << 8) | (where & 0xfc) | 0x8000;
+   address = mt7621_pci_get_cfgaddr(bus->number, slot, func, where);
+
MV_WRITE(address_reg, address);
 
switch (access_type) {
@@ -305,11 +312,11 @@ static struct pci_controller mt7621_controller = {
 static void
 read_config(unsigned long bus, unsigned long dev, unsigned long func, unsigned 
long reg, unsigned long *val)
 {
-   unsigned int address_reg, data_reg, address;
+   u32 address_reg, data_reg, address;
 
address_reg = RALINK_PCI_CONFIG_ADDR;
data_reg = RALINK_PCI_CONFIG_DATA_VIRTUAL_REG;
-   address = (((reg & 0xF00)>>8)<<24) | (bus << 16) | (dev << 11) | (func 
<< 8) | (reg & 0xfc) | 0x8000 ;
+   address = mt7621_pci_get_cfgaddr(bus, dev, func, reg);
MV_WRITE(address_reg, address);
MV_READ(data_reg, val);
return;
@@ -318,11 +325,11 @@ read_config(unsigned long bus, unsigned long dev, 
unsigned long func, unsigned l
 static void
 write_config(unsigned long bus, unsigned long dev, unsigned long func, 
unsigned long reg, unsigned long val)
 {
-   unsigned int address_reg, data_reg, address;
+   u32 address_reg, data_reg, address;
 
address_reg = RALINK_PCI_CONFIG_ADDR;
data_reg = RALINK_PCI_CONFIG_DATA_VIRTUAL_REG;
-   address = (((reg & 0xF00)>>8)<<24) | (bus << 16) | (dev << 11) | (func 
<< 8) | (reg & 0xfc) | 0x8000 ;
+   address = mt7621_pci_get_cfgaddr(bus, dev, func, reg);
MV_WRITE(address_reg, address);
MV_WRITE(data_reg, val);
return;
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 03/23] staging: mt7621-pci: add new variable to be set to PCI base address

2018-07-09 Thread Sergio Paracuellos
Add new 'mt7621_pci_base' variable as a pointer to definition
RALINK_PCI_BASE to use it along the code.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-pci/pci-mt7621.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c 
b/drivers/staging/mt7621-pci/pci-mt7621.c
index 4f56840..b745423 100644
--- a/drivers/staging/mt7621-pci/pci-mt7621.c
+++ b/drivers/staging/mt7621-pci/pci-mt7621.c
@@ -177,6 +177,8 @@ static int pcie_link_status = 0;
 #define PCI_ACCESS_WRITE_2 4
 #define PCI_ACCESS_WRITE_4 5
 
+static void __iomem *mt7621_pci_base;
+
 static inline u32 mt7621_pci_get_cfgaddr(unsigned int bus, unsigned int slot,
 unsigned int func, unsigned int where)
 {
@@ -483,6 +485,7 @@ static int mt7621_pci_probe(struct platform_device *pdev)
 {
unsigned long val = 0;
 
+   mt7621_pci_base = (void __iomem *)RALINK_PCI_BASE;
iomem_resource.start = 0;
iomem_resource.end = ~0;
ioport_resource.start = 0;
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 19/23] staging: mt7621-pci: add blank line between declarations and code statements

2018-07-09 Thread Sergio Paracuellos
There was a missing line between declarations and code statements in function
setup_cm_memory_region. this improves readability.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-pci/pci-mt7621.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c 
b/drivers/staging/mt7621-pci/pci-mt7621.c
index 1be2a11..f9149da 100644
--- a/drivers/staging/mt7621-pci/pci-mt7621.c
+++ b/drivers/staging/mt7621-pci/pci-mt7621.c
@@ -418,6 +418,7 @@ set_phy_for_ssc(void)
 void setup_cm_memory_region(struct resource *mem_resource)
 {
resource_size_t mask;
+
if (mips_cps_numiocu(0)) {
/* FIXME: hardware doesn't accept mask values with 1s after
 * 0s (e.g. 0xffef), so it would be great to warn if that's
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 20/23] staging: mt7621-pci: remove unused preprocessor defines

2018-07-09 Thread Sergio Paracuellos
There are a lot of definitions that are not being used at all.
Just remove them cleaning the code a bit.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-pci/pci-mt7621.c | 20 ++--
 1 file changed, 2 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c 
b/drivers/staging/mt7621-pci/pci-mt7621.c
index f9149da..3e2469a 100644
--- a/drivers/staging/mt7621-pci/pci-mt7621.c
+++ b/drivers/staging/mt7621-pci/pci-mt7621.c
@@ -116,10 +116,7 @@ static struct pcie_controller_data pcie_controllers[] = {
 #define RALINK_PCI_IMBASEBAR0_ADDR(dev)(pcie_controllers[(dev)].offset 
+ 0x0018)
 #define RALINK_PCI_ID(dev) (pcie_controllers[(dev)].offset + 
0x0030)
 #define RALINK_PCI_CLASS(dev)  (pcie_controllers[(dev)].offset + 
0x0034)
-#define RALINK_PCI_SUBID(dev)  (pcie_controllers[(dev)].offset + 
0x0038)
 #define RALINK_PCI_STATUS(dev) (pcie_controllers[(dev)].offset + 
0x0050)
-#define RALINK_PCI_DERR(dev)   (pcie_controllers[(dev)].offset + 
0x0060)
-#define RALINK_PCI_ECRC(dev)   (pcie_controllers[(dev)].offset + 
0x0064)
 
 #define RALINK_PCIEPHY_P0P1_CTL_OFFSET 0x9000
 #define RALINK_PCIEPHY_P2_CTL_OFFSET   0xA000
@@ -132,25 +129,12 @@ static struct pcie_controller_data pcie_controllers[] = {
 #define RALINK_GPIOMODE0x60
 #define RALINK_PCIE_CLK_GEN0x7c
 #define RALINK_PCIE_CLK_GEN1   0x80
-#define PPLL_CFG1  0x9c
-#define PPLL_DRV   0xa0
-/* SYSC_REG_SYSTEM_CONFIG1 bits */
-#define RALINK_PCI_HOST_MODE_ENBIT(7)
-#define RALINK_PCIE_RC_MODE_EN BIT(8)
+
 //RALINK_RSTCTRL bit
 #define RALINK_PCIE_RSTBIT(23)
-#define RALINK_PCI_RST BIT(24)
-//RALINK_CLKCFG1 bit
-#define RALINK_PCI_CLK_EN  BIT(19)
-#define RALINK_PCIE_CLK_EN BIT(21)
-//RALINK_GPIOMODE bit
-#define PCI_SLOTx2 BIT(11)
-#define PCI_SLOTx1 (2<<11)
-//MTK PCIE PLL bit
-#define PDRV_SW_SETBIT(31)
-#define LC_CKDRVPD_BIT(19)
 
 #define MEMORY_BASE 0x0
+
 static int pcie_link_status = 0;
 
 static void __iomem *mt7621_pci_base;
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 09/23] staging: mt7621-pci: simplify pci dependant registers arithmetics

2018-07-09 Thread Sergio Paracuellos
PCI controller dependant register was handled with different
custom macros including very ugly pointer aritmethics. Simplify
them adding an array of offset per controller and a macro to get
the relative offset for each register for the controller. To avoid
arithmetics add two simple mt7621_pci_reg_[read|write] functions
where the base is neing taking into account to get and do the correct
operations. Register useds along the code modified to use the new
approach.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-pci/pci-mt7621.c | 81 -
 1 file changed, 39 insertions(+), 42 deletions(-)

diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c 
b/drivers/staging/mt7621-pci/pci-mt7621.c
index a4cee1e..05e8f4a 100644
--- a/drivers/staging/mt7621-pci/pci-mt7621.c
+++ b/drivers/staging/mt7621-pci/pci-mt7621.c
@@ -79,36 +79,20 @@
 #define RALINK_PCI_BASE0xBE14
 
 #define RALINK_PCIEPHY_P0P1_CTL_OFFSET (RALINK_PCI_BASE + 0x9000)
-#define RT6855_PCIE0_OFFSET0x2000
-#define RT6855_PCIE1_OFFSET0x3000
-#define RT6855_PCIE2_OFFSET0x4000
-
-#define RALINK_PCI0_BAR0SETUP_ADDR *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE0_OFFSET + 0x0010)
-#define RALINK_PCI0_IMBASEBAR0_ADDR*(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE0_OFFSET + 0x0018)
-#define RALINK_PCI0_ID *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE0_OFFSET + 0x0030)
-#define RALINK_PCI0_CLASS  *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE0_OFFSET + 0x0034)
-#define RALINK_PCI0_SUBID  *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE0_OFFSET + 0x0038)
-#define RALINK_PCI0_STATUS *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE0_OFFSET + 0x0050)
-#define RALINK_PCI0_DERR   *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE0_OFFSET + 0x0060)
-#define RALINK_PCI0_ECRC   *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE0_OFFSET + 0x0064)
-
-#define RALINK_PCI1_BAR0SETUP_ADDR *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE1_OFFSET + 0x0010)
-#define RALINK_PCI1_IMBASEBAR0_ADDR*(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE1_OFFSET + 0x0018)
-#define RALINK_PCI1_ID *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE1_OFFSET + 0x0030)
-#define RALINK_PCI1_CLASS  *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE1_OFFSET + 0x0034)
-#define RALINK_PCI1_SUBID  *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE1_OFFSET + 0x0038)
-#define RALINK_PCI1_STATUS *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE1_OFFSET + 0x0050)
-#define RALINK_PCI1_DERR   *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE1_OFFSET + 0x0060)
-#define RALINK_PCI1_ECRC   *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE1_OFFSET + 0x0064)
-
-#define RALINK_PCI2_BAR0SETUP_ADDR *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE2_OFFSET + 0x0010)
-#define RALINK_PCI2_IMBASEBAR0_ADDR*(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE2_OFFSET + 0x0018)
-#define RALINK_PCI2_ID *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE2_OFFSET + 0x0030)
-#define RALINK_PCI2_CLASS  *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE2_OFFSET + 0x0034)
-#define RALINK_PCI2_SUBID  *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE2_OFFSET + 0x0038)
-#define RALINK_PCI2_STATUS *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE2_OFFSET + 0x0050)
-#define RALINK_PCI2_DERR   *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE2_OFFSET + 0x0060)
-#define RALINK_PCI2_ECRC   *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE2_OFFSET + 0x0064)
+
+static u16 pcie_controller_offsets[] = {
+   0x2000, 0x3000, 0x4000,
+};
+
+#define RALINK_PCI_BAR0SETUP_ADDR(dev) (pcie_controller_offsets[(dev)] + 
0x0010)
+#define RALINK_PCI_IMBASEBAR0_ADDR(dev)(pcie_controller_offsets[(dev)] 
+ 0x0018)
+#define RALINK_PCI_ID(dev) (pcie_controller_offsets[(dev)] + 
0x0030)
+#define RALINK_PCI_CLASS(dev)  (pcie_controller_offsets[(dev)] + 
0x0034)
+#define RALINK_PCI_SUBID(dev)  (pcie_controller_offsets[(dev)] + 
0x0038)
+#define RALINK_PCI_STATUS(dev) (pcie_controller_offsets[(dev)] + 
0x0050)
+#define RALINK_PCI_DERR(dev)   (pcie_controller_offsets[(dev)] + 
0x0060)
+#define RALINK_PCI_ECRC(dev)   (pcie_controller_offsets[(dev)] + 
0x0064)
+
 
 #define RALINK_PCIEPHY_P0P1_CTL_OFFSET (RALINK_PCI_BASE + 0x9000)
 #define RALINK_PCIEPHY_P2_CTL_OFFSET   (RALINK_PCI_BASE + 0xA000)
@@ -158,6 +142,16 @@ static int pcie_link_status = 0;
 
 static void __iomem *mt7621_pci_base;
 
+static u32 mt7621_pci_reg_read(u32 reg)
+{
+   return readl(mt7621_pci_base + reg);
+}
+
+static void mt7621_pci_reg_write(u32 val, u32 reg)
+{
+   writel(val, mt7621_pci_base + reg);
+}
+
 static inline u32 mt7621_pci_get_cfgaddr(unsigned int bus, unsigned int slot,

[PATCH v3 00/23] staging: mt7621-pci: Some cleanups

2018-07-09 Thread Sergio Paracuellos
This patch series clean up a bit mt7621-pci driver.

Chnages in v3:
- PATCH 1 has been splited in several patches for better review
- PATCH "avoid pointer arithmetics in some macros" gets back
  a needed switch statement as it has been pointed out here:
  
http://driverdev.linuxdriverproject.org/pipermail/driverdev-devel/2018-July/122872.html

Changes in v2:
- It includes new 17 patches from PATCH 2 to PATCH 18
- PATCH 1 was send before alone and is being included
  as it is in this new series.

Hope this helps.

Best regards,
Sergio Paracuellos

Sergio Paracuellos (23):
  staging: mt7621-pci: remove unused macro MV_READ_DATA
  staging: mt7621-pci: factor out mt7621_pci_get_cfgaddr function
  staging: mt7621-pci: add new variable to be set to PCI base address
  staging: mt7621-pci: reimplement pci_config_[read|write] functions
  staging: mt7621-pci: remove no more needed helper functions and macros
  staging: mt7621-pci: avoid long lines in read_config and write_config
functions
  staging: mt7621-pci: use writel and readl instead of custom macros
  staging: mt7621-pci: remove no more needed macros
  staging: mt7621-pci: simplify pci dependant registers arithmetics
  staging: mt7621-pci: avoid pointer arithmetics in some macros
  staging: mt7621-pci: use BIT macro in definitions
  staging: mt7621-pci: use read and writes in set_pcie_phy function
  staging: mt7621-pci: make ASSERT_SYSRST_PCIE and DEASSERT_SYSRST_PCIE
inline functions
  staging: mt7621-pci: rewrite [read|write]_config functions
  staging: mt7621-pci: factor out mt7621_pci_enable_irqs and
mt7621_pci_disable
  staging: mt7621-pci: minor refactor in duplicated code
  staging: mt7621-pci: factor out mt7621_pci_enable function
  staging: mt7621-pci: factor out mt7621_pci_configure function
  staging: mt7621-pci: add blank line between declarations and code
statements
  staging: mt7621-pci: remove unused preprocessor defines
  staging: mt7621-pci: rename RALINK_PCI_CONFIG_DATA_VIRTUAL_REG
definition
  staging: mt7621-pci: fix and remove some comments
  staging: mt7621-pci: factor out mt7621_pci_init_gpios function

 drivers/staging/mt7621-pci/pci-mt7621.c | 676 +++-
 1 file changed, 311 insertions(+), 365 deletions(-)

-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 05/23] staging: mt7621-pci: remove no more needed helper functions and macros

2018-07-09 Thread Sergio Paracuellos
Re-implement pci_config_write and pci_config_read makes some
functions and definitions to be dead code. Remove all of them.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-pci/pci-mt7621.c | 93 -
 1 file changed, 93 deletions(-)

diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c 
b/drivers/staging/mt7621-pci/pci-mt7621.c
index 122c046..ed46d04 100644
--- a/drivers/staging/mt7621-pci/pci-mt7621.c
+++ b/drivers/staging/mt7621-pci/pci-mt7621.c
@@ -170,13 +170,6 @@
 #define MEMORY_BASE 0x0
 static int pcie_link_status = 0;
 
-#define PCI_ACCESS_READ_1  0
-#define PCI_ACCESS_READ_2  1
-#define PCI_ACCESS_READ_4  2
-#define PCI_ACCESS_WRITE_1 3
-#define PCI_ACCESS_WRITE_2 4
-#define PCI_ACCESS_WRITE_4 5
-
 static void __iomem *mt7621_pci_base;
 
 static inline u32 mt7621_pci_get_cfgaddr(unsigned int bus, unsigned int slot,
@@ -186,92 +179,6 @@ static inline u32 mt7621_pci_get_cfgaddr(unsigned int bus, 
unsigned int slot,
(func << 8) | (where & 0xfc) | 0x8000;
 }
 
-static int config_access(unsigned char access_type, struct pci_bus *bus,
-   unsigned int devfn, unsigned int where, u32 *data)
-{
-   unsigned int slot = PCI_SLOT(devfn);
-   u8 func = PCI_FUNC(devfn);
-   u32 address_reg, data_reg;
-   unsigned int address;
-
-   address_reg = RALINK_PCI_CONFIG_ADDR;
-   data_reg = RALINK_PCI_CONFIG_DATA_VIRTUAL_REG;
-
-   address = mt7621_pci_get_cfgaddr(bus->number, slot, func, where);
-
-   MV_WRITE(address_reg, address);
-
-   switch (access_type) {
-   case PCI_ACCESS_WRITE_1:
-   MV_WRITE_8(data_reg+(where&0x3), *data);
-   break;
-   case PCI_ACCESS_WRITE_2:
-   MV_WRITE_16(data_reg+(where&0x3), *data);
-   break;
-   case PCI_ACCESS_WRITE_4:
-   MV_WRITE(data_reg, *data);
-   break;
-   case PCI_ACCESS_READ_1:
-   MV_READ_8(data_reg+(where&0x3), data);
-   break;
-   case PCI_ACCESS_READ_2:
-   MV_READ_16(data_reg+(where&0x3), data);
-   break;
-   case PCI_ACCESS_READ_4:
-   MV_READ(data_reg, data);
-   break;
-   default:
-   printk("no specify access type\n");
-   break;
-   }
-   return 0;
-}
-
-static int
-read_config_byte(struct pci_bus *bus, unsigned int devfn, int where, u8 *val)
-{
-   return config_access(PCI_ACCESS_READ_1, bus, devfn, (unsigned 
int)where, (u32 *)val);
-}
-
-static int
-read_config_word(struct pci_bus *bus, unsigned int devfn, int where, u16 *val)
-{
-   return config_access(PCI_ACCESS_READ_2, bus, devfn, (unsigned 
int)where, (u32 *)val);
-}
-
-static int
-read_config_dword(struct pci_bus *bus, unsigned int devfn, int where, u32 *val)
-{
-   return config_access(PCI_ACCESS_READ_4, bus, devfn, (unsigned 
int)where, (u32 *)val);
-}
-
-static int
-write_config_byte(struct pci_bus *bus, unsigned int devfn, int where, u8 val)
-{
-   if (config_access(PCI_ACCESS_WRITE_1, bus, devfn, (unsigned int)where, 
(u32 *)))
-   return -1;
-
-   return PCIBIOS_SUCCESSFUL;
-}
-
-static int
-write_config_word(struct pci_bus *bus, unsigned int devfn, int where, u16 val)
-{
-   if (config_access(PCI_ACCESS_WRITE_2, bus, devfn, where, (u32 *)))
-   return -1;
-
-   return PCIBIOS_SUCCESSFUL;
-}
-
-static int
-write_config_dword(struct pci_bus *bus, unsigned int devfn, int where, u32 val)
-{
-   if (config_access(PCI_ACCESS_WRITE_4, bus, devfn, where, ))
-   return -1;
-
-   return PCIBIOS_SUCCESSFUL;
-}
-
 static int
 pci_config_read(struct pci_bus *bus, unsigned int devfn,
int where, int size, u32 *val)
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 10/23] staging: mt7621-pci: avoid pointer arithmetics in some macros

2018-07-09 Thread Sergio Paracuellos
RALINK_PCI_MEMBASE, RALINK_PCI_IOBASE, RALINK_PCI_PCICFG_ADDR and
RALINK_PCI_PCIMSK_ADDR are using very ugly pointer arithmetics to
read and write along the code. Instead of doing this, use the
mt7621_pci_reg_read and mt7621_pci_reg_write functions making
this a bit cleaner.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-pci/pci-mt7621.c | 57 +++--
 1 file changed, 33 insertions(+), 24 deletions(-)

diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c 
b/drivers/staging/mt7621-pci/pci-mt7621.c
index 05e8f4a..7cd8f8a 100644
--- a/drivers/staging/mt7621-pci/pci-mt7621.c
+++ b/drivers/staging/mt7621-pci/pci-mt7621.c
@@ -68,14 +68,14 @@
 
 #define RALINK_PCI_CONFIG_ADDR 0x20
 #define RALINK_PCI_CONFIG_DATA_VIRTUAL_REG 0x24
-#define RALINK_PCI_MEMBASE *(volatile u32 *)(RALINK_PCI_BASE + 
0x0028)
-#define RALINK_PCI_IOBASE  *(volatile u32 *)(RALINK_PCI_BASE + 
0x002C)
+#define RALINK_PCI_MEMBASE 0x0028
+#define RALINK_PCI_IOBASE  0x002C
 #define RALINK_PCIE0_RST   (1<<24)
 #define RALINK_PCIE1_RST   (1<<25)
 #define RALINK_PCIE2_RST   (1<<26)
 
-#define RALINK_PCI_PCICFG_ADDR *(volatile u32 *)(RALINK_PCI_BASE + 
0x)
-#define RALINK_PCI_PCIMSK_ADDR *(volatile u32 *)(RALINK_PCI_BASE + 
0x000C)
+#define RALINK_PCI_PCICFG_ADDR 0x
+#define RALINK_PCI_PCIMSK_ADDR 0x000C
 #define RALINK_PCI_BASE0xBE14
 
 #define RALINK_PCIEPHY_P0P1_CTL_OFFSET (RALINK_PCI_BASE + 0x9000)
@@ -404,6 +404,7 @@ void setup_cm_memory_region(struct resource *mem_resource)
 
 static int mt7621_pci_probe(struct platform_device *pdev)
 {
+   u32 mask;
unsigned long val = 0;
 
mt7621_pci_base = (void __iomem *)RALINK_PCI_BASE;
@@ -467,7 +468,9 @@ static int mt7621_pci_probe(struct platform_device *pdev)
pcie_link_status &= ~(1<<0);
} else {
pcie_link_status |= 1<<0;
-   RALINK_PCI_PCIMSK_ADDR |= (1<<20); // enable pcie1 interrupt
+   mask = mt7621_pci_reg_read(RALINK_PCI_PCIMSK_ADDR);
+   mask |= (1<<20); // enable pcie1 interrupt
+   mt7621_pci_reg_write(mask, RALINK_PCI_PCIMSK_ADDR);
}
 
if ((mt7621_pci_reg_read(RALINK_PCI_STATUS(1)) & 0x1) == 0) {
@@ -477,7 +480,9 @@ static int mt7621_pci_probe(struct platform_device *pdev)
pcie_link_status &= ~(1<<1);
} else {
pcie_link_status |= 1<<1;
-   RALINK_PCI_PCIMSK_ADDR |= (1<<21); // enable pcie1 interrupt
+   mask = mt7621_pci_reg_read(RALINK_PCI_PCIMSK_ADDR);
+   mask |= (1<<21); // enable pcie1 interrupt
+   mt7621_pci_reg_write(mask, RALINK_PCI_PCIMSK_ADDR);
}
 
if ((mt7621_pci_reg_read(RALINK_PCI_STATUS(2)) & 0x1) == 0) {
@@ -487,7 +492,9 @@ static int mt7621_pci_probe(struct platform_device *pdev)
pcie_link_status &= ~(1<<2);
} else {
pcie_link_status |= 1<<2;
-   RALINK_PCI_PCIMSK_ADDR |= (1<<22); // enable pcie2 interrupt
+   mask = mt7621_pci_reg_read(RALINK_PCI_PCIMSK_ADDR);
+   mask |= (1<<22); // enable pcie2 interrupt
+   mt7621_pci_reg_write(mask, RALINK_PCI_PCIMSK_ADDR);
}
 
if (pcie_link_status == 0)
@@ -504,39 +511,41 @@ pcie(2/1/0) link status   pcie2_num   pcie1_num   
pcie0_num
 3'b110 1   0   x
 3'b111 2   1   0
 */
+   mask = mt7621_pci_reg_read(RALINK_PCI_PCICFG_ADDR);
switch (pcie_link_status) {
case 2:
-   RALINK_PCI_PCICFG_ADDR &= ~0x00ff;
-   RALINK_PCI_PCICFG_ADDR |= 0x1 << 16;//port0
-   RALINK_PCI_PCICFG_ADDR |= 0x0 << 20;//port1
+   mask &= ~0x00ff;
+   mask |= (0x1 << 16); // port0
+   mask |= (0x0 << 20); // port1
break;
case 4:
-   RALINK_PCI_PCICFG_ADDR &= ~0x0fff;
-   RALINK_PCI_PCICFG_ADDR |= 0x1 << 16;//port0
-   RALINK_PCI_PCICFG_ADDR |= 0x2 << 20;//port1
-   RALINK_PCI_PCICFG_ADDR |= 0x0 << 24;//port2
+   mask &= ~0x0fff;
+   mask |= (0x1 << 16); // port0
+   mask |= (0x2 << 20); // port1
break;
case 5:
-   RALINK_PCI_PCICFG_ADDR &= ~0x0fff;
-   RALINK_PCI_PCICFG_ADDR |= 0x0 << 16;//port0
-   RALINK_PCI_PCICFG_ADDR |= 0x2 << 20;//port1
-   RALINK_PCI_PCICFG_ADDR |= 0x1 << 24;//port2
+   mask &= ~0x0fff;
+   mask |= (0x0 << 16); // port0
+   mask |= (0x2 << 20); // port1
+   mask |= (0x1 << 24); // port2
break;
case 6:
-   RALINK_PCI_PCICFG_ADDR &= 

Re: [PATCH 5/5] staging: fsl-dpaa2/eth: Remove Rx frame size check

2018-07-09 Thread Dan Carpenter
On Mon, Jul 09, 2018 at 10:01:11AM -0500, Ioana Radulescu wrote:
> @@ -2385,6 +2365,12 @@ static int netdev_init(struct net_device *net_dev)
>  
>   /* Set MTU upper limit; lower limit is 68B (default value) */
>   net_dev->max_mtu = DPAA2_ETH_MAX_MTU;
> + err = dpni_set_max_frame_length(priv->mc_io, 0, priv->mc_token,
> + (u16)DPAA2_ETH_MFL);

The cast was there in the original code so this is not a comment on this
particular patch (which seems fine) but there is no need to cast.

Generally it's best to avoid unnecessary casts.  As a human reader, I
find the cast confusing.  It indicates that DPAA2_ETH_MFL somehow
requires special handling.  Perhaps it's negative or we are trying to
truncate away the high bits.  But neither of those things really make
sense.

>From a static analysis perspective if DPAA2_ETH_MFL doesn't fit nicely
then we would want to generate a warning.  But the cast explicitly
disables the check.

regards,
dan carpenter


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH net] hv_netvsc: Fix napi reschedule while receive completion is busy

2018-07-09 Thread Haiyang Zhang



> -Original Message-
> From: Stephen Hemminger 
> Sent: Monday, July 9, 2018 2:15 PM
> To: Haiyang Zhang 
> Cc: Haiyang Zhang ; da...@davemloft.net;
> net...@vger.kernel.org; o...@aepfle.de; Stephen Hemminger
> ; linux-ker...@vger.kernel.org;
> de...@linuxdriverproject.org; vkuzn...@redhat.com
> Subject: Re: [PATCH net] hv_netvsc: Fix napi reschedule while receive
> completion is busy
> 
> On Mon,  9 Jul 2018 16:43:19 +
> Haiyang Zhang  wrote:
> 
> > From: Haiyang Zhang 
> >
> > If out ring is full temporarily and receive completion cannot go out,
> > we may still need to reschedule napi if other conditions are met.
> > Otherwise the napi poll might be stopped forever, and cause network
> > disconnect.
> >
> > Fixes: 7426b1a51803 ("netvsc: optimize receive completions")
> > Signed-off-by: Haiyang Zhang 
> > ---
> >  drivers/net/hyperv/netvsc.c | 8 
> >  1 file changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
> > index 8e9d0ee1572b..caaf5054f446 100644
> > --- a/drivers/net/hyperv/netvsc.c
> > +++ b/drivers/net/hyperv/netvsc.c
> > @@ -1285,14 +1285,14 @@ int netvsc_poll(struct napi_struct *napi, int
> budget)
> > nvchan->desc = hv_pkt_iter_next(channel, nvchan->desc);
> > }
> >
> > -   /* If send of pending receive completions suceeded
> > -*   and did not exhaust NAPI budget this time
> > +   send_recv_completions(ndev, net_device, nvchan);
> > +
> > +   /* If it did not exhaust NAPI budget this time
> >  *   and not doing busy poll
> >  * then re-enable host interrupts
> >  * and reschedule if ring is not empty.
> >  */
> > -   if (send_recv_completions(ndev, net_device, nvchan) == 0 &&
> > -   work_done < budget &&
> > +   if (work_done < budget &&
> > napi_complete_done(napi, work_done) &&
> > hv_end_read(>inbound) &&
> > napi_schedule_prep(napi)) {
> 
> This patch doesn't look right. I think the existing code works as written.
> 
> If send_receive_completions is unable to send because ring is full then
> vmbus_sendpacket will return -EBUSY which gets returns from
> send_receive_completions.  Because the return is non-zero, the driver will not
> call napi_complete_done.
> Since napi_complete_done was not called, NAPI will reschedule the napi poll
> routine.

With the existing code, we found in test, the rx_comp_busy counter increased,
one of the in-ring mask is 1, but guest is not reading it... With this patch, 
the 
pending receive completion will stay in the buffer (no loss), and be sent next 
time. 
It solves the disconnection problem when high number of connections.

If not calling napi_complete_done(), upper layer should guarantee napi_schedule,
then seems the upper NAPI code may have a bug -- the auto scheduling did not
happen in this case. I will check it further.

Thanks,
- Haiyang

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH net] hv_netvsc: Fix napi reschedule while receive completion is busy

2018-07-09 Thread Stephen Hemminger
On Mon,  9 Jul 2018 16:43:19 +
Haiyang Zhang  wrote:

> From: Haiyang Zhang 
> 
> If out ring is full temporarily and receive completion cannot go out,
> we may still need to reschedule napi if other conditions are met.
> Otherwise the napi poll might be stopped forever, and cause network
> disconnect.
> 
> Fixes: 7426b1a51803 ("netvsc: optimize receive completions")
> Signed-off-by: Haiyang Zhang 
> ---
>  drivers/net/hyperv/netvsc.c | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
> index 8e9d0ee1572b..caaf5054f446 100644
> --- a/drivers/net/hyperv/netvsc.c
> +++ b/drivers/net/hyperv/netvsc.c
> @@ -1285,14 +1285,14 @@ int netvsc_poll(struct napi_struct *napi, int budget)
>   nvchan->desc = hv_pkt_iter_next(channel, nvchan->desc);
>   }
>  
> - /* If send of pending receive completions suceeded
> -  *   and did not exhaust NAPI budget this time
> + send_recv_completions(ndev, net_device, nvchan);
> +
> + /* If it did not exhaust NAPI budget this time
>*   and not doing busy poll
>* then re-enable host interrupts
>* and reschedule if ring is not empty.
>*/
> - if (send_recv_completions(ndev, net_device, nvchan) == 0 &&
> - work_done < budget &&
> + if (work_done < budget &&
>   napi_complete_done(napi, work_done) &&
>   hv_end_read(>inbound) &&
>   napi_schedule_prep(napi)) {

This patch doesn't look right. I think the existing code works
as written.

If send_receive_completions is unable to send because ring is full
then vmbus_sendpacket will return -EBUSY which gets returns
from send_receive_completions.  Because the return is non-zero,
the driver will not call napi_complete_done.
Since napi_complete_done was not called, NAPI will reschedule
the napi poll routine.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/2] x86/hyper-v: check for VP_INVAL in hyperv_flush_tlb_others()

2018-07-09 Thread Vitaly Kuznetsov
Commit 1268ed0c474a ("x86/hyper-v: Fix the circular dependency in IPI
 enlightenment") pre-filled hv_vp_index with VP_INVAL so it is now
(theoretically) possible to observe hv_cpu_number_to_vp_number()
returning VP_INVAL. We need to check for that in hyperv_flush_tlb_others().

Not checking for VP_INVAL on the first call site where we do

 if (hv_cpu_number_to_vp_number(cpumask_last(cpus)) >= 64)
goto do_ex_hypercall;

is OK, in case we're eligible for non-ex hypercall we'll catch the
issue later in for_each_cpu() cycle and in case we'll be doing ex-
hypercall cpumask_to_vpset() will fail.

It would be nice to change hv_cpu_number_to_vp_number() return
value's type to 'u32' but this will likely be a bigger change as
all call sites need to be checked first.

Fixes: 1268ed0c474a ("x86/hyper-v: Fix the circular dependency in IPI 
enlightenment")
Signed-off-by: Vitaly Kuznetsov 
---
 arch/x86/hyperv/mmu.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/arch/x86/hyperv/mmu.c b/arch/x86/hyperv/mmu.c
index 453d2355cd61..1147e1fed7ff 100644
--- a/arch/x86/hyperv/mmu.c
+++ b/arch/x86/hyperv/mmu.c
@@ -111,6 +111,11 @@ static void hyperv_flush_tlb_others(const struct cpumask 
*cpus,
 
for_each_cpu(cpu, cpus) {
vcpu = hv_cpu_number_to_vp_number(cpu);
+   if (vcpu == VP_INVAL) {
+   local_irq_restore(flags);
+   goto do_native;
+   }
+
if (vcpu >= 64)
goto do_ex_hypercall;
 
-- 
2.14.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 0/2] x86/hyper-v: cope with VP_INVAL in PV TLB flush code

2018-07-09 Thread Vitaly Kuznetsov
Commit 1268ed0c474a ("x86/hyper-v: Fix the circular dependency in IPI
 enlightenment") made it possible to observe VP_INVAL returned from 
hv_cpu_number_to_vp_number() and cpumask_to_vpset() and PV TLB flush
code needs to be adjusted.

The window when VP_INVAL is observable is very short, I'm not even sure
we do TLB flushes during this period (secodary CPUs bringup on boot, there
is no CPU hotplug on Hyper-V yet). This, however, may change in future so
let's fix this now.

Thomas, Ingo: these patches are for 'tip/x86/hyperv'. I don't think we have
a real issue in 4.18 but I can definitely prepare fixes for it if you think
this is needed.

Vitaly Kuznetsov (2):
  x86/hyper-v: check cpumask_to_vpset() return value in
hyperv_flush_tlb_others_ex()
  x86/hyper-v: check for VP_INVAL in hyperv_flush_tlb_others()

 arch/x86/hyperv/mmu.c | 7 +++
 1 file changed, 7 insertions(+)

-- 
2.14.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/2] x86/hyper-v: check cpumask_to_vpset() return value in hyperv_flush_tlb_others_ex()

2018-07-09 Thread Vitaly Kuznetsov
Commit 1268ed0c474a ("x86/hyper-v: Fix the circular dependency in IPI
enlightenment") made cpumask_to_vpset() return '-1' when there is a CPU
with unknown VP index in the supplied set. This needs to be checked before
we pass 'nr_bank' to hypercall.

Fixes: 1268ed0c474a ("x86/hyper-v: Fix the circular dependency in IPI 
enlightenment")
Signed-off-by: Vitaly Kuznetsov 
---
 arch/x86/hyperv/mmu.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/x86/hyperv/mmu.c b/arch/x86/hyperv/mmu.c
index 0d90e515ec98..453d2355cd61 100644
--- a/arch/x86/hyperv/mmu.c
+++ b/arch/x86/hyperv/mmu.c
@@ -186,6 +186,8 @@ static u64 hyperv_flush_tlb_others_ex(const struct cpumask 
*cpus,
 
flush->hv_vp_set.format = HV_GENERIC_SET_SPARSE_4K;
nr_bank = cpumask_to_vpset(&(flush->hv_vp_set), cpus);
+   if (nr_bank < 0)
+   return U64_MAX;
 
/*
 * We can flush not more than max_gvas with one hypercall. Flush the
-- 
2.14.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/5] staging: fsl-dpaa2/eth: Fix DMA mapping direction

2018-07-09 Thread Ioana Radulescu
We are using DMA_FROM_DEVICE when mapping RX frame buffers,
but DMA_BIDIRECTIONAL for unmap. Fix the direction for DMA
unmapping operation.

Fixes: 87eb55e418b7 ("staging: fsl-dpaa2/eth: Fix potential endless loop")

Signed-off-by: Ioana Radulescu 
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index 3963717..537d5bb 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -767,7 +767,7 @@ static void free_bufs(struct dpaa2_eth_priv *priv, u64 
*buf_array, int count)
for (i = 0; i < count; i++) {
vaddr = dpaa2_iova_to_virt(priv->iommu_domain, buf_array[i]);
dma_unmap_single(dev, buf_array[i], DPAA2_ETH_RX_BUF_SIZE,
-DMA_BIDIRECTIONAL);
+DMA_FROM_DEVICE);
skb_free_frag(vaddr);
}
 }
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 5/5] staging: fsl-dpaa2/eth: Remove Rx frame size check

2018-07-09 Thread Ioana Radulescu
Most Ethernet drivers don't enforce the MTU value as upper limit
for ingress frames. We too support receiving frames larger than
MTU, so allow that.

Remove our ndo_change_mtu implementation, letting the default
stack implementation handle things. Also, set the max frame length
allowed by hardware only once at probe time, with the largest
possible value.

Signed-off-by: Ioana Radulescu 
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 26 ++
 1 file changed, 6 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index 24e069c..4ae2371 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -1243,25 +1243,6 @@ static void dpaa2_eth_get_stats(struct net_device 
*net_dev,
}
 }
 
-static int dpaa2_eth_change_mtu(struct net_device *net_dev, int mtu)
-{
-   struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
-   int err;
-
-   /* Set the maximum Rx frame length to match the transmit side;
-* account for L2 headers when computing the MFL
-*/
-   err = dpni_set_max_frame_length(priv->mc_io, 0, priv->mc_token,
-   (u16)DPAA2_ETH_L2_MAX_FRM(mtu));
-   if (err) {
-   netdev_err(net_dev, "dpni_set_max_frame_length() failed\n");
-   return err;
-   }
-
-   net_dev->mtu = mtu;
-   return 0;
-}
-
 /* Copy mac unicast addresses from @net_dev to @priv.
  * Its sole purpose is to make dpaa2_eth_set_rx_mode() more readable.
  */
@@ -1469,7 +1450,6 @@ static const struct net_device_ops dpaa2_eth_ops = {
.ndo_init = dpaa2_eth_init,
.ndo_set_mac_address = dpaa2_eth_set_addr,
.ndo_get_stats64 = dpaa2_eth_get_stats,
-   .ndo_change_mtu = dpaa2_eth_change_mtu,
.ndo_set_rx_mode = dpaa2_eth_set_rx_mode,
.ndo_set_features = dpaa2_eth_set_features,
.ndo_do_ioctl = dpaa2_eth_ioctl,
@@ -2385,6 +2365,12 @@ static int netdev_init(struct net_device *net_dev)
 
/* Set MTU upper limit; lower limit is 68B (default value) */
net_dev->max_mtu = DPAA2_ETH_MAX_MTU;
+   err = dpni_set_max_frame_length(priv->mc_io, 0, priv->mc_token,
+   (u16)DPAA2_ETH_MFL);
+   if (err) {
+   dev_err(dev, "dpni_set_max_frame_length() failed\n");
+   return err;
+   }
 
/* Set actual number of queues in the net device */
num_queues = dpaa2_eth_queue_count(priv);
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 4/5] staging: fsl-dpaa2/eth: MTU cleanup

2018-07-09 Thread Ioana Radulescu
Don't set the lower MTU limit explicitly, since we use
the default value anyway.

Signed-off-by: Ioana Radulescu 
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index 439b260..24e069c 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -2383,8 +2383,7 @@ static int netdev_init(struct net_device *net_dev)
return err;
}
 
-   /* Set MTU limits */
-   net_dev->min_mtu = 68;
+   /* Set MTU upper limit; lower limit is 68B (default value) */
net_dev->max_mtu = DPAA2_ETH_MAX_MTU;
 
/* Set actual number of queues in the net device */
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 0/5] staging: fsl-dpaa2/eth: Cleanup and minor fixes

2018-07-09 Thread Ioana Radulescu
One bug fix, one small functional change and a couple of
cleanup patches.

Ioana Radulescu (5):
  staging: fsl-dpaa2/eth: Fix DMA mapping direction
  staging: fsl-dpaa2/eth: Remove obsolete reference
  staging: fsl-dpaa2/eth: Remove pointless instruction
  staging: fsl-dpaa2/eth: MTU cleanup
  staging: fsl-dpaa2/eth: Remove Rx frame size check

 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 34 ++
 1 file changed, 8 insertions(+), 26 deletions(-)

-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 3/5] staging: fsl-dpaa2/eth: Remove pointless instruction

2018-07-09 Thread Ioana Radulescu
We don't need to call dev_set_drvdata(dev, NULL) on driver
remove since core kernel code also performs this step.

Signed-off-by: Ioana Radulescu 
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index 6331e8d..439b260 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -2676,7 +2676,6 @@ static int dpaa2_eth_remove(struct fsl_mc_device *ls_dev)
 
fsl_mc_portal_free(priv->mc_io);
 
-   dev_set_drvdata(dev, NULL);
free_netdev(net_dev);
 
dev_dbg(net_dev->dev.parent, "Removed interface %s\n", net_dev->name);
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/5] staging: fsl-dpaa2/eth: Remove obsolete reference

2018-07-09 Thread Ioana Radulescu
Commit 2b7c86eb7bf3 ("staging: fsl-dpaa2/eth: Don't enable FAS on Tx")
removed the status field from the TX confirm frame annotation,
but a reference to it remained in the description of free_tx_fd().
Remove it.

Signed-off-by: Ioana Radulescu 
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index 537d5bb..6331e8d 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -522,8 +522,6 @@ static int build_single_fd(struct dpaa2_eth_priv *priv,
  * back-pointed to is also freed.
  * This can be called either from dpaa2_eth_tx_conf() or on the error path of
  * dpaa2_eth_tx().
- * Optionally, return the frame annotation status word (FAS), which needs
- * to be checked if we're on the confirmation path.
  */
 static void free_tx_fd(const struct dpaa2_eth_priv *priv,
   const struct dpaa2_fd *fd)
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH net] hv_netvsc: Fix napi reschedule while receive completion is busy

2018-07-09 Thread Haiyang Zhang
From: Haiyang Zhang 

If out ring is full temporarily and receive completion cannot go out,
we may still need to reschedule napi if other conditions are met.
Otherwise the napi poll might be stopped forever, and cause network
disconnect.

Fixes: 7426b1a51803 ("netvsc: optimize receive completions")
Signed-off-by: Haiyang Zhang 
---
 drivers/net/hyperv/netvsc.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index 8e9d0ee1572b..caaf5054f446 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -1285,14 +1285,14 @@ int netvsc_poll(struct napi_struct *napi, int budget)
nvchan->desc = hv_pkt_iter_next(channel, nvchan->desc);
}
 
-   /* If send of pending receive completions suceeded
-*   and did not exhaust NAPI budget this time
+   send_recv_completions(ndev, net_device, nvchan);
+
+   /* If it did not exhaust NAPI budget this time
 *   and not doing busy poll
 * then re-enable host interrupts
 * and reschedule if ring is not empty.
 */
-   if (send_recv_completions(ndev, net_device, nvchan) == 0 &&
-   work_done < budget &&
+   if (work_done < budget &&
napi_complete_done(napi, work_done) &&
hv_end_read(>inbound) &&
napi_schedule_prep(napi)) {
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v4 1/2] gpio: mediatek: add driver for MT7621

2018-07-09 Thread Sergio Paracuellos
On Mon, Jul 9, 2018 at 3:30 PM, Dan Carpenter  wrote:
> On Mon, Jul 09, 2018 at 03:28:50PM +0200, Sergio Paracuellos wrote:
>> On Mon, Jul 09, 2018 at 01:45:22PM +0200, Linus Walleij wrote:
>> > On Thu, Jul 5, 2018 at 3:43 PM Sergio Paracuellos
>> >  wrote:
>> >
>> > > Add driver support for gpio of MT7621 SoC.
>> > >
>> > > Signed-off-by: Sergio Paracuellos 
>> > > Reviewed-by: NeilBrown 
>> >
>> > This is looking really good.
>> >
>> > Patch applied: anything remaining can surely be patched up
>> > in-tree.
>> >
>>
>> Sound good, thanks.
>>
>> Should I send a patch to remove the driver from staging or just
>> is removed by Greg? How is this achieved?
>
> Send a patch.
>

Thanks, Dan. Done.

> regards,
> dan carpenter
>

Best regards,
Sergio Paracuellos
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: mt7621-gpio: remove driver from staging

2018-07-09 Thread Sergio Paracuellos
Remove driver from staging. It has been accepted in
the linux-gpio tree.

Signed-off-by: Sergio Paracuellos 
---

Refer to commits in linux-gpio:
 - 
https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git/commit/?h=devel=af2b04d19242686a2c30e526c9b7a9e9c57bbce9
 - 
https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git/commit/?h=devel=4ba9c3afda41213ec98c30053e32963892e6dc7c

 drivers/staging/Kconfig|   2 -
 drivers/staging/Makefile   |   1 -
 drivers/staging/mt7621-gpio/Kconfig|   8 -
 drivers/staging/mt7621-gpio/Makefile   |   3 -
 drivers/staging/mt7621-gpio/TODO   |   3 -
 drivers/staging/mt7621-gpio/gpio-mt7621.c  | 331 -
 .../staging/mt7621-gpio/mediatek,mt7621-gpio.txt   |  35 ---
 7 files changed, 383 deletions(-)
 delete mode 100644 drivers/staging/mt7621-gpio/Kconfig
 delete mode 100644 drivers/staging/mt7621-gpio/Makefile
 delete mode 100644 drivers/staging/mt7621-gpio/TODO
 delete mode 100644 drivers/staging/mt7621-gpio/gpio-mt7621.c
 delete mode 100644 drivers/staging/mt7621-gpio/mediatek,mt7621-gpio.txt

diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig
index 6f57855..3fa3910 100644
--- a/drivers/staging/Kconfig
+++ b/drivers/staging/Kconfig
@@ -112,8 +112,6 @@ source "drivers/staging/pi433/Kconfig"
 
 source "drivers/staging/mt7621-pinctrl/Kconfig"
 
-source "drivers/staging/mt7621-gpio/Kconfig"
-
 source "drivers/staging/mt7621-spi/Kconfig"
 
 source "drivers/staging/mt7621-dma/Kconfig"
diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile
index 3872351..7a0ff10 100644
--- a/drivers/staging/Makefile
+++ b/drivers/staging/Makefile
@@ -47,7 +47,6 @@ obj-$(CONFIG_DRM_VBOXVIDEO)   += vboxvideo/
 obj-$(CONFIG_PI433)+= pi433/
 obj-$(CONFIG_SOC_MT7621)   += mt7621-pci/
 obj-$(CONFIG_SOC_MT7621)   += mt7621-pinctrl/
-obj-$(CONFIG_SOC_MT7621)   += mt7621-gpio/
 obj-$(CONFIG_SOC_MT7621)   += mt7621-spi/
 obj-$(CONFIG_SOC_MT7621)   += mt7621-dma/
 obj-$(CONFIG_SOC_MT7621)   += mt7621-mmc/
diff --git a/drivers/staging/mt7621-gpio/Kconfig 
b/drivers/staging/mt7621-gpio/Kconfig
deleted file mode 100644
index 5485dd2..000
--- a/drivers/staging/mt7621-gpio/Kconfig
+++ /dev/null
@@ -1,8 +0,0 @@
-config GPIO_MT7621
-   bool "Mediatek MT7621 GPIO Support"
-   depends on SOC_MT7620 || SOC_MT7621 || COMPILE_TEST
-   select GPIO_GENERIC
-   select GPIOLIB_IRQCHIP
-   select ARCH_REQUIRE_GPIOLIB
-   help
- Say yes here to support the Mediatek MT7621 SoC GPIO device
diff --git a/drivers/staging/mt7621-gpio/Makefile 
b/drivers/staging/mt7621-gpio/Makefile
deleted file mode 100644
index e269ab1..000
--- a/drivers/staging/mt7621-gpio/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
-obj-$(CONFIG_GPIO_MT7621)  += gpio-mt7621.o
-
-ccflags-y += -I$(srctree)/$(src)/include
diff --git a/drivers/staging/mt7621-gpio/TODO b/drivers/staging/mt7621-gpio/TODO
deleted file mode 100644
index 674930a..000
--- a/drivers/staging/mt7621-gpio/TODO
+++ /dev/null
@@ -1,3 +0,0 @@
-- general code review and clean up
-
-Cc:  NeilBrown 
diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c 
b/drivers/staging/mt7621-gpio/gpio-mt7621.c
deleted file mode 100644
index d7256b5..000
--- a/drivers/staging/mt7621-gpio/gpio-mt7621.c
+++ /dev/null
@@ -1,331 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright (C) 2009-2011 Gabor Juhos 
- * Copyright (C) 2013 John Crispin 
- */
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#define MTK_BANK_CNT   3
-#define MTK_BANK_WIDTH 32
-
-#define GPIO_BANK_WIDE 0x04
-#define GPIO_REG_CTRL  0x00
-#define GPIO_REG_POL   0x10
-#define GPIO_REG_DATA  0x20
-#define GPIO_REG_DSET  0x30
-#define GPIO_REG_DCLR  0x40
-#define GPIO_REG_REDGE 0x50
-#define GPIO_REG_FEDGE 0x60
-#define GPIO_REG_HLVL  0x70
-#define GPIO_REG_LLVL  0x80
-#define GPIO_REG_STAT  0x90
-#define GPIO_REG_EDGE  0xA0
-
-struct mtk_gc {
-   struct gpio_chip chip;
-   spinlock_t lock;
-   int bank;
-   u32 rising;
-   u32 falling;
-   u32 hlevel;
-   u32 llevel;
-};
-
-/**
- * struct mtk_data - state container for
- * data of the platform driver. It is 3
- * separate gpio-chip each one with its
- * own irq_chip.
- * @dev: device instance
- * @gpio_membase: memory base address
- * @gpio_irq: irq number from the device tree
- * @gc_map: array of the gpio chips
- */
-struct mtk_data {
-   struct device *dev;
-   void __iomem *gpio_membase;
-   int gpio_irq;
-   struct mtk_gc gc_map[MTK_BANK_CNT];
-};
-
-static inline struct mtk_gc *
-to_mediatek_gpio(struct gpio_chip *chip)
-{
-   return container_of(chip, struct mtk_gc, chip);
-}
-
-static inline void
-mtk_gpio_w32(struct mtk_gc *rg, u32 offset, u32 val)
-{
-   struct gpio_chip *gc = >chip;
-   struct mtk_data *gpio_data = 

Re: [PATCH 1/2] staging:fsl-mc: Move DPIO from staging to drivers/soc/fsl

2018-07-09 Thread Roy Pledge
On 7/9/2018 6:37 AM, Laurentiu Tudor wrote:
> Hi Roy,
>
> Couple of comments inline.
>
> On 05.07.2018 22:41, Roy Pledge wrote:
>> Move the NXP DPIO (Datapath I/O Driver) out of the
>> drivers/staging directory and into the drivers/soc/fsl directory.
>>
>> The DPIO driver enables access to Queue and Buffer Manager (QBMAN)
>> hardware on NXP DPAA2 devices. This is a prerequisite to moving the
>> DPAA2 Ethernet driver out of staging.
>>
>> Signed-off-by: Roy Pledge 
>> ---
>>   MAINTAINERS|  2 +-
>>   drivers/crypto/caam/sg_sw_qm2.h|  2 +-
>>   drivers/crypto/caam/sg_sw_sec4.h   |  2 +-
>>   drivers/soc/fsl/Kconfig| 10 
>> ++
>>   drivers/soc/fsl/Makefile   |  1 +
>>   drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/Makefile  |  0
>>   drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio-cmd.h|  0
>>   drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio-driver.c |  2 +-
>>   drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio-driver.txt   |  0
> Maybe this should be converted to .rst and go in the already existing
> Documentation/networking/dpaa2/?

I can look into converting this to RST but I'm not sure it belongs in
the networking documentation folder since
it will be used by other non networking drivers in the near future -
compress/decompress for example.
>
>>   drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio-service.c|  2 +-
>>   drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio.c|  0
>>   drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio.h|  0
>>   drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/qbman-portal.c|  2 +-
>>   drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/qbman-portal.h|  2 +-
>>   drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h |  4 ++--
>>   drivers/staging/fsl-mc/bus/Kconfig |  9 
>> -
>>   drivers/staging/fsl-mc/bus/Makefile|  2 --
>>   {drivers/staging/fsl-mc/include => include/soc/fsl}/dpaa2-fd.h |  0
>>   .../staging/fsl-mc/include => include/soc/fsl}/dpaa2-global.h  |  0
>>   {drivers/staging/fsl-mc/include => include/soc/fsl}/dpaa2-io.h |  0
>>   20 files changed, 20 insertions(+), 20 deletions(-)
>>   rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/Makefile (100%)
>>   rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio-cmd.h (100%)
>>   rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio-driver.c (99%)
>>   rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio-driver.txt (100%)
>>   rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio-service.c (99%)
>>   rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio.c (100%)
>>   rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio.h (100%)
>>   rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/qbman-portal.c (99%)
>>   rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/qbman-portal.h (99%)
>>   rename {drivers/staging/fsl-mc/include => include/soc/fsl}/dpaa2-fd.h 
>> (100%)
>>   rename {drivers/staging/fsl-mc/include => include/soc/fsl}/dpaa2-global.h 
>> (100%)
>>   rename {drivers/staging/fsl-mc/include => include/soc/fsl}/dpaa2-io.h 
>> (100%)
> I received feedback in the past on mc-bus that a driver should limit to 
> only one public header and one private one. Would it make sense to do 
> the same for dpio too?
Looking at this the dpaa-2global.h file should probably be integrated
into the dpaa2-io.h file. 
The dpaaa2-fd.h can be used by devices that don't need to used DPIO -
the definition of a frame descriptor
isn't DPIO specific so I would argue it should be kept in a seperate file.
 
>
> ---
> Best Regards, Laurentiu


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] ANDROID: binder: Latelimit binder_debug().

2018-07-09 Thread Tetsuo Handa
On 2018/07/09 23:02, Martijn Coenen wrote:
> On Mon, Jul 9, 2018 at 3:27 PM, Dmitry Vyukov  wrote:
>> I know almost nothing about binder. How these debug messages are
>> enabled?  I don't see anything like CONFIG_BINDER_VERBOSE_DEBUG in the
>> config:
>> https://github.com/google/syzkaller/blob/master/dashboard/config/upstream-kasan.config
>> Also no mentions of binder in sysctl/cmline.
>> All binder maintainers are in CC already, perhaps they can shed some
>> light on this.
> 
> Some are enabled by default here:
> https://github.com/torvalds/linux/blob/master/drivers/android/binder.c#L138
> 
> Perhaps we should revise that set then, as it can be quite noisy when
> lots of processes are dying (which also happens a lot in syzbot
> tests).
> 

OK. Then, I think we should consider disabling by default or latelimit printk().
Repeating hundreds of (or maybe thousands of ?) similar messages is not useful
(and blocking other threads due to processing flood of printk() is not good).
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [RFC PATCH v1] Xilinx AXI-Stream FIFO v4.1 IP core driver

2018-07-09 Thread Dan Carpenter
On Sat, Jul 07, 2018 at 10:19:40PM -0400, Jacob Feder wrote:
> +static ssize_t sysfs_write(struct device *dev, const char *buf,
> +size_t count, unsigned int addr_offset)
> +{
> + struct axis_fifo_local *device_wrapper = dev_get_drvdata(dev);

What does the "local" mean in axis_fifo_local?  "device_wrapper" is a
weird name.  It's sort of long but also meaningless and or confusing.
What kind of device?  What is it wrapping?  How is it not a fifo?  And
because it's a bit long then we run into the 80 character limit.  Maybe
just say "struct axis_fifo_local *fifo;"?

> +
> + if (!mutex_trylock(_wrapper->write_mutex)) {
> + dev_err(device_wrapper->os_device,
> + "couldn't acquire write lock\n");
> + return -EBUSY;
> + }

Greg has said to remove this.

> +
> + if (!mutex_trylock(_wrapper->read_mutex)) {
> + dev_err(device_wrapper->os_device,
> + "couldn't acquire read lock\n");
> + mutex_unlock(_wrapper->write_mutex);
> + dev_dbg(device_wrapper->os_device, "released write lock\n");
> + return -EBUSY;
> + }
> +
> + dev_dbg(device_wrapper->os_device, "acquired locks\n");

Remove this, because it's related to locks.  Also you can get this info
from ftrace.  The extra debug code just obscures the interest parts of
the code because there is too much debugging.

->os_device is a bad name, because there isn't an operating system
device.  What does that even mean?

> +
> + if (count != 4) {

Remove the magic number.  Just say sizeof(u32).

> + dev_err(device_wrapper->os_device,
> + "error, sysfs write to address 0x%x expected 4 bytes\n",
> + addr_offset);
> + mutex_unlock(_wrapper->write_mutex);
> + mutex_unlock(_wrapper->read_mutex);

Don't let user space spam /var/log messages.  Just return -EINVAL;

> + return -EINVAL;
> + }
> +
> + dev_dbg(device_wrapper->os_device,
> + "writing 0x%x to sysfs address 0x%x\n",
> + *(unsigned int *)buf, addr_offset);
> + iowrite32(*(unsigned int __force *)buf,

__force is for when you're casting to and from __user types.  It's not
required here.

> +   device_wrapper->base_addr + addr_offset);
> + mutex_unlock(_wrapper->write_mutex);
> + mutex_unlock(_wrapper->read_mutex);
> + dev_dbg(device_wrapper->os_device, "released locks\n");

ftrace.

> +
> + return 4;

This is a magic number.  Use "return count;" instead.

> +}

So now it's:

static ssize_t sysfs_write(struct device *dev, const char *buf,
   size_t count, unsigned int addr_offset)
{
struct axis_fifo_local *fifo = dev_get_drvdata(dev);

if (count != sizeof(u32))
return -EINVAL;

iowrite32(*(u32 *)buf, fifo->base_addr + addr_offset);

return count;
}

Sysfs files are supposed to be human readable text files so I don't
feel like casting *(u32 *)buf is the right thing.  In other words you do
echo "1234" > /sys/whatever.  What are we trying to write here?
Normally we would use kstrotul() and write the value that
way.

> +// reads a single packet from the fifo as dictated by the tlast signal

Please use /* */ style comments.

> +static ssize_t axis_fifo_read(struct file *device_file, char __user *buf,
> +   size_t len, loff_t *off)
> +{
> + struct axis_fifo_local *device_wrapper =
> + (struct axis_fifo_local *)device_file->private_data;
> + unsigned int bytes_available;
> + unsigned int words_available;
> + unsigned int word;
> + unsigned int buff_word;

One f in buf.  Otherwise it means a person who works out a lot.  This
is just an iterator.  "int i;"

> + int wait_ret;

Just say "int ret;"

> + u32 read_buff[READ_BUFF_SIZE];
> +
> + if (device_wrapper->read_flags & O_NONBLOCK) {
> + // opened in non-blocking mode
> + // return if there are no packets available
> + if (!ioread32(device_wrapper->base_addr + XLLF_RDFO_OFFSET))
> + return -EAGAIN;
> + } else {
> + // opened in blocking mode
> +
> + // wait for a packet available interrupt (or timeout)
> + // if nothing is currently available
> + spin_lock_irq(_wrapper->read_queue_lock);
> + if (read_timeout < 0) {

There are too many O_NONBLOCK and read_timeout modes...

> + wait_ret = wait_event_interruptible_lock_irq_timeout(
> + device_wrapper->read_queue,
> + ioread32(device_wrapper->base_addr +
> + XLLF_RDFO_OFFSET),
> + device_wrapper->read_queue_lock,
> + MAX_SCHEDULE_TIMEOUT);
> + } else {
> + wait_ret = 

Re: [PATCH] ANDROID: binder: Latelimit binder_debug().

2018-07-09 Thread Martijn Coenen
On Mon, Jul 9, 2018 at 3:27 PM, Dmitry Vyukov  wrote:
> I know almost nothing about binder. How these debug messages are
> enabled?  I don't see anything like CONFIG_BINDER_VERBOSE_DEBUG in the
> config:
> https://github.com/google/syzkaller/blob/master/dashboard/config/upstream-kasan.config
> Also no mentions of binder in sysctl/cmline.
> All binder maintainers are in CC already, perhaps they can shed some
> light on this.

Some are enabled by default here:
https://github.com/torvalds/linux/blob/master/drivers/android/binder.c#L138

Perhaps we should revise that set then, as it can be quite noisy when
lots of processes are dying (which also happens a lot in syzbot
tests).
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: rtl8723bs: use mac_pton()

2018-07-09 Thread Michael Straube
Use mac_pton() instead of custom approach.
Remove the now unused hex2num_i() and hwaddr_aton_i().

Signed-off-by: Michael Straube 
---
 .../staging/rtl8723bs/os_dep/ioctl_linux.c| 41 +--
 1 file changed, 1 insertion(+), 40 deletions(-)

diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c 
b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
index 7dd9521fedfb..ceb2b10fa0b2 100644
--- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
+++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
@@ -39,44 +39,6 @@ static const char * const iw_operation_mode[] = {
"Auto", "Ad-Hoc", "Managed",  "Master", "Repeater", "Secondary", 
"Monitor"
 };
 
-static int hex2num_i(char c)
-{
-   if (c >= '0' && c <= '9')
-   return c - '0';
-   if (c >= 'a' && c <= 'f')
-   return c - 'a' + 10;
-   if (c >= 'A' && c <= 'F')
-   return c - 'A' + 10;
-   return -1;
-}
-
-/**
- * hwaddr_aton - Convert ASCII string to MAC address
- * @txt: MAC address as a string (e.g., "00:11:22:33:44:55")
- * @addr: Buffer for the MAC address (ETH_ALEN = 6 bytes)
- * Returns: 0 on success, -1 on failure (e.g., string not a MAC address)
- */
-static int hwaddr_aton_i(const char *txt, u8 *addr)
-{
-   int i;
-
-   for (i = 0; i < 6; i++) {
-   int a, b;
-
-   a = hex2num_i(*txt++);
-   if (a < 0)
-   return -1;
-   b = hex2num_i(*txt++);
-   if (b < 0)
-   return -1;
-   *addr++ = (a << 4) | b;
-   if (i < 5 && *txt++ != ':')
-   return -1;
-   }
-
-   return 0;
-}
-
 void indicate_wx_scan_complete_event(struct adapter *padapter)
 {
union iwreq_data wrqu;
@@ -2567,8 +2529,7 @@ static int rtw_get_ap_info(struct net_device *dev,
 
pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list);
 
-   /* if (hwaddr_aton_i(pdata->pointer, bssid)) */
-   if (hwaddr_aton_i(data, bssid)) {
+   if (!mac_pton(data, bssid)) {
DBG_871X("Invalid BSSID '%s'.\n", (u8 *)data);
spin_unlock_bh(&(pmlmepriv->scanned_queue.lock));
return -EINVAL;
-- 
2.18.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [RFC PATCH v1] Xilinx AXI-Stream FIFO v4.1 IP core driver

2018-07-09 Thread Jacob Feder
On Mon, Jul 09, 2018 at 09:43:28AM +0200, Greg KH wrote:
> On Sun, Jul 08, 2018 at 02:25:38PM -0400, jacob feder wrote:
> > On Sun, Jul 8, 2018 at 9:28 AM Greg KH  wrote:
> > 
> > On Sat, Jul 07, 2018 at 10:19:40PM -0400, Jacob Feder wrote:
> > > Hi all,
> > > I have developed this driver for a Xilinx-provided IP block for their
> > Zynq
> > > SoC. I fixed all of the checkpatch.pl problems I knew how to. If 
> > someone
> > > could chime in on how to fix the remaining few it would be 
> > appreciated.
> > >
> > > Also looking for feedback on general structure. It's my first driver 
> > (and
> > > patch submission) so I'm sure there are plenty of things to be 
> > improved
> > on
> > > :).
> > >
> > > Functionally everything works OK except the performance isn't as good 
> > as
> > I
> > > was hoping for. I have been testing it by operating the FIFO in 
> > loopback
> > > mode (AXI-Stream TX interface feeding back into RX interface) running 
> > on
> > > the XC7Z020 (7000 series) Zynq device. I am getting anything between
> > > 3-16MB/s depending on the amount of data transferred. The performance
> > > claimed by the PG080 datasheet is ~65MB/s. The CPU isn't under
> > significant
> > > load (~12%) as reported by top so I don't think that's the bottleneck.
> > >
> > > Please +CC in responses as I'm not on the mailing list.
> > >
> > > Cheers
> > >
> > >
> > > This IP core has read and write AXI-Stream FIFOs, the contents of 
> > which
> > can
> > > be accessed from the AXI4 memory-mapped interface. This is useful for
> > > transferring data from a processor into the FPGA fabric. The driver
> > creates
> > > a character device that can be read/written to with standard
> > > open/read/write/close.
> > 
> > Why not use the uio api, which allows userspace to mmap the memory of
> > the device and access it directly from userspace?  That should make
> > things a lot faster, right?
> > 
> > 
> > 
> > I thought about the UIO method but based on what I read it seemed like more 
> > of
> > a hack (and also doesn't expose interrupts?). Whether it would make
> > things faster I have no idea.
> 
> Directly mmap is faster than read/write in a serial way, right?

I'm not sure - to me it seems the same unless mmap is using a different
technique under the hood. With mmap you would still need to write serially
to the FIFO registers. E.g. you can't write the data to a block of memory.
It all has to go to the same spot (TDFD register or RDFD for reading).

> 
> > 
> > Or if that doesn't work, what about the fpga API the kernel now has?
> > Would that work for this hardware?
> > 
> > 
> > 
> > I'm not totally sure what you're referring to here, but I think the FPGA 
> > kernel
> > drivers are for downloading bitstreams to the FPGA (bitstream is
> > equivalent to asm for fpgas), which isn't what I'm trying to do. 
> 
> Ah, ok.
> 
> > >
> > > See Xilinx PG080 document for IP details.
> > 
> > Do you have a link to that?  If so, can you put it in here?
> > 
> > 
> > 
> > https://www.xilinx.com/support/documentation/ip_documentation/axi_fifo_mm_s/
> > v4_1/pg080-axi-fifo-mm-s.pdf
> 
> Can you put this in the changelog message please?
> 

Yes will do on v2.

> > > Currently supports only store-forward mode with a 32-bit
> > > AXI4-Lite interface. DOES NOT support:
> > >       - cut-through mode
> > >       - AXI4 (non-lite)
> > >
> > > Signed-off-by: Jacob Feder 
> > > ---
> > >  drivers/staging/axisfifo/axis-fifo.c | 1296
> > ++
> > >  drivers/staging/axisfifo/axis-fifo.h |  119 
> > >  2 files changed, 1415 insertions(+)
> > >  create mode 100644 drivers/staging/axisfifo/axis-fifo.c
> > >  create mode 100644 drivers/staging/axisfifo/axis-fifo.h
> > 
> > Why does a single .c file need a .h file?
> > 
> > 
> > 
> > Good point... this can be consolidated :)
> >  
> > 
> > I'll be glad to take this driver, as others can clean it up in-tree (I
> > think your locking is crazy and is probably causing a lot of performance
> > issues), but I need a TODO file for it listing what you think is needed
> > to do in order to get this out of the staging tree?
> > 
> > 
> > 
> > I'm confused about why you don't like the locking - all I'm doing is 
> > locking on
> > open() calls to prevent multiple userspace apps from reading/writing
> > to the fifo simultaneously.  This shouldn't reduce performance because
> > the mutexes are only tested on open() not on read() or write().
> > Presumably the user is only opening once.
> 
> Trying to "protect" userspace from itself is not really a good idea.
> Grabbing a lock over open/close is ripe for problems.  You really are
> not keeping multiple owners from accessing the device at the same time,
> think about passing around a file 

Re: [PATCH v4 1/2] gpio: mediatek: add driver for MT7621

2018-07-09 Thread Dan Carpenter
On Mon, Jul 09, 2018 at 03:28:50PM +0200, Sergio Paracuellos wrote:
> On Mon, Jul 09, 2018 at 01:45:22PM +0200, Linus Walleij wrote:
> > On Thu, Jul 5, 2018 at 3:43 PM Sergio Paracuellos
> >  wrote:
> > 
> > > Add driver support for gpio of MT7621 SoC.
> > >
> > > Signed-off-by: Sergio Paracuellos 
> > > Reviewed-by: NeilBrown 
> > 
> > This is looking really good.
> > 
> > Patch applied: anything remaining can surely be patched up
> > in-tree.
> >
> 
> Sound good, thanks.
> 
> Should I send a patch to remove the driver from staging or just
> is removed by Greg? How is this achieved?

Send a patch.

regards,
dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v4 1/2] gpio: mediatek: add driver for MT7621

2018-07-09 Thread Sergio Paracuellos
On Mon, Jul 09, 2018 at 01:45:22PM +0200, Linus Walleij wrote:
> On Thu, Jul 5, 2018 at 3:43 PM Sergio Paracuellos
>  wrote:
> 
> > Add driver support for gpio of MT7621 SoC.
> >
> > Signed-off-by: Sergio Paracuellos 
> > Reviewed-by: NeilBrown 
> 
> This is looking really good.
> 
> Patch applied: anything remaining can surely be patched up
> in-tree.
>

Sound good, thanks.

Should I send a patch to remove the driver from staging or just
is removed by Greg? How is this achieved?
 
> > +/*
> > + * Copyright (C) 2009-2011 Gabor Juhos 
> > + * Copyright (C) 2013 John Crispin 
> > + */
> 
> All OpenWRT drivers are moving upstream and I like it :)
> Gabo and John wrote like 90% of them on their own :D
> 
> > +#define GPIO_BANK_WIDE 0x04
> 
> Nitpick: we usually call this "stride" rather than "wide".
> I changed it while applying the patch.

Thanks :-)

> 
> Yours,
> Linus Walleij

Best regards,
Sergio Paracuellos
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] ANDROID: binder: Latelimit binder_debug().

2018-07-09 Thread Tetsuo Handa
Dmitry, do you know how/why syzbot is enabling debug messages?

On 2018/07/09 16:38, Greg Kroah-Hartman wrote:
> On Mon, Jul 09, 2018 at 10:10:34AM +0900, Tetsuo Handa wrote:
>> >From 62ddef96020cb397dcbf4b8574f1859b32f983de Mon Sep 17 00:00:00 2001
>> From: Tetsuo Handa 
>> Date: Mon, 9 Jul 2018 09:54:01 +0900
>> Subject: [PATCH] ANDROID: binder: Latelimit binder_debug().
>>
>> syzbot is reporting hung tasks [1] [2]. This might be due to flooding of
>> printk() messages from binder subsystem, for NMI backtrace says the CPU
>> was busy doing printk() from binder subsystem. Since the kernel log buffer
>> is trivially spammed by debug messages, let's latelimit binder_debug().
> 
> How is the binder debug messages being turned on?  They are not enabled
> by default, is syzbot enabling them?  If so, then I don't know if this
> needs to be changed, as you want those debug messages if you ask for
> them, you shouldn't ratelimit them.
> 
> thanks,
> 
> greg k-h
> 

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 1/2] staging:fsl-mc: Move DPIO from staging to drivers/soc/fsl

2018-07-09 Thread Laurentiu Tudor
Hi Roy,

Couple of comments inline.

On 05.07.2018 22:41, Roy Pledge wrote:
> Move the NXP DPIO (Datapath I/O Driver) out of the
> drivers/staging directory and into the drivers/soc/fsl directory.
> 
> The DPIO driver enables access to Queue and Buffer Manager (QBMAN)
> hardware on NXP DPAA2 devices. This is a prerequisite to moving the
> DPAA2 Ethernet driver out of staging.
> 
> Signed-off-by: Roy Pledge 
> ---
>   MAINTAINERS|  2 +-
>   drivers/crypto/caam/sg_sw_qm2.h|  2 +-
>   drivers/crypto/caam/sg_sw_sec4.h   |  2 +-
>   drivers/soc/fsl/Kconfig| 10 
> ++
>   drivers/soc/fsl/Makefile   |  1 +
>   drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/Makefile  |  0
>   drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio-cmd.h|  0
>   drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio-driver.c |  2 +-
>   drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio-driver.txt   |  0

Maybe this should be converted to .rst and go in the already existing
Documentation/networking/dpaa2/?

>   drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio-service.c|  2 +-
>   drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio.c|  0
>   drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio.h|  0
>   drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/qbman-portal.c|  2 +-
>   drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/qbman-portal.h|  2 +-
>   drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h |  4 ++--
>   drivers/staging/fsl-mc/bus/Kconfig |  9 
> -
>   drivers/staging/fsl-mc/bus/Makefile|  2 --
>   {drivers/staging/fsl-mc/include => include/soc/fsl}/dpaa2-fd.h |  0
>   .../staging/fsl-mc/include => include/soc/fsl}/dpaa2-global.h  |  0
>   {drivers/staging/fsl-mc/include => include/soc/fsl}/dpaa2-io.h |  0
>   20 files changed, 20 insertions(+), 20 deletions(-)
>   rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/Makefile (100%)
>   rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio-cmd.h (100%)
>   rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio-driver.c (99%)
>   rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio-driver.txt (100%)
>   rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio-service.c (99%)
>   rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio.c (100%)
>   rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio.h (100%)
>   rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/qbman-portal.c (99%)
>   rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/qbman-portal.h (99%)
>   rename {drivers/staging/fsl-mc/include => include/soc/fsl}/dpaa2-fd.h (100%)
>   rename {drivers/staging/fsl-mc/include => include/soc/fsl}/dpaa2-global.h 
> (100%)
>   rename {drivers/staging/fsl-mc/include => include/soc/fsl}/dpaa2-io.h (100%)

I received feedback in the past on mc-bus that a driver should limit to 
only one public header and one private one. Would it make sense to do 
the same for dpio too?

---
Best Regards, Laurentiu
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] Staging: gdm724x: gdm_tty.c:Fixed Macro argument reuse

2018-07-09 Thread Jaya Durga
Hi ,
I have updated the patch --subject-prefix="PATCH v3" and made the
commit as per your suggestion ,
i don't know why does the script doesn't update my changes,will try to
sort out the issue ,
sorry for the inconvenience.

Regards,
Jaya Durga

On Mon, Jul 9, 2018 at 6:26 PM, Dan Carpenter  wrote:
> I don't understand why you have sent this patch four times.
>
> Are you a script which has a bug?  Please answer us so that we know you
> are a human being.
>
> regards,
> dan carpenter
>
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] Staging: gdm724x: gdm_tty.c:Fixed Macro argument reuse

2018-07-09 Thread Dan Carpenter
I don't understand why you have sent this patch four times.

Are you a script which has a bug?  Please answer us so that we know you
are a human being.

regards,
dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] Staging: gdm724x: gdm_tty.c:Fixed Macro argument reuse

2018-07-09 Thread Jaya Durga
From: root 

CHECK: Macro argument reuse 'gdm' - possible side-effects?

convert GDM_TTY_READY to gdm_tty_ready static function
to fix checkpath check

Signed-off-by: Jaya Durga 
---
 drivers/staging/gdm724x/gdm_tty.c | 14 +-
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/gdm724x/gdm_tty.c 
b/drivers/staging/gdm724x/gdm_tty.c
index bf554f7c56ca..5de1940c1f79 100644
--- a/drivers/staging/gdm724x/gdm_tty.c
+++ b/drivers/staging/gdm724x/gdm_tty.c
@@ -27,7 +27,11 @@
#define MUX_TX_MAX_SIZE 2048
-#define GDM_TTY_READY(gdm) (gdm && gdm->tty_dev && gdm->port.count)
+static unsigned int gdm_tty_ready(struct gdm *gdm)
+{
+return (gdm && gdm->tty_dev && gdm->port.count);
+}
+

static struct tty_driver *gdm_driver[TTY_MAX_COUNT];
static struct gdm *gdm_table[TTY_MAX_COUNT][GDM_TTY_MINOR];
@@ -127,7 +131,7 @@ static int gdm_tty_recv_complete(void *data,
{
struct gdm *gdm = tty_dev->gdm[index];
-   if (!GDM_TTY_READY(gdm)) {
+   if (!gdm_tty_ready(gdm)) {
if (complete == RECV_PACKET_PROCESS_COMPLETE)
gdm->tty_dev->recv_func(gdm->tty_dev->priv_dev,
gdm_tty_recv_complete);
@@ -154,7 +158,7 @@ static void gdm_tty_send_complete(void *arg)
 {
struct gdm *gdm = arg;
-   if (!GDM_TTY_READY(gdm))
+   if (!gdm_tty_ready(gdm))
return;
tty_port_tty_wakeup(>port);
@@ -168,7 +172,7 @@ static int gdm_tty_write(struct tty_struct *tty, const 
unsigned char *buf,
int sent_len = 0;
int sending_len = 0;
-   if (!GDM_TTY_READY(gdm))
+   if (!gdm_tty_ready(gdm))
return -ENODEV;
if (!len)
@@ -195,7 +199,7 @@ static int gdm_tty_write_room(struct tty_struct *tty)
{
struct gdm *gdm = tty->driver_data;
-   if (!GDM_TTY_READY(gdm))
+   if (!gdm_tty_ready(gdm))
return -ENODEV;
return WRITE_SIZE;


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 03/12] staging:rtl8192u: Remove blank lines before '}' and after '{' characters

2018-07-09 Thread Greg KH
On Mon, Jul 09, 2018 at 10:29:54AM +0100, John Whitmore wrote:
> On Sun, Jul 08, 2018 at 05:38:11PM +0200, Greg KH wrote:
> > On Sat, Jul 07, 2018 at 03:55:04PM +0100, John Whitmore wrote:
> > > Coding style change to simply remove the unrequired spaces before a 
> > > closing
> > > brace or before an opening brace.
> > 
> > That would be good, but that's not what this patch does :(
> > 
> > It removes lines, not spaces, as the subject line said.  You also fix up
> > an indentation as well.
> > 
> > thanks,
> > 
> > greg k-h
> 
> Just for clarification, before I assume something and make a mistake, I'm
> wondering about this patch set. I got auto notification to say that patches 1,
> 2, 4, & 6 had been accepted and merged with staging-next. And I got this email
> to explain why patch number 3 wasn't up to scratch.
> 
> But that leaves 5, 7, 8, 9, 10, 11 & 12. I'm assuming that they didn't apply
> and I that I can resubmit them with a fixed up patch number 3. That seems
> logical to me so I'll work on that basis for the moment. Thought I'd better
> check, before I confuse people, with an erroneous assumption.

Yes, that is correct.

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v4 2/2] dt-bindings: document gpio-mt7621 bindings

2018-07-09 Thread Sergio Paracuellos
On Mon, Jul 09, 2018 at 01:37:09PM +0200, Linus Walleij wrote:
> On Thu, Jul 5, 2018 at 3:43 PM Sergio Paracuellos
>  wrote:
> 
> > Add a devicetree binding documentation for the mt7621 gpio.
> >
> > Signed-off-by: Sergio Paracuellos 
> > Reviewed-by: NeilBrown 
> 
> Patch applied with Rob's review tag.

Thanks for let me know, Linus.

> 
> Yours,
> Linus Walleij

Best regards,
Sergio Paracuellos
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] Staging: gdm724x: gdm_tty.c:Fixed Macro argument reuse

2018-07-09 Thread Greg KH
On Mon, Jul 09, 2018 at 04:27:58PM +0530, Jaya Durga wrote:
> From: root 

Again, wrong address :(
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v4 1/2] gpio: mediatek: add driver for MT7621

2018-07-09 Thread Linus Walleij
On Thu, Jul 5, 2018 at 3:43 PM Sergio Paracuellos
 wrote:

> Add driver support for gpio of MT7621 SoC.
>
> Signed-off-by: Sergio Paracuellos 
> Reviewed-by: NeilBrown 

This is looking really good.

Patch applied: anything remaining can surely be patched up
in-tree.

> +/*
> + * Copyright (C) 2009-2011 Gabor Juhos 
> + * Copyright (C) 2013 John Crispin 
> + */

All OpenWRT drivers are moving upstream and I like it :)
Gabo and John wrote like 90% of them on their own :D

> +#define GPIO_BANK_WIDE 0x04

Nitpick: we usually call this "stride" rather than "wide".
I changed it while applying the patch.

Yours,
Linus Walleij
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] Staging: gdm724x: gdm_tty.c:Fixed Macro argument reuse

2018-07-09 Thread Dan Carpenter
Also, you really should be sending this as a [PATCH v3] with a note
under the --- cut off that says "V3: fix From header, and indenting"

Google for how to send a v2 patch.

regards,
dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v4 2/2] dt-bindings: document gpio-mt7621 bindings

2018-07-09 Thread Linus Walleij
On Thu, Jul 5, 2018 at 3:43 PM Sergio Paracuellos
 wrote:

> Add a devicetree binding documentation for the mt7621 gpio.
>
> Signed-off-by: Sergio Paracuellos 
> Reviewed-by: NeilBrown 

Patch applied with Rob's review tag.

Yours,
Linus Walleij
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] Revert "staging: mt7621-pinctrl: replace core_initcall_sync with builtin_platform_driver"

2018-07-09 Thread Sergio Paracuellos
On Mon, Jul 09, 2018 at 01:35:57PM +0300, Dan Carpenter wrote:
> On Mon, Jul 09, 2018 at 12:18:46PM +0200, Sergio Paracuellos wrote:
> > That patch causes the network interface on the device to stop working.
> > device_initcall() is called much later than core_initcall_sync() and
> > that seem to be a problem. Revert it to get a correct behaviour.
> > 
> > Signed-off-by: Sergio Paracuellos 
> 
> You should give Reported-by credit to Neil for doing the testing.

Ok, done. I have just send v2 including Reported-by credit.

Thanks for showing me the correct workflow for all of this.
> 
> regards,
> dan carpenter
> 

Best regards,
Sergio Paracuellos
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2] Revert "staging: mt7621-pinctrl: replace core_initcall_sync with builtin_platform_driver"

2018-07-09 Thread Sergio Paracuellos
That patch causes the network interface on the device to stop working.
device_initcall() is called much later than core_initcall_sync() and
that seem to be a problem. Revert it to get a correct behaviour.

Reported-by: NeilBrown 
Signed-off-by: Sergio Paracuellos 
---
Changes in v2:
  - Add Reported-by to the PATCH.
 drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c 
b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
index c223ecb..b8566ed 100644
--- a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
+++ b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
@@ -423,4 +423,9 @@ static struct platform_driver rt2880_pinmux_driver = {
},
 };
 
-builtin_platform_driver(rt2880_pinmux_driver);
+int __init rt2880_pinmux_init(void)
+{
+   return platform_driver_register(_pinmux_driver);
+}
+
+core_initcall_sync(rt2880_pinmux_init);
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] Staging: gdm724x: gdm_tty.c:Fixed Macro argument reuse

2018-07-09 Thread Jaya Durga
From: root 

CHECK: Macro argument reuse 'gdm' - possible side-effects?

convert GDM_TTY_READY to gdm_tty_ready static function
to fix checkpath check

Signed-off-by: Jaya Durga 
---
 drivers/staging/gdm724x/gdm_tty.c | 14 +-
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/gdm724x/gdm_tty.c 
b/drivers/staging/gdm724x/gdm_tty.c
index bf554f7c56ca..5de1940c1f79 100644
--- a/drivers/staging/gdm724x/gdm_tty.c
+++ b/drivers/staging/gdm724x/gdm_tty.c
@@ -27,7 +27,11 @@
#define MUX_TX_MAX_SIZE 2048
-#define GDM_TTY_READY(gdm) (gdm && gdm->tty_dev && gdm->port.count)
+static unsigned int gdm_tty_ready(struct gdm *gdm)
+{
+return (gdm && gdm->tty_dev && gdm->port.count);
+}
+

static struct tty_driver *gdm_driver[TTY_MAX_COUNT];
static struct gdm *gdm_table[TTY_MAX_COUNT][GDM_TTY_MINOR];
@@ -127,7 +131,7 @@ static int gdm_tty_recv_complete(void *data,
{
struct gdm *gdm = tty_dev->gdm[index];
-   if (!GDM_TTY_READY(gdm)) {
+   if (!gdm_tty_ready(gdm)) {
if (complete == RECV_PACKET_PROCESS_COMPLETE)
gdm->tty_dev->recv_func(gdm->tty_dev->priv_dev,
gdm_tty_recv_complete);
@@ -154,7 +158,7 @@ static void gdm_tty_send_complete(void *arg)
 {
struct gdm *gdm = arg;
-   if (!GDM_TTY_READY(gdm))
+   if (!gdm_tty_ready(gdm))
return;
tty_port_tty_wakeup(>port);
@@ -168,7 +172,7 @@ static int gdm_tty_write(struct tty_struct *tty, const 
unsigned char *buf,
int sent_len = 0;
int sending_len = 0;
-   if (!GDM_TTY_READY(gdm))
+   if (!gdm_tty_ready(gdm))
return -ENODEV;
if (!len)
@@ -195,7 +199,7 @@ static int gdm_tty_write_room(struct tty_struct *tty)
{
struct gdm *gdm = tty->driver_data;
-   if (!GDM_TTY_READY(gdm))
+   if (!gdm_tty_ready(gdm))
return -ENODEV;
return WRITE_SIZE;


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] Revert "staging: mt7621-pinctrl: replace core_initcall_sync with builtin_platform_driver"

2018-07-09 Thread Dan Carpenter
On Mon, Jul 09, 2018 at 12:18:46PM +0200, Sergio Paracuellos wrote:
> That patch causes the network interface on the device to stop working.
> device_initcall() is called much later than core_initcall_sync() and
> that seem to be a problem. Revert it to get a correct behaviour.
> 
> Signed-off-by: Sergio Paracuellos 

You should give Reported-by credit to Neil for doing the testing.

regards,
dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] Staging: gdm724x: gdm_tty.c:Fixed Macro argument reuse

2018-07-09 Thread Dan Carpenter
On Mon, Jul 09, 2018 at 03:30:20PM +0530, Jaya Durga wrote:
> From: root 

Please send the patch to yourself first and make sure it's right.  Then
resend to the list.

> 
> CHECK: Macro argument reuse 'gdm' - possible side-effects?
> 
> convert GDM_TTY_READY to gdm_tty_ready static function
> to fix checkpath check
> 
> Signed-off-by: Jaya Durga 
> ---
>  drivers/staging/gdm724x/gdm_tty.c | 14 +-
>  1 file changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/staging/gdm724x/gdm_tty.c 
> b/drivers/staging/gdm724x/gdm_tty.c
> index bf554f7c56ca..5de1940c1f79 100644
> --- a/drivers/staging/gdm724x/gdm_tty.c
> +++ b/drivers/staging/gdm724x/gdm_tty.c
> @@ -27,7 +27,11 @@
> #define MUX_TX_MAX_SIZE 2048
> -#define GDM_TTY_READY(gdm) (gdm && gdm->tty_dev && gdm->port.count)
> +static unsigned int gdm_tty_ready(struct gdm *gdm)
> +{
> +return (gdm && gdm->tty_dev && gdm->port.count);


This needs to be indented.


regards,
dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 00/18] Some cleanups

2018-07-09 Thread Sergio Paracuellos
On Mon, Jul 09, 2018 at 09:38:59AM +0200, Greg KH wrote:
> On Mon, Jul 09, 2018 at 06:41:15AM +0200, Sergio Paracuellos wrote:
> > On Mon, Jul 09, 2018 at 11:08:58AM +1000, NeilBrown wrote:
> > > On Sun, Jul 08 2018, Sergio Paracuellos wrote:
> > > 
> > > > This patch series clean up a bit mt7621-pci driver.
> > > >
> > > > Changes from v2:
> > > > - It includes new 17 patches from PATCH 2 to PATCH 18
> > > > - PATCH 1 was send before alone and is being included
> > > >   as it is in this new series.
> > > >
> > > > Hope this helps.
> > > 
> > > Thanks,
> > > I haven't looked though the patches yet, only tested them.
> > > With the two fixed to pinctrl that I posted together
> > > with the change to "avoid pointer arithmetics in some macros"
> > > in this series, they appear to work.  So
> > > 
> > >   Tested-by: NeilBrown 
> > > 
> > > I may actually look a them later.
> > 
> > Thanks for testing this. Greg, I think is still neccessary to split up
> > patch 1 for better reviewing. If not, please let me know. I'll
> > try to do that hopefully tonight.
> 
> Yes please, I'll drop this series and wait for your next one.

Ok, thanks for let me know.
> 
> thanks,
> 
> greg k-h

Best regards,
Sergio Paracuellos
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 13/13] staging: mt7621-pinctrl: replace core_initcall_sync with builtin_platform_driver

2018-07-09 Thread Sergio Paracuellos
On Mon, Jul 09, 2018 at 09:39:19AM +0200, Greg KH wrote:
> On Mon, Jul 09, 2018 at 06:30:07AM +0200, Sergio Paracuellos wrote:
> > On Mon, Jul 09, 2018 at 09:40:18AM +1000, NeilBrown wrote:
> > > On Thu, Jun 28 2018, Sergio Paracuellos wrote:
> > > 
> > > > We don't really need initialization of this at such an early stage.
> > > > Just use builtin_platform_driver to initialize this driver.
> > > >
> > > > Signed-off-by: Sergio Paracuellos 
> > > > ---
> > > >  drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c | 7 +--
> > > >  1 file changed, 1 insertion(+), 6 deletions(-)
> > > >
> > > > diff --git a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c 
> > > > b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
> > > > index 2cce212..7025942 100644
> > > > --- a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
> > > > +++ b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
> > > > @@ -422,9 +422,4 @@ static struct platform_driver rt2880_pinmux_driver 
> > > > = {
> > > > },
> > > >  };
> > > >  
> > > > -int __init rt2880_pinmux_init(void)
> > > > -{
> > > > -   return platform_driver_register(_pinmux_driver);
> > > > -}
> > > > -
> > > > -core_initcall_sync(rt2880_pinmux_init);
> > > > +builtin_platform_driver(rt2880_pinmux_driver);
> > > > -- 
> > > > 2.7.4
> > > 
> > > This patch causes the network interface on my device to stop working.
> > > device_initcall() is called much later than core_initcall_sync() and
> > > that seem to be a problem.
> > > I think this needs to be reverted - at least until it is understood.
> > 
> > Ok, if that is the case, Greg, please revert this commit.
> 
> Please send a revert.

Sent. Thanks.
> 
> thanks,
> 
> greg k-h

Best regards,
Sergio Paracuellos
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] Revert "staging: mt7621-pinctrl: replace core_initcall_sync with builtin_platform_driver"

2018-07-09 Thread Sergio Paracuellos
That patch causes the network interface on the device to stop working.
device_initcall() is called much later than core_initcall_sync() and
that seem to be a problem. Revert it to get a correct behaviour.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c 
b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
index c223ecb..b8566ed 100644
--- a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
+++ b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
@@ -423,4 +423,9 @@ static struct platform_driver rt2880_pinmux_driver = {
},
 };
 
-builtin_platform_driver(rt2880_pinmux_driver);
+int __init rt2880_pinmux_init(void)
+{
+   return platform_driver_register(_pinmux_driver);
+}
+
+core_initcall_sync(rt2880_pinmux_init);
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] Staging: gdm724x: gdm_tty.c:Fixed Macro argument reuse

2018-07-09 Thread Jaya Durga
From: root 

CHECK: Macro argument reuse 'gdm' - possible side-effects?

convert GDM_TTY_READY to gdm_tty_ready static function
to fix checkpath check

Signed-off-by: Jaya Durga 
---
 drivers/staging/gdm724x/gdm_tty.c | 14 +-
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/gdm724x/gdm_tty.c 
b/drivers/staging/gdm724x/gdm_tty.c
index bf554f7c56ca..5de1940c1f79 100644
--- a/drivers/staging/gdm724x/gdm_tty.c
+++ b/drivers/staging/gdm724x/gdm_tty.c
@@ -27,7 +27,11 @@
#define MUX_TX_MAX_SIZE 2048
-#define GDM_TTY_READY(gdm) (gdm && gdm->tty_dev && gdm->port.count)
+static unsigned int gdm_tty_ready(struct gdm *gdm)
+{
+return (gdm && gdm->tty_dev && gdm->port.count);
+}
+
static struct tty_driver *gdm_driver[TTY_MAX_COUNT];
static struct gdm *gdm_table[TTY_MAX_COUNT][GDM_TTY_MINOR];
@@ -127,7 +131,7 @@ static int gdm_tty_recv_complete(void *data,
{
struct gdm *gdm = tty_dev->gdm[index];
-   if (!GDM_TTY_READY(gdm)) {
+   if (!gdm_tty_ready(gdm)) {
if (complete == RECV_PACKET_PROCESS_COMPLETE)
gdm->tty_dev->recv_func(gdm->tty_dev->priv_dev,
gdm_tty_recv_complete);
@@ -154,7 +158,7 @@ static void gdm_tty_send_complete(void *arg)
 {
struct gdm *gdm = arg;
-   if (!GDM_TTY_READY(gdm))
+   if (!gdm_tty_ready(gdm))
return;
tty_port_tty_wakeup(>port);
@@ -168,7 +172,7 @@ static int gdm_tty_write(struct tty_struct *tty, const 
unsigned char *buf,
int sent_len = 0;
int sending_len = 0;
-   if (!GDM_TTY_READY(gdm))
+   if (!gdm_tty_ready(gdm))
return -ENODEV;
if (!len)
@@ -195,7 +199,7 @@ static int gdm_tty_write_room(struct tty_struct *tty)
{
struct gdm *gdm = tty->driver_data;
-   if (!GDM_TTY_READY(gdm))
+   if (!gdm_tty_ready(gdm))
return -ENODEV;
return WRITE_SIZE;


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 03/12] staging:rtl8192u: Remove blank lines before '}' and after '{' characters

2018-07-09 Thread John Whitmore
On Sun, Jul 08, 2018 at 05:38:11PM +0200, Greg KH wrote:
> On Sat, Jul 07, 2018 at 03:55:04PM +0100, John Whitmore wrote:
> > Coding style change to simply remove the unrequired spaces before a closing
> > brace or before an opening brace.
> 
> That would be good, but that's not what this patch does :(
> 
> It removes lines, not spaces, as the subject line said.  You also fix up
> an indentation as well.
> 
> thanks,
> 
> greg k-h

Just for clarification, before I assume something and make a mistake, I'm
wondering about this patch set. I got auto notification to say that patches 1,
2, 4, & 6 had been accepted and merged with staging-next. And I got this email
to explain why patch number 3 wasn't up to scratch.

But that leaves 5, 7, 8, 9, 10, 11 & 12. I'm assuming that they didn't apply
and I that I can resubmit them with a fixed up patch number 3. That seems
logical to me so I'll work on that basis for the moment. Thought I'd better
check, before I confuse people, with an erroneous assumption.

John Whitmore
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] Staging: gdm724x: gdm_tty.c:Fixed Macro argument reuse

2018-07-09 Thread Greg KH
On Mon, Jul 09, 2018 at 02:14:06PM +0530, Jaya Durga wrote:
> From: root 

That's an odd author name :)

> 
> CHECK: Macro argument reuse 'gdm' - possible side-effects?
> 
> convert GDM_TTY_READY to gdm_tty_ready static function
> to fix checkpath check
> 
> Signed-off-by: Jaya Durga 

It doesn't match this one either :(

Please fix...

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH V2 2/5] KVM: Add tlb remote flush callback in kvm_x86_ops.

2018-07-09 Thread Tianyu Lan
This patch is to provide a way for platforms to register hv tlb remote
flush callback and this helps to optimize operation of tlb flush
among vcpus for nested virtualization case.

Signed-off-by: Lan Tianyu 
---
Change since v1:
   Add kvm_arch_hv_flush_remote_tlb() to avoid compilation issue
for non-x86 platform.
---
 arch/x86/include/asm/kvm_host.h | 11 +++
 include/linux/kvm_host.h|  7 +++
 virt/kvm/kvm_main.c | 11 ++-
 3 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index c13cd28d9d1b..d89e4204816c 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -973,6 +973,7 @@ struct kvm_x86_ops {
void (*set_rflags)(struct kvm_vcpu *vcpu, unsigned long rflags);
 
void (*tlb_flush)(struct kvm_vcpu *vcpu, bool invalidate_gpa);
+   int  (*hv_tlb_remote_flush)(struct kvm *kvm);
 
void (*run)(struct kvm_vcpu *vcpu);
int (*handle_exit)(struct kvm_vcpu *vcpu);
@@ -1117,6 +1118,16 @@ static inline void kvm_arch_free_vm(struct kvm *kvm)
return kvm_x86_ops->vm_free(kvm);
 }
 
+#define __KVM_HAVE_HV_FLUSH_REMOTE_TLB
+static inline int kvm_arch_hv_flush_remote_tlb(struct kvm *kvm)
+{
+   if (kvm_x86_ops->hv_tlb_remote_flush &&
+   !kvm_x86_ops->hv_tlb_remote_flush(kvm))
+   return 0;
+   else
+   return -EFAULT;
+}
+
 int kvm_mmu_module_init(void);
 void kvm_mmu_module_exit(void);
 
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 4ee7bc548a83..0c2c36cb041b 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -827,6 +827,13 @@ static inline void kvm_arch_free_vm(struct kvm *kvm)
 }
 #endif
 
+#ifndef __KVM_HAVE_HV_FLUSH_REMOTE_TLB
+static inline int kvm_arch_hv_flush_remote_tlb(struct kvm *kvm)
+{
+   return -EFAULT;
+}
+#endif
+
 #ifdef __KVM_HAVE_ARCH_NONCOHERENT_DMA
 void kvm_arch_register_noncoherent_dma(struct kvm *kvm);
 void kvm_arch_unregister_noncoherent_dma(struct kvm *kvm);
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 8b47507faab5..c2b5e3273848 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -256,11 +256,20 @@ bool kvm_make_all_cpus_request(struct kvm *kvm, unsigned 
int req)
 #ifndef CONFIG_HAVE_KVM_ARCH_TLB_FLUSH_ALL
 void kvm_flush_remote_tlbs(struct kvm *kvm)
 {
+   long dirty_count;
+
+   /*
+* Call kvm_arch_hv_tlb_remote first and go back old way when
+* return failure.
+*/
+   if (!kvm_arch_hv_flush_remote_tlb(kvm))
+   return;
+
/*
 * Read tlbs_dirty before setting KVM_REQ_TLB_FLUSH in
 * kvm_make_all_cpus_request.
 */
-   long dirty_count = smp_load_acquire(>tlbs_dirty);
+   dirty_count = smp_load_acquire(>tlbs_dirty);
 
/*
 * We want to publish modifications to the page tables before reading
-- 
2.14.3
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH V2 1/5] X86/Hyper-V: Add flush HvFlushGuestPhysicalAddressSpace hypercall support

2018-07-09 Thread Tianyu Lan
Hyper-V supports a pv hypercall HvFlushGuestPhysicalAddressSpace to
flush nested VM address space mapping in l1 hypervisor and it's to
reduce overhead of flushing ept tlb among vcpus. This patch is to
implement it.

Signed-off-by: Lan Tianyu 
---
 arch/x86/hyperv/Makefile   |  2 +-
 arch/x86/hyperv/nested.c   | 64 ++
 arch/x86/include/asm/hyperv-tlfs.h |  8 +
 arch/x86/include/asm/mshyperv.h|  2 ++
 4 files changed, 75 insertions(+), 1 deletion(-)
 create mode 100644 arch/x86/hyperv/nested.c

diff --git a/arch/x86/hyperv/Makefile b/arch/x86/hyperv/Makefile
index b173d404e3df..b21ee65c4101 100644
--- a/arch/x86/hyperv/Makefile
+++ b/arch/x86/hyperv/Makefile
@@ -1,2 +1,2 @@
-obj-y  := hv_init.o mmu.o
+obj-y  := hv_init.o mmu.o nested.o
 obj-$(CONFIG_X86_64)   += hv_apic.o
diff --git a/arch/x86/hyperv/nested.c b/arch/x86/hyperv/nested.c
new file mode 100644
index ..74dd38b5221d
--- /dev/null
+++ b/arch/x86/hyperv/nested.c
@@ -0,0 +1,64 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/*
+ * Hyper-V nested virtualization code.
+ *
+ * Copyright (C) 2018, Microsoft, Inc.
+ *
+ * Author : Lan Tianyu 
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 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, GOOD TITLE or
+ * NON INFRINGEMENT.  See the GNU General Public License for more
+ * details.
+ *
+ */
+
+
+#include 
+#include 
+#include 
+#include 
+
+int hyperv_flush_guest_mapping(u64 as)
+{
+   struct hv_guest_mapping_flush **flush_pcpu;
+   struct hv_guest_mapping_flush *flush;
+   u64 status;
+   unsigned long flags;
+   int ret = -EFAULT;
+
+   if (!hv_hypercall_pg)
+   goto fault;
+
+   local_irq_save(flags);
+
+   flush_pcpu = (struct hv_guest_mapping_flush **)
+   this_cpu_ptr(hyperv_pcpu_input_arg);
+
+   flush = *flush_pcpu;
+
+   if (unlikely(!flush)) {
+   local_irq_restore(flags);
+   goto fault;
+   }
+
+   flush->address_space = as;
+   flush->flags = 0;
+
+   status = hv_do_hypercall(HVCALL_FLUSH_GUEST_PHYSICAL_ADDRESS_SPACE,
+flush, NULL);
+   local_irq_restore(flags);
+
+   if (!(status & HV_HYPERCALL_RESULT_MASK))
+   ret = 0;
+
+fault:
+   return ret;
+}
+EXPORT_SYMBOL_GPL(hyperv_flush_guest_mapping);
diff --git a/arch/x86/include/asm/hyperv-tlfs.h 
b/arch/x86/include/asm/hyperv-tlfs.h
index b8c89265baf0..08e24f552030 100644
--- a/arch/x86/include/asm/hyperv-tlfs.h
+++ b/arch/x86/include/asm/hyperv-tlfs.h
@@ -309,6 +309,7 @@ struct ms_hyperv_tsc_page {
 #define HV_X64_MSR_REENLIGHTENMENT_CONTROL 0x4106
 
 /* Nested features (CPUID 0x400A) EAX */
+#define HV_X64_NESTED_GUEST_MAPPING_FLUSH  BIT(18)
 #define HV_X64_NESTED_MSR_BITMAP   BIT(19)
 
 struct hv_reenlightenment_control {
@@ -350,6 +351,7 @@ struct hv_tsc_emulation_status {
 #define HVCALL_SEND_IPI_EX 0x0015
 #define HVCALL_POST_MESSAGE0x005c
 #define HVCALL_SIGNAL_EVENT0x005d
+#define HVCALL_FLUSH_GUEST_PHYSICAL_ADDRESS_SPACE 0x00af
 
 #define HV_X64_MSR_VP_ASSIST_PAGE_ENABLE   0x0001
 #define HV_X64_MSR_VP_ASSIST_PAGE_ADDRESS_SHIFT12
@@ -741,6 +743,12 @@ struct ipi_arg_ex {
struct hv_vpset vp_set;
 };
 
+/* HvFlushGuestPhysicalAddressSpace hypercalls */
+struct hv_guest_mapping_flush {
+   u64 address_space;
+   u64 flags;
+};
+
 /* HvFlushVirtualAddressSpace, HvFlushVirtualAddressList hypercalls */
 struct hv_tlb_flush {
u64 address_space;
diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index 3cd14311edfa..a6a615b49876 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -302,6 +302,7 @@ void hyperv_reenlightenment_intr(struct pt_regs *regs);
 void set_hv_tscchange_cb(void (*cb)(void));
 void clear_hv_tscchange_cb(void);
 void hyperv_stop_tsc_emulation(void);
+int hyperv_flush_guest_mapping(u64 as);
 
 #ifdef CONFIG_X86_64
 void hv_apic_init(void);
@@ -321,6 +322,7 @@ static inline struct hv_vp_assist_page 
*hv_get_vp_assist_page(unsigned int cpu)
 {
return NULL;
 }
+static inline int hyperv_flush_guest_mapping(u64 as) { return -1; }
 #endif /* CONFIG_HYPERV */
 
 #ifdef CONFIG_HYPERV_TSCPAGE
-- 
2.14.3
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH V2 3/5] KVM/VMX: Add identical ept table pointer check

2018-07-09 Thread Tianyu Lan
This patch is to check ept table pointer of each cpus when set ept
tables and store identical ept table pointer if all ept table pointers
of single VM are same. This is for support of para-virt ept flush
hypercall.

Signed-off-by: Lan Tianyu 
---
Change since v1:
   Replace identical_ept_pointer with ept_pointers_match and
check kvm_x86_ops->tlb_remote_flush in check_ept_pointer().
---
 arch/x86/kvm/vmx.c | 34 ++
 1 file changed, 34 insertions(+)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 1689f433f3a0..8142b2da430a 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -194,6 +194,9 @@ struct kvm_vmx {
unsigned int tss_addr;
bool ept_identity_pagetable_done;
gpa_t ept_identity_map_addr;
+
+   bool ept_pointers_match;
+   spinlock_t ept_pointer_lock;
 };
 
 #define NR_AUTOLOAD_MSRS 8
@@ -853,6 +856,7 @@ struct vcpu_vmx {
 */
u64 msr_ia32_feature_control;
u64 msr_ia32_feature_control_valid_bits;
+   u64 ept_pointer;
 };
 
 enum segment_cache_field {
@@ -4958,6 +4962,32 @@ static u64 construct_eptp(struct kvm_vcpu *vcpu, 
unsigned long root_hpa)
return eptp;
 }
 
+static void check_ept_pointer(struct kvm_vcpu *vcpu, u64 eptp)
+{
+   struct kvm *kvm = vcpu->kvm;
+   u64 tmp_eptp = INVALID_PAGE;
+   int i;
+
+   if (!kvm_x86_ops->tlb_remote_flush)
+   return;
+
+   spin_lock(_kvm_vmx(kvm)->ept_pointer_lock);
+   to_vmx(vcpu)->ept_pointer = eptp;
+
+   kvm_for_each_vcpu(i, vcpu, kvm) {
+   if (!VALID_PAGE(tmp_eptp)) {
+   tmp_eptp = to_vmx(vcpu)->ept_pointer;
+   } else if (tmp_eptp != to_vmx(vcpu)->ept_pointer) {
+   to_kvm_vmx(kvm)->ept_pointers_match = false;
+   spin_unlock(_kvm_vmx(kvm)->ept_pointer_lock);
+   return;
+   }
+   }
+
+   to_kvm_vmx(kvm)->ept_pointers_match = true;
+   spin_unlock(_kvm_vmx(kvm)->ept_pointer_lock);
+}
+
 static void vmx_set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3)
 {
unsigned long guest_cr3;
@@ -4967,6 +4997,8 @@ static void vmx_set_cr3(struct kvm_vcpu *vcpu, unsigned 
long cr3)
if (enable_ept) {
eptp = construct_eptp(vcpu, cr3);
vmcs_write64(EPT_POINTER, eptp);
+   check_ept_pointer(vcpu, eptp);
+
if (enable_unrestricted_guest || is_paging(vcpu) ||
is_guest_mode(vcpu))
guest_cr3 = kvm_read_cr3(vcpu);
@@ -10383,6 +10415,8 @@ static struct kvm_vcpu *vmx_create_vcpu(struct kvm 
*kvm, unsigned int id)
 
 static int vmx_vm_init(struct kvm *kvm)
 {
+   spin_lock_init(_kvm_vmx(kvm)->ept_pointer_lock);
+
if (!ple_gap)
kvm->arch.pause_in_guest = true;
return 0;
-- 
2.14.3
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH V2 5/5] X86/Hyper-V: Add hyperv_nested_flush_guest_mapping ftrace support

2018-07-09 Thread Tianyu Lan
This patch is to add hyperv_nested_flush_guest_mapping support to trace
hvFlushGuestPhysicalAddressSpace hypercall.

Signed-off-by: Lan Tianyu 
---
 arch/x86/hyperv/nested.c|  3 +++
 arch/x86/include/asm/trace/hyperv.h | 14 ++
 2 files changed, 17 insertions(+)

diff --git a/arch/x86/hyperv/nested.c b/arch/x86/hyperv/nested.c
index 74dd38b5221d..42a3232f2835 100644
--- a/arch/x86/hyperv/nested.c
+++ b/arch/x86/hyperv/nested.c
@@ -25,6 +25,8 @@
 #include 
 #include 
 
+#include 
+
 int hyperv_flush_guest_mapping(u64 as)
 {
struct hv_guest_mapping_flush **flush_pcpu;
@@ -59,6 +61,7 @@ int hyperv_flush_guest_mapping(u64 as)
ret = 0;
 
 fault:
+   trace_hyperv_nested_flush_guest_mapping(as, ret);
return ret;
 }
 EXPORT_SYMBOL_GPL(hyperv_flush_guest_mapping);
diff --git a/arch/x86/include/asm/trace/hyperv.h 
b/arch/x86/include/asm/trace/hyperv.h
index 4253bca99989..e1ffe61de8d6 100644
--- a/arch/x86/include/asm/trace/hyperv.h
+++ b/arch/x86/include/asm/trace/hyperv.h
@@ -28,6 +28,20 @@ TRACE_EVENT(hyperv_mmu_flush_tlb_others,
  __entry->addr, __entry->end)
);
 
+TRACE_EVENT(hyperv_nested_flush_guest_mapping,
+   TP_PROTO(u64 as, int ret),
+   TP_ARGS(as, ret),
+
+   TP_STRUCT__entry(
+   __field(u64, as)
+   __field(int, ret)
+   ),
+   TP_fast_assign(__entry->as = as;
+  __entry->ret = ret;
+   ),
+   TP_printk("address space %llx ret %d", __entry->as, __entry->ret)
+   );
+
 #endif /* CONFIG_HYPERV */
 
 #undef TRACE_INCLUDE_PATH
-- 
2.14.3
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH V2 4/5] KVM/x86: Add tlb_remote_flush callback support for vmx

2018-07-09 Thread Tianyu Lan
Register tlb_remote_flush callback for vmx when hyperv capability of
nested guest mapping flush is detected. The interface can help to
reduce overhead when flush ept table among vcpus for nested VM. The
tradition way is to send IPIs to all affected vcpus and executes
INVEPT on each vcpus. It will trigger several vmexits for IPI
and INVEPT emulation. Hyper-V provides such hypercall to do
flush for all vcpus.

Signed-off-by: Lan Tianyu 
---
Change since v1:
   Use ept_pointers_match to check condition of identical ept
table pointer and get ept pointer from struct vcpu_vmx->ept_pointer.
---
 arch/x86/kvm/vmx.c | 27 ++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 8142b2da430a..55fe14d1d4d4 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -4778,6 +4778,25 @@ static inline void __vmx_flush_tlb(struct kvm_vcpu 
*vcpu, int vpid,
}
 }
 
+static int hv_remote_flush_tlb(struct kvm *kvm)
+{
+   int ret;
+
+   spin_lock(_kvm_vmx(kvm)->ept_pointer_lock);
+
+   if (!to_kvm_vmx(kvm)->ept_pointers_match) {
+   ret = -EFAULT;
+   goto out;
+   }
+
+   ret = hyperv_flush_guest_mapping(
+   to_vmx(kvm_get_vcpu(kvm, 0))->ept_pointer);
+
+out:
+   spin_unlock(_kvm_vmx(kvm)->ept_pointer_lock);
+   return ret;
+}
+
 static void vmx_flush_tlb(struct kvm_vcpu *vcpu, bool invalidate_gpa)
 {
__vmx_flush_tlb(vcpu, to_vmx(vcpu)->vpid, invalidate_gpa);
@@ -4968,7 +4987,7 @@ static void check_ept_pointer(struct kvm_vcpu *vcpu, u64 
eptp)
u64 tmp_eptp = INVALID_PAGE;
int i;
 
-   if (!kvm_x86_ops->tlb_remote_flush)
+   if (!kvm_x86_ops->hv_tlb_remote_flush)
return;
 
spin_lock(_kvm_vmx(kvm)->ept_pointer_lock);
@@ -7570,6 +7589,12 @@ static __init int hardware_setup(void)
if (enable_ept && !cpu_has_vmx_ept_2m_page())
kvm_disable_largepages();
 
+#if IS_ENABLED(CONFIG_HYPERV)
+   if (ms_hyperv.nested_features & HV_X64_NESTED_GUEST_MAPPING_FLUSH
+   && enable_ept)
+   kvm_x86_ops->hv_tlb_remote_flush = hv_remote_flush_tlb;
+#endif
+
if (!cpu_has_vmx_ple()) {
ple_gap = 0;
ple_window = 0;
-- 
2.14.3
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH V2 0/5] KVM/x86/hyper-V: Introduce PV guest address space mapping flush support

2018-07-09 Thread Tianyu Lan
Hyper-V provides a para-virtualization hypercall 
HvFlushGuestPhysicalAddressSpace
to flush nested VM address space mapping in l1 hypervisor and it's to reduce 
overhead
of flushing ept tlb among vcpus. The tradition way is to send IPIs to all 
affected
vcpus and executes INVEPT on each vcpus. It will trigger several vmexits for 
IPI and
INVEPT emulation. The pv hypercall can help to flush specified ept table on all 
vcpus
via one single hypercall.

Change since v1:
   - Fix compilation error for non-x86 platform.
   - Use ept_pointers_match to check condition of identical ept
table pointer and get ept pointer from struct vcpu_vmx->ept_pointer.
   - Add hyperv_nested_flush_guest_mapping ftrace support

Lan Tianyu (5):
  X86/Hyper-V: Add flush HvFlushGuestPhysicalAddressSpace hypercall
support
  KVM: Add tlb remote flush callback in kvm_x86_ops.
  KVM/VMX: Add identical ept table pointer check
  KVM/x86: Add tlb_remote_flush callback support for vmx
  X86/Hyper-V: Add hyperv_nested_flush_guest_mapping ftrace support

 arch/x86/hyperv/Makefile|  2 +-
 arch/x86/hyperv/nested.c| 67 +
 arch/x86/include/asm/hyperv-tlfs.h  |  8 +
 arch/x86/include/asm/kvm_host.h | 11 ++
 arch/x86/include/asm/mshyperv.h |  2 ++
 arch/x86/include/asm/trace/hyperv.h | 14 
 arch/x86/kvm/vmx.c  | 59 
 include/linux/kvm_host.h|  7 
 virt/kvm/kvm_main.c | 11 +-
 9 files changed, 179 insertions(+), 2 deletions(-)
 create mode 100644 arch/x86/hyperv/nested.c

-- 
2.14.3
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] Staging: gdm724x: gdm_tty.c:Fixed Macro argument reuse

2018-07-09 Thread Jaya Durga
From: root 

CHECK: Macro argument reuse 'gdm' - possible side-effects?

convert GDM_TTY_READY to gdm_tty_ready static function
to fix checkpath check

Signed-off-by: Jaya Durga 
---
 drivers/staging/gdm724x/gdm_tty.c | 14 +-
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/gdm724x/gdm_tty.c 
b/drivers/staging/gdm724x/gdm_tty.c
index bf554f7c56ca..5de1940c1f79 100644
--- a/drivers/staging/gdm724x/gdm_tty.c
+++ b/drivers/staging/gdm724x/gdm_tty.c
@@ -27,7 +27,11 @@
#define MUX_TX_MAX_SIZE 2048
-#define GDM_TTY_READY(gdm) (gdm && gdm->tty_dev && gdm->port.count)
+static unsigned int gdm_tty_ready(struct gdm *gdm)
+{
+return (gdm && gdm->tty_dev && gdm->port.count);
+}
+
static struct tty_driver *gdm_driver[TTY_MAX_COUNT];
static struct gdm *gdm_table[TTY_MAX_COUNT][GDM_TTY_MINOR];
@@ -127,7 +131,7 @@ static int gdm_tty_recv_complete(void *data,
{
struct gdm *gdm = tty_dev->gdm[index];
-   if (!GDM_TTY_READY(gdm)) {
+   if (!gdm_tty_ready(gdm)) {
if (complete == RECV_PACKET_PROCESS_COMPLETE)
gdm->tty_dev->recv_func(gdm->tty_dev->priv_dev,
gdm_tty_recv_complete);
@@ -154,7 +158,7 @@ static void gdm_tty_send_complete(void *arg)
 {
struct gdm *gdm = arg;
-   if (!GDM_TTY_READY(gdm))
+   if (!gdm_tty_ready(gdm))
return;
tty_port_tty_wakeup(>port);
@@ -168,7 +172,7 @@ static int gdm_tty_write(struct tty_struct *tty, const 
unsigned char *buf,
int sent_len = 0;
int sending_len = 0;
-   if (!GDM_TTY_READY(gdm))
+   if (!gdm_tty_ready(gdm))
return -ENODEV;
if (!len)
@@ -195,7 +199,7 @@ static int gdm_tty_write_room(struct tty_struct *tty)
{
struct gdm *gdm = tty->driver_data;
-   if (!GDM_TTY_READY(gdm))
+   if (!gdm_tty_ready(gdm))
return -ENODEV;
return WRITE_SIZE;


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v1 1/2] ARM: dts: tegra20: Add Memory Client reset to VDE

2018-07-09 Thread Thierry Reding
On Sun, May 20, 2018 at 04:48:44PM +0300, Dmitry Osipenko wrote:
> Hook up Memory Client reset of the Video Decoder to the decoders DT node.
> 
> Signed-off-by: Dmitry Osipenko 
> ---
>  arch/arm/boot/dts/tegra20.dtsi | 7 +--
>  1 file changed, 5 insertions(+), 2 deletions(-)

Applied, thanks.

Thierry


signature.asc
Description: PGP signature
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v1 2/2] ARM: dts: tegra30: Add Memory Client reset to VDE

2018-07-09 Thread Thierry Reding
On Sun, May 20, 2018 at 04:48:46PM +0300, Dmitry Osipenko wrote:
> Hook up Memory Client reset of the Video Decoder to the decoders DT node.
> 
> Signed-off-by: Dmitry Osipenko 
> ---
>  arch/arm/boot/dts/tegra30.dtsi | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

Applied, thanks.

Thierry


signature.asc
Description: PGP signature
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: gasket: Add descriptions for module parameters

2018-07-09 Thread Greg Kroah-Hartman
On Sun, Jul 08, 2018 at 08:30:50PM +0300, Kamal Heib wrote:
> This patch add description for the module parameters and remove the task
> to do it from the TODO file.
> 
> Signed-off-by: Kamal Heib 
> ---
>  drivers/staging/gasket/TODO  | 1 -
>  drivers/staging/gasket/apex_driver.c | 8 
>  2 files changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/gasket/TODO b/drivers/staging/gasket/TODO
> index 0d8ee9602c80..c524dba7945f 100644
> --- a/drivers/staging/gasket/TODO
> +++ b/drivers/staging/gasket/TODO
> @@ -5,7 +5,6 @@ staging directory.
>  - Remove static function declarations.
>  - Document sysfs files with Documentation/ABI/ entries.
>  - Use misc interface instead of major number for driver version description.
> -- Add descriptions of module_param's
>  - Remove gasket-specific logging functions.
>  - apex_get_status() should actually check status.
>  - Static functions don't need kernel doc formatting, can be simplified.
> diff --git a/drivers/staging/gasket/apex_driver.c 
> b/drivers/staging/gasket/apex_driver.c
> index 395256704428..21deef38807a 100644
> --- a/drivers/staging/gasket/apex_driver.c
> +++ b/drivers/staging/gasket/apex_driver.c
> @@ -329,9 +329,17 @@ static int allow_hw_clock_gating = 1;
>  static int bypass_top_level;
>  
>  module_param(allow_power_save, int, 0644);
> +MODULE_PARM_DESC(allow_power_save,
> +  "Allows device to enter power save upon driver close()");
> +
>  module_param(allow_sw_clock_gating, int, 0644);
> +MODULE_PARM_DESC(allow_sw_clock_gating, "Allows SW based clock gating");
> +
>  module_param(allow_hw_clock_gating, int, 0644);
> +MODULE_PARM_DESC(allow_hw_clock_gating, "Allows HW based clock gating");
> +
>  module_param(bypass_top_level, int, 0644);
> +MODULE_PARM_DESC(bypass_top_level, "Act as if only GCB is instantiated");

Are you sure these options are even needed?  "Modern" drivers do not
need kernel module options as everything should "just work"
automatically.  Why are these options on a per-module basis and not a
per-device basis?

So I'd prefer to not take this patch and have the root problem here
fixed instead.

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [RFC PATCH v1] Xilinx AXI-Stream FIFO v4.1 IP core driver

2018-07-09 Thread Greg KH
On Sun, Jul 08, 2018 at 02:25:38PM -0400, jacob feder wrote:
> On Sun, Jul 8, 2018 at 9:28 AM Greg KH  wrote:
> 
> On Sat, Jul 07, 2018 at 10:19:40PM -0400, Jacob Feder wrote:
> > Hi all,
> > I have developed this driver for a Xilinx-provided IP block for their
> Zynq
> > SoC. I fixed all of the checkpatch.pl problems I knew how to. If someone
> > could chime in on how to fix the remaining few it would be appreciated.
> >
> > Also looking for feedback on general structure. It's my first driver 
> (and
> > patch submission) so I'm sure there are plenty of things to be improved
> on
> > :).
> >
> > Functionally everything works OK except the performance isn't as good as
> I
> > was hoping for. I have been testing it by operating the FIFO in loopback
> > mode (AXI-Stream TX interface feeding back into RX interface) running on
> > the XC7Z020 (7000 series) Zynq device. I am getting anything between
> > 3-16MB/s depending on the amount of data transferred. The performance
> > claimed by the PG080 datasheet is ~65MB/s. The CPU isn't under
> significant
> > load (~12%) as reported by top so I don't think that's the bottleneck.
> >
> > Please +CC in responses as I'm not on the mailing list.
> >
> > Cheers
> >
> >
> > This IP core has read and write AXI-Stream FIFOs, the contents of which
> can
> > be accessed from the AXI4 memory-mapped interface. This is useful for
> > transferring data from a processor into the FPGA fabric. The driver
> creates
> > a character device that can be read/written to with standard
> > open/read/write/close.
> 
> Why not use the uio api, which allows userspace to mmap the memory of
> the device and access it directly from userspace?  That should make
> things a lot faster, right?
> 
> 
> 
> I thought about the UIO method but based on what I read it seemed like more of
> a hack (and also doesn't expose interrupts?). Whether it would make
> things faster I have no idea.

Directly mmap is faster than read/write in a serial way, right?

> 
> Or if that doesn't work, what about the fpga API the kernel now has?
> Would that work for this hardware?
> 
> 
> 
> I'm not totally sure what you're referring to here, but I think the FPGA 
> kernel
> drivers are for downloading bitstreams to the FPGA (bitstream is
> equivalent to asm for fpgas), which isn't what I'm trying to do. 

Ah, ok.

> >
> > See Xilinx PG080 document for IP details.
> 
> Do you have a link to that?  If so, can you put it in here?
> 
> 
> 
> https://www.xilinx.com/support/documentation/ip_documentation/axi_fifo_mm_s/
> v4_1/pg080-axi-fifo-mm-s.pdf

Can you put this in the changelog message please?

> > Currently supports only store-forward mode with a 32-bit
> > AXI4-Lite interface. DOES NOT support:
> >       - cut-through mode
> >       - AXI4 (non-lite)
> >
> > Signed-off-by: Jacob Feder 
> > ---
> >  drivers/staging/axisfifo/axis-fifo.c | 1296
> ++
> >  drivers/staging/axisfifo/axis-fifo.h |  119 
> >  2 files changed, 1415 insertions(+)
> >  create mode 100644 drivers/staging/axisfifo/axis-fifo.c
> >  create mode 100644 drivers/staging/axisfifo/axis-fifo.h
> 
> Why does a single .c file need a .h file?
> 
> 
> 
> Good point... this can be consolidated :)
>  
> 
> I'll be glad to take this driver, as others can clean it up in-tree (I
> think your locking is crazy and is probably causing a lot of performance
> issues), but I need a TODO file for it listing what you think is needed
> to do in order to get this out of the staging tree?
> 
> 
> 
> I'm confused about why you don't like the locking - all I'm doing is locking 
> on
> open() calls to prevent multiple userspace apps from reading/writing
> to the fifo simultaneously.  This shouldn't reduce performance because
> the mutexes are only tested on open() not on read() or write().
> Presumably the user is only opening once.

Trying to "protect" userspace from itself is not really a good idea.
Grabbing a lock over open/close is ripe for problems.  You really are
not keeping multiple owners from accessing the device at the same time,
think about passing around a file descriptor to different processes or
threads.  Your kernel code does not protect from that, so it is best
just not to worry about that at all.  If userspace does foolish things,
let it deal with the result :)

> I think locking is necessary - if the hardware registers are accessed in the
> wrong order it goes into an unknown state and must be reset (and will
> probably cause a kernel panic).

How will the kernel crash because of this?

> Or, if you thin it should use the fpga or uio interface instead, maybe
> it's just easier to redo it based on that?
> 
> thanks,
> 
> greg k-h
> 
> 
> I have made some slight modifications 

Re: [PATCH v2 00/18] Some cleanups

2018-07-09 Thread Greg KH
On Mon, Jul 09, 2018 at 06:41:15AM +0200, Sergio Paracuellos wrote:
> On Mon, Jul 09, 2018 at 11:08:58AM +1000, NeilBrown wrote:
> > On Sun, Jul 08 2018, Sergio Paracuellos wrote:
> > 
> > > This patch series clean up a bit mt7621-pci driver.
> > >
> > > Changes from v2:
> > > - It includes new 17 patches from PATCH 2 to PATCH 18
> > > - PATCH 1 was send before alone and is being included
> > >   as it is in this new series.
> > >
> > > Hope this helps.
> > 
> > Thanks,
> > I haven't looked though the patches yet, only tested them.
> > With the two fixed to pinctrl that I posted together
> > with the change to "avoid pointer arithmetics in some macros"
> > in this series, they appear to work.  So
> > 
> >   Tested-by: NeilBrown 
> > 
> > I may actually look a them later.
> 
> Thanks for testing this. Greg, I think is still neccessary to split up
> patch 1 for better reviewing. If not, please let me know. I'll
> try to do that hopefully tonight.

Yes please, I'll drop this series and wait for your next one.

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 13/13] staging: mt7621-pinctrl: replace core_initcall_sync with builtin_platform_driver

2018-07-09 Thread Greg KH
On Mon, Jul 09, 2018 at 06:30:07AM +0200, Sergio Paracuellos wrote:
> On Mon, Jul 09, 2018 at 09:40:18AM +1000, NeilBrown wrote:
> > On Thu, Jun 28 2018, Sergio Paracuellos wrote:
> > 
> > > We don't really need initialization of this at such an early stage.
> > > Just use builtin_platform_driver to initialize this driver.
> > >
> > > Signed-off-by: Sergio Paracuellos 
> > > ---
> > >  drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c | 7 +--
> > >  1 file changed, 1 insertion(+), 6 deletions(-)
> > >
> > > diff --git a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c 
> > > b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
> > > index 2cce212..7025942 100644
> > > --- a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
> > > +++ b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
> > > @@ -422,9 +422,4 @@ static struct platform_driver rt2880_pinmux_driver = {
> > >   },
> > >  };
> > >  
> > > -int __init rt2880_pinmux_init(void)
> > > -{
> > > - return platform_driver_register(_pinmux_driver);
> > > -}
> > > -
> > > -core_initcall_sync(rt2880_pinmux_init);
> > > +builtin_platform_driver(rt2880_pinmux_driver);
> > > -- 
> > > 2.7.4
> > 
> > This patch causes the network interface on my device to stop working.
> > device_initcall() is called much later than core_initcall_sync() and
> > that seem to be a problem.
> > I think this needs to be reverted - at least until it is understood.
> 
> Ok, if that is the case, Greg, please revert this commit.

Please send a revert.

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] ANDROID: binder: Latelimit binder_debug().

2018-07-09 Thread Greg Kroah-Hartman
On Mon, Jul 09, 2018 at 10:10:34AM +0900, Tetsuo Handa wrote:
> >From 62ddef96020cb397dcbf4b8574f1859b32f983de Mon Sep 17 00:00:00 2001
> From: Tetsuo Handa 
> Date: Mon, 9 Jul 2018 09:54:01 +0900
> Subject: [PATCH] ANDROID: binder: Latelimit binder_debug().
> 
> syzbot is reporting hung tasks [1] [2]. This might be due to flooding of
> printk() messages from binder subsystem, for NMI backtrace says the CPU
> was busy doing printk() from binder subsystem. Since the kernel log buffer
> is trivially spammed by debug messages, let's latelimit binder_debug().

How is the binder debug messages being turned on?  They are not enabled
by default, is syzbot enabling them?  If so, then I don't know if this
needs to be changed, as you want those debug messages if you ask for
them, you shouldn't ratelimit them.

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] ANDROID: binder: Latelimit binder_debug().

2018-07-09 Thread Martijn Coenen
On Mon, Jul 9, 2018 at 3:10 AM, Tetsuo Handa
 wrote:
> While at it, let's add cond_resched() to binder_thread_write(),
> binder_transaction() and binder_release_work() loops because they might
> take long time.

This should be a separate patch, and I would love to see some
benchmark data around this change (there's a few in Android userspace
- let me know if you need help setting them up). Did you actually
observe these particular functions running for a long time without the
scheduler running?

Thanks,
Martijn

>
> [1] 
> https://syzkaller.appspot.com/bug?id=0e75779a6f0faac461510c6330514e8f0e893038
> [2] 
> https://syzkaller.appspot.com/bug?id=aa11d2d767f3750ef9a40d156a149e9cfa735b73
>
> Signed-off-by: Tetsuo Handa 
> Reported-by: syzbot+e38306788a2e7102a...@syzkaller.appspotmail.com
> Reported-by: syzbot+4417a2fa149da3802...@syzkaller.appspotmail.com
> ---
>  drivers/android/binder.c | 6 --
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/android/binder.c b/drivers/android/binder.c
> index 95283f3..c136fce 100644
> --- a/drivers/android/binder.c
> +++ b/drivers/android/binder.c
> @@ -161,7 +161,7 @@ static int binder_set_stop_on_user_error(const char *val,
>  #define binder_debug(mask, x...) \
> do { \
> if (binder_debug_mask & mask) \
> -   pr_info(x); \
> +   pr_info_ratelimited(x); \
> } while (0)
>
>  #define binder_user_error(x...) \
> @@ -3016,7 +3016,7 @@ static void binder_transaction(struct binder_proc *proc,
> sg_bufp = (u8 *)(PTR_ALIGN(off_end, sizeof(void *)));
> sg_buf_end = sg_bufp + extra_buffers_size;
> off_min = 0;
> -   for (; offp < off_end; offp++) {
> +   for (; offp < off_end; cond_resched(), offp++) {
> struct binder_object_header *hdr;
> size_t object_size = binder_validate_object(t->buffer, *offp);
>
> @@ -3307,6 +3307,7 @@ static int binder_thread_write(struct binder_proc *proc,
>
> if (get_user(cmd, (uint32_t __user *)ptr))
> return -EFAULT;
> +   cond_resched();
> ptr += sizeof(uint32_t);
> trace_binder_command(cmd);
> if (_IOC_NR(cmd) < ARRAY_SIZE(binder_stats.bc)) {
> @@ -4193,6 +4194,7 @@ static void binder_release_work(struct binder_proc 
> *proc,
> struct binder_work *w;
>
> while (1) {
> +   cond_resched();
> w = binder_dequeue_work_head(proc, list);
> if (!w)
> return;
> --
> 1.8.3.1
>
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] Staging:fwserial Move LINUX_VENDOR_ID to firewire.h

2018-07-09 Thread Greg KH
On Mon, Jul 09, 2018 at 11:52:30AM -0400, Janani Sankara Babu wrote:
> This driver uses the same unregistered vendor id that the
> firewire core does (0xd00d1e). Hence it is exposed as a
> define in firewire.h.
> 
> Signed-off-by:Janani Sankara Babu 
> ---
>  drivers/staging/fwserial/fwserial.c | 1 -
>  include/linux/firewire.h| 2 ++
>  2 files changed, 2 insertions(+), 1 deletion(-)


staging drivers are supposed to be self-contained.  Please work to get
the fwserial driver out of the staging directory before adding stuff
like this to a .h file that everyone includes.

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] Staging:fwserial Move LINUX_VENDOR_ID to firewire.h

2018-07-09 Thread Janani Sankara Babu
This driver uses the same unregistered vendor id that the
firewire core does (0xd00d1e). Hence it is exposed as a
define in firewire.h.

Signed-off-by:Janani Sankara Babu 
---
 drivers/staging/fwserial/fwserial.c | 1 -
 include/linux/firewire.h| 2 ++
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/fwserial/fwserial.c 
b/drivers/staging/fwserial/fwserial.c
index e8bfe55..f2966f2 100644
--- a/drivers/staging/fwserial/fwserial.c
+++ b/drivers/staging/fwserial/fwserial.c
@@ -21,0 +21,0 @@

 #define be32_to_u64(hi, lo)  ((u64)be32_to_cpu(hi) << 32 | be32_to_cpu(lo))

-#define LINUX_VENDOR_ID   0xd00d1eU  /* same id used in card root directory   
*/
 #define FWSERIAL_VERSION  0x00e81cU  /* must be unique within LINUX_VENDOR_ID 
*/

 /* configurable options */
diff --git a/include/linux/firewire.h b/include/linux/firewire.h
index aec8f30..62cdff1 100644
--- a/include/linux/firewire.h
+++ b/include/linux/firewire.h
@@ -66,2 +66,2 @@
 #define CSR_MODEL  0x17
 #define CSR_DIRECTORY_ID   0x20

+#define LINUX_VENDOR_ID   0xd00d1eU  /* same id used in card root directory   
*/
+
 struct fw_csr_iterator {
const u32 *p;
const u32 *end;
--
1.9.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel