[v2, 2/5] MAINTAINERS: update files maintained under DPAA2 PTP/ETHERNET

2018-09-29 Thread Yangbo Lu
The files maintained under DPAA2 PTP/ETHERNET needs to
be updated since dpaa2 ptp driver had been moved into
drivers/net/ethernet/freescale/dpaa2/.

Signed-off-by: Yangbo Lu 
---
Changes for v2:
- Updated files rtc* as dpaa2-ptp*.
---
 MAINTAINERS |   11 ---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 15565de..de33537 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4530,7 +4530,11 @@ DPAA2 ETHERNET DRIVER
 M: Ioana Radulescu 
 L: net...@vger.kernel.org
 S: Maintained
-F: drivers/net/ethernet/freescale/dpaa2
+F: drivers/net/ethernet/freescale/dpaa2/dpaa2-eth*
+F: drivers/net/ethernet/freescale/dpaa2/dpni*
+F: drivers/net/ethernet/freescale/dpaa2/dpkg.h
+F: drivers/net/ethernet/freescale/dpaa2/Makefile
+F: drivers/net/ethernet/freescale/dpaa2/Kconfig
 
 DPAA2 ETHERNET SWITCH DRIVER
 M: Ioana Radulescu 
@@ -4541,9 +4545,10 @@ F:   drivers/staging/fsl-dpaa2/ethsw
 
 DPAA2 PTP CLOCK DRIVER
 M: Yangbo Lu 
-L: linux-ker...@vger.kernel.org
+L: net...@vger.kernel.org
 S: Maintained
-F: drivers/staging/fsl-dpaa2/rtc
+F: drivers/net/ethernet/freescale/dpaa2/dpaa-ptp*
+F: drivers/net/ethernet/freescale/dpaa2/dprtc*
 
 DPT_I2O SCSI RAID DRIVER
 M: Adaptec OEM Raid Solutions 
-- 
1.7.1

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


[v2, 5/5] net: dpaa2: fix and improve dpaa2-ptp driver

2018-09-29 Thread Yangbo Lu
This patch is to fix and improve dpaa2-ptp driver
in some places.

- Fixed the return for some functions.
- Replaced kzalloc with devm_kzalloc.
- Removed dev_set_drvdata(dev, NULL).
- Made ptp_dpaa2_caps const.

Signed-off-by: Yangbo Lu 
---
Changes for v2:
- Added this patch.
---
 drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c |   25 --
 1 files changed, 9 insertions(+), 16 deletions(-)

diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c 
b/drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c
index c73eef2..84b942b 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c
@@ -46,7 +46,7 @@ static int ptp_dpaa2_adjfreq(struct ptp_clock_info *ptp, s32 
ppb)
  mc_dev->mc_handle, tmr_add);
if (err)
dev_err(dev, "dprtc_set_freq_compensation err %d\n", err);
-   return 0;
+   return err;
 }
 
 static int ptp_dpaa2_adjtime(struct ptp_clock_info *ptp, s64 delta)
@@ -61,17 +61,15 @@ static int ptp_dpaa2_adjtime(struct ptp_clock_info *ptp, 
s64 delta)
err = dprtc_get_time(mc_dev->mc_io, 0, mc_dev->mc_handle, &now);
if (err) {
dev_err(dev, "dprtc_get_time err %d\n", err);
-   return 0;
+   return err;
}
 
now += delta;
 
err = dprtc_set_time(mc_dev->mc_io, 0, mc_dev->mc_handle, now);
-   if (err) {
+   if (err)
dev_err(dev, "dprtc_set_time err %d\n", err);
-   return 0;
-   }
-   return 0;
+   return err;
 }
 
 static int ptp_dpaa2_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
@@ -87,12 +85,12 @@ static int ptp_dpaa2_gettime(struct ptp_clock_info *ptp, 
struct timespec64 *ts)
err = dprtc_get_time(mc_dev->mc_io, 0, mc_dev->mc_handle, &ns);
if (err) {
dev_err(dev, "dprtc_get_time err %d\n", err);
-   return 0;
+   return err;
}
 
