Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v8 05/10] firmware: xilinx: Add clock APIs
From: Jolly Shah @ 2018-06-14 18:27 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1529000862-11510-1-git-send-email-jollys@xilinx.com>

From: Rajan Vaja <rajanv@xilinx.com>

Add clock APIs to control clocks through firmware
interface.

Signed-off-by: Rajan Vaja <rajanv@xilinx.com>
Signed-off-by: Jolly Shah <jollys@xilinx.com>
---
 drivers/firmware/xilinx/zynqmp.c     | 186 ++++++++++++++++++++++++++++++++++-
 include/linux/firmware/xlnx-zynqmp.h |  30 ++++++
 2 files changed, 214 insertions(+), 2 deletions(-)

diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
index 86d9bb8..c764d6e 100644
--- a/drivers/firmware/xilinx/zynqmp.c
+++ b/drivers/firmware/xilinx/zynqmp.c
@@ -269,14 +269,196 @@ static int zynqmp_pm_ioctl(u32 node_id, u32 ioctl_id, u32 arg1, u32 arg2,
  */
 static int zynqmp_pm_query_data(struct zynqmp_pm_query_data qdata, u32 *out)
 {
-	return zynqmp_pm_invoke_fn(PM_QUERY_DATA, qdata.qid, qdata.arg1,
-				   qdata.arg2, qdata.arg3, out);
+	int ret;
+
+	ret = zynqmp_pm_invoke_fn(PM_QUERY_DATA, qdata.qid, qdata.arg1,
+				  qdata.arg2, qdata.arg3, out);
+
+	/*
+	 * For clock name query, all bytes in SMC response are clock name
+	 * characters and return code is always success. For invalid clocks,
+	 * clock name bytes would be 0s.
+	 */
+	return qdata.qid == PM_QID_CLOCK_GET_NAME ? 0 : ret;
+}
+
+/**
+ * zynqmp_pm_clock_enable() - Enable the clock for given id
+ * @clock_id:	ID of the clock to be enabled
+ *
+ * This function is used by master to enable the clock
+ * including peripherals and PLL clocks.
+ *
+ * Return: Returns status, either success or error+reason
+ */
+static int zynqmp_pm_clock_enable(u32 clock_id)
+{
+	return zynqmp_pm_invoke_fn(PM_CLOCK_ENABLE, clock_id, 0, 0, 0, NULL);
+}
+
+/**
+ * zynqmp_pm_clock_disable() - Disable the clock for given id
+ * @clock_id:	ID of the clock to be disable
+ *
+ * This function is used by master to disable the clock
+ * including peripherals and PLL clocks.
+ *
+ * Return: Returns status, either success or error+reason
+ */
+static int zynqmp_pm_clock_disable(u32 clock_id)
+{
+	return zynqmp_pm_invoke_fn(PM_CLOCK_DISABLE, clock_id, 0, 0, 0, NULL);
+}
+
+/**
+ * zynqmp_pm_clock_getstate() - Get the clock state for given id
+ * @clock_id:	ID of the clock to be queried
+ * @state:	1/0 (Enabled/Disabled)
+ *
+ * This function is used by master to get the state of clock
+ * including peripherals and PLL clocks.
+ *
+ * Return: Returns status, either success or error+reason
+ */
+static int zynqmp_pm_clock_getstate(u32 clock_id, u32 *state)
+{
+	u32 ret_payload[PAYLOAD_ARG_CNT];
+	int ret;
+
+	ret = zynqmp_pm_invoke_fn(PM_CLOCK_GETSTATE, clock_id, 0,
+				  0, 0, ret_payload);
+	*state = ret_payload[1];
+
+	return ret;
+}
+
+/**
+ * zynqmp_pm_clock_setdivider() - Set the clock divider for given id
+ * @clock_id:	ID of the clock
+ * @divider:	divider value
+ *
+ * This function is used by master to set divider for any clock
+ * to achieve desired rate.
+ *
+ * Return: Returns status, either success or error+reason
+ */
+static int zynqmp_pm_clock_setdivider(u32 clock_id, u32 divider)
+{
+	return zynqmp_pm_invoke_fn(PM_CLOCK_SETDIVIDER, clock_id, divider,
+				   0, 0, NULL);
+}
+
+/**
+ * zynqmp_pm_clock_getdivider() - Get the clock divider for given id
+ * @clock_id:	ID of the clock
+ * @divider:	divider value
+ *
+ * This function is used by master to get divider values
+ * for any clock.
+ *
+ * Return: Returns status, either success or error+reason
+ */
+static int zynqmp_pm_clock_getdivider(u32 clock_id, u32 *divider)
+{
+	u32 ret_payload[PAYLOAD_ARG_CNT];
+	int ret;
+
+	ret = zynqmp_pm_invoke_fn(PM_CLOCK_GETDIVIDER, clock_id, 0,
+				  0, 0, ret_payload);
+	*divider = ret_payload[1];
+
+	return ret;
+}
+
+/**
+ * zynqmp_pm_clock_setrate() - Set the clock rate for given id
+ * @clock_id:	ID of the clock
+ * @rate:	rate value in hz
+ *
+ * This function is used by master to set rate for any clock.
+ *
+ * Return: Returns status, either success or error+reason
+ */
+static int zynqmp_pm_clock_setrate(u32 clock_id, u64 rate)
+{
+	return zynqmp_pm_invoke_fn(PM_CLOCK_SETRATE, clock_id,
+				   rate & 0xFFFFFFFF,
+				   (rate >> 32) & 0xFFFFFFFF,
+				   0, NULL);
+}
+
+/**
+ * zynqmp_pm_clock_getrate() - Get the clock rate for given id
+ * @clock_id:	ID of the clock
+ * @rate:	rate value in hz
+ *
+ * This function is used by master to get rate
+ * for any clock.
+ *
+ * Return: Returns status, either success or error+reason
+ */
+static int zynqmp_pm_clock_getrate(u32 clock_id, u64 *rate)
+{
+	u32 ret_payload[PAYLOAD_ARG_CNT];
+	int ret;
+
+	ret = zynqmp_pm_invoke_fn(PM_CLOCK_GETRATE, clock_id, 0,
+				  0, 0, ret_payload);
+	*rate = ((u64)ret_payload[2] << 32) | ret_payload[1];
+
+	return ret;
+}
+
+/**
+ * zynqmp_pm_clock_setparent() - Set the clock parent for given id
+ * @clock_id:	ID of the clock
+ * @parent_id:	parent id
+ *
+ * This function is used by master to set parent for any clock.
+ *
+ * Return: Returns status, either success or error+reason
+ */
+static int zynqmp_pm_clock_setparent(u32 clock_id, u32 parent_id)
+{
+	return zynqmp_pm_invoke_fn(PM_CLOCK_SETPARENT, clock_id,
+				   parent_id, 0, 0, NULL);
+}
+
+/**
+ * zynqmp_pm_clock_getparent() - Get the clock parent for given id
+ * @clock_id:	ID of the clock
+ * @parent_id:	parent id
+ *
+ * This function is used by master to get parent index
+ * for any clock.
+ *
+ * Return: Returns status, either success or error+reason
+ */
+static int zynqmp_pm_clock_getparent(u32 clock_id, u32 *parent_id)
+{
+	u32 ret_payload[PAYLOAD_ARG_CNT];
+	int ret;
+
+	ret = zynqmp_pm_invoke_fn(PM_CLOCK_GETPARENT, clock_id, 0,
+				  0, 0, ret_payload);
+	*parent_id = ret_payload[1];
+
+	return ret;
 }
 
 static const struct zynqmp_eemi_ops eemi_ops = {
 	.get_api_version = zynqmp_pm_get_api_version,
 	.ioctl = zynqmp_pm_ioctl,
 	.query_data = zynqmp_pm_query_data,
+	.clock_enable = zynqmp_pm_clock_enable,
+	.clock_disable = zynqmp_pm_clock_disable,
+	.clock_getstate = zynqmp_pm_clock_getstate,
+	.clock_setdivider = zynqmp_pm_clock_setdivider,
+	.clock_getdivider = zynqmp_pm_clock_getdivider,
+	.clock_setrate = zynqmp_pm_clock_setrate,
+	.clock_getrate = zynqmp_pm_clock_getrate,
+	.clock_setparent = zynqmp_pm_clock_setparent,
+	.clock_getparent = zynqmp_pm_clock_getparent,
 };
 
 /**
diff --git a/include/linux/firmware/xlnx-zynqmp.h b/include/linux/firmware/xlnx-zynqmp.h
index 354385d..29fb352 100644
--- a/include/linux/firmware/xlnx-zynqmp.h
+++ b/include/linux/firmware/xlnx-zynqmp.h
@@ -36,6 +36,15 @@ enum pm_api_id {
 	PM_GET_API_VERSION = 1,
 	PM_IOCTL = 34,
 	PM_QUERY_DATA,
+	PM_CLOCK_ENABLE,
+	PM_CLOCK_DISABLE,
+	PM_CLOCK_GETSTATE,
+	PM_CLOCK_SETDIVIDER,
+	PM_CLOCK_GETDIVIDER,
+	PM_CLOCK_SETRATE,
+	PM_CLOCK_GETRATE,
+	PM_CLOCK_SETPARENT,
+	PM_CLOCK_GETPARENT,
 };
 
 /* PMU-FW return status codes */
@@ -49,8 +58,20 @@ enum pm_ret_status {
 	XST_PM_ABORT_SUSPEND,
 };
 
+enum pm_ioctl_id {
+	IOCTL_SET_PLL_FRAC_MODE = 8,
+	IOCTL_GET_PLL_FRAC_MODE,
+	IOCTL_SET_PLL_FRAC_DATA,
+	IOCTL_GET_PLL_FRAC_DATA,
+};
+
 enum pm_query_id {
 	PM_QID_INVALID,
+	PM_QID_CLOCK_GET_NAME,
+	PM_QID_CLOCK_GET_TOPOLOGY,
+	PM_QID_CLOCK_GET_FIXEDFACTOR_PARAMS,
+	PM_QID_CLOCK_GET_PARENTS,
+	PM_QID_CLOCK_GET_ATTRIBUTES,
 };
 
 /**
@@ -71,6 +92,15 @@ struct zynqmp_eemi_ops {
 	int (*get_api_version)(u32 *version);
 	int (*ioctl)(u32 node_id, u32 ioctl_id, u32 arg1, u32 arg2, u32 *out);
 	int (*query_data)(struct zynqmp_pm_query_data qdata, u32 *out);
+	int (*clock_enable)(u32 clock_id);
+	int (*clock_disable)(u32 clock_id);
+	int (*clock_getstate)(u32 clock_id, u32 *state);
+	int (*clock_setdivider)(u32 clock_id, u32 divider);
+	int (*clock_getdivider)(u32 clock_id, u32 *divider);
+	int (*clock_setrate)(u32 clock_id, u64 rate);
+	int (*clock_getrate)(u32 clock_id, u64 *rate);
+	int (*clock_setparent)(u32 clock_id, u32 parent_id);
+	int (*clock_getparent)(u32 clock_id, u32 *parent_id);
 };
 
 #if IS_REACHABLE(CONFIG_ARCH_ZYNQMP)
-- 
2.7.4

^ permalink raw reply related

* [PATCH v8 04/10] firmware: xilinx: Add query data API
From: Jolly Shah @ 2018-06-14 18:27 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1529000862-11510-1-git-send-email-jollys@xilinx.com>

From: Rajan Vaja <rajanv@xilinx.com>

Add ZynqMP firmware query data API to query platform
specific information(clocks, pins) from firmware.

Signed-off-by: Rajan Vaja <rajanv@xilinx.com>
Signed-off-by: Jolly Shah <jollys@xilinx.com>
---
 drivers/firmware/xilinx/zynqmp.c     | 14 ++++++++++++++
 include/linux/firmware/xlnx-zynqmp.h | 20 ++++++++++++++++++++
 2 files changed, 34 insertions(+)

diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
index 34c5ad5..86d9bb8 100644
--- a/drivers/firmware/xilinx/zynqmp.c
+++ b/drivers/firmware/xilinx/zynqmp.c
@@ -260,9 +260,23 @@ static int zynqmp_pm_ioctl(u32 node_id, u32 ioctl_id, u32 arg1, u32 arg2,
 				   arg1, arg2, out);
 }
 
+/**
+ * zynqmp_pm_query_data() - Get query data from firmware
+ * @qdata:	Variable to the zynqmp_pm_query_data structure
+ * @out:	Returned output value
+ *
+ * Return: Returns status, either success or error+reason
+ */
+static int zynqmp_pm_query_data(struct zynqmp_pm_query_data qdata, u32 *out)
+{
+	return zynqmp_pm_invoke_fn(PM_QUERY_DATA, qdata.qid, qdata.arg1,
+				   qdata.arg2, qdata.arg3, out);
+}
+
 static const struct zynqmp_eemi_ops eemi_ops = {
 	.get_api_version = zynqmp_pm_get_api_version,
 	.ioctl = zynqmp_pm_ioctl,
+	.query_data = zynqmp_pm_query_data,
 };
 
 /**
diff --git a/include/linux/firmware/xlnx-zynqmp.h b/include/linux/firmware/xlnx-zynqmp.h
index 2eec6e7..354385d 100644
--- a/include/linux/firmware/xlnx-zynqmp.h
+++ b/include/linux/firmware/xlnx-zynqmp.h
@@ -35,6 +35,7 @@
 enum pm_api_id {
 	PM_GET_API_VERSION = 1,
 	PM_IOCTL = 34,
+	PM_QUERY_DATA,
 };
 
 /* PMU-FW return status codes */
@@ -48,9 +49,28 @@ enum pm_ret_status {
 	XST_PM_ABORT_SUSPEND,
 };
 
+enum pm_query_id {
+	PM_QID_INVALID,
+};
+
+/**
+ * struct zynqmp_pm_query_data - PM query data structure
+ * @qid:	query ID
+ * @arg1:	Argument 1 of query data
+ * @arg2:	Argument 2 of query data
+ * @arg3:	Argument 3 of query data
+ */
+struct zynqmp_pm_query_data {
+	u32 qid;
+	u32 arg1;
+	u32 arg2;
+	u32 arg3;
+};
+
 struct zynqmp_eemi_ops {
 	int (*get_api_version)(u32 *version);
 	int (*ioctl)(u32 node_id, u32 ioctl_id, u32 arg1, u32 arg2, u32 *out);
+	int (*query_data)(struct zynqmp_pm_query_data qdata, u32 *out);
 };
 
 #if IS_REACHABLE(CONFIG_ARCH_ZYNQMP)
-- 
2.7.4

^ permalink raw reply related

* [PATCH v8 03/10] firmware: xilinx: Add zynqmp IOCTL API for device control
From: Jolly Shah @ 2018-06-14 18:27 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1529000862-11510-1-git-send-email-jollys@xilinx.com>

From: Rajan Vaja <rajanv@xilinx.com>

Add ZynqMP firmware IOCTL API to control and configure
devices like PLLs, SD, Gem, etc.

Signed-off-by: Rajan Vaja <rajanv@xilinx.com>
Signed-off-by: Jolly Shah <jollys@xilinx.com>
---
 drivers/firmware/xilinx/zynqmp.c     | 20 ++++++++++++++++++++
 include/linux/firmware/xlnx-zynqmp.h |  2 ++
 2 files changed, 22 insertions(+)

diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
index 70e335a..34c5ad5 100644
--- a/drivers/firmware/xilinx/zynqmp.c
+++ b/drivers/firmware/xilinx/zynqmp.c
@@ -241,8 +241,28 @@ static int get_set_conduit_method(struct device_node *np)
 	return 0;
 }
 
+/**
+ * zynqmp_pm_ioctl() - PM IOCTL API for device control and configs
+ * @node_id:	Node ID of the device
+ * @ioctl_id:	ID of the requested IOCTL
+ * @arg1:	Argument 1 to requested IOCTL call
+ * @arg2:	Argument 2 to requested IOCTL call
+ * @out:	Returned output value
+ *
+ * This function calls IOCTL to firmware for device control and configuration.
+ *
+ * Return: Returns status, either success or error+reason
+ */
+static int zynqmp_pm_ioctl(u32 node_id, u32 ioctl_id, u32 arg1, u32 arg2,
+			   u32 *out)
+{
+	return zynqmp_pm_invoke_fn(PM_IOCTL, node_id, ioctl_id,
+				   arg1, arg2, out);
+}
+
 static const struct zynqmp_eemi_ops eemi_ops = {
 	.get_api_version = zynqmp_pm_get_api_version,
+	.ioctl = zynqmp_pm_ioctl,
 };
 
 /**
diff --git a/include/linux/firmware/xlnx-zynqmp.h b/include/linux/firmware/xlnx-zynqmp.h
index cb63bed..2eec6e7 100644
--- a/include/linux/firmware/xlnx-zynqmp.h
+++ b/include/linux/firmware/xlnx-zynqmp.h
@@ -34,6 +34,7 @@
 
 enum pm_api_id {
 	PM_GET_API_VERSION = 1,
+	PM_IOCTL = 34,
 };
 
 /* PMU-FW return status codes */
@@ -49,6 +50,7 @@ enum pm_ret_status {
 
 struct zynqmp_eemi_ops {
 	int (*get_api_version)(u32 *version);
+	int (*ioctl)(u32 node_id, u32 ioctl_id, u32 arg1, u32 arg2, u32 *out);
 };
 
 #if IS_REACHABLE(CONFIG_ARCH_ZYNQMP)
-- 
2.7.4

^ permalink raw reply related

* [PATCH v8 02/10] firmware: xilinx: Add Zynqmp firmware driver
From: Jolly Shah @ 2018-06-14 18:27 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1529000862-11510-1-git-send-email-jollys@xilinx.com>

From: Rajan Vaja <rajanv@xilinx.com>

This patch is adding communication layer with firmware.
Firmware driver provides an interface to firmware APIs.
Interface APIs can be used by any driver to communicate to
PMUFW(Platform Management Unit). All requests go through ATF.

Signed-off-by: Rajan Vaja <rajanv@xilinx.com>
Signed-off-by: Jolly Shah <jollys@xilinx.com>
---
 arch/arm64/Kconfig.platforms         |   1 +
 drivers/firmware/Kconfig             |   1 +
 drivers/firmware/Makefile            |   1 +
 drivers/firmware/xilinx/Kconfig      |  16 ++
 drivers/firmware/xilinx/Makefile     |   4 +
 drivers/firmware/xilinx/zynqmp.c     | 337 +++++++++++++++++++++++++++++++++++
 include/linux/firmware/xlnx-zynqmp.h |  63 +++++++
 7 files changed, 423 insertions(+)
 create mode 100644 drivers/firmware/xilinx/Kconfig
 create mode 100644 drivers/firmware/xilinx/Makefile
 create mode 100644 drivers/firmware/xilinx/zynqmp.c
 create mode 100644 include/linux/firmware/xlnx-zynqmp.h

diff --git a/arch/arm64/Kconfig.platforms b/arch/arm64/Kconfig.platforms
index fbedbd8..6454458 100644
--- a/arch/arm64/Kconfig.platforms
+++ b/arch/arm64/Kconfig.platforms
@@ -274,6 +274,7 @@ config ARCH_ZX
 
 config ARCH_ZYNQMP
 	bool "Xilinx ZynqMP Family"
+	select ZYNQMP_FIRMWARE
 	help
 	  This enables support for Xilinx ZynqMP Family
 
diff --git a/drivers/firmware/Kconfig b/drivers/firmware/Kconfig
index b7c7482..f41eb0d 100644
--- a/drivers/firmware/Kconfig
+++ b/drivers/firmware/Kconfig
@@ -257,5 +257,6 @@ source "drivers/firmware/google/Kconfig"
 source "drivers/firmware/efi/Kconfig"
 source "drivers/firmware/meson/Kconfig"
 source "drivers/firmware/tegra/Kconfig"
+source "drivers/firmware/xilinx/Kconfig"
 
 endmenu
diff --git a/drivers/firmware/Makefile b/drivers/firmware/Makefile
index b248238..f90363e 100644
--- a/drivers/firmware/Makefile
+++ b/drivers/firmware/Makefile
@@ -31,3 +31,4 @@ obj-$(CONFIG_GOOGLE_FIRMWARE)	+= google/
 obj-$(CONFIG_EFI)		+= efi/
 obj-$(CONFIG_UEFI_CPER)		+= efi/
 obj-y				+= tegra/
+obj-y				+= xilinx/
diff --git a/drivers/firmware/xilinx/Kconfig b/drivers/firmware/xilinx/Kconfig
new file mode 100644
index 0000000..cce4e4f
--- /dev/null
+++ b/drivers/firmware/xilinx/Kconfig
@@ -0,0 +1,16 @@
+# SPDX-License-Identifier: GPL-2.0
+# Kconfig for Xilinx firmwares
+
+menu "Zynq MPSoC Firmware Drivers"
+	depends on ARCH_ZYNQMP
+
+config ZYNQMP_FIRMWARE
+	bool "Enable Xilinx Zynq MPSoC firmware interface"
+	help
+	  Firmware interface driver is used by different to
+	  communicate with the firmware for various platform
+	  management services.
+	  Say yes to enable ZynqMP firmware interface driver.
+	  In doubt, say N
+
+endmenu
diff --git a/drivers/firmware/xilinx/Makefile b/drivers/firmware/xilinx/Makefile
new file mode 100644
index 0000000..29f7bf2
--- /dev/null
+++ b/drivers/firmware/xilinx/Makefile
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0
+# Makefile for Xilinx firmwares
+
+obj-$(CONFIG_ZYNQMP_FIRMWARE) += zynqmp.o
diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
new file mode 100644
index 0000000..70e335a
--- /dev/null
+++ b/drivers/firmware/xilinx/zynqmp.c
@@ -0,0 +1,337 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Xilinx Zynq MPSoC Firmware layer
+ *
+ *  Copyright (C) 2014-2018 Xilinx, Inc.
+ *
+ *  Michal Simek <michal.simek@xilinx.com>
+ *  Davorin Mista <davorin.mista@aggios.com>
+ *  Jolly Shah <jollys@xilinx.com>
+ *  Rajan Vaja <rajanv@xilinx.com>
+ */
+
+#include <linux/arm-smccc.h>
+#include <linux/compiler.h>
+#include <linux/device.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_platform.h>
+#include <linux/slab.h>
+#include <linux/uaccess.h>
+
+#include <linux/firmware/xlnx-zynqmp.h>
+
+/**
+ * zynqmp_pm_ret_code() - Convert PMU-FW error codes to Linux error codes
+ * @ret_status:		PMUFW return code
+ *
+ * Return: corresponding Linux error code
+ */
+static int zynqmp_pm_ret_code(u32 ret_status)
+{
+	switch (ret_status) {
+	case XST_PM_SUCCESS:
+	case XST_PM_DOUBLE_REQ:
+		return 0;
+	case XST_PM_NO_ACCESS:
+		return -EACCES;
+	case XST_PM_ABORT_SUSPEND:
+		return -ECANCELED;
+	case XST_PM_INTERNAL:
+	case XST_PM_CONFLICT:
+	case XST_PM_INVALID_NODE:
+	default:
+		return -EINVAL;
+	}
+}
+
+static noinline int do_fw_call_fail(u64 arg0, u64 arg1, u64 arg2,
+				    u32 *ret_payload)
+{
+	return -ENODEV;
+}
+
+/*
+ * PM function call wrapper
+ * Invoke do_fw_call_smc or do_fw_call_hvc, depending on the configuration
+ */
+static int (*do_fw_call)(u64, u64, u64, u32 *ret_payload) = do_fw_call_fail;
+
+/**
+ * do_fw_call_smc() - Call system-level platform management layer (SMC)
+ * @arg0:		Argument 0 to SMC call
+ * @arg1:		Argument 1 to SMC call
+ * @arg2:		Argument 2 to SMC call
+ * @ret_payload:	Returned value array
+ *
+ * Invoke platform management function via SMC call (no hypervisor present).
+ *
+ * Return: Returns status, either success or error+reason
+ */
+static noinline int do_fw_call_smc(u64 arg0, u64 arg1, u64 arg2,
+				   u32 *ret_payload)
+{
+	struct arm_smccc_res res;
+
+	arm_smccc_smc(arg0, arg1, arg2, 0, 0, 0, 0, 0, &res);
+
+	if (ret_payload) {
+		ret_payload[0] = lower_32_bits(res.a0);
+		ret_payload[1] = upper_32_bits(res.a0);
+		ret_payload[2] = lower_32_bits(res.a1);
+		ret_payload[3] = upper_32_bits(res.a1);
+	}
+
+	return zynqmp_pm_ret_code((enum pm_ret_status)res.a0);
+}
+
+/**
+ * do_fw_call_hvc() - Call system-level platform management layer (HVC)
+ * @arg0:		Argument 0 to HVC call
+ * @arg1:		Argument 1 to HVC call
+ * @arg2:		Argument 2 to HVC call
+ * @ret_payload:	Returned value array
+ *
+ * Invoke platform management function via HVC
+ * HVC-based for communication through hypervisor
+ * (no direct communication with ATF).
+ *
+ * Return: Returns status, either success or error+reason
+ */
+static noinline int do_fw_call_hvc(u64 arg0, u64 arg1, u64 arg2,
+				   u32 *ret_payload)
+{
+	struct arm_smccc_res res;
+
+	arm_smccc_hvc(arg0, arg1, arg2, 0, 0, 0, 0, 0, &res);
+
+	if (ret_payload) {
+		ret_payload[0] = lower_32_bits(res.a0);
+		ret_payload[1] = upper_32_bits(res.a0);
+		ret_payload[2] = lower_32_bits(res.a1);
+		ret_payload[3] = upper_32_bits(res.a1);
+	}
+
+	return zynqmp_pm_ret_code((enum pm_ret_status)res.a0);
+}
+
+/**
+ * zynqmp_pm_invoke_fn() - Invoke the system-level platform management layer
+ *			   caller function depending on the configuration
+ * @pm_api_id:		Requested PM-API call
+ * @arg0:		Argument 0 to requested PM-API call
+ * @arg1:		Argument 1 to requested PM-API call
+ * @arg2:		Argument 2 to requested PM-API call
+ * @arg3:		Argument 3 to requested PM-API call
+ * @ret_payload:	Returned value array
+ *
+ * Invoke platform management function for SMC or HVC call, depending on
+ * configuration.
+ * Following SMC Calling Convention (SMCCC) for SMC64:
+ * Pm Function Identifier,
+ * PM_SIP_SVC + PM_API_ID =
+ *	((SMC_TYPE_FAST << FUNCID_TYPE_SHIFT)
+ *	((SMC_64) << FUNCID_CC_SHIFT)
+ *	((SIP_START) << FUNCID_OEN_SHIFT)
+ *	((PM_API_ID) & FUNCID_NUM_MASK))
+ *
+ * PM_SIP_SVC	- Registered ZynqMP SIP Service Call.
+ * PM_API_ID	- Platform Management API ID.
+ *
+ * Return: Returns status, either success or error+reason
+ */
+int zynqmp_pm_invoke_fn(u32 pm_api_id, u32 arg0, u32 arg1,
+			u32 arg2, u32 arg3, u32 *ret_payload)
+{
+	/*
+	 * Added SIP service call Function Identifier
+	 * Make sure to stay in x0 register
+	 */
+	u64 smc_arg[4];
+
+	smc_arg[0] = PM_SIP_SVC | pm_api_id;
+	smc_arg[1] = ((u64)arg1 << 32) | arg0;
+	smc_arg[2] = ((u64)arg3 << 32) | arg2;
+
+	return do_fw_call(smc_arg[0], smc_arg[1], smc_arg[2], ret_payload);
+}
+
+static u32 pm_api_version;
+static u32 pm_tz_version;
+
+/**
+ * zynqmp_pm_get_api_version() - Get version number of PMU PM firmware
+ * @version:	Returned version value
+ *
+ * Return: Returns status, either success or error+reason
+ */
+static int zynqmp_pm_get_api_version(u32 *version)
+{
+	u32 ret_payload[PAYLOAD_ARG_CNT];
+	int ret;
+
+	if (!version)
+		return -EINVAL;
+
+	/* Check is PM API version already verified */
+	if (pm_api_version > 0) {
+		*version = pm_api_version;
+		return 0;
+	}
+	ret = zynqmp_pm_invoke_fn(PM_GET_API_VERSION, 0, 0, 0, 0, ret_payload);
+	*version = ret_payload[1];
+
+	return ret;
+}
+
+/**
+ * zynqmp_pm_get_trustzone_version() - Get secure trustzone firmware version
+ * @version:	Returned version value
+ *
+ * Return: Returns status, either success or error+reason
+ */
+static int zynqmp_pm_get_trustzone_version(u32 *version)
+{
+	u32 ret_payload[PAYLOAD_ARG_CNT];
+	int ret;
+
+	if (!version)
+		return -EINVAL;
+
+	/* Check is PM trustzone version already verified */
+	if (pm_tz_version > 0) {
+		*version = pm_tz_version;
+		return 0;
+	}
+	ret = zynqmp_pm_invoke_fn(PM_GET_TRUSTZONE_VERSION, 0, 0,
+				  0, 0, ret_payload);
+	*version = ret_payload[1];
+
+	return ret;
+}
+
+/**
+ * get_set_conduit_method() - Choose SMC or HVC based communication
+ * @np:		Pointer to the device_node structure
+ *
+ * Use SMC or HVC-based functions to communicate with EL2/EL3.
+ *
+ * Return: Returns 0 on success or error code
+ */
+static int get_set_conduit_method(struct device_node *np)
+{
+	const char *method;
+
+	if (of_property_read_string(np, "method", &method)) {
+		pr_warn("%s missing \"method\" property\n", __func__);
+		return -ENXIO;
+	}
+
+	if (!strcmp("hvc", method)) {
+		do_fw_call = do_fw_call_hvc;
+	} else if (!strcmp("smc", method)) {
+		do_fw_call = do_fw_call_smc;
+	} else {
+		pr_warn("%s Invalid \"method\" property: %s\n",
+			__func__, method);
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static const struct zynqmp_eemi_ops eemi_ops = {
+	.get_api_version = zynqmp_pm_get_api_version,
+};
+
+/**
+ * zynqmp_pm_get_eemi_ops - Get eemi ops functions
+ *
+ * Return: pointer of eemi_ops structure
+ */
+const struct zynqmp_eemi_ops *zynqmp_pm_get_eemi_ops(void)
+{
+	return &eemi_ops;
+}
+EXPORT_SYMBOL_GPL(zynqmp_pm_get_eemi_ops);
+
+static int zynqmp_firmware_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+
+	return of_platform_populate(dev->of_node, NULL, NULL, dev);
+}
+
+static const struct of_device_id zynqmp_firmware_of_match[] = {
+	{.compatible = "xlnx,zynqmp-firmware"},
+	{},
+};
+MODULE_DEVICE_TABLE(of, zynqmp_firmware_of_match);
+
+static struct platform_driver zynqmp_firmware_driver = {
+	.driver = {
+		.name = "zynqmp_firmware",
+		.of_match_table = zynqmp_firmware_of_match,
+	},
+	.probe = zynqmp_firmware_probe,
+};
+module_platform_driver(zynqmp_firmware_driver);
+
+static int __init zynqmp_plat_init(void)
+{
+	int ret;
+	struct device_node *np;
+
+	np = of_find_compatible_node(NULL, NULL, "xlnx,zynqmp");
+	if (!np)
+		return 0;
+	of_node_put(np);
+
+	/*
+	 * We're running on a ZynqMP machine,
+	 * the zynqmp-firmware node is mandatory.
+	 */
+	np = of_find_compatible_node(NULL, NULL, "xlnx,zynqmp-firmware");
+	if (!np) {
+		pr_warn("%s: zynqmp-firmware node not found\n", __func__);
+		return -ENXIO;
+	}
+
+	ret = get_set_conduit_method(np);
+	if (ret) {
+		of_node_put(np);
+		return ret;
+	}
+
+	/* Check PM API version number */
+	zynqmp_pm_get_api_version(&pm_api_version);
+	if (pm_api_version < ZYNQMP_PM_VERSION) {
+		panic("%s Platform Management API version error. Expected: v%d.%d - Found: v%d.%d\n",
+		      __func__,
+		      ZYNQMP_PM_VERSION_MAJOR, ZYNQMP_PM_VERSION_MINOR,
+		      pm_api_version >> 16, pm_api_version & 0xFFFF);
+	}
+
+	pr_info("%s Platform Management API v%d.%d\n", __func__,
+		pm_api_version >> 16, pm_api_version & 0xFFFF);
+
+	/* Check trustzone version number */
+	ret = zynqmp_pm_get_trustzone_version(&pm_tz_version);
+	if (ret)
+		panic("Legacy trustzone found without version support\n");
+
+	if (pm_tz_version < ZYNQMP_TZ_VERSION)
+		panic("%s Trustzone version error. Expected: v%d.%d - Found: v%d.%d\n",
+		      __func__,
+		      ZYNQMP_TZ_VERSION_MAJOR, ZYNQMP_TZ_VERSION_MINOR,
+		      pm_tz_version >> 16, pm_tz_version & 0xFFFF);
+
+	pr_info("%s Trustzone version v%d.%d\n", __func__,
+		pm_tz_version >> 16, pm_tz_version & 0xFFFF);
+
+	of_node_put(np);
+
+	return ret;
+}
+early_initcall(zynqmp_plat_init);
diff --git a/include/linux/firmware/xlnx-zynqmp.h b/include/linux/firmware/xlnx-zynqmp.h
new file mode 100644
index 0000000..cb63bed
--- /dev/null
+++ b/include/linux/firmware/xlnx-zynqmp.h
@@ -0,0 +1,63 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Xilinx Zynq MPSoC Firmware layer
+ *
+ *  Copyright (C) 2014-2018 Xilinx
+ *
+ *  Michal Simek <michal.simek@xilinx.com>
+ *  Davorin Mista <davorin.mista@aggios.com>
+ *  Jolly Shah <jollys@xilinx.com>
+ *  Rajan Vaja <rajanv@xilinx.com>
+ */
+
+#ifndef __FIRMWARE_ZYNQMP_H__
+#define __FIRMWARE_ZYNQMP_H__
+
+#define ZYNQMP_PM_VERSION_MAJOR	1
+#define ZYNQMP_PM_VERSION_MINOR	0
+
+#define ZYNQMP_PM_VERSION	((ZYNQMP_PM_VERSION_MAJOR << 16) | \
+					ZYNQMP_PM_VERSION_MINOR)
+
+#define ZYNQMP_TZ_VERSION_MAJOR	1
+#define ZYNQMP_TZ_VERSION_MINOR	0
+
+#define ZYNQMP_TZ_VERSION	((ZYNQMP_TZ_VERSION_MAJOR << 16) | \
+					ZYNQMP_TZ_VERSION_MINOR)
+
+/* SMC SIP service Call Function Identifier Prefix */
+#define PM_SIP_SVC			0xC2000000
+#define PM_GET_TRUSTZONE_VERSION	0xa03
+
+/* Number of 32bits values in payload */
+#define PAYLOAD_ARG_CNT	4U
+
+enum pm_api_id {
+	PM_GET_API_VERSION = 1,
+};
+
+/* PMU-FW return status codes */
+enum pm_ret_status {
+	XST_PM_SUCCESS = 0,
+	XST_PM_INTERNAL = 2000,
+	XST_PM_CONFLICT,
+	XST_PM_NO_ACCESS,
+	XST_PM_INVALID_NODE,
+	XST_PM_DOUBLE_REQ,
+	XST_PM_ABORT_SUSPEND,
+};
+
+struct zynqmp_eemi_ops {
+	int (*get_api_version)(u32 *version);
+};
+
+#if IS_REACHABLE(CONFIG_ARCH_ZYNQMP)
+const struct zynqmp_eemi_ops *zynqmp_pm_get_eemi_ops(void);
+#else
+static inline struct zynqmp_eemi_ops *zynqmp_pm_get_eemi_ops(void)
+{
+	return NULL;
+}
+#endif
+
+#endif /* __FIRMWARE_ZYNQMP_H__ */
-- 
2.7.4

^ permalink raw reply related

* [PATCH v8 01/10] dt-bindings: firmware: Add bindings for ZynqMP firmware
From: Jolly Shah @ 2018-06-14 18:27 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1529000862-11510-1-git-send-email-jollys@xilinx.com>

From: Rajan Vaja <rajanv@xilinx.com>

Add documentation to describe Xilinx ZynqMP firmware driver
bindings. Firmware driver provides an interface to firmware
APIs. Interface APIs can be used by any driver to communicate
to PMUFW (Platform Management Unit).

Signed-off-by: Rajan Vaja <rajanv@xilinx.com>
Signed-off-by: Jolly Shah <jollys@xilinx.com>
Reviewed-by: Rob Herring <robh@kernel.org>
---
 .../firmware/xilinx/xlnx,zynqmp-firmware.txt       | 29 ++++++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/firmware/xilinx/xlnx,zynqmp-firmware.txt

diff --git a/Documentation/devicetree/bindings/firmware/xilinx/xlnx,zynqmp-firmware.txt b/Documentation/devicetree/bindings/firmware/xilinx/xlnx,zynqmp-firmware.txt
new file mode 100644
index 0000000..1b431d9
--- /dev/null
+++ b/Documentation/devicetree/bindings/firmware/xilinx/xlnx,zynqmp-firmware.txt
@@ -0,0 +1,29 @@
+-----------------------------------------------------------------
+Device Tree Bindings for the Xilinx Zynq MPSoC Firmware Interface
+-----------------------------------------------------------------
+
+The zynqmp-firmware node describes the interface to platform firmware.
+ZynqMP has an interface to communicate with secure firmware. Firmware
+driver provides an interface to firmware APIs. Interface APIs can be
+used by any driver to communicate to PMUFW(Platform Management Unit).
+These requests include clock management, pin control, device control,
+power management service, FPGA service and other platform management
+services.
+
+Required properties:
+ - compatible:	Must contain:	"xlnx,zynqmp-firmware"
+ - method:	The method of calling the PM-API firmware layer.
+		Permitted values are:
+		  - "smc" : SMC #0, following the SMCCC
+		  - "hvc" : HVC #0, following the SMCCC
+
+-------
+Example
+-------
+
+firmware {
+	zynqmp_firmware: zynqmp-firmware {
+		compatible = "xlnx,zynqmp-firmware";
+		method = "smc";
+	};
+};
-- 
2.7.4

^ permalink raw reply related

* [PATCH v8 00/10] drivers: Introduce firmware dnd clock river for ZynqMP core
From: Jolly Shah @ 2018-06-14 18:27 UTC (permalink / raw)
  To: linux-arm-kernel

v8:
 - corrected typo in clk Kconfig
 
v7:
 - Removed xilinx specific clock debugfs API support
 - Added reviewed-by tags for FW and clock bindings
 - Updated clock node name to clock-controller

v6:
 - Broke patch series to have base FW driver and Clock driver user
 - Incorporated code review comments from last FW and Clock driver patch series. Discussed below:
	https://patchwork.kernel.org/patch/10230759/
	https://patchwork.kernel.org/patch/10250047/

v5:
 - Added ATF version check support
 - Updated some functions to be static 
 - Minor function name corrections

v4:
 - Changed clock setrate/getrate API prototype to support 64 bit rate
 - Defined macros for get_node_status return values
 - Moved DT node as a child of firmware
 - Changed debugfs APIs to return data to debugfs buffer instead of dumping to kernel log
 - Minor changes to incorporate other review comments from v3 patch series

v3:
 - added some fixes to firmware-ggs.c
 - updated pinmux get/set function argument names to specify function id instead of node id
 - added new pinctrl query macros
 - incorporated review comments from v2 patch series

v2:
 - change SPDX-License-Identifier license text style
 - split patch into multiple patches
 - Updated copyrights
 - Added ABI documentation
 - incorporated logical review comments from previuos patch. Discussed below:
	https://patchwork.kernel.org/patch/10150665/


Jolly Shah (1):
  drivers: clk: Add ZynqMP clock driver

Rajan Vaja (9):
  dt-bindings: firmware: Add bindings for ZynqMP firmware
  firmware: xilinx: Add Zynqmp firmware driver
  firmware: xilinx: Add zynqmp IOCTL API for device control
  firmware: xilinx: Add query data API
  firmware: xilinx: Add clock APIs
  firmware: xilinx: Add debugfs interface
  firmware: xilinx: Add debugfs for IOCTL API
  firmware: xilinx: Add debugfs for query data API
  dt-bindings: clock: Add bindings for ZynqMP clock driver

 .../firmware/xilinx/xlnx,zynqmp-firmware.txt       |  82 +++
 arch/arm64/Kconfig.platforms                       |   1 +
 drivers/clk/Kconfig                                |   1 +
 drivers/clk/Makefile                               |   1 +
 drivers/clk/zynqmp/Kconfig                         |  11 +
 drivers/clk/zynqmp/Makefile                        |   4 +
 drivers/clk/zynqmp/clk-gate-zynqmp.c               | 146 ++++
 drivers/clk/zynqmp/clk-mux-zynqmp.c                | 150 +++++
 drivers/clk/zynqmp/clk-zynqmp.h                    |  53 ++
 drivers/clk/zynqmp/clkc.c                          | 737 +++++++++++++++++++++
 drivers/clk/zynqmp/divider.c                       | 219 ++++++
 drivers/clk/zynqmp/pll.c                           | 345 ++++++++++
 drivers/firmware/Kconfig                           |   1 +
 drivers/firmware/Makefile                          |   1 +
 drivers/firmware/xilinx/Kconfig                    |  23 +
 drivers/firmware/xilinx/Makefile                   |   5 +
 drivers/firmware/xilinx/zynqmp-debug.c             | 249 +++++++
 drivers/firmware/xilinx/zynqmp-debug.h             |  22 +
 drivers/firmware/xilinx/zynqmp.c                   | 562 ++++++++++++++++
 include/dt-bindings/clock/xlnx,zynqmp-clk.h        | 116 ++++
 include/linux/firmware/xlnx-zynqmp.h               | 115 ++++
 21 files changed, 2844 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/firmware/xilinx/xlnx,zynqmp-firmware.txt
 create mode 100644 drivers/clk/zynqmp/Kconfig
 create mode 100644 drivers/clk/zynqmp/Makefile
 create mode 100644 drivers/clk/zynqmp/clk-gate-zynqmp.c
 create mode 100644 drivers/clk/zynqmp/clk-mux-zynqmp.c
 create mode 100644 drivers/clk/zynqmp/clk-zynqmp.h
 create mode 100644 drivers/clk/zynqmp/clkc.c
 create mode 100644 drivers/clk/zynqmp/divider.c
 create mode 100644 drivers/clk/zynqmp/pll.c
 create mode 100644 drivers/firmware/xilinx/Kconfig
 create mode 100644 drivers/firmware/xilinx/Makefile
 create mode 100644 drivers/firmware/xilinx/zynqmp-debug.c
 create mode 100644 drivers/firmware/xilinx/zynqmp-debug.h
 create mode 100644 drivers/firmware/xilinx/zynqmp.c
 create mode 100644 include/dt-bindings/clock/xlnx,zynqmp-clk.h
 create mode 100644 include/linux/firmware/xlnx-zynqmp.h

-- 
2.7.4

^ permalink raw reply

* [linux-sunxi] [PATCH v2 00/27] Add support for R40 HDMI pipeline
From: Jernej Škrabec @ 2018-06-14 17:29 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <CAMty3ZBt33q9HWm7n3SrON_Y51g+bsQNfoHajCCVzuKZLGHkjw@mail.gmail.com>

Dne ?etrtek, 14. junij 2018 ob 19:16:46 CEST je Jagan Teki napisal(a):
> On Thu, Jun 14, 2018 at 8:04 PM, Jernej ?krabec <jernej.skrabec@siol.net> 
wrote:
> > Dne ?etrtek, 14. junij 2018 ob 09:12:41 CEST je Jagan Teki napisal(a):
> >> On Wed, Jun 13, 2018 at 1:30 AM, Jernej Skrabec <jernej.skrabec@siol.net>
> > 
> > wrote:
> >> > This series adds support for R40 HDMI pipeline. It is a bit special
> >> > than other already supported pipelines because it has additional unit
> >> > called TCON TOP responsible for relationship configuration between
> >> > mixers, TCONs and HDMI. Additionally, it has additional gates for DSI
> >> > and TV TCONs, TV encoder clock settings and pin muxing between LCD
> >> > and TV encoders.
> >> > 
> >> > However, it seems that TCON TOP will become a norm, since newer
> >> > Allwinner SoCs like H6 also have this unit.
> >> > 
> >> > I tested different possible configurations:
> >> > - mixer0 <> TCON-TV0 <> HDMI
> >> > - mixer0 <> TCON-TV1 <> HDMI
> >> > - mixer1 <> TCON-TV0 <> HDMI
> >> > - mixer1 <> TCON-TV1 <> HDMI
> >> > 
> >> > Please review.
> >> > 
> >> > Best regards,
> >> > Jernej
> >> > 
> >> > Changes from v1:
> >> > - Split DT bindings patch and updated description
> >> > - Split HDMI PHY patch
> >> > - Move header file from TCON TOP patch to dt bindings patch
> >> > - Added Rob reviewed-by tag
> >> > - Used clk_hw_register_gate() instead of custom gate registration code
> >> > - Reworked TCON TOP to be part of of-graph. Because of that, a lot of
> >> > 
> >> >   new patches were added.
> >> > 
> >> > - Droped mixer index quirk patch
> >> > - Reworked TCON support for TCON TOP
> >> > - Updated commit messages
> >> > 
> >> > Jernej Skrabec (27):
> >> >   clk: sunxi-ng: r40: Add minimal rate for video PLLs
> >> >   clk: sunxi-ng: r40: Allow setting parent rate to display related
> >> >   
> >> >     clocks
> >> >   
> >> >   clk: sunxi-ng: r40: Export video PLLs
> >> >   dt-bindings: display: sunxi-drm: Add TCON TOP description
> >> >   drm/sun4i: Add TCON TOP driver
> >> >   drm/sun4i: Fix releasing node when enumerating enpoints
> >> >   drm/sun4i: Split out code for enumerating endpoints in output port
> >> >   drm/sun4i: Add support for traversing graph with TCON TOP
> >> >   drm/sun4i: Don't skip TCONs if they don't have channel 0
> >> >   dt-bindings: display: sun4i-drm: Add R40 TV TCON description
> >> >   drm/sun4i: tcon: Add support for tcon-top gate
> >> >   drm/sun4i: tcon: Generalize engine search algorithm
> >> >   drm/sun4i: Don't check for LVDS and RGB when TCON has only ch1
> >> >   drm/sun4i: Don't check for panel or bridge on TV TCONs
> >> >   drm/sun4i: Add support for R40 TV TCON
> >> >   dt-bindings: display: sun4i-drm: Add R40 mixer compatibles
> >> >   drm/sun4i: Add support for R40 mixers
> >> >   dt-bindings: display: sun4i-drm: Add description of A64 HDMI PHY
> >> >   drm/sun4i: Enable DW HDMI PHY clock
> >> >   drm/sun4i: Don't change clock bits in DW HDMI PHY driver
> >> >   drm/sun4i: DW HDMI PHY: Add support for second PLL
> >> >   drm/sun4i: Add support for second clock parent to DW HDMI PHY clk
> >> >   
> >> >     driver
> >> >   
> >> >   drm/sun4i: Add support for A64 HDMI PHY
> >> >   drm: of: Export drm_crtc_port_mask()
> >> >   drm/sun4i: DW HDMI: Expand algorithm for possible crtcs
> >> >   ARM: dts: sun8i: r40: Add HDMI pipeline
> >> >   ARM: dts: sun8i: r40: Enable HDMI output on BananaPi M2 Ultra
> >> 
> >> Tested whole series on top of linux-next.
> >> 
> >> Tested-by: Jagan Teki <jagan@amarulasolutions.com>
> > 
> > Thanks!
> 
> I've V40 board, which is same as R40. I'm able to detect the HDMI but
> seems edid not detecting properly.
> 
> [    0.983007] sun4i-drm display-engine: bound 1100000.mixer (ops
> 0xc074a80c) [    0.999043] sun4i-drm display-engine: bound 1200000.mixer
> (ops 0xc074a80c) [    1.006229] sun4i-drm display-engine: bound
> 1c70000.tcon-top (ops 0xc074e2ac) [    1.013609] sun4i-drm display-engine:
> bound 1c73000.lcd-controller (ops 0xc0747a28)
> [    1.053988] sun8i-dw-hdmi 1ee0000.hdmi: Detected HDMI TX controller
> v1.32a with HDCP (sun8i_dw_hdmi_phy)
> [    1.063913] sun8i-dw-hdmi 1ee0000.hdmi: registered DesignWare HDMI
> I2C bus driver
> [    1.071683] sun4i-drm display-engine: bound 1ee0000.hdmi (ops 0xc074a298)
> [    1.078484] [drm] Supports vblank timestamp caching Rev 2 (21.10.2013).
> [    1.085098] [drm] No driver support for vblank timestamp query. [   
> 1.091055] [drm] Cannot find any crtc or sizes
> [    1.095995] [drm] Initialized sun4i-drm 1.0.0 20150629 for
> display-engine on minor 0

This seems like DT issue. Can you post somewhere your V40 DTSI (if it is 
different to R40) and board DTS?

Best regards,
Jernej

^ permalink raw reply

* [linux-sunxi] [PATCH v3 4/4] arm64: dts: allwinner: a64: add SRAM controller device tree node
From: Jernej Škrabec @ 2018-06-14 17:27 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <CAMty3ZARNpBOQKvS7knH8kWE2+bvjuJoAA4cFGZK8+GzTUQ5zA@mail.gmail.com>

Dne ?etrtek, 14. junij 2018 ob 19:09:56 CEST je Jagan Teki napisal(a):
> On Thu, Jun 14, 2018 at 9:05 PM, Chen-Yu Tsai <wens@csie.org> wrote:
> > From: Icenowy Zheng <icenowy@aosc.io>
> > 
> > Allwinner A64 has a SRAM controller, and in the device tree currently
> > we have a syscon node to enable EMAC driver to access the EMAC clock
> > register. As SRAM controller driver can now export regmap for this
> > register, replace the syscon node to the SRAM controller device node,
> > and let EMAC driver to acquire its EMAC clock regmap.
> > 
> > Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
> > [wens at csie.org: Updated compatible string]
> > Signed-off-by: Chen-Yu Tsai <wens@csie.org>
> > ---
> > 
> >  arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi | 19 +++++++++++++++++--
> >  1 file changed, 17 insertions(+), 2 deletions(-)
> > 
> > diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi
> > b/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi index
> > 1b2ef28c42bd..87968dafe1dc 100644
> > --- a/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi
> > +++ b/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi
> > @@ -169,9 +169,24 @@
> > 
> >                 ranges;
> >                 
> >                 syscon: syscon at 1c00000 {
> > 
> > -                       compatible =
> > "allwinner,sun50i-a64-system-controller", -                              
> > "syscon";
> > +                       compatible =
> > "allwinner,sun50i-a64-system-control";
> > 
> >                         reg = <0x01c00000 0x1000>;
> > 
> > +                       #address-cells = <1>;
> > +                       #size-cells = <1>;
> > +                       ranges;
> > +
> > +                       sram_c: sram at 18000 {
> > +                               compatible = "mmio-sram";
> > +                               reg = <0x00018000 0x28000>;
> > +                               #address-cells = <1>;
> > +                               #size-cells = <1>;
> > +                               ranges = <0 0x00018000 0x28000>;
> > +
> > +                               de2_sram: sram-section at 0 {
> 
> So, this can attach to display-engine node through allwinner,sram and
> add support to claim the sram on sun4i/sun4i_drv.c, correct?

Actually, it has to be added to display_clocks node and claimed in drivers/
clk/sunxi-ng/ccu-sun8i-de2.c

Best regards,
Jernej

^ permalink raw reply

* [linux-sunxi] [PATCH v2 00/27] Add support for R40 HDMI pipeline
From: Jagan Teki @ 2018-06-14 17:16 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <2742773.k39D243pH3@jernej-laptop>

On Thu, Jun 14, 2018 at 8:04 PM, Jernej ?krabec <jernej.skrabec@siol.net> wrote:
> Dne ?etrtek, 14. junij 2018 ob 09:12:41 CEST je Jagan Teki napisal(a):
>> On Wed, Jun 13, 2018 at 1:30 AM, Jernej Skrabec <jernej.skrabec@siol.net>
> wrote:
>> > This series adds support for R40 HDMI pipeline. It is a bit special
>> > than other already supported pipelines because it has additional unit
>> > called TCON TOP responsible for relationship configuration between
>> > mixers, TCONs and HDMI. Additionally, it has additional gates for DSI
>> > and TV TCONs, TV encoder clock settings and pin muxing between LCD
>> > and TV encoders.
>> >
>> > However, it seems that TCON TOP will become a norm, since newer
>> > Allwinner SoCs like H6 also have this unit.
>> >
>> > I tested different possible configurations:
>> > - mixer0 <> TCON-TV0 <> HDMI
>> > - mixer0 <> TCON-TV1 <> HDMI
>> > - mixer1 <> TCON-TV0 <> HDMI
>> > - mixer1 <> TCON-TV1 <> HDMI
>> >
>> > Please review.
>> >
>> > Best regards,
>> > Jernej
>> >
>> > Changes from v1:
>> > - Split DT bindings patch and updated description
>> > - Split HDMI PHY patch
>> > - Move header file from TCON TOP patch to dt bindings patch
>> > - Added Rob reviewed-by tag
>> > - Used clk_hw_register_gate() instead of custom gate registration code
>> > - Reworked TCON TOP to be part of of-graph. Because of that, a lot of
>> >
>> >   new patches were added.
>> >
>> > - Droped mixer index quirk patch
>> > - Reworked TCON support for TCON TOP
>> > - Updated commit messages
>> >
>> > Jernej Skrabec (27):
>> >   clk: sunxi-ng: r40: Add minimal rate for video PLLs
>> >   clk: sunxi-ng: r40: Allow setting parent rate to display related
>> >
>> >     clocks
>> >
>> >   clk: sunxi-ng: r40: Export video PLLs
>> >   dt-bindings: display: sunxi-drm: Add TCON TOP description
>> >   drm/sun4i: Add TCON TOP driver
>> >   drm/sun4i: Fix releasing node when enumerating enpoints
>> >   drm/sun4i: Split out code for enumerating endpoints in output port
>> >   drm/sun4i: Add support for traversing graph with TCON TOP
>> >   drm/sun4i: Don't skip TCONs if they don't have channel 0
>> >   dt-bindings: display: sun4i-drm: Add R40 TV TCON description
>> >   drm/sun4i: tcon: Add support for tcon-top gate
>> >   drm/sun4i: tcon: Generalize engine search algorithm
>> >   drm/sun4i: Don't check for LVDS and RGB when TCON has only ch1
>> >   drm/sun4i: Don't check for panel or bridge on TV TCONs
>> >   drm/sun4i: Add support for R40 TV TCON
>> >   dt-bindings: display: sun4i-drm: Add R40 mixer compatibles
>> >   drm/sun4i: Add support for R40 mixers
>> >   dt-bindings: display: sun4i-drm: Add description of A64 HDMI PHY
>> >   drm/sun4i: Enable DW HDMI PHY clock
>> >   drm/sun4i: Don't change clock bits in DW HDMI PHY driver
>> >   drm/sun4i: DW HDMI PHY: Add support for second PLL
>> >   drm/sun4i: Add support for second clock parent to DW HDMI PHY clk
>> >
>> >     driver
>> >
>> >   drm/sun4i: Add support for A64 HDMI PHY
>> >   drm: of: Export drm_crtc_port_mask()
>> >   drm/sun4i: DW HDMI: Expand algorithm for possible crtcs
>> >   ARM: dts: sun8i: r40: Add HDMI pipeline
>> >   ARM: dts: sun8i: r40: Enable HDMI output on BananaPi M2 Ultra
>>
>> Tested whole series on top of linux-next.
>>
>> Tested-by: Jagan Teki <jagan@amarulasolutions.com>
>
> Thanks!

I've V40 board, which is same as R40. I'm able to detect the HDMI but
seems edid not detecting properly.

[    0.983007] sun4i-drm display-engine: bound 1100000.mixer (ops 0xc074a80c)
[    0.999043] sun4i-drm display-engine: bound 1200000.mixer (ops 0xc074a80c)
[    1.006229] sun4i-drm display-engine: bound 1c70000.tcon-top (ops 0xc074e2ac)
[    1.013609] sun4i-drm display-engine: bound 1c73000.lcd-controller
(ops 0xc0747a28)
[    1.053988] sun8i-dw-hdmi 1ee0000.hdmi: Detected HDMI TX controller
v1.32a with HDCP (sun8i_dw_hdmi_phy)
[    1.063913] sun8i-dw-hdmi 1ee0000.hdmi: registered DesignWare HDMI
I2C bus driver
[    1.071683] sun4i-drm display-engine: bound 1ee0000.hdmi (ops 0xc074a298)
[    1.078484] [drm] Supports vblank timestamp caching Rev 2 (21.10.2013).
[    1.085098] [drm] No driver support for vblank timestamp query.
[    1.091055] [drm] Cannot find any crtc or sizes
[    1.095995] [drm] Initialized sun4i-drm 1.0.0 20150629 for
display-engine on minor 0

^ permalink raw reply

* [linux-sunxi] [PATCH v3 4/4] arm64: dts: allwinner: a64: add SRAM controller device tree node
From: Jagan Teki @ 2018-06-14 17:09 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20180614153548.9644-5-wens@csie.org>

On Thu, Jun 14, 2018 at 9:05 PM, Chen-Yu Tsai <wens@csie.org> wrote:
> From: Icenowy Zheng <icenowy@aosc.io>
>
> Allwinner A64 has a SRAM controller, and in the device tree currently
> we have a syscon node to enable EMAC driver to access the EMAC clock
> register. As SRAM controller driver can now export regmap for this
> register, replace the syscon node to the SRAM controller device node,
> and let EMAC driver to acquire its EMAC clock regmap.
>
> Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
> [wens at csie.org: Updated compatible string]
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
> ---
>  arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi | 19 +++++++++++++++++--
>  1 file changed, 17 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi
> index 1b2ef28c42bd..87968dafe1dc 100644
> --- a/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi
> +++ b/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi
> @@ -169,9 +169,24 @@
>                 ranges;
>
>                 syscon: syscon at 1c00000 {
> -                       compatible = "allwinner,sun50i-a64-system-controller",
> -                               "syscon";
> +                       compatible = "allwinner,sun50i-a64-system-control";
>                         reg = <0x01c00000 0x1000>;
> +                       #address-cells = <1>;
> +                       #size-cells = <1>;
> +                       ranges;
> +
> +                       sram_c: sram at 18000 {
> +                               compatible = "mmio-sram";
> +                               reg = <0x00018000 0x28000>;
> +                               #address-cells = <1>;
> +                               #size-cells = <1>;
> +                               ranges = <0 0x00018000 0x28000>;
> +
> +                               de2_sram: sram-section at 0 {

So, this can attach to display-engine node through allwinner,sram and
add support to claim the sram on sun4i/sun4i_drv.c, correct?

^ permalink raw reply

* [PATCHv2 02/19] arm64: move SCTLR_EL{1,2} assertions to <asm/sysreg.h>
From: Will Deacon @ 2018-06-14 16:44 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20180601112441.37810-3-mark.rutland@arm.com>

On Fri, Jun 01, 2018 at 12:24:24PM +0100, Mark Rutland wrote:
> Currently we assert that the SCTLR_EL{1,2}_{SET,CLEAR} bits are
> self-consistent with an assertion in config_sctlr_el1(). This is a bit
> unusual, since config_sctlr_el1() doesn't make use of these definitions,
> and is far away from the definitions themselves.
> 
> We can use the CPP #error directive to have equivalent assertions in
> <asm/sysreg.h>, next to the definitions of the set/clear bits, which is
> a bit clearer and simpler.
> 
> The preprocessor handles literals differently than regular C, e.g. ~0 is
> equivalent to ~(intmax_t)0 rather than ~(int)0. Therefore, instead of ~0
> we use 0xffffffff, which is unambiguous.
> 
> Signed-off-by: Mark Rutland <mark.rutland@arm.com>
> Reviewed-by: Dave Martin <dave.martin@arm.com>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: James Morse <james.morse@arm.com>
> Cc: Will Deacon <will.deacon@arm.com>
> ---
>  arch/arm64/include/asm/sysreg.h | 14 ++++++--------
>  1 file changed, 6 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/arm64/include/asm/sysreg.h b/arch/arm64/include/asm/sysreg.h
> index 6171178075dc..bd1d1194a5e7 100644
> --- a/arch/arm64/include/asm/sysreg.h
> +++ b/arch/arm64/include/asm/sysreg.h
> @@ -452,9 +452,9 @@
>  			 SCTLR_ELx_SA     | SCTLR_ELx_I    | SCTLR_ELx_WXN | \
>  			 ENDIAN_CLEAR_EL2 | SCTLR_EL2_RES0)
>  
> -/* Check all the bits are accounted for */
> -#define SCTLR_EL2_BUILD_BUG_ON_MISSING_BITS	BUILD_BUG_ON((SCTLR_EL2_SET ^ SCTLR_EL2_CLEAR) != ~0)
> -
> +#if (SCTLR_EL2_SET ^ SCTLR_EL2_CLEAR) != 0xffffffff
> +#error "Inconsistent SCTLR_EL2 set/clear bits"
> +#endif

Please can you extend this check to be 64-bit, since SCTLR is growing fields
up there and we'll want to check them too?

Thanks,

Will

^ permalink raw reply

* [PATCH] ARM: dts: BCM53573: Add architected timer
From: Rafał Miłecki @ 2018-06-14 16:41 UTC (permalink / raw)
  To: linux-arm-kernel

From: Rafa? Mi?ecki <rafal@milecki.pl>

It's a standard ARM architected timer that was simply missed when
initially adding this .dtsi file.

Signed-off-by: Rafa? Mi?ecki <rafal@milecki.pl>
---
 arch/arm/boot/dts/bcm53573.dtsi | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/arch/arm/boot/dts/bcm53573.dtsi b/arch/arm/boot/dts/bcm53573.dtsi
index 16007d72c346..453a2a37dabd 100644
--- a/arch/arm/boot/dts/bcm53573.dtsi
+++ b/arch/arm/boot/dts/bcm53573.dtsi
@@ -48,6 +48,14 @@
 		};
 	};
 
+	timer {
+		compatible = "arm,armv7-timer";
+		interrupts = <GIC_PPI 13 IRQ_TYPE_LEVEL_LOW>,
+			     <GIC_PPI 14 IRQ_TYPE_LEVEL_LOW>,
+			     <GIC_PPI 11 IRQ_TYPE_LEVEL_LOW>,
+			     <GIC_PPI 10 IRQ_TYPE_LEVEL_LOW>;
+	};
+
 	clocks {
 		#address-cells = <1>;
 		#size-cells = <1>;
-- 
2.13.7

^ permalink raw reply related

* [PATCH 0/9] media: cedrus: Add H264 decoding support
From: Maxime Ripard @ 2018-06-14 16:37 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <CAAFQd5A-GMBnNnRCfm0-51R9rn_pWw+UC3r-JX-_BE3cdznqig@mail.gmail.com>

Hi Tomasz,

On Thu, Jun 14, 2018 at 10:00:43PM +0900, Tomasz Figa wrote:
> Hi Maxime,
> 
> On Wed, Jun 13, 2018 at 11:07 PM Maxime Ripard
> <maxime.ripard@bootlin.com> wrote:
> >
> > Hi,
> >
> > Here is a preliminary version of the H264 decoding support in the
> > cedrus driver.
> 
> Thanks for the series! Let me reply inline to some of the points raised here.
> 
> > As you might already know, the cedrus driver relies on the Request
> > API, and is a reverse engineered driver for the video decoding engine
> > found on the Allwinner SoCs.
> >
> > This work has been possible thanks to the work done by the people
> > behind libvdpau-sunxi found here:
> > https://github.com/linux-sunxi/libvdpau-sunxi/
> >
> > This driver is based on the last version of the cedrus driver sent by
> > Paul, based on Request API v13 sent by Hans:
> > https://lkml.org/lkml/2018/5/7/316
> 
> Just FYI, there is v15 already. :)

Yeah, we know, Paul is currently working on rebasing to that version :)

> > This driver has been tested only with baseline profile videos, and is
> > missing a few key features to decode videos with higher profiles.
> > This has been tested using our cedrus-frame-test tool, which should be
> > a quite generic v4l2-to-drm decoder using the request API to
> > demonstrate the video decoding:
> > https://github.com/free-electrons/cedrus-frame-test/, branch h264
> >
> > However, sending this preliminary version, I'd really like to start a
> > discussion and get some feedback on the user-space API for the H264
> > controls exposed through the request API.
> >
> > I've been using the controls currently integrated into ChromeOS that
> > have a working version of this particular setup. However, these
> > controls have a number of shortcomings and inconsistencies with other
> > decoding API. I've worked with libva so far, but I've noticed already
> > that:
> 
> Note that these controls are supposed to be defined exactly like the
> bitstream headers deserialized into C structs in memory. I believe
> Pawel (on CC) defined them based on the actual H264 specification.
> 
> >   - The kernel UAPI expects to have the nal_ref_idc variable, while
> >     libva only exposes whether that frame is a reference frame or
> >     not. I've looked at the rockchip driver in the ChromeOS tree, and
> >     our own driver, and they both need only the information about
> >     whether the frame is a reference one or not, so maybe we should
> >     change this?
> 
> The fact that 2 drivers only need partial information doesn't mean
> that we should ignore the data being already in the bitstream. IMHO
> this API should to provide all the metadata available in the stream to
> the kernel driver, as a replacement for bitstream parsing in firmware
> (or in kernel... yuck).

The point is more that libva will only pass the result of (nal_ref_idc
!= 0). So in the libva plugin, you won't be able to fill the proper
value to the kernel, since you don't have access to it.

> >   - The H264 bitstream exposes the picture default reference list (for
> >     both list 0 and list 1), the slice reference list and an override
> >     flag. The libva will only pass the reference list to be used (so
> >     either the picture default's or the slice's) depending on the
> >     override flag. The kernel UAPI wants the picture default reference
> >     list and the slice reference list, but doesn't expose the override
> >     flag, which prevents us from configuring properly the
> >     hardware. Our video decoding engine needs the three information,
> >     but we can easily adapt to having only one. However, having two
> >     doesn't really work for us.
> 
> Where does the override flag come from? If it's in the bitstream, then
> I guess it was just missed when creating the structures.

It's in the bitstream yeah. I'll add it then.

Maxime

-- 
Maxime Ripard, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply

* [alsa-devel] [PATCH v3 16/27] docs: Fix more broken references
From: Takashi Iwai @ 2018-06-14 16:29 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <e1bf52a721005b2017434acc54ec5ddc152d6fe4.1528990947.git.mchehab+samsung@kernel.org>

On Thu, 14 Jun 2018 18:09:01 +0200,
Mauro Carvalho Chehab wrote:
> 
> As we move stuff around, some doc references are broken. Fix some of
> them via this script:
> 	./scripts/documentation-file-ref-check --fix
> 
> Manually checked that produced results are valid.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>

For the sound bits:
  Acked-by: Takashi Iwai <tiwai@suse.de>


thanks,

Takashi

^ permalink raw reply

* [Intel-wired-lan] [PATCH v3 16/27] docs: Fix more broken references
From: Jeff Kirsher @ 2018-06-14 16:28 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <e1bf52a721005b2017434acc54ec5ddc152d6fe4.1528990947.git.mchehab+samsung@kernel.org>

On Thu, 2018-06-14 at 13:09 -0300, Mauro Carvalho Chehab wrote:
> As we move stuff around, some doc references are broken. Fix some of
> them via this script:
>         ./scripts/documentation-file-ref-check --fix
> 
> Manually checked that produced results are valid.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>

Acked-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>

For the Intel networking Kconfig changes.

> ---
>  .../devicetree/bindings/clock/st/st,clkgen.txt |  8 ++++----
>  .../devicetree/bindings/clock/ti/gate.txt      |  2 +-
>  .../devicetree/bindings/clock/ti/interface.txt |  2 +-
>  .../bindings/cpufreq/cpufreq-mediatek.txt      |  2 +-
>  .../devicetree/bindings/devfreq/rk3399_dmc.txt |  2 +-
>  .../bindings/gpu/arm,mali-midgard.txt          |  2 +-
>  .../bindings/gpu/arm,mali-utgard.txt           |  2 +-
>  .../devicetree/bindings/mfd/mt6397.txt         |  2 +-
>  .../devicetree/bindings/mfd/sun6i-prcm.txt     |  2 +-
>  .../devicetree/bindings/mmc/exynos-dw-mshc.txt |  2 +-
>  .../devicetree/bindings/net/dsa/ksz.txt        |  2 +-
>  .../devicetree/bindings/net/dsa/mt7530.txt     |  2 +-
>  .../devicetree/bindings/power/fsl,imx-gpc.txt  |  2 +-
>  .../bindings/power/wakeup-source.txt           |  2 +-
>  .../devicetree/bindings/usb/rockchip,dwc3.txt  |  2 +-
>  Documentation/hwmon/ina2xx                     |  2 +-
>  Documentation/maintainer/pull-requests.rst     |  2 +-
>  Documentation/translations/ko_KR/howto.rst     |  2 +-
>  MAINTAINERS                                    | 18 +++++++++-------
> --
>  drivers/net/ethernet/intel/Kconfig             |  8 ++++----
>  drivers/soundwire/stream.c                     |  8 ++++----
>  fs/Kconfig.binfmt                              |  2 +-
>  fs/binfmt_misc.c                               |  2 +-
>  23 files changed, 40 insertions(+), 40 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180614/64507779/attachment-0001.sig>

^ permalink raw reply

* [PATCH v3 16/27] docs: Fix more broken references
From: Guenter Roeck @ 2018-06-14 16:22 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <e1bf52a721005b2017434acc54ec5ddc152d6fe4.1528990947.git.mchehab+samsung@kernel.org>

On Thu, Jun 14, 2018 at 01:09:01PM -0300, Mauro Carvalho Chehab wrote:
> As we move stuff around, some doc references are broken. Fix some of
> them via this script:
> 	./scripts/documentation-file-ref-check --fix
> 
> Manually checked that produced results are valid.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>

For hwmon:

Acked-by: Guenter Roeck <linux@roeck-us.net>

> ---
>  .../devicetree/bindings/clock/st/st,clkgen.txt |  8 ++++----
>  .../devicetree/bindings/clock/ti/gate.txt      |  2 +-
>  .../devicetree/bindings/clock/ti/interface.txt |  2 +-
>  .../bindings/cpufreq/cpufreq-mediatek.txt      |  2 +-
>  .../devicetree/bindings/devfreq/rk3399_dmc.txt |  2 +-
>  .../bindings/gpu/arm,mali-midgard.txt          |  2 +-
>  .../bindings/gpu/arm,mali-utgard.txt           |  2 +-
>  .../devicetree/bindings/mfd/mt6397.txt         |  2 +-
>  .../devicetree/bindings/mfd/sun6i-prcm.txt     |  2 +-
>  .../devicetree/bindings/mmc/exynos-dw-mshc.txt |  2 +-
>  .../devicetree/bindings/net/dsa/ksz.txt        |  2 +-
>  .../devicetree/bindings/net/dsa/mt7530.txt     |  2 +-
>  .../devicetree/bindings/power/fsl,imx-gpc.txt  |  2 +-
>  .../bindings/power/wakeup-source.txt           |  2 +-
>  .../devicetree/bindings/usb/rockchip,dwc3.txt  |  2 +-
>  Documentation/hwmon/ina2xx                     |  2 +-
>  Documentation/maintainer/pull-requests.rst     |  2 +-
>  Documentation/translations/ko_KR/howto.rst     |  2 +-
>  MAINTAINERS                                    | 18 +++++++++---------
>  drivers/net/ethernet/intel/Kconfig             |  8 ++++----
>  drivers/soundwire/stream.c                     |  8 ++++----
>  fs/Kconfig.binfmt                              |  2 +-
>  fs/binfmt_misc.c                               |  2 +-
>  23 files changed, 40 insertions(+), 40 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/clock/st/st,clkgen.txt b/Documentation/devicetree/bindings/clock/st/st,clkgen.txt
> index 7364953d0d0b..45ac19bfa0a9 100644
> --- a/Documentation/devicetree/bindings/clock/st/st,clkgen.txt
> +++ b/Documentation/devicetree/bindings/clock/st/st,clkgen.txt
> @@ -31,10 +31,10 @@ This binding uses the common clock binding[1].
>  Each subnode should use the binding described in [2]..[7]
>  
>  [1] Documentation/devicetree/bindings/clock/clock-bindings.txt
> -[3] Documentation/devicetree/bindings/clock/st,clkgen-mux.txt
> -[4] Documentation/devicetree/bindings/clock/st,clkgen-pll.txt
> -[7] Documentation/devicetree/bindings/clock/st,quadfs.txt
> -[8] Documentation/devicetree/bindings/clock/st,flexgen.txt
> +[3] Documentation/devicetree/bindings/clock/st/st,clkgen-mux.txt
> +[4] Documentation/devicetree/bindings/clock/st/st,clkgen-pll.txt
> +[7] Documentation/devicetree/bindings/clock/st/st,quadfs.txt
> +[8] Documentation/devicetree/bindings/clock/st/st,flexgen.txt
>  
>  
>  Required properties:
> diff --git a/Documentation/devicetree/bindings/clock/ti/gate.txt b/Documentation/devicetree/bindings/clock/ti/gate.txt
> index 03f8fdee62a7..56d603c1f716 100644
> --- a/Documentation/devicetree/bindings/clock/ti/gate.txt
> +++ b/Documentation/devicetree/bindings/clock/ti/gate.txt
> @@ -10,7 +10,7 @@ will be controlled instead and the corresponding hw-ops for
>  that is used.
>  
>  [1] Documentation/devicetree/bindings/clock/clock-bindings.txt
> -[2] Documentation/devicetree/bindings/clock/gate-clock.txt
> +[2] Documentation/devicetree/bindings/clock/gpio-gate-clock.txt
>  [3] Documentation/devicetree/bindings/clock/ti/clockdomain.txt
>  
>  Required properties:
> diff --git a/Documentation/devicetree/bindings/clock/ti/interface.txt b/Documentation/devicetree/bindings/clock/ti/interface.txt
> index 3111a409fea6..3f4704040140 100644
> --- a/Documentation/devicetree/bindings/clock/ti/interface.txt
> +++ b/Documentation/devicetree/bindings/clock/ti/interface.txt
> @@ -9,7 +9,7 @@ companion clock finding (match corresponding functional gate
>  clock) and hardware autoidle enable / disable.
>  
>  [1] Documentation/devicetree/bindings/clock/clock-bindings.txt
> -[2] Documentation/devicetree/bindings/clock/gate-clock.txt
> +[2] Documentation/devicetree/bindings/clock/gpio-gate-clock.txt
>  
>  Required properties:
>  - compatible : shall be one of:
> diff --git a/Documentation/devicetree/bindings/cpufreq/cpufreq-mediatek.txt b/Documentation/devicetree/bindings/cpufreq/cpufreq-mediatek.txt
> index d36f07e0a2bb..0551c78619de 100644
> --- a/Documentation/devicetree/bindings/cpufreq/cpufreq-mediatek.txt
> +++ b/Documentation/devicetree/bindings/cpufreq/cpufreq-mediatek.txt
> @@ -8,7 +8,7 @@ Required properties:
>  	"intermediate"	- A parent of "cpu" clock which is used as "intermediate" clock
>  			  source (usually MAINPLL) when the original CPU PLL is under
>  			  transition and not stable yet.
> -	Please refer to Documentation/devicetree/bindings/clk/clock-bindings.txt for
> +	Please refer to Documentation/devicetree/bindings/clock/clock-bindings.txt for
>  	generic clock consumer properties.
>  - operating-points-v2: Please refer to Documentation/devicetree/bindings/opp/opp.txt
>  	for detail.
> diff --git a/Documentation/devicetree/bindings/devfreq/rk3399_dmc.txt b/Documentation/devicetree/bindings/devfreq/rk3399_dmc.txt
> index d6d2833482c9..fc2bcbe26b1e 100644
> --- a/Documentation/devicetree/bindings/devfreq/rk3399_dmc.txt
> +++ b/Documentation/devicetree/bindings/devfreq/rk3399_dmc.txt
> @@ -12,7 +12,7 @@ Required properties:
>  - clocks:		 Phandles for clock specified in "clock-names" property
>  - clock-names :		 The name of clock used by the DFI, must be
>  			 "pclk_ddr_mon";
> -- operating-points-v2:	 Refer to Documentation/devicetree/bindings/power/opp.txt
> +- operating-points-v2:	 Refer to Documentation/devicetree/bindings/opp/opp.txt
>  			 for details.
>  - center-supply:	 DMC supply node.
>  - status:		 Marks the node enabled/disabled.
> diff --git a/Documentation/devicetree/bindings/gpu/arm,mali-midgard.txt b/Documentation/devicetree/bindings/gpu/arm,mali-midgard.txt
> index 039219df05c5..18a2cde2e5f3 100644
> --- a/Documentation/devicetree/bindings/gpu/arm,mali-midgard.txt
> +++ b/Documentation/devicetree/bindings/gpu/arm,mali-midgard.txt
> @@ -34,7 +34,7 @@ Optional properties:
>  - mali-supply : Phandle to regulator for the Mali device. Refer to
>    Documentation/devicetree/bindings/regulator/regulator.txt for details.
>  
> -- operating-points-v2 : Refer to Documentation/devicetree/bindings/power/opp.txt
> +- operating-points-v2 : Refer to Documentation/devicetree/bindings/opp/opp.txt
>    for details.
>  
>  
> diff --git a/Documentation/devicetree/bindings/gpu/arm,mali-utgard.txt b/Documentation/devicetree/bindings/gpu/arm,mali-utgard.txt
> index c1f65d1dac1d..63cd91176a68 100644
> --- a/Documentation/devicetree/bindings/gpu/arm,mali-utgard.txt
> +++ b/Documentation/devicetree/bindings/gpu/arm,mali-utgard.txt
> @@ -44,7 +44,7 @@ Optional properties:
>  
>    - memory-region:
>      Memory region to allocate from, as defined in
> -    Documentation/devicetree/bindi/reserved-memory/reserved-memory.txt
> +    Documentation/devicetree/bindings/reserved-memory/reserved-memory.txt
>  
>    - mali-supply:
>      Phandle to regulator for the Mali device, as defined in
> diff --git a/Documentation/devicetree/bindings/mfd/mt6397.txt b/Documentation/devicetree/bindings/mfd/mt6397.txt
> index d1df77f4d655..0ebd08af777d 100644
> --- a/Documentation/devicetree/bindings/mfd/mt6397.txt
> +++ b/Documentation/devicetree/bindings/mfd/mt6397.txt
> @@ -12,7 +12,7 @@ MT6397/MT6323 is a multifunction device with the following sub modules:
>  It is interfaced to host controller using SPI interface by a proprietary hardware
>  called PMIC wrapper or pwrap. MT6397/MT6323 MFD is a child device of pwrap.
>  See the following for pwarp node definitions:
> -Documentation/devicetree/bindings/soc/pwrap.txt
> +Documentation/devicetree/bindings/soc/mediatek/pwrap.txt
>  
>  This document describes the binding for MFD device and its sub module.
>  
> diff --git a/Documentation/devicetree/bindings/mfd/sun6i-prcm.txt b/Documentation/devicetree/bindings/mfd/sun6i-prcm.txt
> index dd2c06540485..4d21ffdb0fc1 100644
> --- a/Documentation/devicetree/bindings/mfd/sun6i-prcm.txt
> +++ b/Documentation/devicetree/bindings/mfd/sun6i-prcm.txt
> @@ -9,7 +9,7 @@ Required properties:
>  
>  The prcm node may contain several subdevices definitions:
>   - see Documentation/devicetree/clk/sunxi.txt for clock devices
> - - see Documentation/devicetree/reset/allwinner,sunxi-clock-reset.txt for reset
> + - see Documentation/devicetree/bindings/reset/allwinner,sunxi-clock-reset.txt for reset
>     controller devices
>  
>  
> diff --git a/Documentation/devicetree/bindings/mmc/exynos-dw-mshc.txt b/Documentation/devicetree/bindings/mmc/exynos-dw-mshc.txt
> index a58c173b7ab9..0419a63f73a0 100644
> --- a/Documentation/devicetree/bindings/mmc/exynos-dw-mshc.txt
> +++ b/Documentation/devicetree/bindings/mmc/exynos-dw-mshc.txt
> @@ -62,7 +62,7 @@ Required properties for a slot (Deprecated - Recommend to use one slot per host)
>    rest of the gpios (depending on the bus-width property) are the data lines in
>    no particular order. The format of the gpio specifier depends on the gpio
>    controller.
> -(Deprecated - Refer to Documentation/devicetree/binding/pinctrl/samsung-pinctrl.txt)
> +(Deprecated - Refer to Documentation/devicetree/bindings/pinctrl/samsung-pinctrl.txt)
>  
>  Example:
>  
> diff --git a/Documentation/devicetree/bindings/net/dsa/ksz.txt b/Documentation/devicetree/bindings/net/dsa/ksz.txt
> index fd23904ac68e..a700943218ca 100644
> --- a/Documentation/devicetree/bindings/net/dsa/ksz.txt
> +++ b/Documentation/devicetree/bindings/net/dsa/ksz.txt
> @@ -6,7 +6,7 @@ Required properties:
>  - compatible: For external switch chips, compatible string must be exactly one
>    of: "microchip,ksz9477"
>  
> -See Documentation/devicetree/bindings/dsa/dsa.txt for a list of additional
> +See Documentation/devicetree/bindings/net/dsa/dsa.txt for a list of additional
>  required and optional properties.
>  
>  Examples:
> diff --git a/Documentation/devicetree/bindings/net/dsa/mt7530.txt b/Documentation/devicetree/bindings/net/dsa/mt7530.txt
> index a9bc27b93ee3..aa3527f71fdc 100644
> --- a/Documentation/devicetree/bindings/net/dsa/mt7530.txt
> +++ b/Documentation/devicetree/bindings/net/dsa/mt7530.txt
> @@ -31,7 +31,7 @@ Required properties for the child nodes within ports container:
>  - phy-mode: String, must be either "trgmii" or "rgmii" for port labeled
>  	 "cpu".
>  
> -See Documentation/devicetree/bindings/dsa/dsa.txt for a list of additional
> +See Documentation/devicetree/bindings/net/dsa/dsa.txt for a list of additional
>  required, optional properties and how the integrated switch subnodes must
>  be specified.
>  
> diff --git a/Documentation/devicetree/bindings/power/fsl,imx-gpc.txt b/Documentation/devicetree/bindings/power/fsl,imx-gpc.txt
> index b31d6bbeee16..726ec2875223 100644
> --- a/Documentation/devicetree/bindings/power/fsl,imx-gpc.txt
> +++ b/Documentation/devicetree/bindings/power/fsl,imx-gpc.txt
> @@ -14,7 +14,7 @@ Required properties:
>    datasheet
>  - interrupts: Should contain one interrupt specifier for the GPC interrupt
>  - clocks: Must contain an entry for each entry in clock-names.
> -  See Documentation/devicetree/bindings/clocks/clock-bindings.txt for details.
> +  See Documentation/devicetree/bindings/clock/clock-bindings.txt for details.
>  - clock-names: Must include the following entries:
>    - ipg
>  
> diff --git a/Documentation/devicetree/bindings/power/wakeup-source.txt b/Documentation/devicetree/bindings/power/wakeup-source.txt
> index 5d254ab13ebf..cfd74659fbed 100644
> --- a/Documentation/devicetree/bindings/power/wakeup-source.txt
> +++ b/Documentation/devicetree/bindings/power/wakeup-source.txt
> @@ -22,7 +22,7 @@ List of legacy properties and respective binding document
>  3. "has-tpo"			Documentation/devicetree/bindings/rtc/rtc-opal.txt
>  4. "linux,wakeup"		Documentation/devicetree/bindings/input/gpio-matrix-keypad.txt
>  				Documentation/devicetree/bindings/mfd/tc3589x.txt
> -				Documentation/devicetree/bindings/input/ads7846.txt
> +				Documentation/devicetree/bindings/input/touchscreen/ads7846.txt
>  5. "linux,keypad-wakeup"	Documentation/devicetree/bindings/input/qcom,pm8xxx-keypad.txt
>  6. "linux,input-wakeup"		Documentation/devicetree/bindings/input/samsung-keypad.txt
>  7. "nvidia,wakeup-source"	Documentation/devicetree/bindings/input/nvidia,tegra20-kbc.txt
> diff --git a/Documentation/devicetree/bindings/usb/rockchip,dwc3.txt b/Documentation/devicetree/bindings/usb/rockchip,dwc3.txt
> index 50a31536e975..252a05c5d976 100644
> --- a/Documentation/devicetree/bindings/usb/rockchip,dwc3.txt
> +++ b/Documentation/devicetree/bindings/usb/rockchip,dwc3.txt
> @@ -16,7 +16,7 @@ A child node must exist to represent the core DWC3 IP block. The name of
>  the node is not important. The content of the node is defined in dwc3.txt.
>  
>  Phy documentation is provided in the following places:
> -Documentation/devicetree/bindings/phy/rockchip,dwc3-usb-phy.txt
> +Documentation/devicetree/bindings/phy/qcom-dwc3-usb-phy.txt
>  
>  Example device nodes:
>  
> diff --git a/Documentation/hwmon/ina2xx b/Documentation/hwmon/ina2xx
> index cfd31d94c872..72d16f08e431 100644
> --- a/Documentation/hwmon/ina2xx
> +++ b/Documentation/hwmon/ina2xx
> @@ -53,7 +53,7 @@ bus supply voltage.
>  
>  The shunt value in micro-ohms can be set via platform data or device tree at
>  compile-time or via the shunt_resistor attribute in sysfs at run-time. Please
> -refer to the Documentation/devicetree/bindings/i2c/ina2xx.txt for bindings
> +refer to the Documentation/devicetree/bindings/hwmon/ina2xx.txt for bindings
>  if the device tree is used.
>  
>  Additionally ina226 supports update_interval attribute as described in
> diff --git a/Documentation/maintainer/pull-requests.rst b/Documentation/maintainer/pull-requests.rst
> index a19db3458b56..22b271de0304 100644
> --- a/Documentation/maintainer/pull-requests.rst
> +++ b/Documentation/maintainer/pull-requests.rst
> @@ -41,7 +41,7 @@ named ``char-misc-next``, you would be using the following command::
>  
>  that will create a signed tag called ``char-misc-4.15-rc1`` based on the
>  last commit in the ``char-misc-next`` branch, and sign it with your gpg key
> -(see :ref:`Documentation/maintainer/configure_git.rst <configuregit>`).
> +(see :ref:`Documentation/maintainer/configure-git.rst <configuregit>`).
>  
>  Linus will only accept pull requests based on a signed tag. Other
>  maintainers may differ.
> diff --git a/Documentation/translations/ko_KR/howto.rst b/Documentation/translations/ko_KR/howto.rst
> index 624654bdcd8a..a8197e072599 100644
> --- a/Documentation/translations/ko_KR/howto.rst
> +++ b/Documentation/translations/ko_KR/howto.rst
> @@ -160,7 +160,7 @@ mtk.manpages at gmail.com? ??????? ?? ?? ????.
>      ??? ??? ??? ?? ?? ???? ???? ???? ??
>      ????.
>  
> -  :ref:`Documentation/process/stable_kernel_rules.rst <stable_kernel_rules>`
> +  :ref:`Documentation/process/stable-kernel-rules.rst <stable_kernel_rules>`
>      ? ??? ???? ?? ??? ????? ??? ???? ???
>      ????? ??? ??? ? ??? ??? ?? ????
>      ??? ?? ???? ????.
> diff --git a/MAINTAINERS b/MAINTAINERS
> index ec65e33e2cf1..5871dd5060f6 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -4513,7 +4513,7 @@ DRM DRIVER FOR ILITEK ILI9225 PANELS
>  M:	David Lechner <david@lechnology.com>
>  S:	Maintained
>  F:	drivers/gpu/drm/tinydrm/ili9225.c
> -F:	Documentation/devicetree/bindings/display/ili9225.txt
> +F:	Documentation/devicetree/bindings/display/ilitek,ili9225.txt
>  
>  DRM DRIVER FOR INTEL I810 VIDEO CARDS
>  S:	Orphan / Obsolete
> @@ -4599,13 +4599,13 @@ DRM DRIVER FOR SITRONIX ST7586 PANELS
>  M:	David Lechner <david@lechnology.com>
>  S:	Maintained
>  F:	drivers/gpu/drm/tinydrm/st7586.c
> -F:	Documentation/devicetree/bindings/display/st7586.txt
> +F:	Documentation/devicetree/bindings/display/sitronix,st7586.txt
>  
>  DRM DRIVER FOR SITRONIX ST7735R PANELS
>  M:	David Lechner <david@lechnology.com>
>  S:	Maintained
>  F:	drivers/gpu/drm/tinydrm/st7735r.c
> -F:	Documentation/devicetree/bindings/display/st7735r.txt
> +F:	Documentation/devicetree/bindings/display/sitronix,st7735r.txt
>  
>  DRM DRIVER FOR TDFX VIDEO CARDS
>  S:	Orphan / Obsolete
> @@ -4824,7 +4824,7 @@ M:	Eric Anholt <eric@anholt.net>
>  S:	Supported
>  F:	drivers/gpu/drm/v3d/
>  F:	include/uapi/drm/v3d_drm.h
> -F:	Documentation/devicetree/bindings/display/brcm,bcm-v3d.txt
> +F:	Documentation/devicetree/bindings/gpu/brcm,bcm-v3d.txt
>  T:	git git://anongit.freedesktop.org/drm/drm-misc
>  
>  DRM DRIVERS FOR VC4
> @@ -5735,7 +5735,7 @@ M:	Madalin Bucur <madalin.bucur@nxp.com>
>  L:	netdev at vger.kernel.org
>  S:	Maintained
>  F:	drivers/net/ethernet/freescale/fman
> -F:	Documentation/devicetree/bindings/powerpc/fsl/fman.txt
> +F:	Documentation/devicetree/bindings/net/fsl-fman.txt
>  
>  FREESCALE QORIQ PTP CLOCK DRIVER
>  M:	Yangbo Lu <yangbo.lu@nxp.com>
> @@ -8700,7 +8700,7 @@ M:	Guenter Roeck <linux@roeck-us.net>
>  L:	linux-hwmon at vger.kernel.org
>  S:	Maintained
>  F:	Documentation/hwmon/max6697
> -F:	Documentation/devicetree/bindings/i2c/max6697.txt
> +F:	Documentation/devicetree/bindings/hwmon/max6697.txt
>  F:	drivers/hwmon/max6697.c
>  F:	include/linux/platform_data/max6697.h
>  
> @@ -9080,7 +9080,7 @@ M:	Martin Donnelly <martin.donnelly@ge.com>
>  M:	Martyn Welch <martyn.welch@collabora.co.uk>
>  S:	Maintained
>  F:	drivers/gpu/drm/bridge/megachips-stdpxxxx-ge-b850v3-fw.c
> -F:	Documentation/devicetree/bindings/video/bridge/megachips-stdpxxxx-ge-b850v3-fw.txt
> +F:	Documentation/devicetree/bindings/display/bridge/megachips-stdpxxxx-ge-b850v3-fw.txt
>  
>  MEGARAID SCSI/SAS DRIVERS
>  M:	Kashyap Desai <kashyap.desai@broadcom.com>
> @@ -10728,7 +10728,7 @@ PARALLEL LCD/KEYPAD PANEL DRIVER
>  M:	Willy Tarreau <willy@haproxy.com>
>  M:	Ksenija Stanojevic <ksenija.stanojevic@gmail.com>
>  S:	Odd Fixes
> -F:	Documentation/misc-devices/lcd-panel-cgram.txt
> +F:	Documentation/auxdisplay/lcd-panel-cgram.txt
>  F:	drivers/misc/panel.c
>  
>  PARALLEL PORT SUBSYSTEM
> @@ -13291,7 +13291,7 @@ M:	Vinod Koul <vkoul@kernel.org>
>  L:	alsa-devel at alsa-project.org (moderated for non-subscribers)
>  T:	git git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git
>  S:	Supported
> -F:	Documentation/sound/alsa/compress_offload.txt
> +F:	Documentation/sound/designs/compress-offload.rst
>  F:	include/sound/compress_driver.h
>  F:	include/uapi/sound/compress_*
>  F:	sound/core/compress_offload.c
> diff --git a/drivers/net/ethernet/intel/Kconfig b/drivers/net/ethernet/intel/Kconfig
> index 14d287bed33c..1ab613eb5796 100644
> --- a/drivers/net/ethernet/intel/Kconfig
> +++ b/drivers/net/ethernet/intel/Kconfig
> @@ -33,7 +33,7 @@ config E100
>  	  to identify the adapter.
>  
>  	  More specific information on configuring the driver is in
> -	  <file:Documentation/networking/e100.txt>.
> +	  <file:Documentation/networking/e100.rst>.
>  
>  	  To compile this driver as a module, choose M here. The module
>  	  will be called e100.
> @@ -49,7 +49,7 @@ config E1000
>  	  <http://support.intel.com>
>  
>  	  More specific information on configuring the driver is in
> -	  <file:Documentation/networking/e1000.txt>.
> +	  <file:Documentation/networking/e1000.rst>.
>  
>  	  To compile this driver as a module, choose M here. The module
>  	  will be called e1000.
> @@ -94,7 +94,7 @@ config IGB
>  	  <http://support.intel.com>
>  
>  	  More specific information on configuring the driver is in
> -	  <file:Documentation/networking/e1000.txt>.
> +	  <file:Documentation/networking/e1000.rst>.
>  
>  	  To compile this driver as a module, choose M here. The module
>  	  will be called igb.
> @@ -130,7 +130,7 @@ config IGBVF
>  	  <http://support.intel.com>
>  
>  	  More specific information on configuring the driver is in
> -	  <file:Documentation/networking/e1000.txt>.
> +	  <file:Documentation/networking/e1000.rst>.
>  
>  	  To compile this driver as a module, choose M here. The module
>  	  will be called igbvf.
> diff --git a/drivers/soundwire/stream.c b/drivers/soundwire/stream.c
> index 8974a0fcda1b..4b5e250e8615 100644
> --- a/drivers/soundwire/stream.c
> +++ b/drivers/soundwire/stream.c
> @@ -1291,7 +1291,7 @@ static int _sdw_prepare_stream(struct sdw_stream_runtime *stream)
>   *
>   * @stream: Soundwire stream
>   *
> - * Documentation/soundwire/stream.txt explains this API in detail
> + * Documentation/driver-api/soundwire/stream.rst explains this API in detail
>   */
>  int sdw_prepare_stream(struct sdw_stream_runtime *stream)
>  {
> @@ -1348,7 +1348,7 @@ static int _sdw_enable_stream(struct sdw_stream_runtime *stream)
>   *
>   * @stream: Soundwire stream
>   *
> - * Documentation/soundwire/stream.txt explains this API in detail
> + * Documentation/driver-api/soundwire/stream.rst explains this API in detail
>   */
>  int sdw_enable_stream(struct sdw_stream_runtime *stream)
>  {
> @@ -1400,7 +1400,7 @@ static int _sdw_disable_stream(struct sdw_stream_runtime *stream)
>   *
>   * @stream: Soundwire stream
>   *
> - * Documentation/soundwire/stream.txt explains this API in detail
> + * Documentation/driver-api/soundwire/stream.rst explains this API in detail
>   */
>  int sdw_disable_stream(struct sdw_stream_runtime *stream)
>  {
> @@ -1456,7 +1456,7 @@ static int _sdw_deprepare_stream(struct sdw_stream_runtime *stream)
>   *
>   * @stream: Soundwire stream
>   *
> - * Documentation/soundwire/stream.txt explains this API in detail
> + * Documentation/driver-api/soundwire/stream.rst explains this API in detail
>   */
>  int sdw_deprepare_stream(struct sdw_stream_runtime *stream)
>  {
> diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
> index 57a27c42b5ac..56df483de619 100644
> --- a/fs/Kconfig.binfmt
> +++ b/fs/Kconfig.binfmt
> @@ -168,7 +168,7 @@ config BINFMT_MISC
>  	  will automatically feed it to the correct interpreter.
>  
>  	  You can do other nice things, too. Read the file
> -	  <file:Documentation/binfmt_misc.txt> to learn how to use this
> +	  <file:Documentation/admin-guide/binfmt-misc.rst> to learn how to use this
>  	  feature, <file:Documentation/admin-guide/java.rst> for information about how
>  	  to include Java support. and <file:Documentation/admin-guide/mono.rst> for
>            information about how to include Mono-based .NET support.
> diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c
> index 4de191563261..4b5fff31ef27 100644
> --- a/fs/binfmt_misc.c
> +++ b/fs/binfmt_misc.c
> @@ -4,7 +4,7 @@
>   * Copyright (C) 1997 Richard G?nther
>   *
>   * binfmt_misc detects binaries via a magic or filename extension and invokes
> - * a specified wrapper. See Documentation/binfmt_misc.txt for more details.
> + * a specified wrapper. See Documentation/admin-guide/binfmt-misc.rst for more details.
>   */
>  
>  #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> -- 
> 2.17.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-hwmon" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* [PATCH] arm64/mm: Introduce a variable to hold base address of linear region
From: James Morse @ 2018-06-14 16:17 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <CACi5LpMJnFthKUJGfMWgDyMTM65oTtOvsRGCtMDjWP32qDptbQ@mail.gmail.com>

Hi Bhupesh,

On 14/06/18 08:53, Bhupesh Sharma wrote:
> On Wed, Jun 13, 2018 at 3:59 PM, James Morse <james.morse@arm.com> wrote:
>> On 13/06/18 06:16, Bhupesh Sharma wrote:
>>> On Tue, Jun 12, 2018 at 3:42 PM, James Morse <james.morse@arm.com> wrote:
>>>> If I've followed this properly: the problem is that to generate the ELF headers
>>>> in the post-kdump vmcore, at kdump-load-time kexec-tools has to guess the
>>>> virtual addresses of the 'System RAM' regions it can see in /proc/iomem.
>>>>
>>>> The problem you are hitting is an invisible hole at the beginning of RAM,
>>>> meaning user-space's guess_phys_to_virt() is off by the size of this hole.
>>>>
>>>> Isn't KASLR a special case for this? You must have to correct for that after
>>>> kdump has happened, based on an elf-note in the vmcore. Can't we always do this?
>>>
>>> No, I hit this issue both for the KASLR and non-KASLR boot cases.
>>
>> Because in both cases there is a hole at the beginning of the linear-map. KASLR
>> is a special-case of this as the kernel adds a variable sized hole to do the
>> randomization.
>>
>> Surely treating this as one case makes your user-space code simpler.
> 
> Ok.
> 
>>> Fixing this in kernel space seems better to me as the definition of
>>
>> Is there a kernel bug? Changing the definitions of internal kernel variables for
>> the benefit of code digging in /proc/kcore|/dev/mem isn't going to fly.
> 
> Indeed, I am not advocating to change the kernel space code just to
> suit the user-space tools. However in this particular case the
> 'memstart_addr' and PHY_OFFSET value are computed as 0 which IMO

(What is PHY_OFFSET? I assume you mean PHYS_OFFSET, which is the same as
memstart_addr ... why do you quote them together?)


> is
> not the real representation of the start of System RAM as the 1st
> memory block available in Linux starts from 2MB [as confirmed by the
> 'memblock_start_of_DRAM()' value of 0x200000] and indicated by
> '/proc/iomem':
> 
> # head -1 /proc/iomem
> 00200000-0021ffff : reserved

You have assumptions about what memstart_addr is based on its name. Names of
kernel variables get further from their actual use over time.

The purpose of this variable isn't to store where a hypothetical-lowest-page of
memory would be in the linear map. The kernel doesn't have a handy variable for
this, because on-one needs to know.


> I think reading the kernel code and finding 'memstart_addr' and
> PHY_OFFSET as 0, one gets the notion 

notion -> assumption based on the name

It's just a name. Anyone reading this should grep for how the value is used.
It's added/subtracted from addresses as part of phys_to_virt()/virt_to_phs(). It
must be some kind of offset. What does it mean on its own? Probably nothing.


> that the base of System RAM starts from 0,
> which is incorrect in the above case as it starts from
> 2MB as the 1st block is of the type EfiReservedMemType

What will they assume if the value is negative?

[...]

> So, either we should have a uniform way of representing the virtual
> base of the linear range

What needs to know this? RAM will be somewhere between PAGE_OFFSET and the top
of the address space. Anyone who wants to know where has a specific page in
mind, phys_to_virt() or page_address() tell them where their page is.


> or  we should rather look at removing the PAGE_OFFSET
> usage from
> the kernel (or atleast the confusing comment from 'memory.h')

This?:
| PAGE_OFFSET - the virtual address of the start of the linear map

Nothing here says its the virtual address of any particular physical page. Its
the start of the region of VA space that holds the 1:1 mapping of RAM. Its value
is generated at compile time, we have no idea where RAM will be until we boot,
how could this be the address of any particular page?


> BTW adding 'p2v_offset' as an elf-note seems like a good idea. If this
> seems suitable, I can try and spin patch(es) using this approach (both
> for the kernel and user-space tools).

You seem to be using this for user-space phys_to_virt() based on values found in
/proc/iomem. This should give you what you want, and isolate your user-space
from the kernel's unexpected naming of variables.

I'd suggest a 64bit offset that is added to a physical address to get where in
the linear map this page would be, if its mapped.


Thanks,

James

^ permalink raw reply

* [PATCH v3 24/27] devicetree: fix a series of wrong file references
From: Mauro Carvalho Chehab @ 2018-06-14 16:09 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <cover.1528990947.git.mchehab+samsung@kernel.org>

As files got renamed, their references broke.

Manually fix a series of broken refs at the DT bindings.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
---
 .../devicetree/bindings/input/rmi4/rmi_2d_sensor.txt |  2 +-
 Documentation/devicetree/bindings/mfd/sun6i-prcm.txt |  2 +-
 .../devicetree/bindings/pci/hisilicon-pcie.txt       |  2 +-
 Documentation/devicetree/bindings/pci/kirin-pcie.txt |  2 +-
 .../devicetree/bindings/pci/pci-keystone.txt         |  4 ++--
 .../devicetree/bindings/sound/st,stm32-i2s.txt       |  2 +-
 .../devicetree/bindings/sound/st,stm32-sai.txt       |  2 +-
 MAINTAINERS                                          | 12 ++++++------
 8 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/Documentation/devicetree/bindings/input/rmi4/rmi_2d_sensor.txt b/Documentation/devicetree/bindings/input/rmi4/rmi_2d_sensor.txt
index f2c30c8b725d..9afffbdf6e28 100644
--- a/Documentation/devicetree/bindings/input/rmi4/rmi_2d_sensor.txt
+++ b/Documentation/devicetree/bindings/input/rmi4/rmi_2d_sensor.txt
@@ -12,7 +12,7 @@ Additional documentation for F11 can be found at:
 http://www.synaptics.com/sites/default/files/511-000136-01-Rev-E-RMI4-Interfacing-Guide.pdf
 
 Optional Touch Properties:
-Description in Documentation/devicetree/bindings/input/touch
+Description in Documentation/devicetree/bindings/input/touchscreen
 - touchscreen-inverted-x
 - touchscreen-inverted-y
 - touchscreen-swapped-x-y
diff --git a/Documentation/devicetree/bindings/mfd/sun6i-prcm.txt b/Documentation/devicetree/bindings/mfd/sun6i-prcm.txt
index 4d21ffdb0fc1..daa091c2e67b 100644
--- a/Documentation/devicetree/bindings/mfd/sun6i-prcm.txt
+++ b/Documentation/devicetree/bindings/mfd/sun6i-prcm.txt
@@ -8,7 +8,7 @@ Required properties:
  - reg: The PRCM registers range
 
 The prcm node may contain several subdevices definitions:
- - see Documentation/devicetree/clk/sunxi.txt for clock devices
+ - see Documentation/devicetree/bindings/clock/sunxi.txt for clock devices
  - see Documentation/devicetree/bindings/reset/allwinner,sunxi-clock-reset.txt for reset
    controller devices
 
diff --git a/Documentation/devicetree/bindings/pci/hisilicon-pcie.txt b/Documentation/devicetree/bindings/pci/hisilicon-pcie.txt
index 7bf9df047a1e..0dcb87d6554f 100644
--- a/Documentation/devicetree/bindings/pci/hisilicon-pcie.txt
+++ b/Documentation/devicetree/bindings/pci/hisilicon-pcie.txt
@@ -3,7 +3,7 @@ HiSilicon Hip05 and Hip06 PCIe host bridge DT description
 HiSilicon PCIe host controller is based on the Synopsys DesignWare PCI core.
 It shares common functions with the PCIe DesignWare core driver and inherits
 common properties defined in
-Documentation/devicetree/bindings/pci/designware-pci.txt.
+Documentation/devicetree/bindings/pci/designware-pcie.txt.
 
 Additional properties are described here:
 
diff --git a/Documentation/devicetree/bindings/pci/kirin-pcie.txt b/Documentation/devicetree/bindings/pci/kirin-pcie.txt
index 6e217c63123d..6bbe43818ad5 100644
--- a/Documentation/devicetree/bindings/pci/kirin-pcie.txt
+++ b/Documentation/devicetree/bindings/pci/kirin-pcie.txt
@@ -3,7 +3,7 @@ HiSilicon Kirin SoCs PCIe host DT description
 Kirin PCIe host controller is based on the Synopsys DesignWare PCI core.
 It shares common functions with the PCIe DesignWare core driver and
 inherits common properties defined in
-Documentation/devicetree/bindings/pci/designware-pci.txt.
+Documentation/devicetree/bindings/pci/designware-pcie.txt.
 
 Additional properties are described here:
 
diff --git a/Documentation/devicetree/bindings/pci/pci-keystone.txt b/Documentation/devicetree/bindings/pci/pci-keystone.txt
index 7e05487544ed..3d4a209b0fd0 100644
--- a/Documentation/devicetree/bindings/pci/pci-keystone.txt
+++ b/Documentation/devicetree/bindings/pci/pci-keystone.txt
@@ -3,9 +3,9 @@ TI Keystone PCIe interface
 Keystone PCI host Controller is based on the Synopsys DesignWare PCI
 hardware version 3.65.  It shares common functions with the PCIe DesignWare
 core driver and inherits common properties defined in
-Documentation/devicetree/bindings/pci/designware-pci.txt
+Documentation/devicetree/bindings/pci/designware-pcie.txt
 
-Please refer to Documentation/devicetree/bindings/pci/designware-pci.txt
+Please refer to Documentation/devicetree/bindings/pci/designware-pcie.txt
 for the details of DesignWare DT bindings.  Additional properties are
 described here as well as properties that are not applicable.
 
diff --git a/Documentation/devicetree/bindings/sound/st,stm32-i2s.txt b/Documentation/devicetree/bindings/sound/st,stm32-i2s.txt
index 4bda52042402..58c341300552 100644
--- a/Documentation/devicetree/bindings/sound/st,stm32-i2s.txt
+++ b/Documentation/devicetree/bindings/sound/st,stm32-i2s.txt
@@ -18,7 +18,7 @@ Required properties:
     See Documentation/devicetree/bindings/dma/stm32-dma.txt.
   - dma-names: Identifier for each DMA request line. Must be "tx" and "rx".
   - pinctrl-names: should contain only value "default"
-  - pinctrl-0: see Documentation/devicetree/bindings/pinctrl/pinctrl-stm32.txt
+  - pinctrl-0: see Documentation/devicetree/bindings/pinctrl/st,stm32-pinctrl.txt
 
 Optional properties:
   - resets: Reference to a reset controller asserting the reset controller
diff --git a/Documentation/devicetree/bindings/sound/st,stm32-sai.txt b/Documentation/devicetree/bindings/sound/st,stm32-sai.txt
index f301cdf0b7e6..3a3fc506e43a 100644
--- a/Documentation/devicetree/bindings/sound/st,stm32-sai.txt
+++ b/Documentation/devicetree/bindings/sound/st,stm32-sai.txt
@@ -37,7 +37,7 @@ SAI subnodes required properties:
 	"tx": if sai sub-block is configured as playback DAI
 	"rx": if sai sub-block is configured as capture DAI
   - pinctrl-names: should contain only value "default"
-  - pinctrl-0: see Documentation/devicetree/bindings/pinctrl/pinctrl-stm32.txt
+  - pinctrl-0: see Documentation/devicetree/bindings/pinctrl/st,stm32-pinctrl.txt
 
 SAI subnodes Optional properties:
   - st,sync: specify synchronization mode.
diff --git a/MAINTAINERS b/MAINTAINERS
index 67641f5bb373..69c9e9924902 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -6965,7 +6965,7 @@ IIO MULTIPLEXER
 M:	Peter Rosin <peda@axentia.se>
 L:	linux-iio at vger.kernel.org
 S:	Maintained
-F:	Documentation/devicetree/bindings/iio/multiplexer/iio-mux.txt
+F:	Documentation/devicetree/bindings/iio/multiplexer/io-channel-mux.txt
 F:	drivers/iio/multiplexer/iio-mux.c
 
 IIO SUBSYSTEM AND DRIVERS
@@ -9695,7 +9695,7 @@ MXSFB DRM DRIVER
 M:	Marek Vasut <marex@denx.de>
 S:	Supported
 F:	drivers/gpu/drm/mxsfb/
-F:	Documentation/devicetree/bindings/display/mxsfb-drm.txt
+F:	Documentation/devicetree/bindings/display/mxsfb.txt
 
 MYRICOM MYRI-10G 10GbE DRIVER (MYRI10GE)
 M:	Chris Lee <christopher.lee@cspi.com>
@@ -10884,7 +10884,7 @@ M:	Will Deacon <will.deacon@arm.com>
 L:	linux-pci at vger.kernel.org
 L:	linux-arm-kernel at lists.infradead.org (moderated for non-subscribers)
 S:	Maintained
-F:	Documentation/devicetree/bindings/pci/controller-generic-pci.txt
+F:	Documentation/devicetree/bindings/pci/host-generic-pci.txt
 F:	drivers/pci/controller/pci-host-common.c
 F:	drivers/pci/controller/pci-host-generic.c
 
@@ -11065,7 +11065,7 @@ M:	Xiaowei Song <songxiaowei@hisilicon.com>
 M:	Binghui Wang <wangbinghui@hisilicon.com>
 L:	linux-pci at vger.kernel.org
 S:	Maintained
-F:	Documentation/devicetree/bindings/pci/pcie-kirin.txt
+F:	Documentation/devicetree/bindings/pci/kirin-pcie.txt
 F:	drivers/pci/controller/dwc/pcie-kirin.c
 
 PCIE DRIVER FOR HISILICON STB
@@ -12456,7 +12456,7 @@ L:	linux-crypto at vger.kernel.org
 L:	linux-samsung-soc at vger.kernel.org
 S:	Maintained
 F:	drivers/crypto/exynos-rng.c
-F:	Documentation/devicetree/bindings/crypto/samsung,exynos-rng4.txt
+F:	Documentation/devicetree/bindings/rng/samsung,exynos4-rng.txt
 
 SAMSUNG EXYNOS TRUE RANDOM NUMBER GENERATOR (TRNG) DRIVER
 M:	?ukasz Stelmach <l.stelmach@samsung.com>
@@ -13570,7 +13570,7 @@ F:	drivers/*/stm32-*timer*
 F:	drivers/pwm/pwm-stm32*
 F:	include/linux/*/stm32-*tim*
 F:	Documentation/ABI/testing/*timer-stm32
-F:	Documentation/devicetree/bindings/*/stm32-*timer
+F:	Documentation/devicetree/bindings/*/stm32-*timer*
 F:	Documentation/devicetree/bindings/pwm/pwm-stm32*
 
 STMMAC ETHERNET DRIVER
-- 
2.17.1

^ permalink raw reply related

* [PATCH v3 16/27] docs: Fix more broken references
From: Mauro Carvalho Chehab @ 2018-06-14 16:09 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <cover.1528990947.git.mchehab+samsung@kernel.org>

As we move stuff around, some doc references are broken. Fix some of
them via this script:
	./scripts/documentation-file-ref-check --fix

Manually checked that produced results are valid.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
---
 .../devicetree/bindings/clock/st/st,clkgen.txt |  8 ++++----
 .../devicetree/bindings/clock/ti/gate.txt      |  2 +-
 .../devicetree/bindings/clock/ti/interface.txt |  2 +-
 .../bindings/cpufreq/cpufreq-mediatek.txt      |  2 +-
 .../devicetree/bindings/devfreq/rk3399_dmc.txt |  2 +-
 .../bindings/gpu/arm,mali-midgard.txt          |  2 +-
 .../bindings/gpu/arm,mali-utgard.txt           |  2 +-
 .../devicetree/bindings/mfd/mt6397.txt         |  2 +-
 .../devicetree/bindings/mfd/sun6i-prcm.txt     |  2 +-
 .../devicetree/bindings/mmc/exynos-dw-mshc.txt |  2 +-
 .../devicetree/bindings/net/dsa/ksz.txt        |  2 +-
 .../devicetree/bindings/net/dsa/mt7530.txt     |  2 +-
 .../devicetree/bindings/power/fsl,imx-gpc.txt  |  2 +-
 .../bindings/power/wakeup-source.txt           |  2 +-
 .../devicetree/bindings/usb/rockchip,dwc3.txt  |  2 +-
 Documentation/hwmon/ina2xx                     |  2 +-
 Documentation/maintainer/pull-requests.rst     |  2 +-
 Documentation/translations/ko_KR/howto.rst     |  2 +-
 MAINTAINERS                                    | 18 +++++++++---------
 drivers/net/ethernet/intel/Kconfig             |  8 ++++----
 drivers/soundwire/stream.c                     |  8 ++++----
 fs/Kconfig.binfmt                              |  2 +-
 fs/binfmt_misc.c                               |  2 +-
 23 files changed, 40 insertions(+), 40 deletions(-)

diff --git a/Documentation/devicetree/bindings/clock/st/st,clkgen.txt b/Documentation/devicetree/bindings/clock/st/st,clkgen.txt
index 7364953d0d0b..45ac19bfa0a9 100644
--- a/Documentation/devicetree/bindings/clock/st/st,clkgen.txt
+++ b/Documentation/devicetree/bindings/clock/st/st,clkgen.txt
@@ -31,10 +31,10 @@ This binding uses the common clock binding[1].
 Each subnode should use the binding described in [2]..[7]
 
 [1] Documentation/devicetree/bindings/clock/clock-bindings.txt
-[3] Documentation/devicetree/bindings/clock/st,clkgen-mux.txt
-[4] Documentation/devicetree/bindings/clock/st,clkgen-pll.txt
-[7] Documentation/devicetree/bindings/clock/st,quadfs.txt
-[8] Documentation/devicetree/bindings/clock/st,flexgen.txt
+[3] Documentation/devicetree/bindings/clock/st/st,clkgen-mux.txt
+[4] Documentation/devicetree/bindings/clock/st/st,clkgen-pll.txt
+[7] Documentation/devicetree/bindings/clock/st/st,quadfs.txt
+[8] Documentation/devicetree/bindings/clock/st/st,flexgen.txt
 
 
 Required properties:
diff --git a/Documentation/devicetree/bindings/clock/ti/gate.txt b/Documentation/devicetree/bindings/clock/ti/gate.txt
index 03f8fdee62a7..56d603c1f716 100644
--- a/Documentation/devicetree/bindings/clock/ti/gate.txt
+++ b/Documentation/devicetree/bindings/clock/ti/gate.txt
@@ -10,7 +10,7 @@ will be controlled instead and the corresponding hw-ops for
 that is used.
 
 [1] Documentation/devicetree/bindings/clock/clock-bindings.txt
-[2] Documentation/devicetree/bindings/clock/gate-clock.txt
+[2] Documentation/devicetree/bindings/clock/gpio-gate-clock.txt
 [3] Documentation/devicetree/bindings/clock/ti/clockdomain.txt
 
 Required properties:
diff --git a/Documentation/devicetree/bindings/clock/ti/interface.txt b/Documentation/devicetree/bindings/clock/ti/interface.txt
index 3111a409fea6..3f4704040140 100644
--- a/Documentation/devicetree/bindings/clock/ti/interface.txt
+++ b/Documentation/devicetree/bindings/clock/ti/interface.txt
@@ -9,7 +9,7 @@ companion clock finding (match corresponding functional gate
 clock) and hardware autoidle enable / disable.
 
 [1] Documentation/devicetree/bindings/clock/clock-bindings.txt
-[2] Documentation/devicetree/bindings/clock/gate-clock.txt
+[2] Documentation/devicetree/bindings/clock/gpio-gate-clock.txt
 
 Required properties:
 - compatible : shall be one of:
diff --git a/Documentation/devicetree/bindings/cpufreq/cpufreq-mediatek.txt b/Documentation/devicetree/bindings/cpufreq/cpufreq-mediatek.txt
index d36f07e0a2bb..0551c78619de 100644
--- a/Documentation/devicetree/bindings/cpufreq/cpufreq-mediatek.txt
+++ b/Documentation/devicetree/bindings/cpufreq/cpufreq-mediatek.txt
@@ -8,7 +8,7 @@ Required properties:
 	"intermediate"	- A parent of "cpu" clock which is used as "intermediate" clock
 			  source (usually MAINPLL) when the original CPU PLL is under
 			  transition and not stable yet.
-	Please refer to Documentation/devicetree/bindings/clk/clock-bindings.txt for
+	Please refer to Documentation/devicetree/bindings/clock/clock-bindings.txt for
 	generic clock consumer properties.
 - operating-points-v2: Please refer to Documentation/devicetree/bindings/opp/opp.txt
 	for detail.
diff --git a/Documentation/devicetree/bindings/devfreq/rk3399_dmc.txt b/Documentation/devicetree/bindings/devfreq/rk3399_dmc.txt
index d6d2833482c9..fc2bcbe26b1e 100644
--- a/Documentation/devicetree/bindings/devfreq/rk3399_dmc.txt
+++ b/Documentation/devicetree/bindings/devfreq/rk3399_dmc.txt
@@ -12,7 +12,7 @@ Required properties:
 - clocks:		 Phandles for clock specified in "clock-names" property
 - clock-names :		 The name of clock used by the DFI, must be
 			 "pclk_ddr_mon";
-- operating-points-v2:	 Refer to Documentation/devicetree/bindings/power/opp.txt
+- operating-points-v2:	 Refer to Documentation/devicetree/bindings/opp/opp.txt
 			 for details.
 - center-supply:	 DMC supply node.
 - status:		 Marks the node enabled/disabled.
diff --git a/Documentation/devicetree/bindings/gpu/arm,mali-midgard.txt b/Documentation/devicetree/bindings/gpu/arm,mali-midgard.txt
index 039219df05c5..18a2cde2e5f3 100644
--- a/Documentation/devicetree/bindings/gpu/arm,mali-midgard.txt
+++ b/Documentation/devicetree/bindings/gpu/arm,mali-midgard.txt
@@ -34,7 +34,7 @@ Optional properties:
 - mali-supply : Phandle to regulator for the Mali device. Refer to
   Documentation/devicetree/bindings/regulator/regulator.txt for details.
 
-- operating-points-v2 : Refer to Documentation/devicetree/bindings/power/opp.txt
+- operating-points-v2 : Refer to Documentation/devicetree/bindings/opp/opp.txt
   for details.
 
 
diff --git a/Documentation/devicetree/bindings/gpu/arm,mali-utgard.txt b/Documentation/devicetree/bindings/gpu/arm,mali-utgard.txt
index c1f65d1dac1d..63cd91176a68 100644
--- a/Documentation/devicetree/bindings/gpu/arm,mali-utgard.txt
+++ b/Documentation/devicetree/bindings/gpu/arm,mali-utgard.txt
@@ -44,7 +44,7 @@ Optional properties:
 
   - memory-region:
     Memory region to allocate from, as defined in
-    Documentation/devicetree/bindi/reserved-memory/reserved-memory.txt
+    Documentation/devicetree/bindings/reserved-memory/reserved-memory.txt
 
   - mali-supply:
     Phandle to regulator for the Mali device, as defined in
diff --git a/Documentation/devicetree/bindings/mfd/mt6397.txt b/Documentation/devicetree/bindings/mfd/mt6397.txt
index d1df77f4d655..0ebd08af777d 100644
--- a/Documentation/devicetree/bindings/mfd/mt6397.txt
+++ b/Documentation/devicetree/bindings/mfd/mt6397.txt
@@ -12,7 +12,7 @@ MT6397/MT6323 is a multifunction device with the following sub modules:
 It is interfaced to host controller using SPI interface by a proprietary hardware
 called PMIC wrapper or pwrap. MT6397/MT6323 MFD is a child device of pwrap.
 See the following for pwarp node definitions:
-Documentation/devicetree/bindings/soc/pwrap.txt
+Documentation/devicetree/bindings/soc/mediatek/pwrap.txt
 
 This document describes the binding for MFD device and its sub module.
 
diff --git a/Documentation/devicetree/bindings/mfd/sun6i-prcm.txt b/Documentation/devicetree/bindings/mfd/sun6i-prcm.txt
index dd2c06540485..4d21ffdb0fc1 100644
--- a/Documentation/devicetree/bindings/mfd/sun6i-prcm.txt
+++ b/Documentation/devicetree/bindings/mfd/sun6i-prcm.txt
@@ -9,7 +9,7 @@ Required properties:
 
 The prcm node may contain several subdevices definitions:
  - see Documentation/devicetree/clk/sunxi.txt for clock devices
- - see Documentation/devicetree/reset/allwinner,sunxi-clock-reset.txt for reset
+ - see Documentation/devicetree/bindings/reset/allwinner,sunxi-clock-reset.txt for reset
    controller devices
 
 
diff --git a/Documentation/devicetree/bindings/mmc/exynos-dw-mshc.txt b/Documentation/devicetree/bindings/mmc/exynos-dw-mshc.txt
index a58c173b7ab9..0419a63f73a0 100644
--- a/Documentation/devicetree/bindings/mmc/exynos-dw-mshc.txt
+++ b/Documentation/devicetree/bindings/mmc/exynos-dw-mshc.txt
@@ -62,7 +62,7 @@ Required properties for a slot (Deprecated - Recommend to use one slot per host)
   rest of the gpios (depending on the bus-width property) are the data lines in
   no particular order. The format of the gpio specifier depends on the gpio
   controller.
-(Deprecated - Refer to Documentation/devicetree/binding/pinctrl/samsung-pinctrl.txt)
+(Deprecated - Refer to Documentation/devicetree/bindings/pinctrl/samsung-pinctrl.txt)
 
 Example:
 
diff --git a/Documentation/devicetree/bindings/net/dsa/ksz.txt b/Documentation/devicetree/bindings/net/dsa/ksz.txt
index fd23904ac68e..a700943218ca 100644
--- a/Documentation/devicetree/bindings/net/dsa/ksz.txt
+++ b/Documentation/devicetree/bindings/net/dsa/ksz.txt
@@ -6,7 +6,7 @@ Required properties:
 - compatible: For external switch chips, compatible string must be exactly one
   of: "microchip,ksz9477"
 
-See Documentation/devicetree/bindings/dsa/dsa.txt for a list of additional
+See Documentation/devicetree/bindings/net/dsa/dsa.txt for a list of additional
 required and optional properties.
 
 Examples:
diff --git a/Documentation/devicetree/bindings/net/dsa/mt7530.txt b/Documentation/devicetree/bindings/net/dsa/mt7530.txt
index a9bc27b93ee3..aa3527f71fdc 100644
--- a/Documentation/devicetree/bindings/net/dsa/mt7530.txt
+++ b/Documentation/devicetree/bindings/net/dsa/mt7530.txt
@@ -31,7 +31,7 @@ Required properties for the child nodes within ports container:
 - phy-mode: String, must be either "trgmii" or "rgmii" for port labeled
 	 "cpu".
 
-See Documentation/devicetree/bindings/dsa/dsa.txt for a list of additional
+See Documentation/devicetree/bindings/net/dsa/dsa.txt for a list of additional
 required, optional properties and how the integrated switch subnodes must
 be specified.
 
diff --git a/Documentation/devicetree/bindings/power/fsl,imx-gpc.txt b/Documentation/devicetree/bindings/power/fsl,imx-gpc.txt
index b31d6bbeee16..726ec2875223 100644
--- a/Documentation/devicetree/bindings/power/fsl,imx-gpc.txt
+++ b/Documentation/devicetree/bindings/power/fsl,imx-gpc.txt
@@ -14,7 +14,7 @@ Required properties:
   datasheet
 - interrupts: Should contain one interrupt specifier for the GPC interrupt
 - clocks: Must contain an entry for each entry in clock-names.
-  See Documentation/devicetree/bindings/clocks/clock-bindings.txt for details.
+  See Documentation/devicetree/bindings/clock/clock-bindings.txt for details.
 - clock-names: Must include the following entries:
   - ipg
 
diff --git a/Documentation/devicetree/bindings/power/wakeup-source.txt b/Documentation/devicetree/bindings/power/wakeup-source.txt
index 5d254ab13ebf..cfd74659fbed 100644
--- a/Documentation/devicetree/bindings/power/wakeup-source.txt
+++ b/Documentation/devicetree/bindings/power/wakeup-source.txt
@@ -22,7 +22,7 @@ List of legacy properties and respective binding document
 3. "has-tpo"			Documentation/devicetree/bindings/rtc/rtc-opal.txt
 4. "linux,wakeup"		Documentation/devicetree/bindings/input/gpio-matrix-keypad.txt
 				Documentation/devicetree/bindings/mfd/tc3589x.txt
-				Documentation/devicetree/bindings/input/ads7846.txt
+				Documentation/devicetree/bindings/input/touchscreen/ads7846.txt
 5. "linux,keypad-wakeup"	Documentation/devicetree/bindings/input/qcom,pm8xxx-keypad.txt
 6. "linux,input-wakeup"		Documentation/devicetree/bindings/input/samsung-keypad.txt
 7. "nvidia,wakeup-source"	Documentation/devicetree/bindings/input/nvidia,tegra20-kbc.txt
diff --git a/Documentation/devicetree/bindings/usb/rockchip,dwc3.txt b/Documentation/devicetree/bindings/usb/rockchip,dwc3.txt
index 50a31536e975..252a05c5d976 100644
--- a/Documentation/devicetree/bindings/usb/rockchip,dwc3.txt
+++ b/Documentation/devicetree/bindings/usb/rockchip,dwc3.txt
@@ -16,7 +16,7 @@ A child node must exist to represent the core DWC3 IP block. The name of
 the node is not important. The content of the node is defined in dwc3.txt.
 
 Phy documentation is provided in the following places:
-Documentation/devicetree/bindings/phy/rockchip,dwc3-usb-phy.txt
+Documentation/devicetree/bindings/phy/qcom-dwc3-usb-phy.txt
 
 Example device nodes:
 
diff --git a/Documentation/hwmon/ina2xx b/Documentation/hwmon/ina2xx
index cfd31d94c872..72d16f08e431 100644
--- a/Documentation/hwmon/ina2xx
+++ b/Documentation/hwmon/ina2xx
@@ -53,7 +53,7 @@ bus supply voltage.
 
 The shunt value in micro-ohms can be set via platform data or device tree at
 compile-time or via the shunt_resistor attribute in sysfs at run-time. Please
-refer to the Documentation/devicetree/bindings/i2c/ina2xx.txt for bindings
+refer to the Documentation/devicetree/bindings/hwmon/ina2xx.txt for bindings
 if the device tree is used.
 
 Additionally ina226 supports update_interval attribute as described in
diff --git a/Documentation/maintainer/pull-requests.rst b/Documentation/maintainer/pull-requests.rst
index a19db3458b56..22b271de0304 100644
--- a/Documentation/maintainer/pull-requests.rst
+++ b/Documentation/maintainer/pull-requests.rst
@@ -41,7 +41,7 @@ named ``char-misc-next``, you would be using the following command::
 
 that will create a signed tag called ``char-misc-4.15-rc1`` based on the
 last commit in the ``char-misc-next`` branch, and sign it with your gpg key
-(see :ref:`Documentation/maintainer/configure_git.rst <configuregit>`).
+(see :ref:`Documentation/maintainer/configure-git.rst <configuregit>`).
 
 Linus will only accept pull requests based on a signed tag. Other
 maintainers may differ.
diff --git a/Documentation/translations/ko_KR/howto.rst b/Documentation/translations/ko_KR/howto.rst
index 624654bdcd8a..a8197e072599 100644
--- a/Documentation/translations/ko_KR/howto.rst
+++ b/Documentation/translations/ko_KR/howto.rst
@@ -160,7 +160,7 @@ mtk.manpages at gmail.com? ??????? ?? ?? ????.
     ??? ??? ??? ?? ?? ???? ???? ???? ??
     ????.
 
-  :ref:`Documentation/process/stable_kernel_rules.rst <stable_kernel_rules>`
+  :ref:`Documentation/process/stable-kernel-rules.rst <stable_kernel_rules>`
     ? ??? ???? ?? ??? ????? ??? ???? ???
     ????? ??? ??? ? ??? ??? ?? ????
     ??? ?? ???? ????.
diff --git a/MAINTAINERS b/MAINTAINERS
index ec65e33e2cf1..5871dd5060f6 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4513,7 +4513,7 @@ DRM DRIVER FOR ILITEK ILI9225 PANELS
 M:	David Lechner <david@lechnology.com>
 S:	Maintained
 F:	drivers/gpu/drm/tinydrm/ili9225.c
-F:	Documentation/devicetree/bindings/display/ili9225.txt
+F:	Documentation/devicetree/bindings/display/ilitek,ili9225.txt
 
 DRM DRIVER FOR INTEL I810 VIDEO CARDS
 S:	Orphan / Obsolete
@@ -4599,13 +4599,13 @@ DRM DRIVER FOR SITRONIX ST7586 PANELS
 M:	David Lechner <david@lechnology.com>
 S:	Maintained
 F:	drivers/gpu/drm/tinydrm/st7586.c
-F:	Documentation/devicetree/bindings/display/st7586.txt
+F:	Documentation/devicetree/bindings/display/sitronix,st7586.txt
 
 DRM DRIVER FOR SITRONIX ST7735R PANELS
 M:	David Lechner <david@lechnology.com>
 S:	Maintained
 F:	drivers/gpu/drm/tinydrm/st7735r.c
-F:	Documentation/devicetree/bindings/display/st7735r.txt
+F:	Documentation/devicetree/bindings/display/sitronix,st7735r.txt
 
 DRM DRIVER FOR TDFX VIDEO CARDS
 S:	Orphan / Obsolete
@@ -4824,7 +4824,7 @@ M:	Eric Anholt <eric@anholt.net>
 S:	Supported
 F:	drivers/gpu/drm/v3d/
 F:	include/uapi/drm/v3d_drm.h
-F:	Documentation/devicetree/bindings/display/brcm,bcm-v3d.txt
+F:	Documentation/devicetree/bindings/gpu/brcm,bcm-v3d.txt
 T:	git git://anongit.freedesktop.org/drm/drm-misc
 
 DRM DRIVERS FOR VC4
@@ -5735,7 +5735,7 @@ M:	Madalin Bucur <madalin.bucur@nxp.com>
 L:	netdev at vger.kernel.org
 S:	Maintained
 F:	drivers/net/ethernet/freescale/fman
-F:	Documentation/devicetree/bindings/powerpc/fsl/fman.txt
+F:	Documentation/devicetree/bindings/net/fsl-fman.txt
 
 FREESCALE QORIQ PTP CLOCK DRIVER
 M:	Yangbo Lu <yangbo.lu@nxp.com>
@@ -8700,7 +8700,7 @@ M:	Guenter Roeck <linux@roeck-us.net>
 L:	linux-hwmon at vger.kernel.org
 S:	Maintained
 F:	Documentation/hwmon/max6697
-F:	Documentation/devicetree/bindings/i2c/max6697.txt
+F:	Documentation/devicetree/bindings/hwmon/max6697.txt
 F:	drivers/hwmon/max6697.c
 F:	include/linux/platform_data/max6697.h
 
@@ -9080,7 +9080,7 @@ M:	Martin Donnelly <martin.donnelly@ge.com>
 M:	Martyn Welch <martyn.welch@collabora.co.uk>
 S:	Maintained
 F:	drivers/gpu/drm/bridge/megachips-stdpxxxx-ge-b850v3-fw.c
-F:	Documentation/devicetree/bindings/video/bridge/megachips-stdpxxxx-ge-b850v3-fw.txt
+F:	Documentation/devicetree/bindings/display/bridge/megachips-stdpxxxx-ge-b850v3-fw.txt
 
 MEGARAID SCSI/SAS DRIVERS
 M:	Kashyap Desai <kashyap.desai@broadcom.com>
@@ -10728,7 +10728,7 @@ PARALLEL LCD/KEYPAD PANEL DRIVER
 M:	Willy Tarreau <willy@haproxy.com>
 M:	Ksenija Stanojevic <ksenija.stanojevic@gmail.com>
 S:	Odd Fixes
-F:	Documentation/misc-devices/lcd-panel-cgram.txt
+F:	Documentation/auxdisplay/lcd-panel-cgram.txt
 F:	drivers/misc/panel.c
 
 PARALLEL PORT SUBSYSTEM
@@ -13291,7 +13291,7 @@ M:	Vinod Koul <vkoul@kernel.org>
 L:	alsa-devel at alsa-project.org (moderated for non-subscribers)
 T:	git git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git
 S:	Supported
-F:	Documentation/sound/alsa/compress_offload.txt
+F:	Documentation/sound/designs/compress-offload.rst
 F:	include/sound/compress_driver.h
 F:	include/uapi/sound/compress_*
 F:	sound/core/compress_offload.c
diff --git a/drivers/net/ethernet/intel/Kconfig b/drivers/net/ethernet/intel/Kconfig
index 14d287bed33c..1ab613eb5796 100644
--- a/drivers/net/ethernet/intel/Kconfig
+++ b/drivers/net/ethernet/intel/Kconfig
@@ -33,7 +33,7 @@ config E100
 	  to identify the adapter.
 
 	  More specific information on configuring the driver is in
-	  <file:Documentation/networking/e100.txt>.
+	  <file:Documentation/networking/e100.rst>.
 
 	  To compile this driver as a module, choose M here. The module
 	  will be called e100.
@@ -49,7 +49,7 @@ config E1000
 	  <http://support.intel.com>
 
 	  More specific information on configuring the driver is in
-	  <file:Documentation/networking/e1000.txt>.
+	  <file:Documentation/networking/e1000.rst>.
 
 	  To compile this driver as a module, choose M here. The module
 	  will be called e1000.
@@ -94,7 +94,7 @@ config IGB
 	  <http://support.intel.com>
 
 	  More specific information on configuring the driver is in
-	  <file:Documentation/networking/e1000.txt>.
+	  <file:Documentation/networking/e1000.rst>.
 
 	  To compile this driver as a module, choose M here. The module
 	  will be called igb.
@@ -130,7 +130,7 @@ config IGBVF
 	  <http://support.intel.com>
 
 	  More specific information on configuring the driver is in
-	  <file:Documentation/networking/e1000.txt>.
+	  <file:Documentation/networking/e1000.rst>.
 
 	  To compile this driver as a module, choose M here. The module
 	  will be called igbvf.
diff --git a/drivers/soundwire/stream.c b/drivers/soundwire/stream.c
index 8974a0fcda1b..4b5e250e8615 100644
--- a/drivers/soundwire/stream.c
+++ b/drivers/soundwire/stream.c
@@ -1291,7 +1291,7 @@ static int _sdw_prepare_stream(struct sdw_stream_runtime *stream)
  *
  * @stream: Soundwire stream
  *
- * Documentation/soundwire/stream.txt explains this API in detail
+ * Documentation/driver-api/soundwire/stream.rst explains this API in detail
  */
 int sdw_prepare_stream(struct sdw_stream_runtime *stream)
 {
@@ -1348,7 +1348,7 @@ static int _sdw_enable_stream(struct sdw_stream_runtime *stream)
  *
  * @stream: Soundwire stream
  *
- * Documentation/soundwire/stream.txt explains this API in detail
+ * Documentation/driver-api/soundwire/stream.rst explains this API in detail
  */
 int sdw_enable_stream(struct sdw_stream_runtime *stream)
 {
@@ -1400,7 +1400,7 @@ static int _sdw_disable_stream(struct sdw_stream_runtime *stream)
  *
  * @stream: Soundwire stream
  *
- * Documentation/soundwire/stream.txt explains this API in detail
+ * Documentation/driver-api/soundwire/stream.rst explains this API in detail
  */
 int sdw_disable_stream(struct sdw_stream_runtime *stream)
 {
@@ -1456,7 +1456,7 @@ static int _sdw_deprepare_stream(struct sdw_stream_runtime *stream)
  *
  * @stream: Soundwire stream
  *
- * Documentation/soundwire/stream.txt explains this API in detail
+ * Documentation/driver-api/soundwire/stream.rst explains this API in detail
  */
 int sdw_deprepare_stream(struct sdw_stream_runtime *stream)
 {
diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
index 57a27c42b5ac..56df483de619 100644
--- a/fs/Kconfig.binfmt
+++ b/fs/Kconfig.binfmt
@@ -168,7 +168,7 @@ config BINFMT_MISC
 	  will automatically feed it to the correct interpreter.
 
 	  You can do other nice things, too. Read the file
-	  <file:Documentation/binfmt_misc.txt> to learn how to use this
+	  <file:Documentation/admin-guide/binfmt-misc.rst> to learn how to use this
 	  feature, <file:Documentation/admin-guide/java.rst> for information about how
 	  to include Java support. and <file:Documentation/admin-guide/mono.rst> for
           information about how to include Mono-based .NET support.
diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c
index 4de191563261..4b5fff31ef27 100644
--- a/fs/binfmt_misc.c
+++ b/fs/binfmt_misc.c
@@ -4,7 +4,7 @@
  * Copyright (C) 1997 Richard G?nther
  *
  * binfmt_misc detects binaries via a magic or filename extension and invokes
- * a specified wrapper. See Documentation/binfmt_misc.txt for more details.
+ * a specified wrapper. See Documentation/admin-guide/binfmt-misc.rst for more details.
  */
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-- 
2.17.1

^ permalink raw reply related

* [PATCH v3 05/27] docs: Fix some broken references
From: Mauro Carvalho Chehab @ 2018-06-14 16:08 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <cover.1528990947.git.mchehab+samsung@kernel.org>

As we move stuff around, some doc references are broken. Fix some of
them via this script:
	./scripts/documentation-file-ref-check --fix

Manually checked if the produced result is valid, removing a few
false-positives.

Acked-by: Takashi Iwai <tiwai@suse.de>
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Acked-by: Stephen Boyd <sboyd@kernel.org>
Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Acked-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
---
 .../admin-guide/kernel-parameters.txt         |  4 ++--
 .../bindings/input/rotary-encoder.txt         |  2 +-
 Documentation/driver-api/gpio/consumer.rst    |  2 +-
 Documentation/kprobes.txt                     |  4 ++--
 Documentation/trace/coresight.txt             |  2 +-
 Documentation/trace/ftrace-uses.rst           |  2 +-
 Documentation/trace/histogram.txt             |  2 +-
 Documentation/trace/intel_th.rst              |  2 +-
 Documentation/trace/tracepoint-analysis.rst   |  6 +++---
 Documentation/translations/ja_JP/howto.rst    |  4 ++--
 .../translations/zh_CN/magic-number.txt       |  4 ++--
 .../zh_CN/video4linux/omap3isp.txt            |  4 ++--
 MAINTAINERS                                   | 20 +++++++++----------
 arch/Kconfig                                  |  2 +-
 arch/arm/include/asm/cacheflush.h             |  2 +-
 arch/arm64/include/asm/cacheflush.h           |  2 +-
 arch/microblaze/include/asm/cacheflush.h      |  2 +-
 arch/um/Kconfig.um                            |  2 +-
 arch/unicore32/include/asm/cacheflush.h       |  2 +-
 arch/x86/entry/vsyscall/vsyscall_64.c         |  2 +-
 arch/xtensa/include/asm/cacheflush.h          |  4 ++--
 block/Kconfig                                 |  2 +-
 certs/Kconfig                                 |  2 +-
 crypto/asymmetric_keys/asymmetric_type.c      |  2 +-
 crypto/asymmetric_keys/signature.c            |  2 +-
 drivers/char/Kconfig                          |  2 +-
 drivers/clk/clk.c                             |  4 ++--
 drivers/clk/ingenic/cgu.h                     |  2 +-
 drivers/gpu/vga/Kconfig                       |  2 +-
 drivers/gpu/vga/vgaarb.c                      |  2 +-
 drivers/input/joystick/Kconfig                | 10 +++++-----
 drivers/input/joystick/walkera0701.c          |  2 +-
 drivers/input/misc/Kconfig                    |  4 ++--
 drivers/input/misc/rotary_encoder.c           |  2 +-
 drivers/input/mouse/Kconfig                   |  6 +++---
 drivers/input/mouse/alps.c                    |  2 +-
 drivers/input/touchscreen/wm97xx-core.c       |  2 +-
 drivers/lightnvm/pblk-rb.c                    |  2 +-
 drivers/md/bcache/Kconfig                     |  2 +-
 drivers/md/bcache/btree.c                     |  2 +-
 drivers/md/bcache/extents.c                   |  2 +-
 drivers/media/dvb-core/dvb_ringbuffer.c       |  2 +-
 drivers/media/pci/meye/Kconfig                |  2 +-
 drivers/media/platform/pxa_camera.c           |  4 ++--
 .../soc_camera/sh_mobile_ceu_camera.c         |  2 +-
 drivers/media/radio/Kconfig                   |  2 +-
 drivers/media/radio/si470x/Kconfig            |  2 +-
 drivers/media/usb/dvb-usb-v2/lmedm04.c        |  2 +-
 drivers/media/usb/zr364xx/Kconfig             |  2 +-
 drivers/parport/Kconfig                       |  6 +++---
 drivers/staging/media/bcm2048/TODO            |  2 +-
 include/keys/asymmetric-subtype.h             |  2 +-
 include/keys/asymmetric-type.h                |  2 +-
 include/linux/assoc_array.h                   |  2 +-
 include/linux/assoc_array_priv.h              |  2 +-
 include/linux/circ_buf.h                      |  2 +-
 include/linux/ftrace.h                        |  2 +-
 include/linux/rculist_nulls.h                 |  2 +-
 include/uapi/linux/prctl.h                    |  2 +-
 include/xen/interface/io/kbdif.h              |  2 +-
 kernel/cgroup/cpuset.c                        |  2 +-
 kernel/trace/Kconfig                          | 16 +++++++--------
 lib/Kconfig                                   |  2 +-
 security/selinux/hooks.c                      |  2 +-
 sound/core/Kconfig                            |  4 ++--
 sound/drivers/Kconfig                         |  4 ++--
 sound/pci/Kconfig                             | 10 +++++-----
 tools/include/uapi/linux/prctl.h              |  2 +-
 tools/lib/api/fs/fs.c                         |  2 +-
 tools/perf/util/bpf-prologue.c                |  2 +-
 .../config/custom-timeline-functions.cfg      |  4 ++--
 71 files changed, 113 insertions(+), 113 deletions(-)

diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 638342d0a095..6fa3f31ed2a5 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -4335,7 +4335,7 @@
 			[FTRACE] Set and start specified trace events in order
 			to facilitate early boot debugging. The event-list is a
 			comma separated list of trace events to enable. See
-			also Documentation/trace/events.txt
+			also Documentation/trace/events.rst
 
 	trace_options=[option-list]
 			[FTRACE] Enable or disable tracer options at boot.
@@ -4350,7 +4350,7 @@
 
 			      trace_options=stacktrace
 
-			See also Documentation/trace/ftrace.txt "trace options"
+			See also Documentation/trace/ftrace.rst "trace options"
 			section.
 
 	tp_printk[FTRACE]
diff --git a/Documentation/devicetree/bindings/input/rotary-encoder.txt b/Documentation/devicetree/bindings/input/rotary-encoder.txt
index f99fe5cdeaec..a644408b33b8 100644
--- a/Documentation/devicetree/bindings/input/rotary-encoder.txt
+++ b/Documentation/devicetree/bindings/input/rotary-encoder.txt
@@ -28,7 +28,7 @@ Deprecated properties:
   This property is deprecated. Instead, a 'steps-per-period ' value should
   be used, such as "rotary-encoder,steps-per-period = <2>".
 
-See Documentation/input/rotary-encoder.txt for more information.
+See Documentation/input/devices/rotary-encoder.rst for more information.
 
 Example:
 
diff --git a/Documentation/driver-api/gpio/consumer.rst b/Documentation/driver-api/gpio/consumer.rst
index c71a50d85b50..aa03f389d41d 100644
--- a/Documentation/driver-api/gpio/consumer.rst
+++ b/Documentation/driver-api/gpio/consumer.rst
@@ -57,7 +57,7 @@ device that displays digits), an additional index argument can be specified::
 					  enum gpiod_flags flags)
 
 For a more detailed description of the con_id parameter in the DeviceTree case
-see Documentation/gpio/board.txt
+see Documentation/driver-api/gpio/board.rst
 
 The flags parameter is used to optionally specify a direction and initial value
 for the GPIO. Values can be:
diff --git a/Documentation/kprobes.txt b/Documentation/kprobes.txt
index 22208bf2386d..cb3b0de83fc6 100644
--- a/Documentation/kprobes.txt
+++ b/Documentation/kprobes.txt
@@ -724,8 +724,8 @@ migrate your tool to one of the following options:
 
   See following documents:
 
-  - Documentation/trace/kprobetrace.txt
-  - Documentation/trace/events.txt
+  - Documentation/trace/kprobetrace.rst
+  - Documentation/trace/events.rst
   - tools/perf/Documentation/perf-probe.txt
 
 
diff --git a/Documentation/trace/coresight.txt b/Documentation/trace/coresight.txt
index 1d74ad0202b6..efbc832146e7 100644
--- a/Documentation/trace/coresight.txt
+++ b/Documentation/trace/coresight.txt
@@ -426,5 +426,5 @@ root at genericarmv8:~#
 Details on how to use the generic STM API can be found here [2].
 
 [1]. Documentation/ABI/testing/sysfs-bus-coresight-devices-stm
-[2]. Documentation/trace/stm.txt
+[2]. Documentation/trace/stm.rst
 [3]. https://github.com/Linaro/perf-opencsd
diff --git a/Documentation/trace/ftrace-uses.rst b/Documentation/trace/ftrace-uses.rst
index 00283b6dd101..1fbc69894eed 100644
--- a/Documentation/trace/ftrace-uses.rst
+++ b/Documentation/trace/ftrace-uses.rst
@@ -199,7 +199,7 @@ If @buf is NULL and reset is set, all functions will be enabled for tracing.
 The @buf can also be a glob expression to enable all functions that
 match a specific pattern.
 
-See Filter Commands in :file:`Documentation/trace/ftrace.txt`.
+See Filter Commands in :file:`Documentation/trace/ftrace.rst`.
 
 To just trace the schedule function:
 
diff --git a/Documentation/trace/histogram.txt b/Documentation/trace/histogram.txt
index b13771cb12c1..e73bcf9cb5f3 100644
--- a/Documentation/trace/histogram.txt
+++ b/Documentation/trace/histogram.txt
@@ -7,7 +7,7 @@
 
   Histogram triggers are special event triggers that can be used to
   aggregate trace event data into histograms.  For information on
-  trace events and event triggers, see Documentation/trace/events.txt.
+  trace events and event triggers, see Documentation/trace/events.rst.
 
 
 2. Histogram Trigger Command
diff --git a/Documentation/trace/intel_th.rst b/Documentation/trace/intel_th.rst
index 990f13265178..19e2d633f3c7 100644
--- a/Documentation/trace/intel_th.rst
+++ b/Documentation/trace/intel_th.rst
@@ -38,7 +38,7 @@ description is at Documentation/ABI/testing/sysfs-bus-intel_th-devices-gth.
 
 STH registers an stm class device, through which it provides interface
 to userspace and kernelspace software trace sources. See
-Documentation/trace/stm.txt for more information on that.
+Documentation/trace/stm.rst for more information on that.
 
 MSU can be configured to collect trace data into a system memory
 buffer, which can later on be read from its device nodes via read() or
diff --git a/Documentation/trace/tracepoint-analysis.rst b/Documentation/trace/tracepoint-analysis.rst
index bef37abf4ad3..716326b9f152 100644
--- a/Documentation/trace/tracepoint-analysis.rst
+++ b/Documentation/trace/tracepoint-analysis.rst
@@ -55,7 +55,7 @@ simple case of::
 3.1 System-Wide Event Enabling
 ------------------------------
 
-See Documentation/trace/events.txt for a proper description on how events
+See Documentation/trace/events.rst for a proper description on how events
 can be enabled system-wide. A short example of enabling all events related
 to page allocation would look something like::
 
@@ -112,7 +112,7 @@ at that point.
 3.4 Local Event Enabling
 ------------------------
 
-Documentation/trace/ftrace.txt describes how to enable events on a per-thread
+Documentation/trace/ftrace.rst describes how to enable events on a per-thread
 basis using set_ftrace_pid.
 
 3.5 Local Event Enablement with PCL
@@ -137,7 +137,7 @@ basis using PCL such as follows.
 4. Event Filtering
 ==================
 
-Documentation/trace/ftrace.txt covers in-depth how to filter events in
+Documentation/trace/ftrace.rst covers in-depth how to filter events in
 ftrace.  Obviously using grep and awk of trace_pipe is an option as well
 as any script reading trace_pipe.
 
diff --git a/Documentation/translations/ja_JP/howto.rst b/Documentation/translations/ja_JP/howto.rst
index 8d7ed0cbbf5f..f3116381c26b 100644
--- a/Documentation/translations/ja_JP/howto.rst
+++ b/Documentation/translations/ja_JP/howto.rst
@@ -1,5 +1,5 @@
 NOTE:
-This is a version of Documentation/HOWTO translated into Japanese.
+This is a version of Documentation/process/howto.rst translated into Japanese.
 This document is maintained by Tsugikazu Shibata <tshibata@ab.jp.nec.com>
 If you find any difference between this document and the original file or
 a problem with the translation, please contact the maintainer of this file.
@@ -109,7 +109,7 @@ linux-api at vger.kernel.org ???????????
     ????? ???????????????????????????
     ?????
 
-  :ref:`Documentation/Process/changes.rst <changes>`
+  :ref:`Documentation/process/changes.rst <changes>`
     ?????????????????(?? build )?????????
     ????????????????????????????????
     ???
diff --git a/Documentation/translations/zh_CN/magic-number.txt b/Documentation/translations/zh_CN/magic-number.txt
index e9db693c0a23..7159cec04090 100644
--- a/Documentation/translations/zh_CN/magic-number.txt
+++ b/Documentation/translations/zh_CN/magic-number.txt
@@ -1,4 +1,4 @@
-Chinese translated version of Documentation/magic-number.txt
+Chinese translated version of Documentation/process/magic-number.rst
 
 If you have any comment or update to the content, please post to LKML directly.
 However, if you have problem communicating in English you can also ask the
@@ -7,7 +7,7 @@ translation is outdated or there is problem with translation.
 
 Chinese maintainer: Jia Wei Wei <harryxiyou@gmail.com>
 ---------------------------------------------------------------------
-Documentation/magic-number.txt?????
+Documentation/process/magic-number.rst?????
 
 ????????????????????LKML??????????????????
 ????????????????????????????????????????
diff --git a/Documentation/translations/zh_CN/video4linux/omap3isp.txt b/Documentation/translations/zh_CN/video4linux/omap3isp.txt
index 67ffbf352ae0..e9f29375aa95 100644
--- a/Documentation/translations/zh_CN/video4linux/omap3isp.txt
+++ b/Documentation/translations/zh_CN/video4linux/omap3isp.txt
@@ -1,4 +1,4 @@
-Chinese translated version of Documentation/video4linux/omap3isp.txt
+Chinese translated version of Documentation/media/v4l-drivers/omap3isp.rst
 
 If you have any comment or update to the content, please contact the
 original document maintainer directly.  However, if you have a problem
@@ -11,7 +11,7 @@ Maintainer: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
 	  David Cohen <dacohen@gmail.com>
 Chinese maintainer: Fu Wei <tekkamanninja@gmail.com>
 ---------------------------------------------------------------------
-Documentation/video4linux/omap3isp.txt ?????
+Documentation/media/v4l-drivers/omap3isp.rst ?????
 
 ??????????????????????????????????
 ??????????????????????????????????
diff --git a/MAINTAINERS b/MAINTAINERS
index 653a2c29ca43..09554034be46 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3079,7 +3079,7 @@ M:	Clemens Ladisch <clemens@ladisch.de>
 L:	alsa-devel at alsa-project.org (moderated for non-subscribers)
 T:	git git://git.alsa-project.org/alsa-kernel.git
 S:	Maintained
-F:	Documentation/sound/alsa/Bt87x.txt
+F:	Documentation/sound/cards/bt87x.rst
 F:	sound/pci/bt87x.c
 
 BT8XXGPIO DRIVER
@@ -3375,7 +3375,7 @@ M:	David Howells <dhowells@redhat.com>
 M:	David Woodhouse <dwmw2@infradead.org>
 L:	keyrings at vger.kernel.org
 S:	Maintained
-F:	Documentation/module-signing.txt
+F:	Documentation/admin-guide/module-signing.rst
 F:	certs/
 F:	scripts/sign-file.c
 F:	scripts/extract-cert.c
@@ -6501,7 +6501,7 @@ L:	linux-mm at kvack.org
 S:	Maintained
 F:	mm/hmm*
 F:	include/linux/hmm*
-F:	Documentation/vm/hmm.txt
+F:	Documentation/vm/hmm.rst
 
 HOST AP DRIVER
 M:	Jouni Malinen <j@w1.fi>
@@ -7401,7 +7401,7 @@ F:	drivers/platform/x86/intel-wmi-thunderbolt.c
 INTEL(R) TRACE HUB
 M:	Alexander Shishkin <alexander.shishkin@linux.intel.com>
 S:	Supported
-F:	Documentation/trace/intel_th.txt
+F:	Documentation/trace/intel_th.rst
 F:	drivers/hwtracing/intel_th/
 
 INTEL(R) TRUSTED EXECUTION TECHNOLOGY (TXT)
@@ -9665,7 +9665,7 @@ F:	include/uapi/linux/mmc/
 MULTIPLEXER SUBSYSTEM
 M:	Peter Rosin <peda@axentia.se>
 S:	Maintained
-F:	Documentation/ABI/testing/mux/sysfs-class-mux*
+F:	Documentation/ABI/testing/sysfs-class-mux*
 F:	Documentation/devicetree/bindings/mux/
 F:	include/linux/dt-bindings/mux/
 F:	include/linux/mux/
@@ -10244,7 +10244,7 @@ F:	arch/powerpc/include/asm/pnv-ocxl.h
 F:	drivers/misc/ocxl/
 F:	include/misc/ocxl*
 F:	include/uapi/misc/ocxl.h
-F:	Documentation/accelerators/ocxl.txt
+F:	Documentation/accelerators/ocxl.rst
 
 OMAP AUDIO SUPPORT
 M:	Peter Ujfalusi <peter.ujfalusi@ti.com>
@@ -13794,7 +13794,7 @@ SYSTEM TRACE MODULE CLASS
 M:	Alexander Shishkin <alexander.shishkin@linux.intel.com>
 S:	Maintained
 T:	git git://git.kernel.org/pub/scm/linux/kernel/git/ash/stm.git
-F:	Documentation/trace/stm.txt
+F:	Documentation/trace/stm.rst
 F:	drivers/hwtracing/stm/
 F:	include/linux/stm.h
 F:	include/uapi/linux/stm.h
@@ -14471,7 +14471,7 @@ M:	Steven Rostedt <rostedt@goodmis.org>
 M:	Ingo Molnar <mingo@redhat.com>
 T:	git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git perf/core
 S:	Maintained
-F:	Documentation/trace/ftrace.txt
+F:	Documentation/trace/ftrace.rst
 F:	arch/*/*/*/ftrace.h
 F:	arch/*/kernel/ftrace.c
 F:	include/*/ftrace.h
@@ -14940,7 +14940,7 @@ M:	Heikki Krogerus <heikki.krogerus@linux.intel.com>
 L:	linux-usb at vger.kernel.org
 S:	Maintained
 F:	Documentation/ABI/testing/sysfs-class-typec
-F:	Documentation/usb/typec.rst
+F:	Documentation/driver-api/usb/typec.rst
 F:	drivers/usb/typec/
 F:	include/linux/usb/typec.h
 
@@ -15770,7 +15770,7 @@ YEALINK PHONE DRIVER
 M:	Henk Vergonet <Henk.Vergonet@gmail.com>
 L:	usbb2k-api-dev at nongnu.org
 S:	Maintained
-F:	Documentation/input/yealink.rst
+F:	Documentation/input/devices/yealink.rst
 F:	drivers/input/misc/yealink.*
 
 Z8530 DRIVER FOR AX.25
diff --git a/arch/Kconfig b/arch/Kconfig
index c302b3dd0058..25e744c85bd3 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -403,7 +403,7 @@ config SECCOMP_FILTER
 	  in terms of Berkeley Packet Filter programs which implement
 	  task-defined system call filtering polices.
 
-	  See Documentation/prctl/seccomp_filter.txt for details.
+	  See Documentation/userspace-api/seccomp_filter.rst for details.
 
 preferred-plugin-hostcc := $(if-success,[ $(gcc-version) -ge 40800 ],$(HOSTCXX),$(HOSTCC))
 
diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h
index 869080bedb89..ec1a5fd0d294 100644
--- a/arch/arm/include/asm/cacheflush.h
+++ b/arch/arm/include/asm/cacheflush.h
@@ -35,7 +35,7 @@
  *	Start addresses are inclusive and end addresses are exclusive;
  *	start addresses should be rounded down, end addresses up.
  *
- *	See Documentation/cachetlb.txt for more information.
+ *	See Documentation/core-api/cachetlb.rst for more information.
  *	Please note that the implementation of these, and the required
  *	effects are cache-type (VIVT/VIPT/PIPT) specific.
  *
diff --git a/arch/arm64/include/asm/cacheflush.h b/arch/arm64/include/asm/cacheflush.h
index 0094c6653b06..d264a7274811 100644
--- a/arch/arm64/include/asm/cacheflush.h
+++ b/arch/arm64/include/asm/cacheflush.h
@@ -36,7 +36,7 @@
  *	Start addresses are inclusive and end addresses are exclusive; start
  *	addresses should be rounded down, end addresses up.
  *
- *	See Documentation/cachetlb.txt for more information. Please note that
+ *	See Documentation/core-api/cachetlb.rst for more information. Please note that
  *	the implementation assumes non-aliasing VIPT D-cache and (aliasing)
  *	VIPT I-cache.
  *
diff --git a/arch/microblaze/include/asm/cacheflush.h b/arch/microblaze/include/asm/cacheflush.h
index ffea82a16d2c..b091de77b15b 100644
--- a/arch/microblaze/include/asm/cacheflush.h
+++ b/arch/microblaze/include/asm/cacheflush.h
@@ -19,7 +19,7 @@
 #include <linux/mm.h>
 #include <linux/io.h>
 
-/* Look at Documentation/cachetlb.txt */
+/* Look at Documentation/core-api/cachetlb.rst */
 
 /*
  * Cache handling functions.
diff --git a/arch/um/Kconfig.um b/arch/um/Kconfig.um
index 3e7f228b22e1..20da5a8ca949 100644
--- a/arch/um/Kconfig.um
+++ b/arch/um/Kconfig.um
@@ -80,7 +80,7 @@ config MAGIC_SYSRQ
 	  On UML, this is accomplished by sending a "sysrq" command with
 	  mconsole, followed by the letter for the requested command.
 
-	  The keys are documented in <file:Documentation/sysrq.txt>. Don't say Y
+	  The keys are documented in <file:Documentation/admin-guide/sysrq.rst>. Don't say Y
 	  unless you really know what this hack does.
 
 config KERNEL_STACK_ORDER
diff --git a/arch/unicore32/include/asm/cacheflush.h b/arch/unicore32/include/asm/cacheflush.h
index 1d9132b66039..1c8b9f13a9e1 100644
--- a/arch/unicore32/include/asm/cacheflush.h
+++ b/arch/unicore32/include/asm/cacheflush.h
@@ -33,7 +33,7 @@
  *	Start addresses are inclusive and end addresses are exclusive;
  *	start addresses should be rounded down, end addresses up.
  *
- *	See Documentation/cachetlb.txt for more information.
+ *	See Documentation/core-api/cachetlb.rst for more information.
  *	Please note that the implementation of these, and the required
  *	effects are cache-type (VIVT/VIPT/PIPT) specific.
  *
diff --git a/arch/x86/entry/vsyscall/vsyscall_64.c b/arch/x86/entry/vsyscall/vsyscall_64.c
index 7782cdbcd67d..82ed001e8909 100644
--- a/arch/x86/entry/vsyscall/vsyscall_64.c
+++ b/arch/x86/entry/vsyscall/vsyscall_64.c
@@ -201,7 +201,7 @@ bool emulate_vsyscall(struct pt_regs *regs, unsigned long address)
 
 	/*
 	 * Handle seccomp.  regs->ip must be the original value.
-	 * See seccomp_send_sigsys and Documentation/prctl/seccomp_filter.txt.
+	 * See seccomp_send_sigsys and Documentation/userspace-api/seccomp_filter.rst.
 	 *
 	 * We could optimize the seccomp disabled case, but performance
 	 * here doesn't matter.
diff --git a/arch/xtensa/include/asm/cacheflush.h b/arch/xtensa/include/asm/cacheflush.h
index 397d6a1a4224..a0d50be5a8cb 100644
--- a/arch/xtensa/include/asm/cacheflush.h
+++ b/arch/xtensa/include/asm/cacheflush.h
@@ -88,7 +88,7 @@ static inline void __invalidate_icache_page_alias(unsigned long virt,
  *
  * Pages can get remapped. Because this might change the 'color' of that page,
  * we have to flush the cache before the PTE is changed.
- * (see also Documentation/cachetlb.txt)
+ * (see also Documentation/core-api/cachetlb.rst)
  */
 
 #if defined(CONFIG_MMU) && \
@@ -152,7 +152,7 @@ void local_flush_cache_page(struct vm_area_struct *vma,
 		__invalidate_icache_range(start,(end) - (start));	\
 	} while (0)
 
-/* This is not required, see Documentation/cachetlb.txt */
+/* This is not required, see Documentation/core-api/cachetlb.rst */
 #define	flush_icache_page(vma,page)			do { } while (0)
 
 #define flush_dcache_mmap_lock(mapping)			do { } while (0)
diff --git a/block/Kconfig b/block/Kconfig
index 28ec55752b68..eb50fd4977c2 100644
--- a/block/Kconfig
+++ b/block/Kconfig
@@ -114,7 +114,7 @@ config BLK_DEV_THROTTLING
 	one needs to mount and use blkio cgroup controller for creating
 	cgroups and specifying per device IO rate policies.
 
-	See Documentation/cgroups/blkio-controller.txt for more information.
+	See Documentation/cgroup-v1/blkio-controller.txt for more information.
 
 config BLK_DEV_THROTTLING_LOW
 	bool "Block throttling .low limit interface support (EXPERIMENTAL)"
diff --git a/certs/Kconfig b/certs/Kconfig
index 5f7663df6e8e..c94e93d8bccf 100644
--- a/certs/Kconfig
+++ b/certs/Kconfig
@@ -13,7 +13,7 @@ config MODULE_SIG_KEY
 
          If this option is unchanged from its default "certs/signing_key.pem",
          then the kernel will automatically generate the private key and
-         certificate as described in Documentation/module-signing.txt
+         certificate as described in Documentation/admin-guide/module-signing.rst
 
 config SYSTEM_TRUSTED_KEYRING
 	bool "Provide system-wide ring of trusted keys"
diff --git a/crypto/asymmetric_keys/asymmetric_type.c b/crypto/asymmetric_keys/asymmetric_type.c
index 39aecad286fe..26539e9a8bda 100644
--- a/crypto/asymmetric_keys/asymmetric_type.c
+++ b/crypto/asymmetric_keys/asymmetric_type.c
@@ -1,6 +1,6 @@
 /* Asymmetric public-key cryptography key type
  *
- * See Documentation/security/asymmetric-keys.txt
+ * See Documentation/crypto/asymmetric-keys.txt
  *
  * Copyright (C) 2012 Red Hat, Inc. All Rights Reserved.
  * Written by David Howells (dhowells at redhat.com)
diff --git a/crypto/asymmetric_keys/signature.c b/crypto/asymmetric_keys/signature.c
index 11b7ba170904..28198314bc39 100644
--- a/crypto/asymmetric_keys/signature.c
+++ b/crypto/asymmetric_keys/signature.c
@@ -1,6 +1,6 @@
 /* Signature verification with an asymmetric key
  *
- * See Documentation/security/asymmetric-keys.txt
+ * See Documentation/crypto/asymmetric-keys.txt
  *
  * Copyright (C) 2012 Red Hat, Inc. All Rights Reserved.
  * Written by David Howells (dhowells at redhat.com)
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index 410c30c42120..212f447938ae 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -81,7 +81,7 @@ config PRINTER
 	  corresponding drivers into the kernel.
 
 	  To compile this driver as a module, choose M here and read
-	  <file:Documentation/parport.txt>.  The module will be called lp.
+	  <file:Documentation/admin-guide/parport.rst>.  The module will be called lp.
 
 	  If you have several parallel ports, you can specify which ports to
 	  use with the "lp" kernel command line option.  (Try "man bootparam"
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index a24a6afb50b6..9760b526ca31 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -6,7 +6,7 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  *
- * Standard functionality for the common clock API.  See Documentation/clk.txt
+ * Standard functionality for the common clock API.  See Documentation/driver-api/clk.rst
  */
 
 #include <linux/clk.h>
@@ -2747,7 +2747,7 @@ static int __clk_core_init(struct clk_core *core)
 		goto out;
 	}
 
-	/* check that clk_ops are sane.  See Documentation/clk.txt */
+	/* check that clk_ops are sane.  See Documentation/driver-api/clk.rst */
 	if (core->ops->set_rate &&
 	    !((core->ops->round_rate || core->ops->determine_rate) &&
 	      core->ops->recalc_rate)) {
diff --git a/drivers/clk/ingenic/cgu.h b/drivers/clk/ingenic/cgu.h
index 542192376ebf..502bcbb61b04 100644
--- a/drivers/clk/ingenic/cgu.h
+++ b/drivers/clk/ingenic/cgu.h
@@ -194,7 +194,7 @@ struct ingenic_cgu {
 
 /**
  * struct ingenic_clk - private data for a clock
- * @hw: see Documentation/clk.txt
+ * @hw: see Documentation/driver-api/clk.rst
  * @cgu: a pointer to the CGU data
  * @idx: the index of this clock in cgu->clock_info
  */
diff --git a/drivers/gpu/vga/Kconfig b/drivers/gpu/vga/Kconfig
index 29437eabe095..b677e5d524e6 100644
--- a/drivers/gpu/vga/Kconfig
+++ b/drivers/gpu/vga/Kconfig
@@ -6,7 +6,7 @@ config VGA_ARB
 	  Some "legacy" VGA devices implemented on PCI typically have the same
 	  hard-decoded addresses as they did on ISA. When multiple PCI devices
 	  are accessed at same time they need some kind of coordination. Please
-	  see Documentation/vgaarbiter.txt for more details. Select this to
+	  see Documentation/gpu/vgaarbiter.rst for more details. Select this to
 	  enable VGA arbiter.
 
 config VGA_ARB_MAX_GPUS
diff --git a/drivers/gpu/vga/vgaarb.c b/drivers/gpu/vga/vgaarb.c
index 1c5e74cb9279..c61b04555779 100644
--- a/drivers/gpu/vga/vgaarb.c
+++ b/drivers/gpu/vga/vgaarb.c
@@ -1,6 +1,6 @@
 /*
  * vgaarb.c: Implements the VGA arbitration. For details refer to
- * Documentation/vgaarbiter.txt
+ * Documentation/gpu/vgaarbiter.rst
  *
  *
  * (C) Copyright 2005 Benjamin Herrenschmidt <benh@kernel.crashing.org>
diff --git a/drivers/input/joystick/Kconfig b/drivers/input/joystick/Kconfig
index 32ec4cee6716..d8f9c6e1fc08 100644
--- a/drivers/input/joystick/Kconfig
+++ b/drivers/input/joystick/Kconfig
@@ -214,7 +214,7 @@ config JOYSTICK_DB9
 	  gamepad, Sega Saturn gamepad, or a Multisystem -- Atari, Amiga,
 	  Commodore, Amstrad CPC joystick connected to your parallel port.
 	  For more information on how to use the driver please read
-	  <file:Documentation/input/joystick-parport.txt>.
+	  <file:Documentation/input/devices/joystick-parport.rst>.
 
 	  To compile this driver as a module, choose M here: the
 	  module will be called db9.
@@ -229,7 +229,7 @@ config JOYSTICK_GAMECON
 	  Sony PlayStation gamepad or a Multisystem -- Atari, Amiga,
 	  Commodore, Amstrad CPC joystick connected to your parallel port.
 	  For more information on how to use the driver please read
-	  <file:Documentation/input/joystick-parport.txt>.
+	  <file:Documentation/input/devices/joystick-parport.rst>.
 
 	  To compile this driver as a module, choose M here: the
 	  module will be called gamecon.
@@ -241,7 +241,7 @@ config JOYSTICK_TURBOGRAFX
 	  Say Y here if you have the TurboGraFX interface by Steffen Schwenke,
 	  and want to use it with Multisystem -- Atari, Amiga, Commodore,
 	  Amstrad CPC joystick. For more information on how to use the driver
-	  please read <file:Documentation/input/joystick-parport.txt>.
+	  please read <file:Documentation/input/devices/joystick-parport.rst>.
 
 	  To compile this driver as a module, choose M here: the
 	  module will be called turbografx.
@@ -287,7 +287,7 @@ config JOYSTICK_XPAD
 	  and/or "Event interface support" (CONFIG_INPUT_EVDEV) as well.
 
 	  For information about how to connect the X-Box pad to USB, see
-	  <file:Documentation/input/xpad.txt>.
+	  <file:Documentation/input/devices/xpad.rst>.
 
 	  To compile this driver as a module, choose M here: the
 	  module will be called xpad.
@@ -313,7 +313,7 @@ config JOYSTICK_WALKERA0701
 	  Say Y or M here if you have a Walkera WK-0701 transmitter which is
 	  supplied with a ready to fly Walkera helicopters such as HM36,
 	  HM37, HM60 and want to use it via parport as a joystick. More
-	  information is available: <file:Documentation/input/walkera0701.txt>
+	  information is available: <file:Documentation/input/devices/walkera0701.rst>
 
 	  To compile this driver as a module, choose M here: the
 	  module will be called walkera0701.
diff --git a/drivers/input/joystick/walkera0701.c b/drivers/input/joystick/walkera0701.c
index 36a5b93156ed..dce313dc260a 100644
--- a/drivers/input/joystick/walkera0701.c
+++ b/drivers/input/joystick/walkera0701.c
@@ -3,7 +3,7 @@
  *
  *  Copyright (c) 2008 Peter Popovec
  *
- *  More about driver:  <file:Documentation/input/walkera0701.txt>
+ *  More about driver:  <file:Documentation/input/devices/walkera0701.rst>
  */
 
 /*
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 572b15fa18c2..c25606e00693 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -411,7 +411,7 @@ config INPUT_YEALINK
 	  usb sound driver, so you might want to enable that as well.
 
 	  For information about how to use these additional functions, see
-	  <file:Documentation/input/yealink.txt>.
+	  <file:Documentation/input/devices/yealink.rst>.
 
 	  To compile this driver as a module, choose M here: the module will be
 	  called yealink.
@@ -595,7 +595,7 @@ config INPUT_GPIO_ROTARY_ENCODER
 	depends on GPIOLIB || COMPILE_TEST
 	help
 	  Say Y here to add support for rotary encoders connected to GPIO lines.
-	  Check file:Documentation/input/rotary-encoder.txt for more
+	  Check file:Documentation/input/devices/rotary-encoder.rst for more
 	  information.
 
 	  To compile this driver as a module, choose M here: the
diff --git a/drivers/input/misc/rotary_encoder.c b/drivers/input/misc/rotary_encoder.c
index 6d304381fc30..30ec77ad32c6 100644
--- a/drivers/input/misc/rotary_encoder.c
+++ b/drivers/input/misc/rotary_encoder.c
@@ -7,7 +7,7 @@
  * state machine code inspired by code from Tim Ruetz
  *
  * A generic driver for rotary encoders connected to GPIO lines.
- * See file:Documentation/input/rotary-encoder.txt for more information
+ * See file:Documentation/input/devices/rotary-encoder.rst for more information
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
diff --git a/drivers/input/mouse/Kconfig b/drivers/input/mouse/Kconfig
index f27f23f2d99a..566a1e3aa504 100644
--- a/drivers/input/mouse/Kconfig
+++ b/drivers/input/mouse/Kconfig
@@ -129,7 +129,7 @@ config MOUSE_PS2_ELANTECH
 
 	  This driver exposes some configuration registers via sysfs
 	  entries. For further information,
-	  see <file:Documentation/input/elantech.txt>.
+	  see <file:Documentation/input/devices/elantech.rst>.
 
 	  If unsure, say N.
 
@@ -228,7 +228,7 @@ config MOUSE_APPLETOUCH
 	  scrolling in X11.
 
 	  For further information, see
-	  <file:Documentation/input/appletouch.txt>.
+	  <file:Documentation/input/devices/appletouch.rst>.
 
 	  To compile this driver as a module, choose M here: the
 	  module will be called appletouch.
@@ -251,7 +251,7 @@ config MOUSE_BCM5974
 
 	  The interface is currently identical to the appletouch interface,
 	  for further information, see
-	  <file:Documentation/input/appletouch.txt>.
+	  <file:Documentation/input/devices/appletouch.rst>.
 
 	  To compile this driver as a module, choose M here: the
 	  module will be called bcm5974.
diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c
index cb5579716dba..0a6f7ca883e7 100644
--- a/drivers/input/mouse/alps.c
+++ b/drivers/input/mouse/alps.c
@@ -212,7 +212,7 @@ static void alps_set_abs_params_v7(struct alps_data *priv,
 static void alps_set_abs_params_ss4_v2(struct alps_data *priv,
 				       struct input_dev *dev1);
 
-/* Packet formats are described in Documentation/input/alps.txt */
+/* Packet formats are described in Documentation/input/devices/alps.rst */
 
 static bool alps_is_valid_first_byte(struct alps_data *priv,
 				     unsigned char data)
diff --git a/drivers/input/touchscreen/wm97xx-core.c b/drivers/input/touchscreen/wm97xx-core.c
index fd714ee881f7..2566b4d8b342 100644
--- a/drivers/input/touchscreen/wm97xx-core.c
+++ b/drivers/input/touchscreen/wm97xx-core.c
@@ -68,7 +68,7 @@
  * The default values correspond to Mainstone II in QVGA mode
  *
  * Please read
- * Documentation/input/input-programming.txt for more details.
+ * Documentation/input/input-programming.rst for more details.
  */
 
 static int abs_x[3] = {150, 4000, 5};
diff --git a/drivers/lightnvm/pblk-rb.c b/drivers/lightnvm/pblk-rb.c
index 00cd1f20a196..55e9442a99e2 100644
--- a/drivers/lightnvm/pblk-rb.c
+++ b/drivers/lightnvm/pblk-rb.c
@@ -38,7 +38,7 @@ void pblk_rb_data_free(struct pblk_rb *rb)
 /*
  * Initialize ring buffer. The data and metadata buffers must be previously
  * allocated and their size must be a power of two
- * (Documentation/circular-buffers.txt)
+ * (Documentation/core-api/circular-buffers.rst)
  */
 int pblk_rb_init(struct pblk_rb *rb, struct pblk_rb_entry *rb_entry_base,
 		 unsigned int power_size, unsigned int power_seg_sz)
diff --git a/drivers/md/bcache/Kconfig b/drivers/md/bcache/Kconfig
index 4d200883c505..17bf109c58e9 100644
--- a/drivers/md/bcache/Kconfig
+++ b/drivers/md/bcache/Kconfig
@@ -5,7 +5,7 @@ config BCACHE
 	Allows a block device to be used as cache for other devices; uses
 	a btree for indexing and the layout is optimized for SSDs.
 
-	See Documentation/bcache.txt for details.
+	See Documentation/admin-guide/bcache.rst for details.
 
 config BCACHE_DEBUG
 	bool "Bcache debugging"
diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c
index 2a0968c04e21..547c9eedc2f4 100644
--- a/drivers/md/bcache/btree.c
+++ b/drivers/md/bcache/btree.c
@@ -18,7 +18,7 @@
  * as keys are inserted we only sort the pages that have not yet been written.
  * When garbage collection is run, we resort the entire node.
  *
- * All configuration is done via sysfs; see Documentation/bcache.txt.
+ * All configuration is done via sysfs; see Documentation/admin-guide/bcache.rst.
  */
 
 #include "bcache.h"
diff --git a/drivers/md/bcache/extents.c b/drivers/md/bcache/extents.c
index c334e6666461..1d096742eb41 100644
--- a/drivers/md/bcache/extents.c
+++ b/drivers/md/bcache/extents.c
@@ -18,7 +18,7 @@
  * as keys are inserted we only sort the pages that have not yet been written.
  * When garbage collection is run, we resort the entire node.
  *
- * All configuration is done via sysfs; see Documentation/bcache.txt.
+ * All configuration is done via sysfs; see Documentation/admin-guide/bcache.rst.
  */
 
 #include "bcache.h"
diff --git a/drivers/media/dvb-core/dvb_ringbuffer.c b/drivers/media/dvb-core/dvb_ringbuffer.c
index 4330b6fa4af2..d1d471af0636 100644
--- a/drivers/media/dvb-core/dvb_ringbuffer.c
+++ b/drivers/media/dvb-core/dvb_ringbuffer.c
@@ -55,7 +55,7 @@ int dvb_ringbuffer_empty(struct dvb_ringbuffer *rbuf)
 	 * this pairs with smp_store_release() in dvb_ringbuffer_write(),
 	 * dvb_ringbuffer_write_user(), or dvb_ringbuffer_reset()
 	 *
-	 * for memory barriers also see Documentation/circular-buffers.txt
+	 * for memory barriers also see Documentation/core-api/circular-buffers.rst
 	 */
 	return (rbuf->pread == smp_load_acquire(&rbuf->pwrite));
 }
diff --git a/drivers/media/pci/meye/Kconfig b/drivers/media/pci/meye/Kconfig
index 2e60334ffef5..9a50f54231ad 100644
--- a/drivers/media/pci/meye/Kconfig
+++ b/drivers/media/pci/meye/Kconfig
@@ -5,7 +5,7 @@ config VIDEO_MEYE
 	---help---
 	  This is the video4linux driver for the Motion Eye camera found
 	  in the Vaio Picturebook laptops. Please read the material in
-	  <file:Documentation/video4linux/meye.txt> for more information.
+	  <file:Documentation/media/v4l-drivers/meye.rst> for more information.
 
 	  If you say Y or M here, you need to say Y or M to "Sony Laptop
 	  Extras" in the misc device section.
diff --git a/drivers/media/platform/pxa_camera.c b/drivers/media/platform/pxa_camera.c
index 4d5a26b4cdda..d85ffbfb7c1f 100644
--- a/drivers/media/platform/pxa_camera.c
+++ b/drivers/media/platform/pxa_camera.c
@@ -1021,7 +1021,7 @@ static void pxa_camera_wakeup(struct pxa_camera_dev *pcdev,
  *  - a videobuffer is queued on the pcdev->capture list
  *
  * Please check the "DMA hot chaining timeslice issue" in
- *   Documentation/video4linux/pxa_camera.txt
+ *   Documentation/media/v4l-drivers/pxa_camera.rst
  *
  * Context: should only be called within the dma irq handler
  */
@@ -1443,7 +1443,7 @@ static void pxac_vb2_queue(struct vb2_buffer *vb)
 
 /*
  * Please check the DMA prepared buffer structure in :
- *   Documentation/video4linux/pxa_camera.txt
+ *   Documentation/media/v4l-drivers/pxa_camera.rst
  * Please check also in pxa_camera_check_link_miss() to understand why DMA chain
  * modification while DMA chain is running will work anyway.
  */
diff --git a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
index 242342fd7ede..9897213f2618 100644
--- a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
+++ b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
@@ -1111,7 +1111,7 @@ static void sh_mobile_ceu_put_formats(struct soc_camera_device *icd)
 /*
  * CEU can scale and crop, but we don't want to waste bandwidth and kill the
  * framerate by always requesting the maximum image from the client. See
- * Documentation/video4linux/sh_mobile_ceu_camera.txt for a description of
+ * Documentation/media/v4l-drivers/sh_mobile_ceu_camera.rst for a description of
  * scaling and cropping algorithms and for the meaning of referenced here steps.
  */
 static int sh_mobile_ceu_set_selection(struct soc_camera_device *icd,
diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig
index 39b04ad924c0..b426d6f9787d 100644
--- a/drivers/media/radio/Kconfig
+++ b/drivers/media/radio/Kconfig
@@ -272,7 +272,7 @@ config RADIO_RTRACK
 	  been reported to be used by these cards.
 
 	  More information is contained in the file
-	  <file:Documentation/video4linux/radiotrack.txt>.
+	  <file:Documentation/media/v4l-drivers/radiotrack.rst>.
 
 	  To compile this driver as a module, choose M here: the
 	  module will be called radio-aimslab.
diff --git a/drivers/media/radio/si470x/Kconfig b/drivers/media/radio/si470x/Kconfig
index a21172e413a9..6dbb158cd2a0 100644
--- a/drivers/media/radio/si470x/Kconfig
+++ b/drivers/media/radio/si470x/Kconfig
@@ -29,7 +29,7 @@ config USB_SI470X
 
 	  Please have a look at the documentation, especially on how
 	  to redirect the audio stream from the radio to your sound device:
-	  Documentation/video4linux/si470x.txt
+	  Documentation/media/v4l-drivers/si470x.rst
 
 	  Say Y here if you want to connect this type of radio to your
 	  computer's USB port.
diff --git a/drivers/media/usb/dvb-usb-v2/lmedm04.c b/drivers/media/usb/dvb-usb-v2/lmedm04.c
index be26c029546b..39db6dc4b5cd 100644
--- a/drivers/media/usb/dvb-usb-v2/lmedm04.c
+++ b/drivers/media/usb/dvb-usb-v2/lmedm04.c
@@ -21,7 +21,7 @@
  *
  * LME2510C + M88RS2000
  *
- * For firmware see Documentation/dvb/lmedm04.txt
+ * For firmware see Documentation/media/dvb-drivers/lmedm04.rst
  *
  * I2C addresses:
  * 0xd0 - STV0288	- Demodulator
diff --git a/drivers/media/usb/zr364xx/Kconfig b/drivers/media/usb/zr364xx/Kconfig
index 0f585662881d..ac429bca70e8 100644
--- a/drivers/media/usb/zr364xx/Kconfig
+++ b/drivers/media/usb/zr364xx/Kconfig
@@ -6,7 +6,7 @@ config USB_ZR364XX
 	---help---
 	  Say Y here if you want to connect this type of camera to your
 	  computer's USB port.
-	  See <file:Documentation/video4linux/zr364xx.txt> for more info
+	  See <file:Documentation/media/v4l-drivers/zr364xx.rst> for more info
 	  and list of supported cameras.
 
 	  To compile this driver as a module, choose M here: the
diff --git a/drivers/parport/Kconfig b/drivers/parport/Kconfig
index 44333bd8f908..a97f4eada60b 100644
--- a/drivers/parport/Kconfig
+++ b/drivers/parport/Kconfig
@@ -20,7 +20,7 @@ menuconfig PARPORT
 	  drive, PLIP link (Parallel Line Internet Protocol is mainly used to
 	  create a mini network by connecting the parallel ports of two local
 	  machines) etc., then you need to say Y here; please read
-	  <file:Documentation/parport.txt> and
+	  <file:Documentation/admin-guide/parport.rst> and
 	  <file:drivers/parport/BUGS-parport>.
 
 	  For extensive information about drivers for many devices attaching
@@ -33,7 +33,7 @@ menuconfig PARPORT
 	  the module will be called parport.
 	  If you have more than one parallel port and want to specify which
 	  port and IRQ to be used by this driver at module load time, take a
-	  look at <file:Documentation/parport.txt>.
+	  look at <file:Documentation/admin-guide/parport.rst>.
 
 	  If unsure, say Y.
 
@@ -71,7 +71,7 @@ config PARPORT_PC_FIFO
 	  As well as actually having a FIFO, or DMA capability, the kernel
 	  will need to know which IRQ the parallel port has.  By default,
 	  parallel port interrupts will not be used, and so neither will the
-	  FIFO.  See <file:Documentation/parport.txt> to find out how to
+	  FIFO.  See <file:Documentation/admin-guide/parport.rst> to find out how to
 	  specify which IRQ/DMA to use.
 
 config PARPORT_PC_SUPERIO
diff --git a/drivers/staging/media/bcm2048/TODO b/drivers/staging/media/bcm2048/TODO
index 051f85dbe89e..6bee2a2dad68 100644
--- a/drivers/staging/media/bcm2048/TODO
+++ b/drivers/staging/media/bcm2048/TODO
@@ -3,7 +3,7 @@ TODO:
 From the initial code review:
 
 The main thing you need to do is to implement all the controls using the
-control framework (see Documentation/video4linux/v4l2-controls.txt).
+control framework (see Documentation/media/kapi/v4l2-controls.rst).
 Most drivers are by now converted to the control framework, so you will
 find many examples of how to do this in drivers/media/radio.
 
diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
index 2480469ce8fb..e0a9c2368872 100644
--- a/include/keys/asymmetric-subtype.h
+++ b/include/keys/asymmetric-subtype.h
@@ -1,6 +1,6 @@
 /* Asymmetric public-key cryptography key subtype
  *
- * See Documentation/security/asymmetric-keys.txt
+ * See Documentation/crypto/asymmetric-keys.txt
  *
  * Copyright (C) 2012 Red Hat, Inc. All Rights Reserved.
  * Written by David Howells (dhowells at redhat.com)
diff --git a/include/keys/asymmetric-type.h b/include/keys/asymmetric-type.h
index b38240716d41..1cb77cd5135e 100644
--- a/include/keys/asymmetric-type.h
+++ b/include/keys/asymmetric-type.h
@@ -1,6 +1,6 @@
 /* Asymmetric Public-key cryptography key type interface
  *
- * See Documentation/security/asymmetric-keys.txt
+ * See Documentation/crypto/asymmetric-keys.txt
  *
  * Copyright (C) 2012 Red Hat, Inc. All Rights Reserved.
  * Written by David Howells (dhowells at redhat.com)
diff --git a/include/linux/assoc_array.h b/include/linux/assoc_array.h
index a89df3be1686..65e3832f96b2 100644
--- a/include/linux/assoc_array.h
+++ b/include/linux/assoc_array.h
@@ -1,6 +1,6 @@
 /* Generic associative array implementation.
  *
- * See Documentation/assoc_array.txt for information.
+ * See Documentation/core-api/assoc_array.rst for information.
  *
  * Copyright (C) 2013 Red Hat, Inc. All Rights Reserved.
  * Written by David Howells (dhowells at redhat.com)
diff --git a/include/linux/assoc_array_priv.h b/include/linux/assoc_array_priv.h
index 711275e6681c..a00a06550c10 100644
--- a/include/linux/assoc_array_priv.h
+++ b/include/linux/assoc_array_priv.h
@@ -1,6 +1,6 @@
 /* Private definitions for the generic associative array implementation.
  *
- * See Documentation/assoc_array.txt for information.
+ * See Documentation/core-api/assoc_array.rst for information.
  *
  * Copyright (C) 2013 Red Hat, Inc. All Rights Reserved.
  * Written by David Howells (dhowells at redhat.com)
diff --git a/include/linux/circ_buf.h b/include/linux/circ_buf.h
index 7cf262a421c3..b3233e8202f9 100644
--- a/include/linux/circ_buf.h
+++ b/include/linux/circ_buf.h
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 /*
- * See Documentation/circular-buffers.txt for more information.
+ * See Documentation/core-api/circular-buffers.rst for more information.
  */
 
 #ifndef _LINUX_CIRC_BUF_H
diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
index 9c3c9a319e48..8154f4920fcb 100644
--- a/include/linux/ftrace.h
+++ b/include/linux/ftrace.h
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 /*
  * Ftrace header.  For implementation details beyond the random comments
- * scattered below, see: Documentation/trace/ftrace-design.txt
+ * scattered below, see: Documentation/trace/ftrace-design.rst
  */
 
 #ifndef _LINUX_FTRACE_H
diff --git a/include/linux/rculist_nulls.h b/include/linux/rculist_nulls.h
index e4b257ff881b..bc8206a8f30e 100644
--- a/include/linux/rculist_nulls.h
+++ b/include/linux/rculist_nulls.h
@@ -109,7 +109,7 @@ static inline void hlist_nulls_add_head_rcu(struct hlist_nulls_node *n,
  *
  * The barrier() is needed to make sure compiler doesn't cache first element [1],
  * as this loop can be restarted [2]
- * [1] Documentation/atomic_ops.txt around line 114
+ * [1] Documentation/core-api/atomic_ops.rst around line 114
  * [2] Documentation/RCU/rculist_nulls.txt around line 146
  */
 #define hlist_nulls_for_each_entry_rcu(tpos, pos, head, member)			\
diff --git a/include/uapi/linux/prctl.h b/include/uapi/linux/prctl.h
index db9f15f5db04..c0d7ea0bf5b6 100644
--- a/include/uapi/linux/prctl.h
+++ b/include/uapi/linux/prctl.h
@@ -170,7 +170,7 @@ struct prctl_mm_map {
  * asking selinux for a specific new context (e.g. with runcon) will result
  * in execve returning -EPERM.
  *
- * See Documentation/prctl/no_new_privs.txt for more details.
+ * See Documentation/userspace-api/no_new_privs.rst for more details.
  */
 #define PR_SET_NO_NEW_PRIVS	38
 #define PR_GET_NO_NEW_PRIVS	39
diff --git a/include/xen/interface/io/kbdif.h b/include/xen/interface/io/kbdif.h
index 2a9510ade701..e2340a4130cf 100644
--- a/include/xen/interface/io/kbdif.h
+++ b/include/xen/interface/io/kbdif.h
@@ -317,7 +317,7 @@ struct xenkbd_position {
  * Linux [2] and Windows [3] multi-touch support.
  *
  * [1] https://cgit.freedesktop.org/wayland/wayland/tree/protocol/wayland.xml
- * [2] https://www.kernel.org/doc/Documentation/input/multi-touch-protocol.txt
+ * [2] https://www.kernel.org/doc/Documentation/input/multi-touch-protocol.rst
  * [3] https://msdn.microsoft.com/en-us/library/jj151564(v=vs.85).aspx
  *
  *
diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index d8b12e0d39cd..266f10cb7222 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -605,7 +605,7 @@ static inline int nr_cpusets(void)
  * load balancing domains (sched domains) as specified by that partial
  * partition.
  *
- * See "What is sched_load_balance" in Documentation/cgroups/cpusets.txt
+ * See "What is sched_load_balance" in Documentation/cgroup-v1/cpusets.txt
  * for a background explanation of this.
  *
  * Does not return errors, on the theory that the callers of this
diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig
index dd6c0a2ad969..dcc0166d1997 100644
--- a/kernel/trace/Kconfig
+++ b/kernel/trace/Kconfig
@@ -12,22 +12,22 @@ config NOP_TRACER
 config HAVE_FTRACE_NMI_ENTER
 	bool
 	help
-	  See Documentation/trace/ftrace-design.txt
+	  See Documentation/trace/ftrace-design.rst
 
 config HAVE_FUNCTION_TRACER
 	bool
 	help
-	  See Documentation/trace/ftrace-design.txt
+	  See Documentation/trace/ftrace-design.rst
 
 config HAVE_FUNCTION_GRAPH_TRACER
 	bool
 	help
-	  See Documentation/trace/ftrace-design.txt
+	  See Documentation/trace/ftrace-design.rst
 
 config HAVE_DYNAMIC_FTRACE
 	bool
 	help
-	  See Documentation/trace/ftrace-design.txt
+	  See Documentation/trace/ftrace-design.rst
 
 config HAVE_DYNAMIC_FTRACE_WITH_REGS
 	bool
@@ -35,12 +35,12 @@ config HAVE_DYNAMIC_FTRACE_WITH_REGS
 config HAVE_FTRACE_MCOUNT_RECORD
 	bool
 	help
-	  See Documentation/trace/ftrace-design.txt
+	  See Documentation/trace/ftrace-design.rst
 
 config HAVE_SYSCALL_TRACEPOINTS
 	bool
 	help
-	  See Documentation/trace/ftrace-design.txt
+	  See Documentation/trace/ftrace-design.rst
 
 config HAVE_FENTRY
 	bool
@@ -448,7 +448,7 @@ config KPROBE_EVENTS
 	help
 	  This allows the user to add tracing events (similar to tracepoints)
 	  on the fly via the ftrace interface. See
-	  Documentation/trace/kprobetrace.txt for more details.
+	  Documentation/trace/kprobetrace.rst for more details.
 
 	  Those events can be inserted wherever kprobes can probe, and record
 	  various register and memory values.
@@ -575,7 +575,7 @@ config MMIOTRACE
 	  implementation and works via page faults. Tracing is disabled by
 	  default and can be enabled at run-time.
 
-	  See Documentation/trace/mmiotrace.txt.
+	  See Documentation/trace/mmiotrace.rst.
 	  If you are not helping to develop drivers, say N.
 
 config TRACING_MAP
diff --git a/lib/Kconfig b/lib/Kconfig
index 809fdd155739..e34b04b56057 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -405,7 +405,7 @@ config ASSOCIATIVE_ARRAY
 
 	  See:
 
-		Documentation/assoc_array.txt
+		Documentation/core-api/assoc_array.rst
 
 	  for more information.
 
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 9a46dc24ac10..2b5ee5fbd652 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -4728,7 +4728,7 @@ static int selinux_socket_bind(struct socket *sock, struct sockaddr *address, in
 }
 
 /* This supports connect(2) and SCTP connect services such as sctp_connectx(3)
- * and sctp_sendmsg(3) as described in Documentation/security/LSM-sctp.txt
+ * and sctp_sendmsg(3) as described in Documentation/security/LSM-sctp.rst
  */
 static int selinux_socket_connect_helper(struct socket *sock,
 					 struct sockaddr *address, int addrlen)
diff --git a/sound/core/Kconfig b/sound/core/Kconfig
index 6e937a8146a1..63b3ef9c83f5 100644
--- a/sound/core/Kconfig
+++ b/sound/core/Kconfig
@@ -48,7 +48,7 @@ config SND_MIXER_OSS
 	depends on SND_OSSEMUL
 	help
 	  To enable OSS mixer API emulation (/dev/mixer*), say Y here
-	  and read <file:Documentation/sound/alsa/OSS-Emulation.txt>.
+	  and read <file:Documentation/sound/designs/oss-emulation.rst>.
 
 	  Many programs still use the OSS API, so say Y.
 
@@ -61,7 +61,7 @@ config SND_PCM_OSS
 	select SND_PCM
 	help
 	  To enable OSS digital audio (PCM) emulation (/dev/dsp*), say Y
-	  here and read <file:Documentation/sound/alsa/OSS-Emulation.txt>.
+	  here and read <file:Documentation/sound/designs/oss-emulation.rst>.
 
 	  Many programs still use the OSS API, so say Y.
 
diff --git a/sound/drivers/Kconfig b/sound/drivers/Kconfig
index 7144cc36e8ae..648a12da44f9 100644
--- a/sound/drivers/Kconfig
+++ b/sound/drivers/Kconfig
@@ -153,7 +153,7 @@ config SND_SERIAL_U16550
 	select SND_RAWMIDI
 	help
 	  To include support for MIDI serial port interfaces, say Y here
-	  and read <file:Documentation/sound/alsa/serial-u16550.txt>.
+	  and read <file:Documentation/sound/cards/serial-u16550.rst>.
 	  This driver works with serial UARTs 16550 and better.
 
 	  This driver accesses the serial port hardware directly, so
@@ -223,7 +223,7 @@ config SND_AC97_POWER_SAVE
 	  the device frequently.  A value of 10 seconds would be a
 	  good choice for normal operations.
 
-	  See Documentation/sound/alsa/powersave.txt for more details.
+	  See Documentation/sound/designs/powersave.rst for more details.
 
 config SND_AC97_POWER_SAVE_DEFAULT
 	int "Default time-out for AC97 power-save mode"
diff --git a/sound/pci/Kconfig b/sound/pci/Kconfig
index d9f3fdb777e4..4105d9f653d9 100644
--- a/sound/pci/Kconfig
+++ b/sound/pci/Kconfig
@@ -175,7 +175,7 @@ config SND_BT87X
 	help
 	  If you want to record audio from TV cards based on
 	  Brooktree Bt878/Bt879 chips, say Y here and read
-	  <file:Documentation/sound/alsa/Bt87x.txt>.
+	  <file:Documentation/sound/cards/bt87x.rst>.
 
 	  To compile this driver as a module, choose M here: the module
 	  will be called snd-bt87x.
@@ -210,7 +210,7 @@ config SND_CMIPCI
 	help
 	  If you want to use soundcards based on C-Media CMI8338, CMI8738,
 	  CMI8768 or CMI8770 chips, say Y here and read
-	  <file:Documentation/sound/alsa/CMIPCI.txt>.
+	  <file:Documentation/sound/cards/cmipci.rst>.
 
 	  To compile this driver as a module, choose M here: the module
 	  will be called snd-cmipci.
@@ -472,8 +472,8 @@ config SND_EMU10K1
 	  Audigy and E-mu APS (partially supported) soundcards.
 
 	  The confusing multitude of mixer controls is documented in
-	  <file:Documentation/sound/alsa/SB-Live-mixer.txt> and
-	  <file:Documentation/sound/alsa/Audigy-mixer.txt>.
+	  <file:Documentation/sound/cards/sb-live-mixer.rst> and
+	  <file:Documentation/sound/cards/audigy-mixer.rst>.
 
 	  To compile this driver as a module, choose M here: the module
 	  will be called snd-emu10k1.
@@ -735,7 +735,7 @@ config SND_MIXART
 	select SND_PCM
 	help
 	  If you want to use Digigram miXart soundcards, say Y here and
-	  read <file:Documentation/sound/alsa/MIXART.txt>.
+	  read <file:Documentation/sound/cards/mixart.rst>.
 
 	  To compile this driver as a module, choose M here: the module
 	  will be called snd-mixart.
diff --git a/tools/include/uapi/linux/prctl.h b/tools/include/uapi/linux/prctl.h
index db9f15f5db04..c0d7ea0bf5b6 100644
--- a/tools/include/uapi/linux/prctl.h
+++ b/tools/include/uapi/linux/prctl.h
@@ -170,7 +170,7 @@ struct prctl_mm_map {
  * asking selinux for a specific new context (e.g. with runcon) will result
  * in execve returning -EPERM.
  *
- * See Documentation/prctl/no_new_privs.txt for more details.
+ * See Documentation/userspace-api/no_new_privs.rst for more details.
  */
 #define PR_SET_NO_NEW_PRIVS	38
 #define PR_GET_NO_NEW_PRIVS	39
diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c
index 6a12bbf39f7b..7aba8243a0e7 100644
--- a/tools/lib/api/fs/fs.c
+++ b/tools/lib/api/fs/fs.c
@@ -201,7 +201,7 @@ static void mem_toupper(char *f, size_t len)
 
 /*
  * Check for "NAME_PATH" environment variable to override fs location (for
- * testing). This matches the recommendation in Documentation/sysfs-rules.txt
+ * testing). This matches the recommendation in Documentation/admin-guide/sysfs-rules.rst
  * for SYSFS_PATH.
  */
 static bool fs__env_override(struct fs *fs)
diff --git a/tools/perf/util/bpf-prologue.c b/tools/perf/util/bpf-prologue.c
index 29347756b0af..77e4891e17b0 100644
--- a/tools/perf/util/bpf-prologue.c
+++ b/tools/perf/util/bpf-prologue.c
@@ -61,7 +61,7 @@ check_pos(struct bpf_insn_pos *pos)
 
 /*
  * Convert type string (u8/u16/u32/u64/s8/s16/s32/s64 ..., see
- * Documentation/trace/kprobetrace.txt) to size field of BPF_LDX_MEM
+ * Documentation/trace/kprobetrace.rst) to size field of BPF_LDX_MEM
  * instruction (BPF_{B,H,W,DW}).
  */
 static int
diff --git a/tools/power/pm-graph/config/custom-timeline-functions.cfg b/tools/power/pm-graph/config/custom-timeline-functions.cfg
index 4f80ad7d7275..f8fcb06fd68b 100644
--- a/tools/power/pm-graph/config/custom-timeline-functions.cfg
+++ b/tools/power/pm-graph/config/custom-timeline-functions.cfg
@@ -105,7 +105,7 @@ override-dev-timeline-functions: true
 #       example: [color=#CC00CC]
 #
 #   arglist: A list of arguments from registers/stack addresses. See URL:
-#            https://www.kernel.org/doc/Documentation/trace/kprobetrace.txt
+#            https://www.kernel.org/doc/Documentation/trace/kprobetrace.rst
 #
 #       example: cpu=%di:s32
 #
@@ -170,7 +170,7 @@ pm_restore_console:
 #       example: [color=#CC00CC]
 #
 #   arglist: A list of arguments from registers/stack addresses. See URL:
-#            https://www.kernel.org/doc/Documentation/trace/kprobetrace.txt
+#            https://www.kernel.org/doc/Documentation/trace/kprobetrace.rst
 #
 #       example: port=+36(%di):s32
 #
-- 
2.17.1

^ permalink raw reply related

* [PATCH v3 03/27] arch/*: Kconfig: fix documentation for NMI watchdog
From: Mauro Carvalho Chehab @ 2018-06-14 16:08 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <cover.1528990947.git.mchehab+samsung@kernel.org>

Changeset 9919cba7ff71 ("watchdog: Update documentation") updated
the documentation, removing the old nmi_watchdog.txt and adding
a file with a new content.

Update Kconfig files accordingly.

Fixes: 9919cba7ff71 ("watchdog: Update documentation")

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
---
 arch/arm/Kconfig    | 2 +-
 arch/parisc/Kconfig | 2 +-
 arch/sh/Kconfig     | 2 +-
 arch/sparc/Kconfig  | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 2a78bdef9a24..fc3330807b09 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1301,7 +1301,7 @@ config SMP
 	  will run faster if you say N here.
 
 	  See also <file:Documentation/x86/i386/IO-APIC.txt>,
-	  <file:Documentation/nmi_watchdog.txt> and the SMP-HOWTO available at
+	  <file:Documentation/lockup-watchdogs.txt> and the SMP-HOWTO available at
 	  <http://tldp.org/HOWTO/SMP-HOWTO.html>.
 
 	  If you don't know what to do here, say N.
diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig
index 4d8f64d48597..c480770fabcd 100644
--- a/arch/parisc/Kconfig
+++ b/arch/parisc/Kconfig
@@ -275,7 +275,7 @@ config SMP
 	  machines, but will use only one CPU of a multiprocessor machine.
 	  On a uniprocessor machine, the kernel will run faster if you say N.
 
-	  See also <file:Documentation/nmi_watchdog.txt> and the SMP-HOWTO
+	  See also <file:Documentation/lockup-watchdogs.txt> and the SMP-HOWTO
 	  available at <http://www.tldp.org/docs.html#howto>.
 
 	  If you don't know what to do here, say N.
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 4d61a085982b..ac1829353139 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -687,7 +687,7 @@ config SMP
 	  People using multiprocessor machines who say Y here should also say
 	  Y to "Enhanced Real Time Clock Support", below.
 
-	  See also <file:Documentation/nmi_watchdog.txt> and the SMP-HOWTO
+	  See also <file:Documentation/lockup-watchdogs.txt> and the SMP-HOWTO
 	  available at <http://www.tldp.org/docs.html#howto>.
 
 	  If you don't know what to do here, say N.
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 9a2b8877f174..0f535debf802 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -178,7 +178,7 @@ config SMP
 	  Y to "Enhanced Real Time Clock Support", below. The "Advanced Power
 	  Management" code will be disabled if you say Y here.
 
-	  See also <file:Documentation/nmi_watchdog.txt> and the SMP-HOWTO
+	  See also <file:Documentation/lockup-watchdogs.txt> and the SMP-HOWTO
 	  available at <http://www.tldp.org/docs.html#howto>.
 
 	  If you don't know what to do here, say N.
-- 
2.17.1

^ permalink raw reply related

* [PATCH v3 00/27] Fix some doc build warnings/errors and broken links
From: Mauro Carvalho Chehab @ 2018-06-14 16:08 UTC (permalink / raw)
  To: linux-arm-kernel

Jon,

As discussed during the review of v2, your plans were to merge
things with potential to conflict with merges by the end of the
merge window. So, I'm resubmitting it in order to help you with
that.

This patch series is at my experimental tree:
	https://git.linuxtv.org/mchehab/experimental.git/log/?h=broken-links-v5

	git://linuxtv.org/mchehab/experimental.git broken-links-v5

This series contains:

- 5 patches that weren't applied on my previous v2 series yet. 
  Except for rebasing, the only change is that tools/memory-model/README
  was removed from patch 5, as per Andrea review;

- 4 patches for media stuff. I forgot to apply those via my tree.
  Only noticed I didn't apply on media when I rebased by work.

  Jon, 
    I could sent them via my tree, but, IMHO, better to apply together
    with the other ones. So, feel free to send them via your tree.

- 6 patches improving the scripts/documentation-file-ref-check tool.
  They fix a few things there and add more auto-correct rules,
  some focused at DT binding stuff.

- a series of other patches fixing several broken Documentation/
  file references.

After this patch series, only 32 broken references to doc files are detected:

  Documentation/devicetree/bindings/input/mtk-pmic-keys.txt: Documentation/devicetree/bindings/input/keys.txt
  Documentation/devicetree/bindings/input/mtk-pmic-keys.txt: Documentation/devicetree/bindings/input/keys.txt
  Documentation/devicetree/bindings/leds/common.txt: Documentation/devicetree/bindings/gpio/led.txt
  Documentation/devicetree/bindings/regulator/rohm,bd71837-regulator.txt: Documentation/devicetree/bindings/mfd/rohm,bd71837-pmic.txt
  Documentation/devicetree/dynamic-resolution-notes.txt: Documentation/devicetree/dt-object-internal.txt
  Documentation/scheduler/sched-pelt.c: Documentation/scheduler/sched-pelt
  Documentation/scsi/scsi_mid_low_api.txt: Documentation/Configure.help
  Documentation/sound/alsa-configuration.rst: Documentation/sound/oss/MultiSound
  Documentation/target/tcm_mod_builder.txt: mnt/sdb/lio-core-2.6.git/Documentation/target/../../drivers/target/tcm_nab5000
  Documentation/target/tcm_mod_builder.txt: mnt/sdb/lio-core-2.6.git/Documentation/target/../../drivers/target/tcm_nab5000
  Documentation/target/tcm_mod_builder.txt: mnt/sdb/lio-core-2.6.git/Documentation/target/../../drivers/target/tcm_nab5000/tcm_nab5000_base.h
  Documentation/target/tcm_mod_builder.txt: mnt/sdb/lio-core-2.6.git/Documentation/target/../../include/target/target_core_fabric_ops.h
  Documentation/target/tcm_mod_builder.txt: mnt/sdb/lio-core-2.6.git/Documentation/target/../../drivers/target/tcm_nab5000/tcm_nab5000_fabric.c
  Documentation/target/tcm_mod_builder.txt: mnt/sdb/lio-core-2.6.git/Documentation/target/../../drivers/target/tcm_nab5000/tcm_nab5000_fabric.h
  Documentation/target/tcm_mod_builder.txt: mnt/sdb/lio-core-2.6.git/Documentation/target/../../drivers/target/tcm_nab5000/tcm_nab5000_configfs.c
  Documentation/target/tcm_mod_builder.txt: mnt/sdb/lio-core-2.6.git/Documentation/target/../../drivers/target/tcm_nab5000/Kbuild
  Documentation/target/tcm_mod_builder.txt: mnt/sdb/lio-core-2.6.git/Documentation/target/../../drivers/target/tcm_nab5000/Kconfig
  Documentation/trace/ftrace.rst: Documentation/trace/histogram.rst
  Documentation/translations/zh_CN/HOWTO: Documentation/DocBook/
  Documentation/translations/zh_CN/basic_profiling.txt: Documentation/basic_profiling
  Documentation/translations/zh_CN/basic_profiling.txt: Documentation/basic_profiling
  Documentation/translations/zh_CN/oops-tracing.txt: Documentation/admin-guide/oops-tracing.rst
  Documentation/translations/zh_CN/oops-tracing.txt: Documentation/admin-guide/oops-tracing.rst
  MAINTAINERS: Documentation/devicetree/bindings/i2c/ina209.txt
  MAINTAINERS: Documentation/devicetree/bindings/rng/samsung,exynos5250-trng.txt
  arch/powerpc/Kconfig: Documentation/vm/protection-keys.rst
  drivers/isdn/mISDN/dsp_core.c: Documentation/isdn/mISDN.cert
  drivers/scsi/Kconfig: file:Documentation/scsi/tmscsim.txt
  drivers/vhost/vhost.c: Documentation/virtual/lguest/lguest.c
  include/linux/gpio.h: Documentation/gpio/gpio-legacy.txt
  kernel/sched/sched-pelt.h: Documentation/scheduler/sched-pelt
  sound/isa/Kconfig: file:Documentation/sound/oss/MultiSound

Just reminding, before v1 of this series, we had around 300 broken refs,
so, I guess we've made some progress.

The remaining ones will likely require subsystem attention, as most
of them seem to be related to non-trivial code changes and/or code
cleanups.

Mauro Carvalho Chehab (27):
  docs: can.rst: fix a footnote reference
  docs: crypto_engine.rst: Fix two parse warnings
  arch/*: Kconfig: fix documentation for NMI watchdog
  docs: fix broken references with multiple hints
  docs: Fix some broken references
  media: dvb: fix location of get_dvb_firmware script
  media: dvb: point to the location of the old README.dvb-usb file
  media: v4l: fix broken video4linux docs locations
  media: max2175: fix location of driver's companion documentation
  scripts/documentation-file-ref-check: fix help message
  scripts/documentation-file-ref-check: accept more wildcards at
    filenames
  scripts/documentation-file-ref-check: add a fix logic for DT
  scripts/documentation-file-ref-check: hint: dash or underline
  scripts/documentation-file-ref-check: get rid of false-positives
  scripts/documentation-file-ref-check: check tools/*/Documentation
  docs: Fix more broken references
  bindings: nvmem/zii: Fix location of nvmem.txt
  kernel-parameters.txt: fix pointers to sound parameters
  MAINTAINERS: fix location of some display DT bindings
  MAINTAINERS: fix location of DT npcm files
  MAINTAINERS: get rid of non-existing Documentation/fpga
  devicetree: fix some bindings file names
  devicetree: fix name of pinctrl-bindings.txt
  devicetree: fix a series of wrong file references
  ABI: sysfs-devices-system-cpu: remove a broken reference
  Documentation: rstFlatTable.py: fix a broken reference
  fix a series of Documentation/ broken file name references

 Documentation/ABI/obsolete/sysfs-gpio         |  2 +-
 .../ABI/testing/sysfs-devices-system-cpu      |  3 -
 .../admin-guide/kernel-parameters.txt         |  9 +--
 Documentation/crypto/crypto_engine.rst        |  8 ++-
 .../bindings/clock/st/st,clkgen.txt           |  8 +--
 .../devicetree/bindings/clock/ti/gate.txt     |  2 +-
 .../bindings/clock/ti/interface.txt           |  2 +-
 .../bindings/cpufreq/cpufreq-mediatek.txt     |  2 +-
 .../bindings/devfreq/rk3399_dmc.txt           |  2 +-
 .../bindings/display/bridge/tda998x.txt       |  2 +-
 .../bindings/gpu/arm,mali-midgard.txt         |  2 +-
 .../bindings/gpu/arm,mali-utgard.txt          |  2 +-
 .../bindings/input/rmi4/rmi_2d_sensor.txt     |  2 +-
 .../bindings/input/rotary-encoder.txt         |  2 +-
 .../bindings/media/stih407-c8sectpfe.txt      |  2 +-
 .../devicetree/bindings/mfd/as3722.txt        |  2 +-
 .../devicetree/bindings/mfd/mt6397.txt        |  2 +-
 .../devicetree/bindings/mfd/sun6i-prcm.txt    |  4 +-
 .../bindings/mmc/exynos-dw-mshc.txt           |  2 +-
 .../bindings/mmc/microchip,sdhci-pic32.txt    |  2 +-
 .../devicetree/bindings/mmc/sdhci-st.txt      |  2 +-
 .../devicetree/bindings/net/dsa/ksz.txt       |  2 +-
 .../devicetree/bindings/net/dsa/mt7530.txt    |  2 +-
 .../bindings/nvmem/zii,rave-sp-eeprom.txt     |  2 +-
 .../bindings/pci/hisilicon-pcie.txt           |  2 +-
 .../devicetree/bindings/pci/kirin-pcie.txt    |  2 +-
 .../devicetree/bindings/pci/pci-keystone.txt  |  4 +-
 .../bindings/pinctrl/pinctrl-max77620.txt     |  4 +-
 .../bindings/pinctrl/pinctrl-mcp23s08.txt     |  4 +-
 .../bindings/pinctrl/pinctrl-rk805.txt        |  4 +-
 .../devicetree/bindings/power/fsl,imx-gpc.txt |  2 +-
 .../bindings/power/supply/ab8500/btemp.txt    |  2 +-
 .../bindings/power/supply/ab8500/chargalg.txt |  2 +-
 .../bindings/power/supply/ab8500/charger.txt  |  2 +-
 .../bindings/power/wakeup-source.txt          |  2 +-
 .../bindings/serial/microchip,pic32-uart.txt  |  2 +-
 .../bindings/sound/st,stm32-i2s.txt           |  2 +-
 .../bindings/sound/st,stm32-sai.txt           |  2 +-
 .../devicetree/bindings/spi/spi-st-ssc.txt    |  2 +-
 .../devicetree/bindings/usb/rockchip,dwc3.txt |  2 +-
 Documentation/driver-api/gpio/consumer.rst    |  2 +-
 Documentation/hwmon/ina2xx                    |  2 +-
 Documentation/kprobes.txt                     |  4 +-
 Documentation/maintainer/pull-requests.rst    |  2 +-
 Documentation/networking/can.rst              |  4 +-
 Documentation/sphinx/rstFlatTable.py          |  2 -
 Documentation/trace/coresight.txt             |  2 +-
 Documentation/trace/events.rst                |  2 +-
 Documentation/trace/ftrace-uses.rst           |  2 +-
 Documentation/trace/histogram.txt             |  2 +-
 Documentation/trace/intel_th.rst              |  2 +-
 Documentation/trace/tracepoint-analysis.rst   |  8 +--
 Documentation/translations/ja_JP/howto.rst    |  4 +-
 Documentation/translations/ko_KR/howto.rst    |  2 +-
 .../translations/zh_CN/SubmittingDrivers      |  2 +-
 Documentation/translations/zh_CN/gpio.txt     |  4 +-
 .../translations/zh_CN/io_ordering.txt        |  2 +-
 .../translations/zh_CN/magic-number.txt       |  4 +-
 .../zh_CN/video4linux/omap3isp.txt            |  4 +-
 .../zh_CN/video4linux/v4l2-framework.txt      |  6 +-
 MAINTAINERS                                   | 63 +++++++++----------
 arch/Kconfig                                  |  2 +-
 arch/arm/Kconfig                              |  2 +-
 arch/arm/include/asm/cacheflush.h             |  2 +-
 arch/arm64/include/asm/cacheflush.h           |  2 +-
 arch/microblaze/include/asm/cacheflush.h      |  2 +-
 arch/parisc/Kconfig                           |  2 +-
 arch/sh/Kconfig                               |  2 +-
 arch/sparc/Kconfig                            |  2 +-
 arch/um/Kconfig.um                            |  2 +-
 arch/unicore32/include/asm/cacheflush.h       |  2 +-
 arch/x86/entry/vsyscall/vsyscall_64.c         |  2 +-
 arch/xtensa/include/asm/cacheflush.h          |  4 +-
 block/Kconfig                                 |  2 +-
 certs/Kconfig                                 |  2 +-
 crypto/asymmetric_keys/asymmetric_type.c      |  2 +-
 crypto/asymmetric_keys/signature.c            |  2 +-
 drivers/char/Kconfig                          |  2 +-
 drivers/clk/clk.c                             |  4 +-
 drivers/clk/ingenic/cgu.h                     |  2 +-
 drivers/dma/dmaengine.c                       |  2 +-
 drivers/gpu/vga/Kconfig                       |  2 +-
 drivers/gpu/vga/vgaarb.c                      |  2 +-
 drivers/hid/usbhid/Kconfig                    |  2 +-
 drivers/input/Kconfig                         |  4 +-
 drivers/input/joystick/Kconfig                | 14 ++---
 drivers/input/joystick/iforce/Kconfig         |  4 +-
 drivers/input/joystick/walkera0701.c          |  2 +-
 drivers/input/misc/Kconfig                    |  4 +-
 drivers/input/misc/rotary_encoder.c           |  2 +-
 drivers/input/mouse/Kconfig                   |  6 +-
 drivers/input/mouse/alps.c                    |  2 +-
 drivers/input/serio/Kconfig                   |  4 +-
 drivers/input/touchscreen/wm97xx-core.c       |  2 +-
 drivers/lightnvm/pblk-rb.c                    |  2 +-
 drivers/md/bcache/Kconfig                     |  2 +-
 drivers/md/bcache/btree.c                     |  2 +-
 drivers/md/bcache/extents.c                   |  2 +-
 drivers/media/dvb-core/dvb_ringbuffer.c       |  2 +-
 drivers/media/dvb-frontends/Kconfig           | 18 +++---
 drivers/media/dvb-frontends/dib3000.h         |  2 +-
 drivers/media/dvb-frontends/dib3000mb.c       |  2 +-
 drivers/media/dvb-frontends/eds1547.h         |  2 +-
 drivers/media/dvb-frontends/nxt200x.c         |  4 +-
 drivers/media/dvb-frontends/or51211.c         |  2 +-
 drivers/media/dvb-frontends/sp8870.c          |  2 +-
 drivers/media/dvb-frontends/sp887x.c          |  2 +-
 drivers/media/dvb-frontends/tda1004x.c        |  4 +-
 drivers/media/dvb-frontends/tda10071.c        |  2 +-
 drivers/media/dvb-frontends/z0194a.h          |  2 +-
 drivers/media/i2c/max2175.c                   |  6 +-
 drivers/media/pci/bt8xx/Kconfig               |  2 +-
 drivers/media/pci/cx18/cx18-dvb.c             |  2 +-
 drivers/media/pci/cx18/cx18-streams.c         |  4 +-
 drivers/media/pci/cx23885/cx23885-cards.c     |  2 +-
 drivers/media/pci/meye/Kconfig                |  2 +-
 drivers/media/pci/ttpci/Kconfig               |  2 +-
 drivers/media/platform/pxa_camera.c           |  4 +-
 .../soc_camera/sh_mobile_ceu_camera.c         |  2 +-
 drivers/media/radio/Kconfig                   | 12 ++--
 drivers/media/radio/si470x/Kconfig            |  2 +-
 drivers/media/radio/wl128x/Kconfig            |  2 +-
 drivers/media/usb/dvb-usb-v2/Kconfig          |  2 +-
 drivers/media/usb/dvb-usb-v2/dvb_usb_core.c   |  2 +-
 drivers/media/usb/dvb-usb-v2/gl861.c          |  2 +-
 drivers/media/usb/dvb-usb-v2/lmedm04.c        |  4 +-
 drivers/media/usb/dvb-usb-v2/lmedm04.h        |  2 +-
 drivers/media/usb/dvb-usb-v2/mxl111sf.c       |  2 +-
 drivers/media/usb/dvb-usb-v2/mxl111sf.h       |  2 +-
 drivers/media/usb/dvb-usb/Kconfig             |  2 +-
 drivers/media/usb/dvb-usb/a800.c              |  2 +-
 drivers/media/usb/dvb-usb/af9005-fe.c         |  2 +-
 drivers/media/usb/dvb-usb/af9005-remote.c     |  2 +-
 drivers/media/usb/dvb-usb/af9005.c            |  2 +-
 drivers/media/usb/dvb-usb/af9005.h            |  2 +-
 drivers/media/usb/dvb-usb/az6027.c            |  2 +-
 drivers/media/usb/dvb-usb/cxusb.c             |  2 +-
 drivers/media/usb/dvb-usb/dibusb-common.c     |  2 +-
 drivers/media/usb/dvb-usb/dibusb-mb.c         |  2 +-
 drivers/media/usb/dvb-usb/dibusb-mc-common.c  |  2 +-
 drivers/media/usb/dvb-usb/dibusb-mc.c         |  2 +-
 drivers/media/usb/dvb-usb/dibusb.h            |  2 +-
 drivers/media/usb/dvb-usb/digitv.c            |  2 +-
 drivers/media/usb/dvb-usb/dtt200u-fe.c        |  2 +-
 drivers/media/usb/dvb-usb/dtt200u.c           |  2 +-
 drivers/media/usb/dvb-usb/dtt200u.h           |  2 +-
 drivers/media/usb/dvb-usb/dvb-usb-firmware.c  |  2 +-
 drivers/media/usb/dvb-usb/dvb-usb-init.c      |  2 +-
 drivers/media/usb/dvb-usb/dw2102.c            |  6 +-
 drivers/media/usb/dvb-usb/friio-fe.c          |  2 +-
 drivers/media/usb/dvb-usb/friio.c             |  2 +-
 drivers/media/usb/dvb-usb/friio.h             |  2 +-
 drivers/media/usb/dvb-usb/gp8psk.c            |  4 +-
 drivers/media/usb/dvb-usb/gp8psk.h            |  2 +-
 drivers/media/usb/dvb-usb/m920x.c             |  2 +-
 drivers/media/usb/dvb-usb/nova-t-usb2.c       |  2 +-
 drivers/media/usb/dvb-usb/opera1.c            |  4 +-
 drivers/media/usb/dvb-usb/ttusb2.c            |  2 +-
 drivers/media/usb/dvb-usb/ttusb2.h            |  2 +-
 drivers/media/usb/dvb-usb/umt-010.c           |  2 +-
 drivers/media/usb/dvb-usb/vp702x-fe.c         |  2 +-
 drivers/media/usb/dvb-usb/vp702x.c            |  2 +-
 drivers/media/usb/dvb-usb/vp7045-fe.c         |  2 +-
 drivers/media/usb/dvb-usb/vp7045.c            |  2 +-
 drivers/media/usb/dvb-usb/vp7045.h            |  2 +-
 drivers/media/usb/gspca/m5602/Kconfig         |  2 -
 drivers/media/usb/ttusb-dec/Kconfig           |  6 +-
 drivers/media/usb/zr364xx/Kconfig             |  2 +-
 drivers/net/ethernet/intel/Kconfig            |  8 +--
 drivers/parport/Kconfig                       |  6 +-
 drivers/platform/x86/Kconfig                  |  2 +-
 drivers/sbus/char/oradax.c                    |  2 +-
 drivers/soundwire/stream.c                    |  8 +--
 .../staging/fsl-mc/bus/dpio/dpio-driver.txt   |  2 +-
 drivers/staging/media/bcm2048/TODO            |  2 +-
 drivers/staging/media/zoran/Kconfig           |  2 +-
 drivers/video/fbdev/skeletonfb.c              |  8 +--
 fs/Kconfig.binfmt                             |  2 +-
 fs/befs/ChangeLog                             |  2 +-
 fs/binfmt_misc.c                              |  2 +-
 fs/orangefs/orangefs-sysfs.c                  |  2 +-
 include/keys/asymmetric-subtype.h             |  2 +-
 include/keys/asymmetric-type.h                |  2 +-
 include/linux/assoc_array.h                   |  2 +-
 include/linux/assoc_array_priv.h              |  2 +-
 include/linux/circ_buf.h                      |  2 +-
 include/linux/ftrace.h                        |  2 +-
 include/linux/platform_data/sc18is602.h       |  2 +-
 include/linux/rculist_nulls.h                 |  2 +-
 include/linux/tracepoint.h                    |  2 +-
 include/uapi/linux/prctl.h                    |  2 +-
 include/xen/interface/io/kbdif.h              |  2 +-
 kernel/cgroup/cpuset.c                        |  2 +-
 kernel/power/main.c                           |  2 +-
 kernel/trace/Kconfig                          | 16 ++---
 lib/Kconfig                                   |  2 +-
 scripts/documentation-file-ref-check          | 56 ++++++++++++++---
 security/device_cgroup.c                      |  2 +-
 security/selinux/hooks.c                      |  2 +-
 sound/core/Kconfig                            |  4 +-
 sound/drivers/Kconfig                         |  4 +-
 sound/pci/Kconfig                             | 10 +--
 tools/include/uapi/linux/prctl.h              |  2 +-
 tools/lib/api/fs/fs.c                         |  2 +-
 tools/perf/util/bpf-prologue.c                |  2 +-
 .../config/custom-timeline-functions.cfg      |  4 +-
 206 files changed, 370 insertions(+), 339 deletions(-)

-- 
2.17.1

^ permalink raw reply

* [PATCH v3 11/14] media: platform: Add Sunxi-Cedrus VPU decoder driver
From: Paul Kocialkowski @ 2018-06-14 15:47 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <daf66c3c-d5a1-2cf2-433e-56bcef7f69ce@xs4all.nl>

Hi,

On Mon, 2018-05-07 at 16:02 +0200, Hans Verkuil wrote:
> On 07/05/18 14:44, Paul Kocialkowski wrote:
> > This introduces the Sunxi-Cedrus VPU driver that supports the VPU found
> > in Allwinner SoCs, also known as Video Engine. It is implemented through
> > a v4l2 m2m decoder device and a media device (used for media requests).
> > So far, it only supports MPEG2 decoding.
> > 
> > Since this VPU is stateless, synchronization with media requests is
> > required in order to ensure consistency between frame headers that
> > contain metadata about the frame to process and the raw slice data that
> > is used to generate the frame.
> > 
> > This driver was made possible thanks to the long-standing effort
> > carried out by the linux-sunxi community in the interest of reverse
> > engineering, documenting and implementing support for Allwinner VPU.
> > 
> > Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
> > ---
> >  MAINTAINERS                                        |   7 +
> >  drivers/media/platform/Kconfig                     |  15 +
> >  drivers/media/platform/Makefile                    |   1 +
> >  drivers/media/platform/sunxi/cedrus/Makefile       |   4 +
> >  drivers/media/platform/sunxi/cedrus/sunxi_cedrus.c | 333 ++++++++++++++
> >  .../platform/sunxi/cedrus/sunxi_cedrus_common.h    | 128 ++++++
> >  .../media/platform/sunxi/cedrus/sunxi_cedrus_dec.c | 188 ++++++++
> >  .../media/platform/sunxi/cedrus/sunxi_cedrus_dec.h |  35 ++
> >  .../media/platform/sunxi/cedrus/sunxi_cedrus_hw.c  | 240 ++++++++++
> >  .../media/platform/sunxi/cedrus/sunxi_cedrus_hw.h  |  37 ++
> >  .../platform/sunxi/cedrus/sunxi_cedrus_mpeg2.c     | 160 +++++++
> >  .../platform/sunxi/cedrus/sunxi_cedrus_mpeg2.h     |  33 ++
> >  .../platform/sunxi/cedrus/sunxi_cedrus_regs.h      | 175 +++++++
> >  .../platform/sunxi/cedrus/sunxi_cedrus_video.c     | 505 +++++++++++++++++++++
> >  .../platform/sunxi/cedrus/sunxi_cedrus_video.h     |  31 ++
> >  15 files changed, 1892 insertions(+)
> >  create mode 100644 drivers/media/platform/sunxi/cedrus/Makefile
> >  create mode 100644 drivers/media/platform/sunxi/cedrus/sunxi_cedrus.c
> >  create mode 100644 drivers/media/platform/sunxi/cedrus/sunxi_cedrus_common.h
> >  create mode 100644 drivers/media/platform/sunxi/cedrus/sunxi_cedrus_dec.c
> >  create mode 100644 drivers/media/platform/sunxi/cedrus/sunxi_cedrus_dec.h
> >  create mode 100644 drivers/media/platform/sunxi/cedrus/sunxi_cedrus_hw.c
> >  create mode 100644 drivers/media/platform/sunxi/cedrus/sunxi_cedrus_hw.h
> >  create mode 100644 drivers/media/platform/sunxi/cedrus/sunxi_cedrus_mpeg2.c
> >  create mode 100644 drivers/media/platform/sunxi/cedrus/sunxi_cedrus_mpeg2.h
> >  create mode 100644 drivers/media/platform/sunxi/cedrus/sunxi_cedrus_regs.h
> >  create mode 100644 drivers/media/platform/sunxi/cedrus/sunxi_cedrus_video.c
> >  create mode 100644 drivers/media/platform/sunxi/cedrus/sunxi_cedrus_video.h
> > 
> > diff --git a/MAINTAINERS b/MAINTAINERS
> > index 79bb02ff812f..489f1dccc810 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -656,6 +656,13 @@ L:	linux-crypto at vger.kernel.org
> >  S:	Maintained
> >  F:	drivers/crypto/sunxi-ss/
> >  
> > +ALLWINNER VPU DRIVER
> > +M:	Maxime Ripard <maxime.ripard@bootlin.com>
> > +M:	Paul Kocialkowski <paul.kocialkowski@bootlin.com>
> > +L:	linux-media at vger.kernel.org
> > +S:	Maintained
> > +F:	drivers/media/platform/sunxi/cedrus/
> > +
> >  ALPHA PORT
> >  M:	Richard Henderson <rth@twiddle.net>
> >  M:	Ivan Kokshaysky <ink@jurassic.park.msu.ru>
> > diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
> > index 5af07b620094..72d37cd2f7a2 100644
> > --- a/drivers/media/platform/Kconfig
> > +++ b/drivers/media/platform/Kconfig
> > @@ -476,6 +476,21 @@ config VIDEO_TI_VPE
> >  	  Support for the TI VPE(Video Processing Engine) block
> >  	  found on DRA7XX SoC.
> >  
> > +config VIDEO_SUNXI_CEDRUS
> > +	tristate "Sunxi-Cedrus VPU driver"
> > +	depends on VIDEO_DEV && VIDEO_V4L2 && MEDIA_CONTROLLER
> > +	depends on ARCH_SUNXI
> > +	depends on HAS_DMA
> > +	select VIDEOBUF2_DMA_CONTIG
> > +	select MEDIA_REQUEST_API
> > +	select V4L2_MEM2MEM_DEV
> > +	---help---
> > +	  Support for the VPU found in Allwinner SoCs, also known as the Cedar
> > +	  video engine.
> > +
> > +	  To compile this driver as a module, choose M here: the module
> > +	  will be called sunxi-cedrus.
> > +
> >  config VIDEO_TI_VPE_DEBUG
> >  	bool "VPE debug messages"
> >  	depends on VIDEO_TI_VPE
> > diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
> > index 932515df4477..444b995424a5 100644
> > --- a/drivers/media/platform/Makefile
> > +++ b/drivers/media/platform/Makefile
> > @@ -69,6 +69,7 @@ obj-$(CONFIG_VIDEO_ROCKCHIP_RGA)	+= rockchip/rga/
> >  obj-y	+= omap/
> >  
> >  obj-$(CONFIG_VIDEO_AM437X_VPFE)		+= am437x/
> > +obj-$(CONFIG_VIDEO_SUNXI_CEDRUS)	+= sunxi/cedrus/
> >  
> >  obj-$(CONFIG_VIDEO_XILINX)		+= xilinx/
> >  
> > diff --git a/drivers/media/platform/sunxi/cedrus/Makefile b/drivers/media/platform/sunxi/cedrus/Makefile
> > new file mode 100644
> > index 000000000000..98f30df626a9
> > --- /dev/null
> > +++ b/drivers/media/platform/sunxi/cedrus/Makefile
> > @@ -0,0 +1,4 @@
> > +obj-$(CONFIG_VIDEO_SUNXI_CEDRUS) += sunxi-cedrus.o
> > +
> > +sunxi-cedrus-y = sunxi_cedrus.o sunxi_cedrus_video.o sunxi_cedrus_hw.o \
> > +		 sunxi_cedrus_dec.o sunxi_cedrus_mpeg2.o
> > diff --git a/drivers/media/platform/sunxi/cedrus/sunxi_cedrus.c b/drivers/media/platform/sunxi/cedrus/sunxi_cedrus.c
> > new file mode 100644
> > index 000000000000..ccd41d9a3e41
> > --- /dev/null
> > +++ b/drivers/media/platform/sunxi/cedrus/sunxi_cedrus.c
> > @@ -0,0 +1,333 @@
> > +/*
> > + * Sunxi-Cedrus VPU driver
> > + *
> > + * Copyright (C) 2018 Paul Kocialkowski <paul.kocialkowski@bootlin.com>
> > + * Copyright (C) 2016 Florent Revest <florent.revest@free-electrons.com>
> > + *
> > + * Based on the vim2m driver, that is:
> > + *
> > + * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
> > + * Pawel Osciak, <pawel@osciak.com>
> > + * Marek Szyprowski, <m.szyprowski@samsung.com>
> > + *
> > + * This software is licensed under the terms of the GNU General Public
> > + * License version 2, as published by the Free Software Foundation, and
> > + * may be copied, distributed, and modified under those terms.
> > + *
> > + * This program is distributed in the hope that it will be useful,
> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > + * GNU General Public License for more details.
> > + */
> > +
> > +#include <linux/platform_device.h>
> > +#include <linux/module.h>
> > +#include <linux/of.h>
> > +
> > +#include <media/videobuf2-dma-contig.h>
> > +#include <media/v4l2-device.h>
> > +#include <media/v4l2-ioctl.h>
> > +#include <media/v4l2-ctrls.h>
> > +#include <media/v4l2-mem2mem.h>
> > +
> > +#include "sunxi_cedrus_common.h"
> > +#include "sunxi_cedrus_video.h"
> > +#include "sunxi_cedrus_dec.h"
> > +#include "sunxi_cedrus_hw.h"
> > +
> > +static int sunxi_cedrus_s_ctrl(struct v4l2_ctrl *ctrl)
> > +{
> > +	struct sunxi_cedrus_ctx *ctx =
> > +		container_of(ctrl->handler, struct sunxi_cedrus_ctx, hdl);
> > +
> > +	switch (ctrl->id) {
> > +	case V4L2_CID_MPEG_VIDEO_MPEG2_FRAME_HDR:
> > +		/* This is kept in memory and used directly. */
> 
> Is there any validation done/needed for the contents of this control?
> 
> I noticed it is just ignored in std_validate() in v4l2-ctrls.c, but I expected
> to see some validation here.
> 
> What happens if someone puts in rubbish data? How robust is the hardware?

I agree, there is definitely a lack of validation here and it is badly
needed. Especially when it comes to the reference frames indices, that
are used directly to address arrays elements at one point.

Since it seems beneficial to add this for all users of this structure,
it's best to add it in a common place. I'll investigate std_validate for
the next revision then. 

> > +		break;
> > +	default:
> > +		v4l2_err(&ctx->dev->v4l2_dev, "Invalid control\n");
> > +		return -EINVAL;
> > +	}
> > +
> > +	return 0;
> > +}
> > +
> > +static const struct v4l2_ctrl_ops sunxi_cedrus_ctrl_ops = {
> > +	.s_ctrl = sunxi_cedrus_s_ctrl,
> > +};
> > +
> > +static const struct sunxi_cedrus_control controls[] = {
> > +	[SUNXI_CEDRUS_CTRL_DEC_MPEG2_FRAME_HDR] = {
> > +		.id		= V4L2_CID_MPEG_VIDEO_MPEG2_FRAME_HDR,
> > +		.elem_size	= sizeof(struct v4l2_ctrl_mpeg2_frame_hdr),
> > +	},
> > +};
> > +
> > +static int sunxi_cedrus_init_ctrls(struct sunxi_cedrus_dev *dev,
> > +				   struct sunxi_cedrus_ctx *ctx)
> > +{
> > +	struct v4l2_ctrl_handler *hdl = &ctx->hdl;
> > +	unsigned int num_ctrls = ARRAY_SIZE(controls);
> > +	unsigned int i;
> > +
> > +	v4l2_ctrl_handler_init(hdl, num_ctrls);
> > +	if (hdl->error) {
> > +		dev_err(dev->dev, "Couldn't initialize our control handler\n");
> > +		return hdl->error;
> > +	}
> > +
> > +	for (i = 0; i < num_ctrls; i++) {
> > +		struct v4l2_ctrl_config cfg = { 0 };
> > +
> > +		cfg.ops = &sunxi_cedrus_ctrl_ops;
> > +		cfg.elem_size = controls[i].elem_size;
> > +		cfg.id = controls[i].id;
> > +
> > +		ctx->ctrls[i] = v4l2_ctrl_new_custom(hdl, &cfg, NULL);
> > +		if (hdl->error) {
> > +			v4l2_ctrl_handler_free(hdl);
> > +			return hdl->error;
> > +		}
> > +	}
> > +
> > +	ctx->fh.ctrl_handler = hdl;
> > +	v4l2_ctrl_handler_setup(hdl);
> 
> This initializes the header with all zeroes, is that what you want?
> Just checking.

I guess the underlying point here is that we should somehow check that a
proper header was passed, overriding the zero-ed default.

Otherwise, I doubt that feeding zero values to the hardware will cause
any substantial issue (but I should really double-check that).

What do you think?

> > +
> > +	return 0;
> > +}
> > +
> > +static void sunxi_cedrus_deinit_ctrls(struct sunxi_cedrus_dev *dev,
> > +				      struct sunxi_cedrus_ctx *ctx)
> > +{
> > +	unsigned int num_ctrls = ARRAY_SIZE(controls);
> > +	unsigned int i;
> > +
> > +	v4l2_ctrl_handler_free(&ctx->hdl);
> > +	for (i = 0; i < num_ctrls; i++)
> > +		ctx->ctrls[0] = NULL;
> 
> Is this necessary? Since ctx is freed right after this call?

You're right, it most likely is not.

> > +}
> > +
> > +static int sunxi_cedrus_open(struct file *file)
> > +{
> > +	struct sunxi_cedrus_dev *dev = video_drvdata(file);
> > +	struct sunxi_cedrus_ctx *ctx = NULL;
> > +	int rc;
> > +
> > +	if (mutex_lock_interruptible(&dev->dev_mutex))
> > +		return -ERESTARTSYS;
> > +
> > +	ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
> > +	if (!ctx) {
> > +		mutex_unlock(&dev->dev_mutex);
> > +		return -ENOMEM;
> > +	}
> > +
> > +	INIT_WORK(&ctx->run_work, sunxi_cedrus_device_work);
> > +
> > +	INIT_LIST_HEAD(&ctx->src_list);
> > +	INIT_LIST_HEAD(&ctx->dst_list);
> > +
> > +	v4l2_fh_init(&ctx->fh, video_devdata(file));
> > +	file->private_data = &ctx->fh;
> > +	ctx->dev = dev;
> > +
> > +	rc = sunxi_cedrus_init_ctrls(dev, ctx);
> > +	if (rc)
> > +		goto err_free;
> > +
> > +	ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(dev->m2m_dev, ctx,
> > +					    &sunxi_cedrus_queue_init);
> > +	if (IS_ERR(ctx->fh.m2m_ctx)) {
> > +		rc = PTR_ERR(ctx->fh.m2m_ctx);
> > +		goto err_ctrl_deinit;
> > +	}
> > +
> > +	v4l2_fh_add(&ctx->fh);
> > +
> > +	dev_dbg(dev->dev, "Created instance: %p, m2m_ctx: %p\n",
> > +		ctx, ctx->fh.m2m_ctx);
> > +
> > +	mutex_unlock(&dev->dev_mutex);
> > +	return 0;
> > +
> > +err_ctrl_deinit:
> > +	sunxi_cedrus_deinit_ctrls(dev, ctx);
> > +err_free:
> > +	kfree(ctx);
> > +	mutex_unlock(&dev->dev_mutex);
> > +	return rc;
> > +}
> > +
> > +static int sunxi_cedrus_release(struct file *file)
> > +{
> > +	struct sunxi_cedrus_dev *dev = video_drvdata(file);
> > +	struct sunxi_cedrus_ctx *ctx = container_of(file->private_data,
> > +			struct sunxi_cedrus_ctx, fh);
> > +
> > +	dev_dbg(dev->dev, "Releasing instance %p\n", ctx);
> > +
> > +	mutex_lock(&dev->dev_mutex);
> > +	v4l2_fh_del(&ctx->fh);
> > +	v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
> > +	sunxi_cedrus_deinit_ctrls(dev, ctx);
> > +	v4l2_fh_exit(&ctx->fh);
> > +	v4l2_fh_exit(&ctx->fh);
> > +	kfree(ctx);
> > +	mutex_unlock(&dev->dev_mutex);
> > +
> > +	return 0;
> > +}
> > +
> > +static const struct v4l2_file_operations sunxi_cedrus_fops = {
> > +	.owner		= THIS_MODULE,
> > +	.open		= sunxi_cedrus_open,
> > +	.release	= sunxi_cedrus_release,
> > +	.poll		= v4l2_m2m_fop_poll,
> > +	.unlocked_ioctl	= video_ioctl2,
> > +	.mmap		= v4l2_m2m_fop_mmap,
> > +};
> > +
> > +static const struct video_device sunxi_cedrus_video_device = {
> > +	.name		= SUNXI_CEDRUS_NAME,
> > +	.vfl_dir	= VFL_DIR_M2M,
> > +	.fops		= &sunxi_cedrus_fops,
> > +	.ioctl_ops	= &sunxi_cedrus_ioctl_ops,
> > +	.minor		= -1,
> > +	.release	= video_device_release_empty,
> > +};
> > +
> > +static const struct v4l2_m2m_ops sunxi_cedrus_m2m_ops = {
> > +	.device_run	= sunxi_cedrus_device_run,
> > +	.job_abort	= sunxi_cedrus_job_abort,
> > +};
> > +
> > +static const struct media_device_ops sunxi_cedrus_m2m_media_ops = {
> > +	.req_validate = vb2_request_validate,
> > +	.req_queue = vb2_m2m_request_queue,
> > +};
> > +
> > +static int sunxi_cedrus_probe(struct platform_device *pdev)
> > +{
> > +	struct sunxi_cedrus_dev *dev;
> > +	struct video_device *vfd;
> > +	int ret;
> > +
> > +	dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
> > +	if (!dev)
> > +		return -ENOMEM;
> > +
> > +	dev->dev = &pdev->dev;
> > +	dev->pdev = pdev;
> > +
> > +	ret = sunxi_cedrus_hw_probe(dev);
> > +	if (ret) {
> > +		dev_err(&pdev->dev, "Failed to probe hardware\n");
> > +		return ret;
> > +	}
> > +
> > +	mutex_init(&dev->dev_mutex);
> > +	spin_lock_init(&dev->irq_lock);
> > +
> > +	dev->vfd = sunxi_cedrus_video_device;
> > +	vfd = &dev->vfd;
> > +	vfd->lock = &dev->dev_mutex;
> > +	vfd->v4l2_dev = &dev->v4l2_dev;
> > +
> > +	dev->mdev.dev = &pdev->dev;
> > +	strlcpy(dev->mdev.model, SUNXI_CEDRUS_NAME, sizeof(dev->mdev.model));
> > +	media_device_init(&dev->mdev);
> > +	dev->mdev.ops = &sunxi_cedrus_m2m_media_ops;
> > +	dev->v4l2_dev.mdev = &dev->mdev;
> > +	dev->pad[0].flags = MEDIA_PAD_FL_SINK;
> > +	dev->pad[1].flags = MEDIA_PAD_FL_SOURCE;
> > +	ret = media_entity_pads_init(&vfd->entity, 2, dev->pad);
> > +	if (ret)
> > +		return ret;
> > +
> > +	ret = v4l2_device_register(&pdev->dev, &dev->v4l2_dev);
> > +	if (ret)
> > +		goto unreg_media;
> > +
> > +	ret = video_register_device(vfd, VFL_TYPE_GRABBER, 0);
> > +	if (ret) {
> > +		v4l2_err(&dev->v4l2_dev, "Failed to register video device\n");
> > +		goto unreg_dev;
> > +	}
> > +
> > +	video_set_drvdata(vfd, dev);
> > +	snprintf(vfd->name, sizeof(vfd->name), "%s",
> > +		 sunxi_cedrus_video_device.name);
> > +	v4l2_info(&dev->v4l2_dev,
> > +		  "Device registered as /dev/video%d\n", vfd->num);
> > +
> > +	platform_set_drvdata(pdev, dev);
> > +
> > +	dev->m2m_dev = v4l2_m2m_init(&sunxi_cedrus_m2m_ops);
> > +	if (IS_ERR(dev->m2m_dev)) {
> > +		v4l2_err(&dev->v4l2_dev, "Failed to init mem2mem device\n");
> > +		ret = PTR_ERR(dev->m2m_dev);
> > +		goto err_m2m;
> > +	}
> > +
> > +	/* Register the media device node */
> > +	ret = media_device_register(&dev->mdev);
> > +	if (ret)
> > +		goto err_m2m;
> > +
> > +	return 0;
> > +
> > +err_m2m:
> > +	v4l2_m2m_release(dev->m2m_dev);
> > +	video_unregister_device(&dev->vfd);
> > +unreg_media:
> > +	media_device_unregister(&dev->mdev);
> > +unreg_dev:
> > +	v4l2_device_unregister(&dev->v4l2_dev);
> > +
> > +	return ret;
> > +}
> > +
> > +static int sunxi_cedrus_remove(struct platform_device *pdev)
> > +{
> > +	struct sunxi_cedrus_dev *dev = platform_get_drvdata(pdev);
> > +
> > +	v4l2_info(&dev->v4l2_dev, "Removing " SUNXI_CEDRUS_NAME);
> > +
> > +	if (media_devnode_is_registered(dev->mdev.devnode)) {
> > +		media_device_unregister(&dev->mdev);
> > +		media_device_cleanup(&dev->mdev);
> > +	}
> > +
> > +	v4l2_m2m_release(dev->m2m_dev);
> > +	video_unregister_device(&dev->vfd);
> > +	v4l2_device_unregister(&dev->v4l2_dev);
> > +	sunxi_cedrus_hw_remove(dev);
> > +
> > +	return 0;
> > +}
> > +
> > +#ifdef CONFIG_OF
> > +static const struct of_device_id of_sunxi_cedrus_match[] = {
> > +	{ .compatible = "allwinner,sun4i-a10-video-engine" },
> > +	{ .compatible = "allwinner,sun5i-a13-video-engine" },
> > +	{ .compatible = "allwinner,sun7i-a20-video-engine" },
> > +	{ .compatible = "allwinner,sun8i-a33-video-engine" },
> > +	{ /* sentinel */ }
> > +};
> > +MODULE_DEVICE_TABLE(of, of_sunxi_cedrus_match);
> > +#endif
> > +
> > +static struct platform_driver sunxi_cedrus_driver = {
> > +	.probe		= sunxi_cedrus_probe,
> > +	.remove		= sunxi_cedrus_remove,
> > +	.driver		= {
> > +		.name	= SUNXI_CEDRUS_NAME,
> > +		.owner = THIS_MODULE,
> > +		.of_match_table = of_match_ptr(of_sunxi_cedrus_match),
> > +	},
> > +};
> > +module_platform_driver(sunxi_cedrus_driver);
> > +
> > +MODULE_LICENSE("GPL v2");
> > +MODULE_AUTHOR("Florent Revest <florent.revest@free-electrons.com>");
> > +MODULE_DESCRIPTION("Sunxi-Cedrus VPU driver");
> > diff --git a/drivers/media/platform/sunxi/cedrus/sunxi_cedrus_common.h b/drivers/media/platform/sunxi/cedrus/sunxi_cedrus_common.h
> > new file mode 100644
> > index 000000000000..ee6883ef9cb7
> > --- /dev/null
> > +++ b/drivers/media/platform/sunxi/cedrus/sunxi_cedrus_common.h
> > @@ -0,0 +1,128 @@
> > +/*
> > + * Sunxi-Cedrus VPU driver
> > + *
> > + * Copyright (C) 2018 Paul Kocialkowski <paul.kocialkowski@bootlin.com>
> > + * Copyright (C) 2016 Florent Revest <florent.revest@free-electrons.com>
> > + *
> > + * Based on the vim2m driver, that is:
> > + *
> > + * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
> > + * Pawel Osciak, <pawel@osciak.com>
> > + * Marek Szyprowski, <m.szyprowski@samsung.com>
> > + *
> > + * This software is licensed under the terms of the GNU General Public
> > + * License version 2, as published by the Free Software Foundation, and
> > + * may be copied, distributed, and modified under those terms.
> > + *
> > + * This program is distributed in the hope that it will be useful,
> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > + * GNU General Public License for more details.
> > + */
> > +
> > +#ifndef _SUNXI_CEDRUS_COMMON_H_
> > +#define _SUNXI_CEDRUS_COMMON_H_
> > +
> > +#include <linux/platform_device.h>
> > +
> > +#include <media/videobuf2-v4l2.h>
> > +#include <media/v4l2-device.h>
> > +#include <media/v4l2-ctrls.h>
> > +
> > +#define SUNXI_CEDRUS_NAME	"sunxi-cedrus"
> > +
> > +enum sunxi_cedrus_control_id {
> > +	SUNXI_CEDRUS_CTRL_DEC_MPEG2_FRAME_HDR = 0,
> > +	SUNXI_CEDRUS_CTRL_MAX,
> > +};
> > +
> > +struct sunxi_cedrus_control {
> > +	u32	id;
> > +	u32	elem_size;
> > +};
> > +
> > +struct sunxi_cedrus_fmt {
> > +	u32 fourcc;
> > +	int depth;
> > +	u32 types;
> > +	unsigned int num_planes;
> > +};
> > +
> > +struct sunxi_cedrus_mpeg2_run {
> > +	const struct v4l2_ctrl_mpeg2_frame_hdr		*hdr;
> > +};
> > +
> > +struct sunxi_cedrus_run {
> > +	struct vb2_v4l2_buffer	*src;
> > +	struct vb2_v4l2_buffer	*dst;
> > +
> > +	union {
> > +		struct sunxi_cedrus_mpeg2_run	mpeg2;
> > +	};
> > +};
> > +
> > +struct sunxi_cedrus_ctx {
> > +	struct v4l2_fh fh;
> > +	struct sunxi_cedrus_dev	*dev;
> > +
> > +	struct sunxi_cedrus_fmt *vpu_src_fmt;
> > +	struct v4l2_pix_format_mplane src_fmt;
> > +	struct sunxi_cedrus_fmt *vpu_dst_fmt;
> > +	struct v4l2_pix_format_mplane dst_fmt;
> > +
> > +	struct v4l2_ctrl_handler hdl;
> > +	struct v4l2_ctrl *ctrls[SUNXI_CEDRUS_CTRL_MAX];
> > +
> > +	struct vb2_buffer *dst_bufs[VIDEO_MAX_FRAME];
> > +
> > +	int job_abort;
> > +
> > +	struct work_struct try_schedule_work;
> > +	struct work_struct run_work;
> > +	struct list_head src_list;
> > +	struct list_head dst_list;
> > +};
> > +
> > +struct sunxi_cedrus_buffer {
> > +	struct vb2_v4l2_buffer vb;
> > +	enum vb2_buffer_state state;
> > +	struct list_head list;
> > +};
> > +
> > +struct sunxi_cedrus_dev {
> > +	struct v4l2_device v4l2_dev;
> > +	struct video_device vfd;
> > +	struct media_device mdev;
> > +	struct media_pad pad[2];
> > +	struct platform_device *pdev;
> > +	struct device *dev;
> > +	struct v4l2_m2m_dev *m2m_dev;
> > +
> > +	/* Mutex for device file */
> > +	struct mutex dev_mutex;
> > +	/* Spinlock for interrupt */
> > +	spinlock_t irq_lock;
> > +
> > +	void __iomem		*base;
> > +
> > +	struct clk *mod_clk;
> > +	struct clk *ahb_clk;
> > +	struct clk *ram_clk;
> > +
> > +	struct reset_control *rstc;
> > +
> > +	struct regmap *syscon;
> > +};
> > +
> > +static inline void sunxi_cedrus_write(struct sunxi_cedrus_dev *dev,
> > +				      u32 val, u32 reg)
> > +{
> > +	writel(val, dev->base + reg);
> > +}
> > +
> > +static inline u32 sunxi_cedrus_read(struct sunxi_cedrus_dev *dev, u32 reg)
> > +{
> > +	return readl(dev->base + reg);
> > +}
> > +
> > +#endif
> > diff --git a/drivers/media/platform/sunxi/cedrus/sunxi_cedrus_dec.c b/drivers/media/platform/sunxi/cedrus/sunxi_cedrus_dec.c
> > new file mode 100644
> > index 000000000000..8c92af34ebeb
> > --- /dev/null
> > +++ b/drivers/media/platform/sunxi/cedrus/sunxi_cedrus_dec.c
> > @@ -0,0 +1,188 @@
> > +/*
> > + * Sunxi-Cedrus VPU driver
> > + *
> > + * Copyright (C) 2018 Paul Kocialkowski <paul.kocialkowski@bootlin.com>
> > + * Copyright (C) 2016 Florent Revest <florent.revest@free-electrons.com>
> > + *
> > + * Based on the vim2m driver, that is:
> > + *
> > + * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
> > + * Pawel Osciak, <pawel@osciak.com>
> > + * Marek Szyprowski, <m.szyprowski@samsung.com>
> > + *
> > + * This software is licensed under the terms of the GNU General Public
> > + * License version 2, as published by the Free Software Foundation, and
> > + * may be copied, distributed, and modified under those terms.
> > + *
> > + * This program is distributed in the hope that it will be useful,
> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > + * GNU General Public License for more details.
> > + */
> > +
> > +#include <media/videobuf2-dma-contig.h>
> > +#include <media/v4l2-device.h>
> > +#include <media/v4l2-ioctl.h>
> > +#include <media/v4l2-ctrls.h>
> > +#include <media/v4l2-event.h>
> > +#include <media/v4l2-mem2mem.h>
> > +
> > +#include "sunxi_cedrus_common.h"
> > +#include "sunxi_cedrus_mpeg2.h"
> > +#include "sunxi_cedrus_dec.h"
> > +#include "sunxi_cedrus_hw.h"
> > +
> > +static inline void *get_ctrl_ptr(struct sunxi_cedrus_ctx *ctx,
> > +				 enum sunxi_cedrus_control_id id)
> > +{
> > +	struct v4l2_ctrl *ctrl = ctx->ctrls[id];
> > +
> > +	return ctrl->p_cur.p;
> > +}
> > +
> > +void sunxi_cedrus_device_work(struct work_struct *work)
> > +{
> > +	struct sunxi_cedrus_ctx *ctx = container_of(work,
> > +			struct sunxi_cedrus_ctx, run_work);
> > +	struct sunxi_cedrus_buffer *buffer_entry;
> > +	struct vb2_v4l2_buffer *src_buf, *dst_buf;
> > +	unsigned long flags;
> > +
> > +	spin_lock_irqsave(&ctx->dev->irq_lock, flags);
> > +
> > +	if (list_empty(&ctx->src_list) ||
> > +	    list_empty(&ctx->dst_list)) {
> > +		pr_err("Empty source and/or destination buffers lists\n");
> > +		spin_unlock_irqrestore(&ctx->dev->irq_lock, flags);
> > +		return;
> > +	}
> > +
> > +	buffer_entry = list_last_entry(&ctx->src_list, struct sunxi_cedrus_buffer, list);
> > +	list_del(ctx->src_list.prev);
> > +
> > +	src_buf = &buffer_entry->vb;
> > +	v4l2_m2m_buf_done(src_buf, buffer_entry->state);
> > +
> > +	buffer_entry = list_last_entry(&ctx->dst_list, struct sunxi_cedrus_buffer, list);
> > +	list_del(ctx->dst_list.prev);
> > +
> > +	dst_buf = &buffer_entry->vb;
> > +	v4l2_m2m_buf_done(dst_buf, buffer_entry->state);
> > +
> > +	spin_unlock_irqrestore(&ctx->dev->irq_lock, flags);
> > +
> > +	v4l2_m2m_job_finish(ctx->dev->m2m_dev, ctx->fh.m2m_ctx);
> > +}
> > +
> > +void sunxi_cedrus_device_run(void *priv)
> > +{
> > +	struct sunxi_cedrus_ctx *ctx = priv;
> > +	struct sunxi_cedrus_run run = { 0 };
> > +	struct media_request *src_req, *dst_req;
> > +	unsigned long flags;
> > +	bool mpeg1 = false;
> > +
> > +	run.src = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
> > +	if (!run.src) {
> > +		v4l2_err(&ctx->dev->v4l2_dev,
> > +			 "No source buffer to prepare\n");
> > +		return;
> > +	}
> > +
> > +	run.dst = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx);
> > +	if (!run.dst) {
> > +		v4l2_err(&ctx->dev->v4l2_dev,
> > +			 "No destination buffer to prepare\n");
> > +		return;
> > +	}
> > +
> > +	/* Apply request(s) controls if needed. */
> > +	src_req = run.src->vb2_buf.req_obj.req;
> > +	dst_req = run.dst->vb2_buf.req_obj.req;
> > +
> > +	if (src_req)
> > +		v4l2_ctrl_request_setup(src_req, &ctx->hdl);
> > +
> > +	if (dst_req && dst_req != src_req)
> > +		v4l2_ctrl_request_setup(dst_req, &ctx->hdl);
> > +
> > +	ctx->job_abort = 0;
> > +
> > +	spin_lock_irqsave(&ctx->dev->irq_lock, flags);
> > +
> > +	switch (ctx->vpu_src_fmt->fourcc) {
> > +	case V4L2_PIX_FMT_MPEG2_FRAME:
> > +		if (!ctx->ctrls[SUNXI_CEDRUS_CTRL_DEC_MPEG2_FRAME_HDR]) {
> > +			v4l2_err(&ctx->dev->v4l2_dev,
> > +				 "Invalid MPEG2 frame header control\n");
> > +			ctx->job_abort = 1;
> > +			goto unlock_complete;
> > +		}
> > +
> > +		run.mpeg2.hdr = get_ctrl_ptr(ctx, SUNXI_CEDRUS_CTRL_DEC_MPEG2_FRAME_HDR);
> > +		sunxi_cedrus_mpeg2_setup(ctx, &run);
> > +
> > +		mpeg1 = run.mpeg2.hdr->type == MPEG1;
> > +		break;
> > +
> > +	default:
> > +		ctx->job_abort = 1;
> > +	}
> > +
> > +unlock_complete:
> > +	spin_unlock_irqrestore(&ctx->dev->irq_lock, flags);
> > +
> > +	/* Complete request(s) controls if needed. */
> > +
> > +	if (src_req)
> > +		v4l2_ctrl_request_complete(src_req, &ctx->hdl);
> > +
> > +	if (dst_req && dst_req != src_req)
> > +		v4l2_ctrl_request_complete(dst_req, &ctx->hdl);
> > +
> > +	spin_lock_irqsave(&ctx->dev->irq_lock, flags);
> > +
> > +	if (!ctx->job_abort) {
> > +		if (ctx->vpu_src_fmt->fourcc == V4L2_PIX_FMT_MPEG2_FRAME)
> > +			sunxi_cedrus_mpeg2_trigger(ctx, mpeg1);
> > +	} else {
> > +		v4l2_m2m_buf_done(run.src, VB2_BUF_STATE_ERROR);
> > +		v4l2_m2m_buf_done(run.dst, VB2_BUF_STATE_ERROR);
> > +	}
> > +
> > +	spin_unlock_irqrestore(&ctx->dev->irq_lock, flags);
> > +
> > +	if (ctx->job_abort)
> > +		v4l2_m2m_job_finish(ctx->dev->m2m_dev, ctx->fh.m2m_ctx);
> > +}
> > +
> > +void sunxi_cedrus_job_abort(void *priv)
> > +{
> > +	struct sunxi_cedrus_ctx *ctx = priv;
> > +	struct vb2_v4l2_buffer *src_buf, *dst_buf;
> > +	unsigned long flags;
> > +
> > +	ctx->job_abort = 1;
> > +
> > +	/*
> > +	 * V4L2 m2m and request API cleanup is done here while hardware state
> > +	 * cleanup is done in the interrupt context. Doing all the cleanup in
> > +	 * the interrupt context is a bit risky, since the job_abort call might
> > +	 * originate from the release hook, where interrupts have already been
> > +	 * disabled.
> > +	 */
> > +
> > +	spin_lock_irqsave(&ctx->dev->irq_lock, flags);
> > +
> > +	src_buf = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx);
> > +	if (src_buf)
> > +		v4l2_m2m_buf_done(src_buf, VB2_BUF_STATE_ERROR);
> > +
> > +	dst_buf = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx);
> > +	if (dst_buf)
> > +		v4l2_m2m_buf_done(dst_buf, VB2_BUF_STATE_ERROR);
> > +
> > +	spin_unlock_irqrestore(&ctx->dev->irq_lock, flags);
> > +
> > +	v4l2_m2m_job_finish(ctx->dev->m2m_dev, ctx->fh.m2m_ctx);
> > +}
> > diff --git a/drivers/media/platform/sunxi/cedrus/sunxi_cedrus_dec.h b/drivers/media/platform/sunxi/cedrus/sunxi_cedrus_dec.h
> > new file mode 100644
> > index 000000000000..9899b399b2ba
> > --- /dev/null
> > +++ b/drivers/media/platform/sunxi/cedrus/sunxi_cedrus_dec.h
> > @@ -0,0 +1,35 @@
> > +/*
> > + * Sunxi-Cedrus VPU driver
> > + *
> > + * Copyright (C) 2018 Paul Kocialkowski <paul.kocialkowski@bootlin.com>
> > + * Copyright (C) 2016 Florent Revest <florent.revest@free-electrons.com>
> > + *
> > + * Based on the vim2m driver, that is:
> > + *
> > + * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
> > + * Pawel Osciak, <pawel@osciak.com>
> > + * Marek Szyprowski, <m.szyprowski@samsung.com>
> > + *
> > + * This software is licensed under the terms of the GNU General Public
> > + * License version 2, as published by the Free Software Foundation, and
> > + * may be copied, distributed, and modified under those terms.
> > + *
> > + * This program is distributed in the hope that it will be useful,
> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > + * GNU General Public License for more details.
> > + */
> > +
> > +#ifndef _SUNXI_CEDRUS_DEC_H_
> > +#define _SUNXI_CEDRUS_DEC_H_
> > +
> > +extern const struct v4l2_ioctl_ops sunxi_cedrus_ioctl_ops;
> > +
> > +void sunxi_cedrus_device_work(struct work_struct *work);
> > +void sunxi_cedrus_device_run(void *priv);
> > +void sunxi_cedrus_job_abort(void *priv);
> > +
> > +int sunxi_cedrus_queue_init(void *priv, struct vb2_queue *src_vq,
> > +			    struct vb2_queue *dst_vq);
> > +
> > +#endif
> > diff --git a/drivers/media/platform/sunxi/cedrus/sunxi_cedrus_hw.c b/drivers/media/platform/sunxi/cedrus/sunxi_cedrus_hw.c
> > new file mode 100644
> > index 000000000000..5783bd985855
> > --- /dev/null
> > +++ b/drivers/media/platform/sunxi/cedrus/sunxi_cedrus_hw.c
> > @@ -0,0 +1,240 @@
> > +/*
> > + * Sunxi-Cedrus VPU driver
> > + *
> > + * Copyright (C) 2018 Paul Kocialkowski <paul.kocialkowski@bootlin.com>
> > + * Copyright (C) 2016 Florent Revest <florent.revest@free-electrons.com>
> > + *
> > + * Based on the vim2m driver, that is:
> > + *
> > + * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
> > + * Pawel Osciak, <pawel@osciak.com>
> > + * Marek Szyprowski, <m.szyprowski@samsung.com>
> > + *
> > + * This software is licensed under the terms of the GNU General Public
> > + * License version 2, as published by the Free Software Foundation, and
> > + * may be copied, distributed, and modified under those terms.
> > + *
> > + * This program is distributed in the hope that it will be useful,
> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > + * GNU General Public License for more details.
> > + */
> > +
> > +#include <linux/platform_device.h>
> > +#include <linux/of_reserved_mem.h>
> > +#include <linux/dma-mapping.h>
> > +#include <linux/mfd/syscon.h>
> > +#include <linux/interrupt.h>
> > +#include <linux/clk.h>
> > +#include <linux/regmap.h>
> > +#include <linux/reset.h>
> > +#include <linux/soc/sunxi/sunxi_sram.h>
> > +
> > +#include <media/videobuf2-core.h>
> > +#include <media/v4l2-mem2mem.h>
> > +
> > +#include "sunxi_cedrus_common.h"
> > +#include "sunxi_cedrus_hw.h"
> > +#include "sunxi_cedrus_regs.h"
> > +
> > +#define SYSCON_SRAM_CTRL_REG0	0x0
> > +#define SYSCON_SRAM_C1_MAP_VE	0x7fffffff
> > +
> > +int sunxi_cedrus_engine_enable(struct sunxi_cedrus_dev *dev,
> > +			       enum sunxi_cedrus_engine engine)
> > +{
> > +	u32 reg = 0;
> > +
> > +	/*
> > +	 * FIXME: This is only valid on 32-bits DDR's, we should test
> > +	 * it on the A13/A33.
> > +	 */
> > +	reg |= VE_CTRL_REC_WR_MODE_2MB;
> > +
> > +	reg |= VE_CTRL_CACHE_BUS_BW_128;
> > +
> > +	switch (engine) {
> > +	case SUNXI_CEDRUS_ENGINE_MPEG:
> > +		reg |= VE_CTRL_DEC_MODE_MPEG;
> > +		break;
> > +
> > +	default:
> > +		return -EINVAL;
> > +	}
> > +
> > +	sunxi_cedrus_write(dev, reg, VE_CTRL);
> > +	return 0;
> > +}
> > +
> > +void sunxi_cedrus_engine_disable(struct sunxi_cedrus_dev *dev)
> > +{
> > +	sunxi_cedrus_write(dev, VE_CTRL_DEC_MODE_DISABLED, VE_CTRL);
> > +}
> > +
> > +static irqreturn_t sunxi_cedrus_ve_irq(int irq, void *dev_id)
> > +{
> > +	struct sunxi_cedrus_dev *dev = dev_id;
> > +	struct sunxi_cedrus_ctx *ctx;
> > +	struct sunxi_cedrus_buffer *src_buffer, *dst_buffer;
> > +	struct vb2_v4l2_buffer *src_vb, *dst_vb;
> > +	unsigned long flags;
> > +	unsigned int value, status;
> > +
> > +	spin_lock_irqsave(&dev->irq_lock, flags);
> > +
> > +	/* Disable MPEG interrupts and stop the MPEG engine */
> > +	value = sunxi_cedrus_read(dev, VE_MPEG_CTRL);
> > +	sunxi_cedrus_write(dev, value & (~0xf), VE_MPEG_CTRL);
> > +
> > +	status = sunxi_cedrus_read(dev, VE_MPEG_STATUS);
> > +	sunxi_cedrus_write(dev, 0x0000c00f, VE_MPEG_STATUS);
> > +	sunxi_cedrus_engine_disable(dev);
> > +
> > +	ctx = v4l2_m2m_get_curr_priv(dev->m2m_dev);
> > +	if (!ctx) {
> > +		pr_err("Instance released before the end of transaction\n");
> > +		spin_unlock_irqrestore(&dev->irq_lock, flags);
> > +
> > +		return IRQ_HANDLED;
> > +	}
> > +
> > +	src_vb = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx);
> > +	dst_vb = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx);
> > +
> > +	if (!src_vb || !dst_vb) {
> > +		pr_err("Unable to get source and/or destination buffers\n");
> > +		spin_unlock_irqrestore(&dev->irq_lock, flags);
> > +
> > +		return IRQ_HANDLED;
> > +	}
> > +
> > +	src_buffer = container_of(src_vb, struct sunxi_cedrus_buffer, vb);
> > +	dst_buffer = container_of(dst_vb, struct sunxi_cedrus_buffer, vb);
> > +
> > +	/* First bit of MPEG_STATUS indicates success. */
> > +	if (ctx->job_abort || !(status & 0x01))
> > +		src_buffer->state = dst_buffer->state = VB2_BUF_STATE_ERROR;
> > +	else
> > +		src_buffer->state = dst_buffer->state = VB2_BUF_STATE_DONE;
> > +
> > +	list_add_tail(&src_buffer->list, &ctx->src_list);
> > +	list_add_tail(&dst_buffer->list, &ctx->dst_list);
> > +
> > +	spin_unlock_irqrestore(&dev->irq_lock, flags);
> > +
> > +	schedule_work(&ctx->run_work);
> > +
> > +	return IRQ_HANDLED;
> > +}
> > +
> > +int sunxi_cedrus_hw_probe(struct sunxi_cedrus_dev *dev)
> > +{
> > +	struct resource *res;
> > +	int irq_dec;
> > +	int ret;
> > +
> > +	irq_dec = platform_get_irq(dev->pdev, 0);
> > +	if (irq_dec <= 0) {
> > +		dev_err(dev->dev, "could not get ve IRQ\n");
> > +		return -ENXIO;
> > +	}
> > +	ret = devm_request_irq(dev->dev, irq_dec, sunxi_cedrus_ve_irq, 0,
> > +			       dev_name(dev->dev), dev);
> > +	if (ret) {
> > +		dev_err(dev->dev, "could not request ve IRQ\n");
> > +		return -ENXIO;
> > +	}
> > +
> > +	/*
> > +	 * The VPU is only able to handle bus addresses so we have to subtract
> > +	 * the RAM offset to the physcal addresses.
> > +	 */
> > +	dev->dev->dma_pfn_offset = PHYS_PFN_OFFSET;
> > +
> > +	ret = of_reserved_mem_device_init(dev->dev);
> > +	if (ret && ret != -ENODEV) {
> > +		dev_err(dev->dev, "could not reserve memory\n");
> > +		return -ENODEV;
> > +	}
> > +
> > +	ret = sunxi_sram_claim(dev->dev);
> > +	if (ret) {
> > +		dev_err(dev->dev, "couldn't map SRAM to device\n");
> > +		return ret;
> > +	}
> > +
> > +	dev->ahb_clk = devm_clk_get(dev->dev, "ahb");
> > +	if (IS_ERR(dev->ahb_clk)) {
> > +		dev_err(dev->dev, "failed to get ahb clock\n");
> > +		return PTR_ERR(dev->ahb_clk);
> > +	}
> > +	dev->mod_clk = devm_clk_get(dev->dev, "mod");
> > +	if (IS_ERR(dev->mod_clk)) {
> > +		dev_err(dev->dev, "failed to get mod clock\n");
> > +		return PTR_ERR(dev->mod_clk);
> > +	}
> > +	dev->ram_clk = devm_clk_get(dev->dev, "ram");
> > +	if (IS_ERR(dev->ram_clk)) {
> > +		dev_err(dev->dev, "failed to get ram clock\n");
> > +		return PTR_ERR(dev->ram_clk);
> > +	}
> > +
> > +	dev->rstc = devm_reset_control_get(dev->dev, NULL);
> > +
> > +	res = platform_get_resource(dev->pdev, IORESOURCE_MEM, 0);
> > +	dev->base = devm_ioremap_resource(dev->dev, res);
> > +	if (!dev->base)
> > +		dev_err(dev->dev, "could not maps MACC registers\n");
> > +
> > +	dev->syscon = syscon_regmap_lookup_by_phandle(dev->dev->of_node,
> > +						      "syscon");
> > +	if (IS_ERR(dev->syscon)) {
> > +		dev->syscon = NULL;
> > +	} else {
> > +		regmap_write_bits(dev->syscon, SYSCON_SRAM_CTRL_REG0,
> > +				  SYSCON_SRAM_C1_MAP_VE,
> > +				  SYSCON_SRAM_C1_MAP_VE);
> > +	}
> > +
> > +	ret = clk_prepare_enable(dev->ahb_clk);
> > +	if (ret) {
> > +		dev_err(dev->dev, "could not enable ahb clock\n");
> > +		return -EFAULT;
> > +	}
> > +	ret = clk_prepare_enable(dev->mod_clk);
> > +	if (ret) {
> > +		clk_disable_unprepare(dev->ahb_clk);
> > +		dev_err(dev->dev, "could not enable mod clock\n");
> > +		return -EFAULT;
> > +	}
> > +	ret = clk_prepare_enable(dev->ram_clk);
> > +	if (ret) {
> > +		clk_disable_unprepare(dev->mod_clk);
> > +		clk_disable_unprepare(dev->ahb_clk);
> > +		dev_err(dev->dev, "could not enable ram clock\n");
> > +		return -EFAULT;
> > +	}
> > +
> > +	ret = reset_control_reset(dev->rstc);
> > +	if (ret) {
> > +		clk_disable_unprepare(dev->ram_clk);
> > +		clk_disable_unprepare(dev->mod_clk);
> > +		clk_disable_unprepare(dev->ahb_clk);
> > +		dev_err(dev->dev, "could not reset device\n");
> > +		return -EFAULT;
> > +	}
> > +
> > +	return 0;
> > +}
> > +
> > +void sunxi_cedrus_hw_remove(struct sunxi_cedrus_dev *dev)
> > +{
> > +	reset_control_assert(dev->rstc);
> > +
> > +	clk_disable_unprepare(dev->ram_clk);
> > +	clk_disable_unprepare(dev->mod_clk);
> > +	clk_disable_unprepare(dev->ahb_clk);
> > +
> > +	sunxi_sram_release(dev->dev);
> > +	of_reserved_mem_device_release(dev->dev);
> > +}
> > diff --git a/drivers/media/platform/sunxi/cedrus/sunxi_cedrus_hw.h b/drivers/media/platform/sunxi/cedrus/sunxi_cedrus_hw.h
> > new file mode 100644
> > index 000000000000..34f3fae462a8
> > --- /dev/null
> > +++ b/drivers/media/platform/sunxi/cedrus/sunxi_cedrus_hw.h
> > @@ -0,0 +1,37 @@
> > +/*
> > + * Sunxi-Cedrus VPU driver
> > + *
> > + * Copyright (C) 2018 Paul Kocialkowski <paul.kocialkowski@bootlin.com>
> > + * Copyright (C) 2016 Florent Revest <florent.revest@free-electrons.com>
> > + *
> > + * Based on the vim2m driver, that is:
> > + *
> > + * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
> > + * Pawel Osciak, <pawel@osciak.com>
> > + * Marek Szyprowski, <m.szyprowski@samsung.com>
> > + *
> > + * This software is licensed under the terms of the GNU General Public
> > + * License version 2, as published by the Free Software Foundation, and
> > + * may be copied, distributed, and modified under those terms.
> > + *
> > + * This program is distributed in the hope that it will be useful,
> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > + * GNU General Public License for more details.
> > + */
> > +
> > +#ifndef _SUNXI_CEDRUS_HW_H_
> > +#define _SUNXI_CEDRUS_HW_H_
> > +
> > +enum sunxi_cedrus_engine {
> > +	SUNXI_CEDRUS_ENGINE_MPEG,
> > +};
> > +
> > +int sunxi_cedrus_engine_enable(struct sunxi_cedrus_dev *dev,
> > +			       enum sunxi_cedrus_engine engine);
> > +void sunxi_cedrus_engine_disable(struct sunxi_cedrus_dev *dev);
> > +
> > +int sunxi_cedrus_hw_probe(struct sunxi_cedrus_dev *dev);
> > +void sunxi_cedrus_hw_remove(struct sunxi_cedrus_dev *dev);
> > +
> > +#endif
> > diff --git a/drivers/media/platform/sunxi/cedrus/sunxi_cedrus_mpeg2.c b/drivers/media/platform/sunxi/cedrus/sunxi_cedrus_mpeg2.c
> > new file mode 100644
> > index 000000000000..5be3e3b9ceef
> > --- /dev/null
> > +++ b/drivers/media/platform/sunxi/cedrus/sunxi_cedrus_mpeg2.c
> > @@ -0,0 +1,160 @@
> > +/*
> > + * Sunxi-Cedrus VPU driver
> > + *
> > + * Copyright (C) 2018 Paul Kocialkowski <paul.kocialkowski@bootlin.com>
> > + * Copyright (C) 2016 Florent Revest <florent.revest@free-electrons.com>
> > + *
> > + * Based on the vim2m driver, that is:
> > + *
> > + * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
> > + * Pawel Osciak, <pawel@osciak.com>
> > + * Marek Szyprowski, <m.szyprowski@samsung.com>
> > + *
> > + * This software is licensed under the terms of the GNU General Public
> > + * License version 2, as published by the Free Software Foundation, and
> > + * may be copied, distributed, and modified under those terms.
> > + *
> > + * This program is distributed in the hope that it will be useful,
> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > + * GNU General Public License for more details.
> > + */
> > +
> > +#include <media/videobuf2-dma-contig.h>
> > +
> > +#include "sunxi_cedrus_common.h"
> > +#include "sunxi_cedrus_hw.h"
> > +#include "sunxi_cedrus_regs.h"
> > +
> > +static const u8 mpeg_default_intra_quant[64] = {
> > +	 8, 16, 16, 19, 16, 19, 22, 22,
> > +	22, 22, 22, 22, 26, 24, 26, 27,
> > +	27, 27, 26, 26, 26, 26, 27, 27,
> > +	27, 29, 29, 29, 34, 34, 34, 29,
> > +	29, 29, 27, 27, 29, 29, 32, 32,
> > +	34, 34, 37, 38, 37, 35, 35, 34,
> > +	35, 38, 38, 40, 40, 40, 48, 48,
> > +	46, 46, 56, 56, 58, 69, 69, 83
> > +};
> > +
> > +#define m_iq(i) (((64 + i) << 8) | mpeg_default_intra_quant[i])
> > +
> > +static const u8 mpeg_default_non_intra_quant[64] = {
> > +	16, 16, 16, 16, 16, 16, 16, 16,
> > +	16, 16, 16, 16, 16, 16, 16, 16,
> > +	16, 16, 16, 16, 16, 16, 16, 16,
> > +	16, 16, 16, 16, 16, 16, 16, 16,
> > +	16, 16, 16, 16, 16, 16, 16, 16,
> > +	16, 16, 16, 16, 16, 16, 16, 16,
> > +	16, 16, 16, 16, 16, 16, 16, 16,
> > +	16, 16, 16, 16, 16, 16, 16, 16
> > +};
> > +
> > +#define m_niq(i) ((i << 8) | mpeg_default_non_intra_quant[i])
> > +
> > +void sunxi_cedrus_mpeg2_setup(struct sunxi_cedrus_ctx *ctx,
> > +			      struct sunxi_cedrus_run *run)
> > +{
> > +	struct sunxi_cedrus_dev *dev = ctx->dev;
> > +	const struct v4l2_ctrl_mpeg2_frame_hdr *frame_hdr = run->mpeg2.hdr;
> > +
> > +	u16 width = DIV_ROUND_UP(frame_hdr->width, 16);
> > +	u16 height = DIV_ROUND_UP(frame_hdr->height, 16);
> > +
> > +	u32 pic_header = 0;
> > +	u32 vld_len = frame_hdr->slice_len - frame_hdr->slice_pos;
> > +	int i;
> > +
> > +	struct vb2_buffer *fwd_vb2_buf, *bwd_vb2_buf;
> > +	dma_addr_t src_buf_addr, dst_luma_addr, dst_chroma_addr;
> > +	dma_addr_t fwd_luma = 0, fwd_chroma = 0, bwd_luma = 0, bwd_chroma = 0;
> > +
> > +
> > +	fwd_vb2_buf = ctx->dst_bufs[frame_hdr->forward_ref_index];
> > +	if (fwd_vb2_buf) {
> > +		fwd_luma = vb2_dma_contig_plane_dma_addr(fwd_vb2_buf, 0);
> > +		fwd_chroma = vb2_dma_contig_plane_dma_addr(fwd_vb2_buf, 1);
> > +	}
> > +
> > +	bwd_vb2_buf = ctx->dst_bufs[frame_hdr->backward_ref_index];
> > +	if (bwd_vb2_buf) {
> > +		bwd_luma = vb2_dma_contig_plane_dma_addr(bwd_vb2_buf, 0);
> > +		bwd_chroma = vb2_dma_contig_plane_dma_addr(bwd_vb2_buf, 1);
> > +	}
> > +
> > +	/* Activate MPEG engine. */
> > +	sunxi_cedrus_engine_enable(dev, SUNXI_CEDRUS_ENGINE_MPEG);
> > +
> > +	/* Set quantization matrices. */
> > +	for (i = 0; i < 64; i++) {
> > +		sunxi_cedrus_write(dev, m_iq(i), VE_MPEG_IQ_MIN_INPUT);
> > +		sunxi_cedrus_write(dev, m_niq(i), VE_MPEG_IQ_MIN_INPUT);
> > +	}
> > +
> > +	/* Set frame dimensions. */
> > +	sunxi_cedrus_write(dev, width << 8 | height, VE_MPEG_SIZE);
> > +	sunxi_cedrus_write(dev, width << 20 | height << 4, VE_MPEG_FRAME_SIZE);
> > +
> > +	/* Set MPEG picture header. */
> > +	pic_header |= (frame_hdr->picture_coding_type & 0xf) << 28;
> > +	pic_header |= (frame_hdr->f_code[0][0] & 0xf) << 24;
> > +	pic_header |= (frame_hdr->f_code[0][1] & 0xf) << 20;
> > +	pic_header |= (frame_hdr->f_code[1][0] & 0xf) << 16;
> > +	pic_header |= (frame_hdr->f_code[1][1] & 0xf) << 12;
> > +	pic_header |= (frame_hdr->intra_dc_precision & 0x3) << 10;
> > +	pic_header |= (frame_hdr->picture_structure & 0x3) << 8;
> > +	pic_header |= (frame_hdr->top_field_first & 0x1) << 7;
> > +	pic_header |= (frame_hdr->frame_pred_frame_dct & 0x1) << 6;
> > +	pic_header |= (frame_hdr->concealment_motion_vectors & 0x1) << 5;
> > +	pic_header |= (frame_hdr->q_scale_type & 0x1) << 4;
> > +	pic_header |= (frame_hdr->intra_vlc_format & 0x1) << 3;
> > +	pic_header |= (frame_hdr->alternate_scan & 0x1) << 2;
> > +	sunxi_cedrus_write(dev, pic_header, VE_MPEG_PIC_HDR);
> > +
> > +	/* Enable interrupt and an unknown control flag. */
> > +	sunxi_cedrus_write(dev, VE_MPEG_CTRL_MPEG2, VE_MPEG_CTRL);
> > +
> > +	/* Macroblock address. */
> > +	sunxi_cedrus_write(dev, 0, VE_MPEG_MBA);
> > +
> > +	/* Clear previous errors. */
> > +	sunxi_cedrus_write(dev, 0, VE_MPEG_ERROR);
> > +
> > +	/* Clear correct macroblocks register. */
> > +	sunxi_cedrus_write(dev, 0, VE_MPEG_CTR_MB);
> > +
> > +	/* Forward and backward prediction reference buffers. */
> > +	sunxi_cedrus_write(dev, fwd_luma, VE_MPEG_FWD_LUMA);
> > +	sunxi_cedrus_write(dev, fwd_chroma, VE_MPEG_FWD_CHROMA);
> > +	sunxi_cedrus_write(dev, bwd_luma, VE_MPEG_BACK_LUMA);
> > +	sunxi_cedrus_write(dev, bwd_chroma, VE_MPEG_BACK_CHROMA);
> > +
> > +	/* Destination luma and chroma buffers. */
> > +	dst_luma_addr = vb2_dma_contig_plane_dma_addr(&run->dst->vb2_buf, 0);
> > +	dst_chroma_addr = vb2_dma_contig_plane_dma_addr(&run->dst->vb2_buf, 1);
> > +	sunxi_cedrus_write(dev, dst_luma_addr, VE_MPEG_REC_LUMA);
> > +	sunxi_cedrus_write(dev, dst_chroma_addr, VE_MPEG_REC_CHROMA);
> > +	sunxi_cedrus_write(dev, dst_luma_addr, VE_MPEG_ROT_LUMA);
> > +	sunxi_cedrus_write(dev, dst_chroma_addr, VE_MPEG_ROT_CHROMA);
> > +
> > +	/* Source offset and length in bits. */
> > +	sunxi_cedrus_write(dev, frame_hdr->slice_pos, VE_MPEG_VLD_OFFSET);
> > +	sunxi_cedrus_write(dev, vld_len, VE_MPEG_VLD_LEN);
> > +
> > +	/* Source beginning and end addresses. */
> > +	src_buf_addr = vb2_dma_contig_plane_dma_addr(&run->src->vb2_buf, 0);
> > +	sunxi_cedrus_write(dev, VE_MPEG_VLD_ADDR_VAL(src_buf_addr),
> > +			   VE_MPEG_VLD_ADDR);
> > +	sunxi_cedrus_write(dev, src_buf_addr + VBV_SIZE - 1, VE_MPEG_VLD_END);
> > +}
> > +
> > +void sunxi_cedrus_mpeg2_trigger(struct sunxi_cedrus_ctx *ctx, bool mpeg1)
> > +{
> > +	struct sunxi_cedrus_dev *dev = ctx->dev;
> > +
> > +	/* Trigger MPEG engine. */
> > +	if (mpeg1)
> > +		sunxi_cedrus_write(dev, VE_TRIG_MPEG1, VE_MPEG_TRIGGER);
> > +	else
> > +		sunxi_cedrus_write(dev, VE_TRIG_MPEG2, VE_MPEG_TRIGGER);
> > +}
> > diff --git a/drivers/media/platform/sunxi/cedrus/sunxi_cedrus_mpeg2.h b/drivers/media/platform/sunxi/cedrus/sunxi_cedrus_mpeg2.h
> > new file mode 100644
> > index 000000000000..b572001d47f2
> > --- /dev/null
> > +++ b/drivers/media/platform/sunxi/cedrus/sunxi_cedrus_mpeg2.h
> > @@ -0,0 +1,33 @@
> > +/*
> > + * Sunxi-Cedrus VPU driver
> > + *
> > + * Copyright (C) 2018 Paul Kocialkowski <paul.kocialkowski@bootlin.com>
> > + * Copyright (C) 2016 Florent Revest <florent.revest@free-electrons.com>
> > + *
> > + * Based on the vim2m driver, that is:
> > + *
> > + * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
> > + * Pawel Osciak, <pawel@osciak.com>
> > + * Marek Szyprowski, <m.szyprowski@samsung.com>
> > + *
> > + * This software is licensed under the terms of the GNU General Public
> > + * License version 2, as published by the Free Software Foundation, and
> > + * may be copied, distributed, and modified under those terms.
> > + *
> > + * This program is distributed in the hope that it will be useful,
> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > + * GNU General Public License for more details.
> > + */
> > +
> > +#ifndef _SUNXI_CEDRUS_MPEG2_H_
> > +#define _SUNXI_CEDRUS_MPEG2_H_
> > +
> > +struct sunxi_cedrus_ctx;
> > +struct sunxi_cedrus_run;
> > +
> > +void sunxi_cedrus_mpeg2_setup(struct sunxi_cedrus_ctx *ctx,
> > +			      struct sunxi_cedrus_run *run);
> > +void sunxi_cedrus_mpeg2_trigger(struct sunxi_cedrus_ctx *ctx, bool mpeg1);
> > +
> > +#endif
> > diff --git a/drivers/media/platform/sunxi/cedrus/sunxi_cedrus_regs.h b/drivers/media/platform/sunxi/cedrus/sunxi_cedrus_regs.h
> > new file mode 100644
> > index 000000000000..6705d41dad07
> > --- /dev/null
> > +++ b/drivers/media/platform/sunxi/cedrus/sunxi_cedrus_regs.h
> > @@ -0,0 +1,175 @@
> > +/*
> > + * Sunxi-Cedrus VPU driver
> > + *
> > + * Copyright (C) 2018 Paul Kocialkowski <paul.kocialkowski@bootlin.com>
> > + * Copyright (C) 2016 Florent Revest <florent.revest@free-electrons.com>
> > + *
> > + * Based on the vim2m driver, that is:
> > + *
> > + * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
> > + * Pawel Osciak, <pawel@osciak.com>
> > + * Marek Szyprowski, <m.szyprowski@samsung.com>
> > + *
> > + * This software is licensed under the terms of the GNU General Public
> > + * License version 2, as published by the Free Software Foundation, and
> > + * may be copied, distributed, and modified under those terms.
> > + *
> > + * This program is distributed in the hope that it will be useful,
> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > + * GNU General Public License for more details.
> > + */
> > +
> > +#ifndef _SUNXI_CEDRUS_REGS_H_
> > +#define _SUNXI_CEDRUS_REGS_H_
> > +
> > +/*
> > + * For more information, consult http://linux-sunxi.org/VE_Register_guide
> > + */
> > +
> > +/* VE_MPEG_CTRL:
> > + * The bit 3 (0x8) is used to enable IRQs
> > + * The other bits are unknown but needed
> > + */
> > +#define VE_MPEG_CTRL_MPEG2	0x800001b8
> > +#define VE_MPEG_CTRL_MPEG4	(0x80084118 | BIT(7))
> > +#define VE_MPEG_CTRL_MPEG4_P	(VE_MPEG_CTRL_MPEG4 | BIT(12))
> > +
> > +/* VE_MPEG_VLD_ADDR:
> > + * The bits 27 to 4 are used for the address
> > + * The bits 31 to 28 (0x7) are used to select the MPEG or JPEG engine
> > + */
> > +#define VE_MPEG_VLD_ADDR_VAL(x)	((x & 0x0ffffff0) | (x >> 28) | (0x7 << 28))
> > +
> > +/* VE_MPEG_TRIGGER:
> > + * The first three bits are used to trigger the engine
> > + * The bits 24 to 26 are used to select the input format (1 for MPEG1, 2 for
> > + *                           MPEG2, 4 for MPEG4)
> > + * The bit 21 (0x8) is used to disable bitstream error handling
> > + *
> > + * In MPEG4 the w*h value is somehow used for an offset, unknown but needed
> > + */
> > +#define VE_TRIG_MPEG1		0x8100000f
> > +#define VE_TRIG_MPEG2		0x8200000f
> > +#define VE_TRIG_MPEG4(w, h)	(0x8400000d | ((w * h) << 8))
> > +
> > +/* VE_MPEG_SDROT_CTRL:
> > + * The bit 8 at zero is used to disable x downscaling
> > + * The bit 10 at 0 is used to disable y downscaling
> > + * The other bits are unknown but needed
> > + */
> > +#define VE_NO_SDROT_CTRL	0x40620000
> > +
> > +/* Decent size fo video buffering verifier */
> > +#define VBV_SIZE		(1024 * 1024)
> > +
> > +/* Registers addresses */
> > +#define VE_CTRL				0x000
> > +/*
> > + * The datasheet states that this should be set to 2MB on a 32bits
> > + * DDR-3.
> > + */
> > +#define VE_CTRL_REC_WR_MODE_2MB			(1 << 20)
> > +#define VE_CTRL_REC_WR_MODE_1MB			(0 << 20)
> > +
> > +#define VE_CTRL_CACHE_BUS_BW_128		(3 << 16)
> > +#define VE_CTRL_CACHE_BUS_BW_256		(2 << 16)
> > +
> > +#define VE_CTRL_DEC_MODE_DISABLED		(7 << 0)
> > +#define VE_CTRL_DEC_MODE_H265			(4 << 0)
> > +#define VE_CTRL_DEC_MODE_H264			(1 << 0)
> > +#define VE_CTRL_DEC_MODE_MPEG			(0 << 0)
> > +
> > +#define VE_VERSION			0x0f0
> > +
> > +#define VE_MPEG_PIC_HDR			0x100
> > +#define VE_MPEG_VOP_HDR			0x104
> > +#define VE_MPEG_SIZE			0x108
> > +#define VE_MPEG_FRAME_SIZE		0x10c
> > +#define VE_MPEG_MBA			0x110
> > +#define VE_MPEG_CTRL			0x114
> > +#define VE_MPEG_TRIGGER			0x118
> > +#define VE_MPEG_STATUS			0x11c
> > +#define VE_MPEG_TRBTRD_FIELD		0x120
> > +#define VE_MPEG_TRBTRD_FRAME		0x124
> > +#define VE_MPEG_VLD_ADDR		0x128
> > +#define VE_MPEG_VLD_OFFSET		0x12c
> > +#define VE_MPEG_VLD_LEN			0x130
> > +#define VE_MPEG_VLD_END			0x134
> > +#define VE_MPEG_MBH_ADDR		0x138
> > +#define VE_MPEG_DCAC_ADDR		0x13c
> > +#define VE_MPEG_NCF_ADDR		0x144
> > +#define VE_MPEG_REC_LUMA		0x148
> > +#define VE_MPEG_REC_CHROMA		0x14c
> > +#define VE_MPEG_FWD_LUMA		0x150
> > +#define VE_MPEG_FWD_CHROMA		0x154
> > +#define VE_MPEG_BACK_LUMA		0x158
> > +#define VE_MPEG_BACK_CHROMA		0x15c
> > +#define VE_MPEG_IQ_MIN_INPUT		0x180
> > +#define VE_MPEG_QP_INPUT		0x184
> > +#define VE_MPEG_JPEG_SIZE		0x1b8
> > +#define VE_MPEG_JPEG_RES_INT		0x1c0
> > +#define VE_MPEG_ERROR			0x1c4
> > +#define VE_MPEG_CTR_MB			0x1c8
> > +#define VE_MPEG_ROT_LUMA		0x1cc
> > +#define VE_MPEG_ROT_CHROMA		0x1d0
> > +#define VE_MPEG_SDROT_CTRL		0x1d4
> > +#define VE_MPEG_RAM_WRITE_PTR		0x1e0
> > +#define VE_MPEG_RAM_WRITE_DATA		0x1e4
> > +
> > +#define VE_H264_FRAME_SIZE		0x200
> > +#define VE_H264_PIC_HDR			0x204
> > +#define VE_H264_SLICE_HDR		0x208
> > +#define VE_H264_SLICE_HDR2		0x20c
> > +#define VE_H264_PRED_WEIGHT		0x210
> > +#define VE_H264_QP_PARAM		0x21c
> > +#define VE_H264_CTRL			0x220
> > +#define VE_H264_TRIGGER			0x224
> > +#define VE_H264_STATUS			0x228
> > +#define VE_H264_CUR_MB_NUM		0x22c
> > +#define VE_H264_VLD_ADDR		0x230
> > +#define VE_H264_VLD_OFFSET		0x234
> > +#define VE_H264_VLD_LEN			0x238
> > +#define VE_H264_VLD_END			0x23c
> > +#define VE_H264_SDROT_CTRL		0x240
> > +#define VE_H264_OUTPUT_FRAME_IDX	0x24c
> > +#define VE_H264_EXTRA_BUFFER1		0x250
> > +#define VE_H264_EXTRA_BUFFER2		0x254
> > +#define VE_H264_BASIC_BITS		0x2dc
> > +#define VE_H264_RAM_WRITE_PTR		0x2e0
> > +#define VE_H264_RAM_WRITE_DATA		0x2e4
> > +
> > +#define VE_SRAM_H264_PRED_WEIGHT_TABLE	0x000
> > +#define VE_SRAM_H264_FRAMEBUFFER_LIST	0x400
> > +#define VE_SRAM_H264_REF_LIST0		0x640
> > +#define VE_SRAM_H264_REF_LIST1		0x664
> > +#define VE_SRAM_H264_SCALING_LISTS	0x800
> > +
> > +#define VE_ISP_INPUT_SIZE		0xa00
> > +#define VE_ISP_INPUT_STRIDE		0xa04
> > +#define VE_ISP_CTRL			0xa08
> > +#define VE_ISP_INPUT_LUMA		0xa78
> > +#define VE_ISP_INPUT_CHROMA		0xa7c
> > +
> > +#define VE_AVC_PARAM			0xb04
> > +#define VE_AVC_QP			0xb08
> > +#define VE_AVC_MOTION_EST		0xb10
> > +#define VE_AVC_CTRL			0xb14
> > +#define VE_AVC_TRIGGER			0xb18
> > +#define VE_AVC_STATUS			0xb1c
> > +#define VE_AVC_BASIC_BITS		0xb20
> > +#define VE_AVC_UNK_BUF			0xb60
> > +#define VE_AVC_VLE_ADDR			0xb80
> > +#define VE_AVC_VLE_END			0xb84
> > +#define VE_AVC_VLE_OFFSET		0xb88
> > +#define VE_AVC_VLE_MAX			0xb8c
> > +#define VE_AVC_VLE_LENGTH		0xb90
> > +#define VE_AVC_REF_LUMA			0xba0
> > +#define VE_AVC_REF_CHROMA		0xba4
> > +#define VE_AVC_REC_LUMA			0xbb0
> > +#define VE_AVC_REC_CHROMA		0xbb4
> > +#define VE_AVC_REF_SLUMA		0xbb8
> > +#define VE_AVC_REC_SLUMA		0xbbc
> > +#define VE_AVC_MB_INFO			0xbc0
> > +
> > +#endif
> > diff --git a/drivers/media/platform/sunxi/cedrus/sunxi_cedrus_video.c b/drivers/media/platform/sunxi/cedrus/sunxi_cedrus_video.c
> > new file mode 100644
> > index 000000000000..089abfe6bfeb
> > --- /dev/null
> > +++ b/drivers/media/platform/sunxi/cedrus/sunxi_cedrus_video.c
> > @@ -0,0 +1,505 @@
> > +/*
> > + * Sunxi-Cedrus VPU driver
> > + *
> > + * Copyright (C) 2018 Paul Kocialkowski <paul.kocialkowski@bootlin.com>
> > + * Copyright (C) 2016 Florent Revest <florent.revest@free-electrons.com>
> > + *
> > + * Based on the vim2m driver, that is:
> > + *
> > + * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
> > + * Pawel Osciak, <pawel@osciak.com>
> > + * Marek Szyprowski, <m.szyprowski@samsung.com>
> > + *
> > + * This software is licensed under the terms of the GNU General Public
> > + * License version 2, as published by the Free Software Foundation, and
> > + * may be copied, distributed, and modified under those terms.
> > + *
> > + * This program is distributed in the hope that it will be useful,
> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > + * GNU General Public License for more details.
> > + */
> > +
> > +#include <media/videobuf2-dma-contig.h>
> > +#include <media/v4l2-device.h>
> > +#include <media/v4l2-ioctl.h>
> > +#include <media/v4l2-ctrls.h>
> > +#include <media/v4l2-event.h>
> > +#include <media/v4l2-mem2mem.h>
> > +
> > +#include "sunxi_cedrus_common.h"
> > +#include "sunxi_cedrus_mpeg2.h"
> > +#include "sunxi_cedrus_dec.h"
> > +#include "sunxi_cedrus_hw.h"
> > +
> > +/* Flags that indicate a format can be used for capture/output. */
> > +#define SUNXI_CEDRUS_CAPTURE	BIT(0)
> > +#define SUNXI_CEDRUS_OUTPUT	BIT(1)
> > +
> > +#define SUNXI_CEDRUS_MIN_WIDTH	16U
> > +#define SUNXI_CEDRUS_MIN_HEIGHT	16U
> > +#define SUNXI_CEDRUS_MAX_WIDTH	3840U
> > +#define SUNXI_CEDRUS_MAX_HEIGHT	2160U
> > +
> > +static struct sunxi_cedrus_fmt formats[] = {
> > +	{
> > +		.fourcc = V4L2_PIX_FMT_MB32_NV12,
> > +		.types	= SUNXI_CEDRUS_CAPTURE,
> > +		.depth = 2,
> > +		.num_planes = 2,
> > +	},
> > +	{
> > +		.fourcc = V4L2_PIX_FMT_MPEG2_FRAME,
> > +		.types	= SUNXI_CEDRUS_OUTPUT,
> > +		.num_planes = 1,
> > +	},
> > +};
> > +
> > +#define NUM_FORMATS ARRAY_SIZE(formats)
> > +
> > +static struct sunxi_cedrus_fmt *find_format(struct v4l2_format *f)
> > +{
> > +	struct sunxi_cedrus_fmt *fmt;
> > +	unsigned int k;
> > +
> > +	for (k = 0; k < NUM_FORMATS; k++) {
> > +		fmt = &formats[k];
> > +		if (fmt->fourcc == f->fmt.pix_mp.pixelformat)
> > +			break;
> > +	}
> > +
> > +	if (k == NUM_FORMATS)
> > +		return NULL;
> > +
> > +	return &formats[k];
> > +}
> > +
> > +static inline struct sunxi_cedrus_ctx *file2ctx(struct file *file)
> > +{
> > +	return container_of(file->private_data, struct sunxi_cedrus_ctx, fh);
> > +}
> > +
> > +static int vidioc_querycap(struct file *file, void *priv,
> > +			   struct v4l2_capability *cap)
> > +{
> > +	strncpy(cap->driver, SUNXI_CEDRUS_NAME, sizeof(cap->driver) - 1);
> > +	strncpy(cap->card, SUNXI_CEDRUS_NAME, sizeof(cap->card) - 1);
> > +	snprintf(cap->bus_info, sizeof(cap->bus_info),
> > +		 "platform:%s", SUNXI_CEDRUS_NAME);
> > +	cap->device_caps = V4L2_CAP_VIDEO_M2M_MPLANE | V4L2_CAP_STREAMING;
> > +	cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
> > +	return 0;
> > +}
> > +
> > +static int enum_fmt(struct v4l2_fmtdesc *f, u32 type)
> > +{
> > +	struct sunxi_cedrus_fmt *fmt;
> > +	int i, num = 0;
> > +
> > +	for (i = 0; i < NUM_FORMATS; ++i) {
> > +		if (formats[i].types & type) {
> > +			/* index-th format of type type found ? */
> > +			if (num == f->index)
> > +				break;
> > +			/*
> > +			 * Correct type but haven't reached our index yet,
> > +			 * just increment per-type index
> > +			 */
> > +			++num;
> > +		}
> > +	}
> > +
> > +	if (i < NUM_FORMATS) {
> > +		fmt = &formats[i];
> > +		f->pixelformat = fmt->fourcc;
> > +		return 0;
> > +	}
> > +
> > +	return -EINVAL;
> > +}
> > +
> > +static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
> > +				   struct v4l2_fmtdesc *f)
> > +{
> > +	return enum_fmt(f, SUNXI_CEDRUS_CAPTURE);
> > +}
> > +
> > +static int vidioc_enum_fmt_vid_out(struct file *file, void *priv,
> > +				   struct v4l2_fmtdesc *f)
> > +{
> > +	return enum_fmt(f, SUNXI_CEDRUS_OUTPUT);
> > +}
> > +
> > +static int vidioc_g_fmt(struct sunxi_cedrus_ctx *ctx, struct v4l2_format *f)
> > +{
> > +	switch (f->type) {
> > +	case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
> > +		f->fmt.pix_mp = ctx->dst_fmt;
> > +		break;
> > +	case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
> > +		f->fmt.pix_mp = ctx->src_fmt;
> > +		break;
> > +	default:
> > +		dev_dbg(ctx->dev->dev, "invalid buf type\n");
> > +		return -EINVAL;
> > +	}
> > +
> > +	return 0;
> > +}
> > +
> > +static int vidioc_g_fmt_vid_out(struct file *file, void *priv,
> > +				struct v4l2_format *f)
> > +{
> > +	return vidioc_g_fmt(file2ctx(file), f);
> > +}
> > +
> > +static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
> > +				struct v4l2_format *f)
> > +{
> > +	return vidioc_g_fmt(file2ctx(file), f);
> > +}
> > +
> > +static int vidioc_try_fmt(struct v4l2_format *f, struct sunxi_cedrus_fmt *fmt)
> > +{
> > +	int i;
> > +	__u32 bpl;
> > +
> > +	f->fmt.pix_mp.field = V4L2_FIELD_NONE;
> > +	f->fmt.pix_mp.num_planes = fmt->num_planes;
> > +
> > +	switch (f->type) {
> > +	case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
> > +		if (f->fmt.pix_mp.plane_fmt[0].sizeimage == 0)
> > +			return -EINVAL;
> > +
> > +		f->fmt.pix_mp.plane_fmt[0].bytesperline = 0;
> > +		break;
> > +	case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
> > +		/* Limit to hardware min/max. */
> > +		f->fmt.pix_mp.width = clamp(f->fmt.pix_mp.width,
> > +			SUNXI_CEDRUS_MIN_WIDTH, SUNXI_CEDRUS_MAX_WIDTH);
> > +		f->fmt.pix_mp.height = clamp(f->fmt.pix_mp.height,
> > +			SUNXI_CEDRUS_MIN_HEIGHT, SUNXI_CEDRUS_MAX_HEIGHT);
> > +
> > +		for (i = 0; i < f->fmt.pix_mp.num_planes; ++i) {
> > +			bpl = (f->fmt.pix_mp.width * fmt->depth) >> 3;
> > +			f->fmt.pix_mp.plane_fmt[i].bytesperline = bpl;
> > +			f->fmt.pix_mp.plane_fmt[i].sizeimage =
> > +				f->fmt.pix_mp.height * bpl;
> > +		}
> > +		break;
> > +	}
> > +	return 0;
> > +}
> > +
> > +static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
> > +				  struct v4l2_format *f)
> > +{
> > +	struct sunxi_cedrus_fmt *fmt;
> > +	struct sunxi_cedrus_ctx *ctx = file2ctx(file);
> > +
> > +	fmt = find_format(f);
> > +	if (!fmt) {
> > +		f->fmt.pix_mp.pixelformat = formats[0].fourcc;
> > +		fmt = find_format(f);
> > +	}
> > +	if (!(fmt->types & SUNXI_CEDRUS_CAPTURE)) {
> > +		v4l2_err(&ctx->dev->v4l2_dev,
> > +			 "Fourcc format (0x%08x) invalid.\n",
> > +			 f->fmt.pix_mp.pixelformat);
> > +		return -EINVAL;
> > +	}
> > +
> > +	return vidioc_try_fmt(f, fmt);
> > +}
> > +
> > +static int vidioc_try_fmt_vid_out(struct file *file, void *priv,
> > +				  struct v4l2_format *f)
> > +{
> > +	struct sunxi_cedrus_fmt *fmt;
> > +	struct sunxi_cedrus_ctx *ctx = file2ctx(file);
> > +
> > +	fmt = find_format(f);
> > +	if (!fmt) {
> > +		f->fmt.pix_mp.pixelformat = formats[0].fourcc;
> > +		fmt = find_format(f);
> > +	}
> > +	if (!(fmt->types & SUNXI_CEDRUS_OUTPUT)) {
> > +		v4l2_err(&ctx->dev->v4l2_dev,
> > +			 "Fourcc format (0x%08x) invalid.\n",
> > +			 f->fmt.pix_mp.pixelformat);
> > +		return -EINVAL;
> > +	}
> > +
> > +	return vidioc_try_fmt(f, fmt);
> > +}
> > +
> > +static int vidioc_s_fmt(struct sunxi_cedrus_ctx *ctx, struct v4l2_format *f)
> > +{
> > +	struct v4l2_pix_format_mplane *pix_fmt_mp = &f->fmt.pix_mp;
> > +	struct sunxi_cedrus_fmt *fmt;
> > +	int i, ret = 0;
> > +
> > +	switch (f->type) {
> > +	case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
> > +		ctx->vpu_src_fmt = find_format(f);
> > +		ctx->src_fmt = *pix_fmt_mp;
> > +		break;
> > +	case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
> > +		fmt = find_format(f);
> > +		ctx->vpu_dst_fmt = fmt;
> > +
> > +		for (i = 0; i < fmt->num_planes; ++i) {
> > +			pix_fmt_mp->plane_fmt[i].bytesperline =
> > +				pix_fmt_mp->width * fmt->depth;
> > +			pix_fmt_mp->plane_fmt[i].sizeimage =
> > +				pix_fmt_mp->plane_fmt[i].bytesperline
> > +				* pix_fmt_mp->height;
> > +		}
> > +		ctx->dst_fmt = *pix_fmt_mp;
> > +		break;
> > +	default:
> > +		dev_dbg(ctx->dev->dev, "invalid buf type\n");
> > +		return -EINVAL;
> > +	}
> > +
> > +	return ret;
> > +}
> > +
> > +static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
> > +				struct v4l2_format *f)
> > +{
> > +	int ret;
> > +
> > +	ret = vidioc_try_fmt_vid_cap(file, priv, f);
> > +	if (ret)
> > +		return ret;
> > +
> > +	return vidioc_s_fmt(file2ctx(file), f);
> > +}
> > +
> > +static int vidioc_s_fmt_vid_out(struct file *file, void *priv,
> > +				struct v4l2_format *f)
> > +{
> > +	int ret;
> > +
> > +	ret = vidioc_try_fmt_vid_out(file, priv, f);
> > +	if (ret)
> > +		return ret;
> > +
> > +	ret = vidioc_s_fmt(file2ctx(file), f);
> > +	return ret;
> > +}
> > +
> > +const struct v4l2_ioctl_ops sunxi_cedrus_ioctl_ops = {
> > +	.vidioc_querycap		= vidioc_querycap,
> > +
> > +	.vidioc_enum_fmt_vid_cap	= vidioc_enum_fmt_vid_cap,
> > +	.vidioc_g_fmt_vid_cap_mplane	= vidioc_g_fmt_vid_cap,
> > +	.vidioc_try_fmt_vid_cap_mplane	= vidioc_try_fmt_vid_cap,
> > +	.vidioc_s_fmt_vid_cap_mplane	= vidioc_s_fmt_vid_cap,
> > +
> > +	.vidioc_enum_fmt_vid_out_mplane = vidioc_enum_fmt_vid_out,
> > +	.vidioc_g_fmt_vid_out_mplane	= vidioc_g_fmt_vid_out,
> > +	.vidioc_try_fmt_vid_out_mplane	= vidioc_try_fmt_vid_out,
> > +	.vidioc_s_fmt_vid_out_mplane	= vidioc_s_fmt_vid_out,
> > +
> > +	.vidioc_reqbufs			= v4l2_m2m_ioctl_reqbufs,
> > +	.vidioc_querybuf		= v4l2_m2m_ioctl_querybuf,
> > +	.vidioc_qbuf			= v4l2_m2m_ioctl_qbuf,
> > +	.vidioc_dqbuf			= v4l2_m2m_ioctl_dqbuf,
> > +	.vidioc_prepare_buf		= v4l2_m2m_ioctl_prepare_buf,
> > +	.vidioc_create_bufs		= v4l2_m2m_ioctl_create_bufs,
> > +	.vidioc_expbuf			= v4l2_m2m_ioctl_expbuf,
> > +
> > +	.vidioc_streamon		= v4l2_m2m_ioctl_streamon,
> > +	.vidioc_streamoff		= v4l2_m2m_ioctl_streamoff,
> > +
> > +	.vidioc_subscribe_event		= v4l2_ctrl_subscribe_event,
> > +	.vidioc_unsubscribe_event	= v4l2_event_unsubscribe,
> > +};
> > +
> > +static int sunxi_cedrus_queue_setup(struct vb2_queue *vq, unsigned int *nbufs,
> > +				    unsigned int *nplanes, unsigned int sizes[],
> > +				    struct device *alloc_devs[])
> > +{
> > +	struct sunxi_cedrus_ctx *ctx = vb2_get_drv_priv(vq);
> > +
> > +	if (*nbufs < 1)
> > +		*nbufs = 1;
> > +
> > +	if (*nbufs > VIDEO_MAX_FRAME)
> > +		*nbufs = VIDEO_MAX_FRAME;
> 
> No need for these two checks, the vb2 core takes care of that.

That is definitely good to know.

Thanks a lot for the feedback!

Cheers,

Paul

> > +
> > +	switch (vq->type) {
> > +	case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
> > +		*nplanes = ctx->vpu_src_fmt->num_planes;
> > +
> > +		sizes[0] = ctx->src_fmt.plane_fmt[0].sizeimage;
> > +		break;
> > +
> > +	case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
> > +		*nplanes = ctx->vpu_dst_fmt->num_planes;
> > +
> > +		sizes[0] = round_up(ctx->dst_fmt.plane_fmt[0].sizeimage, 8);
> > +		sizes[1] = sizes[0];
> > +		break;
> > +
> > +	default:
> > +		dev_dbg(ctx->dev->dev, "invalid queue type: %d\n", vq->type);
> > +		return -EINVAL;
> > +	}
> > +
> > +	return 0;
> > +}
> > +
> > +static int sunxi_cedrus_buf_init(struct vb2_buffer *vb)
> > +{
> > +	struct vb2_queue *vq = vb->vb2_queue;
> > +	struct sunxi_cedrus_ctx *ctx = container_of(vq->drv_priv,
> > +			struct sunxi_cedrus_ctx, fh);
> > +
> > +	if (vq->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
> > +		ctx->dst_bufs[vb->index] = vb;
> > +
> > +	return 0;
> > +}
> > +
> > +static void sunxi_cedrus_buf_cleanup(struct vb2_buffer *vb)
> > +{
> > +	struct vb2_queue *vq = vb->vb2_queue;
> > +	struct sunxi_cedrus_ctx *ctx = container_of(vq->drv_priv,
> > +			struct sunxi_cedrus_ctx, fh);
> > +
> > +	if (vq->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
> > +		ctx->dst_bufs[vb->index] = NULL;
> > +}
> > +
> > +static int sunxi_cedrus_buf_prepare(struct vb2_buffer *vb)
> > +{
> > +	struct sunxi_cedrus_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
> > +	struct vb2_queue *vq = vb->vb2_queue;
> > +	int i;
> > +
> > +	dev_dbg(ctx->dev->dev, "type: %d\n", vb->vb2_queue->type);
> > +
> > +	switch (vq->type) {
> > +	case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
> > +		if (vb2_plane_size(vb, 0)
> > +		    < ctx->src_fmt.plane_fmt[0].sizeimage) {
> > +			dev_dbg(ctx->dev->dev, "plane too small for output\n");
> > +			return -EINVAL;
> > +		}
> > +		break;
> > +
> > +	case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
> > +		for (i = 0; i < ctx->vpu_dst_fmt->num_planes; ++i) {
> > +			if (vb2_plane_size(vb, i)
> > +			    < ctx->dst_fmt.plane_fmt[i].sizeimage) {
> > +				dev_dbg(ctx->dev->dev,
> > +					"plane %d too small for capture\n", i);
> > +				break;
> > +			}
> > +		}
> > +
> > +		if (i != ctx->vpu_dst_fmt->num_planes)
> > +			return -EINVAL;
> > +		break;
> > +
> > +	default:
> > +		dev_dbg(ctx->dev->dev, "invalid queue type: %d\n", vq->type);
> > +		return -EINVAL;
> > +	}
> > +
> > +	return 0;
> > +}
> > +
> > +static void sunxi_cedrus_stop_streaming(struct vb2_queue *q)
> > +{
> > +	struct sunxi_cedrus_ctx *ctx = vb2_get_drv_priv(q);
> > +	struct vb2_v4l2_buffer *vbuf;
> > +	unsigned long flags;
> > +
> > +	flush_scheduled_work();
> > +	for (;;) {
> > +		spin_lock_irqsave(&ctx->dev->irq_lock, flags);
> > +
> > +		if (V4L2_TYPE_IS_OUTPUT(q->type))
> > +			vbuf = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx);
> > +		else
> > +			vbuf = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx);
> > +
> > +		spin_unlock_irqrestore(&ctx->dev->irq_lock, flags);
> > +
> > +		if (vbuf == NULL)
> > +			return;
> > +
> > +		v4l2_ctrl_request_complete(vbuf->vb2_buf.req_obj.req,
> > +					   &ctx->hdl);
> > +		v4l2_m2m_buf_done(vbuf, VB2_BUF_STATE_ERROR);
> > +	}
> > +}
> > +
> > +static void sunxi_cedrus_buf_queue(struct vb2_buffer *vb)
> > +{
> > +	struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
> > +	struct sunxi_cedrus_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
> > +
> > +	v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, vbuf);
> > +}
> > +
> > +static void sunxi_cedrus_buf_request_complete(struct vb2_buffer *vb)
> > +{
> > +	struct sunxi_cedrus_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
> > +
> > +	v4l2_ctrl_request_complete(vb->req_obj.req, &ctx->hdl);
> > +}
> > +
> > +static struct vb2_ops sunxi_cedrus_qops = {
> > +	.queue_setup		= sunxi_cedrus_queue_setup,
> > +	.buf_prepare		= sunxi_cedrus_buf_prepare,
> > +	.buf_init		= sunxi_cedrus_buf_init,
> > +	.buf_cleanup		= sunxi_cedrus_buf_cleanup,
> > +	.buf_queue		= sunxi_cedrus_buf_queue,
> > +	.buf_request_complete	= sunxi_cedrus_buf_request_complete,
> > +	.stop_streaming		= sunxi_cedrus_stop_streaming,
> > +	.wait_prepare		= vb2_ops_wait_prepare,
> > +	.wait_finish		= vb2_ops_wait_finish,
> > +};
> > +
> > +int sunxi_cedrus_queue_init(void *priv, struct vb2_queue *src_vq,
> > +			    struct vb2_queue *dst_vq)
> > +{
> > +	struct sunxi_cedrus_ctx *ctx = priv;
> > +	int ret;
> > +
> > +	src_vq->type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
> > +	src_vq->io_modes = VB2_MMAP | VB2_DMABUF;
> > +	src_vq->drv_priv = ctx;
> > +	src_vq->buf_struct_size = sizeof(struct sunxi_cedrus_buffer);
> > +	src_vq->allow_zero_bytesused = 1;
> > +	src_vq->min_buffers_needed = 1;
> > +	src_vq->ops = &sunxi_cedrus_qops;
> > +	src_vq->mem_ops = &vb2_dma_contig_memops;
> > +	src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
> > +	src_vq->lock = &ctx->dev->dev_mutex;
> > +	src_vq->dev = ctx->dev->dev;
> > +
> > +	ret = vb2_queue_init(src_vq);
> > +	if (ret)
> > +		return ret;
> > +
> > +	dst_vq->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
> > +	dst_vq->io_modes = VB2_MMAP | VB2_DMABUF;
> > +	dst_vq->drv_priv = ctx;
> > +	dst_vq->buf_struct_size = sizeof(struct sunxi_cedrus_buffer);
> > +	dst_vq->allow_zero_bytesused = 1;
> > +	dst_vq->min_buffers_needed = 1;
> > +	dst_vq->ops = &sunxi_cedrus_qops;
> > +	dst_vq->mem_ops = &vb2_dma_contig_memops;
> > +	dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
> > +	dst_vq->lock = &ctx->dev->dev_mutex;
> > +	dst_vq->dev = ctx->dev->dev;
> > +
> > +	return vb2_queue_init(dst_vq);
> > +}
> > diff --git a/drivers/media/platform/sunxi/cedrus/sunxi_cedrus_video.h b/drivers/media/platform/sunxi/cedrus/sunxi_cedrus_video.h
> > new file mode 100644
> > index 000000000000..d5b7f881c386
> > --- /dev/null
> > +++ b/drivers/media/platform/sunxi/cedrus/sunxi_cedrus_video.h
> > @@ -0,0 +1,31 @@
> > +/*
> > + * Sunxi-Cedrus VPU driver
> > + *
> > + * Copyright (C) 2018 Paul Kocialkowski <paul.kocialkowski@bootlin.com>
> > + * Copyright (C) 2016 Florent Revest <florent.revest@free-electrons.com>
> > + *
> > + * Based on the vim2m driver, that is:
> > + *
> > + * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
> > + * Pawel Osciak, <pawel@osciak.com>
> > + * Marek Szyprowski, <m.szyprowski@samsung.com>
> > + *
> > + * This software is licensed under the terms of the GNU General Public
> > + * License version 2, as published by the Free Software Foundation, and
> > + * may be copied, distributed, and modified under those terms.
> > + *
> > + * This program is distributed in the hope that it will be useful,
> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > + * GNU General Public License for more details.
> > + */
> > +
> > +#ifndef _SUNXI_CEDRUS_VIDEO_H_
> > +#define _SUNXI_CEDRUS_VIDEO_H_
> > +
> > +extern const struct v4l2_ioctl_ops sunxi_cedrus_ioctl_ops;
> > +
> > +int sunxi_cedrus_queue_init(void *priv, struct vb2_queue *src_vq,
> > +			    struct vb2_queue *dst_vq);
> > +
> > +#endif
> > 
> 
> Regards,
> 
> 	Hans
-- 
Paul Kocialkowski, Bootlin (formerly Free Electrons)
Embedded Linux and kernel engineering
https://bootlin.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: This is a digitally signed message part
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180614/2735d42c/attachment-0001.sig>

^ permalink raw reply

* [PATCH v3 11/14] media: platform: Add Sunxi-Cedrus VPU decoder driver
From: Paul Kocialkowski @ 2018-06-14 15:39 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20180507154201.4vz3y6j7u7kzfud6@flea>

Hi,

On Mon, 2018-05-07 at 17:42 +0200, Maxime Ripard wrote:
> On Mon, May 07, 2018 at 02:44:57PM +0200, Paul Kocialkowski wrote:
> > +#define SYSCON_SRAM_CTRL_REG0	0x0
> > +#define SYSCON_SRAM_C1_MAP_VE	0x7fffffff
> 
> This isn't needed anymore

Will do in the next revision.

> > +	dev->ahb_clk = devm_clk_get(dev->dev, "ahb");
> > +	if (IS_ERR(dev->ahb_clk)) {
> > +		dev_err(dev->dev, "failed to get ahb clock\n");
> > +		return PTR_ERR(dev->ahb_clk);
> > +	}
> > +	dev->mod_clk = devm_clk_get(dev->dev, "mod");
> > +	if (IS_ERR(dev->mod_clk)) {
> > +		dev_err(dev->dev, "failed to get mod clock\n");
> > +		return PTR_ERR(dev->mod_clk);
> > +	}
> > +	dev->ram_clk = devm_clk_get(dev->dev, "ram");
> > +	if (IS_ERR(dev->ram_clk)) {
> > +		dev_err(dev->dev, "failed to get ram clock\n");
> > +		return PTR_ERR(dev->ram_clk);
> > +	}
> 
> Please add some blank lines between those blocks

Yes, looks much better that way!

> > +	dev->rstc = devm_reset_control_get(dev->dev, NULL);
> 
> You're not checking the error code here

Good catch.

> > +	dev->syscon = syscon_regmap_lookup_by_phandle(dev->dev->of_node,
> > +						      "syscon");
> > +	if (IS_ERR(dev->syscon)) {
> > +		dev->syscon = NULL;
> > +	} else {
> > +		regmap_write_bits(dev->syscon, SYSCON_SRAM_CTRL_REG0,
> > +				  SYSCON_SRAM_C1_MAP_VE,
> > +				  SYSCON_SRAM_C1_MAP_VE);
> > +	}
> 
> You don't need the syscon part anymore either

Correct.

> > +	ret = clk_prepare_enable(dev->ahb_clk);
> > +	if (ret) {
> > +		dev_err(dev->dev, "could not enable ahb clock\n");
> > +		return -EFAULT;
> > +	}
> > +	ret = clk_prepare_enable(dev->mod_clk);
> > +	if (ret) {
> > +		clk_disable_unprepare(dev->ahb_clk);
> > +		dev_err(dev->dev, "could not enable mod clock\n");
> > +		return -EFAULT;
> > +	}
> > +	ret = clk_prepare_enable(dev->ram_clk);
> > +	if (ret) {
> > +		clk_disable_unprepare(dev->mod_clk);
> > +		clk_disable_unprepare(dev->ahb_clk);
> > +		dev_err(dev->dev, "could not enable ram clock\n");
> > +		return -EFAULT;
> > +	}
> > +
> > +	ret = reset_control_reset(dev->rstc);
> > +	if (ret) {
> > +		clk_disable_unprepare(dev->ram_clk);
> > +		clk_disable_unprepare(dev->mod_clk);
> > +		clk_disable_unprepare(dev->ahb_clk);
> > +		dev_err(dev->dev, "could not reset device\n");
> > +		return -EFAULT;
> 
> labels would simplify this greatly, and you should also release the
> sram and the memory region here.

I'll definitely do a sweep and add labels/gotos for this before
submitting the nexr revision.

Thanks for the review!

Cheers,

Paul

-- 
Paul Kocialkowski, Bootlin (formerly Free Electrons)
Embedded Linux and kernel engineering
https://bootlin.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: This is a digitally signed message part
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180614/71c6d245/attachment.sig>

^ permalink raw reply

* [PATCH v3 4/4] arm64: dts: allwinner: a64: add SRAM controller device tree node
From: Chen-Yu Tsai @ 2018-06-14 15:35 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20180614153548.9644-1-wens@csie.org>

From: Icenowy Zheng <icenowy@aosc.io>

Allwinner A64 has a SRAM controller, and in the device tree currently
we have a syscon node to enable EMAC driver to access the EMAC clock
register. As SRAM controller driver can now export regmap for this
register, replace the syscon node to the SRAM controller device node,
and let EMAC driver to acquire its EMAC clock regmap.

Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
[wens at csie.org: Updated compatible string]
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
 arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi
index 1b2ef28c42bd..87968dafe1dc 100644
--- a/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi
+++ b/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi
@@ -169,9 +169,24 @@
 		ranges;
 
 		syscon: syscon at 1c00000 {
-			compatible = "allwinner,sun50i-a64-system-controller",
-				"syscon";
+			compatible = "allwinner,sun50i-a64-system-control";
 			reg = <0x01c00000 0x1000>;
+			#address-cells = <1>;
+			#size-cells = <1>;
+			ranges;
+
+			sram_c: sram at 18000 {
+				compatible = "mmio-sram";
+				reg = <0x00018000 0x28000>;
+				#address-cells = <1>;
+				#size-cells = <1>;
+				ranges = <0 0x00018000 0x28000>;
+
+				de2_sram: sram-section at 0 {
+					compatible = "allwinner,sun50i-a64-sram-c";
+					reg = <0x0000 0x28000>;
+				};
+			};
 		};
 
 		dma: dma-controller at 1c02000 {
-- 
2.17.1

^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox