Re: [PATCH v2 1/2] staging: Introduce NVIDIA Tegra20 video decoder driver

2017-10-06 Thread Dmitry Osipenko
On 06.10.2017 06:57, kbuild test robot wrote:
> Hi Dmitry,
> 
> [auto build test WARNING on staging/staging-testing]
> [also build test WARNING on v4.14-rc3 next-20170929]
> [cannot apply to tegra/for-next]
> [if your patch is applied to the wrong git tree, please drop us a note to 
> help improve the system]
> 
> url:
> https://github.com/0day-ci/linux/commits/Dmitry-Osipenko/staging-Introduce-NVIDIA-Tegra20-video-decoder-driver/20171006-101015
> config: ia64-allmodconfig (attached as .config)
> compiler: ia64-linux-gcc (GCC) 6.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
> make.cross ARCH=ia64 
> 
> All warnings (new ones prefixed by >>):
> 
>In file included from include/linux/kernel.h:13:0,
> from include/linux/clk.h:16,
> from drivers/staging/tegra-vde/vde.c:11:
>drivers/staging/tegra-vde/vde.c: In function 'tegra_vde_setup_hw_context':
>>> drivers/staging/tegra-vde/vde.c:51:11: warning: format '%X' expects 
>>> argument of type 'unsigned int', but argument 5 has type 'long long 
>>> unsigned int' [-Wformat=]
>  pr_debug("%s: %d: 0x%08X => " #__addr ")\n", \
>   ^
>include/linux/printk.h:285:21: note: in definition of macro 'pr_fmt'
> #define pr_fmt(fmt) fmt
> ^~~
>include/linux/printk.h:333:2: note: in expansion of macro 
> 'dynamic_pr_debug'
>  dynamic_pr_debug(fmt, ##__VA_ARGS__)
>  ^~~~
>drivers/staging/tegra-vde/vde.c:51:2: note: in expansion of macro 
> 'pr_debug'
>  pr_debug("%s: %d: 0x%08X => " #__addr ")\n", \
>  ^~~~
>drivers/staging/tegra-vde/vde.c:362:2: note: in expansion of macro 'VDE_WR'
>  VDE_WR(bitstream_data_paddr + bitstream_data_size,
>  ^~
>>> drivers/staging/tegra-vde/vde.c:51:11: warning: format '%X' expects 
>>> argument of type 'unsigned int', but argument 5 has type 'phys_addr_t {aka 
>>> long long unsigned int}' [-Wformat=]
>  pr_debug("%s: %d: 0x%08X => " #__addr ")\n", \
>   ^
>include/linux/printk.h:285:21: note: in definition of macro 'pr_fmt'
> #define pr_fmt(fmt) fmt
> ^~~
>include/linux/printk.h:333:2: note: in expansion of macro 
> 'dynamic_pr_debug'
>  dynamic_pr_debug(fmt, ##__VA_ARGS__)
>  ^~~~
>drivers/staging/tegra-vde/vde.c:51:2: note: in expansion of macro 
> 'pr_debug'
>  pr_debug("%s: %d: 0x%08X => " #__addr ")\n", \
>  ^~~~
>drivers/staging/tegra-vde/vde.c:435:2: note: in expansion of macro 'VDE_WR'
>  VDE_WR(bitstream_data_paddr, vde->regs + SXE(0x6C));
>  ^~
>drivers/staging/tegra-vde/vde.c: In function 'tegra_vde_attach_dmabuf':
>drivers/staging/tegra-vde/vde.c:531:40: warning: format '%d' expects 
> argument of type 'int', but argument 3 has type 'size_t {aka long unsigned 
> int}' [-Wformat=]
>   dev_err(dev, "Too small dmabuf size %d @0x%lX, "
>^
>drivers/staging/tegra-vde/vde.c: In function 'tegra_vde_ioctl_decode_h264':
>drivers/staging/tegra-vde/vde.c:855:16: warning: format '%X' expects 
> argument of type 'unsigned int', but argument 3 has type 'phys_addr_t {aka 
> long long unsigned int}' [-Wformat=]
>   dev_err(dev, "Decoding failed, "
>^~~
> 
> vim +51 drivers/staging/tegra-vde/vde.c
> 
>   > 11#include 
> 12#include 
> 13#include 
> 14#include 
> 15#include 
> 16#include 
> 17#include 
> 18#include 
> 19#include 
> 20#include 
> 21#include 
> 22#include 
> 23#include 
> 24
> 25#include 
> 26
> 27#include "uapi.h"
> 28
> 29#define SXE(offt)   (0x + (offt)) /* Syntax 
> Engine */
> 30#define BSEV(offt)  (0x1000 + (offt)) /* Video 
> Bitstream Engine */
> 31#define MBE(offt)   (0x2000 + (offt)) /* Macroblock 
> Engin

Re: [PATCH v4] staging: atomisp: add a driver for ov5648 camera sensor

2017-10-06 Thread Sakari Ailus
Hi Devid,

On Wed, Oct 04, 2017 at 01:23:36AM +0200, Devid Antonio Filoni wrote:
> I was not able to properly test this patch on my Lenovo Miix 310 due to other
> issues with atomisp, the output is the same as ov2680 driver (OVTI2680) which
> is very similar to ov5648. As reported by dmesg, atomisp-gmin-platform fails
> to load CamClk, ClkSrc, CsiPort, CsiLanes variables from ACPI (although they
> are set as showed by DSDT) and it fails to get regulators. My Miix 310 uses
> AXP PMIC (INT33F4:00) which, as far as I can understand by looking at
> 01org/ProductionKernelQuilts code, it's yet not supported by mainline kernel.

Hmm. In other words this driver isn't usable due to lack of other drivers.
Even if they'd be in place, this hasn't been tested. What would be the
likelihood of it functioning in the end?

Would it make sense to first get the other drivers to upstream and then see
what's the status of atomisp? The atomisp driver has a number of entries in
its TODO file, one of which is making the sensor drivers to use the
standard kernel interfaces to work with the main driver (atomisp), so that
they could be used with any ISP / bridge driver.

Also, the interface the atomisp uses with the sensor drivers as well as how
the board specific information from firmware is conveyed to the sensor
drivers will change to what the rest of the sensor drivers are using. I
think a most straightforward way would be to amend the ACPI tables to
include the necessary information.

Therefore, applying this patch would not have an effective improvement to
the users in form of support for new systems and would make the upcoming
interface changes more difficult as there would be one more driver to
change (and test).

For this reason I'm tempted to postpone applying this patch at least until
the other drivers are available.

Andy, Alan; any opinion?

-- 
Kind regards,

Sakari Ailus
sakari.ai...@linux.intel.com
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/2 v3] Add new uio device for PCI with dynamic memory allocation

2017-10-06 Thread Stahl, Manuel
This device combines the uio_pci_generic driver and the uio_dmem_genirq
driver since PCI uses a slightly different API for interrupts.
A fixed number of DMA capable memory regions can be defined using the
module parameter "dmem_sizes". The memory is not allocated until the uio
device file is opened for the first time. When the device file is closed,
the allocated memory block is freed. Physical (DMA) addresses for the
dynamic regions are provided to the userspace via
/sys/class/uio/uioX/maps/mapY/addr in the same way as static addresses are
when the uio device file is open, when no processes are holding the device
file open, the address returned to userspace is DMA_ERROR_CODE.

Signed-off-by: Manuel Stahl 
---
 MAINTAINERS   |   6 +
 drivers/uio/Kconfig   |   9 +
 drivers/uio/Makefile  |   1 +
 drivers/uio/uio_pci_dmem_genirq.c | 352 ++
 4 files changed, 368 insertions(+)
 create mode 100644 drivers/uio/uio_pci_dmem_genirq.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 65b0c88d5ee0..e135c171f88b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5801,6 +5801,12 @@ L:   k...@vger.kernel.org
 S: Supported
 F: drivers/uio/uio_pci_generic.c
 
+GENERIC UIO DRIVER FOR PCI DEVICES WITH DMA
+M: "Manuel Stahl" 
+L: k...@vger.kernel.org
+S: Supported
+F: drivers/uio/uio_pci_dmem_genirq.c
+
 GENWQE (IBM Generic Workqueue Card)
 M: Frank Haverkamp 
 M: Guilherme G. Piccoli 
diff --git a/drivers/uio/Kconfig b/drivers/uio/Kconfig
index 7e8dc78a9796..30ca4d405378 100644
--- a/drivers/uio/Kconfig
+++ b/drivers/uio/Kconfig
@@ -93,6 +93,15 @@ config UIO_PCI_GENERIC
      primarily, for virtualization scenarios.
      If you compile this as a module, it will be called uio_pci_generic.
 
+config UIO_PCI_DMEM_GENIRQ
+   tristate "Generic driver for PCI 2.3 and PCI Express cards with DMA"
+   depends on PCI
+   help
+     Generic driver that you can bind, dynamically, to any
+     PCI 2.3 compliant and PCI Express card. It is useful
+  for FPGAs with DMA capability connected via PCI.
+     If you compile this as a module, it will be called 
uio_pci_dmem_genirq.
+
 config UIO_NETX
    tristate "Hilscher NetX Card driver"
    depends on PCI
diff --git a/drivers/uio/Makefile b/drivers/uio/Makefile
index e9663bb8a4c7..6c010c26695d 100644
--- a/drivers/uio/Makefile
+++ b/drivers/uio/Makefile
@@ -5,6 +5,7 @@ obj-$(CONFIG_UIO_DMEM_GENIRQ)   += uio_dmem_genirq.o
 obj-$(CONFIG_UIO_AEC)  += uio_aec.o
 obj-$(CONFIG_UIO_SERCOS3)  += uio_sercos3.o
 obj-$(CONFIG_UIO_PCI_GENERIC)  += uio_pci_generic.o
+obj-$(CONFIG_UIO_PCI_DMEM_GENIRQ)  += uio_pci_dmem_genirq.o
 obj-$(CONFIG_UIO_NETX) += uio_netx.o
 obj-$(CONFIG_UIO_PRUSS) += uio_pruss.o
 obj-$(CONFIG_UIO_MF624) += uio_mf624.o
diff --git a/drivers/uio/uio_pci_dmem_genirq.c 
b/drivers/uio/uio_pci_dmem_genirq.c
new file mode 100644
index ..d1dfd8002c6d
--- /dev/null
+++ b/drivers/uio/uio_pci_dmem_genirq.c
@@ -0,0 +1,352 @@
+/* uio_pci_generic - generic UIO driver for PCI 2.3 devices with DMA memory
+ *
+ * Copyright (C) 2016 Fraunhofer IIS
+ * Author: Manuel Stahl 
+ *
+ * Based on uio_pci_generic.c by Michael S. Tsirkin
+ * and uio_dmem_genirq.c by Damian Hobson-Garcia.
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.
+ *
+ * Since the driver does not declare any device ids, you must allocate
+ * id and bind the device to the driver yourself.  For example:
+ *
+ * # echo "8086 10f5" > /sys/bus/pci/drivers/uio_pci_dmem_genirq/new_id
+ * # echo -n :00:19.0 > /sys/bus/pci/drivers/e1000e/unbind
+ * # echo -n :00:19.0 > /sys/bus/pci/drivers/uio_pci_dmem_genirq/bind
+ * # ls -l /sys/bus/pci/devices/:00:19.0/driver
+ * .../:00:19.0/driver -> ../../../bus/pci/drivers/uio_pci_dmem_genirq
+ *
+ * Or use a modprobe alias:
+ * # alias pci:v10EEd1000sv*sd*sc*i* uio_pci_dmem_genirq
+ *
+ * Driver won't bind to devices which do not support the Interrupt Disable Bit
+ * in the command register. All devices compliant to PCI 2.3 (circa 2002) and
+ * all compliant PCI Express devices should support this bit.
+ *
+ * The DMA mask bits and sizes of dynamic regions are derived from module
+ * parameters.
+ *
+ * The format for specifying dynamic region sizes in module parameters
+ * is as follows:
+ *
+ * uio_pci_dmem_genirq.dmem_sizes := 
[;]
+ *    := :[,]
+ *    := :
+ *  := standard linux memsize
+ *
+ * Examples:
+ *
+ * 1) UIO dmem device with 3 dynamic regions:
+ * uio_pci_dmem_genirq.dmem_sizes=8086:10f5:4K,16K,4M
+ *
+ * 2) Two UIO dmem devices with different number of dynamic regions:
+ * uio_pci_dmem_genirq.dmem_sizes=8086:10f5:4K,16K,4M;1234:0001:8K
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define DRIVER_VERSION  "0.01.0"
+#define DRIVER_AUTHOR 

[PATCH 2/2] uio: Prefer MSI(X) interrupts in PCI drivers

2017-10-06 Thread Stahl, Manuel

Signed-off-by: Manuel Stahl 
---
 drivers/uio/uio_pci_dmem_genirq.c | 27 ---
 drivers/uio/uio_pci_generic.c | 24 ++--
 2 files changed, 38 insertions(+), 13 deletions(-)

diff --git a/drivers/uio/uio_pci_dmem_genirq.c 
b/drivers/uio/uio_pci_dmem_genirq.c
index d1dfd8002c6d..ebb3f9012cd8 100644
--- a/drivers/uio/uio_pci_dmem_genirq.c
+++ b/drivers/uio/uio_pci_dmem_genirq.c
@@ -173,11 +173,13 @@ static irqreturn_t irqhandler(int irq, struct uio_info 
*info)
 {
    struct uio_pci_dmem_dev *gdev = to_uio_pci_dmem_dev(info);
 
-   if (!pci_check_and_mask_intx(gdev->pdev))
-   return IRQ_NONE;
+   if (gdev->pdev->msi_enabled || gdev->pdev->msix_enabled)
+   return IRQ_HANDLED;
 
-   /* UIO core will signal the user process. */
-   return IRQ_HANDLED;
+   if (pci_check_and_mask_intx(gdev->pdev))
+   return IRQ_HANDLED;
+
+   return IRQ_NONE;
 }
 
 static unsigned int uio_dmem_dma_bits = 32;
@@ -269,11 +271,19 @@ static int probe(struct pci_dev *pdev, const struct 
pci_device_id *id)
    }
    pci_set_master(pdev);
 
-   dev_info(&pdev->dev, "Legacy IRQ: %i", pdev->irq);
-   if (pdev->irq && !pci_intx_mask_supported(pdev)) {
-   err = -ENODEV;
+   /* Try to use MSI interrupts */
+   err = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES);
+   if (err) {
+   dev_err(&pdev->dev, "%s: pci_alloc_irq_vectors failed: %d\n",
+   __func__, err);
    goto err_disable_pci;
    }
+   if (!pdev->msi_enabled && !pdev->msix_enabled &&
+   !pci_intx_mask_supported(pdev)) {
+   err = -ENODEV;
+   goto err_free_irq_vectors;
+   }
+   dev_info(&pdev->dev, "IRQ: %i", pdev->irq);
 
    gdev = kzalloc(sizeof(*gdev), GFP_KERNEL);
    if (!gdev) {
@@ -316,6 +326,8 @@ static int probe(struct pci_dev *pdev, const struct 
pci_device_id *id)
    return 0;
 err_free_gdev:
    kfree(gdev);
+err_free_irq_vectors:
+   pci_free_irq_vectors(pdev);
 err_disable_pci:
    pci_clear_master(pdev);
    pci_disable_device(pdev);
@@ -327,6 +339,7 @@ static void remove(struct pci_dev *pdev)
    struct uio_pci_dmem_dev *gdev = pci_get_drvdata(pdev);
 
    uio_unregister_device(&gdev->info);
+   pci_free_irq_vectors(pdev);
    pci_clear_master(pdev);
    pci_disable_device(pdev);
    kfree(gdev);
diff --git a/drivers/uio/uio_pci_generic.c b/drivers/uio/uio_pci_generic.c
index a56fdf972dbe..23a800e76303 100644
--- a/drivers/uio/uio_pci_generic.c
+++ b/drivers/uio/uio_pci_generic.c
@@ -46,11 +46,13 @@ static irqreturn_t irqhandler(int irq, struct uio_info 
*info)
 {
    struct uio_pci_generic_dev *gdev = to_uio_pci_generic_dev(info);
 
-   if (!pci_check_and_mask_intx(gdev->pdev))
-   return IRQ_NONE;
+   if (gdev->pdev->msi_enabled || gdev->pdev->msix_enabled)
+   return IRQ_HANDLED;
 
-   /* UIO core will signal the user process. */
-   return IRQ_HANDLED;
+   if (pci_check_and_mask_intx(gdev->pdev))
+   return IRQ_HANDLED;
+
+   return IRQ_NONE;
 }
 
 static int probe(struct pci_dev *pdev,
@@ -66,10 +68,18 @@ static int probe(struct pci_dev *pdev,
    return err;
    }
 
-   if (pdev->irq && !pci_intx_mask_supported(pdev)) {
-   err = -ENODEV;
+   /* Try to use MSI interrupts */
+   err = pci_alloc_irq_vectors(pdev, 0, 1, PCI_IRQ_ALL_TYPES);
+   if (err) {
+   dev_err(&pdev->dev, "%s: pci_alloc_irq_vectors failed: %d\n",
+   __func__, err);
    goto err_verify;
    }
+   if (pdev->irq && !pdev->msi_enabled && !pdev->msix_enabled &&
+   !pci_intx_mask_supported(pdev)) {
+   err = -ENODEV;
+   goto err_alloc;
+   }
 
    gdev = kzalloc(sizeof(struct uio_pci_generic_dev), GFP_KERNEL);
    if (!gdev) {
@@ -98,6 +108,7 @@ static int probe(struct pci_dev *pdev,
 err_register:
    kfree(gdev);
 err_alloc:
+   pci_free_irq_vectors(pdev);
 err_verify:
    pci_disable_device(pdev);
    return err;
@@ -108,6 +119,7 @@ static void remove(struct pci_dev *pdev)
    struct uio_pci_generic_dev *gdev = pci_get_drvdata(pdev);
 
    uio_unregister_device(&gdev->info);
+   pci_free_irq_vectors(pdev);
    pci_disable_device(pdev);
    kfree(gdev);
 }
-- 
2.11.0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 2/2] uio: Prefer MSI(X) interrupts in PCI drivers

2017-10-06 Thread gre...@linuxfoundation.org
On Fri, Oct 06, 2017 at 01:33:32PM +, Stahl, Manuel wrote:
> 
> Signed-off-by: Manuel Stahl 
> ---
>  drivers/uio/uio_pci_dmem_genirq.c | 27 ---
>  drivers/uio/uio_pci_generic.c | 24 ++--
>  2 files changed, 38 insertions(+), 13 deletions(-)

I can't take patches without any changelog text in them, sorry.

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


Re: [PATCH 2/2] uio: Prefer MSI(X) interrupts in PCI drivers

2017-10-06 Thread Stahl, Manuel
MSI(X) interrupts are not shared between devices. So when available
those should be preferred over legacy interrupts.

Signed-off-by: Manuel Stahl 
---
 drivers/uio/uio_pci_dmem_genirq.c | 27 ---
 drivers/uio/uio_pci_generic.c | 24 ++--
 2 files changed, 38 insertions(+), 13 deletions(-)

diff --git a/drivers/uio/uio_pci_dmem_genirq.c 
b/drivers/uio/uio_pci_dmem_genirq.c
index d1dfd8002c6d..ebb3f9012cd8 100644
--- a/drivers/uio/uio_pci_dmem_genirq.c
+++ b/drivers/uio/uio_pci_dmem_genirq.c
@@ -173,11 +173,13 @@ static irqreturn_t irqhandler(int irq, struct uio_info 
*info)
 {
    struct uio_pci_dmem_dev *gdev = to_uio_pci_dmem_dev(info);
 
-   if (!pci_check_and_mask_intx(gdev->pdev))
-   return IRQ_NONE;
+   if (gdev->pdev->msi_enabled || gdev->pdev->msix_enabled)
+   return IRQ_HANDLED;
 
-   /* UIO core will signal the user process. */
-   return IRQ_HANDLED;
+   if (pci_check_and_mask_intx(gdev->pdev))
+   return IRQ_HANDLED;
+
+   return IRQ_NONE;
 }
 
 static unsigned int uio_dmem_dma_bits = 32;
@@ -269,11 +271,19 @@ static int probe(struct pci_dev *pdev, const struct 
pci_device_id *id)
    }
    pci_set_master(pdev);
 
-   dev_info(&pdev->dev, "Legacy IRQ: %i", pdev->irq);
-   if (pdev->irq && !pci_intx_mask_supported(pdev)) {
-   err = -ENODEV;
+   /* Try to use MSI interrupts */
+   err = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES);
+   if (err) {
+   dev_err(&pdev->dev, "%s: pci_alloc_irq_vectors failed: %d\n",
+   __func__, err);
    goto err_disable_pci;
    }
+   if (!pdev->msi_enabled && !pdev->msix_enabled &&
+   !pci_intx_mask_supported(pdev)) {
+   err = -ENODEV;
+   goto err_free_irq_vectors;
+   }
+   dev_info(&pdev->dev, "IRQ: %i", pdev->irq);
 
    gdev = kzalloc(sizeof(*gdev), GFP_KERNEL);
    if (!gdev) {
@@ -316,6 +326,8 @@ static int probe(struct pci_dev *pdev, const struct 
pci_device_id *id)
    return 0;
 err_free_gdev:
    kfree(gdev);
+err_free_irq_vectors:
+   pci_free_irq_vectors(pdev);
 err_disable_pci:
    pci_clear_master(pdev);
    pci_disable_device(pdev);
@@ -327,6 +339,7 @@ static void remove(struct pci_dev *pdev)
    struct uio_pci_dmem_dev *gdev = pci_get_drvdata(pdev);
 
    uio_unregister_device(&gdev->info);
+   pci_free_irq_vectors(pdev);
    pci_clear_master(pdev);
    pci_disable_device(pdev);
    kfree(gdev);
diff --git a/drivers/uio/uio_pci_generic.c b/drivers/uio/uio_pci_generic.c
index a56fdf972dbe..23a800e76303 100644
--- a/drivers/uio/uio_pci_generic.c
+++ b/drivers/uio/uio_pci_generic.c
@@ -46,11 +46,13 @@ static irqreturn_t irqhandler(int irq, struct uio_info 
*info)
 {
    struct uio_pci_generic_dev *gdev = to_uio_pci_generic_dev(info);
 
-   if (!pci_check_and_mask_intx(gdev->pdev))
-   return IRQ_NONE;
+   if (gdev->pdev->msi_enabled || gdev->pdev->msix_enabled)
+   return IRQ_HANDLED;
 
-   /* UIO core will signal the user process. */
-   return IRQ_HANDLED;
+   if (pci_check_and_mask_intx(gdev->pdev))
+   return IRQ_HANDLED;
+
+   return IRQ_NONE;
 }
 
 static int probe(struct pci_dev *pdev,
@@ -66,10 +68,18 @@ static int probe(struct pci_dev *pdev,
    return err;
    }
 
-   if (pdev->irq && !pci_intx_mask_supported(pdev)) {
-   err = -ENODEV;
+   /* Try to use MSI interrupts */
+   err = pci_alloc_irq_vectors(pdev, 0, 1, PCI_IRQ_ALL_TYPES);
+   if (err) {
+   dev_err(&pdev->dev, "%s: pci_alloc_irq_vectors failed: %d\n",
+   __func__, err);
    goto err_verify;
    }
+   if (pdev->irq && !pdev->msi_enabled && !pdev->msix_enabled &&
+   !pci_intx_mask_supported(pdev)) {
+   err = -ENODEV;
+   goto err_alloc;
+   }
 
    gdev = kzalloc(sizeof(struct uio_pci_generic_dev), GFP_KERNEL);
    if (!gdev) {
@@ -98,6 +108,7 @@ static int probe(struct pci_dev *pdev,
 err_register:
    kfree(gdev);
 err_alloc:
+   pci_free_irq_vectors(pdev);
 err_verify:
    pci_disable_device(pdev);
    return err;
@@ -108,6 +119,7 @@ static void remove(struct pci_dev *pdev)
    struct uio_pci_generic_dev *gdev = pci_get_drvdata(pdev);
 
    uio_unregister_device(&gdev->info);
+   pci_free_irq_vectors(pdev);
    pci_disable_device(pdev);
    kfree(gdev);
 }
-- 
2.11.0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 2/2] uio: Prefer MSI(X) interrupts in PCI drivers

2017-10-06 Thread Stephen Hemminger
On Fri, 6 Oct 2017 13:50:44 +
"Stahl, Manuel"  wrote:

> MSI(X) interrupts are not shared between devices. So when available
> those should be preferred over legacy interrupts.
> 
> Signed-off-by: Manuel Stahl 
> ---
>  drivers/uio/uio_pci_dmem_genirq.c | 27 ---
>  drivers/uio/uio_pci_generic.c | 24 ++--
>  2 files changed, 38 insertions(+), 13 deletions(-)

The last time I tried to do MSI-X with pci-generic it got rejected
by the maintainer.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] x86/hyperv: clear vcpu banks between calls to avoid flushing unneeded vCPUs

2017-10-06 Thread Vitaly Kuznetsov
hv_flush_pcpu_ex structures are not cleared between calls for performance
reasons (they're variable size up to PAGE_SIZE each) but we must clear
hv_vp_set.bank_contents part of it to avoid flushing unneeded vCPUs. The
rest of the structure is formed correctly.

To do the clearing in an efficient way stash the maximum possible vCPU
number (this may differ from Linux CPU id).

Reported-by: Jork Loeser 
Signed-off-by: Vitaly Kuznetsov 
---
 arch/x86/hyperv/hv_init.c   |  5 +
 arch/x86/hyperv/mmu.c   | 17 -
 arch/x86/include/asm/mshyperv.h |  1 +
 3 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
index 1a8eb550c40f..a5db63f728a2 100644
--- a/arch/x86/hyperv/hv_init.c
+++ b/arch/x86/hyperv/hv_init.c
@@ -85,6 +85,8 @@ EXPORT_SYMBOL_GPL(hyperv_cs);
 u32 *hv_vp_index;
 EXPORT_SYMBOL_GPL(hv_vp_index);
 
+u32 hv_max_vp_index;
+
 static int hv_cpu_init(unsigned int cpu)
 {
u64 msr_vp_index;
@@ -93,6 +95,9 @@ static int hv_cpu_init(unsigned int cpu)
 
hv_vp_index[smp_processor_id()] = msr_vp_index;
 
+   if (msr_vp_index > hv_max_vp_index)
+   hv_max_vp_index = msr_vp_index;
+
return 0;
 }
 
diff --git a/arch/x86/hyperv/mmu.c b/arch/x86/hyperv/mmu.c
index b8957309bdc4..9cc9e1c1e2db 100644
--- a/arch/x86/hyperv/mmu.c
+++ b/arch/x86/hyperv/mmu.c
@@ -76,6 +76,18 @@ static inline int cpumask_to_vp_set(struct hv_flush_pcpu_ex 
*flush,
 {
int cpu, vcpu, vcpu_bank, vcpu_offset, nr_bank = 1;
 
+   /* valid_bank_mask can represent up to 64 banks */
+   if (hv_max_vp_index / 64 >= 64)
+   return 0;
+
+   /*
+* Clear all banks up to the maximum possible bank as hv_flush_pcpu_ex
+* structs are not cleared between calls, we risk flushing unneeded
+* vCPUs otherwise.
+*/
+   for (vcpu_bank = 0; vcpu_bank <= hv_max_vp_index / 64; vcpu_bank++)
+   flush->hv_vp_set.bank_contents[vcpu_bank] = 0;
+
/*
 * Some banks may end up being empty but this is acceptable.
 */
@@ -83,11 +95,6 @@ static inline int cpumask_to_vp_set(struct hv_flush_pcpu_ex 
*flush,
vcpu = hv_cpu_number_to_vp_number(cpu);
vcpu_bank = vcpu / 64;
vcpu_offset = vcpu % 64;
-
-   /* valid_bank_mask can represent up to 64 banks */
-   if (vcpu_bank >= 64)
-   return 0;
-
__set_bit(vcpu_offset, (unsigned long *)
  &flush->hv_vp_set.bank_contents[vcpu_bank]);
if (vcpu_bank >= nr_bank)
diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index 738503e1f80c..530f448fddaf 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -289,6 +289,7 @@ static inline u64 hv_do_rep_hypercall(u16 code, u16 
rep_count, u16 varhead_size,
  * to this information.
  */
 extern u32 *hv_vp_index;
+extern u32 hv_max_vp_index;
 
 /**
  * hv_cpu_number_to_vp_number() - Map CPU to VP.
-- 
2.13.6

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


[PATCH] staging: comedi: dt282x: release irq on dt282x detach

2017-10-06 Thread Arvind Yadav
free_irq() should be called on driver 'dt282x' detach.

Signed-off-by: Arvind Yadav 
---
 drivers/staging/comedi/drivers/dt282x.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/staging/comedi/drivers/dt282x.c 
b/drivers/staging/comedi/drivers/dt282x.c
index d5295bb..a132f60 100644
--- a/drivers/staging/comedi/drivers/dt282x.c
+++ b/drivers/staging/comedi/drivers/dt282x.c
@@ -1057,6 +1057,8 @@ static void dt282x_alloc_dma(struct comedi_device *dev,
if (request_irq(irq_num, dt282x_interrupt, 0, dev->board_name, dev))
return;
 
+   dev->irq = irq_num;
+
/* DMA uses two 4K buffers with separate DMA channels */
devpriv->dma = comedi_isadma_alloc(dev, 2, dma_chan[0], dma_chan[1],
   PAGE_SIZE, 0);
@@ -1070,6 +1072,9 @@ static void dt282x_free_dma(struct comedi_device *dev)
 
if (devpriv)
comedi_isadma_free(devpriv->dma);
+
+   if (dev->irq)
+   free_irq(dev->irq, dev);
 }
 
 static int dt282x_initialize(struct comedi_device *dev)
-- 
2.7.4

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


Re: [PATCH] staging: comedi: dt282x: release irq on dt282x detach

2017-10-06 Thread arvindY

Sorry for noise, ignore this patch.

On Friday 06 October 2017 10:06 PM, Arvind Yadav wrote:

free_irq() should be called on driver 'dt282x' detach.

Signed-off-by: Arvind Yadav 
---
  drivers/staging/comedi/drivers/dt282x.c | 5 +
  1 file changed, 5 insertions(+)

diff --git a/drivers/staging/comedi/drivers/dt282x.c 
b/drivers/staging/comedi/drivers/dt282x.c
index d5295bb..a132f60 100644
--- a/drivers/staging/comedi/drivers/dt282x.c
+++ b/drivers/staging/comedi/drivers/dt282x.c
@@ -1057,6 +1057,8 @@ static void dt282x_alloc_dma(struct comedi_device *dev,
if (request_irq(irq_num, dt282x_interrupt, 0, dev->board_name, dev))
return;
  
+	dev->irq = irq_num;

+
/* DMA uses two 4K buffers with separate DMA channels */
devpriv->dma = comedi_isadma_alloc(dev, 2, dma_chan[0], dma_chan[1],
   PAGE_SIZE, 0);
@@ -1070,6 +1072,9 @@ static void dt282x_free_dma(struct comedi_device *dev)
  
  	if (devpriv)

comedi_isadma_free(devpriv->dma);
+
+   if (dev->irq)
+   free_irq(dev->irq, dev);
  }
  
  static int dt282x_initialize(struct comedi_device *dev)


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


[PATCH] staging: comedi: dt282x: fix IRQ assignment for dev->irq.

2017-10-06 Thread Arvind Yadav
Here, dev->irq is not assigned with irq(irq_num). comedi_legacy_detach()
is using dev->irq for release irq and dt282x_attach() is using dev->irq
for initialize comedi_subdevice.

Signed-off-by: Arvind Yadav 
---
 drivers/staging/comedi/drivers/dt282x.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/comedi/drivers/dt282x.c 
b/drivers/staging/comedi/drivers/dt282x.c
index d5295bb..afb7ac2 100644
--- a/drivers/staging/comedi/drivers/dt282x.c
+++ b/drivers/staging/comedi/drivers/dt282x.c
@@ -1057,6 +1057,8 @@ static void dt282x_alloc_dma(struct comedi_device *dev,
if (request_irq(irq_num, dt282x_interrupt, 0, dev->board_name, dev))
return;
 
+   dev->irq = irq_num;
+
/* DMA uses two 4K buffers with separate DMA channels */
devpriv->dma = comedi_isadma_alloc(dev, 2, dma_chan[0], dma_chan[1],
   PAGE_SIZE, 0);
-- 
2.7.4

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


[PATCH v2] staging: comedi: dt282x: fix IRQ assignment for dev->irq.

2017-10-06 Thread Arvind Yadav
Here, dev->irq is not assigned with irq. comedi_legacy_detach()
is using dev->irq for release irq and dt282x_attach() is using dev->irq
for initialize comedi_subdevice.

Signed-off-by: Arvind Yadav 
---
changes in v2:
comedi_isadma_alloc() can fail. adding dev->irq assignment after
successful return of comedi_isadma_alloc().

 drivers/staging/comedi/drivers/dt282x.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/comedi/drivers/dt282x.c 
b/drivers/staging/comedi/drivers/dt282x.c
index d5295bb..217a4b8 100644
--- a/drivers/staging/comedi/drivers/dt282x.c
+++ b/drivers/staging/comedi/drivers/dt282x.c
@@ -1062,6 +1062,8 @@ static void dt282x_alloc_dma(struct comedi_device *dev,
   PAGE_SIZE, 0);
if (!devpriv->dma)
free_irq(irq_num, dev);
+   else
+   dev->irq = irq_num;
 }
 
 static void dt282x_free_dma(struct comedi_device *dev)
-- 
2.7.4

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


[PATCH v3] staging: most: hdm_usb: Register the driver with module_usb_driver macro

2017-10-06 Thread Alex Briskin
1. Register the driver with module_usb_driver macro instead of module_init
   and module_exit.
2. Remove redundant code.

Signed-off-by: Alex Briskin 
---
 drivers/staging/most/hdm-usb/hdm_usb.c | 20 +---
 1 file changed, 1 insertion(+), 19 deletions(-)

diff --git a/drivers/staging/most/hdm-usb/hdm_usb.c 
b/drivers/staging/most/hdm-usb/hdm_usb.c
index a9c3785d19ae..85775da293fb 100644
--- a/drivers/staging/most/hdm-usb/hdm_usb.c
+++ b/drivers/staging/most/hdm-usb/hdm_usb.c
@@ -1301,25 +1301,7 @@ static struct usb_driver hdm_usb = {
.disconnect = hdm_disconnect,
 };
 
-static int __init hdm_usb_init(void)
-{
-   pr_info("hdm_usb_init()\n");
-   if (usb_register(&hdm_usb)) {
-   pr_err("could not register hdm_usb driver\n");
-   return -EIO;
-   }
-
-   return 0;
-}
-
-static void __exit hdm_usb_exit(void)
-{
-   pr_info("hdm_usb_exit()\n");
-   usb_deregister(&hdm_usb);
-}
-
-module_init(hdm_usb_init);
-module_exit(hdm_usb_exit);
+module_usb_driver(hdm_usb);
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Christian Gromm ");
 MODULE_DESCRIPTION("HDM_4_USB");
-- 
2.11.0

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


[PATCH 2/2] android: binder: Fix null ptr dereference in debug msg

2017-10-06 Thread Sherry Yang
Don't access next->data in kernel debug message when the
next buffer is null.

Acked-by: Arve Hjønnevåg 
Signed-off-by: Sherry Yang 
---
 drivers/android/binder_alloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/android/binder_alloc.c b/drivers/android/binder_alloc.c
index 47e2c032ad3d..6f6f745605af 100644
--- a/drivers/android/binder_alloc.c
+++ b/drivers/android/binder_alloc.c
@@ -560,7 +560,7 @@ static void binder_delete_free_buffer(struct binder_alloc 
*alloc,
binder_alloc_debug(BINDER_DEBUG_BUFFER_ALLOC,
   "%d: merge free, buffer %pK do not share 
page with %pK or %pK\n",
   alloc->pid, buffer->data,
-  prev->data, next->data);
+  prev->data, next ? next->data : NULL);
binder_update_page_range(alloc, 0, buffer_start_page(buffer),
 buffer_start_page(buffer) + PAGE_SIZE);
}
-- 
2.11.0 (Apple Git-81)

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


[PATCH 1/2] android: binder: Change binder_shrinker to static

2017-10-06 Thread Sherry Yang
binder_shrinker struct is not used anywhere outside of
binder_alloc.c and should be static.

Acked-by: Arve Hjønnevåg 
Signed-off-by: Sherry Yang 
---
 drivers/android/binder_alloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/android/binder_alloc.c b/drivers/android/binder_alloc.c
index e283670695db..47e2c032ad3d 100644
--- a/drivers/android/binder_alloc.c
+++ b/drivers/android/binder_alloc.c
@@ -982,7 +982,7 @@ binder_shrink_scan(struct shrinker *shrink, struct 
shrink_control *sc)
return ret;
 }
 
-struct shrinker binder_shrinker = {
+static struct shrinker binder_shrinker = {
.count_objects = binder_shrink_count,
.scan_objects = binder_shrink_scan,
.seeks = DEFAULT_SEEKS,
-- 
2.11.0 (Apple Git-81)

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