ts->tv_sec = div_u64_rem(ns, 10, &remainder);
ts->tv_nsec = remainder;
-   return 0;
+   return err;
 }
 
 static int ptp_dpaa2_settime(struct ptp_clock_info *ptp,
@@ -111,10 +109,10 @@ static int ptp_dpaa2_settime(struct ptp_clock_info *ptp,
err = dprtc_set_time(mc_dev->mc_io, 0, mc_dev->mc_handle, ns);
if (err)
dev_err(dev, "dprtc_set_time err %d\n", err);
-   return 0;
+   return err;
 }
 
-static struct ptp_clock_info ptp_dpaa2_caps = {
+static const struct ptp_clock_info ptp_dpaa2_caps = {
.owner  = THIS_MODULE,
.name   = "DPAA2 PTP Clock",
.max_adj= 512000,
@@ -136,7 +134,7 @@ static int dpaa2_ptp_probe(struct fsl_mc_device *mc_dev)
u32 tmr_add = 0;
int err;
 
-   ptp_dpaa2 = kzalloc(sizeof(*ptp_dpaa2), GFP_KERNEL);
+   ptp_dpaa2 = devm_kzalloc(dev, sizeof(*ptp_dpaa2), GFP_KERNEL);
if (!ptp_dpaa2)
return -ENOMEM;
 
@@ -182,8 +180,6 @@ static int dpaa2_ptp_probe(struct fsl_mc_device *mc_dev)
 err_free_mcp:
fsl_mc_portal_free(mc_dev->mc_io);
 err_exit:
-   kfree(ptp_dpaa2);
-   dev_set_drvdata(dev, NULL);
return err;
 }
 
@@ -198,9 +194,6 @@ static int dpaa2_ptp_remove(struct fsl_mc_device *mc_dev)
dprtc_close(mc_dev->mc_io, 0, mc_dev->mc_handle);
fsl_mc_portal_free(mc_dev->mc_io);
 
-   kfree(ptp_dpaa2);
-   dev_set_drvdata(dev, NULL);
-
return 0;
 }
 
-- 
1.7.1

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


[v2, 3/5] net: dpaa2: rename rtc as ptp in dpaa2-ptp driver

2018-09-29 Thread Yangbo Lu
In dpaa2-ptp driver, it's odd to use rtc in names of
some functions and structures except for these dprtc
APIs. This patch is to use ptp instead of rtc in names.

Signed-off-by: Yangbo Lu 
---
Changes for v2:
- Added this patch.
---
 drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c |   30 +++---
 1 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c 
b/drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c
index 2e90d5a..c73eef2 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c
@@ -12,7 +12,7 @@
 #include "dpaa2-ptp.h"
 
 struct ptp_dpaa2_priv {
-   struct fsl_mc_device *rtc_mc_dev;
+   struct fsl_mc_device *ptp_mc_dev;
struct ptp_clock *clock;
struct ptp_clock_info caps;
u32 freq_comp;
@@ -23,7 +23,7 @@ static int ptp_dpaa2_adjfreq(struct ptp_clock_info *ptp, s32 
ppb)
 {
struct ptp_dpaa2_priv *ptp_dpaa2 =
container_of(ptp, struct ptp_dpaa2_priv, caps);
-   struct fsl_mc_device *mc_dev = ptp_dpaa2->rtc_mc_dev;
+   struct fsl_mc_device *mc_dev = ptp_dpaa2->ptp_mc_dev;
struct device *dev = &mc_dev->dev;
u64 adj;
u32 diff, tmr_add;
@@ -53,7 +53,7 @@ static int ptp_dpaa2_adjtime(struct ptp_clock_info *ptp, s64 
delta)
 {
struct ptp_dpaa2_priv *ptp_dpaa2 =
container_of(ptp, struct ptp_dpaa2_priv, caps);
-   struct fsl_mc_device *mc_dev = ptp_dpaa2->rtc_mc_dev;
+   struct fsl_mc_device *mc_dev = ptp_dpaa2->ptp_mc_dev;
struct device *dev = &mc_dev->dev;
s64 now;
int err = 0;
@@ -78,7 +78,7 @@ static int ptp_dpaa2_gettime(struct ptp_clock_info *ptp, 
struct timespec64 *ts)
 {
struct ptp_dpaa2_priv *ptp_dpaa2 =
container_of(ptp, struct ptp_dpaa2_priv, caps);
-   struct fsl_mc_device *mc_dev = ptp_dpaa2->rtc_mc_dev;
+   struct fsl_mc_device *mc_dev = ptp_dpaa2->ptp_mc_dev;
struct device *dev = &mc_dev->dev;
u64 ns;
u32 remainder;
@@ -100,7 +100,7 @@ static int ptp_dpaa2_settime(struct ptp_clock_info *ptp,
 {
struct ptp_dpaa2_priv *ptp_dpaa2 =
container_of(ptp, struct ptp_dpaa2_priv, caps);
-   struct fsl_mc_device *mc_dev = ptp_dpaa2->rtc_mc_dev;
+   struct fsl_mc_device *mc_dev = ptp_dpaa2->ptp_mc_dev;
struct device *dev = &mc_dev->dev;
u64 ns;
int err = 0;
@@ -129,7 +129,7 @@ static int ptp_dpaa2_settime(struct ptp_clock_info *ptp,
.settime64  = ptp_dpaa2_settime,
 };
 
-static int rtc_probe(struct fsl_mc_device *mc_dev)
+static int dpaa2_ptp_probe(struct fsl_mc_device *mc_dev)
 {
struct device *dev = &mc_dev->dev;
struct ptp_dpaa2_priv *ptp_dpaa2;
@@ -153,7 +153,7 @@ static int rtc_probe(struct fsl_mc_device *mc_dev)
goto err_free_mcp;
}
 
-   ptp_dpaa2->rtc_mc_dev = mc_dev;
+   ptp_dpaa2->ptp_mc_dev = mc_dev;
 
err = dprtc_get_freq_compensation(mc_dev->mc_io, 0,
  mc_dev->mc_handle, &tmr_add);
@@ -187,7 +187,7 @@ static int rtc_probe(struct fsl_mc_device *mc_dev)
return err;
 }
 
-static int rtc_remove(struct fsl_mc_device *mc_dev)
+static int dpaa2_ptp_remove(struct fsl_mc_device *mc_dev)
 {
struct ptp_dpaa2_priv *ptp_dpaa2;
struct device *dev = &mc_dev->dev;
@@ -204,26 +204,26 @@ static int rtc_remove(struct fsl_mc_device *mc_dev)
return 0;
 }
 
-static const struct fsl_mc_device_id rtc_match_id_table[] = {
+static const struct fsl_mc_device_id dpaa2_ptp_match_id_table[] = {
{
.vendor = FSL_MC_VENDOR_FREESCALE,
.obj_type = "dprtc",
},
{}
 };
-MODULE_DEVICE_TABLE(fslmc, rtc_match_id_table);
+MODULE_DEVICE_TABLE(fslmc, dpaa2_ptp_match_id_table);
 
-static struct fsl_mc_driver rtc_drv = {
+static struct fsl_mc_driver dpaa2_ptp_drv = {
.driver = {
.name = KBUILD_MODNAME,
.owner = THIS_MODULE,
},
-   .probe = rtc_probe,
-   .remove = rtc_remove,
-   .match_id_table = rtc_match_id_table,
+   .probe = dpaa2_ptp_probe,
+   .remove = dpaa2_ptp_remove,
+   .match_id_table = dpaa2_ptp_match_id_table,
 };
 
-module_fsl_mc_driver(rtc_drv);
+module_fsl_mc_driver(dpaa2_ptp_drv);
 
 MODULE_LICENSE("GPL v2");
 MODULE_DESCRIPTION("DPAA2 PTP Clock Driver");
-- 
1.7.1

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


[v2, 1/5] net: dpaa2: move DPAA2 PTP driver out of staging/

2018-09-29 Thread Yangbo Lu
This patch is to move DPAA2 PTP driver out of staging/
since the dpaa2-eth had been moved out.

Signed-off-by: Yangbo Lu 
---
Changes for v2:
- Renamed files rtc.* as dpaa2-ptp.*.
---
 drivers/net/ethernet/freescale/Kconfig |9 +
 drivers/net/ethernet/freescale/dpaa2/Kconfig   |   15 +++
 drivers/net/ethernet/freescale/dpaa2/Makefile  |6 --
 .../ethernet/freescale/dpaa2/dpaa2-ptp.c}  |2 +-
 .../ethernet/freescale/dpaa2/dpaa2-ptp.h}  |0
 .../ethernet/freescale/dpaa2}/dprtc-cmd.h  |0
 .../rtc => net/ethernet/freescale/dpaa2}/dprtc.c   |0
 .../rtc => net/ethernet/freescale/dpaa2}/dprtc.h   |0
 drivers/staging/fsl-dpaa2/Kconfig  |8 
 drivers/staging/fsl-dpaa2/Makefile |1 -
 drivers/staging/fsl-dpaa2/rtc/Makefile |7 ---
 11 files changed, 21 insertions(+), 27 deletions(-)
 create mode 100644 drivers/net/ethernet/freescale/dpaa2/Kconfig
 rename drivers/{staging/fsl-dpaa2/rtc/rtc.c => 
net/ethernet/freescale/dpaa2/dpaa2-ptp.c} (99%)
 rename drivers/{staging/fsl-dpaa2/rtc/rtc.h => 
net/ethernet/freescale/dpaa2/dpaa2-ptp.h} (100%)
 rename drivers/{staging/fsl-dpaa2/rtc => 
net/ethernet/freescale/dpaa2}/dprtc-cmd.h (100%)
 rename drivers/{staging/fsl-dpaa2/rtc => net/ethernet/freescale/dpaa2}/dprtc.c 
(100%)
 rename drivers/{staging/fsl-dpaa2/rtc => net/ethernet/freescale/dpaa2}/dprtc.h 
(100%)
 delete mode 100644 drivers/staging/fsl-dpaa2/rtc/Makefile

diff --git a/drivers/net/ethernet/freescale/Kconfig 
b/drivers/net/ethernet/freescale/Kconfig
index 7a30276..d3a62bc 100644
--- a/drivers/net/ethernet/freescale/Kconfig
+++ b/drivers/net/ethernet/freescale/Kconfig
@@ -96,13 +96,6 @@ config GIANFAR
  on the 8540.
 
 source "drivers/net/ethernet/freescale/dpaa/Kconfig"
-
-config FSL_DPAA2_ETH
-   tristate "Freescale DPAA2 Ethernet"
-   depends on FSL_MC_BUS && FSL_MC_DPIO
-   depends on NETDEVICES && ETHERNET
-   ---help---
- Ethernet driver for Freescale DPAA2 SoCs, using the
- Freescale MC bus driver
+source "drivers/net/ethernet/freescale/dpaa2/Kconfig"
 
 endif # NET_VENDOR_FREESCALE
diff --git a/drivers/net/ethernet/freescale/dpaa2/Kconfig 
b/drivers/net/ethernet/freescale/dpaa2/Kconfig
new file mode 100644
index 000..44c5c3a
--- /dev/null
+++ b/drivers/net/ethernet/freescale/dpaa2/Kconfig
@@ -0,0 +1,15 @@
+config FSL_DPAA2_ETH
+   tristate "Freescale DPAA2 Ethernet"
+   depends on FSL_MC_BUS && FSL_MC_DPIO
+   depends on NETDEVICES && ETHERNET
+   help
+ Ethernet driver for Freescale DPAA2 SoCs, using the
+ Freescale MC bus driver
+
+config FSL_DPAA2_PTP_CLOCK
+   tristate "Freescale DPAA2 PTP Clock"
+   depends on FSL_DPAA2_ETH && POSIX_TIMERS
+   select PTP_1588_CLOCK
+   help
+ This driver adds support for using the DPAA2 1588 timer module
+ as a PTP clock.
diff --git a/drivers/net/ethernet/freescale/dpaa2/Makefile 
b/drivers/net/ethernet/freescale/dpaa2/Makefile
index 9315ecd..2f424e0 100644
--- a/drivers/net/ethernet/freescale/dpaa2/Makefile
+++ b/drivers/net/ethernet/freescale/dpaa2/Makefile
@@ -3,9 +3,11 @@
 # Makefile for the Freescale DPAA2 Ethernet controller
 #
 
-obj-$(CONFIG_FSL_DPAA2_ETH) += fsl-dpaa2-eth.o
+obj-$(CONFIG_FSL_DPAA2_ETH)+= fsl-dpaa2-eth.o
+obj-$(CONFIG_FSL_DPAA2_PTP_CLOCK)  += fsl-dpaa2-ptp.o
 
-fsl-dpaa2-eth-objs:= dpaa2-eth.o dpaa2-ethtool.o dpni.o
+fsl-dpaa2-eth-objs := dpaa2-eth.o dpaa2-ethtool.o dpni.o
+fsl-dpaa2-ptp-objs := dpaa2-ptp.o dprtc.o
 
 # Needed by the tracing framework
 CFLAGS_dpaa2-eth.o := -I$(src)
diff --git a/drivers/staging/fsl-dpaa2/rtc/rtc.c 
b/drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c
similarity index 99%
rename from drivers/staging/fsl-dpaa2/rtc/rtc.c
rename to drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c
index 0d52cb8..2e90d5a 100644
--- a/drivers/staging/fsl-dpaa2/rtc/rtc.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c
@@ -9,7 +9,7 @@
 #include 
 #include 
 
-#include "rtc.h"
+#include "dpaa2-ptp.h"
 
 struct ptp_dpaa2_priv {
struct fsl_mc_device *rtc_mc_dev;
diff --git a/drivers/staging/fsl-dpaa2/rtc/rtc.h 
b/drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.h
similarity index 100%
rename from drivers/staging/fsl-dpaa2/rtc/rtc.h
rename to drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.h
diff --git a/drivers/staging/fsl-dpaa2/rtc/dprtc-cmd.h 
b/drivers/net/ethernet/freescale/dpaa2/dprtc-cmd.h
similarity index 100%
rename from drivers/staging/fsl-dpaa2/rtc/dprtc-cmd.h
rename to drivers/net/ethernet/freescale/dpaa2/dprtc-cmd.h
diff --git a/drivers/staging/fsl-dpaa2/rtc/dprtc.c 
b/drivers/net/ethernet/freescale/dpaa2/dprtc.c
similarity index 100%
rename from drivers/staging/fsl-dpaa2/rtc/dprtc.c
rename to drivers/net/ethernet/freescale/dpaa2/dprtc.c
diff --git a/drivers/staging/fsl-dpaa2/rtc/dprtc.h 
b/drivers/net/ethernet/freescale/d

[v2, 4/5] net: dpaa2: remove unused code for dprtc

2018-09-29 Thread Yangbo Lu
This patch is to removed unused code for dprtc.
This code will be re-added along with more features
of dpaa2-ptp added.

Signed-off-by: Yangbo Lu 
---
Changes for v2:
- Added this patch.
---
 drivers/net/ethernet/freescale/dpaa2/dprtc-cmd.h |   97 
 drivers/net/ethernet/freescale/dpaa2/dprtc.c |  507 --
 drivers/net/ethernet/freescale/dpaa2/dprtc.h |  119 -
 3 files changed, 0 insertions(+), 723 deletions(-)

diff --git a/drivers/net/ethernet/freescale/dpaa2/dprtc-cmd.h 
b/drivers/net/ethernet/freescale/dpaa2/dprtc-cmd.h
index db6a473..9af4ac7 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dprtc-cmd.h
+++ b/drivers/net/ethernet/freescale/dpaa2/dprtc-cmd.h
@@ -7,10 +7,6 @@
 #ifndef _FSL_DPRTC_CMD_H
 #define _FSL_DPRTC_CMD_H
 
-/* DPRTC Version */
-#define DPRTC_VER_MAJOR2
-#define DPRTC_VER_MINOR0
-
 /* Command versioning */
 #define DPRTC_CMD_BASE_VERSION 1
 #define DPRTC_CMD_ID_OFFSET4
@@ -20,105 +16,17 @@
 /* Command IDs */
 #define DPRTC_CMDID_CLOSE  DPRTC_CMD(0x800)
 #define DPRTC_CMDID_OPEN   DPRTC_CMD(0x810)
-#define DPRTC_CMDID_CREATE DPRTC_CMD(0x910)
-#define DPRTC_CMDID_DESTROYDPRTC_CMD(0x990)
-#define DPRTC_CMDID_GET_API_VERSIONDPRTC_CMD(0xa10)
-
-#define DPRTC_CMDID_ENABLE DPRTC_CMD(0x002)
-#define DPRTC_CMDID_DISABLEDPRTC_CMD(0x003)
-#define DPRTC_CMDID_GET_ATTR   DPRTC_CMD(0x004)
-#define DPRTC_CMDID_RESET  DPRTC_CMD(0x005)
-#define DPRTC_CMDID_IS_ENABLED DPRTC_CMD(0x006)
 
-#define DPRTC_CMDID_SET_IRQ_ENABLE DPRTC_CMD(0x012)
-#define DPRTC_CMDID_GET_IRQ_ENABLE DPRTC_CMD(0x013)
-#define DPRTC_CMDID_SET_IRQ_MASK   DPRTC_CMD(0x014)
-#define DPRTC_CMDID_GET_IRQ_MASK   DPRTC_CMD(0x015)
-#define DPRTC_CMDID_GET_IRQ_STATUS DPRTC_CMD(0x016)
-#define DPRTC_CMDID_CLEAR_IRQ_STATUS   DPRTC_CMD(0x017)
-
-#define DPRTC_CMDID_SET_CLOCK_OFFSET   DPRTC_CMD(0x1d0)
 #define DPRTC_CMDID_SET_FREQ_COMPENSATION  DPRTC_CMD(0x1d1)
 #define DPRTC_CMDID_GET_FREQ_COMPENSATION  DPRTC_CMD(0x1d2)
 #define DPRTC_CMDID_GET_TIME   DPRTC_CMD(0x1d3)
 #define DPRTC_CMDID_SET_TIME   DPRTC_CMD(0x1d4)
-#define DPRTC_CMDID_SET_ALARM  DPRTC_CMD(0x1d5)
-#define DPRTC_CMDID_SET_PERIODIC_PULSE DPRTC_CMD(0x1d6)
-#define DPRTC_CMDID_CLEAR_PERIODIC_PULSE   DPRTC_CMD(0x1d7)
-#define DPRTC_CMDID_SET_EXT_TRIGGERDPRTC_CMD(0x1d8)
-#define DPRTC_CMDID_CLEAR_EXT_TRIGGER  DPRTC_CMD(0x1d9)
-#define DPRTC_CMDID_GET_EXT_TRIGGER_TIMESTAMP  DPRTC_CMD(0x1dA)
-
-/* Macros for accessing command fields smaller than 1byte */
-#define DPRTC_MASK(field)\
-   GENMASK(DPRTC_##field##_SHIFT + DPRTC_##field##_SIZE - 1, \
-   DPRTC_##field##_SHIFT)
-#define dprtc_get_field(var, field)  \
-   (((var) & DPRTC_MASK(field)) >> DPRTC_##field##_SHIFT)
 
 #pragma pack(push, 1)
 struct dprtc_cmd_open {
__le32 dprtc_id;
 };
 
-struct dprtc_cmd_destroy {
-   __le32 object_id;
-};
-
-#define DPRTC_ENABLE_SHIFT 0
-#define DPRTC_ENABLE_SIZE  1
-
-struct dprtc_rsp_is_enabled {
-   u8 en;
-};
-
-struct dprtc_cmd_get_irq {
-   __le32 pad;
-   u8 irq_index;
-};
-
-struct dprtc_cmd_set_irq_enable {
-   u8 en;
-   u8 pad[3];
-   u8 irq_index;
-};
-
-struct dprtc_rsp_get_irq_enable {
-   u8 en;
-};
-
-struct dprtc_cmd_set_irq_mask {
-   __le32 mask;
-   u8 irq_index;
-};
-
-struct dprtc_rsp_get_irq_mask {
-   __le32 mask;
-};
-
-struct dprtc_cmd_get_irq_status {
-   __le32 status;
-   u8 irq_index;
-};
-
-struct dprtc_rsp_get_irq_status {
-   __le32 status;
-};
-
-struct dprtc_cmd_clear_irq_status {
-   __le32 status;
-   u8 irq_index;
-};
-
-struct dprtc_rsp_get_attributes {
-   __le32 pad;
-   __le32 id;
-};
-
-struct dprtc_cmd_set_clock_offset {
-   __le64 offset;
-};
-
 struct dprtc_get_freq_compensation {
__le32 freq_compensation;
 };
@@ -127,11 +35,6 @@ struct dprtc_time {
__le64 time;
 };
 
-struct dprtc_rsp_get_api_version {
-   __le16 major;
-   __le16 minor;
-};
-
 #pragma pack(pop)
 
 #endif /* _FSL_DPRTC_CMD_H */
diff --git a/drivers/net/ethernet/freescale/dpaa2/dprtc.c 
b/drivers/net/ethernet/freescale/dpaa2/dprtc.c
index 68ae6ff..c13e09b 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dprtc.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dprtc.c
@@ -74,452 +74,6 @@ int dprtc_close(struct fsl_mc_io *mc_io,
 }
 
 /**
- * dprtc_create() - Create the DPRTC object.
- * @mc_io: Pointer to MC portal's I/O object
- * @dprc_token:Parent container token; '0' for default container
- * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
- * @cfg:   Configuration 

RE: [PATCH 1/2] net: dpaa2: move DPAA2 PTP driver out of staging/

2018-09-29 Thread Y.b. Lu
Hi all,
Sent out the v2. Please help to review.
Thanks a lot.

Hi Andrew,

> -Original Message-
> From: Y.b. Lu
> Sent: Friday, September 28, 2018 4:04 PM
> To: 'Andrew Lunn' 
> Cc: linux-ker...@vger.kernel.org; de...@driverdev.osuosl.org;
> net...@vger.kernel.org; Richard Cochran ;
> David S . Miller ; Ioana Ciocoi Radulescu
> ; Greg Kroah-Hartman
> 
> Subject: RE: [PATCH 1/2] net: dpaa2: move DPAA2 PTP driver out of staging/
> 
> Hi Andrew,
> 
> Thanks a lot for your comments.
> Please see my comments inline.
> 
> Best regards,
> Yangbo Lu
> 
> > -Original Message-
> > From: Andrew Lunn 
> > Sent: Thursday, September 27, 2018 9:25 PM
> > To: Y.b. Lu 
> > Cc: linux-ker...@vger.kernel.org; de...@driverdev.osuosl.org;
> > net...@vger.kernel.org; Richard Cochran ;
> > David S . Miller ; Ioana Ciocoi Radulescu
> > ; Greg Kroah-Hartman
> > 
> > Subject: Re: [PATCH 1/2] net: dpaa2: move DPAA2 PTP driver out of
> > staging/
> >
> > On Thu, Sep 27, 2018 at 07:12:27PM +0800, Yangbo Lu wrote:
> > > This patch is to move DPAA2 PTP driver out of staging/ since the
> > > dpaa2-eth had been moved out.
> > >
> > > Signed-off-by: Yangbo Lu 
> > > ---
[...]
> 
> > Can rtc_drv be made const?
> 
> [Y.b. Lu] Will use const in next version.
> 

[Y.b. Lu] Sorry, just found it couldn't be made const. Warnings showed when 
built with const.

> > Is rtc.h used by anything other than rtc.c? It seems like it can be removed.
> 
> [Y.b. Lu] Let me remove it in next version.

[Y.b. Lu] Sorry, I still kept that header file since dpaa2_phc_index need to be 
declared.


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


Re: [PATCH] staging: rtlwifi: coding style fixes

2018-09-29 Thread Greg KH
On Sat, Sep 29, 2018 at 11:47:47AM +0800, spring full wrote:
> According to Documentation/process/coding-style.rst,
> ``13) Printing kernel messages ..
> Do not use crippled words like ``dont``; use ``do not`` or ``don't``
> instead``,
> the word dont is changed to don't.
> 
> Signed-off-by: Chunguang Wu 

This name did not match the name in the From: line of your email :(


> ---
>  drivers/staging/rtlwifi/btcoexist/halbtcoutsrc.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/rtlwifi/btcoexist/halbtcoutsrc.c
> b/drivers/staging/rtlwifi/btcoexist/halbtcoutsrc.c
> index 4d1f9bf..d06a747 100644
> --- a/drivers/staging/rtlwifi/btcoexist/halbtcoutsrc.c
> +++ b/drivers/staging/rtlwifi/btcoexist/halbtcoutsrc.c
> @@ -292,7 +292,7 @@ static void halbtc_leave_lps(struct btc_coexist
> *btcoexist)
> 
> if (ap_enable) {
> RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_DMESG,
> -"%s()<--dont leave lps under AP mode\n", __func__);
> +"%s()<--don't leave lps under AP mode\n",
> __func__);
> return;
> }
> 
> @@ -315,7 +315,7 @@ static void halbtc_enter_lps(struct btc_coexist
> *btcoexist)
> 
> if (ap_enable) {
> RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_DMESG,
> -"%s()<--dont enter lps under AP mode\n", __func__);
> +"%s()<--don't enter lps under AP mode\n",
> __func__);
> return;
> }
> 

You email client corrupted all of the whitespace, so I could not apply
this even if I wanted to :(

Please fix up and resend.

thanks,

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


Re: [PATCH] Staging: rts5208: rtsx_card: Fixed multiple coding style issues

2018-09-29 Thread Greg KH
On Fri, Sep 28, 2018 at 10:03:00PM -0400, Maxime Desroches wrote:
> Fixed multiple coding style issues
> 
> Signed-off-by: Maxime Desroches 
> ---
>  drivers/staging/rts5208/rtsx_card.c | 96 +++--
>  1 file changed, 37 insertions(+), 59 deletions(-)

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman.  You have sent him
a patch that has triggered this response.  He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created.  Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.

You are receiving this message because of the following common error(s)
as indicated below:

- Your patch did many different things all at once, making it difficult
  to review.  All Linux kernel patches need to only do one thing at a
  time.  If you need to do multiple things (such as clean up all coding
  style issues in a file/driver), do it in a sequence of patches, each
  one doing only one thing.  This will make it easier to review the
  patches to ensure that they are correct, and to help alleviate any
  merge issues that larger patches can cause.

If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.

thanks,

greg k-h's patch email bot
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] media: zoran: fix spelling mistake "queing" -> "queuing"

2018-09-29 Thread Colin King
From: Colin Ian King 

Trivial fix to spelling mistake in kernel warning message

Signed-off-by: Colin Ian King 
---
 drivers/staging/media/zoran/zoran_driver.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/media/zoran/zoran_driver.c 
b/drivers/staging/media/zoran/zoran_driver.c
index e30c3ef31a9b..27c76e2eeb41 100644
--- a/drivers/staging/media/zoran/zoran_driver.c
+++ b/drivers/staging/media/zoran/zoran_driver.c
@@ -692,7 +692,7 @@ static int zoran_jpg_queue_frame(struct zoran_fh *fh, int 
num,
case BUZ_STATE_DONE:
dprintk(2,
KERN_WARNING
-   "%s: %s - queing frame in BUZ_STATE_DONE 
state!?\n",
+   "%s: %s - queuing frame in BUZ_STATE_DONE 
state!?\n",
ZR_DEVNAME(zr), __func__);
/* fall through */
case BUZ_STATE_USER:
-- 
2.17.1

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


Patch "staging: android: ashmem: Fix mmap size validation" has been added to the 3.18-stable tree

2018-09-29 Thread gregkh


This is a note to let you know that I've just added the patch titled

staging: android: ashmem: Fix mmap size validation

to the 3.18-stable tree which can be found at:

http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
 staging-android-ashmem-fix-mmap-size-validation.patch
and it can be found in the queue-3.18 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let  know about it.


>From foo@baz Sat Sep 29 04:32:11 PDT 2018
From: Alistair Strachan 
Date: Tue, 19 Jun 2018 17:57:35 -0700
Subject: staging: android: ashmem: Fix mmap size validation

From: Alistair Strachan 

[ Upstream commit 8632c614565d0c5fdde527889601c018e97b6384 ]

The ashmem driver did not check that the size/offset of the vma passed
to its .mmap() function was not larger than the ashmem object being
mapped. This could cause mmap() to succeed, even though accessing parts
of the mapping would later fail with a segmentation fault.

Ensure an error is returned by the ashmem_mmap() function if the vma
size is larger than the ashmem object size. This enables safer handling
of the problem in userspace.

Cc: Todd Kjos 
Cc: de...@driverdev.osuosl.org
Cc: linux-ker...@vger.kernel.org
Cc: kernel-t...@android.com
Cc: Joel Fernandes 
Signed-off-by: Alistair Strachan 
Acked-by: Joel Fernandes (Google) 
Reviewed-by: Martijn Coenen 
Signed-off-by: Greg Kroah-Hartman 
Signed-off-by: Sasha Levin 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/staging/android/ashmem.c |6 ++
 1 file changed, 6 insertions(+)

--- a/drivers/staging/android/ashmem.c
+++ b/drivers/staging/android/ashmem.c
@@ -370,6 +370,12 @@ static int ashmem_mmap(struct file *file
goto out;
}
 
+   /* requested mapping size larger than object size */
+   if (vma->vm_end - vma->vm_start > PAGE_ALIGN(asma->size)) {
+   ret = -EINVAL;
+   goto out;
+   }
+
/* requested protection bits must match our allowed protection mask */
if (unlikely((vma->vm_flags & ~calc_vm_prot_bits(asma->prot_mask)) &
 calc_vm_prot_bits(PROT_MASK))) {


Patches currently in stable-queue which might be from astrac...@google.com are

queue-3.18/staging-android-ashmem-fix-mmap-size-validation.patch
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Patch "staging: android: ashmem: Fix mmap size validation" has been added to the 4.14-stable tree

2018-09-29 Thread gregkh


This is a note to let you know that I've just added the patch titled

staging: android: ashmem: Fix mmap size validation

to the 4.14-stable tree which can be found at:

http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
 staging-android-ashmem-fix-mmap-size-validation.patch
and it can be found in the queue-4.14 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let  know about it.


>From foo@baz Sat Sep 29 04:27:59 PDT 2018
From: Alistair Strachan 
Date: Tue, 19 Jun 2018 17:57:35 -0700
Subject: staging: android: ashmem: Fix mmap size validation

From: Alistair Strachan 

[ Upstream commit 8632c614565d0c5fdde527889601c018e97b6384 ]

The ashmem driver did not check that the size/offset of the vma passed
to its .mmap() function was not larger than the ashmem object being
mapped. This could cause mmap() to succeed, even though accessing parts
of the mapping would later fail with a segmentation fault.

Ensure an error is returned by the ashmem_mmap() function if the vma
size is larger than the ashmem object size. This enables safer handling
of the problem in userspace.

Cc: Todd Kjos 
Cc: de...@driverdev.osuosl.org
Cc: linux-ker...@vger.kernel.org
Cc: kernel-t...@android.com
Cc: Joel Fernandes 
Signed-off-by: Alistair Strachan 
Acked-by: Joel Fernandes (Google) 
Reviewed-by: Martijn Coenen 
Signed-off-by: Greg Kroah-Hartman 
Signed-off-by: Sasha Levin 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/staging/android/ashmem.c |6 ++
 1 file changed, 6 insertions(+)

--- a/drivers/staging/android/ashmem.c
+++ b/drivers/staging/android/ashmem.c
@@ -374,6 +374,12 @@ static int ashmem_mmap(struct file *file
goto out;
}
 
+   /* requested mapping size larger than object size */
+   if (vma->vm_end - vma->vm_start > PAGE_ALIGN(asma->size)) {
+   ret = -EINVAL;
+   goto out;
+   }
+
/* requested protection bits must match our allowed protection mask */
if (unlikely((vma->vm_flags & ~calc_vm_prot_bits(asma->prot_mask, 0)) &
 calc_vm_prot_bits(PROT_MASK, 0))) {


Patches currently in stable-queue which might be from astrac...@google.com are

queue-4.14/staging-android-ashmem-fix-mmap-size-validation.patch
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Patch "staging: android: ashmem: Fix mmap size validation" has been added to the 4.18-stable tree

2018-09-29 Thread gregkh


This is a note to let you know that I've just added the patch titled

staging: android: ashmem: Fix mmap size validation

to the 4.18-stable tree which can be found at:

http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
 staging-android-ashmem-fix-mmap-size-validation.patch
and it can be found in the queue-4.18 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let  know about it.


>From foo@baz Sat Sep 29 04:24:28 PDT 2018
From: Alistair Strachan 
Date: Tue, 19 Jun 2018 17:57:35 -0700
Subject: staging: android: ashmem: Fix mmap size validation

From: Alistair Strachan 

[ Upstream commit 8632c614565d0c5fdde527889601c018e97b6384 ]

The ashmem driver did not check that the size/offset of the vma passed
to its .mmap() function was not larger than the ashmem object being
mapped. This could cause mmap() to succeed, even though accessing parts
of the mapping would later fail with a segmentation fault.

Ensure an error is returned by the ashmem_mmap() function if the vma
size is larger than the ashmem object size. This enables safer handling
of the problem in userspace.

Cc: Todd Kjos 
Cc: de...@driverdev.osuosl.org
Cc: linux-ker...@vger.kernel.org
Cc: kernel-t...@android.com
Cc: Joel Fernandes 
Signed-off-by: Alistair Strachan 
Acked-by: Joel Fernandes (Google) 
Reviewed-by: Martijn Coenen 
Signed-off-by: Greg Kroah-Hartman 
Signed-off-by: Sasha Levin 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/staging/android/ashmem.c |6 ++
 1 file changed, 6 insertions(+)

--- a/drivers/staging/android/ashmem.c
+++ b/drivers/staging/android/ashmem.c
@@ -366,6 +366,12 @@ static int ashmem_mmap(struct file *file
goto out;
}
 
+   /* requested mapping size larger than object size */
+   if (vma->vm_end - vma->vm_start > PAGE_ALIGN(asma->size)) {
+   ret = -EINVAL;
+   goto out;
+   }
+
/* requested protection bits must match our allowed protection mask */
if (unlikely((vma->vm_flags & ~calc_vm_prot_bits(asma->prot_mask, 0)) &
 calc_vm_prot_bits(PROT_MASK, 0))) {


Patches currently in stable-queue which might be from astrac...@google.com are

queue-4.18/staging-android-ashmem-fix-mmap-size-validation.patch
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Patch "staging: android: ashmem: Fix mmap size validation" has been added to the 4.4-stable tree

2018-09-29 Thread gregkh


This is a note to let you know that I've just added the patch titled

staging: android: ashmem: Fix mmap size validation

to the 4.4-stable tree which can be found at:

http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
 staging-android-ashmem-fix-mmap-size-validation.patch
and it can be found in the queue-4.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let  know about it.


>From foo@baz Sat Sep 29 04:30:43 PDT 2018
From: Alistair Strachan 
Date: Tue, 19 Jun 2018 17:57:35 -0700
Subject: staging: android: ashmem: Fix mmap size validation

From: Alistair Strachan 

[ Upstream commit 8632c614565d0c5fdde527889601c018e97b6384 ]

The ashmem driver did not check that the size/offset of the vma passed
to its .mmap() function was not larger than the ashmem object being
mapped. This could cause mmap() to succeed, even though accessing parts
of the mapping would later fail with a segmentation fault.

Ensure an error is returned by the ashmem_mmap() function if the vma
size is larger than the ashmem object size. This enables safer handling
of the problem in userspace.

Cc: Todd Kjos 
Cc: de...@driverdev.osuosl.org
Cc: linux-ker...@vger.kernel.org
Cc: kernel-t...@android.com
Cc: Joel Fernandes 
Signed-off-by: Alistair Strachan 
Acked-by: Joel Fernandes (Google) 
Reviewed-by: Martijn Coenen 
Signed-off-by: Greg Kroah-Hartman 
Signed-off-by: Sasha Levin 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/staging/android/ashmem.c |6 ++
 1 file changed, 6 insertions(+)

--- a/drivers/staging/android/ashmem.c
+++ b/drivers/staging/android/ashmem.c
@@ -370,6 +370,12 @@ static int ashmem_mmap(struct file *file
goto out;
}
 
+   /* requested mapping size larger than object size */
+   if (vma->vm_end - vma->vm_start > PAGE_ALIGN(asma->size)) {
+   ret = -EINVAL;
+   goto out;
+   }
+
/* requested protection bits must match our allowed protection mask */
if (unlikely((vma->vm_flags & ~calc_vm_prot_bits(asma->prot_mask)) &
 calc_vm_prot_bits(PROT_MASK))) {


Patches currently in stable-queue which might be from astrac...@google.com are

queue-4.4/staging-android-ashmem-fix-mmap-size-validation.patch
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Patch "staging: android: ashmem: Fix mmap size validation" has been added to the 4.9-stable tree

2018-09-29 Thread gregkh


This is a note to let you know that I've just added the patch titled

staging: android: ashmem: Fix mmap size validation

to the 4.9-stable tree which can be found at:

http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
 staging-android-ashmem-fix-mmap-size-validation.patch
and it can be found in the queue-4.9 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let  know about it.


>From foo@baz Sat Sep 29 04:29:21 PDT 2018
From: Alistair Strachan 
Date: Tue, 19 Jun 2018 17:57:35 -0700
Subject: staging: android: ashmem: Fix mmap size validation

From: Alistair Strachan 

[ Upstream commit 8632c614565d0c5fdde527889601c018e97b6384 ]

The ashmem driver did not check that the size/offset of the vma passed
to its .mmap() function was not larger than the ashmem object being
mapped. This could cause mmap() to succeed, even though accessing parts
of the mapping would later fail with a segmentation fault.

Ensure an error is returned by the ashmem_mmap() function if the vma
size is larger than the ashmem object size. This enables safer handling
of the problem in userspace.

Cc: Todd Kjos 
Cc: de...@driverdev.osuosl.org
Cc: linux-ker...@vger.kernel.org
Cc: kernel-t...@android.com
Cc: Joel Fernandes 
Signed-off-by: Alistair Strachan 
Acked-by: Joel Fernandes (Google) 
Reviewed-by: Martijn Coenen 
Signed-off-by: Greg Kroah-Hartman 
Signed-off-by: Sasha Levin 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/staging/android/ashmem.c |6 ++
 1 file changed, 6 insertions(+)

--- a/drivers/staging/android/ashmem.c
+++ b/drivers/staging/android/ashmem.c
@@ -383,6 +383,12 @@ static int ashmem_mmap(struct file *file
goto out;
}
 
+   /* requested mapping size larger than object size */
+   if (vma->vm_end - vma->vm_start > PAGE_ALIGN(asma->size)) {
+   ret = -EINVAL;
+   goto out;
+   }
+
/* requested protection bits must match our allowed protection mask */
if (unlikely((vma->vm_flags & ~calc_vm_prot_bits(asma->prot_mask, 0)) &
 calc_vm_prot_bits(PROT_MASK, 0))) {


Patches currently in stable-queue which might be from astrac...@google.com are

queue-4.9/staging-android-ashmem-fix-mmap-size-validation.patch
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH resend 00/15] staging: vboxvideo: Convert to atomic modesetting API

2018-09-29 Thread Hans de Goede
Hi All,

This series converts the vboxvideo driver to the modesetting API, once this
is merged I will submit a patch to move the driver out of staging and into
drivers/gpu/drm.

This series consists of 3 parts:

1) More cleanups / prep work for atomic conversion
2) The actual atomic conversion, this is modelled after the atomic conversion
   of the qxl driver done by Gabriel Krisman Bertazi. Gabriel if you are
   reading this, thank you for providing a roadmap how to go about this.
3) Restore some features which were lost by the atomic conversion +
   more cleanups

Regards,

Hans

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


[PATCH resend 07/15] staging: vboxvideo: Atomic phase 2: Wire up state object handlers

2018-09-29 Thread Hans de Goede
Wire up state object handlers for the crtc-s and the planes, call
drm_mode_config_reset() after creating all the crtc-s and encoders and
remove the legacy drm_helper_disable_unused_functions() call.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_fb.c   |  3 ---
 drivers/staging/vboxvideo/vbox_mode.c | 15 ++-
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_fb.c 
b/drivers/staging/vboxvideo/vbox_fb.c
index b8b42f9aafae..8a9d56762659 100644
--- a/drivers/staging/vboxvideo/vbox_fb.c
+++ b/drivers/staging/vboxvideo/vbox_fb.c
@@ -216,9 +216,6 @@ int vbox_fbdev_init(struct vbox_private *vbox)
if (ret)
goto err_fini;
 
-   /* disable all the possible outputs/crtcs before entering KMS mode */
-   drm_helper_disable_unused_functions(dev);
-
ret = drm_fb_helper_initial_config(&fbdev->helper, 32);
if (ret)
goto err_fini;
diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index e560e36e7953..cb897b672752 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -301,10 +301,6 @@ static const struct drm_crtc_helper_funcs 
vbox_crtc_helper_funcs = {
.atomic_flush = vbox_crtc_atomic_flush,
 };
 
-static void vbox_crtc_reset(struct drm_crtc *crtc)
-{
-}
-
 static void vbox_crtc_destroy(struct drm_crtc *crtc)
 {
drm_crtc_cleanup(crtc);
@@ -312,10 +308,12 @@ static void vbox_crtc_destroy(struct drm_crtc *crtc)
 }
 
 static const struct drm_crtc_funcs vbox_crtc_funcs = {
-   .reset = vbox_crtc_reset,
.set_config = drm_crtc_helper_set_config,
/* .gamma_set = vbox_crtc_gamma_set, */
.destroy = vbox_crtc_destroy,
+   .reset = drm_atomic_helper_crtc_reset,
+   .atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
+   .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
 };
 
 static int vbox_primary_atomic_check(struct drm_plane *plane,
@@ -527,6 +525,9 @@ static const struct drm_plane_funcs vbox_cursor_plane_funcs 
= {
.update_plane   = drm_plane_helper_update,
.disable_plane  = drm_plane_helper_disable,
.destroy= drm_primary_helper_destroy,
+   .reset  = drm_atomic_helper_plane_reset,
+   .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
+   .atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
 };
 
 static const uint32_t vbox_primary_plane_formats[] = {
@@ -546,6 +547,9 @@ static const struct drm_plane_funcs 
vbox_primary_plane_funcs = {
.update_plane   = drm_plane_helper_update,
.disable_plane  = drm_primary_helper_disable,
.destroy= drm_primary_helper_destroy,
+   .reset  = drm_atomic_helper_plane_reset,
+   .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
+   .atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
 };
 
 static struct drm_plane *vbox_create_plane(struct vbox_private *vbox,
@@ -982,6 +986,7 @@ int vbox_mode_init(struct vbox_private *vbox)
goto err_drm_mode_cleanup;
}
 
+   drm_mode_config_reset(dev);
return 0;
 
 err_drm_mode_cleanup:
-- 
2.19.0

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


[PATCH resend 14/15] staging: vboxvideo: Drop unnecessary drm_connector_helper_funcs callbacks

2018-09-29 Thread Hans de Goede
vbox_mode_valid always returns MODE_OK, which is also the default if no
mode_valid callback is defined.

vbox_best_single_encoder chains to drm_encoder_find, the drm-core will
call drm_encoder_find itself if there is no best_encoder call back.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_mode.c | 20 
 1 file changed, 20 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index 4993a6cf6770..756544b53600 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -651,18 +651,6 @@ static void vbox_encoder_destroy(struct drm_encoder 
*encoder)
kfree(encoder);
 }
 
-static struct drm_encoder *vbox_best_single_encoder(struct drm_connector
-   *connector)
-{
-   int enc_id = connector->encoder_ids[0];
-
-   /* pick the encoder ids */
-   if (enc_id)
-   return drm_encoder_find(connector->dev, NULL, enc_id);
-
-   return NULL;
-}
-
 static const struct drm_encoder_funcs vbox_enc_funcs = {
.destroy = vbox_encoder_destroy,
 };
@@ -820,12 +808,6 @@ static int vbox_get_modes(struct drm_connector *connector)
return num_modes;
 }
 
-static enum drm_mode_status vbox_mode_valid(struct drm_connector *connector,
-  struct drm_display_mode *mode)
-{
-   return MODE_OK;
-}
-
 static void vbox_connector_destroy(struct drm_connector *connector)
 {
drm_connector_unregister(connector);
@@ -862,9 +844,7 @@ static int vbox_fill_modes(struct drm_connector *connector, 
u32 max_x,
 }
 
 static const struct drm_connector_helper_funcs vbox_connector_helper_funcs = {
-   .mode_valid = vbox_mode_valid,
.get_modes = vbox_get_modes,
-   .best_encoder = vbox_best_single_encoder,
 };
 
 static const struct drm_connector_funcs vbox_connector_funcs = {
-- 
2.19.0

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


[PATCH] gpiolib: Fix incorrect use of find_next_zero_bit()

2018-09-29 Thread Janusz Krzysztofik
Commit b17566a6b08b ("gpiolib: Implement fast processing path in
get/set array"), already fixed to some extent with commit 5d581d7e8cdc
("gpiolib: Fix missing updates of bitmap index"), introduced a new mode
of processing bitmaps where bits applicable for fast bitmap processing
path are supposed to be skipped while iterating bits which don't apply.
Unfortunately, find_next_zero_bit() function supposed to skip over
those fast bits is always called with a 'start' argument equal to an
index of last zero bit found and returns that index value again an
again, causing an infinite loop.

Fix it by incrementing the index uncoditionally before
find_next_zero_bit() is optionally called.

Reported-by: Marek Szyprowski 
Signed-off-by: Janusz Krzysztofik 
---
Marek,

Could you please test it on top of next-20180920 with "gpiolib: Fix
missing updates of bitmap index" and optionally "mmc: pwrseq_simple:
Fix incorrect handling of GPIO bitmap" also applied?

Thanks,
Janusz


 drivers/gpio/gpiolib.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 6ae13e3e05f1..940b543e966d 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -2878,12 +2878,11 @@ int gpiod_get_array_value_complex(bool raw, bool 
can_sleep,
int hwgpio = gpio_chip_hwgpio(desc);
 
__set_bit(hwgpio, mask);
+   i++;
 
if (array_info)
i = find_next_zero_bit(array_info->get_mask,
   array_size, i);
-   else
-   i++;
} while ((i < array_size) &&
 (desc_array[i]->gdev->chip == chip));
 
@@ -2903,12 +2902,11 @@ int gpiod_get_array_value_complex(bool raw, bool 
can_sleep,
value = !value;
__assign_bit(j, value_bitmap, value);
trace_gpio_value(desc_to_gpio(desc), 1, value);
+   j++;
 
if (array_info)
j = find_next_zero_bit(array_info->get_mask, i,
   j);
-   else
-   j++;
}
 
if (mask != fastpath)
@@ -3191,12 +3189,11 @@ int gpiod_set_array_value_complex(bool raw, bool 
can_sleep,
__clear_bit(hwgpio, bits);
count++;
}
+   i++;
 
if (array_info)
i = find_next_zero_bit(array_info->set_mask,
   array_size, i);
-   else
-   i++;
} while ((i < array_size) &&
 (desc_array[i]->gdev->chip == chip));
/* push collected bits to outputs */
-- 
2.16.4

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


[PATCH resend 10/15] staging: vboxvideo: Restore page-flip support

2018-09-29 Thread Hans de Goede
Restore page-flip support now that the atomic conversion is complete.

Since the mode parameter to vbox_crtc_set_base_and_mode() now never
is NULL call drm_atomic_crtc_needs_modeset() to check if we need to
check for input-mapping changes, to avoid doing unnecesarry work on
a flip. And hookup the drm_atomic_helper_page_flip helper to implement
the page_flip callback.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_mode.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index 69a1e6c163b9..c4ec3fa49782 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -32,6 +32,7 @@
  *  Hans de Goede 
  */
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -217,6 +218,7 @@ static void vbox_crtc_set_base_and_mode(struct drm_crtc 
*crtc,
struct vbox_bo *bo = gem_to_vbox_bo(to_vbox_framebuffer(fb)->obj);
struct vbox_private *vbox = crtc->dev->dev_private;
struct vbox_crtc *vbox_crtc = to_vbox_crtc(crtc);
+   bool needs_modeset = drm_atomic_crtc_needs_modeset(crtc->state);
 
mutex_lock(&vbox->hw_mutex);
 
@@ -227,7 +229,7 @@ static void vbox_crtc_set_base_and_mode(struct drm_crtc 
*crtc,
vbox_crtc->fb_offset = vbox_bo_gpu_offset(bo);
 
/* vbox_do_modeset() checks vbox->single_framebuffer so update it now */
-   if (mode && vbox_set_up_input_mapping(vbox)) {
+   if (needs_modeset && vbox_set_up_input_mapping(vbox)) {
struct drm_crtc *crtci;
 
list_for_each_entry(crtci, &vbox->ddev.mode_config.crtc_list,
@@ -241,7 +243,7 @@ static void vbox_crtc_set_base_and_mode(struct drm_crtc 
*crtc,
vbox_set_view(crtc);
vbox_do_modeset(crtc);
 
-   if (mode)
+   if (needs_modeset)
hgsmi_update_input_mapping(vbox->guest_pool, 0, 0,
   vbox->input_mapping_width,
   vbox->input_mapping_height);
@@ -288,6 +290,7 @@ static void vbox_crtc_destroy(struct drm_crtc *crtc)
 
 static const struct drm_crtc_funcs vbox_crtc_funcs = {
.set_config = drm_atomic_helper_set_config,
+   .page_flip = drm_atomic_helper_page_flip,
/* .gamma_set = vbox_crtc_gamma_set, */
.destroy = vbox_crtc_destroy,
.reset = drm_atomic_helper_crtc_reset,
-- 
2.19.0

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


[PATCH resend 06/15] staging: vboxvideo: Atomic phase 1: Use drm_plane_helpers for primary plane

2018-09-29 Thread Hans de Goede
Use drm_plane_helpers for the primary plane and replace our custom
mode_set callback with drm_helper_crtc_mode_set.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_mode.c | 116 --
 1 file changed, 90 insertions(+), 26 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index 75e112d33cf0..e560e36e7953 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -257,50 +257,48 @@ static void vbox_crtc_set_base_and_mode(struct drm_crtc 
*crtc,
mutex_unlock(&vbox->hw_mutex);
 }
 
-static int vbox_crtc_mode_set(struct drm_crtc *crtc,
- struct drm_display_mode *mode,
- struct drm_display_mode *adjusted_mode,
- int x, int y, struct drm_framebuffer *old_fb)
+static void vbox_crtc_disable(struct drm_crtc *crtc)
 {
-   struct drm_framebuffer *new_fb = CRTC_FB(crtc);
-   struct vbox_bo *bo = gem_to_vbox_bo(to_vbox_framebuffer(new_fb)->obj);
-   int ret;
-
-   ret = vbox_bo_pin(bo, TTM_PL_FLAG_VRAM);
-   if (ret) {
-   DRM_WARN("Error %d pinning new fb, out of video mem?\n", ret);
-   return ret;
-   }
-
-   vbox_crtc_set_base_and_mode(crtc, new_fb, mode, x, y);
-
-   if (old_fb) {
-   bo = gem_to_vbox_bo(to_vbox_framebuffer(old_fb)->obj);
-   vbox_bo_unpin(bo);
-   }
+}
 
-   return 0;
+static void vbox_crtc_prepare(struct drm_crtc *crtc)
+{
 }
 
-static void vbox_crtc_disable(struct drm_crtc *crtc)
+static void vbox_crtc_commit(struct drm_crtc *crtc)
 {
 }
 
-static void vbox_crtc_prepare(struct drm_crtc *crtc)
+static void vbox_crtc_mode_set_nofb(struct drm_crtc *crtc)
 {
+   /* We always set the mode when we set the fb/base */
 }
 
-static void vbox_crtc_commit(struct drm_crtc *crtc)
+static void vbox_crtc_atomic_flush(struct drm_crtc *crtc,
+  struct drm_crtc_state *old_crtc_state)
 {
+   struct drm_pending_vblank_event *event;
+   unsigned long flags;
+
+   if (crtc->state && crtc->state->event) {
+   event = crtc->state->event;
+   crtc->state->event = NULL;
+
+   spin_lock_irqsave(&crtc->dev->event_lock, flags);
+   drm_crtc_send_vblank_event(crtc, event);
+   spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
+   }
 }
 
 static const struct drm_crtc_helper_funcs vbox_crtc_helper_funcs = {
.dpms = vbox_crtc_dpms,
.mode_fixup = vbox_crtc_mode_fixup,
-   .mode_set = vbox_crtc_mode_set,
+   .mode_set = drm_helper_crtc_mode_set,
+   .mode_set_nofb = vbox_crtc_mode_set_nofb,
.disable = vbox_crtc_disable,
.prepare = vbox_crtc_prepare,
.commit = vbox_crtc_commit,
+   .atomic_flush = vbox_crtc_atomic_flush,
 };
 
 static void vbox_crtc_reset(struct drm_crtc *crtc)
@@ -320,6 +318,63 @@ static const struct drm_crtc_funcs vbox_crtc_funcs = {
.destroy = vbox_crtc_destroy,
 };
 
+static int vbox_primary_atomic_check(struct drm_plane *plane,
+struct drm_plane_state *new_state)
+{
+   return 0;
+}
+
+static void vbox_primary_atomic_update(struct drm_plane *plane,
+  struct drm_plane_state *old_state)
+{
+   struct drm_crtc *crtc = plane->state->crtc;
+   struct drm_framebuffer *fb = plane->state->fb;
+
+   vbox_crtc_set_base_and_mode(crtc, fb, &crtc->state->mode,
+   plane->state->src_x >> 16,
+   plane->state->src_y >> 16);
+}
+
+void vbox_primary_atomic_disable(struct drm_plane *plane,
+struct drm_plane_state *old_state)
+{
+   struct drm_crtc *crtc = old_state->crtc;
+
+   /* vbox_do_modeset checks plane->state->fb and will disable if NULL */
+   vbox_crtc_set_base_and_mode(crtc, old_state->fb, &crtc->state->mode,
+   old_state->src_x >> 16,
+   old_state->src_y >> 16);
+}
+
+static int vbox_primary_prepare_fb(struct drm_plane *plane,
+  struct drm_plane_state *new_state)
+{
+   struct vbox_bo *bo;
+   int ret;
+
+   if (!new_state->fb)
+   return 0;
+
+   bo = gem_to_vbox_bo(to_vbox_framebuffer(new_state->fb)->obj);
+   ret = vbox_bo_pin(bo, TTM_PL_FLAG_VRAM);
+   if (ret)
+   DRM_WARN("Error %d pinning new fb, out of video mem?\n", ret);
+
+   return ret;
+}
+
+static void vbox_primary_cleanup_fb(struct drm_plane *plane,
+   struct drm_plane_state *old_state)
+{
+   struct vbox_bo *bo;
+
+   if (!old_state->fb)
+   return;
+
+   bo = gem_to_vbox_bo(to_vbox_framebuffer(old_state->fb)->obj);
+   vbox_bo_unpin(bo);
+}
+
 static int vbox_cur

[PATCH resend 03/15] staging: vboxvideo: Temporarily remove page_flip support

2018-09-29 Thread Hans de Goede
drm_mode_page_flip_ioctl() cannot deal with the in between phase of
the transitioning to atomic modeset support. Once we start using
drm_helper_crtc_mode_set(), we start setting plane->state on the primary
plane. But we are not fully atomic yet so then set both plane-state->fb
and plane->fb.

If both plane-state->fb and plane->fb are set drm_mode_page_flip_ioctl()
gets confused and stops calling drm_framebuffer_get() on the new fb while
still calling drm_framebuffer_put() on the old fb.

The current page_flip implementation expects drm_mode_page_flip_ioctl()
to take care of both and once we switch to drm_atomic_helper_page_flip()
that will expect neither to be done, taking care of both itself.

So for the transition we need to remove page_flip support and then after
the transition is complete and we set DRIVER_ATOMIC in our driver_features,
we can start using drm_atomic_helper_page_flip().

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_mode.c | 35 ---
 1 file changed, 35 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index babb02a1ebf2..adb6bcf989d1 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -282,40 +282,6 @@ static int vbox_crtc_mode_set(struct drm_crtc *crtc,
return 0;
 }
 
-static int vbox_crtc_page_flip(struct drm_crtc *crtc,
-  struct drm_framebuffer *fb,
-  struct drm_pending_vblank_event *event,
-  uint32_t page_flip_flags,
-  struct drm_modeset_acquire_ctx *ctx)
-{
-   struct vbox_bo *bo = gem_to_vbox_bo(to_vbox_framebuffer(fb)->obj);
-   struct drm_framebuffer *old_fb = CRTC_FB(crtc);
-   unsigned long flags;
-   int rc;
-
-   rc = vbox_bo_pin(bo, TTM_PL_FLAG_VRAM);
-   if (rc) {
-   DRM_WARN("Error %d pinning new fb, out of video mem?\n", rc);
-   return rc;
-   }
-
-   vbox_crtc_set_base_and_mode(crtc, fb, NULL, 0, 0);
-
-   if (old_fb) {
-   bo = gem_to_vbox_bo(to_vbox_framebuffer(old_fb)->obj);
-   vbox_bo_unpin(bo);
-   }
-
-   spin_lock_irqsave(&crtc->dev->event_lock, flags);
-
-   if (event)
-   drm_crtc_send_vblank_event(crtc, event);
-
-   spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
-
-   return 0;
-}
-
 static void vbox_crtc_disable(struct drm_crtc *crtc)
 {
 }
@@ -353,7 +319,6 @@ static const struct drm_crtc_funcs vbox_crtc_funcs = {
.reset = vbox_crtc_reset,
.set_config = drm_crtc_helper_set_config,
/* .gamma_set = vbox_crtc_gamma_set, */
-   .page_flip = vbox_crtc_page_flip,
.destroy = vbox_crtc_destroy,
 };
 
-- 
2.19.0

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


[PATCH resend 13/15] staging: vboxvideo: Call drm_atomic_helper_check_plane_state from atomic_check

2018-09-29 Thread Hans de Goede
Extend our planes atomic_check callbacks to be more thorough by calling
the drm_atomic_helper_check_plane_state helper.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_mode.c | 30 ++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index 72fc6614179a..4993a6cf6770 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -280,7 +280,19 @@ static const struct drm_crtc_funcs vbox_crtc_funcs = {
 static int vbox_primary_atomic_check(struct drm_plane *plane,
 struct drm_plane_state *new_state)
 {
-   return 0;
+   struct drm_crtc_state *crtc_state = NULL;
+
+   if (new_state->crtc) {
+   crtc_state = drm_atomic_get_existing_crtc_state(
+   new_state->state, new_state->crtc);
+   if (WARN_ON(!crtc_state))
+   return -EINVAL;
+   }
+
+   return drm_atomic_helper_check_plane_state(new_state, crtc_state,
+  DRM_PLANE_HELPER_NO_SCALING,
+  DRM_PLANE_HELPER_NO_SCALING,
+  false, true);
 }
 
 static void vbox_primary_atomic_update(struct drm_plane *plane,
@@ -337,8 +349,24 @@ static void vbox_primary_cleanup_fb(struct drm_plane 
*plane,
 static int vbox_cursor_atomic_check(struct drm_plane *plane,
struct drm_plane_state *new_state)
 {
+   struct drm_crtc_state *crtc_state = NULL;
u32 width = new_state->crtc_w;
u32 height = new_state->crtc_h;
+   int ret;
+
+   if (new_state->crtc) {
+   crtc_state = drm_atomic_get_existing_crtc_state(
+   new_state->state, new_state->crtc);
+   if (WARN_ON(!crtc_state))
+   return -EINVAL;
+   }
+
+   ret = drm_atomic_helper_check_plane_state(new_state, crtc_state,
+ DRM_PLANE_HELPER_NO_SCALING,
+ DRM_PLANE_HELPER_NO_SCALING,
+ true, true);
+   if (ret)
+   return ret;
 
if (!new_state->fb)
return 0;
-- 
2.19.0

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


[PATCH resend 11/15] staging: vboxvideo: Fix DPMS support after atomic conversion

2018-09-29 Thread Hans de Goede
Atomic modesetting does not use the traditional dpms call backs, instead
we should check crtc_state->active.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_drv.h  |  1 -
 drivers/staging/vboxvideo/vbox_mode.c | 28 ++-
 2 files changed, 2 insertions(+), 27 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_drv.h 
b/drivers/staging/vboxvideo/vbox_drv.h
index fccb3851d6a3..9cc20c182df1 100644
--- a/drivers/staging/vboxvideo/vbox_drv.h
+++ b/drivers/staging/vboxvideo/vbox_drv.h
@@ -139,7 +139,6 @@ struct vbox_connector {
 
 struct vbox_crtc {
struct drm_crtc base;
-   bool blanked;
bool disconnected;
unsigned int crtc_id;
u32 fb_offset;
diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index c4ec3fa49782..49ff9c4a6302 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -84,14 +84,13 @@ static void vbox_do_modeset(struct drm_crtc *crtc)
}
 
flags = VBVA_SCREEN_F_ACTIVE;
-   flags |= (fb && !vbox_crtc->blanked) ? 0 : VBVA_SCREEN_F_BLANK;
+   flags |= (fb && crtc->state->active) ? 0 : VBVA_SCREEN_F_BLANK;
flags |= vbox_crtc->disconnected ? VBVA_SCREEN_F_DISABLED : 0;
hgsmi_process_display_info(vbox->guest_pool, vbox_crtc->crtc_id,
   x_offset, y_offset,
   vbox_crtc->x * bpp / 8 +
vbox_crtc->y * pitch,
-  pitch, width, height,
-  vbox_crtc->blanked ? 0 : bpp, flags);
+  pitch, width, height, bpp, flags);
 }
 
 static int vbox_set_view(struct drm_crtc *crtc)
@@ -128,27 +127,6 @@ static int vbox_set_view(struct drm_crtc *crtc)
return 0;
 }
 
-static void vbox_crtc_dpms(struct drm_crtc *crtc, int mode)
-{
-   struct vbox_crtc *vbox_crtc = to_vbox_crtc(crtc);
-   struct vbox_private *vbox = crtc->dev->dev_private;
-
-   switch (mode) {
-   case DRM_MODE_DPMS_ON:
-   vbox_crtc->blanked = false;
-   break;
-   case DRM_MODE_DPMS_STANDBY:
-   case DRM_MODE_DPMS_SUSPEND:
-   case DRM_MODE_DPMS_OFF:
-   vbox_crtc->blanked = true;
-   break;
-   }
-
-   mutex_lock(&vbox->hw_mutex);
-   vbox_do_modeset(crtc);
-   mutex_unlock(&vbox->hw_mutex);
-}
-
 /*
  * Try to map the layout of virtual screens to the range of the input device.
  * Return true if we need to re-set the crtc modes due to screen offset
@@ -276,7 +254,6 @@ static void vbox_crtc_atomic_flush(struct drm_crtc *crtc,
 }
 
 static const struct drm_crtc_helper_funcs vbox_crtc_helper_funcs = {
-   .dpms = vbox_crtc_dpms,
.disable = vbox_crtc_disable,
.commit = vbox_crtc_commit,
.atomic_flush = vbox_crtc_atomic_flush,
@@ -861,7 +838,6 @@ static const struct drm_connector_helper_funcs 
vbox_connector_helper_funcs = {
 };
 
 static const struct drm_connector_funcs vbox_connector_funcs = {
-   .dpms = drm_helper_connector_dpms,
.detect = vbox_connector_detect,
.fill_modes = vbox_fill_modes,
.destroy = vbox_connector_destroy,
-- 
2.19.0

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


[PATCH resend 08/15] staging: vboxvideo: Atomic phase 2: Stop using plane->fb and crtc->*

2018-09-29 Thread Hans de Goede
Once we are fully atomic plane->fb will always be NULL and we also
should not access things like crtc->enabled and crt->[hw]mode.

Now that we've wired up the state object handlers, we always have a
plane_state and crtc_state so change the code referencing plane->fb and
crtc->* to use the data from the plane_state and crt_state instead.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_drv.h  |  1 -
 drivers/staging/vboxvideo/vbox_main.c | 16 +++-
 drivers/staging/vboxvideo/vbox_mode.c | 15 +++
 3 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_drv.h 
b/drivers/staging/vboxvideo/vbox_drv.h
index 7fc668ff4465..fccb3851d6a3 100644
--- a/drivers/staging/vboxvideo/vbox_drv.h
+++ b/drivers/staging/vboxvideo/vbox_drv.h
@@ -199,7 +199,6 @@ int vbox_mode_init(struct vbox_private *vbox);
 void vbox_mode_fini(struct vbox_private *vbox);
 
 #define DRM_MODE_FB_CMD drm_mode_fb_cmd2
-#define CRTC_FB(crtc) ((crtc)->primary->fb)
 
 void vbox_enable_accel(struct vbox_private *vbox);
 void vbox_disable_accel(struct vbox_private *vbox);
diff --git a/drivers/staging/vboxvideo/vbox_main.c 
b/drivers/staging/vboxvideo/vbox_main.c
index 95100c5976e4..3b82d483ab51 100644
--- a/drivers/staging/vboxvideo/vbox_main.c
+++ b/drivers/staging/vboxvideo/vbox_main.c
@@ -102,24 +102,30 @@ void vbox_framebuffer_dirty_rectangles(struct 
drm_framebuffer *fb,
   unsigned int num_rects)
 {
struct vbox_private *vbox = fb->dev->dev_private;
+   struct drm_display_mode *mode;
struct drm_crtc *crtc;
+   int crtc_x, crtc_y;
unsigned int i;
 
mutex_lock(&vbox->hw_mutex);
list_for_each_entry(crtc, &fb->dev->mode_config.crtc_list, head) {
-   if (CRTC_FB(crtc) != fb)
+   if (crtc->primary->state->fb != fb)
continue;
 
+   mode = &crtc->state->mode;
+   crtc_x = crtc->primary->state->src_x >> 16;
+   crtc_y = crtc->primary->state->src_y >> 16;
+
vbox_enable_accel(vbox);
 
for (i = 0; i < num_rects; ++i) {
struct vbva_cmd_hdr cmd_hdr;
unsigned int crtc_id = to_vbox_crtc(crtc)->crtc_id;
 
-   if ((rects[i].x1 > crtc->x + crtc->hwmode.hdisplay) ||
-   (rects[i].y1 > crtc->y + crtc->hwmode.vdisplay) ||
-   (rects[i].x2 < crtc->x) ||
-   (rects[i].y2 < crtc->y))
+   if ((rects[i].x1 > crtc_x + mode->hdisplay) ||
+   (rects[i].y1 > crtc_y + mode->vdisplay) ||
+   (rects[i].x2 < crtc_x) ||
+   (rects[i].y2 < crtc_y))
continue;
 
cmd_hdr.x = (s16)rects[i].x1;
diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index cb897b672752..54e6aac784f7 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -46,6 +46,7 @@
  */
 static void vbox_do_modeset(struct drm_crtc *crtc)
 {
+   struct drm_framebuffer *fb = crtc->primary->state->fb;
struct vbox_crtc *vbox_crtc = to_vbox_crtc(crtc);
struct vbox_private *vbox;
int width, height, bpp, pitch;
@@ -55,8 +56,8 @@ static void vbox_do_modeset(struct drm_crtc *crtc)
vbox = crtc->dev->dev_private;
width = vbox_crtc->width ? vbox_crtc->width : 640;
height = vbox_crtc->height ? vbox_crtc->height : 480;
-   bpp = crtc->enabled ? CRTC_FB(crtc)->format->cpp[0] * 8 : 32;
-   pitch = crtc->enabled ? CRTC_FB(crtc)->pitches[0] : width * bpp / 8;
+   bpp = fb ? fb->format->cpp[0] * 8 : 32;
+   pitch = fb ? fb->pitches[0] : width * bpp / 8;
x_offset = vbox->single_framebuffer ? vbox_crtc->x : vbox_crtc->x_hint;
y_offset = vbox->single_framebuffer ? vbox_crtc->y : vbox_crtc->y_hint;
 
@@ -66,14 +67,13 @@ static void vbox_do_modeset(struct drm_crtc *crtc)
 * VirtualBox, certain parts of the code still assume that the first
 * screen is programmed this way, so try to fake it.
 */
-   if (vbox_crtc->crtc_id == 0 && crtc->enabled &&
+   if (vbox_crtc->crtc_id == 0 && fb &&
vbox_crtc->fb_offset / pitch < 0x - crtc->y &&
vbox_crtc->fb_offset % (bpp / 8) == 0) {
vbox_write_ioport(VBE_DISPI_INDEX_XRES, width);
vbox_write_ioport(VBE_DISPI_INDEX_YRES, height);
vbox_write_ioport(VBE_DISPI_INDEX_VIRT_WIDTH, pitch * 8 / bpp);
-   vbox_write_ioport(VBE_DISPI_INDEX_BPP,
- CRTC_FB(crtc)->format->cpp[0] * 8);
+   vbox_write_ioport(VBE_DISPI_INDEX_BPP, bpp);
vbox_write_ioport(VBE_DISPI_INDEX_ENABLE, VBE_DISPI_ENABLED);
vbox_write_iopor

[PATCH resend 15/15] staging: vboxvideo: Use more drm_fb_helper functions

2018-09-29 Thread Hans de Goede
Store fbhelper and afb struct directly in vbox_private and use
drm_fb_helper_fbdev_setup to replace vbox_fbdev_init, note we cannot use
drm_fb_helper_fbdev_teardown since we use a private framebuffer for the
fbdev.

And replace vbox_driver_lastclose with drm_fb_helper_lastclose.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_drv.c  | 10 +++-
 drivers/staging/vboxvideo/vbox_drv.h  | 28 +++
 drivers/staging/vboxvideo/vbox_fb.c   | 70 ++-
 drivers/staging/vboxvideo/vbox_main.c | 12 -
 drivers/staging/vboxvideo/vbox_mode.c |  2 +-
 5 files changed, 31 insertions(+), 91 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_drv.c 
b/drivers/staging/vboxvideo/vbox_drv.c
index c3e14107da0d..257030460fb6 100644
--- a/drivers/staging/vboxvideo/vbox_drv.c
+++ b/drivers/staging/vboxvideo/vbox_drv.c
@@ -49,6 +49,10 @@ static const struct pci_device_id pciidlist[] = {
 };
 MODULE_DEVICE_TABLE(pci, pciidlist);
 
+static struct drm_fb_helper_funcs vbox_fb_helper_funcs = {
+   .fb_probe = vboxfb_create,
+};
+
 static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id 
*ent)
 {
struct vbox_private *vbox;
@@ -92,7 +96,9 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
if (ret)
goto err_mode_fini;
 
-   ret = vbox_fbdev_init(vbox);
+   ret = drm_fb_helper_fbdev_setup(&vbox->ddev, &vbox->fb_helper,
+   &vbox_fb_helper_funcs, 32,
+   vbox->num_crtcs);
if (ret)
goto err_irq_fini;
 
@@ -257,7 +263,7 @@ static struct drm_driver driver = {
DRIVER_PRIME | DRIVER_ATOMIC,
.dev_priv_size = 0,
 
-   .lastclose = vbox_driver_lastclose,
+   .lastclose = drm_fb_helper_lastclose,
.master_set = vbox_master_set,
.master_drop = vbox_master_drop,
 
diff --git a/drivers/staging/vboxvideo/vbox_drv.h 
b/drivers/staging/vboxvideo/vbox_drv.h
index 9cc20c182df1..73395a7536c5 100644
--- a/drivers/staging/vboxvideo/vbox_drv.h
+++ b/drivers/staging/vboxvideo/vbox_drv.h
@@ -72,11 +72,16 @@
sizeof(struct hgsmi_host_flags))
 #define HOST_FLAGS_OFFSET GUEST_HEAP_USABLE_SIZE
 
-struct vbox_fbdev;
+struct vbox_framebuffer {
+   struct drm_framebuffer base;
+   struct drm_gem_object *obj;
+};
 
 struct vbox_private {
/* Must be first; or we must define our own release callback */
struct drm_device ddev;
+   struct drm_fb_helper fb_helper;
+   struct vbox_framebuffer afb;
 
u8 __iomem *guest_heap;
u8 __iomem *vbva_buffers;
@@ -91,8 +96,6 @@ struct vbox_private {
/** Array of structures for receiving mode hints. */
struct vbva_modehint *last_mode_hints;
 
-   struct vbox_fbdev *fbdev;
-
int fb_mtrr;
 
struct {
@@ -122,8 +125,6 @@ struct vbox_private {
 #undef CURSOR_PIXEL_COUNT
 #undef CURSOR_DATA_SIZE
 
-void vbox_driver_lastclose(struct drm_device *dev);
-
 struct vbox_gem_object;
 
 struct vbox_connector {
@@ -171,20 +172,6 @@ struct vbox_encoder {
struct drm_encoder base;
 };
 
-struct vbox_framebuffer {
-   struct drm_framebuffer base;
-   struct drm_gem_object *obj;
-};
-
-struct vbox_fbdev {
-   struct drm_fb_helper helper;
-   struct vbox_framebuffer afb;
-   int size;
-   struct ttm_bo_kmap_obj mapping;
-   int x1, y1, x2, y2; /* dirty rect */
-   spinlock_t dirty_lock;
-};
-
 #define to_vbox_crtc(x) container_of(x, struct vbox_crtc, base)
 #define to_vbox_connector(x) container_of(x, struct vbox_connector, base)
 #define to_vbox_encoder(x) container_of(x, struct vbox_encoder, base)
@@ -212,7 +199,8 @@ int vbox_framebuffer_init(struct vbox_private *vbox,
  const struct DRM_MODE_FB_CMD *mode_cmd,
  struct drm_gem_object *obj);
 
-int vbox_fbdev_init(struct vbox_private *vbox);
+int vboxfb_create(struct drm_fb_helper *helper,
+ struct drm_fb_helper_surface_size *sizes);
 void vbox_fbdev_fini(struct vbox_private *vbox);
 
 struct vbox_bo {
diff --git a/drivers/staging/vboxvideo/vbox_fb.c 
b/drivers/staging/vboxvideo/vbox_fb.c
index 8a9d56762659..ee25f3a03934 100644
--- a/drivers/staging/vboxvideo/vbox_fb.c
+++ b/drivers/staging/vboxvideo/vbox_fb.c
@@ -66,13 +66,11 @@ static struct fb_ops vboxfb_ops = {
.fb_debug_leave = drm_fb_helper_debug_leave,
 };
 
-static int vboxfb_create(struct drm_fb_helper *helper,
-struct drm_fb_helper_surface_size *sizes)
+int vboxfb_create(struct drm_fb_helper *helper,
+ struct drm_fb_helper_surface_size *sizes)
 {
-   struct vbox_fbdev *fbdev =
-   container_of(helper, struct vbox_fbdev, helper);
-   struct vbox_private *vbox = container_of(fbdev->helper.dev,
-struct vbox_private, ddev);
+   struct vbo

[PATCH resend 04/15] staging: vboxvideo: Cache mode width, height and crtc panning in vbox_crtc

2018-09-29 Thread Hans de Goede
When setting a mode we not only pass the mode to the hypervisor,
but also information on how to map / translate input coordinates
for the emulated USB tablet.  This input-mapping may change when
the mode on *another* crtc changes.

This means that sometimes we must do a modeset on other crtc-s then
the one being changed to update the input-mapping. Including crtc-s
which may be disabled inside the guest (shown as a black window
on the host unless closed by the user).

With atomic modesetting the mode-info of disabled crtcs gets zeroed
yet we need it when updating the input-map to avoid resizing the
window as a side effect of a mode_set on another crtc.

This commit adds caching of the mode info into out private vbox_crtc
struct so that we always have the info at hand when we need it.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_drv.h  | 20 +++
 drivers/staging/vboxvideo/vbox_mode.c | 28 +++
 2 files changed, 36 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_drv.h 
b/drivers/staging/vboxvideo/vbox_drv.h
index 6c52cbd9e91e..34c4d7fc6c8e 100644
--- a/drivers/staging/vboxvideo/vbox_drv.h
+++ b/drivers/staging/vboxvideo/vbox_drv.h
@@ -151,6 +151,26 @@ struct vbox_crtc {
bool cursor_enabled;
u32 x_hint;
u32 y_hint;
+   /*
+* When setting a mode we not only pass the mode to the hypervisor,
+* but also information on how to map / translate input coordinates
+* for the emulated USB tablet.  This input-mapping may change when
+* the mode on *another* crtc changes.
+*
+* This means that sometimes we must do a modeset on other crtc-s then
+* the one being changed to update the input-mapping. Including crtc-s
+* which may be disabled inside the guest (shown as a black window
+* on the host unless closed by the user).
+*
+* With atomic modesetting the mode-info of disabled crtcs gets zeroed
+* yet we need it when updating the input-map to avoid resizing the
+* window as a side effect of a mode_set on another crtc. Therefor we
+* cache the info of the last mode below.
+*/
+   u32 width;
+   u32 height;
+   u32 x;
+   u32 y;
 };
 
 struct vbox_encoder {
diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index adb6bcf989d1..e85b27f95def 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -48,8 +48,7 @@ static int vbox_cursor_move(struct drm_crtc *crtc, int x, int 
y);
  * Set a graphics mode.  Poke any required values into registers, do an HGSMI
  * mode set and tell the host we support advanced graphics functions.
  */
-static void vbox_do_modeset(struct drm_crtc *crtc,
-   const struct drm_display_mode *mode)
+static void vbox_do_modeset(struct drm_crtc *crtc)
 {
struct vbox_crtc *vbox_crtc = to_vbox_crtc(crtc);
struct vbox_private *vbox;
@@ -58,12 +57,12 @@ static void vbox_do_modeset(struct drm_crtc *crtc,
s32 x_offset, y_offset;
 
vbox = crtc->dev->dev_private;
-   width = mode->hdisplay ? mode->hdisplay : 640;
-   height = mode->vdisplay ? mode->vdisplay : 480;
+   width = vbox_crtc->width ? vbox_crtc->width : 640;
+   height = vbox_crtc->height ? vbox_crtc->height : 480;
bpp = crtc->enabled ? CRTC_FB(crtc)->format->cpp[0] * 8 : 32;
pitch = crtc->enabled ? CRTC_FB(crtc)->pitches[0] : width * bpp / 8;
-   x_offset = vbox->single_framebuffer ? crtc->x : vbox_crtc->x_hint;
-   y_offset = vbox->single_framebuffer ? crtc->y : vbox_crtc->y_hint;
+   x_offset = vbox->single_framebuffer ? vbox_crtc->x : vbox_crtc->x_hint;
+   y_offset = vbox->single_framebuffer ? vbox_crtc->y : vbox_crtc->y_hint;
 
/*
 * This is the old way of setting graphics modes.  It assumed one screen
@@ -82,9 +81,9 @@ static void vbox_do_modeset(struct drm_crtc *crtc,
vbox_write_ioport(VBE_DISPI_INDEX_ENABLE, VBE_DISPI_ENABLED);
vbox_write_ioport(
VBE_DISPI_INDEX_X_OFFSET,
-   vbox_crtc->fb_offset % pitch / bpp * 8 + crtc->x);
+   vbox_crtc->fb_offset % pitch / bpp * 8 + vbox_crtc->x);
vbox_write_ioport(VBE_DISPI_INDEX_Y_OFFSET,
- vbox_crtc->fb_offset / pitch + crtc->y);
+ vbox_crtc->fb_offset / pitch + vbox_crtc->y);
}
 
flags = VBVA_SCREEN_F_ACTIVE;
@@ -93,7 +92,8 @@ static void vbox_do_modeset(struct drm_crtc *crtc,
flags |= vbox_crtc->disconnected ? VBVA_SCREEN_F_DISABLED : 0;
hgsmi_process_display_info(vbox->guest_pool, vbox_crtc->crtc_id,
   x_offset, y_offset,
-  crtc->x * bpp / 8 + crtc->y * pitch,
+ 

[PATCH resend 01/15] staging: vboxvideo: Cleanup vbox_set_up_input_mapping()

2018-09-29 Thread Hans de Goede
This cleanups 2 things:

1) The first time we loop over the crtc-s, to compare framebuffers, fb1 may
get set to NULL by the fb1 = CRTC_FB(crtci); statement and then we call
to_vbox_framebuffer() on it. The result of this call is only used for
an address comparison, so we don't end up dereferencing the bad pointer,
but still it is better to not do this.

2) Since we already figure out the first crtc with a fb in the first loop
and store that in fb1, there is no need to loop over the crtc-s again just
to find the first crtc with a fb again.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_mode.c | 24 
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index bef99664d030..4f5d28aeca95 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -169,7 +169,7 @@ static bool vbox_set_up_input_mapping(struct vbox_private 
*vbox)
 {
struct drm_crtc *crtci;
struct drm_connector *connectori;
-   struct drm_framebuffer *fb1 = NULL;
+   struct drm_framebuffer *fb, *fb1 = NULL;
bool single_framebuffer = true;
bool old_single_framebuffer = vbox->single_framebuffer;
u16 width = 0, height = 0;
@@ -180,25 +180,25 @@ static bool vbox_set_up_input_mapping(struct vbox_private 
*vbox)
 * Same fall-back if this is the fbdev frame-buffer.
 */
list_for_each_entry(crtci, &vbox->ddev.mode_config.crtc_list, head) {
+   fb = CRTC_FB(crtci);
+   if (!fb)
+   continue;
+
if (!fb1) {
-   fb1 = CRTC_FB(crtci);
+   fb1 = fb;
if (to_vbox_framebuffer(fb1) == &vbox->fbdev->afb)
break;
-   } else if (CRTC_FB(crtci) && fb1 != CRTC_FB(crtci)) {
+   } else if (fb != fb1) {
single_framebuffer = false;
}
}
+   if (!fb1)
+   return false;
+
if (single_framebuffer) {
vbox->single_framebuffer = true;
-   list_for_each_entry(crtci, &vbox->ddev.mode_config.crtc_list,
-   head) {
-   if (!CRTC_FB(crtci))
-   continue;
-
-   vbox->input_mapping_width = CRTC_FB(crtci)->width;
-   vbox->input_mapping_height = CRTC_FB(crtci)->height;
-   break;
-   }
+   vbox->input_mapping_width = fb1->width;
+   vbox->input_mapping_height = fb1->height;
return old_single_framebuffer != vbox->single_framebuffer;
}
/* Otherwise calculate the total span of all screens. */
-- 
2.19.0

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


[PATCH resend 12/15] staging: vboxvideo: Replace crtc_helper enable/disable functions

2018-09-29 Thread Hans de Goede
Replace vbox_crtc_commit and vbox_crtc_disable with
vbox_crtc_atomic_[en|dis]able which are the preferred callbacks for
these for atomic drivers.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_mode.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index 49ff9c4a6302..72fc6614179a 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -229,11 +229,13 @@ static void vbox_crtc_set_base_and_mode(struct drm_crtc 
*crtc,
mutex_unlock(&vbox->hw_mutex);
 }
 
-static void vbox_crtc_disable(struct drm_crtc *crtc)
+static void vbox_crtc_atomic_enable(struct drm_crtc *crtc,
+   struct drm_crtc_state *old_crtc_state)
 {
 }
 
-static void vbox_crtc_commit(struct drm_crtc *crtc)
+static void vbox_crtc_atomic_disable(struct drm_crtc *crtc,
+struct drm_crtc_state *old_crtc_state)
 {
 }
 
@@ -254,8 +256,8 @@ static void vbox_crtc_atomic_flush(struct drm_crtc *crtc,
 }
 
 static const struct drm_crtc_helper_funcs vbox_crtc_helper_funcs = {
-   .disable = vbox_crtc_disable,
-   .commit = vbox_crtc_commit,
+   .atomic_enable = vbox_crtc_atomic_enable,
+   .atomic_disable = vbox_crtc_atomic_disable,
.atomic_flush = vbox_crtc_atomic_flush,
 };
 
-- 
2.19.0

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


[PATCH resend 02/15] staging: vboxvideo: Remove empty encoder_helper_funcs

2018-09-29 Thread Hans de Goede
All the encoder_helper_funcs are optional, and even setting the
drm_encoder_helper_funcs vtable itself is optional and may be left out
when not using any of the helper funcs, so lets drop all of this.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_mode.c | 34 ---
 1 file changed, 34 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index 4f5d28aeca95..babb02a1ebf2 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -466,39 +466,6 @@ static const struct drm_encoder_funcs vbox_enc_funcs = {
.destroy = vbox_encoder_destroy,
 };
 
-static void vbox_encoder_dpms(struct drm_encoder *encoder, int mode)
-{
-}
-
-static bool vbox_mode_fixup(struct drm_encoder *encoder,
-   const struct drm_display_mode *mode,
-   struct drm_display_mode *adjusted_mode)
-{
-   return true;
-}
-
-static void vbox_encoder_mode_set(struct drm_encoder *encoder,
- struct drm_display_mode *mode,
- struct drm_display_mode *adjusted_mode)
-{
-}
-
-static void vbox_encoder_prepare(struct drm_encoder *encoder)
-{
-}
-
-static void vbox_encoder_commit(struct drm_encoder *encoder)
-{
-}
-
-static const struct drm_encoder_helper_funcs vbox_enc_helper_funcs = {
-   .dpms = vbox_encoder_dpms,
-   .mode_fixup = vbox_mode_fixup,
-   .prepare = vbox_encoder_prepare,
-   .commit = vbox_encoder_commit,
-   .mode_set = vbox_encoder_mode_set,
-};
-
 static struct drm_encoder *vbox_encoder_init(struct drm_device *dev,
 unsigned int i)
 {
@@ -510,7 +477,6 @@ static struct drm_encoder *vbox_encoder_init(struct 
drm_device *dev,
 
drm_encoder_init(dev, &vbox_encoder->base, &vbox_enc_funcs,
 DRM_MODE_ENCODER_DAC, NULL);
-   drm_encoder_helper_add(&vbox_encoder->base, &vbox_enc_helper_funcs);
 
vbox_encoder->base.possible_crtcs = 1 << i;
return &vbox_encoder->base;
-- 
2.19.0

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


[PATCH resend 09/15] staging: vboxvideo: Atomic phase 3: Switch last bits over to atomic

2018-09-29 Thread Hans de Goede
Now that the state objects are wired up, we can:

1) Move to the final atomic handlers
2) Wire up atomic set_config helper
3) Switch to drm_mode_config_helper_suspend/resume for suspend/resume
4) Enable atomic modesetting ioctl

This is all done in one commit because doing this piecemeal leads to
an intermediate state which triggers WARN_ONs in the atomic code because
e.g. plane->fb is still being set.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/TODO|  1 -
 drivers/staging/vboxvideo/vbox_drv.c  | 40 +--
 drivers/staging/vboxvideo/vbox_mode.c | 35 +++
 3 files changed, 17 insertions(+), 59 deletions(-)

diff --git a/drivers/staging/vboxvideo/TODO b/drivers/staging/vboxvideo/TODO
index 468eea856ca6..2e0f99c3f10c 100644
--- a/drivers/staging/vboxvideo/TODO
+++ b/drivers/staging/vboxvideo/TODO
@@ -1,5 +1,4 @@
 TODO:
--Move the driver over to the atomic API
 -Get a full review from the drm-maintainers on dri-devel done on this driver
 -Extend this TODO with the results of that review
 
diff --git a/drivers/staging/vboxvideo/vbox_drv.c 
b/drivers/staging/vboxvideo/vbox_drv.c
index c6a53b0ad66c..c3e14107da0d 100644
--- a/drivers/staging/vboxvideo/vbox_drv.c
+++ b/drivers/staging/vboxvideo/vbox_drv.c
@@ -132,35 +132,16 @@ static void vbox_pci_remove(struct pci_dev *pdev)
drm_dev_put(&vbox->ddev);
 }
 
-static int vbox_drm_freeze(struct vbox_private *vbox)
-{
-   drm_kms_helper_poll_disable(&vbox->ddev);
-
-   pci_save_state(vbox->ddev.pdev);
-
-   drm_fb_helper_set_suspend_unlocked(&vbox->fbdev->helper, true);
-
-   return 0;
-}
-
-static int vbox_drm_thaw(struct vbox_private *vbox)
-{
-   drm_mode_config_reset(&vbox->ddev);
-   drm_helper_resume_force_mode(&vbox->ddev);
-   drm_fb_helper_set_suspend_unlocked(&vbox->fbdev->helper, false);
-
-   return 0;
-}
-
 static int vbox_pm_suspend(struct device *dev)
 {
struct vbox_private *vbox = dev_get_drvdata(dev);
int error;
 
-   error = vbox_drm_freeze(vbox);
+   error = drm_mode_config_helper_suspend(&vbox->ddev);
if (error)
return error;
 
+   pci_save_state(vbox->ddev.pdev);
pci_disable_device(vbox->ddev.pdev);
pci_set_power_state(vbox->ddev.pdev, PCI_D3hot);
 
@@ -170,39 +151,32 @@ static int vbox_pm_suspend(struct device *dev)
 static int vbox_pm_resume(struct device *dev)
 {
struct vbox_private *vbox = dev_get_drvdata(dev);
-   int ret;
 
if (pci_enable_device(vbox->ddev.pdev))
return -EIO;
 
-   ret = vbox_drm_thaw(vbox);
-   if (ret)
-   return ret;
-
-   drm_kms_helper_poll_enable(&vbox->ddev);
-
-   return 0;
+   return drm_mode_config_helper_resume(&vbox->ddev);
 }
 
 static int vbox_pm_freeze(struct device *dev)
 {
struct vbox_private *vbox = dev_get_drvdata(dev);
 
-   return vbox_drm_freeze(vbox);
+   return drm_mode_config_helper_suspend(&vbox->ddev);
 }
 
 static int vbox_pm_thaw(struct device *dev)
 {
struct vbox_private *vbox = dev_get_drvdata(dev);
 
-   return vbox_drm_thaw(vbox);
+   return drm_mode_config_helper_resume(&vbox->ddev);
 }
 
 static int vbox_pm_poweroff(struct device *dev)
 {
struct vbox_private *vbox = dev_get_drvdata(dev);
 
-   return vbox_drm_freeze(vbox);
+   return drm_mode_config_helper_suspend(&vbox->ddev);
 }
 
 static const struct dev_pm_ops vbox_pm_ops = {
@@ -280,7 +254,7 @@ static void vbox_master_drop(struct drm_device *dev, struct 
drm_file *file_priv)
 static struct drm_driver driver = {
.driver_features =
DRIVER_MODESET | DRIVER_GEM | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED |
-   DRIVER_PRIME,
+   DRIVER_PRIME | DRIVER_ATOMIC,
.dev_priv_size = 0,
 
.lastclose = vbox_driver_lastclose,
diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index 54e6aac784f7..69a1e6c163b9 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -148,13 +148,6 @@ static void vbox_crtc_dpms(struct drm_crtc *crtc, int mode)
mutex_unlock(&vbox->hw_mutex);
 }
 
-static bool vbox_crtc_mode_fixup(struct drm_crtc *crtc,
-const struct drm_display_mode *mode,
-struct drm_display_mode *adjusted_mode)
-{
-   return true;
-}
-
 /*
  * Try to map the layout of virtual screens to the range of the input device.
  * Return true if we need to re-set the crtc modes due to screen offset
@@ -260,19 +253,10 @@ static void vbox_crtc_disable(struct drm_crtc *crtc)
 {
 }
 
-static void vbox_crtc_prepare(struct drm_crtc *crtc)
-{
-}
-
 static void vbox_crtc_commit(struct drm_crtc *crtc)
 {
 }
 
-static void vbox_crtc_mode_set_nofb(struct drm_crtc *crtc)
-{
-   /* We always set the mode when we set the fb/base */
-}
-
 static void vbox_crtc_atomic_flush(struct drm_crtc *c

[PATCH resend 05/15] staging: vboxvideo: Atomic phase 1: convert cursor to universal plane

2018-09-29 Thread Hans de Goede
In preparation for atomic conversion, let's use the transitional atomic
helpers drm_plane_helper_update/disable.

Signed-off-by: Hans de Goede 
---
 drivers/staging/vboxvideo/vbox_drv.h  |   5 -
 drivers/staging/vboxvideo/vbox_mode.c | 386 +-
 2 files changed, 186 insertions(+), 205 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_drv.h 
b/drivers/staging/vboxvideo/vbox_drv.h
index 34c4d7fc6c8e..7fc668ff4465 100644
--- a/drivers/staging/vboxvideo/vbox_drv.h
+++ b/drivers/staging/vboxvideo/vbox_drv.h
@@ -116,11 +116,6 @@ struct vbox_private {
 * encompassing all screen ones or is the fbdev console active?
 */
bool single_framebuffer;
-   u32 cursor_width;
-   u32 cursor_height;
-   u32 cursor_hot_x;
-   u32 cursor_hot_y;
-   size_t cursor_data_size;
u8 cursor_data[CURSOR_DATA_SIZE];
 };
 
diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index e85b27f95def..75e112d33cf0 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -34,16 +34,12 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "vbox_drv.h"
 #include "vboxvideo.h"
 #include "hgsmi_channels.h"
 
-static int vbox_cursor_set2(struct drm_crtc *crtc, struct drm_file *file_priv,
-   u32 handle, u32 width, u32 height,
-   s32 hot_x, s32 hot_y);
-static int vbox_cursor_move(struct drm_crtc *crtc, int x, int y);
-
 /**
  * Set a graphics mode.  Poke any required values into registers, do an HGSMI
  * mode set and tell the host we support advanced graphics functions.
@@ -318,14 +314,166 @@ static void vbox_crtc_destroy(struct drm_crtc *crtc)
 }
 
 static const struct drm_crtc_funcs vbox_crtc_funcs = {
-   .cursor_move = vbox_cursor_move,
-   .cursor_set2 = vbox_cursor_set2,
.reset = vbox_crtc_reset,
.set_config = drm_crtc_helper_set_config,
/* .gamma_set = vbox_crtc_gamma_set, */
.destroy = vbox_crtc_destroy,
 };
 
+static int vbox_cursor_atomic_check(struct drm_plane *plane,
+   struct drm_plane_state *new_state)
+{
+   u32 width = new_state->crtc_w;
+   u32 height = new_state->crtc_h;
+
+   if (!new_state->fb)
+   return 0;
+
+   if (width > VBOX_MAX_CURSOR_WIDTH || height > VBOX_MAX_CURSOR_HEIGHT ||
+   width == 0 || height == 0)
+   return -EINVAL;
+
+   return 0;
+}
+
+/**
+ * Copy the ARGB image and generate the mask, which is needed in case the host
+ * does not support ARGB cursors.  The mask is a 1BPP bitmap with the bit set
+ * if the corresponding alpha value in the ARGB image is greater than 0xF0.
+ */
+static void copy_cursor_image(u8 *src, u8 *dst, u32 width, u32 height,
+ size_t mask_size)
+{
+   size_t line_size = (width + 7) / 8;
+   u32 i, j;
+
+   memcpy(dst + mask_size, src, width * height * 4);
+   for (i = 0; i < height; ++i)
+   for (j = 0; j < width; ++j)
+   if (((u32 *)src)[i * width + j] > 0xf000)
+   dst[i * line_size + j / 8] |= (0x80 >> (j % 8));
+}
+
+static void vbox_cursor_atomic_update(struct drm_plane *plane,
+ struct drm_plane_state *old_state)
+{
+   struct vbox_private *vbox =
+   container_of(plane->dev, struct vbox_private, ddev);
+   struct vbox_crtc *vbox_crtc = to_vbox_crtc(plane->state->crtc);
+   struct drm_framebuffer *fb = plane->state->fb;
+   struct vbox_bo *bo = gem_to_vbox_bo(to_vbox_framebuffer(fb)->obj);
+   u32 width = plane->state->crtc_w;
+   u32 height = plane->state->crtc_h;
+   size_t data_size, mask_size;
+   u32 flags;
+   u8 *src;
+
+   /*
+* VirtualBox uses the host windowing system to draw the cursor so
+* moves are a no-op, we only need to upload new cursor sprites.
+*/
+   if (fb == old_state->fb)
+   return;
+
+   mutex_lock(&vbox->hw_mutex);
+
+   vbox_crtc->cursor_enabled = true;
+
+   /* pinning is done in prepare/cleanup framebuffer */
+   src = vbox_bo_kmap(bo);
+   if (IS_ERR(src)) {
+   DRM_WARN("Could not kmap cursor bo, skipping update\n");
+   return;
+   }
+
+   /*
+* The mask must be calculated based on the alpha
+* channel, one bit per ARGB word, and must be 32-bit
+* padded.
+*/
+   mask_size = ((width + 7) / 8 * height + 3) & ~3;
+   data_size = width * height * 4 + mask_size;
+
+   copy_cursor_image(src, vbox->cursor_data, width, height, mask_size);
+   vbox_bo_kunmap(bo);
+
+   flags = VBOX_MOUSE_POINTER_VISIBLE | VBOX_MOUSE_POINTER_SHAPE |
+   VBOX_MOUSE_POINTER_ALPHA;
+   hgsmi_update_pointer_shape(vbox->guest_pool, flags,
+  min_t(u32, max(fb->hot_

Re: [PATCH 01/15] staging: vboxvideo: Cleanup vbox_set_up_input_mapping()

2018-09-29 Thread Hans de Goede

Hi,

On 28-09-18 14:38, Greg Kroah-Hartman wrote:

On Wed, Sep 26, 2018 at 09:41:52PM +0200, Hans de Goede wrote:

This cleanups 2 things:

1) The first time we loop over the crtc-s, to compare framebuffers, fb1 may
get set to NULL by the fb1 = CRTC_FB(crtci); statement and then we call
to_vbox_framebuffer() on it. The result of this call is only used for
an address comparison, so we don't end up dereferencing the bad pointer,
but still it is better to not do this.

2) Since we already figure out the first crtc with a fb in the first loop
and store that in fb1, there is no need to loop over the crtc-s again just
to find the first crtc with a fb again.

Signed-off-by: Hans de Goede 


I have two patch 1/15 in this series, making it 16 patches?


It seems like I've accidentally numbered my cover-letter
as 01/15 instead of 00/15. Could that it be that that was the problem?


Something went odd on your end, can you please resend these properly?


Done.

Regards,

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


Re: [PATCH 01/15] staging: vboxvideo: Cleanup vbox_set_up_input_mapping()

2018-09-29 Thread Greg Kroah-Hartman
On Sat, Sep 29, 2018 at 02:23:37PM +0200, Hans de Goede wrote:
> Hi,
> 
> On 28-09-18 14:38, Greg Kroah-Hartman wrote:
> > On Wed, Sep 26, 2018 at 09:41:52PM +0200, Hans de Goede wrote:
> > > This cleanups 2 things:
> > > 
> > > 1) The first time we loop over the crtc-s, to compare framebuffers, fb1 
> > > may
> > > get set to NULL by the fb1 = CRTC_FB(crtci); statement and then we call
> > > to_vbox_framebuffer() on it. The result of this call is only used for
> > > an address comparison, so we don't end up dereferencing the bad pointer,
> > > but still it is better to not do this.
> > > 
> > > 2) Since we already figure out the first crtc with a fb in the first loop
> > > and store that in fb1, there is no need to loop over the crtc-s again just
> > > to find the first crtc with a fb again.
> > > 
> > > Signed-off-by: Hans de Goede 
> > 
> > I have two patch 1/15 in this series, making it 16 patches?
> 
> It seems like I've accidentally numbered my cover-letter
> as 01/15 instead of 00/15. Could that it be that that was the problem?

Maybe, I didn't look too hard at it :)

> > Something went odd on your end, can you please resend these properly?
> 
> Done.

Now applied, thanks!

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


Re: [PATCH v3] staging: mt7621-mmc: Remove #if 0 blocks and fix macros in sd.c

2018-09-29 Thread Nishad Kamdar
On Fri, Sep 28, 2018 at 02:30:25PM +0200, Greg Kroah-Hartman wrote:
> On Thu, Sep 27, 2018 at 09:10:57PM +0530, Nishad Kamdar wrote:
> > This patch removes #if 0 code blocks and usages of the
> > functions defined in the #if 0 code block. It removes
> > the macro msdc_irq_restore() and replaces its usage
> > with call to the function called in the macro definition.
> > Issue found by checkpatch.
> 
> When you have to start listing all of the different things your patch
> does, that's a huge hint it needs to be broken up into smaller pieces.
> 
> Please make this a patch series, only doing on "logical" change at a
> time.  You are doing too many different things here all at once.
> 
> thanks
> 
> greg k-h

Ok I'll do that.

thanks for the review.

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


[PATCH 1/4] Staging: rts5208: rtsx_card.c: Fixed all braces issues of the file

2018-09-29 Thread Maxime Desroches
Fixed all the braces issues of the rtsx_card.c file

Signed-off-by: Maxime Desroches 
---
 drivers/staging/rts5208/rtsx_card.c | 96 +++--
 1 file changed, 37 insertions(+), 59 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx_card.c 
b/drivers/staging/rts5208/rtsx_card.c
index d26a8e372fce..b45abbe29bc2 100644
--- a/drivers/staging/rts5208/rtsx_card.c
+++ b/drivers/staging/rts5208/rtsx_card.c
@@ -647,9 +647,8 @@ int switch_ssc_clock(struct rtsx_chip *chip, int clk)
dev_dbg(rtsx_dev(chip), "Switch SSC clock to %dMHz (cur_clk = %d)\n",
clk, chip->cur_clk);
 
-   if ((clk <= 2) || (n > max_n)) {
+   if ((clk <= 2) || (n > max_n))
return STATUS_FAIL;
-   }
 
mcu_cnt = (u8)(125 / clk + 3);
if (mcu_cnt > 7)
@@ -688,15 +687,13 @@ int switch_ssc_clock(struct rtsx_chip *chip, int clk)
}
 
retval = rtsx_send_cmd(chip, 0, WAIT_TIME);
-   if (retval < 0) {
+   if (retval < 0)
return STATUS_ERROR;
-   }
 
udelay(10);
retval = rtsx_write_register(chip, CLK_CTL, CLK_LOW_FREQ, 0);
-   if (retval) {
+   if (retval)
return retval;
-   }
 
chip->cur_clk = clk;
 
@@ -790,49 +787,44 @@ int switch_normal_clock(struct rtsx_chip *chip, int clk)
}
 
retval = rtsx_write_register(chip, CLK_CTL, 0xFF, CLK_LOW_FREQ);
-   if (retval) {
+   if (retval)
return retval;
-   }
if (sd_vpclk_phase_reset) {
retval = rtsx_write_register(chip, SD_VPCLK0_CTL,
 PHASE_NOT_RESET, 0);
-   if (retval) {
+   if (retval)
return retval;
-   }
+
retval = rtsx_write_register(chip, SD_VPCLK1_CTL,
 PHASE_NOT_RESET, 0);
-   if (retval) {
+   if (retval)
return retval;
-   }
}
retval = rtsx_write_register(chip, CLK_DIV, 0xFF,
 (div << 4) | mcu_cnt);
-   if (retval) {
+   if (retval)
return retval;
-   }
retval = rtsx_write_register(chip, CLK_SEL, 0xFF, sel);
-   if (retval) {
+   if (retval)
return retval;
-   }
 
if (sd_vpclk_phase_reset) {
udelay(200);
retval = rtsx_write_register(chip, SD_VPCLK0_CTL,
 PHASE_NOT_RESET, PHASE_NOT_RESET);
-   if (retval) {
+   if (retval)
return retval;
-   }
+
retval = rtsx_write_register(chip, SD_VPCLK1_CTL,
 PHASE_NOT_RESET, PHASE_NOT_RESET);
-   if (retval) {
+   if (retval)
return retval;
-   }
+
udelay(200);
}
retval = rtsx_write_register(chip, CLK_CTL, 0xFF, 0);
-   if (retval) {
+   if (retval)
return retval;
-   }
 
chip->cur_clk = clk;
 
@@ -878,9 +870,8 @@ int enable_card_clock(struct rtsx_chip *chip, u8 card)
clk_en |= MS_CLK_EN;
 
retval = rtsx_write_register(chip, CARD_CLK_EN, clk_en, clk_en);
-   if (retval) {
+   if (retval)
return retval;
-   }
 
return STATUS_SUCCESS;
 }
@@ -898,9 +889,8 @@ int disable_card_clock(struct rtsx_chip *chip, u8 card)
clk_en |= MS_CLK_EN;
 
retval = rtsx_write_register(chip, CARD_CLK_EN, clk_en, 0);
-   if (retval) {
+   if (retval)
return retval;
-   }
 
return STATUS_SUCCESS;
 }
@@ -924,9 +914,8 @@ int card_power_on(struct rtsx_chip *chip, u8 card)
rtsx_add_cmd(chip, WRITE_REG_CMD, CARD_PWR_CTL, mask, val1);
 
retval = rtsx_send_cmd(chip, 0, 100);
-   if (retval != STATUS_SUCCESS) {
+   if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
-   }
 
udelay(chip->pmos_pwr_on_interval);
 
@@ -934,9 +923,8 @@ int card_power_on(struct rtsx_chip *chip, u8 card)
rtsx_add_cmd(chip, WRITE_REG_CMD, CARD_PWR_CTL, mask, val2);
 
retval = rtsx_send_cmd(chip, 0, 100);
-   if (retval != STATUS_SUCCESS) {
+   if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
-   }
 
return STATUS_SUCCESS;
 }
@@ -955,9 +943,8 @@ int card_power_off(struct rtsx_chip *chip, u8 card)
}
 
retval = rtsx_write_register(chip, CARD_PWR_CTL, mask, val);
-   if (retval) {
+   if (retval)
return retval;
-   }
 
return STATUS_SUCCESS;
 }
@@ -969,9 +956,8 @@ int card_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip,
unsigned int lun = SCSI_LUN(srb);
int i;
 
-   if (!chip->rw_card[lun]) {
+   if (!chip->rw_card[lun])

[PATCH 2/4] Staging: rts5208: rtsx_chip.c: Fixed all braces issues of the file

2018-09-29 Thread Maxime Desroches
Fixed all the braces issues of the rtsx_chip.c file

Signed-off-by: Maxime Desroches 
---
 drivers/staging/rts5208/rtsx_chip.c | 463 
 1 file changed, 199 insertions(+), 264 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx_chip.c 
b/drivers/staging/rts5208/rtsx_chip.c
index 6b1234bff09c..6bec2ddc75f2 100644
--- a/drivers/staging/rts5208/rtsx_chip.c
+++ b/drivers/staging/rts5208/rtsx_chip.c
@@ -116,34 +116,31 @@ static int rtsx_pre_handle_sdio_old(struct rtsx_chip 
*chip)
 0xFF,
 MS_INS_PU | SD_WP_PU |
 SD_CD_PU | SD_CMD_PU);
-   if (retval) {
+   if (retval)
return retval;
-   }
+
} else {
retval = rtsx_write_register(chip, FPGA_PULL_CTL,
 0xFF,
 FPGA_SD_PULL_CTL_EN);
-   if (retval) {
+   if (retval)
return retval;
-   }
+
}
retval = rtsx_write_register(chip, CARD_SHARE_MODE, 0xFF,
 CARD_SHARE_48_SD);
-   if (retval) {
+   if (retval)
return retval;
-   }
 
/* Enable SDIO internal clock */
retval = rtsx_write_register(chip, 0xFF2C, 0x01, 0x01);
-   if (retval) {
+   if (retval)
return retval;
-   }
 
retval = rtsx_write_register(chip, SDIO_CTRL, 0xFF,
 SDIO_BUS_CTRL | SDIO_CD_CTRL);
-   if (retval) {
+   if (retval)
return retval;
-   }
 
chip->sd_int = 1;
chip->sd_io = 1;
@@ -164,16 +161,16 @@ static int rtsx_pre_handle_sdio_new(struct rtsx_chip 
*chip)
if (chip->driver_first_load) {
if (CHECK_PID(chip, 0x5288)) {
retval = rtsx_read_register(chip, 0xFE5A, &tmp);
-   if (retval) {
+   if (retval)
return retval;
-   }
+
if (tmp & 0x08)
sw_bypass_sd = true;
} else if (CHECK_PID(chip, 0x5208)) {
retval = rtsx_read_register(chip, 0xFE70, &tmp);
-   if (retval) {
+   if (retval)
return retval;
-   }
+
if (tmp & 0x80)
sw_bypass_sd = true;
}
@@ -192,9 +189,9 @@ static int rtsx_pre_handle_sdio_new(struct rtsx_chip *chip)
u8 cd_toggle_mask = 0;
 
retval = rtsx_read_register(chip, TLPTISTAT, &tmp);
-   if (retval) {
+   if (retval)
return retval;
-   }
+
cd_toggle_mask = 0x08;
 
if (tmp & cd_toggle_mask) {
@@ -202,22 +199,20 @@ static int rtsx_pre_handle_sdio_new(struct rtsx_chip 
*chip)
if (CHECK_PID(chip, 0x5288)) {
retval = rtsx_write_register(chip, 0xFE5A,
 0x08, 0x00);
-   if (retval) {
+   if (retval)
return retval;
-   }
+
} else if (CHECK_PID(chip, 0x5208)) {
retval = rtsx_write_register(chip, 0xFE70,
 0x80, 0x00);
-   if (retval) {
+   if (retval)
return retval;
-   }
}
 
retval = rtsx_write_register(chip, TLPTISTAT, 0xFF,
 tmp);
-   if (retval) {
+   if (retval)
return retval;
-   }
 
chip->need_reset |= SD_CARD;
} else {
@@ -225,36 +220,35 @@ static int rtsx_pre_handle_sdio_new(struct rtsx_chip 
*chip)
 
if (chip->asic_code) {
retval = sd_pull_ctl_enable(chip);
-   if (retval != STATUS_SUCCESS) {
+   if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
-   

[PATCH 3/4] Staging: rts5208: rtsx_scsi.c: Fixed all braces issues of the file

2018-09-29 Thread Maxime Desroches
Fixed all the braces issues of the rtsx_scsi.c file

Signed-off-by: Maxime Desroches 
---
 drivers/staging/rts5208/rtsx_scsi.c | 108 ++--
 1 file changed, 36 insertions(+), 72 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx_scsi.c 
b/drivers/staging/rts5208/rtsx_scsi.c
index c9a6d97938f6..9c594a778425 100644
--- a/drivers/staging/rts5208/rtsx_scsi.c
+++ b/drivers/staging/rts5208/rtsx_scsi.c
@@ -507,9 +507,8 @@ static int inquiry(struct scsi_cmnd *srb, struct rtsx_chip 
*chip)
}
 
buf = vmalloc(scsi_bufflen(srb));
-   if (!buf) {
+   if (!buf)
return TRANSPORT_ERROR;
-   }
 
 #ifdef SUPPORT_MAGIC_GATE
if ((chip->mspro_formatter_enable) &&
@@ -637,9 +636,8 @@ static int request_sense(struct scsi_cmnd *srb, struct 
rtsx_chip *chip)
}
 
buf = vmalloc(scsi_bufflen(srb));
-   if (!buf) {
+   if (!buf)
return TRANSPORT_ERROR;
-   }
 
tmp = (unsigned char *)sense;
memcpy(buf, tmp, scsi_bufflen(srb));
@@ -783,9 +781,8 @@ static int mode_sense(struct scsi_cmnd *srb, struct 
rtsx_chip *chip)
 #endif
 
buf = kmalloc(data_size, GFP_KERNEL);
-   if (!buf) {
+   if (!buf)
return TRANSPORT_ERROR;
-   }
 
page_code = srb->cmnd[2] & 0x3f;
 
@@ -999,9 +996,8 @@ static int read_format_capacity(struct scsi_cmnd *srb, 
struct rtsx_chip *chip)
buf_len = (scsi_bufflen(srb) > 12) ? 0x14 : 12;
 
buf = kmalloc(buf_len, GFP_KERNEL);
-   if (!buf) {
+   if (!buf)
return TRANSPORT_ERROR;
-   }
 
buf[i++] = 0;
buf[i++] = 0;
@@ -1076,9 +1072,8 @@ static int read_capacity(struct scsi_cmnd *srb, struct 
rtsx_chip *chip)
}
 
buf = kmalloc(8, GFP_KERNEL);
-   if (!buf) {
+   if (!buf)
return TRANSPORT_ERROR;
-   }
 
card_size = get_card_size(chip, lun);
buf[0] = (unsigned char)((card_size - 1) >> 24);
@@ -1116,9 +,8 @@ static int read_eeprom(struct scsi_cmnd *srb, struct 
rtsx_chip *chip)
len = ((u16)srb->cmnd[4] << 8) | srb->cmnd[5];
 
buf = vmalloc(len);
-   if (!buf) {
+   if (!buf)
return TRANSPORT_ERROR;
-   }
 
retval = rtsx_force_power_on(chip, SSC_PDCTL);
if (retval != STATUS_SUCCESS) {
@@ -1180,9 +1174,8 @@ static int write_eeprom(struct scsi_cmnd *srb, struct 
rtsx_chip *chip)
len = (unsigned short)min_t(unsigned int, scsi_bufflen(srb),
len);
buf = vmalloc(len);
-   if (!buf) {
+   if (!buf)
return TRANSPORT_ERROR;
-   }
 
rtsx_stor_get_xfer_buf(buf, len, srb);
scsi_set_resid(srb, scsi_bufflen(srb) - len);
@@ -1227,9 +1220,8 @@ static int read_mem(struct scsi_cmnd *srb, struct 
rtsx_chip *chip)
}
 
buf = vmalloc(len);
-   if (!buf) {
+   if (!buf)
return TRANSPORT_ERROR;
-   }
 
retval = rtsx_force_power_on(chip, SSC_PDCTL);
if (retval != STATUS_SUCCESS) {
@@ -1282,9 +1274,8 @@ static int write_mem(struct scsi_cmnd *srb, struct 
rtsx_chip *chip)
 
len = (unsigned short)min_t(unsigned int, scsi_bufflen(srb), len);
buf = vmalloc(len);
-   if (!buf) {
+   if (!buf)
return TRANSPORT_ERROR;
-   }
 
rtsx_stor_get_xfer_buf(buf, len, srb);
scsi_set_resid(srb, scsi_bufflen(srb) - len);
@@ -1702,41 +1693,35 @@ static int set_chip_mode(struct scsi_cmnd *srb, struct 
rtsx_chip *chip)
if (phy_debug_mode) {
chip->phy_debug_mode = 1;
retval = rtsx_write_register(chip, CDRESUMECTL, 0x77, 0);
-   if (retval != STATUS_SUCCESS) {
+   if (retval != STATUS_SUCCESS)
return TRANSPORT_FAILED;
-   }
 
rtsx_disable_bus_int(chip);
 
retval = rtsx_read_phy_register(chip, 0x1C, ®);
-   if (retval != STATUS_SUCCESS) {
+   if (retval != STATUS_SUCCESS)
return TRANSPORT_FAILED;
-   }
 
reg |= 0x0001;
retval = rtsx_write_phy_register(chip, 0x1C, reg);
-   if (retval != STATUS_SUCCESS) {
+   if (retval != STATUS_SUCCESS)
return TRANSPORT_FAILED;
-   }
} else {
chip->phy_debug_mode = 0;
retval = rtsx_write_register(chip, CDRESUMECTL, 0x77, 0x77);
-   if (retval != STATUS_SUCCESS) {
+   if (retval != STATUS_SUCCESS)
return TRANSPORT_FAILED;
-   }
 
rtsx_enable_bus_int(chip);
 
retval = rtsx_read_phy_register(chip, 0x1C, ®);
-   if (retval != STATUS_SUCCESS) {
+   if (retval != STATUS_SUCCESS)

[PATCH 4/4] Staging: rts5208: sd.c: Fixed all braces issues of the file

2018-09-29 Thread Maxime Desroches
Fixed all the braces issues of the sd.c file

Signed-off-by: Maxime Desroches 
---
 drivers/staging/rts5208/sd.c | 704 +--
 1 file changed, 268 insertions(+), 436 deletions(-)

diff --git a/drivers/staging/rts5208/sd.c b/drivers/staging/rts5208/sd.c
index e7efa34195c7..930c61ccb047 100644
--- a/drivers/staging/rts5208/sd.c
+++ b/drivers/staging/rts5208/sd.c
@@ -109,9 +109,8 @@ static int sd_check_data0_status(struct rtsx_chip *chip)
u8 stat;
 
retval = rtsx_read_register(chip, REG_SD_STAT1, &stat);
-   if (retval) {
+   if (retval)
return retval;
-   }
 
if (!(stat & SD_DAT0_STATUS)) {
sd_set_err_code(chip, SD_BUSY);
@@ -234,9 +233,8 @@ static int sd_send_cmd_get_rsp(struct rtsx_chip *chip, u8 
cmd_idx,
if ((cmd_idx != SEND_RELATIVE_ADDR) &&
(cmd_idx != SEND_IF_COND)) {
if (cmd_idx != STOP_TRANSMISSION) {
-   if (ptr[1] & 0x80) {
+   if (ptr[1] & 0x80)
return STATUS_FAIL;
-   }
}
 #ifdef SUPPORT_SD_LOCK
if (ptr[1] & 0x7D) {
@@ -284,9 +282,8 @@ static int sd_read_data(struct rtsx_chip *chip,
if (!buf)
buf_len = 0;
 
-   if (buf_len > 512) {
+   if (buf_len > 512)
return STATUS_FAIL;
-   }
 
rtsx_init_cmd(chip);
 
@@ -331,9 +328,8 @@ static int sd_read_data(struct rtsx_chip *chip,
 
if (buf && buf_len) {
retval = rtsx_read_ppbuf(chip, buf, buf_len);
-   if (retval != STATUS_SUCCESS) {
+   if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
-   }
}
 
return STATUS_SUCCESS;
@@ -359,9 +355,8 @@ static int sd_write_data(struct rtsx_chip *chip, u8 
trans_mode,
 
if (buf && buf_len) {
retval = rtsx_write_ppbuf(chip, buf, buf_len);
-   if (retval != STATUS_SUCCESS) {
+   if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
-   }
}
 
rtsx_init_cmd(chip);
@@ -426,9 +421,8 @@ static int sd_check_csd(struct rtsx_chip *chip, char 
check_wp)
break;
}
 
-   if (i == 6) {
+   if (i == 6)
return STATUS_FAIL;
-   }
 
memcpy(sd_card->raw_csd, rsp + 1, 15);
 
@@ -543,9 +537,8 @@ static int sd_set_sample_push_timing(struct rtsx_chip *chip)
}
 
retval = rtsx_write_register(chip, REG_SD_CFG1, 0x1C, val);
-   if (retval) {
+   if (retval)
return retval;
-   }
 
return STATUS_SUCCESS;
 }
@@ -606,9 +599,8 @@ static int sd_set_clock_divider(struct rtsx_chip *chip, u8 
clk_div)
val = 0x20;
 
retval = rtsx_write_register(chip, REG_SD_CFG1, mask, val);
-   if (retval) {
+   if (retval)
return retval;
-   }
 
return STATUS_SUCCESS;
 }
@@ -619,16 +611,14 @@ static int sd_set_init_para(struct rtsx_chip *chip)
int retval;
 
retval = sd_set_sample_push_timing(chip);
-   if (retval != STATUS_SUCCESS) {
+   if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
-   }
 
sd_choose_proper_clock(chip);
 
retval = switch_clock(chip, sd_card->sd_clock);
-   if (retval != STATUS_SUCCESS) {
+   if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
-   }
 
return STATUS_SUCCESS;
 }
@@ -651,9 +641,8 @@ int sd_select_card(struct rtsx_chip *chip, int select)
}
 
retval = sd_send_cmd_get_rsp(chip, cmd_idx, addr, cmd_type, NULL, 0);
-   if (retval != STATUS_SUCCESS) {
+   if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
-   }
 
return STATUS_SUCCESS;
 }
@@ -667,9 +656,8 @@ static int sd_update_lock_status(struct rtsx_chip *chip)
 
retval = sd_send_cmd_get_rsp(chip, SEND_STATUS, sd_card->sd_addr,
 SD_RSP_TYPE_R1, rsp, 5);
-   if (retval != STATUS_SUCCESS) {
+   if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
-   }
 
if (rsp[1] & 0x02)
sd_card->sd_lock_status |= SD_LOCKED;
@@ -679,9 +667,8 @@ static int sd_update_lock_status(struct rtsx_chip *chip)
dev_dbg(rtsx_dev(chip), "sd_card->sd_lock_status = 0x%x\n",
sd_card->sd_lock_status);
 
-   if (rsp[1] & 0x01) {
+   if (rsp[1] & 0x01)
return STATUS_FAIL;
-   }
 
return STATUS_SUCCESS;
 }
@@ -698,9 +685,8 @@ static int sd_wait_state_data_ready(struct rtsx_chip *chip, 
u8 state,
retval = sd_send_cmd_get_rsp(chip, SEND_STATUS,
 sd_card->sd_addr, SD_RSP_TYPE_R1,
 rsp, 5

[PATCH 5/5] Staging: rts5208: spi.c: Fixed all braces issues of the file

2018-09-29 Thread Maxime Desroches
Fixed all the braces issues of the spi.c file

Signed-off-by: Maxime Desroches 
---
 drivers/staging/rts5208/spi.c | 153 +-
 1 file changed, 59 insertions(+), 94 deletions(-)

diff --git a/drivers/staging/rts5208/spi.c b/drivers/staging/rts5208/spi.c
index 4675668ad977..420264bc03e5 100644
--- a/drivers/staging/rts5208/spi.c
+++ b/drivers/staging/rts5208/spi.c
@@ -41,14 +41,13 @@ static int spi_init(struct rtsx_chip *chip)
retval = rtsx_write_register(chip, SPI_CONTROL, 0xFF,
 CS_POLARITY_LOW | DTO_MSB_FIRST
 | SPI_MASTER | SPI_MODE0 | SPI_AUTO);
-   if (retval) {
+   if (retval)
return retval;
-   }
+
retval = rtsx_write_register(chip, SPI_TCTL, EDO_TIMING_MASK,
 SAMPLE_DELAY_HALF);
-   if (retval) {
+   if (retval)
return retval;
-   }
 
return STATUS_SUCCESS;
 }
@@ -60,42 +59,37 @@ static int spi_set_init_para(struct rtsx_chip *chip)
 
retval = rtsx_write_register(chip, SPI_CLK_DIVIDER1, 0xFF,
 (u8)(spi->clk_div >> 8));
-   if (retval) {
+   if (retval)
return retval;
-   }
+
retval = rtsx_write_register(chip, SPI_CLK_DIVIDER0, 0xFF,
 (u8)(spi->clk_div));
-   if (retval) {
+   if (retval)
return retval;
-   }
 
retval = switch_clock(chip, spi->spi_clock);
-   if (retval != STATUS_SUCCESS) {
+   if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
-   }
 
retval = select_card(chip, SPI_CARD);
-   if (retval != STATUS_SUCCESS) {
+   if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
-   }
 
retval = rtsx_write_register(chip, CARD_CLK_EN, SPI_CLK_EN,
 SPI_CLK_EN);
-   if (retval) {
+   if (retval)
return retval;
-   }
+
retval = rtsx_write_register(chip, CARD_OE, SPI_OUTPUT_EN,
 SPI_OUTPUT_EN);
-   if (retval) {
+   if (retval)
return retval;
-   }
 
wait_timeout(10);
 
retval = spi_init(chip);
-   if (retval != STATUS_SUCCESS) {
+   if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
-   }
 
return STATUS_SUCCESS;
 }
@@ -247,47 +241,45 @@ static int spi_init_eeprom(struct rtsx_chip *chip)
clk = CLK_30;
 
retval = rtsx_write_register(chip, SPI_CLK_DIVIDER1, 0xFF, 0x00);
-   if (retval) {
+   if (retval)
return retval;
-   }
+
retval = rtsx_write_register(chip, SPI_CLK_DIVIDER0, 0xFF, 0x27);
-   if (retval) {
+   if (retval)
return retval;
-   }
 
retval = switch_clock(chip, clk);
-   if (retval != STATUS_SUCCESS) {
+   if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
-   }
+
 
retval = select_card(chip, SPI_CARD);
-   if (retval != STATUS_SUCCESS) {
+   if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
-   }
+
 
retval = rtsx_write_register(chip, CARD_CLK_EN, SPI_CLK_EN,
 SPI_CLK_EN);
-   if (retval) {
+   if (retval)
return retval;
-   }
+
retval = rtsx_write_register(chip, CARD_OE, SPI_OUTPUT_EN,
 SPI_OUTPUT_EN);
-   if (retval) {
+   if (retval)
return retval;
-   }
+
 
wait_timeout(10);
 
retval = rtsx_write_register(chip, SPI_CONTROL, 0xFF,
 CS_POLARITY_HIGH | SPI_EEPROM_AUTO);
-   if (retval) {
+   if (retval)
return retval;
-   }
+
retval = rtsx_write_register(chip, SPI_TCTL, EDO_TIMING_MASK,
 SAMPLE_DELAY_HALF);
-   if (retval) {
+   if (retval)
return retval;
-   }
 
return STATUS_SUCCESS;
 }
@@ -306,9 +298,8 @@ static int spi_eeprom_program_enable(struct rtsx_chip *chip)
 SPI_TRANSFER0_END);
 
retval = rtsx_send_cmd(chip, 0, 100);
-   if (retval < 0) {
+   if (retval < 0)
return STATUS_FAIL;
-   }
 
return STATUS_SUCCESS;
 }
@@ -318,14 +309,12 @@ int spi_erase_eeprom_chip(struct rtsx_chip *chip)
int retval;
 
retval = spi_init_eeprom(chip);
-   if (retval != STATUS_SUCCESS) {
+   if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
-   }
 
retval = spi_eeprom_program_enable(chip);
-   if (retval != STATUS_SUCCESS) {
+   if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
-   }
 
rtsx_init_cmd(chip);
 
@@ -339,14 +328,12 @@ int spi_erase_eeprom_chip(struct rtsx_chip *chip)
  

[PATCH] staging: rtlwifi: Return -ENOMEM instead of -1

2018-09-29 Thread Aymen Qader
Use the ENOMEM constant instead of -1 for kzalloc failure checks in
rtl_halmac.c

Signed-off-by: Aymen Qader 
---
 drivers/staging/rtlwifi/halmac/rtl_halmac.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rtlwifi/halmac/rtl_halmac.c 
b/drivers/staging/rtlwifi/halmac/rtl_halmac.c
index f0c6fc8c6aca..7bfc9620479a 100644
--- a/drivers/staging/rtlwifi/halmac/rtl_halmac.c
+++ b/drivers/staging/rtlwifi/halmac/rtl_halmac.c
@@ -209,7 +209,7 @@ static int init_halmac_event_with_waittime(struct rtl_priv 
*rtlpriv,
if (!rtlpriv->halmac.indicator[id].comp) {
comp = kzalloc(sizeof(*comp), GFP_KERNEL);
if (!comp)
-   return -1;
+   return -ENOMEM;
} else {
RT_TRACE(rtlpriv, COMP_HALMAC, DBG_LOUD,
 "%s:  id(%d) sctx is not NULL!!\n", __func__,
@@ -359,7 +359,7 @@ static int init_priv(struct rtl_halmac *halmac)
size = sizeof(*indicator) * count;
indicator = kzalloc(size, GFP_KERNEL);
if (!indicator)
-   return -1;
+   return -ENOMEM;
halmac->indicator = indicator;
 
return 0;
-- 
2.17.1

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


[PATCH] staging: sm750fb: Remove extra space character

2018-09-29 Thread Aymen Qader
Remove an extra space in ddk750_mode.c to fix indentation

Signed-off-by: Aymen Qader 
---
 drivers/staging/sm750fb/ddk750_mode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/sm750fb/ddk750_mode.c 
b/drivers/staging/sm750fb/ddk750_mode.c
index 7e22d093b091..4dac691ad1b1 100644
--- a/drivers/staging/sm750fb/ddk750_mode.c
+++ b/drivers/staging/sm750fb/ddk750_mode.c
@@ -131,7 +131,7 @@ static int programModeRegisters(struct mode_parameter 
*pModeParam,
  DISPLAY_CTRL_HSYNC_PHASE |
  DISPLAY_CTRL_TIMING | DISPLAY_CTRL_PLANE);
 
-poke32(CRT_DISPLAY_CTRL, tmp | reg);
+   poke32(CRT_DISPLAY_CTRL, tmp | reg);
}
 
} else if (pll->clockType == PRIMARY_PLL) {
-- 
2.17.1

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


[PATCH 6/6] Staging: rts5208: xd.c: Fixed all braces issues of the file

2018-09-29 Thread Maxime Desroches
Fixed all the braces issues of the xd.c file

Signed-off-by: Maxime Desroches 
---
 drivers/staging/rts5208/xd.c | 232 ++-
 1 file changed, 92 insertions(+), 140 deletions(-)

diff --git a/drivers/staging/rts5208/xd.c b/drivers/staging/rts5208/xd.c
index 261d868a3072..415fea2f9ff1 100644
--- a/drivers/staging/rts5208/xd.c
+++ b/drivers/staging/rts5208/xd.c
@@ -60,9 +60,8 @@ static int xd_set_init_para(struct rtsx_chip *chip)
xd_card->xd_clock = CLK_50;
 
retval = switch_clock(chip, xd_card->xd_clock);
-   if (retval != STATUS_SUCCESS) {
+   if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
-   }
 
return STATUS_SUCCESS;
 }
@@ -73,14 +72,12 @@ static int xd_switch_clock(struct rtsx_chip *chip)
int retval;
 
retval = select_card(chip, XD_CARD);
-   if (retval != STATUS_SUCCESS) {
+   if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
-   }
 
retval = switch_clock(chip, xd_card->xd_clock);
-   if (retval != STATUS_SUCCESS) {
+   if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
-   }
 
return STATUS_SUCCESS;
 }
@@ -102,9 +99,8 @@ static int xd_read_id(struct rtsx_chip *chip, u8 id_cmd, u8 
*id_buf, u8 buf_len)
rtsx_add_cmd(chip, READ_REG_CMD, (u16)(XD_ADDRESS1 + i), 0, 0);
 
retval = rtsx_send_cmd(chip, XD_CARD, 20);
-   if (retval < 0) {
+   if (retval < 0)
return STATUS_FAIL;
-   }
 
ptr = rtsx_get_cmd_data(chip) + 1;
if (id_buf && buf_len) {
@@ -173,9 +169,8 @@ static int xd_read_redundant(struct rtsx_chip *chip, u32 
page_addr,
rtsx_add_cmd(chip, READ_REG_CMD, XD_PARITY, 0, 0);
 
retval = rtsx_send_cmd(chip, XD_CARD, 500);
-   if (retval < 0) {
+   if (retval < 0)
return STATUS_FAIL;
-   }
 
if (buf && buf_len) {
u8 *ptr = rtsx_get_cmd_data(chip) + 1;
@@ -193,9 +188,8 @@ static int xd_read_data_from_ppb(struct rtsx_chip *chip, 
int offset,
 {
int retval, i;
 
-   if (!buf || (buf_len < 0)) {
+   if (!buf || (buf_len < 0))
return STATUS_FAIL;
-   }
 
rtsx_init_cmd(chip);
 
@@ -220,9 +214,8 @@ static int xd_read_cis(struct rtsx_chip *chip, u32 
page_addr, u8 *buf,
int retval;
u8 reg;
 
-   if (!buf || (buf_len < 10)) {
+   if (!buf || (buf_len < 10))
return STATUS_FAIL;
-   }
 
rtsx_init_cmd(chip);
 
@@ -246,36 +239,35 @@ static int xd_read_cis(struct rtsx_chip *chip, u32 
page_addr, u8 *buf,
}
 
retval = rtsx_read_register(chip, XD_PAGE_STATUS, ®);
-   if (retval) {
+   if (retval)
return retval;
-   }
+
if (reg != XD_GPG) {
rtsx_clear_xd_error(chip);
return STATUS_FAIL;
}
 
retval = rtsx_read_register(chip, XD_CTL, ®);
-   if (retval) {
+   if (retval)
return retval;
-   }
+
if (!(reg & XD_ECC1_ERROR) || !(reg & XD_ECC1_UNCORRECTABLE)) {
retval = xd_read_data_from_ppb(chip, 0, buf, buf_len);
-   if (retval != STATUS_SUCCESS) {
+   if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
-   }
+
if (reg & XD_ECC1_ERROR) {
u8 ecc_bit, ecc_byte;
 
retval = rtsx_read_register(chip, XD_ECC_BIT1,
&ecc_bit);
-   if (retval) {
+   if (retval)
return retval;
-   }
+
retval = rtsx_read_register(chip, XD_ECC_BYTE1,
&ecc_byte);
-   if (retval) {
+   if (retval)
return retval;
-   }
 
dev_dbg(rtsx_dev(chip), "ECC_BIT1 = 0x%x, ECC_BYTE1 = 
0x%x\n",
ecc_bit, ecc_byte);
@@ -291,22 +283,21 @@ static int xd_read_cis(struct rtsx_chip *chip, u32 
page_addr, u8 *buf,
rtsx_clear_xd_error(chip);
 
retval = xd_read_data_from_ppb(chip, 256, buf, buf_len);
-   if (retval != STATUS_SUCCESS) {
+   if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
-   }
+
if (reg & XD_ECC2_ERROR) {
u8 ecc_bit, ecc_byte;
 
retval = rtsx_read_register(chip, XD_ECC_BIT2,
&ecc_bit);
-   if (retval) {
+   if (retval)
return retval;
-   }
+
retval = rtsx_read_register(chip, XD_ECC_BYTE2,
   

[staging:staging-next 433/443] drivers/staging/vboxvideo/vbox_mode.c:386:2-8: preceding lock on line 378 (fwd)

2018-09-29 Thread Julia Lawall
Hello,

Please check whether an unlock is needed before line 386.

thanks,
julia

-- Forwarded message --
Date: Sun, 30 Sep 2018 01:57:53 +0800
From: kbuild test robot 
To: kbu...@01.org
Cc: Julia Lawall 
Subject: [staging:staging-next 433/443]
drivers/staging/vboxvideo/vbox_mode.c:386:2-8: preceding lock on line 378

CC: kbuild-...@01.org
CC: de...@driverdev.osuosl.org
TO: Hans de Goede 
CC: "Greg Kroah-Hartman" 

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git 
staging-next
head:   e2c3860ba27d21f991bf9b81d64589f7c9e087c1
commit: 35f3288c453e25201a5de4d4b3dfb0fb37025de1 [433/443] staging: vboxvideo: 
Atomic phase 1: convert cursor to universal plane
:: branch date: 5 hours ago
:: commit date: 5 hours ago

>> drivers/staging/vboxvideo/vbox_mode.c:386:2-8: preceding lock on line 378

# 
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git/commit/?id=35f3288c453e25201a5de4d4b3dfb0fb37025de1
git remote add staging 
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git
git remote update staging
git checkout 35f3288c453e25201a5de4d4b3dfb0fb37025de1
vim +386 drivers/staging/vboxvideo/vbox_mode.c

35f3288c Hans de Goede 2018-09-29  356
35f3288c Hans de Goede 2018-09-29  357  static void 
vbox_cursor_atomic_update(struct drm_plane *plane,
35f3288c Hans de Goede 2018-09-29  358
struct drm_plane_state *old_state)
35f3288c Hans de Goede 2018-09-29  359  {
35f3288c Hans de Goede 2018-09-29  360  struct vbox_private *vbox =
35f3288c Hans de Goede 2018-09-29  361  
container_of(plane->dev, struct vbox_private, ddev);
35f3288c Hans de Goede 2018-09-29  362  struct vbox_crtc *vbox_crtc = 
to_vbox_crtc(plane->state->crtc);
35f3288c Hans de Goede 2018-09-29  363  struct drm_framebuffer *fb = 
plane->state->fb;
35f3288c Hans de Goede 2018-09-29  364  struct vbox_bo *bo = 
gem_to_vbox_bo(to_vbox_framebuffer(fb)->obj);
35f3288c Hans de Goede 2018-09-29  365  u32 width = 
plane->state->crtc_w;
35f3288c Hans de Goede 2018-09-29  366  u32 height = 
plane->state->crtc_h;
35f3288c Hans de Goede 2018-09-29  367  size_t data_size, mask_size;
35f3288c Hans de Goede 2018-09-29  368  u32 flags;
35f3288c Hans de Goede 2018-09-29  369  u8 *src;
35f3288c Hans de Goede 2018-09-29  370
35f3288c Hans de Goede 2018-09-29  371  /*
35f3288c Hans de Goede 2018-09-29  372   * VirtualBox uses the host 
windowing system to draw the cursor so
35f3288c Hans de Goede 2018-09-29  373   * moves are a no-op, we only 
need to upload new cursor sprites.
35f3288c Hans de Goede 2018-09-29  374   */
35f3288c Hans de Goede 2018-09-29  375  if (fb == old_state->fb)
35f3288c Hans de Goede 2018-09-29  376  return;
35f3288c Hans de Goede 2018-09-29  377
35f3288c Hans de Goede 2018-09-29 @378  mutex_lock(&vbox->hw_mutex);
35f3288c Hans de Goede 2018-09-29  379
35f3288c Hans de Goede 2018-09-29  380  vbox_crtc->cursor_enabled = 
true;
35f3288c Hans de Goede 2018-09-29  381
35f3288c Hans de Goede 2018-09-29  382  /* pinning is done in 
prepare/cleanup framebuffer */
35f3288c Hans de Goede 2018-09-29  383  src = vbox_bo_kmap(bo);
35f3288c Hans de Goede 2018-09-29  384  if (IS_ERR(src)) {
35f3288c Hans de Goede 2018-09-29  385  DRM_WARN("Could not 
kmap cursor bo, skipping update\n");
35f3288c Hans de Goede 2018-09-29 @386  return;
35f3288c Hans de Goede 2018-09-29  387  }
35f3288c Hans de Goede 2018-09-29  388
35f3288c Hans de Goede 2018-09-29  389  /*
35f3288c Hans de Goede 2018-09-29  390   * The mask must be calculated 
based on the alpha
35f3288c Hans de Goede 2018-09-29  391   * channel, one bit per ARGB 
word, and must be 32-bit
35f3288c Hans de Goede 2018-09-29  392   * padded.
35f3288c Hans de Goede 2018-09-29  393   */
35f3288c Hans de Goede 2018-09-29  394  mask_size = ((width + 7) / 8 * 
height + 3) & ~3;
35f3288c Hans de Goede 2018-09-29  395  data_size = width * height * 4 
+ mask_size;
35f3288c Hans de Goede 2018-09-29  396
35f3288c Hans de Goede 2018-09-29  397  copy_cursor_image(src, 
vbox->cursor_data, width, height, mask_size);
35f3288c Hans de Goede 2018-09-29  398  vbox_bo_kunmap(bo);
35f3288c Hans de Goede 2018-09-29  399
35f3288c Hans de Goede 2018-09-29  400  flags = 
VBOX_MOUSE_POINTER_VISIBLE | VBOX_MOUSE_POINTER_SHAPE |
35f3288c Hans de Goede 2018-09-29  401  
VBOX_MOUSE_POINTER_ALPHA;
35f3288c Hans de Goede 2018-09-29  402  
hgsmi_update_pointer_shape(vbox->guest_pool, flags,
35f3288c Hans de Goede 2018-09-29  403 
min_t(u32, max(fb->hot_x, 0), width),
35f3288c Hans de Goede 2018-09-29  404 
min_t(u32, max(fb->hot_y, 0), height),

[PATCH] Staging: media: replaced deprecated probe method

2018-09-29 Thread Andrey Abramov
drivers/staging/media/bcm2048/radio-bcm2048.c replaced i2c_driver::probe with 
i2c_driver::probe_new, because documentation says that i2c_driver::probe "soon 
to be deprecated"

Signed-off-by: Andrey Abramov 
---
 drivers/staging/media/bcm2048/radio-bcm2048.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/media/bcm2048/radio-bcm2048.c 
b/drivers/staging/media/bcm2048/radio-bcm2048.c
index a90b2eb112f9..756f7f08c713 100644
--- a/drivers/staging/media/bcm2048/radio-bcm2048.c
+++ b/drivers/staging/media/bcm2048/radio-bcm2048.c
@@ -2574,8 +2574,7 @@ static const struct video_device bcm2048_viddev_template 
= {
 /*
  * I2C driver interface
  */
-static int bcm2048_i2c_driver_probe(struct i2c_client *client,
-   const struct i2c_device_id *id)
+static int bcm2048_i2c_driver_probe_new(struct i2c_client *client)
 {
struct bcm2048_device *bdev;
int err;
@@ -2679,7 +2678,7 @@ static struct i2c_driver bcm2048_i2c_driver = {
.driver = {
.name   = BCM2048_DRIVER_NAME,
},
-   .probe  = bcm2048_i2c_driver_probe,
+   .probe_new  = bcm2048_i2c_driver_probe_new,
.remove = bcm2048_i2c_driver_remove,
.id_table   = bcm2048_id,
 };
-- 
2.19.0

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


Re: [v2, 1/5] net: dpaa2: move DPAA2 PTP driver out of staging/

2018-09-29 Thread Andrew Lunn
> +++ b/drivers/net/ethernet/freescale/dpaa2/Kconfig
> @@ -0,0 +1,15 @@
> +config FSL_DPAA2_ETH
> + tristate "Freescale DPAA2 Ethernet"
> + depends on FSL_MC_BUS && FSL_MC_DPIO

Could you add in here COMPILE_TEST? 

> + depends on NETDEVICES && ETHERNET

With the move out of staging, i don't think these two are required.

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


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

2018-09-29 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 acde372c6795..1c9175433ba6 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, &remote_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)
 

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

2018-09-29 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 7b457a4b7df5..d60a52cfc69c 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(&csi2->sd, "failed to get sink endpoint node\n");
+   if (!fwnode_device_is_available(asd->match.fwnode)) {
+   v4l2_err(&csi2->sd, "remote is not available\n");
return -EINVAL;
}
 
-   v4l2_fwnode_endpoint_parse(of_fwnode_handle(epnode), &ep);
-   of_node_put(epnode);
-
-   if (ep.bus_type != V4L2_MBUS_CSI2) {
+   if (vep->bus_type != V4L2_MBUS_CSI2) {
v4l2_err(&csi2->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(&pdev->dev, "ref");
if (IS_ERR(csi2->pllref_clk)) {
v4l2_err(&csi2->sd, "failed to get pll reference clock\n");
@@ -654,7 +649,9 @@ static int csi2_probe(struct platform_device *pdev)
 
platform_set_drvdata(pdev, &csi2->sd);
 
-   ret = v4l2_async_register_subdev(&csi2->sd);
+   ret = v4l2_async_register_fwnode_subdev(
+   &csi2->sd, sizeof(struct v4l2_async_subdev),
+   &sink_port, 1, csi2_parse_endpoint);
if (ret)
goto dphy_off;
 
-- 
2.17.1

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


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

2018-09-29 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 1931d1b038dc..718954f969bd 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, ¬ifier->done, async_list) {
+   list_for_each_entry(sd, &imxmd->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.17.1

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


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

2018-09-29 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 v6:
- none
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 4acdd7ae612b..bca13846ce6d 100644
--- a/drivers/staging/media/imx/imx-media-csi.c
+++ b/drivers/staging/media/imx/imx-media-csi.c
@@ -1783,6 +1783,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", &port);
+   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(&priv->sd, notifier);
+   if (ret < 0)
+   goto out_cleanup;
+
+   ret = v4l2_async_register_subdev(&priv->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;
@@ -1852,7 +1907,7 @@ static int imx_csi_probe(struct platform_device *pdev)
goto free;
}
 
-   ret = v4l2_async_register_subdev(&priv->sd);
+   ret = imx_csi_async_register(priv);
if (ret)
goto free;
 
-- 
2.17.1

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


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

2018-09-29 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 9eb7326f3fc6..aeeb15494a49 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.17.1

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


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

2018-09-29 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 718954f969bd..a9faee4b2495 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(&imxasd->list, &imxmd->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++] = &imxasd->asd;
 
/* prepare the async subdev notifier and register it */
-   imxmd->subdev_notifier.subdevs = subdevs;
-   imxmd->subdev_notifier.ops = &imx_media_subdev_ops;
+   imxmd->notifier.subdevs = subdevs;
+   imxmd->notifier.ops = &imx_media_subdev_ops;
ret = v4l2_async_notifier_register(&imxmd->v4l2_dev,
-  &imxmd->subdev_notifier);
+  &imxmd->notifier);
if (ret) {
v4l2_err(&imxmd->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(&imxmd->v4l2_dev, "Removing imx-media\n");
 
-   v4l2_async_notifier_unregister(&imxmd->subdev_notifier);
+   v4l2_async_notifier_unregister(&imxmd->notifier);
imx_media_remove_internal_subdevs(imxmd);
v4l2_device_unregister(&imxmd->v4l2_dev);
media_device_unregister(&imxmd->md);
diff --git a/drivers/staging/media/imx/imx-media.h 
b/drivers/staging/media/imx/imx-media.h
index 57bd094cf765..227b79ccc194 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.17.1

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


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

2018-09-29 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 v6:
- none
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 +-
 .../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 a9faee4b2495..481840195071 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, &imxmd->asd_list, list) {
-   asd = &imxasd->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(&imxmd->mutex);
+   int ret;
 
-   if (pdev)
+   if (fwnode) {
+   asd = v4l2_async_notifier_add_fwnode_subdev(
+   &imxmd->notifier, fwnode, sizeof(*imxasd));
+   } else {
devname = dev_name(&pdev->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(
+   &imxmd->notifier, devname, sizeof(*imxasd));
}
 
-   imxasd = devm_kzalloc(imxmd->md.dev, sizeof(*imxasd), GFP_KERNEL);
-   if (!imxasd) {
-   ret = -ENOMEM;
-   goto out;
-   }
-   asd = &imxasd->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(&imxasd->list, &imxmd->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(&

Re: [patch V2 11/11] x66/vdso: Add CLOCK_TAI support

2018-09-29 Thread Matthew Rickard




On 17/09/2018 10:45 PM, Thomas Gleixner wrote:

With the storage array in place it's now trivial to support CLOCK_TAI in
the vdso. Extend the base time storage array and add the update code.

Signed-off-by: Thomas Gleixner


That's much better. Thanks

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