[RFC,4/5] rpmsg: add rpmsg support for mt8183 SCP.
Add a simple rpmsg support for mt8183 SCP, that use IPI / IPC directly. Signed-off-by: Pi-Hsun Shih --- There are lots of TODO comments on things that are not done yet / I have doubt on whether it's the best way to do it. drivers/remoteproc/mtk_common.h | 3 + drivers/remoteproc/mtk_scp.c | 30 ++- drivers/remoteproc/mtk_scp_ipi.c | 2 +- drivers/rpmsg/Kconfig | 5 + drivers/rpmsg/Makefile| 1 + drivers/rpmsg/mtk_rpmsg.c | 341 ++ include/linux/platform_data/mtk_scp.h | 7 + include/linux/rpmsg/mtk_rpmsg.h | 34 +++ 8 files changed, 419 insertions(+), 4 deletions(-) create mode 100644 drivers/rpmsg/mtk_rpmsg.c create mode 100644 include/linux/rpmsg/mtk_rpmsg.h diff --git a/drivers/remoteproc/mtk_common.h b/drivers/remoteproc/mtk_common.h index ae55fca2ce2d7..cdd4919a402a8 100644 --- a/drivers/remoteproc/mtk_common.h +++ b/drivers/remoteproc/mtk_common.h @@ -54,6 +54,9 @@ struct mtk_scp { void __iomem *cpu_addr; phys_addr_t phys_addr; size_t dram_size; + + struct platform_device *pdev; + struct rproc_subdev *rpmsg_subdev; }; /** diff --git a/drivers/remoteproc/mtk_scp.c b/drivers/remoteproc/mtk_scp.c index aaebe96bcfd66..0ed7904809dce 100644 --- a/drivers/remoteproc/mtk_scp.c +++ b/drivers/remoteproc/mtk_scp.c @@ -12,6 +12,7 @@ #include #include #include +#include #include "remoteproc_internal.h" #include "mtk_common.h" @@ -278,6 +279,24 @@ static int scp_map_memory_region(struct mtk_scp *scp) return 0; } +static void scp_add_rpmsg_subdev(struct mtk_scp *scp) +{ + scp->rpmsg_subdev = + mtk_rpmsg_create_rproc_subdev(scp->pdev, scp->rproc); + if (scp->rpmsg_subdev) { + rproc_add_subdev(scp->rproc, scp->rpmsg_subdev); + } +} + +static void scp_remove_rpmsg_subdev(struct mtk_scp *scp) +{ + if (scp->rpmsg_subdev) { + rproc_remove_subdev(scp->rproc, scp->rpmsg_subdev); + mtk_rpmsg_destroy_rproc_subdev(scp->rpmsg_subdev); + scp->rpmsg_subdev = NULL; + } +} + static int mtk_scp_probe(struct platform_device *pdev) { struct device *dev = >dev; @@ -301,6 +320,7 @@ static int mtk_scp_probe(struct platform_device *pdev) scp = (struct mtk_scp *)rproc->priv; scp->rproc = rproc; scp->dev = dev; + scp->pdev = pdev; platform_set_drvdata(pdev, scp); res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "sram"); @@ -372,13 +392,16 @@ static int mtk_scp_probe(struct platform_device *pdev) init_waitqueue_head(>run.wq); init_waitqueue_head(>ack_wq); + scp_add_rpmsg_subdev(scp); + ret = rproc_add(rproc); if (ret) - goto destroy_mutex; + goto remove_subdev; - return ret; + return 0; -destroy_mutex: +remove_subdev: + scp_remove_rpmsg_subdev(scp); mutex_destroy(>scp_mutex); free_rproc: rproc_free(rproc); @@ -390,6 +413,7 @@ static int mtk_scp_remove(struct platform_device *pdev) { struct mtk_scp *scp = platform_get_drvdata(pdev); + scp_remove_rpmsg_subdev(scp); rproc_del(scp->rproc); rproc_free(scp->rproc); diff --git a/drivers/remoteproc/mtk_scp_ipi.c b/drivers/remoteproc/mtk_scp_ipi.c index 6923066869874..1b72c5cc72d36 100644 --- a/drivers/remoteproc/mtk_scp_ipi.c +++ b/drivers/remoteproc/mtk_scp_ipi.c @@ -50,7 +50,7 @@ int scp_ipi_send(struct platform_device *pdev, unsigned long timeout; int ret; - if (WARN(id <= IPI_SCP_INIT || id >= IPI_MAX || + if (WARN(id <= IPI_NS_SERVICE || id >= IPI_MAX || len > sizeof(send_obj->share_buf) || !buf, "failed to send ipi message\n")) return -EINVAL; diff --git a/drivers/rpmsg/Kconfig b/drivers/rpmsg/Kconfig index d0322b41eca54..b8364a397bb60 100644 --- a/drivers/rpmsg/Kconfig +++ b/drivers/rpmsg/Kconfig @@ -55,4 +55,9 @@ config RPMSG_VIRTIO select RPMSG select VIRTIO +config RPMSG_MTK_SCP + tristate "MediaTek SCP" + depends on MTK_SCP + select RPMSG + endmenu diff --git a/drivers/rpmsg/Makefile b/drivers/rpmsg/Makefile index 9aa859502d275..a0c1dcefa36ee 100644 --- a/drivers/rpmsg/Makefile +++ b/drivers/rpmsg/Makefile @@ -6,3 +6,4 @@ obj-$(CONFIG_RPMSG_QCOM_GLINK_NATIVE) += qcom_glink_native.o obj-$(CONFIG_RPMSG_QCOM_GLINK_SMEM) += qcom_glink_smem.o obj-$(CONFIG_RPMSG_QCOM_SMD) += qcom_smd.o obj-$(CONFIG_RPMSG_VIRTIO) += virtio_rpmsg_bus.o +obj-$(CONFIG_RPMSG_MTK_SCP)+= mtk_rpmsg.o diff --git a/drivers/rpmsg/mtk_rpmsg.c b/drivers/rpmsg/mtk_rpmsg.c new file mode 100644 index 0..66b39eaae51f2 --- /dev/null +++ b/drivers/rpmsg/mtk_rpmsg.c @@ -0,0 +1,341 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Copyright 2018 Google LLC. + +#include +#include +#include +#include +#include +#include
[RFC,5/5] mfd: cros_ec: add EC host command support using rpmsg.
Add EC host command support through rpmsg. Signed-off-by: Pi-Hsun Shih --- drivers/mfd/cros_ec_dev.c | 9 ++ drivers/platform/chrome/Kconfig | 8 ++ drivers/platform/chrome/Makefile| 1 + drivers/platform/chrome/cros_ec_rpmsg.c | 164 include/linux/mfd/cros_ec.h | 1 + include/linux/mfd/cros_ec_commands.h| 2 + 6 files changed, 185 insertions(+) create mode 100644 drivers/platform/chrome/cros_ec_rpmsg.c diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c index 2d0fee488c5aa8..67983853413d07 100644 --- a/drivers/mfd/cros_ec_dev.c +++ b/drivers/mfd/cros_ec_dev.c @@ -414,6 +414,15 @@ static int ec_device_probe(struct platform_device *pdev) device_initialize(>class_dev); cdev_init(>cdev, ); + if (cros_ec_check_features(ec, EC_FEATURE_SCP)) { + dev_info(dev, "SCP detected.\n"); + /* +* Help userspace differentiating ECs from SCP, +* regardless of the probing order. +*/ + ec_platform->ec_name = CROS_EC_DEV_SCP_NAME; + } + /* * Add the class device * Link to the character device for creating the /dev entry diff --git a/drivers/platform/chrome/Kconfig b/drivers/platform/chrome/Kconfig index 16b1615958aa2d..b03d68eb732177 100644 --- a/drivers/platform/chrome/Kconfig +++ b/drivers/platform/chrome/Kconfig @@ -72,6 +72,14 @@ config CROS_EC_SPI response time cannot be guaranteed, we support ignoring 'pre-amble' bytes before the response actually starts. +config CROS_EC_RPMSG + tristate "ChromeOS Embedded Controller (rpmsg)" + depends on MFD_CROS_EC && RPMSG + help + If you say Y here, you get support for talking to the ChromeOS EC + through rpmsg. This uses a simple byte-level protocol with a + checksum. + config CROS_EC_LPC tristate "ChromeOS Embedded Controller (LPC)" depends on MFD_CROS_EC && ACPI && (X86 || COMPILE_TEST) diff --git a/drivers/platform/chrome/Makefile b/drivers/platform/chrome/Makefile index cd591bf872bbe9..3e3190af2b50f4 100644 --- a/drivers/platform/chrome/Makefile +++ b/drivers/platform/chrome/Makefile @@ -8,6 +8,7 @@ cros_ec_ctl-objs:= cros_ec_sysfs.o cros_ec_lightbar.o \ obj-$(CONFIG_CROS_EC_CTL) += cros_ec_ctl.o obj-$(CONFIG_CROS_EC_I2C) += cros_ec_i2c.o obj-$(CONFIG_CROS_EC_SPI) += cros_ec_spi.o +obj-$(CONFIG_CROS_EC_RPMSG)+= cros_ec_rpmsg.o cros_ec_lpcs-objs := cros_ec_lpc.o cros_ec_lpc_reg.o cros_ec_lpcs-$(CONFIG_CROS_EC_LPC_MEC) += cros_ec_lpc_mec.o obj-$(CONFIG_CROS_EC_LPC) += cros_ec_lpcs.o diff --git a/drivers/platform/chrome/cros_ec_rpmsg.c b/drivers/platform/chrome/cros_ec_rpmsg.c new file mode 100644 index 00..f123ca6d1c029c --- /dev/null +++ b/drivers/platform/chrome/cros_ec_rpmsg.c @@ -0,0 +1,164 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Copyright 2018 Google LLC. + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/** + * cros_ec_cmd_xfer_rpmsg - Transfer a message over rpmsg and receive the reply + * + * This is only used for old EC proto version, and is not supported for this + * driver. + * + * @ec_dev: ChromeOS EC device + * @ec_msg: Message to transfer + */ +static int cros_ec_cmd_xfer_rpmsg(struct cros_ec_device *ec_dev, + struct cros_ec_command *ec_msg) +{ + return -EINVAL; +} + +/** + * cros_ec_pkt_xfer_rpmsg - Transfer a packet over rpmsg and receive the reply + * + * @ec_dev: ChromeOS EC device + * @ec_msg: Message to transfer + */ +static int cros_ec_pkt_xfer_rpmsg(struct cros_ec_device *ec_dev, + struct cros_ec_command *ec_msg) +{ + struct ec_host_response *response; + struct rpmsg_device *rpdev = ec_dev->priv; + int len; + u8 sum; + int ret; + int i; + + ec_msg->result = 0; + len = cros_ec_prepare_tx(ec_dev, ec_msg); + dev_dbg(ec_dev->dev, "prepared, len=%d\n", len); + + // TODO: This currently relies on that mtk_rpmsg send actually blocks + // until ack. Should do the wait here instead. + ret = rpmsg_send(rpdev->ept, ec_dev->dout, len); + + if (ret) { + dev_err(ec_dev->dev, "rpmsg send failed\n"); + return ret; + } + + /* check response error code */ + response = (struct ec_host_response *)ec_dev->din; + ec_msg->result = response->result; + + ret = cros_ec_check_result(ec_dev, ec_msg); + if (ret) + goto exit; + + if (response->data_len > ec_msg->insize) { + dev_err(ec_dev->dev, "packet too long (%d bytes, expected %d)", + response->data_len, ec_msg->insize); + ret = -EMSGSIZE; +
[RFC,2/5] remoteproc/mediatek: add SCP support for mt8183
From: Erin Lo Provide a basic driver to control Cortex M4 co-processor Signed-off-by: Erin Lo --- drivers/remoteproc/Kconfig| 9 + drivers/remoteproc/Makefile | 1 + drivers/remoteproc/mtk_scp.c | 568 ++ include/linux/platform_data/mtk_scp.h | 136 ++ 4 files changed, 714 insertions(+) create mode 100644 drivers/remoteproc/mtk_scp.c create mode 100644 include/linux/platform_data/mtk_scp.h diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig index f0abd26080447..ee0bda2376893 100644 --- a/drivers/remoteproc/Kconfig +++ b/drivers/remoteproc/Kconfig @@ -22,6 +22,15 @@ config IMX_REMOTEPROC It's safe to say N here. +config MTK_SCP +tristate "Mediatek SCP support" +depends on ARCH_MEDIATEK +help + Say y here to support Mediatek's SCP (Cortex M4 + on MT8183) via the remote processor framework. + + It's safe to say N here. + config OMAP_REMOTEPROC tristate "OMAP remoteproc support" depends on ARCH_OMAP4 || SOC_OMAP5 diff --git a/drivers/remoteproc/Makefile b/drivers/remoteproc/Makefile index ce5d061e92be5..98e3498dbbe0e 100644 --- a/drivers/remoteproc/Makefile +++ b/drivers/remoteproc/Makefile @@ -10,6 +10,7 @@ remoteproc-y += remoteproc_sysfs.o remoteproc-y += remoteproc_virtio.o remoteproc-y += remoteproc_elf_loader.o obj-$(CONFIG_IMX_REMOTEPROC) += imx_rproc.o +obj-$(CONFIG_MTK_SCP) += mtk_scp.o obj-$(CONFIG_OMAP_REMOTEPROC) += omap_remoteproc.o obj-$(CONFIG_WKUP_M3_RPROC)+= wkup_m3_rproc.o obj-$(CONFIG_DA8XX_REMOTEPROC) += da8xx_remoteproc.o diff --git a/drivers/remoteproc/mtk_scp.c b/drivers/remoteproc/mtk_scp.c new file mode 100644 index 0..7a1a8fe53b54a --- /dev/null +++ b/drivers/remoteproc/mtk_scp.c @@ -0,0 +1,568 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Copyright (c) 2018 MediaTek Inc. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "remoteproc_internal.h" + +#define MT8183_SW_RSTN 0x0 +#define MT8183_SW_RSTN_BIT BIT(0) +#define MT8183_SCP_TO_HOST 0x1C +#define MT8183_SCP_IPC_INT_BIT BIT(0) +#define MT8183_SCP_WDT_INT_BIT BIT(8) +#define MT8183_HOST_TO_SCP 0x28 +#define MT8183_HOST_IPC_INT_BITBIT(0) +#define MT8183_SCP_SRAM_PDN0x402C + +#define INIT_TIMEOUT_MS2000 +#define IPI_TIMEOUT_MS 2000 +#define SCP_FW_VER_LEN 32 + +#define MAX_CODE_SIZE 0x50 + +struct scp_run { + u32 signaled; + s8 fw_ver[SCP_FW_VER_LEN]; + u32 dec_capability; + u32 enc_capability; + wait_queue_head_t wq; +}; + +struct scp_ipi_desc { + ipi_handler_t handler; + const char *name; + void *priv; +}; + +struct mtk_scp { + struct device *dev; + struct rproc *rproc; + struct clk *clk; + void __iomem *reg_base; + void __iomem *sram_base; + size_t sram_size; + + struct share_obj *recv_buf; + struct share_obj *send_buf; + struct scp_run run; + struct mutex scp_mutex; /* for protecting mtk_scp data structure */ + struct scp_ipi_desc ipi_desc[IPI_MAX]; + bool ipi_id_ack[IPI_MAX]; + wait_queue_head_t ack_wq; + + void __iomem *cpu_addr; + phys_addr_t phys_addr; + size_t dram_size; +}; + +/** + * struct share_obj - SRAM buffer shared with + * AP and SCP + * + * @id:IPI id + * @len: share buffer length + * @share_buf: share buffer data + */ +struct share_obj { + s32 id; + u32 len; + u8 share_buf[288]; +}; + +int scp_ipi_register(struct platform_device *pdev, +enum ipi_id id, +ipi_handler_t handler, +const char *name, +void *priv) +{ + struct mtk_scp *scp = platform_get_drvdata(pdev); + struct scp_ipi_desc *ipi_desc; + + if (!scp) { + dev_err(>dev, "scp device is not ready\n"); + return -EPROBE_DEFER; + } + + if (WARN(id < 0 || id >= IPI_MAX || handler == NULL, + "register scp ipi id %d with invalid arguments\n", id)) + return -EINVAL; + + ipi_desc = scp->ipi_desc; + ipi_desc[id].name = name; + ipi_desc[id].handler = handler; + ipi_desc[id].priv = priv; + + return 0; +} +EXPORT_SYMBOL_GPL(scp_ipi_register); + +int scp_ipi_send(struct platform_device *pdev, +enum ipi_id id, void *buf, +unsigned int len, +unsigned int wait) +{ + struct mtk_scp *scp = platform_get_drvdata(pdev); + struct share_obj *send_obj = scp->send_buf; + unsigned long timeout; + int ret; + +
[RFC,0/5] Add support for mt8183 SCP.
Add support for controlling and communicating with mt8183's system control processor (SCP), using the remoteproc & rpmsg framework. And also add a cros_ec driver for CrOS EC host command over rpmsg. The overall structure of the series is: * remoteproc/mtk_scp.c: Control the start / stop of SCP (Patch 2). * remoteproc/mtk_scp_ipi.c: Communicates to SCP using inter-processor interrupt (IPI) and shared memory (Patch 2, 3). * rpmsg/mtk_rpmsg.c: Wrapper to wrap the IPI communication into a rpmsg device. Supports name service for SCP firmware to announce channels (Patch 4). * platform/chrome/cros_ec_rpmsg.c: Communicates with the SCP over the rpmsg framework (like what platform/chrome/cros_ec_{i2c,spi}.c does) (Patch 5). Since I'm not familiar with the remoteproc / rpmsg framework, and there are not much other custom rpmsg driver for reference, would like some review / comments on the overall structure of the driver. Erin Lo (2): dt-bindings: Add a binding for Mediatek SCP remoteproc/mediatek: add SCP support for mt8183 Pi-Hsun Shih (3): remoteproc: move IPI interface into separate file. rpmsg: add rpmsg support for mt8183 SCP. mfd: cros_ec: add EC host command support using rpmsg. .../bindings/remoteproc/mtk,scp.txt | 10 + drivers/mfd/cros_ec_dev.c | 10 + drivers/platform/chrome/Kconfig | 8 + drivers/platform/chrome/Makefile | 1 + drivers/platform/chrome/cros_ec_rpmsg.c | 164 +++ drivers/remoteproc/Kconfig| 9 + drivers/remoteproc/Makefile | 1 + drivers/remoteproc/mtk_common.h | 76 +++ drivers/remoteproc/mtk_scp.c | 441 ++ drivers/remoteproc/mtk_scp_ipi.c | 109 + drivers/rpmsg/Kconfig | 5 + drivers/rpmsg/Makefile| 1 + drivers/rpmsg/mtk_rpmsg.c | 341 ++ include/linux/mfd/cros_ec.h | 1 + include/linux/mfd/cros_ec_commands.h | 2 + include/linux/platform_data/mtk_scp.h | 143 ++ include/linux/rpmsg/mtk_rpmsg.h | 34 ++ 17 files changed, 1356 insertions(+) create mode 100644 Documentation/devicetree/bindings/remoteproc/mtk,scp.txt create mode 100644 drivers/platform/chrome/cros_ec_rpmsg.c create mode 100644 drivers/remoteproc/mtk_common.h create mode 100644 drivers/remoteproc/mtk_scp.c create mode 100644 drivers/remoteproc/mtk_scp_ipi.c create mode 100644 drivers/rpmsg/mtk_rpmsg.c create mode 100644 include/linux/platform_data/mtk_scp.h create mode 100644 include/linux/rpmsg/mtk_rpmsg.h -- 2.20.1.415.g653613c723-goog
[RFC,1/5] dt-bindings: Add a binding for Mediatek SCP
From: Erin Lo Add a DT binding documentation of SCP for the MT8183 SoC from Mediatek. Signed-off-by: Erin Lo --- .../devicetree/bindings/remoteproc/mtk,scp.txt | 10 ++ 1 file changed, 10 insertions(+) create mode 100644 Documentation/devicetree/bindings/remoteproc/mtk,scp.txt diff --git a/Documentation/devicetree/bindings/remoteproc/mtk,scp.txt b/Documentation/devicetree/bindings/remoteproc/mtk,scp.txt new file mode 100644 index 0..b07e5c4ca9af1 --- /dev/null +++ b/Documentation/devicetree/bindings/remoteproc/mtk,scp.txt @@ -0,0 +1,9 @@ +Mediatek SCP Bindings + + +This binding provides support for ARM Cortex M4 Co-processor found on some +Mediatek SoCs. + +Required properties: +- compatible Should be "mediatek,mt8183-scp" +- clocks Clock for co-processor (See: ../clock/clock-bindings.txt) -- 2.20.1.415.g653613c723-goog
[RFC,3/5] remoteproc: move IPI interface into separate file.
Move the IPI interface into a separate file mtk_scp_ipi.c, so the things that use the interface only can depend on the module only. Signed-off-by: Pi-Hsun Shih --- drivers/remoteproc/Makefile | 2 +- drivers/remoteproc/mtk_common.h | 73 +++ drivers/remoteproc/mtk_scp.c | 153 +-- drivers/remoteproc/mtk_scp_ipi.c | 109 ++ 4 files changed, 184 insertions(+), 153 deletions(-) create mode 100644 drivers/remoteproc/mtk_common.h create mode 100644 drivers/remoteproc/mtk_scp_ipi.c diff --git a/drivers/remoteproc/Makefile b/drivers/remoteproc/Makefile index 98e3498dbbe0e..16b3e5e7a81c8 100644 --- a/drivers/remoteproc/Makefile +++ b/drivers/remoteproc/Makefile @@ -10,7 +10,7 @@ remoteproc-y += remoteproc_sysfs.o remoteproc-y += remoteproc_virtio.o remoteproc-y += remoteproc_elf_loader.o obj-$(CONFIG_IMX_REMOTEPROC) += imx_rproc.o -obj-$(CONFIG_MTK_SCP) += mtk_scp.o +obj-$(CONFIG_MTK_SCP) += mtk_scp.o mtk_scp_ipi.o obj-$(CONFIG_OMAP_REMOTEPROC) += omap_remoteproc.o obj-$(CONFIG_WKUP_M3_RPROC)+= wkup_m3_rproc.o obj-$(CONFIG_DA8XX_REMOTEPROC) += da8xx_remoteproc.o diff --git a/drivers/remoteproc/mtk_common.h b/drivers/remoteproc/mtk_common.h new file mode 100644 index 0..ae55fca2ce2d7 --- /dev/null +++ b/drivers/remoteproc/mtk_common.h @@ -0,0 +1,73 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Copyright (c) 2018 MediaTek Inc. + +#ifndef __RPROC_MTK_COMMON_H +#define __RPROC_MTK_COMMON_H + +#include +#include +#include +#include + +#define MT8183_SW_RSTN 0x0 +#define MT8183_SW_RSTN_BIT BIT(0) +#define MT8183_SCP_TO_HOST 0x1C +#define MT8183_SCP_IPC_INT_BIT BIT(0) +#define MT8183_SCP_WDT_INT_BIT BIT(8) +#define MT8183_HOST_TO_SCP 0x28 +#define MT8183_HOST_IPC_INT_BITBIT(0) +#define MT8183_SCP_SRAM_PDN0x402C + +#define SCP_FW_VER_LEN 32 + +struct scp_run { + u32 signaled; + s8 fw_ver[SCP_FW_VER_LEN]; + u32 dec_capability; + u32 enc_capability; + wait_queue_head_t wq; +}; + +struct scp_ipi_desc { + ipi_handler_t handler; + const char *name; + void *priv; +}; + +struct mtk_scp { + struct device *dev; + struct rproc *rproc; + struct clk *clk; + void __iomem *reg_base; + void __iomem *sram_base; + size_t sram_size; + + struct share_obj *recv_buf; + struct share_obj *send_buf; + struct scp_run run; + struct mutex scp_mutex; /* for protecting mtk_scp data structure */ + struct scp_ipi_desc ipi_desc[IPI_MAX]; + bool ipi_id_ack[IPI_MAX]; + wait_queue_head_t ack_wq; + + void __iomem *cpu_addr; + phys_addr_t phys_addr; + size_t dram_size; +}; + +/** + * struct share_obj - SRAM buffer shared with + * AP and SCP + * + * @id:IPI id + * @len: share buffer length + * @share_buf: share buffer data + */ +struct share_obj { + s32 id; + u32 len; + u8 share_buf[288]; +}; + +#endif diff --git a/drivers/remoteproc/mtk_scp.c b/drivers/remoteproc/mtk_scp.c index 7a1a8fe53b54a..aaebe96bcfd66 100644 --- a/drivers/remoteproc/mtk_scp.c +++ b/drivers/remoteproc/mtk_scp.c @@ -14,163 +14,12 @@ #include #include "remoteproc_internal.h" - -#define MT8183_SW_RSTN 0x0 -#define MT8183_SW_RSTN_BIT BIT(0) -#define MT8183_SCP_TO_HOST 0x1C -#define MT8183_SCP_IPC_INT_BIT BIT(0) -#define MT8183_SCP_WDT_INT_BIT BIT(8) -#define MT8183_HOST_TO_SCP 0x28 -#define MT8183_HOST_IPC_INT_BITBIT(0) -#define MT8183_SCP_SRAM_PDN0x402C +#include "mtk_common.h" #define INIT_TIMEOUT_MS2000 -#define IPI_TIMEOUT_MS 2000 -#define SCP_FW_VER_LEN 32 #define MAX_CODE_SIZE 0x50 -struct scp_run { - u32 signaled; - s8 fw_ver[SCP_FW_VER_LEN]; - u32 dec_capability; - u32 enc_capability; - wait_queue_head_t wq; -}; - -struct scp_ipi_desc { - ipi_handler_t handler; - const char *name; - void *priv; -}; - -struct mtk_scp { - struct device *dev; - struct rproc *rproc; - struct clk *clk; - void __iomem *reg_base; - void __iomem *sram_base; - size_t sram_size; - - struct share_obj *recv_buf; - struct share_obj *send_buf; - struct scp_run run; - struct mutex scp_mutex; /* for protecting mtk_scp data structure */ - struct scp_ipi_desc ipi_desc[IPI_MAX]; - bool ipi_id_ack[IPI_MAX]; - wait_queue_head_t ack_wq; - - void __iomem *cpu_addr; - phys_addr_t phys_addr; - size_t dram_size; -}; - -/** - * struct share_obj - SRAM buffer shared with - *
Re: [PATCH v2 2/3] ASoC: Documentation: Add google,cros-ec-codec
On Mon, Dec 24, 2018 at 10:38 PM Guenter Roeck wrote: > > On Mon, Dec 24, 2018 at 12:39 AM Cheng-Yi Chiang > wrote: > > > > Add documentation for Chrome EC codec driver. > > > > Signed-off-by: Cheng-Yi Chiang > > --- > > Change in v2: Fixed name of driver in MAINTAINERS. > > > > .../bindings/sound/google,cros-ec-codec.txt | 24 +++ > > Since this is a devicetree binding, it will require an Ack from a DT > maintainer. You might want to check the output of > scripts/get_maintainer.pl to make sure you don't miss anyone > important. > > Guenter > Thanks for the suggestion. cc'ed Rob Herring in v3. > > MAINTAINERS | 5 > > 2 files changed, 29 insertions(+) > > create mode 100644 > > Documentation/devicetree/bindings/sound/google,cros-ec-codec.txt > > > > diff --git > > a/Documentation/devicetree/bindings/sound/google,cros-ec-codec.txt > > b/Documentation/devicetree/bindings/sound/google,cros-ec-codec.txt > > new file mode 100644 > > index 0..57718382b3a36 > > --- /dev/null > > +++ b/Documentation/devicetree/bindings/sound/google,cros-ec-codec.txt > > @@ -0,0 +1,24 @@ > > +* Audio codec controlled by ChromeOS EC > > + > > +Google's ChromeOS EC codec is a digital mic codec provided by the > > +Embedded Controller (EC) and is controlled via a host-command interface. > > + > > +An EC codec node should only be found as a sub-node of the EC node (see > > +Documentation/devicetree/bindings/mfd/cros-ec.txt). > > + > > +Required properties: > > +- compatible: Must contain "google,cros-ec-codec" > > +- #sound-dai-cells: Should be 1. The cell specifies number of DAIs. > > + > > +Example: > > + > > +cros-ec@0 { > > + compatible = "google,cros-ec-spi"; > > + > > + ... > > + > > + cros_ec_codec: ec-codec { > > + compatible = "google,cros-ec-codec"; > > + #sound-dai-cells = <1>; > > + }; > > +}; > > diff --git a/MAINTAINERS b/MAINTAINERS > > index 5b9c6af98283b..05e1922624e58 100644 > > --- a/MAINTAINERS > > +++ b/MAINTAINERS > > @@ -3636,6 +3636,11 @@ S: Maintained > > T: git > > git://git.kernel.org/pub/scm/linux/kernel/git/bleung/chrome-platform.git > > F: drivers/platform/chrome/ > > > > +CHROMEOS EC CODEC DRIVER > > +M: Cheng-Yi Chiang > > +S: Maintained > > +F: Documentation/devicetree/bindings/sound/google,cros-ec-codec.txt > > + > > CIRRUS LOGIC AUDIO CODEC DRIVERS > > M: Brian Austin > > M: Paul Handrigan > > -- > > 2.20.1.415.g653613c723-goog > >
Re: [PATCH v2 3/3] ASoC: cros_ec_codec: Add codec driver for Cros EC
Hi Guenter, Thanks a lot for reviewing the patch on holidays. On Mon, Dec 24, 2018 at 10:48 PM Guenter Roeck wrote: > > On Mon, Dec 24, 2018 at 12:45 AM Cheng-Yi Chiang > wrote: > > > > Add a codec driver to control ChromeOS EC codec. > > > > Use EC Host command to enable/disable I2S recording and control other > > configurations. > > > > Signed-off-by: Cheng-Yi Chiang > > --- > > Addressed Enric's comments. > > > > Changes in v2: > > - Many style fixes. Passed checkpatch.pl --strict. > > - Use ChromeOS naming. > > - Remove license boilerplate. > > - Use u8 instead of uint8_t. > > - Remove useless debug messages. > > - Remove useless remove ops. > > - Remove -EPROBE_DEFER in probe. > > > > MAINTAINERS | 2 + > > sound/soc/codecs/Kconfig | 8 + > > sound/soc/codecs/Makefile| 2 + > > sound/soc/codecs/cros_ec_codec.c | 458 +++ > > sound/soc/codecs/cros_ec_codec.h | 21 ++ > > 5 files changed, 491 insertions(+) > > create mode 100644 sound/soc/codecs/cros_ec_codec.c > > create mode 100644 sound/soc/codecs/cros_ec_codec.h > > > > diff --git a/MAINTAINERS b/MAINTAINERS > > index 05e1922624e58..d66f80f3252d7 100644 > > --- a/MAINTAINERS > > +++ b/MAINTAINERS > > @@ -3638,8 +3638,10 @@ F: drivers/platform/chrome/ > > > > CHROMEOS EC CODEC DRIVER > > M: Cheng-Yi Chiang > > +R: Enric Balletbo i Serra > > S: Maintained > > F: Documentation/devicetree/bindings/sound/google,cros-ec-codec.txt > > +F: sound/soc/codecs/cros_ec_codec.* > > > > CIRRUS LOGIC AUDIO CODEC DRIVERS > > M: Brian Austin > > diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig > > index 87cb9c51e6f5a..0b36428159b71 100644 > > --- a/sound/soc/codecs/Kconfig > > +++ b/sound/soc/codecs/Kconfig > > @@ -50,6 +50,7 @@ config SND_SOC_ALL_CODECS > > select SND_SOC_BT_SCO > > select SND_SOC_BD28623 > > select SND_SOC_CQ0093VC > > + select SND_SOC_CROS_EC_CODEC > > select SND_SOC_CS35L32 if I2C > > select SND_SOC_CS35L33 if I2C > > select SND_SOC_CS35L34 if I2C > > @@ -457,6 +458,13 @@ config SND_SOC_CPCAP > > config SND_SOC_CQ0093VC > > tristate > > > > +config SND_SOC_CROS_EC_CODEC > > + tristate "codec driver for ChromeOS EC" > > + depends on MFD_CROS_EC > > + help > > + If you say yes here you will get support for the > > + ChromeOS Embedded Controller's Audio Codec. > > + > > config SND_SOC_CS35L32 > > tristate "Cirrus Logic CS35L32 CODEC" > > depends on I2C > > diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile > > index 9bb3346fab2fe..3cfd8f5f61705 100644 > > --- a/sound/soc/codecs/Makefile > > +++ b/sound/soc/codecs/Makefile > > @@ -42,6 +42,7 @@ snd-soc-bd28623-objs := bd28623.o > > snd-soc-bt-sco-objs := bt-sco.o > > snd-soc-cpcap-objs := cpcap.o > > snd-soc-cq93vc-objs := cq93vc.o > > +snd-soc-cros-ec-codec-objs := cros_ec_codec.o > > snd-soc-cs35l32-objs := cs35l32.o > > snd-soc-cs35l33-objs := cs35l33.o > > snd-soc-cs35l34-objs := cs35l34.o > > @@ -310,6 +311,7 @@ obj-$(CONFIG_SND_SOC_BD28623) += snd-soc-bd28623.o > > obj-$(CONFIG_SND_SOC_BT_SCO) += snd-soc-bt-sco.o > > obj-$(CONFIG_SND_SOC_CQ0093VC) += snd-soc-cq93vc.o > > obj-$(CONFIG_SND_SOC_CPCAP)+= snd-soc-cpcap.o > > +obj-$(CONFIG_SND_SOC_CROS_EC_CODEC)+= snd-soc-cros-ec-codec.o > > obj-$(CONFIG_SND_SOC_CS35L32) += snd-soc-cs35l32.o > > obj-$(CONFIG_SND_SOC_CS35L33) += snd-soc-cs35l33.o > > obj-$(CONFIG_SND_SOC_CS35L34) += snd-soc-cs35l34.o > > diff --git a/sound/soc/codecs/cros_ec_codec.c > > b/sound/soc/codecs/cros_ec_codec.c > > new file mode 100644 > > index 0..39e61bf46b5c0 > > --- /dev/null > > +++ b/sound/soc/codecs/cros_ec_codec.c > > @@ -0,0 +1,458 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > +/* > > + * Driver for ChromeOS Embedded Controller codec. > > + * > > + * This driver uses the cros-ec interface to communicate with the ChromeOS > > + * EC for audio function. > > + */ > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +#include "cros_ec_codec.h" > > + > > +#define MAX_GAIN 43 > > + > > +#define DRV_NAME "cros-ec-codec" > > + > > +static const DECLARE_TLV_DB_SCALE(ec_mic_gain_tlv, 0, 100, 0); > > +/* > > + * Wrapper for EC command. > > + */ > > +static int ec_command(struct snd_soc_component *component, int version, > > + int command, u8 *outdata, int outsize, > > + u8 *indata, int insize) > > +{ > > + struct cros_ec_codec_data *codec_data = > > + snd_soc_component_get_drvdata(component); > > + struct cros_ec_device *ec_device = codec_data->ec_device; > > + struct cros_ec_command *msg; > > + int ret; > > + > > + msg = kzalloc(sizeof(*msg) +
[PATCH v3 3/3] ASoC: cros_ec_codec: Add codec driver for Cros EC
Add a codec driver to control ChromeOS EC codec. Use EC Host command to enable/disable I2S recording and control other configurations. Signed-off-by: Cheng-Yi Chiang --- Changes in v3: 1.remove cros_ec_codec.h. 2.Fix error code overriding in set_i2s_config set_i2s_sample_depth set_bclk get_ec_mic_gain set_ec_mic_gain enable_i2s 3.Fix missing return code in cros_ec_i2s_set_dai_fmt. 4.Simplify return code in cros_ec_i2s_hw_params and mic_gain_put. 5.Remove useless debug message in cros_ec_codec_platform_probe. MAINTAINERS | 2 + sound/soc/codecs/Kconfig | 8 + sound/soc/codecs/Makefile| 2 + sound/soc/codecs/cros_ec_codec.c | 454 +++ 4 files changed, 466 insertions(+) create mode 100644 sound/soc/codecs/cros_ec_codec.c diff --git a/MAINTAINERS b/MAINTAINERS index 05e1922624e58..d66f80f3252d7 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3638,8 +3638,10 @@ F: drivers/platform/chrome/ CHROMEOS EC CODEC DRIVER M: Cheng-Yi Chiang +R: Enric Balletbo i Serra S: Maintained F: Documentation/devicetree/bindings/sound/google,cros-ec-codec.txt +F: sound/soc/codecs/cros_ec_codec.* CIRRUS LOGIC AUDIO CODEC DRIVERS M: Brian Austin diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 87cb9c51e6f5a..0b36428159b71 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -50,6 +50,7 @@ config SND_SOC_ALL_CODECS select SND_SOC_BT_SCO select SND_SOC_BD28623 select SND_SOC_CQ0093VC + select SND_SOC_CROS_EC_CODEC select SND_SOC_CS35L32 if I2C select SND_SOC_CS35L33 if I2C select SND_SOC_CS35L34 if I2C @@ -457,6 +458,13 @@ config SND_SOC_CPCAP config SND_SOC_CQ0093VC tristate +config SND_SOC_CROS_EC_CODEC + tristate "codec driver for ChromeOS EC" + depends on MFD_CROS_EC + help + If you say yes here you will get support for the + ChromeOS Embedded Controller's Audio Codec. + config SND_SOC_CS35L32 tristate "Cirrus Logic CS35L32 CODEC" depends on I2C diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index 9bb3346fab2fe..3cfd8f5f61705 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -42,6 +42,7 @@ snd-soc-bd28623-objs := bd28623.o snd-soc-bt-sco-objs := bt-sco.o snd-soc-cpcap-objs := cpcap.o snd-soc-cq93vc-objs := cq93vc.o +snd-soc-cros-ec-codec-objs := cros_ec_codec.o snd-soc-cs35l32-objs := cs35l32.o snd-soc-cs35l33-objs := cs35l33.o snd-soc-cs35l34-objs := cs35l34.o @@ -310,6 +311,7 @@ obj-$(CONFIG_SND_SOC_BD28623) += snd-soc-bd28623.o obj-$(CONFIG_SND_SOC_BT_SCO) += snd-soc-bt-sco.o obj-$(CONFIG_SND_SOC_CQ0093VC) += snd-soc-cq93vc.o obj-$(CONFIG_SND_SOC_CPCAP)+= snd-soc-cpcap.o +obj-$(CONFIG_SND_SOC_CROS_EC_CODEC)+= snd-soc-cros-ec-codec.o obj-$(CONFIG_SND_SOC_CS35L32) += snd-soc-cs35l32.o obj-$(CONFIG_SND_SOC_CS35L33) += snd-soc-cs35l33.o obj-$(CONFIG_SND_SOC_CS35L34) += snd-soc-cs35l34.o diff --git a/sound/soc/codecs/cros_ec_codec.c b/sound/soc/codecs/cros_ec_codec.c new file mode 100644 index 0..85ea23f4b681c --- /dev/null +++ b/sound/soc/codecs/cros_ec_codec.c @@ -0,0 +1,454 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Driver for ChromeOS Embedded Controller codec. + * + * This driver uses the cros-ec interface to communicate with the ChromeOS + * EC for audio function. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define MAX_GAIN 43 + +#define DRV_NAME "cros-ec-codec" + +/** + * struct cros_ec_codec_data - ChromeOS EC codec driver data. + * @dev: Device structure used in sysfs. + * @ec_device: cros_ec_device structure to talk to the physical device. + * @component: Pointer to the component. + */ +struct cros_ec_codec_data { + struct device *dev; + struct cros_ec_device *ec_device; + struct snd_soc_component *component; +}; + +static const DECLARE_TLV_DB_SCALE(ec_mic_gain_tlv, 0, 100, 0); +/* + * Wrapper for EC command. + */ +static int ec_command(struct snd_soc_component *component, int version, + int command, u8 *outdata, int outsize, + u8 *indata, int insize) +{ + struct cros_ec_codec_data *codec_data = + snd_soc_component_get_drvdata(component); + struct cros_ec_device *ec_device = codec_data->ec_device; + struct cros_ec_command *msg; + int ret; + + msg = kzalloc(sizeof(*msg) + max(insize, outsize), GFP_KERNEL); + if (!msg) + return -ENOMEM; + + msg->version = version; + msg->command = command; + msg->outsize = outsize; + msg->insize = insize; + + if (outsize) + memcpy(msg->data, outdata, outsize); + + ret = cros_ec_cmd_xfer_status(ec_device, msg); + if (ret > 0 && insize)
[PATCH v3 2/3] ASoC: Documentation: Add google,cros-ec-codec
Add documentation for Chrome EC codec driver. Signed-off-by: Cheng-Yi Chiang --- +Rob Herring for reviewing this patch. Hi Rob, Could you please take a look ? Thanks! .../bindings/sound/google,cros-ec-codec.txt | 24 +++ MAINTAINERS | 5 2 files changed, 29 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/google,cros-ec-codec.txt diff --git a/Documentation/devicetree/bindings/sound/google,cros-ec-codec.txt b/Documentation/devicetree/bindings/sound/google,cros-ec-codec.txt new file mode 100644 index 0..57718382b3a36 --- /dev/null +++ b/Documentation/devicetree/bindings/sound/google,cros-ec-codec.txt @@ -0,0 +1,24 @@ +* Audio codec controlled by ChromeOS EC + +Google's ChromeOS EC codec is a digital mic codec provided by the +Embedded Controller (EC) and is controlled via a host-command interface. + +An EC codec node should only be found as a sub-node of the EC node (see +Documentation/devicetree/bindings/mfd/cros-ec.txt). + +Required properties: +- compatible: Must contain "google,cros-ec-codec" +- #sound-dai-cells: Should be 1. The cell specifies number of DAIs. + +Example: + +cros-ec@0 { + compatible = "google,cros-ec-spi"; + + ... + + cros_ec_codec: ec-codec { + compatible = "google,cros-ec-codec"; + #sound-dai-cells = <1>; + }; +}; diff --git a/MAINTAINERS b/MAINTAINERS index 5b9c6af98283b..05e1922624e58 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3636,6 +3636,11 @@ S: Maintained T: git git://git.kernel.org/pub/scm/linux/kernel/git/bleung/chrome-platform.git F: drivers/platform/chrome/ +CHROMEOS EC CODEC DRIVER +M: Cheng-Yi Chiang +S: Maintained +F: Documentation/devicetree/bindings/sound/google,cros-ec-codec.txt + CIRRUS LOGIC AUDIO CODEC DRIVERS M: Brian Austin M: Paul Handrigan -- 2.20.1.415.g653613c723-goog
Re: [PATCH] staging: erofs: fix return type of erofs_workgroup_get
On 2018/12/26 11:34, Gao Xiang wrote: > There exists a return type misuse (`int'->`bool') since all > users assume it fails if only return value != 0, let's fix > the return type to `int' instead of confusing `bool'. > > No logic changes. > > Signed-off-by: Gao Xiang Reviewed-by: Chao Yu Thanks,
[PATCH v3 1/3] mfd: cros_ec: Add commands to control codec
Add EC host commands to control codec on EC. Signed-off-by: Cheng-Yi Chiang Signed-off-by: Lee Jones --- Note: This patch is merged to mfd tree for-mfd-next branch already. But this is still needed on sound tree for-next branch in order to compile cros_ec_codec driver. include/linux/mfd/cros_ec_commands.h | 94 1 file changed, 94 insertions(+) diff --git a/include/linux/mfd/cros_ec_commands.h b/include/linux/mfd/cros_ec_commands.h index 9a9631f0559e2..fc91082d4c357 100644 --- a/include/linux/mfd/cros_ec_commands.h +++ b/include/linux/mfd/cros_ec_commands.h @@ -2790,6 +2790,100 @@ struct ec_response_battery_vendor_param { uint32_t value; } __packed; +/*/ +/* Commands for I2S recording on audio codec. */ + +#define EC_CMD_CODEC_I2S 0x00BC + +enum ec_codec_i2s_subcmd { + EC_CODEC_SET_SAMPLE_DEPTH = 0x0, + EC_CODEC_SET_GAIN = 0x1, + EC_CODEC_GET_GAIN = 0x2, + EC_CODEC_I2S_ENABLE = 0x3, + EC_CODEC_I2S_SET_CONFIG = 0x4, + EC_CODEC_I2S_SET_TDM_CONFIG = 0x5, + EC_CODEC_I2S_SET_BCLK = 0x6, +}; + +enum ec_sample_depth_value { + EC_CODEC_SAMPLE_DEPTH_16 = 0, + EC_CODEC_SAMPLE_DEPTH_24 = 1, +}; + +enum ec_i2s_config { + EC_DAI_FMT_I2S = 0, + EC_DAI_FMT_RIGHT_J = 1, + EC_DAI_FMT_LEFT_J = 2, + EC_DAI_FMT_PCM_A = 3, + EC_DAI_FMT_PCM_B = 4, + EC_DAI_FMT_PCM_TDM = 5, +}; + +struct ec_param_codec_i2s { + /* +* enum ec_codec_i2s_subcmd +*/ + uint8_t cmd; + union { + /* +* EC_CODEC_SET_SAMPLE_DEPTH +* Value should be one of ec_sample_depth_value. +*/ + uint8_t depth; + + /* +* EC_CODEC_SET_GAIN +* Value should be 0~43 for both channels. +*/ + struct ec_param_codec_i2s_set_gain { + uint8_t left; + uint8_t right; + } __packed gain; + + /* +* EC_CODEC_I2S_ENABLE +* 1 to enable, 0 to disable. +*/ + uint8_t i2s_enable; + + /* +* EC_CODEC_I2S_SET_COFNIG +* Value should be one of ec_i2s_config. +*/ + uint8_t i2s_config; + + /* +* EC_CODEC_I2S_SET_TDM_CONFIG +* Value should be one of ec_i2s_config. +*/ + struct ec_param_codec_i2s_tdm { + /* +* 0 to 496 +*/ + int16_t ch0_delay; + /* +* -1 to 496 +*/ + int16_t ch1_delay; + uint8_t adjacent_to_ch0; + uint8_t adjacent_to_ch1; + } __packed tdm_param; + + /* +* EC_CODEC_I2S_SET_BCLK +*/ + uint32_t bclk; + }; +} __packed; + +/* + * For subcommand EC_CODEC_GET_GAIN. + */ +struct ec_response_codec_gain { + uint8_t left; + uint8_t right; +} __packed; + /*/ /* System commands */ -- 2.20.1.415.g653613c723-goog
Re: [PATCH] fs: proc: check status of register_filesystem
On Wed, Dec 26, 2018 at 09:18:56AM +0300, Alexey Dobriyan wrote: > On Tue, Dec 25, 2018 at 09:06:40PM -0600, Kangjie Lu wrote: > > register_filesystem() could fail. The fix issues an error message if it > > fails. > > > - register_filesystem(_fs_type); > > + if (register_filesystem(_fs_type)) > > + pr_err("failed to register the filesystem.\n"); > > No, register_filesystem() should do it. Folks, check when would it fail. If we have something called "proc" already registered by the time when proc_root_init() runs... might as well have been a panic().
[PATCH] target: fix a missing check for match_int
When match_int fails, "arg" is left uninitialized and may contain random value, thus should not be used. The fix checks if match_int fails, and if so, break. Signed-off-by: Kangjie Lu --- drivers/target/target_core_rd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/target/target_core_rd.c b/drivers/target/target_core_rd.c index a6e8106abd6f..3138123143e8 100644 --- a/drivers/target/target_core_rd.c +++ b/drivers/target/target_core_rd.c @@ -573,7 +573,8 @@ static ssize_t rd_set_configfs_dev_params(struct se_device *dev, token = match_token(ptr, tokens, args); switch (token) { case Opt_rd_pages: - match_int(args, ); + if (match_int(args, )) + break; rd_dev->rd_page_count = arg; pr_debug("RAMDISK: Referencing Page" " Count: %u\n", rd_dev->rd_page_count); -- 2.17.2 (Apple Git-113)
Re: [PATCH] scsi: avoid a double-fetch and a redundant copy
On 2018-12-25 3:15 p.m., Kangjie Lu wrote: What we need is only "pack_id", so do not create a heap object or copy the whole object in. The fix efficiently copies "pack_id" only. Now this looks like a worthwhile optimization, in some pretty tricky code. I can't see a security angle in it. Did you test it? Well the code as presented doesn't compile and the management takes a dim view of that. Signed-off-by: Kangjie Lu --- drivers/scsi/sg.c | 12 ++-- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index c6ad00703c5b..4dacbfffd113 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c @@ -446,16 +446,8 @@ sg_read(struct file *filp, char __user *buf, size_t count, loff_t * ppos) } if (old_hdr->reply_len < 0) { if (count >= SZ_SG_IO_HDR) { - sg_io_hdr_t *new_hdr; - new_hdr = kmalloc(SZ_SG_IO_HDR, GFP_KERNEL); - if (!new_hdr) { - retval = -ENOMEM; - goto free_old_hdr; - } - retval =__copy_from_user - (new_hdr, buf, SZ_SG_IO_HDR); - req_pack_id = new_hdr->pack_id; - kfree(new_hdr); + retval = get_user(req_pack_id, + &((sg_io_hdr_t *)buf->pack_id)); The '->' binds higher then the cast and since buf is a 'char *' it doesn't have a member called pack_id . Hopefully your drive to remove redundancy went a little too far and removed the required (but missing) parentheses binding the cast to 'buf'. if (retval) { retval = -EFAULT; goto free_old_hdr; Good work, silly mistake, but its got me thinking, the heap allocation can be replaced by stack since its short. The code in this area is more tricky in the v4 driver because I want to specifically exclude the sg_io_v4 (aka v4) interface being sent through write(2)/read(2). The way to do that is to read the first 32 bit integer which should be 'S' or v3, 'Q' for v4. Hmm, just looking further along my mailer I see the kbuild test robot has picked up the error and you have presented another patch which also won't compile. Please stop doing that; apply your patch to kernel source and compile it _before_ sending it to this list. Doug Gilbert
RE: [PATCH] usb: chipidea: add a check for the availability of next child
> Signed-off-by: Kangjie Lu > --- > drivers/usb/chipidea/ci_hdrc_msm.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/usb/chipidea/ci_hdrc_msm.c > b/drivers/usb/chipidea/ci_hdrc_msm.c > index 880009987460..7dc987b4036a 100644 > --- a/drivers/usb/chipidea/ci_hdrc_msm.c > +++ b/drivers/usb/chipidea/ci_hdrc_msm.c > @@ -250,6 +250,8 @@ static int ci_hdrc_msm_probe(struct platform_device *pdev) > ulpi_node = of_get_child_by_name(pdev->dev.of_node, "ulpi"); > if (ulpi_node) { > phy_node = of_get_next_available_child(ulpi_node, NULL); > + if (!phy_node) > + dev_err(>dev, "no child nodes found\n"); > ci->hsic = of_device_is_compatible(phy_node, > "qcom,usb-hsic-phy"); > of_node_put(phy_node); > } With "ulpi" node, but phy node is not found, I assume the controller can't work properly, we may need to return error value. Add loic to confirm. Peter
[PATCH] wireless: ath: return error code upstream
ath6kl_wmi_cmd_send could fail, so let's return its error code upstream. Signed-off-by: Kangjie Lu --- drivers/net/wireless/ath/ath6kl/wmi.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c index 777acc564ac9..1f3cead3180b 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.c +++ b/drivers/net/wireless/ath/ath6kl/wmi.c @@ -776,10 +776,8 @@ int ath6kl_wmi_set_roam_lrssi_cmd(struct wmi *wmi, u8 lrssi) cmd->info.params.roam_rssi_floor = DEF_LRSSI_ROAM_FLOOR; cmd->roam_ctrl = WMI_SET_LRSSI_SCAN_PARAMS; - ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_ROAM_CTRL_CMDID, + return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_ROAM_CTRL_CMDID, NO_SYNC_WMIFLAG); - - return 0; } int ath6kl_wmi_force_roam_cmd(struct wmi *wmi, const u8 *bssid) -- 2.17.2 (Apple Git-113)
[PATCH] isdn: eicon: fix a missing check of api_parse
api_parse can fail, and if it fails, we should not use the ss_parms which can be incorrect. The fix checks its return value and stops using ss_parms if api_parse fails. Signed-off-by: Kangjie Lu --- drivers/isdn/hardware/eicon/message.c | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/isdn/hardware/eicon/message.c b/drivers/isdn/hardware/eicon/message.c index def7992a38e6..afb4a7d88288 100644 --- a/drivers/isdn/hardware/eicon/message.c +++ b/drivers/isdn/hardware/eicon/message.c @@ -1846,7 +1846,13 @@ static byte facility_req(dword Id, word Number, DIVA_CAPI_ADAPTER *a, break; case S_HOLD: - api_parse(>info[1], (word)parms->length, "ws", ss_parms); + if (api_parse(>info[1], + (word)parms->length, + "ws", ss_parms)) { + dbug(1, dprintf("format wrong")); + Info = _WRONG_MESSAGE_FORMAT; + break; + } if (plci && plci->State && plci->SuppState == IDLE) { plci->SuppState = HOLD_REQUEST; -- 2.17.2 (Apple Git-113)
Re: [PATCH v7 1/2] dmaengine: 8250_mtk_dma: add MediaTek uart DMA support
On Wed, 2018-12-26 at 08:05 +0800, Nicolas Boichat wrote: thanks. > On Tue, Dec 25, 2018 at 8:06 PM Long Cheng wrote: > > > > Thanks for your comments. > > > > On Tue, 2018-12-25 at 15:16 +0800, Nicolas Boichat wrote: > > > Not a full review, a few comments below. > > > > > > Thanks, > > > > > > > would you like help to full review at this version patch? and then i > > can modify these at next version patch. thanks. > > Added a few more comments ,-) > > > > On Tue, Dec 25, 2018 at 9:27 AM Long Cheng > > > wrote: > > > > > > > > In DMA engine framework, add 8250 uart dma to support MediaTek uart. > > > > If MediaTek uart enabled(SERIAL_8250_MT6577), and want to improve > > > > the performance, can enable the function. > > > > > > > > Signed-off-by: Long Cheng > > > > --- > > > > drivers/dma/mediatek/8250_mtk_dma.c | 694 > > > > +++ > > > > drivers/dma/mediatek/Kconfig| 11 + > > > > drivers/dma/mediatek/Makefile |1 + > > > > 3 files changed, 706 insertions(+) > > > > create mode 100644 drivers/dma/mediatek/8250_mtk_dma.c > > > > > > > > diff --git a/drivers/dma/mediatek/8250_mtk_dma.c > > > > b/drivers/dma/mediatek/8250_mtk_dma.c > > > > new file mode 100644 > > > > index 000..c4090f2 > > > > --- /dev/null > > > > +++ b/drivers/dma/mediatek/8250_mtk_dma.c > > > > @@ -0,0 +1,694 @@ > > > > +// SPDX-License-Identifier: GPL-2.0 > > > > +/* > > > > + * MediaTek 8250 DMA driver. > > > > + * > > > > + * Copyright (c) 2018 MediaTek Inc. > > > > + * Author: Long Cheng > > > > + */ > > > > + > > > > +#include > > > > +#include > > > > +#include > > > > +#include > > > > +#include > > > > +#include > > > > +#include > > > > +#include > > > > +#include > > > > +#include > > > > +#include > > > > +#include > > > > +#include > > > > +#include > > > > +#include > > > > +#include > > > > > > Alphabetical order. > > > > ok, i will order. > > > > > > > > > + > > > > +#include "../virt-dma.h" > > > > + > > > > +#define MTK_UART_APDMA_CHANNELS > > > > (CONFIG_SERIAL_8250_NR_UARTS * 2) > > > > + > > > > +#define VFF_EN_B BIT(0) > > > > +#define VFF_STOP_B BIT(0) > > > > +#define VFF_FLUSH_BBIT(0) > > > > +#define VFF_4G_SUPPORT_B BIT(0) > > > > +#define VFF_RX_INT_EN0_B BIT(0) /*rx valid size >= vff thre*/ > > > > +#define VFF_RX_INT_EN1_B BIT(1) > > > > +#define VFF_TX_INT_EN_BBIT(0) /*tx left size >= vff > > > > thre*/ > > > > +#define VFF_WARM_RST_B BIT(0) > > > > +#define VFF_RX_INT_FLAG_CLR_B (BIT(0) | BIT(1)) > > > > +#define VFF_TX_INT_FLAG_CLR_B 0 > > > > +#define VFF_STOP_CLR_B 0 > > > > +#define VFF_FLUSH_CLR_B0 > > > > +#define VFF_INT_EN_CLR_B 0 > > > > +#define VFF_4G_SUPPORT_CLR_B 0 > > > > + > > > > +/* interrupt trigger level for tx */ > > > > +#define VFF_TX_THRE(n) ((n) * 7 / 8) > > > > +/* interrupt trigger level for rx */ > > > > +#define VFF_RX_THRE(n) ((n) * 3 / 4) > > > > + > > > > +#define MTK_UART_APDMA_RING_SIZE 0xU > > > > +/* invert this bit when wrap ring head again*/ > > > > +#define MTK_UART_APDMA_RING_WRAP 0x1U > > > > + > > > > +#define VFF_INT_FLAG 0x00 > > > > +#define VFF_INT_EN 0x04 > > > > +#define VFF_EN 0x08 > > > > +#define VFF_RST0x0c > > > > +#define VFF_STOP 0x10 > > > > +#define VFF_FLUSH 0x14 > > > > +#define VFF_ADDR 0x1c > > > > +#define VFF_LEN0x24 > > > > +#define VFF_THRE 0x28 > > > > +#define VFF_WPT0x2c > > > > +#define VFF_RPT0x30 > > > > +/*TX: the buffer size HW can read. RX: the buffer size SW can read.*/ > > > > +#define VFF_VALID_SIZE 0x3c > > > > +/*TX: the buffer size SW can write. RX: the buffer size HW can write.*/ > > > > +#define VFF_LEFT_SIZE 0x40 > > > > +#define VFF_DEBUG_STATUS 0x50 > > > > +#define VFF_4G_SUPPORT 0x54 > > > > + > > > > +struct mtk_uart_apdmadev { > > > > + struct dma_device ddev; > > > > + struct clk *clk; > > > > + bool support_33bits; > > > > + unsigned int dma_irq[MTK_UART_APDMA_CHANNELS]; > > > > +}; > > > > + > > > > +struct mtk_uart_apdma_desc { > > > > + struct virt_dma_desc vd; > > > > + > > > > + unsigned int avail_len; > > > > +}; > > > > + > > > > +struct mtk_chan { > > > > + struct virt_dma_chan vc; > > > > + struct dma_slave_config cfg; > > > > + void __iomem *base; > > > > + struct mtk_uart_apdma_desc *desc; > > > > + > > > > + bool requested; > > > > + > > > > + unsigned int rx_status; > > > > +}; > > > > + > > > > +static inline struct mtk_uart_apdmadev * > > > > +to_mtk_uart_apdma_dev(struct dma_device *d) > > > > +{ > > > > + return container_of(d, struct mtk_uart_apdmadev,
[PATCH] net: marvell: fix a missing check of acpi_match_device
When acpi_match_device fails, its return value is NULL. Directly using the return value without a check may result in a NULL-pointer dereference. The fix checks if acpi_match_device fails, and if so, returns -EINVAL. Signed-off-by: Kangjie Lu --- drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c index f1dab0b55769..c9444346475b 100644 --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c @@ -5255,6 +5255,8 @@ static int mvpp2_probe(struct platform_device *pdev) if (has_acpi_companion(>dev)) { acpi_id = acpi_match_device(pdev->dev.driver->acpi_match_table, >dev); + if (!acpi_id) + return -EINVAL; priv->hw_version = (unsigned long)acpi_id->driver_data; } else { priv->hw_version = -- 2.17.2 (Apple Git-113)
Re: [PATCH v5 1/5] Bluetooth: hci_qca: use wait_until_sent() for power pulses
Hi Matthias, On 2018-12-22 07:29, Matthias Kaehlcke wrote: On Thu, Dec 20, 2018 at 08:16:35PM +0530, Balakrishna Godavarthi wrote: wcn3990 requires a power pulse to turn ON/OFF along with regulators. Sometimes we are observing the power pulses are sent out with some time delay, due to queuing these commands. This is causing synchronization issues with chip, which intern delay the chip setup or may end up with communication issues. Signed-off-by: Balakrishna Godavarthi --- drivers/bluetooth/hci_qca.c | 38 ++--- 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c index f036c8f98ea3..5a07c2370289 100644 --- a/drivers/bluetooth/hci_qca.c +++ b/drivers/bluetooth/hci_qca.c @@ -1013,11 +1013,9 @@ static inline void host_set_baudrate(struct hci_uart *hu, unsigned int speed) hci_uart_set_baudrate(hu, speed); } -static int qca_send_power_pulse(struct hci_dev *hdev, u8 cmd) +static int qca_send_power_pulse(struct hci_uart *hu, u8 cmd) { - struct hci_uart *hu = hci_get_drvdata(hdev); - struct qca_data *qca = hu->priv; - struct sk_buff *skb; + int ret; /* These power pulses are single byte command which are sent * at required baudrate to wcn3990. On wcn3990, we have an external @@ -1029,19 +1027,16 @@ static int qca_send_power_pulse(struct hci_dev *hdev, u8 cmd) * save power. Disabling hardware flow control is mandatory while * sending power pulses to SoC. */ - bt_dev_dbg(hdev, "sending power pulse %02x to SoC", cmd); - - skb = bt_skb_alloc(sizeof(cmd), GFP_KERNEL); - if (!skb) - return -ENOMEM; - + bt_dev_dbg(hu->hdev, "sending power pulse %02x to SoC", cmd); hci_uart_set_flow_control(hu, true); + ret = serdev_device_write_buf(hu->serdev, , sizeof(cmd)); + if (ret < 0) { + bt_dev_err(hu->hdev, "failed to send power pulse %02x to SoC", + cmd); + return ret; + } - skb_put_u8(skb, cmd); - hci_skb_pkt_type(skb) = HCI_COMMAND_PKT; - - skb_queue_tail(>txq, skb); - hci_uart_tx_wakeup(hu); + serdev_device_wait_until_sent(hu->serdev, 0); serdev_device_wait_until_sent() might only guarantee that the UART circular buffer is empty (see https://elixir.bootlin.com/linux/v4.19/source/drivers/tty/tty_ioctl.c#L225), not that the data has actually sent (e.g. it might be sitting in the UART FIFO). However with this: /* Wait for 100 uS for SoC to settle down */ usleep_range(100, 200); we should probably be fine, unless there's tons of data in the FIFO. You currently call serdev_device_write_flush() in qca_power_shutdown(), I wonder if it would make sense to call it in qca_send_power_pulse(), regardless of whether it's an on or off [Bala]: during sending the ON pulse we will not have any data in the UART circular buffer as this is the first command to send and we are sending it as soon as we open the port. so i taught why should be flush the circular as it is already empty. pulse. In any case we don't care if the chip receives any 'pending' data when we switch it on or off, right? [Bala]: during on we freshly open port and i see that flush() called while port opening. https://elixir.bootlin.com/linux/latest/source/drivers/tty/serial/serial_core.c#L207 Cheers Matthias -- Regards Balakrishna.
[PATCH] gpu: drm: fix an improper check of amdgpu_bo_create_kernel
adev->firmware.fw_buf being not NULL may not indicate kernel buffer is created successful. A better way is to check the status (return value) of it. The fix does so. Signed-off-by: Kangjie Lu --- drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c | 18 -- 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c index 7b33867036e7..ba3c1cfb2c35 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c @@ -422,13 +422,19 @@ static int amdgpu_ucode_patch_jt(struct amdgpu_firmware_info *ucode, int amdgpu_ucode_create_bo(struct amdgpu_device *adev) { + int ret; + if (adev->firmware.load_type != AMDGPU_FW_LOAD_DIRECT) { - amdgpu_bo_create_kernel(adev, adev->firmware.fw_size, PAGE_SIZE, - amdgpu_sriov_vf(adev) ? AMDGPU_GEM_DOMAIN_VRAM : AMDGPU_GEM_DOMAIN_GTT, - >firmware.fw_buf, - >firmware.fw_buf_mc, - >firmware.fw_buf_ptr); - if (!adev->firmware.fw_buf) { + ret = + amdgpu_bo_create_kernel(adev, + adev->firmware.fw_size, + PAGE_SIZE, + amdgpu_sriov_vf(adev) ? AMDGPU_GEM_DOMAIN_VRAM : + AMDGPU_GEM_DOMAIN_GTT, + >firmware.fw_buf, + >firmware.fw_buf_mc, + >firmware.fw_buf_ptr); + if (ret) { dev_err(adev->dev, "failed to create kernel buffer for firmware.fw_buf\n"); return -ENOMEM; } else if (amdgpu_sriov_vf(adev)) { -- 2.17.2 (Apple Git-113)
Re: [PATCH] fs: proc: check status of register_filesystem
On Tue, Dec 25, 2018 at 09:06:40PM -0600, Kangjie Lu wrote: > register_filesystem() could fail. The fix issues an error message if it > fails. > - register_filesystem(_fs_type); > + if (register_filesystem(_fs_type)) > + pr_err("failed to register the filesystem.\n"); No, register_filesystem() should do it.
[PATCH v2] thermal: uniphier: Convert to SPDX identifier
This converts license boilerplate to SPDX identifier, and removes unnecessary lines. Reviewed-by: Daniel Lezcano Signed-off-by: Kunihiko Hayashi --- drivers/thermal/uniphier_thermal.c | 13 + 1 file changed, 1 insertion(+), 12 deletions(-) Changes since v1: - Add Reviewd-by line diff --git a/drivers/thermal/uniphier_thermal.c b/drivers/thermal/uniphier_thermal.c index 55477d7..bba2284 100644 --- a/drivers/thermal/uniphier_thermal.c +++ b/drivers/thermal/uniphier_thermal.c @@ -1,21 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0 /** * uniphier_thermal.c - Socionext UniPhier thermal driver - * * Copyright 2014 Panasonic Corporation * Copyright 2016-2017 Socionext Inc. - * All rights reserved. - * * Author: * Kunihiko Hayashi - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 of - * the License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. */ #include -- 2.7.4
Re: [PATCH 1/2 v3] kdump: add the vmcoreinfo documentation
在 2018年12月26日 11:36, Dave Young 写道: > On 12/26/18 at 11:24am, Dave Young wrote: > + > +KERNEL_IMAGE_SIZE > += > +The size of 'KERNEL_IMAGE_SIZE', currently unused. So remove? >>> >>> I'm not sure whether it should be removed, so i keep it. >> >> Just remove it. It was added by Baoquan for KASLR issues, later >> makedumpfile reverted the userspace part and added other implementation. >> >> In case old makedumpfile does not support new kernel, it has some kernel >> versions support list in code, thus no worry about the compatibility >> issue. > > Ah, it is not unused actually, clone crash tool git: > $ git grep KERNEL_IMAGE_SIZE > x86_64.c: if ((string = > pc->read_vmcoreinfo("NUMBER(KERNEL_IMAGE_SIZE)"))) { > > So in the documentation, the use cases of crash tool should also be > covered. > Sure, maybe only this one was ignored. I will improve this variable in the documentation. > Lianbo, it would be good to cc Dave and Kazu for these patches, could > you cc them in your next post? > Yes, i will add Dave and Kazu, and also resend patch v4. Thanks. >> >> Thanks >> Dave > > Thanks > Dave >
[PATCH] tipc: fix a missing check of genlmsg_put
genlmsg_put could fail. The fix inserts a check of its return value, and if it fails, returns -EMSGSIZE. Signed-off-by: Kangjie Lu --- net/tipc/netlink_compat.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/tipc/netlink_compat.c b/net/tipc/netlink_compat.c index 6376467e78f8..764aa29612ea 100644 --- a/net/tipc/netlink_compat.c +++ b/net/tipc/netlink_compat.c @@ -904,6 +904,8 @@ static int tipc_nl_compat_publ_dump(struct tipc_nl_compat_msg *msg, u32 sock) hdr = genlmsg_put(args, 0, 0, _genl_family, NLM_F_MULTI, TIPC_NL_PUBL_GET); + if (!hdr) + return -EMSGSIZE; nest = nla_nest_start(args, TIPC_NLA_SOCK); if (!nest) { -- 2.17.2 (Apple Git-113)
[PATCH] xfs: add a check for xfs_trans_commit
xfs_trans_commit could fails. The checks issues an error message upon its failure. Signed-off-by: Kangjie Lu --- fs/xfs/xfs_super.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index d3e6cd063688..8ec2e3c8e946 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -1010,6 +1010,7 @@ xfs_fs_dirty_inode( struct xfs_inode*ip = XFS_I(inode); struct xfs_mount*mp = ip->i_mount; struct xfs_trans*tp; + int error; if (!(inode->i_sb->s_flags & SB_LAZYTIME)) return; @@ -1021,7 +1022,10 @@ xfs_fs_dirty_inode( xfs_ilock(ip, XFS_ILOCK_EXCL); xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); xfs_trans_log_inode(tp, ip, XFS_ILOG_TIMESTAMP); - xfs_trans_commit(tp); + error = xfs_trans_commit(tp); + if (error) + xfs_err(mp, + "Error in xfs_trans_commit: %d\n", error); } /* -- 2.17.2 (Apple Git-113)
Re: [PATCH 06/18] drm/mediatek: add mmsys private data for ddp path config
Hi, Yongqiang: On Mon, 2018-12-24 at 16:08 +0800, Yongqiang Niu wrote: > This patch add mmsys private data for ddp path config Describe WHY do this. > > Signed-off-by: Yongqiang Niu > --- > drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 4 ++ > drivers/gpu/drm/mediatek/mtk_drm_ddp.c | 102 > ++-- > drivers/gpu/drm/mediatek/mtk_drm_ddp.h | 10 > drivers/gpu/drm/mediatek/mtk_drm_drv.c | 11 > drivers/gpu/drm/mediatek/mtk_drm_drv.h | 4 ++ > 5 files changed, 112 insertions(+), 19 deletions(-) > > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c > b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c > index 92ecb9b..a5af4be 100644 > --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c > +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c > @@ -50,6 +50,7 @@ struct mtk_drm_crtc { > boolpending_planes; > > void __iomem*config_regs; > + const struct mtk_mmsys_reg_data *mmsys_reg_data; > struct mtk_disp_mutex *mutex; > unsigned intddp_comp_nr; > struct mtk_ddp_comp **ddp_comp; > @@ -271,6 +272,7 @@ static int mtk_crtc_ddp_hw_init(struct mtk_drm_crtc > *mtk_crtc) > DRM_DEBUG_DRIVER("mediatek_ddp_ddp_path_setup\n"); > for (i = 0; i < mtk_crtc->ddp_comp_nr - 1; i++) { > mtk_ddp_add_comp_to_path(mtk_crtc->config_regs, > + mtk_crtc->mmsys_reg_data, >mtk_crtc->ddp_comp[i]->id, >mtk_crtc->ddp_comp[i + 1]->id); > mtk_disp_mutex_add_comp(mtk_crtc->mutex, > @@ -319,6 +321,7 @@ static void mtk_crtc_ddp_hw_fini(struct mtk_drm_crtc > *mtk_crtc) > mtk_disp_mutex_disable(mtk_crtc->mutex); > for (i = 0; i < mtk_crtc->ddp_comp_nr - 1; i++) { > mtk_ddp_remove_comp_from_path(mtk_crtc->config_regs, > + mtk_crtc->mmsys_reg_data, > mtk_crtc->ddp_comp[i]->id, > mtk_crtc->ddp_comp[i + 1]->id); > mtk_disp_mutex_remove_comp(mtk_crtc->mutex, > @@ -561,6 +564,7 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev, > return -ENOMEM; > > mtk_crtc->config_regs = priv->config_regs; > + mtk_crtc->mmsys_reg_data = priv->reg_data; > mtk_crtc->ddp_comp_nr = path_len; > mtk_crtc->ddp_comp = devm_kmalloc_array(dev, mtk_crtc->ddp_comp_nr, > sizeof(*mtk_crtc->ddp_comp), > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp.c > b/drivers/gpu/drm/mediatek/mtk_drm_ddp.c > index 60cfde7..4be3c11 100644 > --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp.c > +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp.c > @@ -145,6 +145,17 @@ > #define DPI_SEL_IN_BLS 0x0 > #define DSI_SEL_IN_RDMA 0x1 > > +#define DISP_REG_OVL0_MOUT_EN(data) ((data)->ovl0_mout_en) > +#define DISP_REG_DPI0_SEL_IN(data) ((data)->dpi0_sel_in) > +#define DISP_REG_DPI0_SEL_IN_RDMA1(data) ((data)->dpi0_sel_in_rdma1) > +#define DISP_REG_DSI0_SEL_IN(data) ((data)->dsi0_sel_in) > +#define DISP_REG_DSI0_SEL_IN_RDMA1(data) ((data)->dsi0_sel_in_rdma1) > +#define DISP_REG_RDMA0_SOUT_SEL_IN(data) ((data)->rdma0_sout_sel_in) > +#define DISP_REG_RDMA0_SOUT_COLOR0(data) ((data)->rdma0_sout_color0) > +#define DISP_REG_RDMA1_SOUT_SEL_IN(data) ((data)->rdma1_sout_sel_in) > +#define DISP_REG_RDMA1_SOUT_DPI0(data) > ((data)->rdma1_sout_dpi0) > +#define DISP_REG_RDMA1_SOUT_DSI0(data) > ((data)->rdma1_sout_dsi0) > + > struct mtk_disp_mutex { > int id; > bool claimed; > @@ -176,6 +187,19 @@ struct mtk_ddp { > const struct mtk_ddp_data *data; > }; > > +struct mtk_mmsys_reg_data { > + unsigned int ovl0_mout_en; > + unsigned int rdma0_sout_sel_in; > + unsigned int rdma0_sout_color0; > + unsigned int rdma1_sout_sel_in; > + unsigned int rdma1_sout_dpi0; > + unsigned int rdma1_sout_dsi0; > + unsigned int dpi0_sel_in; > + unsigned int dpi0_sel_in_rdma1; > + unsigned int dsi0_sel_in; > + unsigned int dsi0_sel_in_rdma1; I would like use 'u32' for these variables. > +}; > + > static const unsigned int mt2701_mutex_mod[DDP_COMPONENT_ID_MAX] = { > [DDP_COMPONENT_BLS] = MT2701_MUTEX_MOD_DISP_BLS, > [DDP_COMPONENT_COLOR0] = MT2701_MUTEX_MOD_DISP_COLOR, > @@ -268,17 +292,34 @@ struct mtk_ddp { > .mutex_sof_reg = MT2701_DISP_MUTEX0_SOF0, > }; > > -static unsigned int mtk_ddp_mout_en(enum mtk_ddp_comp_id cur, > +const struct mtk_mmsys_reg_data mt2701_mmsys_reg_data = { > + .ovl0_mout_en = DISP_REG_CONFIG_DISP_OVL_MOUT_EN, > + .dsi0_sel_in = DISP_REG_CONFIG_DSI_SEL, > + .dsi0_sel_in_rdma1 = DSI_SEL_IN_RDMA, > +}; > + > +const struct mtk_mmsys_reg_data
[PATCH] usb: dvb: check status of mxl111sf_read_reg
When mxl111sf_read_reg fails, we shouldn't use "mode". The fix checks its return value using mxl_fail Signed-off-by: Kangjie Lu --- drivers/media/usb/dvb-usb-v2/mxl111sf-phy.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/media/usb/dvb-usb-v2/mxl111sf-phy.c b/drivers/media/usb/dvb-usb-v2/mxl111sf-phy.c index ffb6e7c72f57..aecc3d02fc1e 100644 --- a/drivers/media/usb/dvb-usb-v2/mxl111sf-phy.c +++ b/drivers/media/usb/dvb-usb-v2/mxl111sf-phy.c @@ -130,7 +130,8 @@ int mxl111sf_config_mpeg_in(struct mxl111sf_state *state, mxl_fail(ret); /* Configure MPEG Clock phase */ - mxl111sf_read_reg(state, V6_MPEG_IN_CLK_INV_REG, ); + ret = mxl111sf_read_reg(state, V6_MPEG_IN_CLK_INV_REG, ); + mxl_fail(ret); if (clock_phase == TSIF_NORMAL) mode &= ~V6_INVERTED_CLK_PHASE; -- 2.17.2 (Apple Git-113)
[PATCH] scsi: aacraid: add a check for aac_fib_send
aac_fib_send could fail, so add a check to its return value: If it fails, issue an error message. Signed-off-by: Kangjie Lu --- drivers/scsi/aacraid/dpcsup.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/scsi/aacraid/dpcsup.c b/drivers/scsi/aacraid/dpcsup.c index ddc69738375f..0fbdc0dbf9d8 100644 --- a/drivers/scsi/aacraid/dpcsup.c +++ b/drivers/scsi/aacraid/dpcsup.c @@ -271,6 +271,8 @@ static void aac_aif_callback(void *context, struct fib * fibptr) FsaNormal, 0, 1, (fib_callback)aac_aif_callback, fibctx); + if (status) + pr_err("failure in aac_fib_send: %d\n", status); } -- 2.17.2 (Apple Git-113)
[PATCH] scsi: associate bio write hint with WRITE CDB
In SPC-3, WRITE(10)/(16) support grouping function. Let's associate bio write hint with group number for enabling StreamID or Turbo Write feature. Signed-off-by: Randall Huang --- drivers/scsi/sd.c | 14 -- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 4b49cb67617e..28bfa9ed2b54 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -1201,7 +1201,12 @@ static int sd_setup_read_write_cmnd(struct scsi_cmnd *SCpnt) SCpnt->cmnd[11] = (unsigned char) (this_count >> 16) & 0xff; SCpnt->cmnd[12] = (unsigned char) (this_count >> 8) & 0xff; SCpnt->cmnd[13] = (unsigned char) this_count & 0xff; - SCpnt->cmnd[14] = SCpnt->cmnd[15] = 0; + if (rq_data_dir(rq) == WRITE) { + SCpnt->cmnd[14] = rq->bio->bi_write_hint & 0x3f; + } else { + SCpnt->cmnd[14] = 0; + } + SCpnt->cmnd[15] = 0; } else if ((this_count > 0xff) || (block > 0x1f) || scsi_device_protection(SCpnt->device) || SCpnt->device->use_10_for_rw) { @@ -1211,9 +1216,14 @@ static int sd_setup_read_write_cmnd(struct scsi_cmnd *SCpnt) SCpnt->cmnd[3] = (unsigned char) (block >> 16) & 0xff; SCpnt->cmnd[4] = (unsigned char) (block >> 8) & 0xff; SCpnt->cmnd[5] = (unsigned char) block & 0xff; - SCpnt->cmnd[6] = SCpnt->cmnd[9] = 0; + if (rq_data_dir(rq) == WRITE) { + SCpnt->cmnd[6] = rq->bio->bi_write_hint & 0x1f; + } else { + SCpnt->cmnd[6] = 0; + } SCpnt->cmnd[7] = (unsigned char) (this_count >> 8) & 0xff; SCpnt->cmnd[8] = (unsigned char) this_count & 0xff; + SCpnt->cmnd[9] = 0; } else { if (unlikely(rq->cmd_flags & REQ_FUA)) { /* -- 2.20.1.415.g653613c723-goog
[PATCH v2] f2fs: fix use-after-free issue when accessing sbi->stat_info
iput() on sbi->node_inode can update sbi->stat_info in the below context, if the f2fs_write_checkpoint() has failed with error. f2fs_balance_fs_bg+0x1ac/0x1ec f2fs_write_node_pages+0x4c/0x260 do_writepages+0x80/0xbc __writeback_single_inode+0xdc/0x4ac writeback_single_inode+0x9c/0x144 write_inode_now+0xc4/0xec iput+0x194/0x22c f2fs_put_super+0x11c/0x1e8 generic_shutdown_super+0x70/0xf4 kill_block_super+0x2c/0x5c kill_f2fs_super+0x44/0x50 deactivate_locked_super+0x60/0x8c deactivate_super+0x68/0x74 cleanup_mnt+0x40/0x78 Fix this by moving f2fs_destroy_stats() further below iput() in both f2fs_put_super() and f2fs_fill_super() paths. Signed-off-by: Sahitya Tummala --- v2: - cover f2fs_fill_super() also, as pointed out by Chao. fs/f2fs/super.c | 27 +++ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index e184ad4e..01d9548 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -1058,9 +1058,6 @@ static void f2fs_put_super(struct super_block *sb) f2fs_write_checkpoint(sbi, ); } - /* f2fs_write_checkpoint can update stat informaion */ - f2fs_destroy_stats(sbi); - /* * normally superblock is clean, so we need to release this. * In addition, EIO will skip do checkpoint, we need this as well. @@ -1080,6 +1077,12 @@ static void f2fs_put_super(struct super_block *sb) iput(sbi->node_inode); iput(sbi->meta_inode); + /* +* iput() can update stat information, if f2fs_write_checkpoint() +* above failed with error. +*/ + f2fs_destroy_stats(sbi); + /* destroy f2fs internal modules */ f2fs_destroy_node_manager(sbi); f2fs_destroy_segment_manager(sbi); @@ -3259,30 +3262,30 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent) f2fs_build_gc_manager(sbi); + err = f2fs_build_stats(sbi); + if (err) + goto free_nm; + /* get an inode for node space */ sbi->node_inode = f2fs_iget(sb, F2FS_NODE_INO(sbi)); if (IS_ERR(sbi->node_inode)) { f2fs_msg(sb, KERN_ERR, "Failed to read node inode"); err = PTR_ERR(sbi->node_inode); - goto free_nm; + goto free_stats; } - err = f2fs_build_stats(sbi); - if (err) - goto free_node_inode; - /* read root inode and dentry */ root = f2fs_iget(sb, F2FS_ROOT_INO(sbi)); if (IS_ERR(root)) { f2fs_msg(sb, KERN_ERR, "Failed to read root inode"); err = PTR_ERR(root); - goto free_stats; + goto free_node_inode; } if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size || !root->i_nlink) { iput(root); err = -EINVAL; - goto free_stats; + goto free_node_inode; } sb->s_root = d_make_root(root); /* allocate root dentry */ @@ -3406,12 +3409,12 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent) free_root_inode: dput(sb->s_root); sb->s_root = NULL; -free_stats: - f2fs_destroy_stats(sbi); free_node_inode: f2fs_release_ino_entry(sbi, true); truncate_inode_pages_final(NODE_MAPPING(sbi)); iput(sbi->node_inode); +free_stats: + f2fs_destroy_stats(sbi); free_nm: f2fs_destroy_node_manager(sbi); free_sm: -- Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.
Re: [PATCH v2] btrfs: add a check for sysfs_create_group
On 2018/12/26 下午1:37, Kangjie Lu wrote: > In case sysfs_create_group fails, let's check its return value and > issues an error message. > > Signed-off-by: Kangjie Lu > --- > fs/btrfs/sysfs.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c > index 3717c864ba23..24ef416e700b 100644 > --- a/fs/btrfs/sysfs.c > +++ b/fs/btrfs/sysfs.c > @@ -889,6 +889,8 @@ void btrfs_sysfs_feature_update(struct btrfs_fs_info > *fs_info, >*/ > sysfs_remove_group(fsid_kobj, _feature_attr_group); > ret = sysfs_create_group(fsid_kobj, _feature_attr_group); > + if (ret) > + btrfs_err(fs_info, "failed to create > btrfs_feature_attr_group.\n"); Forgot to mention, for btrfs_* infrastructure, no need for the ending '\n'. Despite that, looks good. Reviewed-by: Qu Wenruo Thanks, Qu > } > > static int btrfs_init_debugfs(void) > signature.asc Description: OpenPGP digital signature
Re: [PATCH v5 2/5] Bluetooth: hci_qca: Deassert RTS while baudrate change command
Hi Matthias, On 2018-12-22 06:01, Matthias Kaehlcke wrote: On Thu, Dec 20, 2018 at 08:16:36PM +0530, Balakrishna Godavarthi wrote: This patch will help to stop frame reassembly errors while changing the baudrate. This is because host send a change baudrate request command to the chip with 115200 bps, Whereas chip will change their UART clocks to the enable for new baudrate and sends the response for the change request command with newer baudrate, On host side we are still operating in 115200 bps which results of reading garbage data. Here we are pulling RTS line, so that chip we will wait to send data to host until host change its baudrate. Signed-off-by: Balakrishna Godavarthi Tested-by: Matthias Kaehlcke Reviewed-by: Matthias Kaehlcke --- drivers/bluetooth/hci_qca.c | 24 +--- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c index 5a07c2370289..1680ead6cc3d 100644 --- a/drivers/bluetooth/hci_qca.c +++ b/drivers/bluetooth/hci_qca.c @@ -963,7 +963,6 @@ static int qca_set_baudrate(struct hci_dev *hdev, uint8_t baudrate) struct hci_uart *hu = hci_get_drvdata(hdev); struct qca_data *qca = hu->priv; struct sk_buff *skb; - struct qca_serdev *qcadev; u8 cmd[] = { 0x01, 0x48, 0xFC, 0x01, 0x00 }; if (baudrate > QCA_BAUDRATE_320) @@ -977,13 +976,6 @@ static int qca_set_baudrate(struct hci_dev *hdev, uint8_t baudrate) return -ENOMEM; } - /* Disabling hardware flow control is mandatory while -* sending change baudrate request to wcn3990 SoC. -*/ - qcadev = serdev_device_get_drvdata(hu->serdev); - if (qcadev->btsoc_type == QCA_WCN3990) - hci_uart_set_flow_control(hu, true); - /* Assign commands to change baudrate and packet type. */ skb_put_data(skb, cmd, sizeof(cmd)); hci_skb_pkt_type(skb) = HCI_COMMAND_PKT; @@ -999,9 +991,6 @@ static int qca_set_baudrate(struct hci_dev *hdev, uint8_t baudrate) schedule_timeout(msecs_to_jiffies(BAUDRATE_SETTLE_TIMEOUT_MS)); set_current_state(TASK_RUNNING); - if (qcadev->btsoc_type == QCA_WCN3990) - hci_uart_set_flow_control(hu, false); - return 0; } @@ -1086,6 +1075,7 @@ static int qca_check_speeds(struct hci_uart *hu) static int qca_set_speed(struct hci_uart *hu, enum qca_speed_type speed_type) { unsigned int speed, qca_baudrate; + struct qca_serdev *qcadev; int ret; if (speed_type == QCA_INIT_SPEED) { @@ -1097,6 +1087,15 @@ static int qca_set_speed(struct hci_uart *hu, enum qca_speed_type speed_type) if (!speed) return 0; + /* Deassert RTS while changing the baudrate of chip and host. +* This will prevent chip from transmitting its response with +* the new baudrate while the host port is still operating at +* the old speed. +*/ + qcadev = serdev_device_get_drvdata(hu->serdev); + if (qcadev->btsoc_type == QCA_WCN3990) + serdev_device_set_rts(hu->serdev, false); + qca_baudrate = qca_get_baudrate_value(speed); bt_dev_dbg(hu->hdev, "Set UART speed to %d", speed); ret = qca_set_baudrate(hu->hdev, qca_baudrate); @@ -1104,6 +1103,9 @@ static int qca_set_speed(struct hci_uart *hu, enum qca_speed_type speed_type) return ret; host_set_baudrate(hu, speed); + + if (qcadev->btsoc_type == QCA_WCN3990) + serdev_device_set_rts(hu->serdev, true); } return 0; I looked for ways to do without this change, but didn't find a good solution. There are several possible problems with baudrate changes: 1) send request to BT controller to change the baudrate this is an asynchronous operation, the actual baudrate change can be delayed for multiple reasons, e.g.: - request sits in the BT driver's TX queue this could be worked around by checking skb_queue_empty() - request sits in the UART buffer a workaround for this could be calling serdev_device_wait_until_sent() (only available with serdev though) - the request sits in the UART FIFO will be sent out 'immediately'. no neat solution available AFAIK, a short sleep could be an effective workaround - the controller may have a short delay to apply the change Also no neat solution here. A/the same short sleep could work around this 2) change baudrate of the host UART - this must not happen before the baudrate change request has been sent to the BT controller, otherwise things are messed up seriously Ideally set_termios would make sure all pending data is sent before the change is applied, some UART drivers do this, others don't, so we can't rely
Re: [PATCH net V2 4/4] vhost: log dirty page correctly
On 2018/12/26 上午12:25, Michael S. Tsirkin wrote: On Tue, Dec 25, 2018 at 05:43:25PM +0800, Jason Wang wrote: On 2018/12/25 上午1:41, Michael S. Tsirkin wrote: On Mon, Dec 24, 2018 at 11:43:31AM +0800, Jason Wang wrote: On 2018/12/14 下午9:20, Michael S. Tsirkin wrote: On Fri, Dec 14, 2018 at 10:43:03AM +0800, Jason Wang wrote: On 2018/12/13 下午10:31, Michael S. Tsirkin wrote: Just to make sure I understand this. It looks to me we should: - allow passing GIOVA->GPA through UAPI - cache GIOVA->GPA somewhere but still use GIOVA->HVA in device IOTLB for performance Is this what you suggest? Thanks Not really. We already have GPA->HVA, so I suggested a flag to pass GIOVA->GPA in the IOTLB. This has advantages for security since a single table needs then to be validated to ensure guest does not corrupt QEMU memory. I wonder how much we can gain through this. Currently, qemu IOMMU gives GIOVA->GPA mapping, and qemu vhost code will translate GPA to HVA then pass GIOVA->HVA to vhost. It looks no difference to me. Thanks The difference is in security not in performance. Getting a bad HVA corrupts QEMU memory and it might be guest controlled. Very risky. How can this be controlled by guest? HVA was generated from qemu ram blocks which is totally under the control of qemu memory core instead of guest. Thanks It is ultimately under guest influence as guest supplies IOVA->GPA translations. qemu translates GPA->HVA and gives the translated result to the kernel. If it's not buggy and kernel isn't buggy it's all fine. If qemu provides buggy GPA->HVA, we can't workaround this. And I don't get the point why we even want to try this. Buggy qemu code can crash itself in many ways. But that's the approach that was proven not to work in the 20th century. In the 21st century we are trying defence in depth approach. My point is that a single code path that is responsible for the HVA translations is better than two. So the difference whether or not use memory table information: Current: 1) SET_MEM_TABLE: GPA->HVA 2) Qemu GIOVA->GPA 3) Qemu GPA->HVA 4) IOTLB_UPDATE: GIOVA->HVA If I understand correctly you want to drop step 3 consider it might be buggy which is just 19 lines of code in qemu (vhost_memory_region_lookup()). This will ends up: 1) Do GPA->HVA translation in IOTLB_UPDATE path (I believe we won't want to do it during device IOTLB lookup). 2) Extra bits to enable this capability. So this looks need more codes in kernel than what qemu did in userspace. Is this really worthwhile? Thanks So there are several points I would like to make 1. At the moment without an iommu it is possible to change GPA-HVA mappings and everything keeps working because a change in memory tables flushes the rings. Interesting, I don't know this before. But when can this happen? However I don't see the iotlb cache being invalidated on that path - did I miss it? If it is not there it's a related minor bug. It might have a bug. But a question is consider the case without IOMMU. We only update mem table (SET_MEM_TABLE), but not vring address. This looks like a bug as well? 2. qemu already has a GPA. Discarding it and re-calculating when logging is on just seems wrong. However if you would like to *also* keep the HVA in the iotlb to avoid doing extra translations, that sounds like a reasonable optimization. Yes, traverse GPA->HVA mapping seems unnecessary. 3. it also means that the hva->gpa translation only runs when logging is enabled. That is a rarely excercised path so any bugs there will not be caught. I wonder maybe some kind of unit-test may help here. So I really would like us long term to move away from hva->gpa translations, keep them for legacy userspace only but I don't really mind how we do it. How about - a new flag to pass an iotlb with *both* a gpa and hva - for legacy userspace, calculate the gpa on iotlb update so the device then uses a shared code path what do you think? I don't object this idea so I can try, just want to figure out why it was a must. Thanks
Re: [PATCH v2] btrfs: add a check for sysfs_create_group
On 12/26/18 1:37 PM, Kangjie Lu wrote: In case sysfs_create_group fails, let's check its return value and issues an error message. Signed-off-by: Kangjie Lu --- fs/btrfs/sysfs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c index 3717c864ba23..24ef416e700b 100644 --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c @@ -889,6 +889,8 @@ void btrfs_sysfs_feature_update(struct btrfs_fs_info *fs_info, */ sysfs_remove_group(fsid_kobj, _feature_attr_group); ret = sysfs_create_group(fsid_kobj, _feature_attr_group); + if (ret) + btrfs_err(fs_info, "failed to create btrfs_feature_attr_group.\n"); NIT: ".\n" is unnecessary. --- Su } static int btrfs_init_debugfs(void)
[PATCH v2] btrfs: add a check for sysfs_create_group
In case sysfs_create_group fails, let's check its return value and issues an error message. Signed-off-by: Kangjie Lu --- fs/btrfs/sysfs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c index 3717c864ba23..24ef416e700b 100644 --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c @@ -889,6 +889,8 @@ void btrfs_sysfs_feature_update(struct btrfs_fs_info *fs_info, */ sysfs_remove_group(fsid_kobj, _feature_attr_group); ret = sysfs_create_group(fsid_kobj, _feature_attr_group); + if (ret) + btrfs_err(fs_info, "failed to create btrfs_feature_attr_group.\n"); } static int btrfs_init_debugfs(void) -- 2.17.2 (Apple Git-113)
Re: [PATCH] mm, swap: Fix swapoff with KSM pages
Hi, Andrew, This patch is based on linus' tree instead of the head of mmotm tree because it is to fix a bug there. The bug is introduced by commit e07098294adf ("mm, THP, swap: support to reclaim swap space for THP swapped out"), which is merged by v4.14-rc1. So I think we should backport the fix to from 4.14 on. But Hugh thinks it may be rare for the KSM pages being in the swap device when swapoff, so nobody reports the bug so far. Best Regards, Huang, Ying Huang Ying writes: > KSM pages may be mapped to the multiple VMAs that cannot be reached > from one anon_vma. So during swapin, a new copy of the page need to > be generated if a different anon_vma is needed, please refer to > comments of ksm_might_need_to_copy() for details. > > During swapoff, unuse_vma() uses anon_vma (if available) to locate VMA > and virtual address mapped to the page, so not all mappings to a > swapped out KSM page could be found. So in try_to_unuse(), even if > the swap count of a swap entry isn't zero, the page needs to be > deleted from swap cache, so that, in the next round a new page could > be allocated and swapin for the other mappings of the swapped out KSM > page. > > But this contradicts with the THP swap support. Where the THP could > be deleted from swap cache only after the swap count of every swap > entry in the huge swap cluster backing the THP has reach 0. So > try_to_unuse() is changed in commit e07098294adf ("mm, THP, swap: > support to reclaim swap space for THP swapped out") to check that > before delete a page from swap cache, but this has broken KSM swapoff > too. > > Fortunately, KSM is for the normal pages only, so the original > behavior for KSM pages could be restored easily via checking > PageTransCompound(). That is how this patch works. > > Fixes: e07098294adf ("mm, THP, swap: support to reclaim swap space for THP > swapped out") > Signed-off-by: "Huang, Ying" > Reported-and-Tested-and-Acked-by: Hugh Dickins > Cc: Rik van Riel > Cc: Johannes Weiner > Cc: Minchan Kim > Cc: Shaohua Li > Cc: Daniel Jordan > --- > mm/swapfile.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/mm/swapfile.c b/mm/swapfile.c > index 8688ae65ef58..20d3c0f47a5f 100644 > --- a/mm/swapfile.c > +++ b/mm/swapfile.c > @@ -2197,7 +2197,8 @@ int try_to_unuse(unsigned int type, bool frontswap, >*/ > if (PageSwapCache(page) && > likely(page_private(page) == entry.val) && > - !page_swapped(page)) > + (!PageTransCompound(page) || > + !swap_page_trans_huge_swapped(si, entry))) > delete_from_swap_cache(compound_head(page)); > > /*
[PATCH] firmware: (memconsole) do not count numbers if read fails
When memory_read_from_buffer() fails, the return value is a negative error code, thus we shouldn't count it as the number of read bytes. The fix checks the return value of memory_read_from_buffer, and count the number only when it succeeds. Signed-off-by: Kangjie Lu --- drivers/firmware/google/memconsole-coreboot.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/google/memconsole-coreboot.c b/drivers/firmware/google/memconsole-coreboot.c index b29e10757bfb..4e8a0ad110c1 100644 --- a/drivers/firmware/google/memconsole-coreboot.c +++ b/drivers/firmware/google/memconsole-coreboot.c @@ -55,6 +55,7 @@ static ssize_t memconsole_coreboot_read(char *buf, loff_t pos, size_t count) } seg[2] = { {0}, {0} }; size_t done = 0; int i; + int ret; if (flags & OVERFLOW) { if (cursor > size) /* Shouldn't really happen, but... */ @@ -66,8 +67,10 @@ static ssize_t memconsole_coreboot_read(char *buf, loff_t pos, size_t count) } for (i = 0; i < ARRAY_SIZE(seg) && count > done; i++) { - done += memory_read_from_buffer(buf + done, count - done, , + ret = memory_read_from_buffer(buf + done, count - done, , cbmem_console->body + seg[i].phys, seg[i].len); + if (ret >= 0) + done += ret; pos -= seg[i].len; } return done; -- 2.17.2 (Apple Git-113)
Re: [PATCH 05/18] drm/mediatek: add ddp component CCORR
Hi, Yongqiang: On Mon, 2018-12-24 at 16:08 +0800, Yongqiang Niu wrote: > This patch add ddp component CCORR Reviewed-by: CK Hu > Signed-off-by: Yongqiang Niu > --- > drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c | 32 > + > drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h | 2 ++ > 2 files changed, 34 insertions(+) > > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c > b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c > index 54ca794..310c0b9 100644 > --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c > +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c > @@ -41,6 +41,12 @@ > #define DISP_AAL_EN 0x > #define DISP_AAL_SIZE0x0030 > > +#define DISP_CCORR_EN0x > +#define CCORR_EN BIT(0) > +#define DISP_CCORR_CFG 0x0020 > +#define CCORR_RELAY_MODE BIT(0) > +#define DISP_CCORR_SIZE 0x0030 > + > #define DISP_GAMMA_EN0x > #define DISP_GAMMA_CFG 0x0020 > #define DISP_GAMMA_SIZE 0x0030 > @@ -131,6 +137,24 @@ static void mtk_aal_stop(struct mtk_ddp_comp *comp) > writel_relaxed(0x0, comp->regs + DISP_AAL_EN); > } > > +static void mtk_ccorr_config(struct mtk_ddp_comp *comp, unsigned int w, > + unsigned int h, unsigned int vrefresh, > + unsigned int bpc) > +{ > + writel(h << 16 | w, comp->regs + DISP_CCORR_SIZE); > + writel(CCORR_RELAY_MODE, comp->regs + DISP_CCORR_CFG); > +} > + > +static void mtk_ccorr_start(struct mtk_ddp_comp *comp) > +{ > + writel(CCORR_EN, comp->regs + DISP_CCORR_EN); > +} > + > +static void mtk_ccorr_stop(struct mtk_ddp_comp *comp) > +{ > + writel_relaxed(0x0, comp->regs + DISP_CCORR_EN); > +} > + > static void mtk_gamma_config(struct mtk_ddp_comp *comp, unsigned int w, >unsigned int h, unsigned int vrefresh, >unsigned int bpc) > @@ -179,6 +203,12 @@ static void mtk_gamma_set(struct mtk_ddp_comp *comp, > .stop = mtk_aal_stop, > }; > > +static const struct mtk_ddp_comp_funcs ddp_ccorr = { > + .config = mtk_ccorr_config, > + .start = mtk_ccorr_start, > + .stop = mtk_ccorr_stop, > +}; > + > static const struct mtk_ddp_comp_funcs ddp_gamma = { > .gamma_set = mtk_gamma_set, > .config = mtk_gamma_config, > @@ -200,6 +230,7 @@ static void mtk_gamma_set(struct mtk_ddp_comp *comp, > [MTK_DISP_RDMA] = "rdma", > [MTK_DISP_WDMA] = "wdma", > [MTK_DISP_COLOR] = "color", > + [MTK_DISP_CCORR] = "ccorr", > [MTK_DISP_AAL] = "aal", > [MTK_DISP_GAMMA] = "gamma", > [MTK_DISP_UFOE] = "ufoe", > @@ -221,6 +252,7 @@ struct mtk_ddp_comp_match { > [DDP_COMPONENT_AAL0]= { MTK_DISP_AAL, 0, _aal }, > [DDP_COMPONENT_AAL1]= { MTK_DISP_AAL, 1, _aal }, > [DDP_COMPONENT_BLS] = { MTK_DISP_BLS, 0, NULL }, > + [DDP_COMPONENT_CCORR] = { MTK_DISP_CCORR, 0, _ccorr }, > [DDP_COMPONENT_COLOR0] = { MTK_DISP_COLOR, 0, NULL }, > [DDP_COMPONENT_COLOR1] = { MTK_DISP_COLOR, 1, NULL }, > [DDP_COMPONENT_DPI0]= { MTK_DPI,0, NULL }, > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h > b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h > index 8399229..87ef290 100644 > --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h > +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h > @@ -28,6 +28,7 @@ enum mtk_ddp_comp_type { > MTK_DISP_RDMA, > MTK_DISP_WDMA, > MTK_DISP_COLOR, > + MTK_DISP_CCORR, > MTK_DISP_AAL, > MTK_DISP_GAMMA, > MTK_DISP_UFOE, > @@ -44,6 +45,7 @@ enum mtk_ddp_comp_id { > DDP_COMPONENT_AAL0, > DDP_COMPONENT_AAL1, > DDP_COMPONENT_BLS, > + DDP_COMPONENT_CCORR, > DDP_COMPONENT_COLOR0, > DDP_COMPONENT_COLOR1, > DDP_COMPONENT_DPI0,
Re: [PATCH] btrfs: add a check for sysfs_create_group
On 2018/12/26 上午11:46, Kangjie Lu wrote: > In case sysfs_create_group fails, let's check its return value and > issues an error message. > > Signed-off-by: Kangjie Lu > --- > fs/btrfs/sysfs.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c > index 3717c864ba23..62529153a51a 100644 > --- a/fs/btrfs/sysfs.c > +++ b/fs/btrfs/sysfs.c > @@ -889,6 +889,8 @@ void btrfs_sysfs_feature_update(struct btrfs_fs_info > *fs_info, >*/ > sysfs_remove_group(fsid_kobj, _feature_attr_group); > ret = sysfs_create_group(fsid_kobj, _feature_attr_group); > + if (ret) > + pr_err("failed to create btrfs_feature_attr_group.\n"); Btrfs have better error message infrastructures (e.g. distinguish different filesystems). Please use btrfs_error() or btrfs_warn() instead. Despite that, I think the patch looks good. Thanks, Qu > } > > static int btrfs_init_debugfs(void) > signature.asc Description: OpenPGP digital signature
[PATCH] mm, swap: Fix swapoff with KSM pages
KSM pages may be mapped to the multiple VMAs that cannot be reached from one anon_vma. So during swapin, a new copy of the page need to be generated if a different anon_vma is needed, please refer to comments of ksm_might_need_to_copy() for details. During swapoff, unuse_vma() uses anon_vma (if available) to locate VMA and virtual address mapped to the page, so not all mappings to a swapped out KSM page could be found. So in try_to_unuse(), even if the swap count of a swap entry isn't zero, the page needs to be deleted from swap cache, so that, in the next round a new page could be allocated and swapin for the other mappings of the swapped out KSM page. But this contradicts with the THP swap support. Where the THP could be deleted from swap cache only after the swap count of every swap entry in the huge swap cluster backing the THP has reach 0. So try_to_unuse() is changed in commit e07098294adf ("mm, THP, swap: support to reclaim swap space for THP swapped out") to check that before delete a page from swap cache, but this has broken KSM swapoff too. Fortunately, KSM is for the normal pages only, so the original behavior for KSM pages could be restored easily via checking PageTransCompound(). That is how this patch works. Fixes: e07098294adf ("mm, THP, swap: support to reclaim swap space for THP swapped out") Signed-off-by: "Huang, Ying" Reported-and-Tested-and-Acked-by: Hugh Dickins Cc: Rik van Riel Cc: Johannes Weiner Cc: Minchan Kim Cc: Shaohua Li Cc: Daniel Jordan --- mm/swapfile.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/swapfile.c b/mm/swapfile.c index 8688ae65ef58..20d3c0f47a5f 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -2197,7 +2197,8 @@ int try_to_unuse(unsigned int type, bool frontswap, */ if (PageSwapCache(page) && likely(page_private(page) == entry.val) && - !page_swapped(page)) + (!PageTransCompound(page) || +!swap_page_trans_huge_swapped(si, entry))) delete_from_swap_cache(compound_head(page)); /* -- 2.19.2
[PATCH] pci: fix a missing check of snd_i2c_sendbytes
snd_i2c_sendbytes could fail. The fix checks its return value: if it fails, issues an error message and returns with its error code. Signed-off-by: Kangjie Lu --- sound/pci/ice1712/ews.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sound/pci/ice1712/ews.c b/sound/pci/ice1712/ews.c index b8af747ecb43..b978cdb0fc20 100644 --- a/sound/pci/ice1712/ews.c +++ b/sound/pci/ice1712/ews.c @@ -826,7 +826,10 @@ static int snd_ice1712_6fire_read_pca(struct snd_ice1712 *ice, unsigned char reg snd_i2c_lock(ice->i2c); byte = reg; - snd_i2c_sendbytes(spec->i2cdevs[EWS_I2C_6FIRE], , 1); + if (snd_i2c_sendbytes(spec->i2cdevs[EWS_I2C_6FIRE], , 1)) { + dev_err(ice->card->dev, "cannot send pca\n"); + return -EIO; + } byte = 0; if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_6FIRE], , 1) != 1) { snd_i2c_unlock(ice->i2c); -- 2.17.2 (Apple Git-113)
[PATCH] net: sfc: checks status of efx_mcdi_rpc
efx_mcdi_rpc() could fail. The fix checks its status and issues an error message if it fails. Signed-off-by: Kangjie Lu --- drivers/net/ethernet/sfc/mcdi.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/ethernet/sfc/mcdi.c b/drivers/net/ethernet/sfc/mcdi.c index dfad93fca0a6..9486e6534dea 100644 --- a/drivers/net/ethernet/sfc/mcdi.c +++ b/drivers/net/ethernet/sfc/mcdi.c @@ -1819,6 +1819,9 @@ void efx_mcdi_set_id_led(struct efx_nic *efx, enum efx_led_mode mode) rc = efx_mcdi_rpc(efx, MC_CMD_SET_ID_LED, inbuf, sizeof(inbuf), NULL, 0, NULL); + if (rc) + netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n", + __func__, rc); } static int efx_mcdi_reset_func(struct efx_nic *efx) -- 2.17.2 (Apple Git-113)
[PATCH] wan: fix a missing check of spi_write_then_read
When spi_write_then_read() fails, "data" can be uninitialized and thus may contain a random value; the following execution checks "data" with a mask, the result could be random. The fix inserts a check of spi_write_then_read(): if it fails, always returns -1. Signed-off-by: Kangjie Lu --- drivers/net/wan/slic_ds26522.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/wan/slic_ds26522.c b/drivers/net/wan/slic_ds26522.c index 1f6bc8791d51..89681910d875 100644 --- a/drivers/net/wan/slic_ds26522.c +++ b/drivers/net/wan/slic_ds26522.c @@ -64,8 +64,9 @@ static u8 slic_read(struct spi_device *spi, u16 addr) temp[0] = (u8)(((addr >> 8) & 0x7f) | 0x80); temp[1] = (u8)(addr & 0xfe); - spi_write_then_read(spi, [0], SLIC_TWO_LEN, , - SLIC_TRANS_LEN); + if (spi_write_then_read(spi, [0], SLIC_TWO_LEN, , + SLIC_TRANS_LEN)) + return -1; data = bitrev8(data); return data; -- 2.17.2 (Apple Git-113)
Re: [PATCH] f2fs: fix use-after-free issue with sbi->stat_info
On Tue, Dec 25, 2018 at 11:06:45AM +0800, Chao Yu wrote: > On 2018/12/24 21:06, Sahitya Tummala wrote: > > iput() on sbi->node_inode can update sbi->stat_info > > in the below context, if the f2fs_write_checkpoint() > > has failed with error. > > > > f2fs_balance_fs_bg+0x1ac/0x1ec > > f2fs_write_node_pages+0x4c/0x260 > > do_writepages+0x80/0xbc > > __writeback_single_inode+0xdc/0x4ac > > writeback_single_inode+0x9c/0x144 > > write_inode_now+0xc4/0xec > > iput+0x194/0x22c > > f2fs_put_super+0x11c/0x1e8 > > generic_shutdown_super+0x70/0xf4 > > kill_block_super+0x2c/0x5c > > kill_f2fs_super+0x44/0x50 > > deactivate_locked_super+0x60/0x8c > > deactivate_super+0x68/0x74 > > cleanup_mnt+0x40/0x78 > > > > Fix this by moving f2fs_destroy_stats() further below iput(). > > > > Signed-off-by: Sahitya Tummala > > --- > > fs/f2fs/super.c | 9 ++--- > > 1 file changed, 6 insertions(+), 3 deletions(-) > > > > diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c > > index e184ad4e..df41a3a 100644 > > --- a/fs/f2fs/super.c > > +++ b/fs/f2fs/super.c > > @@ -1058,9 +1058,6 @@ static void f2fs_put_super(struct super_block *sb) > > f2fs_write_checkpoint(sbi, ); > > } > > > > - /* f2fs_write_checkpoint can update stat informaion */ > > - f2fs_destroy_stats(sbi); > > The code order in error path of fill_super is almost the same as the one of > put_super, could you please check that as well? > Thanks Chao, for pointing it out. Yes, the same issue exists in error path of fill_super as well. I will fix it. > Thanks, > > > - > > /* > > * normally superblock is clean, so we need to release this. > > * In addition, EIO will skip do checkpoint, we need this as well. > > @@ -1080,6 +1077,12 @@ static void f2fs_put_super(struct super_block *sb) > > iput(sbi->node_inode); > > iput(sbi->meta_inode); > > > > + /* > > +* iput() can update stat information, if f2fs_write_checkpoint() > > +* above failed with error. > > +*/ > > + f2fs_destroy_stats(sbi); > > + > > /* destroy f2fs internal modules */ > > f2fs_destroy_node_manager(sbi); > > f2fs_destroy_segment_manager(sbi); > > > -- -- Sent by a consultant of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
[PATCH] ethernet: atl1e: checking the status of atl1e_write_phy_reg
atl1e_write_phy_reg() could fail. The fix issues an error message when it fails. Signed-off-by: Kangjie Lu --- drivers/net/ethernet/atheros/atl1e/atl1e_main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/atheros/atl1e/atl1e_main.c b/drivers/net/ethernet/atheros/atl1e/atl1e_main.c index 9dc6da039a6d..3164aad29bcf 100644 --- a/drivers/net/ethernet/atheros/atl1e/atl1e_main.c +++ b/drivers/net/ethernet/atheros/atl1e/atl1e_main.c @@ -473,7 +473,9 @@ static void atl1e_mdio_write(struct net_device *netdev, int phy_id, { struct atl1e_adapter *adapter = netdev_priv(netdev); - atl1e_write_phy_reg(>hw, reg_num & MDIO_REG_ADDR_MASK, val); + if (atl1e_write_phy_reg(>hw, + reg_num & MDIO_REG_ADDR_MASK, val)) + netdev_err(netdev, "write phy register failed\n"); } static int atl1e_mii_ioctl(struct net_device *netdev, -- 2.17.2 (Apple Git-113)
[PATCH] leds: fix a missing check of return value of lp55xx_read
When lp55xx_read() fails, "status" is an uninitialized variable and thus may contain random value; using it leads to undefined behaviors. The fix inserts a check for the return value of lp55xx_read: if it fails, returns with its error code. Signed-off-by: Kangjie Lu --- drivers/leds/leds-lp5523.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/leds/leds-lp5523.c b/drivers/leds/leds-lp5523.c index a2e74feee2b2..fd64df5a57a5 100644 --- a/drivers/leds/leds-lp5523.c +++ b/drivers/leds/leds-lp5523.c @@ -318,7 +318,9 @@ static int lp5523_init_program_engine(struct lp55xx_chip *chip) /* Let the programs run for couple of ms and check the engine status */ usleep_range(3000, 6000); - lp55xx_read(chip, LP5523_REG_STATUS, ); + ret = lp55xx_read(chip, LP5523_REG_STATUS, ); + if (ret) + return ret; status &= LP5523_ENG_STATUS_MASK; if (status != LP5523_ENG_STATUS_MASK) { -- 2.17.2 (Apple Git-113)
[PATCH] time: fix a missing check of rtc_read_time
When rtc_read_time fails, we shouldn't use it read time. The fix returns with its error code when it fails. Signed-off-by: Kangjie Lu --- kernel/time/alarmtimer.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c index fa5de5e8de61..19ba8a1633e0 100644 --- a/kernel/time/alarmtimer.c +++ b/kernel/time/alarmtimer.c @@ -293,7 +293,9 @@ static int alarmtimer_suspend(struct device *dev) /* Setup an rtc timer to fire that far in the future */ rtc_timer_cancel(rtc, ); - rtc_read_time(rtc, ); + ret = rtc_read_time(rtc, ); + if (ret < 0) + return ret; now = rtc_tm_to_ktime(tm); now = ktime_add(now, min); -- 2.17.2 (Apple Git-113)
[PATCH] dsa: return error code upstream
Both bcm_sf2_sw_indir_rw and mdiobus_write_nested could fail, so let's return their error codes upstream. Signed-off-by: Kangjie Lu --- drivers/net/dsa/bcm_sf2.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c index 2eb68769562c..441fea57a7ea 100644 --- a/drivers/net/dsa/bcm_sf2.c +++ b/drivers/net/dsa/bcm_sf2.c @@ -303,11 +303,10 @@ static int bcm_sf2_sw_mdio_write(struct mii_bus *bus, int addr, int regnum, * send them to our master MDIO bus controller */ if (addr == BRCM_PSEUDO_PHY_ADDR && priv->indir_phy_mask & BIT(addr)) - bcm_sf2_sw_indir_rw(priv, 0, addr, regnum, val); + return bcm_sf2_sw_indir_rw(priv, 0, addr, regnum, val); else - mdiobus_write_nested(priv->master_mii_bus, addr, regnum, val); - - return 0; + return mdiobus_write_nested(priv->master_mii_bus, addr, + regnum, val); } static irqreturn_t bcm_sf2_switch_0_isr(int irq, void *dev_id) -- 2.17.2 (Apple Git-113)
Re: [PATCH net-next 0/3] vhost: accelerate metadata access through vmap()
On 2018/12/25 下午8:52, Michael S. Tsirkin wrote: On Tue, Dec 25, 2018 at 06:09:19PM +0800, Jason Wang wrote: On 2018/12/25 上午2:12, Michael S. Tsirkin wrote: On Mon, Dec 24, 2018 at 04:32:39PM +0800, Jason Wang wrote: On 2018/12/14 下午8:33, Michael S. Tsirkin wrote: On Fri, Dec 14, 2018 at 11:42:18AM +0800, Jason Wang wrote: On 2018/12/13 下午11:27, Michael S. Tsirkin wrote: On Thu, Dec 13, 2018 at 06:10:19PM +0800, Jason Wang wrote: Hi: This series tries to access virtqueue metadata through kernel virtual address instead of copy_user() friends since they had too much overheads like checks, spec barriers or even hardware feature toggling. Userspace accesses through remapping tricks and next time there's a need for a new barrier we are left to figure it out by ourselves. I don't get here, do you mean spec barriers? I mean the next barrier people decide to put into userspace memory accesses. It's completely unnecessary for vhost which is kernel thread. It's defence in depth. Take a look at the commit that added them. And yes quite possibly in most cases we actually have a spec barrier in the validation phase. If we do let's use the unsafe variants so they can be found. unsafe variants can only work if you can batch userspace access. This is not necessarily the case for light load. Do we care a lot about the light load? How would you benchmark it? If we can reduce the latency that's will be more than what we expect. 1 byte TCP_RR shows 1.5%-2% improvement. It's nice but not great. E.g. adaptive polling would be a better approach to work on latency imho. Actually this is another advantages of vmap(): For split ring, we will poll avail idx For packed ring, we will poll wrap counter Either of which can not be batched. And even if you're right, vhost is not the only place, there's lots of vmap() based accessing in kernel. For sure. But if one can get by without get user pages, one really should. Witness recently uncovered mess with file backed storage. We only pin metadata pages, I don't believe they will be used by any DMA. It doesn't matter really, if you dirty pages behind the MM back the problem is there. Ok, but the usual case is anonymous pages, do we use file backed pages for user of vhost? Some people use file backed pages for vms. Nothing prevents them from using vhost as well. Ok. And even if we use sometime, according to the pointer it's not something that can fix, RFC has been posted to solve this issue. Thanks Except it's not broken if we don't to gup + write. So yea, wait for rfc to be merged. Yes. Thanks
Re: [PATCH net-next 3/3] vhost: access vq metadata through kernel virtual address
On 2018/12/25 下午8:50, Michael S. Tsirkin wrote: On Tue, Dec 25, 2018 at 06:05:25PM +0800, Jason Wang wrote: On 2018/12/25 上午2:10, Michael S. Tsirkin wrote: On Mon, Dec 24, 2018 at 03:53:16PM +0800, Jason Wang wrote: On 2018/12/14 下午8:36, Michael S. Tsirkin wrote: On Fri, Dec 14, 2018 at 11:57:35AM +0800, Jason Wang wrote: On 2018/12/13 下午11:44, Michael S. Tsirkin wrote: On Thu, Dec 13, 2018 at 06:10:22PM +0800, Jason Wang wrote: It was noticed that the copy_user() friends that was used to access virtqueue metdata tends to be very expensive for dataplane implementation like vhost since it involves lots of software check, speculation barrier, hardware feature toggling (e.g SMAP). The extra cost will be more obvious when transferring small packets. This patch tries to eliminate those overhead by pin vq metadata pages and access them through vmap(). During SET_VRING_ADDR, we will setup those mappings and memory accessors are modified to use pointers to access the metadata directly. Note, this was only done when device IOTLB is not enabled. We could use similar method to optimize it in the future. Tests shows about ~24% improvement on TX PPS when using virtio-user + vhost_net + xdp1 on TAP (CONFIG_HARDENED_USERCOPY is not enabled): Before: ~5.0Mpps After: ~6.1Mpps Signed-off-by: Jason Wang --- drivers/vhost/vhost.c | 178 ++ drivers/vhost/vhost.h | 11 +++ 2 files changed, 189 insertions(+) diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index bafe39d2e637..1bd24203afb6 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -443,6 +443,9 @@ void vhost_dev_init(struct vhost_dev *dev, vq->indirect = NULL; vq->heads = NULL; vq->dev = dev; + memset(>avail_ring, 0, sizeof(vq->avail_ring)); + memset(>used_ring, 0, sizeof(vq->used_ring)); + memset(>desc_ring, 0, sizeof(vq->desc_ring)); mutex_init(>mutex); vhost_vq_reset(dev, vq); if (vq->handle_kick) @@ -614,6 +617,102 @@ static void vhost_clear_msg(struct vhost_dev *dev) spin_unlock(>iotlb_lock); } +static int vhost_init_vmap(struct vhost_vmap *map, unsigned long uaddr, + size_t size, int write) +{ + struct page **pages; + int npages = DIV_ROUND_UP(size, PAGE_SIZE); + int npinned; + void *vaddr; + + pages = kmalloc_array(npages, sizeof(struct page *), GFP_KERNEL); + if (!pages) + return -ENOMEM; + + npinned = get_user_pages_fast(uaddr, npages, write, pages); + if (npinned != npages) + goto err; + As I said I have doubts about the whole approach, but this implementation in particular isn't a good idea as it keeps the page around forever. The pages wil be released during set features. So no THP, no NUMA rebalancing, For THP, we will probably miss 2 or 4 pages, but does this really matter consider the gain we have? We as in vhost? networking isn't the only thing guest does. We don't even know if this guest does a lot of networking. You don't know what else is in this huge page. Can be something very important that guest touches all the time. Well, the probability should be very small consider we usually give several gigabytes to guest. The rest of the pages that doesn't sit in the same hugepage with metadata can still be merged by THP. Anyway, I can test the differences. Thanks! For NUMA rebalancing, I'm even not quite sure if it can helps for the case of IPC (vhost). It looks to me the worst case it may cause page to be thrash between nodes if vhost and userspace are running in two nodes. So again it's a gain for vhost but has a completely unpredictable effect on other functionality of the guest. That's what bothers me with this approach. So: - The rest of the pages could still be balanced to other nodes, no? - try to balance metadata pages (belongs to co-operate processes) itself is still questionable I am not sure why. It should be easy enough to force the VCPU and vhost to move (e.g. start them pinned to 1 cpu, then pin them to another one). Clearly sometimes this would be necessary for load balancing reasons. Yes, but it looks to me the part of motivation of auto NUMA is to avoid manual pinning. With autonuma after a while (could take seconds but it will happen) the memory will migrate. Yes. As you mentioned during the discuss, I wonder we could do it similarly through mmu notifier like APIC access page in commit c24ae0dcd3e ("kvm: x86: Unpin and remove kvm_arch->apic_access_page") This is the price of all GUP users not only vhost itself. Yes. GUP is just not a great interface for vhost to use. Zerocopy codes (enabled by defualt) use them for years. But only for TX and temporarily. We pin, read, unpin. Probably not. For several reasons that the page will be not be released
Re: [PATCH 04/18] drm/mediatek: move rdma sout from mtk_ddp_mout_en into mtk_ddp_sout_sel
Hi, Yongqiang: On Mon, 2018-12-24 at 16:08 +0800, Yongqiang Niu wrote: > This patch move rdma sout from mtk_ddp_mout_en into mtk_ddp_sout_sel This patch looks good to me, but you should describe why do you do this. Regards, CK > > Signed-off-by: Yongqiang Niu > --- > drivers/gpu/drm/mediatek/mtk_drm_ddp.c | 90 > +- > 1 file changed, 45 insertions(+), 45 deletions(-) > > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp.c > b/drivers/gpu/drm/mediatek/mtk_drm_ddp.c > index 592f852..60cfde7 100644 > --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp.c > +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp.c > @@ -295,51 +295,6 @@ static unsigned int mtk_ddp_mout_en(enum mtk_ddp_comp_id > cur, > } else if (cur == DDP_COMPONENT_OD1 && next == DDP_COMPONENT_RDMA1) { > *addr = DISP_REG_CONFIG_DISP_OD_MOUT_EN; > value = OD1_MOUT_EN_RDMA1; > - } else if (cur == DDP_COMPONENT_RDMA0 && next == DDP_COMPONENT_DPI0) { > - *addr = DISP_REG_CONFIG_DISP_RDMA0_SOUT_EN; > - value = RDMA0_SOUT_DPI0; > - } else if (cur == DDP_COMPONENT_RDMA0 && next == DDP_COMPONENT_DPI1) { > - *addr = DISP_REG_CONFIG_DISP_RDMA0_SOUT_EN; > - value = RDMA0_SOUT_DPI1; > - } else if (cur == DDP_COMPONENT_RDMA0 && next == DDP_COMPONENT_DSI1) { > - *addr = DISP_REG_CONFIG_DISP_RDMA0_SOUT_EN; > - value = RDMA0_SOUT_DSI1; > - } else if (cur == DDP_COMPONENT_RDMA0 && next == DDP_COMPONENT_DSI2) { > - *addr = DISP_REG_CONFIG_DISP_RDMA0_SOUT_EN; > - value = RDMA0_SOUT_DSI2; > - } else if (cur == DDP_COMPONENT_RDMA0 && next == DDP_COMPONENT_DSI3) { > - *addr = DISP_REG_CONFIG_DISP_RDMA0_SOUT_EN; > - value = RDMA0_SOUT_DSI3; > - } else if (cur == DDP_COMPONENT_RDMA1 && next == DDP_COMPONENT_DSI1) { > - *addr = DISP_REG_CONFIG_DISP_RDMA1_SOUT_EN; > - value = RDMA1_SOUT_DSI1; > - } else if (cur == DDP_COMPONENT_RDMA1 && next == DDP_COMPONENT_DSI2) { > - *addr = DISP_REG_CONFIG_DISP_RDMA1_SOUT_EN; > - value = RDMA1_SOUT_DSI2; > - } else if (cur == DDP_COMPONENT_RDMA1 && next == DDP_COMPONENT_DSI3) { > - *addr = DISP_REG_CONFIG_DISP_RDMA1_SOUT_EN; > - value = RDMA1_SOUT_DSI3; > - } else if (cur == DDP_COMPONENT_RDMA1 && next == DDP_COMPONENT_DPI0) { > - *addr = DISP_REG_CONFIG_DISP_RDMA1_SOUT_EN; > - value = RDMA1_SOUT_DPI0; > - } else if (cur == DDP_COMPONENT_RDMA1 && next == DDP_COMPONENT_DPI1) { > - *addr = DISP_REG_CONFIG_DISP_RDMA1_SOUT_EN; > - value = RDMA1_SOUT_DPI1; > - } else if (cur == DDP_COMPONENT_RDMA2 && next == DDP_COMPONENT_DPI0) { > - *addr = DISP_REG_CONFIG_DISP_RDMA2_SOUT; > - value = RDMA2_SOUT_DPI0; > - } else if (cur == DDP_COMPONENT_RDMA2 && next == DDP_COMPONENT_DPI1) { > - *addr = DISP_REG_CONFIG_DISP_RDMA2_SOUT; > - value = RDMA2_SOUT_DPI1; > - } else if (cur == DDP_COMPONENT_RDMA2 && next == DDP_COMPONENT_DSI1) { > - *addr = DISP_REG_CONFIG_DISP_RDMA2_SOUT; > - value = RDMA2_SOUT_DSI1; > - } else if (cur == DDP_COMPONENT_RDMA2 && next == DDP_COMPONENT_DSI2) { > - *addr = DISP_REG_CONFIG_DISP_RDMA2_SOUT; > - value = RDMA2_SOUT_DSI2; > - } else if (cur == DDP_COMPONENT_RDMA2 && next == DDP_COMPONENT_DSI3) { > - *addr = DISP_REG_CONFIG_DISP_RDMA2_SOUT; > - value = RDMA2_SOUT_DSI3; > } else { > value = 0; > } > @@ -421,6 +376,51 @@ static unsigned int mtk_ddp_sout_sel(void __iomem > *config_regs, > } else if (cur == DDP_COMPONENT_RDMA1 && next == DDP_COMPONENT_DSI0) { > *addr = DISP_REG_CONFIG_DSI_SEL; > value = DSI_SEL_IN_RDMA; > + } else if (cur == DDP_COMPONENT_RDMA0 && next == DDP_COMPONENT_DPI0) { > + *addr = DISP_REG_CONFIG_DISP_RDMA0_SOUT_EN; > + value = RDMA0_SOUT_DPI0; > + } else if (cur == DDP_COMPONENT_RDMA0 && next == DDP_COMPONENT_DPI1) { > + *addr = DISP_REG_CONFIG_DISP_RDMA0_SOUT_EN; > + value = RDMA0_SOUT_DPI1; > + } else if (cur == DDP_COMPONENT_RDMA0 && next == DDP_COMPONENT_DSI1) { > + *addr = DISP_REG_CONFIG_DISP_RDMA0_SOUT_EN; > + value = RDMA0_SOUT_DSI1; > + } else if (cur == DDP_COMPONENT_RDMA0 && next == DDP_COMPONENT_DSI2) { > + *addr = DISP_REG_CONFIG_DISP_RDMA0_SOUT_EN; > + value = RDMA0_SOUT_DSI2; > + } else if (cur == DDP_COMPONENT_RDMA0 && next == DDP_COMPONENT_DSI3) { > + *addr = DISP_REG_CONFIG_DISP_RDMA0_SOUT_EN; > + value = RDMA0_SOUT_DSI3; > + } else if (cur == DDP_COMPONENT_RDMA1 && next == DDP_COMPONENT_DSI1) { > + *addr = DISP_REG_CONFIG_DISP_RDMA1_SOUT_EN; > + value = RDMA1_SOUT_DSI1; > + } else if
[PATCH] ipset: fix a missing check of nla_parse
When nla_parse fails, we should not use the results (the first argument). The fix checks if it fails, and if so, returns its error code upstream. Signed-off-by: Kangjie Lu --- net/netfilter/ipset/ip_set_core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c index 1577f2f76060..4dc8057cff02 100644 --- a/net/netfilter/ipset/ip_set_core.c +++ b/net/netfilter/ipset/ip_set_core.c @@ -1531,8 +1531,10 @@ call_ad(struct sock *ctnl, struct sk_buff *skb, struct ip_set *set, memcpy(>msg, nlh, nlh->nlmsg_len); cmdattr = (void *)>msg + min_len; - nla_parse(cda, IPSET_ATTR_CMD_MAX, cmdattr, + ret = nla_parse(cda, IPSET_ATTR_CMD_MAX, cmdattr, nlh->nlmsg_len - min_len, ip_set_adt_policy, NULL); + if (ret) + return ret; errline = nla_data(cda[IPSET_ATTR_LINENO]); -- 2.17.2 (Apple Git-113)
[PATCH] btrfs: add a check for sysfs_create_group
In case sysfs_create_group fails, let's check its return value and issues an error message. Signed-off-by: Kangjie Lu --- fs/btrfs/sysfs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c index 3717c864ba23..62529153a51a 100644 --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c @@ -889,6 +889,8 @@ void btrfs_sysfs_feature_update(struct btrfs_fs_info *fs_info, */ sysfs_remove_group(fsid_kobj, _feature_attr_group); ret = sysfs_create_group(fsid_kobj, _feature_attr_group); + if (ret) + pr_err("failed to create btrfs_feature_attr_group.\n"); } static int btrfs_init_debugfs(void) -- 2.17.2 (Apple Git-113)
[PATCH] wireless: marvell: add checks for the return value of sysfs_create_group
sysfs_create_group() could fail, so let's check its return values and issue error messages if it fails. Signed-off-by: Kangjie Lu --- drivers/net/wireless/marvell/libertas/mesh.c | 4 1 file changed, 4 insertions(+) diff --git a/drivers/net/wireless/marvell/libertas/mesh.c b/drivers/net/wireless/marvell/libertas/mesh.c index b0cb16ef8d1d..90b20618e0af 100644 --- a/drivers/net/wireless/marvell/libertas/mesh.c +++ b/drivers/net/wireless/marvell/libertas/mesh.c @@ -797,7 +797,11 @@ static void lbs_persist_config_init(struct net_device *dev) { int ret; ret = sysfs_create_group(&(dev->dev.kobj), _opts_group); + if (ret) + pr_err("failed to create boot_opts_group.\n"); ret = sysfs_create_group(&(dev->dev.kobj), _ie_group); + if (ret) + pr_err("failed to create mesh_ie_group.\n"); } static void lbs_persist_config_remove(struct net_device *dev) -- 2.17.2 (Apple Git-113)
Re: [PATCH] scsi: fix a double-fetch bug in sg_write
On 2018-12-25 3:24 p.m., Kangjie Lu wrote: "opcode" has been copied in from user space and checked. We should not copy it in again, which may have been modified by malicous multi-threading user programs through race conditions. The fix uses the opcode fetched in the first copy. Signed-off-by: Kangjie Lu Acked-by: Douglas Gilbert Also applied to my sg v4 driver code. The v1 and v2 interfaces (based on struct sg_header) did not provide a command length field. The sg driver needed to read the first byte of the command (the "opcode") to determine the full command's length prior to actually reading it in full. Hard to think of an example of an exploit based on this double read. --- drivers/scsi/sg.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index 4dacbfffd113..41774e4f9508 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c @@ -686,7 +686,8 @@ sg_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos) hp->flags = input_size; /* structure abuse ... */ hp->pack_id = old_hdr.pack_id; hp->usr_ptr = NULL; - if (__copy_from_user(cmnd, buf, cmd_size)) + cmnd[0] = opcode; + if (__copy_from_user(cmnd + 1, buf + 1, cmd_size - 1)) return -EFAULT; /* * SG_DXFER_TO_FROM_DEV is functionally equivalent to SG_DXFER_FROM_DEV,
[PATCH] line6: add a check for snd_card_register
The fix checks if snd_card_register() fails, and if so, issues a warning. Signed-off-by: Kangjie Lu --- sound/usb/line6/pod.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sound/usb/line6/pod.c b/sound/usb/line6/pod.c index 020c81818951..da8837bc5a5b 100644 --- a/sound/usb/line6/pod.c +++ b/sound/usb/line6/pod.c @@ -320,7 +320,8 @@ static void pod_startup4(struct work_struct *work) line6_read_serial_number(>line6, >serial_number); /* ALSA audio interface: */ - snd_card_register(line6->card); + if (snd_card_register(line6->card)) + pr_warn("Failed to register ALSA card.\n"); } /* POD special files: */ -- 2.17.2 (Apple Git-113)
Re: [PATCH 1/2 v3] kdump: add the vmcoreinfo documentation
On 12/26/18 at 11:24am, Dave Young wrote: > > >> + > > >> +KERNEL_IMAGE_SIZE > > >> += > > >> +The size of 'KERNEL_IMAGE_SIZE', currently unused. > > > > > > So remove? > > > > > > > I'm not sure whether it should be removed, so i keep it. > > Just remove it. It was added by Baoquan for KASLR issues, later > makedumpfile reverted the userspace part and added other implementation. > > In case old makedumpfile does not support new kernel, it has some kernel > versions support list in code, thus no worry about the compatibility > issue. Ah, it is not unused actually, clone crash tool git: $ git grep KERNEL_IMAGE_SIZE x86_64.c: if ((string = pc->read_vmcoreinfo("NUMBER(KERNEL_IMAGE_SIZE)"))) { So in the documentation, the use cases of crash tool should also be covered. Lianbo, it would be good to cc Dave and Kazu for these patches, could you cc them in your next post? > > Thanks > Dave Thanks Dave
RE: [PATCH V5 2/4] thermal: imx_sc: add i.MX system controller thermal support
Hi, Eduardo Best Regards! Anson Huang > -Original Message- > From: Eduardo Valentin [mailto:edubez...@gmail.com] > Sent: 2018年12月26日 6:44 > To: Anson Huang > Cc: robh...@kernel.org; mark.rutl...@arm.com; catalin.mari...@arm.com; > will.dea...@arm.com; rui.zh...@intel.com; daniel.lezc...@linaro.org; > Aisheng Dong ; s.ha...@pengutronix.de; > shawn...@kernel.org; Andy Gross ; a...@arndb.de; > horms+rene...@verge.net.au; he...@sntech.de; bjorn.anders...@linaro.org; > enric.balle...@collabora.com; amit.kuche...@linaro.org; > ezequ...@collabora.com; o...@lixom.net; devicet...@vger.kernel.org; > linux-kernel@vger.kernel.org; linux-arm-ker...@lists.infradead.org; > linux...@vger.kernel.org; dl-linux-imx > Subject: Re: [PATCH V5 2/4] thermal: imx_sc: add i.MX system controller > thermal support > > On Thu, Dec 20, 2018 at 09:08:32AM +, Anson Huang wrote: > > i.MX8QXP is an ARMv8 SoC which has a Cortex-M4 system controller > > inside, the system controller is in charge of controlling power, clock > > and thermal sensors etc.. > > > > This patch adds i.MX system controller thermal driver support, Linux > > kernel has to communicate with system controller via MU (message unit) > > IPC to get each thermal sensor's temperature, it supports multiple > > sensors which are passed from device tree, please see the binding doc > > for details. > > > > Signed-off-by: Anson Huang > > --- > > ChangeLog since V4: > > - Add driver dependency on IMX_SCU to avoid compile error when > IMX_SCU is NOT selected; > > - Remove unnecessary of different errors handle for > imx_scu_get_handle, already included in API. > > --- > > drivers/thermal/Kconfig | 11 +++ > > drivers/thermal/Makefile | 1 + > > drivers/thermal/imx_sc_thermal.c | 200 > > +++ > > 3 files changed, 212 insertions(+) > > create mode 100644 drivers/thermal/imx_sc_thermal.c > > > > diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig index > > 0e69edc..8d4601d 100644 > > --- a/drivers/thermal/Kconfig > > +++ b/drivers/thermal/Kconfig > > @@ -222,6 +222,17 @@ config IMX_THERMAL > > cpufreq is used as the cooling device to throttle CPUs when the > > passive trip is crossed. > > > > +config IMX_SC_THERMAL > > + tristate "Temperature sensor driver for NXP i.MX SoCs with System > Controller" > > + depends on (ARCH_MXC && IMX_SCU) || COMPILE_TEST > > + depends on OF > > + help > > + Support for Temperature Monitor (TEMPMON) found on NXP i.MX SoCs > with > > + system controller inside, Linux kernel has to communicate with system > > + controller via MU (message unit) IPC to get temperature from thermal > > + sensor. It supports one critical trip point and one > > + passive trip point for each thermal sensor. > > + > > config MAX77620_THERMAL > > tristate "Temperature sensor driver for Maxim MAX77620 PMIC" > > depends on MFD_MAX77620 > > diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile index > > 610344e..1b13f6a 100644 > > --- a/drivers/thermal/Makefile > > +++ b/drivers/thermal/Makefile > > @@ -41,6 +41,7 @@ obj-$(CONFIG_DB8500_THERMAL) += > db8500_thermal.o > > obj-$(CONFIG_ARMADA_THERMAL) += armada_thermal.o > > obj-$(CONFIG_TANGO_THERMAL)+= tango_thermal.o > > obj-$(CONFIG_IMX_THERMAL) += imx_thermal.o > > +obj-$(CONFIG_IMX_SC_THERMAL) += imx_sc_thermal.o > > obj-$(CONFIG_MAX77620_THERMAL) += max77620_thermal.o > > obj-$(CONFIG_QORIQ_THERMAL)+= qoriq_thermal.o > > obj-$(CONFIG_DA9062_THERMAL) += da9062-thermal.o > > diff --git a/drivers/thermal/imx_sc_thermal.c > > b/drivers/thermal/imx_sc_thermal.c > > new file mode 100644 > > index 000..1030a31 > > --- /dev/null > > +++ b/drivers/thermal/imx_sc_thermal.c > > @@ -0,0 +1,200 @@ > > +// SPDX-License-Identifier: GPL-2.0+ > > +/* > > + * Copyright 2018 NXP. > > + */ > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +#include "thermal_core.h" > > + > > +#define IMX_SC_MISC_FUNC_GET_TEMP 13 > > +#define IMX_SC_C_TEMP 0 > > + > > +static struct imx_sc_ipc *thermal_ipc_handle; > > + > > +struct imx_sc_sensor { > > + struct thermal_zone_device *tzd; > > + u32 resource_id; > > +}; > > + > > +struct imx_sc_thermal_data { > > + struct imx_sc_sensor *sensor; > > +}; > > + > > +struct req_get_temp { > > + u16 resource_id; > > + u8 type; > > +} __packed; > > + > > +struct resp_get_temp { > > + u16 celsius; > > + u8 tenths; > > +} __packed; > > + > > +struct imx_sc_msg_misc_get_temp { > > + struct imx_sc_rpc_msg hdr; > > + union { > > + struct req_get_temp req; > > + struct resp_get_temp resp; > > + } data; > > +} __packed; > > + > > +static int imx_sc_thermal_get_temp(void *data, int *temp) { > > + struct imx_sc_msg_misc_get_temp msg; > > + struct imx_sc_rpc_msg *hdr = > > +
[PATCH] staging: erofs: fix return type of erofs_workgroup_get
There exists a return type misuse (`int'->`bool') since all users assume it fails if only return value != 0, let's fix the return type to `int' instead of confusing `bool'. No logic changes. Signed-off-by: Gao Xiang --- drivers/staging/erofs/internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h index e049d00c087a..49c587383315 100644 --- a/drivers/staging/erofs/internal.h +++ b/drivers/staging/erofs/internal.h @@ -252,7 +252,7 @@ static inline int erofs_wait_on_workgroup_freezed(struct erofs_workgroup *grp) } #endif -static inline bool erofs_workgroup_get(struct erofs_workgroup *grp, int *ocnt) +static inline int erofs_workgroup_get(struct erofs_workgroup *grp, int *ocnt) { int o; -- 2.14.4
[PATCH] ACPI: Change wrong print type to display the real value for i386-PAE
There is a wrong display for memory address of NUMA node in i386-PAE. That may mislead developers. Here is a debian9-32bit with PAE in QEMU guest whose total memory is more than 4G: qemu-system-i386 \ -hda /var/lib/libvirt/images/debian32.qcow2 \ -m 5G \ -enable-kvm \ -smp 10 \ -numa node,mem=512M,nodeid=0,cpus=0 \ -numa node,mem=512M,nodeid=1,cpus=1 \ -numa node,mem=512M,nodeid=2,cpus=2 \ -numa node,mem=512M,nodeid=3,cpus=3 \ -numa node,mem=512M,nodeid=4,cpus=4 \ -numa node,mem=512M,nodeid=5,cpus=5 \ -numa node,mem=512M,nodeid=6,cpus=6 \ -numa node,mem=512M,nodeid=7,cpus=7 \ -numa node,mem=512M,nodeid=8,cpus=8 \ -numa node,mem=512M,nodeid=9,cpus=9 \ -serial stdio Because of the wrong value type, it prints as below: [0.021049] ACPI: SRAT Memory (0x0 length 0xa) in proximity domain 0 enabled [0.021740] ACPI: SRAT Memory (0x10 length 0x1ff0) in proximity domain 0 enabled [0.022425] ACPI: SRAT Memory (0x2000 length 0x2000) in proximity domain 1 enabled [0.023092] ACPI: SRAT Memory (0x4000 length 0x2000) in proximity domain 2 enabled [0.023764] ACPI: SRAT Memory (0x6000 length 0x2000) in proximity domain 3 enabled [0.024431] ACPI: SRAT Memory (0x8000 length 0x2000) in proximity domain 4 enabled [0.025104] ACPI: SRAT Memory (0xa000 length 0x2000) in proximity domain 5 enabled [0.025791] ACPI: SRAT Memory (0x0 length 0x2000) in proximity domain 6 enabled [0.026412] ACPI: SRAT Memory (0x2000 length 0x2000) in proximity domain 7 enabled [0.027118] ACPI: SRAT Memory (0x4000 length 0x2000) in proximity domain 8 enabled [0.027802] ACPI: SRAT Memory (0x6000 length 0x2000) in proximity domain 9 enabled The upper half of start address from domain 6 to domain 9 was cut so that developers get a wrong value. Fix the value type, it prints as below: [0.023698] ACPI: SRAT Memory (0x0 length 0xa) in proximity domain 0 enabled [0.024325] ACPI: SRAT Memory (0x10 length 0x1ff0) in proximity domain 0 enabled [0.024981] ACPI: SRAT Memory (0x2000 length 0x2000) in proximity domain 1 enabled [0.025659] ACPI: SRAT Memory (0x4000 length 0x2000) in proximity domain 2 enabled [0.026317] ACPI: SRAT Memory (0x6000 length 0x2000) in proximity domain 3 enabled [0.026980] ACPI: SRAT Memory (0x8000 length 0x2000) in proximity domain 4 enabled [0.027635] ACPI: SRAT Memory (0xa000 length 0x2000) in proximity domain 5 enabled [0.028311] ACPI: SRAT Memory (0x1 length 0x2000) in proximity domain 6 enabled [0.028985] ACPI: SRAT Memory (0x12000 length 0x2000) in proximity domain 7 enabled [0.029667] ACPI: SRAT Memory (0x14000 length 0x2000) in proximity domain 8 enabled [0.030334] ACPI: SRAT Memory (0x16000 length 0x2000) in proximity domain 9 enabled The start address from domain 6 to domain 9 is the real value. Signed-off-by: Chao Fan --- drivers/acpi/numa.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/acpi/numa.c b/drivers/acpi/numa.c index 274699463b4f..7bbbf8256a41 100644 --- a/drivers/acpi/numa.c +++ b/drivers/acpi/numa.c @@ -146,9 +146,9 @@ acpi_table_print_srat_entry(struct acpi_subtable_header *header) { struct acpi_srat_mem_affinity *p = (struct acpi_srat_mem_affinity *)header; - pr_debug("SRAT Memory (0x%lx length 0x%lx) in proximity domain %d %s%s%s\n", -(unsigned long)p->base_address, -(unsigned long)p->length, + pr_debug("SRAT Memory (0x%llx length 0x%llx) in proximity domain %d %s%s%s\n", +(unsigned long long)p->base_address, +(unsigned long long)p->length, p->proximity_domain, (p->flags & ACPI_SRAT_MEM_ENABLED) ? "enabled" : "disabled", -- 2.19.2
Re: [PATCH 0/2 v4] kdump,vmcoreinfo: Export the value of sme mask to vmcoreinfo
Add Kazu and Dave in cc On 12/20/18 at 01:40pm, Lianbo Jiang wrote: > This patchset did two things: > a. add a new document for vmcoreinfo > > This document lists some variables that export to vmcoreinfo, and briefly > describles what these variables indicate. It should be instructive for > many people who do not know the vmcoreinfo, and it also normalizes the > exported variable as a convention between kernel and use-space. > > b. export the value of sme mask to vmcoreinfo > > For AMD machine with SME feature, makedumpfile tools need to know whether > the crash kernel was encrypted or not. If SME is enabled in the first > kernel, the crash kernel's page table(pgd/pud/pmd/pte) contains the > memory encryption mask, so need to remove the sme mask to obtain the true > physical address. > > Changes since v1: > 1. No need to export a kernel-internal mask to userspace, so copy the > value of sme_me_mask to a local variable 'sme_mask' and write the value > of sme_mask to vmcoreinfo. > 2. Add comment for the code. > 3. Improve the patch log. > 4. Add the vmcoreinfo documentation. > > Changes since v2: > 1. Improve the vmcoreinfo document, add more descripts for these > variables exported. > 2. Fix spelling errors in the document. > > Changes since v3: > 1. Still improve the vmcoreinfo document, and make it become more > clear and easy to read. > 2. Move sme_mask comments in the code to the vmcoreinfo document. > 3. Improve patch log. > > Lianbo Jiang (2): > kdump: add the vmcoreinfo documentation > kdump,vmcoreinfo: Export the value of sme mask to vmcoreinfo > > Documentation/kdump/vmcoreinfo.txt | 513 + > arch/x86/kernel/machine_kexec_64.c | 3 + > 2 files changed, 516 insertions(+) > create mode 100644 Documentation/kdump/vmcoreinfo.txt > > -- > 2.17.1 >
[PATCH] sound: line6: fix a missing check of snd_card_register
snd_card_register() may fail, so let's check its status and issue an error message if it fails. Signed-off-by: Kangjie Lu --- sound/usb/line6/variax.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sound/usb/line6/variax.c b/sound/usb/line6/variax.c index e8c852b2ce35..b0caa9ea1f5f 100644 --- a/sound/usb/line6/variax.c +++ b/sound/usb/line6/variax.c @@ -167,7 +167,8 @@ static void variax_startup6(struct work_struct *work) CHECK_STARTUP_PROGRESS(variax->startup_progress, VARIAX_STARTUP_SETUP); /* ALSA audio interface: */ - snd_card_register(variax->line6.card); + if (snd_card_register(variax->line6.card)) + dev_err(variax->line6.ifcdev, "Failed to register variax card.\n"); } /* -- 2.17.2 (Apple Git-113)
Re: [PATCH 1/2 v3] kdump: add the vmcoreinfo documentation
> >> + > >> +KERNEL_IMAGE_SIZE > >> += > >> +The size of 'KERNEL_IMAGE_SIZE', currently unused. > > > > So remove? > > > > I'm not sure whether it should be removed, so i keep it. Just remove it. It was added by Baoquan for KASLR issues, later makedumpfile reverted the userspace part and added other implementation. In case old makedumpfile does not support new kernel, it has some kernel versions support list in code, thus no worry about the compatibility issue. Thanks Dave
[PATCH] sunrpc: remove redundant code
If no bytes to decode, just use "xdr->p" instead of calling xdr_inline_decode to get it. The fix cleans up the code. Signed-off-by: Kangjie Lu --- net/sunrpc/xprtrdma/rpc_rdma.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/net/sunrpc/xprtrdma/rpc_rdma.c b/net/sunrpc/xprtrdma/rpc_rdma.c index 9f53e0240035..2ef86be49bd8 100644 --- a/net/sunrpc/xprtrdma/rpc_rdma.c +++ b/net/sunrpc/xprtrdma/rpc_rdma.c @@ -1123,7 +1123,6 @@ rpcrdma_decode_msg(struct rpcrdma_xprt *r_xprt, struct rpcrdma_rep *rep, { struct xdr_stream *xdr = >rr_stream; u32 writelist, replychunk, rpclen; - char *base; /* Decode the chunk lists */ if (decode_read_list(xdr)) @@ -1138,10 +1137,9 @@ rpcrdma_decode_msg(struct rpcrdma_xprt *r_xprt, struct rpcrdma_rep *rep, return -EIO; /* Build the RPC reply's Payload stream in rqst->rq_rcv_buf */ - base = (char *)xdr_inline_decode(xdr, 0); rpclen = xdr_stream_remaining(xdr); r_xprt->rx_stats.fixup_copy_count += - rpcrdma_inline_fixup(rqst, base, rpclen, writelist & 3); + rpcrdma_inline_fixup(rqst, xdr->p, rpclen, writelist & 3); r_xprt->rx_stats.total_rdma_reply += writelist; return rpclen + xdr_align_size(writelist); -- 2.17.2 (Apple Git-113)
[PATCH] sunrpc: fix a missing check of xdr_inline_decode
xdr_inline_decode() could fail. When it fails, the return value is NULL and should not be dereferenced. The fix checks if xdr_inline_decode fails, and if so, returns. Signed-off-by: Kangjie Lu --- net/sunrpc/xprtrdma/backchannel.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/sunrpc/xprtrdma/backchannel.c b/net/sunrpc/xprtrdma/backchannel.c index e5b367a3e517..bd9be5272ef4 100644 --- a/net/sunrpc/xprtrdma/backchannel.c +++ b/net/sunrpc/xprtrdma/backchannel.c @@ -285,6 +285,8 @@ void rpcrdma_bc_receive_call(struct rpcrdma_xprt *r_xprt, __be32 *p; p = xdr_inline_decode(>rr_stream, 0); + if (unlikely(!p)) + goto out_overflow; size = xdr_stream_remaining(>rr_stream); #ifdef RPCRDMA_BACKCHANNEL_DEBUG -- 2.17.2 (Apple Git-113)
[PATCH] usb: dwc3: gadget: Fix the uninitialized link_state when udc starts
Currently the link_state is uninitialized and the default value is 0(U0) before the first time we start the udc, and after we start the udc then stop the udc, the link_state will be undefined. We may have the following warnings if we start the udc again with an undefined link_state: WARNING: CPU: 0 PID: 327 at drivers/usb/dwc3/gadget.c:294 dwc3_send_gadget_ep_cmd+0x304/0x308 dwc3 100e.hidwc3_0: wakeup failed --> -22 [...] Call Trace: [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [] (show_stack) from [] (dump_stack+0x84/0x98) [] (dump_stack) from [] (__warn+0xe8/0x100) [] (__warn) from [](warn_slowpath_fmt+0x38/0x48) [] (warn_slowpath_fmt) from [](dwc3_send_gadget_ep_cmd+0x304/0x308) [] (dwc3_send_gadget_ep_cmd) from [](dwc3_ep0_start_trans+0x48/0xf4) [] (dwc3_ep0_start_trans) from [](dwc3_ep0_out_start+0x64/0x80) [] (dwc3_ep0_out_start) from [](__dwc3_gadget_start+0x1e0/0x278) [] (__dwc3_gadget_start) from [](dwc3_gadget_start+0x88/0x10c) [] (dwc3_gadget_start) from [](udc_bind_to_driver+0x88/0xbc) [] (udc_bind_to_driver) from [](usb_gadget_probe_driver+0xf8/0x140) [] (usb_gadget_probe_driver) from [](gadget_dev_desc_UDC_store+0xac/0xc4 [libcomposite]) [] (gadget_dev_desc_UDC_store [libcomposite]) from[] (configfs_write_file+0xd4/0x160) [] (configfs_write_file) from [] (__vfs_write+0x1c/0x114) [] (__vfs_write) from [] (vfs_write+0xa4/0x168) [] (vfs_write) from [] (SyS_write+0x3c/0x90) [] (SyS_write) from [] (ret_fast_syscall+0x0/0x3c) Signed-off-by: Zeng Tao --- drivers/usb/dwc3/gadget.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 16a6e3c..e18c2a2 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -1988,6 +1988,7 @@ static int __dwc3_gadget_start(struct dwc3 *dwc) /* begin to receive SETUP packets */ dwc->ep0state = EP0_SETUP_PHASE; + dwc->link_state = DWC3_LINK_STATE_SS_DIS; dwc3_ep0_out_start(dwc); dwc3_gadget_enable_irq(dwc); -- 2.7.4
[PATCH] rtc: fix a missing check of block data read
When i2c_smbus_read_i2c_block_data() fails, the read data in "buf" could be incorrect and should not be used. The fix checks if i2c_smbus_read_i2c_block_data fails, and if so, return its error code upstream. Signed-off-by: Kangjie Lu --- drivers/rtc/rtc-hym8563.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/rtc/rtc-hym8563.c b/drivers/rtc/rtc-hym8563.c index e5ad527cb75e..d03f5d212eea 100644 --- a/drivers/rtc/rtc-hym8563.c +++ b/drivers/rtc/rtc-hym8563.c @@ -109,6 +109,8 @@ static int hym8563_rtc_read_time(struct device *dev, struct rtc_time *tm) } ret = i2c_smbus_read_i2c_block_data(client, HYM8563_SEC, 7, buf); + if (ret < 0) + return ret; tm->tm_sec = bcd2bin(buf[0] & HYM8563_SEC_MASK); tm->tm_min = bcd2bin(buf[1] & HYM8563_MIN_MASK); -- 2.17.2 (Apple Git-113)
[PATCH] fs: proc: check status of register_filesystem
register_filesystem() could fail. The fix issues an error message if it fails. Signed-off-by: Kangjie Lu --- fs/proc/root.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/proc/root.c b/fs/proc/root.c index f4b1a9d2eca6..7dcd947cba23 100644 --- a/fs/proc/root.c +++ b/fs/proc/root.c @@ -141,7 +141,8 @@ void __init proc_root_init(void) proc_mkdir("bus", NULL); proc_sys_init(); - register_filesystem(_fs_type); + if (register_filesystem(_fs_type)) + pr_err("failed to register the filesystem.\n"); } static int proc_root_getattr(const struct path *path, struct kstat *stat, -- 2.17.2 (Apple Git-113)
[PATCH] net: stmicro: fix a missing check of clk_prepare
clk_prepare() could fail, so let's check its status, and if it fails, return its error code upstream. Signed-off-by: Kangjie Lu --- drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c index d07520fb969e..62ccbd47c1db 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c @@ -59,7 +59,9 @@ static int sun7i_gmac_init(struct platform_device *pdev, void *priv) gmac->clk_enabled = 1; } else { clk_set_rate(gmac->tx_clk, SUN7I_GMAC_MII_RATE); - clk_prepare(gmac->tx_clk); + ret = clk_prepare(gmac->tx_clk); + if (ret) + return ret; } return 0; -- 2.17.2 (Apple Git-113)
Re: [PATCH 02/18] drm/mediatek: add mutex mod and sof into ddp private data
Hi, Yongqiang: On Mon, 2018-12-24 at 16:08 +0800, Yongqiang Niu wrote: > This patch add mutex mod and sof into ddp private data Usually, the commit title shows 'WHAT' does this patch do, commit message shows 'WHY' does this patch do, and commit body shows 'HOW' does this patch do. This commit message just show WHAT does this patch do but does not show WHY. Maybe this is trivial for you but not for everyone. So describe more about why you do this. In addition, 'add mutex mode' and 'add sof' are two things, so break these two modification into two patches. > > Signed-off-by: Yongqiang Niu > --- > drivers/gpu/drm/mediatek/mtk_drm_ddp.c | 117 > ++--- > 1 file changed, 94 insertions(+), 23 deletions(-) > > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp.c > b/drivers/gpu/drm/mediatek/mtk_drm_ddp.c > index 579ce28..adb37e4 100644 > --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp.c > +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp.c > @@ -41,11 +41,14 @@ > #define DISP_REG_CONFIG_DSI_SEL 0x050 > #define DISP_REG_CONFIG_DPI_SEL 0x064 > > +#define MT2701_DISP_MUTEX0_MOD0 0x2C Lower case for hex number. > +#define MT2701_DISP_MUTEX0_SOF0 0x30 Align 0x2c and 0x30 > + > #define DISP_REG_MUTEX_EN(n) (0x20 + 0x20 * (n)) > #define DISP_REG_MUTEX(n)(0x24 + 0x20 * (n)) > #define DISP_REG_MUTEX_RST(n)(0x28 + 0x20 * (n)) > -#define DISP_REG_MUTEX_MOD(n)(0x2c + 0x20 * (n)) > -#define DISP_REG_MUTEX_SOF(n)(0x30 + 0x20 * (n)) > +#define DISP_REG_MUTEX_MOD(data, n) ((data)->mutex_mod_reg + 0x20 * (n)) > +#define DISP_REG_MUTEX_SOF(data, n) ((data)->mutex_sof_reg + 0x20 * (n)) > #define DISP_REG_MUTEX_MOD2(n) (0x34 + 0x20 * (n)) > > #define INT_MUTEXBIT(1) > @@ -147,12 +150,30 @@ struct mtk_disp_mutex { > bool claimed; > }; > > +enum mtk_ddp_mutex_sof_id { > + DDP_MUTEX_SOF_SINGLE_MODE, > + DDP_MUTEX_SOF_DSI0, > + DDP_MUTEX_SOF_DSI1, > + DDP_MUTEX_SOF_DPI0, > + DDP_MUTEX_SOF_DPI1, > + DDP_MUTEX_SOF_DSI2, > + DDP_MUTEX_SOF_DSI3, > + DDP_MUTEX_SOF_MAX, > +}; > + > +struct mtk_ddp_data { > + const unsigned int *mutex_mod; > + const unsigned int *mutex_sof; > + unsigned int mutex_mod_reg; > + unsigned int mutex_sof_reg; > +}; > + > struct mtk_ddp { > struct device *dev; > struct clk *clk; > void __iomem*regs; > struct mtk_disp_mutex mutex[10]; > - const unsigned int *mutex_mod; > + const struct mtk_ddp_data *data; > }; > > static const unsigned int mt2701_mutex_mod[DDP_COMPONENT_ID_MAX] = { > @@ -202,6 +223,51 @@ struct mtk_ddp { > [DDP_COMPONENT_WDMA1] = MT8173_MUTEX_MOD_DISP_WDMA1, > }; > > +static const unsigned int mt2701_mutex_sof[DDP_MUTEX_SOF_MAX] = { > + [DDP_MUTEX_SOF_SINGLE_MODE] = MUTEX_SOF_SINGLE_MODE, > + [DDP_MUTEX_SOF_DSI0] = MUTEX_SOF_DSI0, > + [DDP_MUTEX_SOF_DSI1] = MUTEX_SOF_DSI1, > + [DDP_MUTEX_SOF_DPI0] = MUTEX_SOF_DPI0, > +}; > + > +static const unsigned int mt2712_mutex_sof[DDP_MUTEX_SOF_MAX] = { > + [DDP_MUTEX_SOF_SINGLE_MODE] = MUTEX_SOF_SINGLE_MODE, > + [DDP_MUTEX_SOF_DSI0] = MUTEX_SOF_DSI0, > + [DDP_MUTEX_SOF_DSI1] = MUTEX_SOF_DSI1, > + [DDP_MUTEX_SOF_DPI0] = MUTEX_SOF_DPI0, > + [DDP_MUTEX_SOF_DPI1] = MUTEX_SOF_DPI1, > + [DDP_MUTEX_SOF_DSI2] = MUTEX_SOF_DSI2, > + [DDP_MUTEX_SOF_DSI3] = MUTEX_SOF_DSI3, > +}; > + > +static const unsigned int mt8173_mutex_sof[DDP_MUTEX_SOF_MAX] = { > + [DDP_MUTEX_SOF_SINGLE_MODE] = MUTEX_SOF_SINGLE_MODE, > + [DDP_MUTEX_SOF_DSI0] = MUTEX_SOF_DSI0, > + [DDP_MUTEX_SOF_DSI1] = MUTEX_SOF_DSI1, > + [DDP_MUTEX_SOF_DPI0] = MUTEX_SOF_DPI0, > +}; It looks like that both mt8173_mutex_sof and mt2701_mutex_sof are subset of mt2712_mutex_sof, so I think you could keep only mt2712_mutex_sof and mt8173 and mt2701 also use this one. > + > +static const struct mtk_ddp_data mt2701_ddp_driver_data = { > + .mutex_mod = mt2701_mutex_mod, > + .mutex_sof = mt2701_mutex_sof, > + .mutex_mod_reg = MT2701_DISP_MUTEX0_MOD0, > + .mutex_sof_reg = MT2701_DISP_MUTEX0_SOF0, > +}; > + > +static const struct mtk_ddp_data mt2712_ddp_driver_data = { > + .mutex_mod = mt2712_mutex_mod, > + .mutex_sof = mt2712_mutex_sof, > + .mutex_mod_reg = MT2701_DISP_MUTEX0_MOD0, > + .mutex_sof_reg = MT2701_DISP_MUTEX0_SOF0, > +}; > + > +static const struct mtk_ddp_data mt8173_ddp_driver_data = { > + .mutex_mod = mt8173_mutex_mod, > + .mutex_sof = mt8173_mutex_sof, > + .mutex_mod_reg = MT2701_DISP_MUTEX0_MOD0, > + .mutex_sof_reg = MT2701_DISP_MUTEX0_SOF0, > +}; > + > static unsigned int mtk_ddp_mout_en(enum mtk_ddp_comp_id cur, > enum mtk_ddp_comp_id next, > unsigned int *addr) > @@ -446,39 +512,40 @@ void
[PATCH] net: (cpts) fix a missing check of clk_prepare
clk_prepare() could fail, so let's check its status, and if it fails, return its error code upstream. Signed-off-by: Kangjie Lu --- drivers/net/ethernet/ti/cpts.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/ti/cpts.c b/drivers/net/ethernet/ti/cpts.c index b96b93c686bf..4f644ac314fe 100644 --- a/drivers/net/ethernet/ti/cpts.c +++ b/drivers/net/ethernet/ti/cpts.c @@ -572,7 +572,9 @@ struct cpts *cpts_create(struct device *dev, void __iomem *regs, return ERR_CAST(cpts->refclk); } - clk_prepare(cpts->refclk); + ret = clk_prepare(cpts->refclk); + if (ret) + return ERR_PTR(ret); cpts->cc.read = cpts_systim_read; cpts->cc.mask = CLOCKSOURCE_MASK(32); -- 2.17.2 (Apple Git-113)
[PATCH] atmel: fix a missing check of clk_prepare
clk_prepare() could fail, so let's check its status, and if it fails, issue an error message. Signed-off-by: Kangjie Lu --- drivers/misc/atmel-ssc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/misc/atmel-ssc.c b/drivers/misc/atmel-ssc.c index d8e3cc2dc747..9e69d0585f49 100644 --- a/drivers/misc/atmel-ssc.c +++ b/drivers/misc/atmel-ssc.c @@ -60,7 +60,8 @@ struct ssc_device *ssc_request(unsigned int ssc_num) ssc->user++; spin_unlock(_lock); - clk_prepare(ssc->clk); + if (clk_prepare(ssc->clk)) + pr_err("ssc: failed to prepare clk.\n"); return ssc; } -- 2.17.2 (Apple Git-113)
[PATCH] clocksource: fix a missing check of clk_prepare
clk_prepare() could fail, so let's check its status, and if it fails, issue an error message. Signed-off-by: Kangjie Lu --- drivers/clocksource/sh_cmt.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c index 55d3e03f2cd4..60a70832cfa9 100644 --- a/drivers/clocksource/sh_cmt.c +++ b/drivers/clocksource/sh_cmt.c @@ -764,7 +764,10 @@ static void sh_cmt_clock_event_resume(struct clock_event_device *ced) { struct sh_cmt_channel *ch = ced_to_sh_cmt(ced); - clk_prepare(ch->cmt->clk); + if (clk_prepare(ch->cmt->clk)) + dev_err(>cmt->pdev->dev, "ch%u: failed to prepare clk\n", + ch->index); + pm_genpd_syscore_poweron(>cmt->pdev->dev); } -- 2.17.2 (Apple Git-113)
[PATCH] base: fix a missing check of clk_prepare
clk_prepare() could fail, so let's check its status, and if it fails, issue an error message. Signed-off-by: Kangjie Lu --- drivers/base/power/clock_ops.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/base/power/clock_ops.c b/drivers/base/power/clock_ops.c index 5a42ae4078c2..cb6144fb24e2 100644 --- a/drivers/base/power/clock_ops.c +++ b/drivers/base/power/clock_ops.c @@ -65,7 +65,9 @@ static void pm_clk_acquire(struct device *dev, struct pm_clock_entry *ce) if (IS_ERR(ce->clk)) { ce->status = PCE_STATUS_ERROR; } else { - clk_prepare(ce->clk); + if (clk_prepare(ce->clk)) + dev_err(dev, "clk_prepare failed.\n"); + ce->status = PCE_STATUS_ACQUIRED; dev_dbg(dev, "Clock %pC con_id %s managed by runtime PM.\n", ce->clk, ce->con_id); -- 2.17.2 (Apple Git-113)
[PATCH] rtc: fix a missing check of clk_prepare
clk_prepare() could fail, so let's check its status and if it fails return its error code upstream. Signed-off-by: Kangjie Lu --- drivers/rtc/rtc-coh901331.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/rtc/rtc-coh901331.c b/drivers/rtc/rtc-coh901331.c index fc5cf5c44ae7..0b232c84f674 100644 --- a/drivers/rtc/rtc-coh901331.c +++ b/drivers/rtc/rtc-coh901331.c @@ -235,9 +235,13 @@ static int coh901331_suspend(struct device *dev) static int coh901331_resume(struct device *dev) { + int ret; struct coh901331_port *rtap = dev_get_drvdata(dev); - clk_prepare(rtap->clk); + ret = clk_prepare(rtap->clk); + if (ret) + return ret; + if (device_may_wakeup(dev)) { disable_irq_wake(rtap->irq); } else { -- 2.17.2 (Apple Git-113)
[PATCH v2] rtl8712: add a check for the status of register_netdev
register_netdev() may fail, so let's check its return value, and if it fails, issue an error message. Signed-off-by: Kangjie Lu --- drivers/staging/rtl8712/hal_init.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8712/hal_init.c b/drivers/staging/rtl8712/hal_init.c index 7cdd609cab6c..ca0858660a45 100644 --- a/drivers/staging/rtl8712/hal_init.c +++ b/drivers/staging/rtl8712/hal_init.c @@ -32,10 +32,10 @@ static void rtl871x_load_fw_cb(const struct firmware *firmware, void *context) { struct _adapter *padapter = context; + struct usb_device *udev = padapter->dvobjpriv.pusbdev; complete(>rtl8712_fw_ready); if (!firmware) { - struct usb_device *udev = padapter->dvobjpriv.pusbdev; struct usb_interface *pusb_intf = padapter->pusb_intf; dev_err(>dev, "r8712u: Firmware request failed\n"); @@ -45,7 +45,8 @@ static void rtl871x_load_fw_cb(const struct firmware *firmware, void *context) } padapter->fw = firmware; /* firmware available - start netdev */ - register_netdev(padapter->pnetdev); + if (register_netdev(padapter->pnetdev)) + dev_err(>dev, "r8712u: Registering netdev failed\n"); } static const char firmware_file[] = "rtlwifi/rtl8712u.bin"; -- 2.17.2 (Apple Git-113)
[PATCH -mmotm] efi: drop kmemleak_ignore() for page allocator
a0fc5578f1d (efi: Let kmemleak ignore false positives) is no longer needed due to efi_mem_reserve_persistent() uses __get_free_page() instead where kmemelak is not able to track regardless. Otherwise, kernel reported "kmemleak: Trying to color unknown object at 0x801060ef as Black" Signed-off-by: Qian Cai --- drivers/firmware/efi/efi.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index 7ac09dd8f268..4c46ff6f2242 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -31,7 +31,6 @@ #include #include #include -#include #include @@ -1027,8 +1026,6 @@ int __ref efi_mem_reserve_persistent(phys_addr_t addr, u64 size) if (!rsv) return -ENOMEM; - kmemleak_ignore(rsv); - rsv->size = EFI_MEMRESERVE_COUNT(PAGE_SIZE); atomic_set(>count, 1); rsv->entry[0].base = addr; -- 2.17.2 (Apple Git-113)
Re: [PATCH] rtl8712: add a check for the status of register_netdev
Hi Kangjie, Thank you for the patch! Yet something to improve: [auto build test ERROR on staging/staging-testing] [also build test ERROR on v4.20 next-20181224] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Kangjie-Lu/rtl8712-add-a-check-for-the-status-of-register_netdev/20181226-094828 config: xtensa-allmodconfig (attached as .config) compiler: xtensa-linux-gcc (GCC) 8.1.0 reproduce: wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree GCC_VERSION=8.1.0 make.cross ARCH=xtensa All errors (new ones prefixed by >>): In file included from include/linux/usb/ch9.h:36, from include/linux/usb.h:6, from drivers/staging/rtl8712/hal_init.c:19: drivers/staging/rtl8712/hal_init.c: In function 'rtl871x_load_fw_cb': >> drivers/staging/rtl8712/hal_init.c:49:12: error: 'udev' undeclared (first >> use in this function); did you mean 'cdev'? dev_err(>dev, "r8712u: Registering netdev failed\n"); ^~~~ include/linux/device.h:1453:11: note: in definition of macro 'dev_err' _dev_err(dev, dev_fmt(fmt), ##__VA_ARGS__) ^~~ drivers/staging/rtl8712/hal_init.c:49:12: note: each undeclared identifier is reported only once for each function it appears in dev_err(>dev, "r8712u: Registering netdev failed\n"); ^~~~ include/linux/device.h:1453:11: note: in definition of macro 'dev_err' _dev_err(dev, dev_fmt(fmt), ##__VA_ARGS__) ^~~ vim +49 drivers/staging/rtl8712/hal_init.c 18 > 19 #include 20 #include 21 #include 22 #include 23 #include 24 25 #include "osdep_service.h" 26 #include "drv_types.h" 27 #include "usb_osintf.h" 28 29 #define FWBUFF_ALIGN_SZ 512 30 #define MAX_DUMP_FWSZ 49152 /*default = 49152 (48k)*/ 31 32 static void rtl871x_load_fw_cb(const struct firmware *firmware, void *context) 33 { 34 struct _adapter *padapter = context; 35 36 complete(>rtl8712_fw_ready); 37 if (!firmware) { 38 struct usb_device *udev = padapter->dvobjpriv.pusbdev; 39 struct usb_interface *pusb_intf = padapter->pusb_intf; 40 41 dev_err(>dev, "r8712u: Firmware request failed\n"); 42 usb_put_dev(udev); 43 usb_set_intfdata(pusb_intf, NULL); 44 return; 45 } 46 padapter->fw = firmware; 47 /* firmware available - start netdev */ 48 if (register_netdev(padapter->pnetdev)) > 49 dev_err(>dev, "r8712u: Registering netdev failed\n"); 50 } 51 --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: application/gzip
[PATCH] sound: atom: fix a missing check of snd_pcm_lib_malloc_pages
snd_pcm_lib_malloc_pages() may fail, so let's check its status and return its error code upstream. Signed-off-by: Kangjie Lu --- sound/soc/intel/atom/sst-mfld-platform-pcm.c | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sound/soc/intel/atom/sst-mfld-platform-pcm.c b/sound/soc/intel/atom/sst-mfld-platform-pcm.c index afc559866095..91a2436ce952 100644 --- a/sound/soc/intel/atom/sst-mfld-platform-pcm.c +++ b/sound/soc/intel/atom/sst-mfld-platform-pcm.c @@ -399,7 +399,13 @@ static int sst_media_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params)); + int ret; + + ret = + snd_pcm_lib_malloc_pages(substream, + params_buffer_bytes(params)); + if (ret) + return ret; memset(substream->runtime->dma_area, 0, params_buffer_bytes(params)); return 0; } -- 2.17.2 (Apple Git-113)
Re: [PATCH] rtl8712: add a check for the status of register_netdev
Hi Kangjie, Thank you for the patch! Yet something to improve: [auto build test ERROR on staging/staging-testing] [also build test ERROR on v4.20 next-20181224] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Kangjie-Lu/rtl8712-add-a-check-for-the-status-of-register_netdev/20181226-094828 config: nds32-allmodconfig (attached as .config) compiler: nds32le-linux-gcc (GCC) 6.4.0 reproduce: wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree GCC_VERSION=6.4.0 make.cross ARCH=nds32 All errors (new ones prefixed by >>): In file included from include/linux/usb/ch9.h:36:0, from include/linux/usb.h:6, from drivers/staging//rtl8712/hal_init.c:19: drivers/staging//rtl8712/hal_init.c: In function 'rtl871x_load_fw_cb': >> drivers/staging//rtl8712/hal_init.c:49:12: error: 'udev' undeclared (first >> use in this function) dev_err(>dev, "r8712u: Registering netdev failed\n"); ^ include/linux/device.h:1453:11: note: in definition of macro 'dev_err' _dev_err(dev, dev_fmt(fmt), ##__VA_ARGS__) ^~~ drivers/staging//rtl8712/hal_init.c:49:12: note: each undeclared identifier is reported only once for each function it appears in dev_err(>dev, "r8712u: Registering netdev failed\n"); ^ include/linux/device.h:1453:11: note: in definition of macro 'dev_err' _dev_err(dev, dev_fmt(fmt), ##__VA_ARGS__) ^~~ vim +/udev +49 drivers/staging//rtl8712/hal_init.c 18 > 19 #include 20 #include 21 #include 22 #include 23 #include 24 25 #include "osdep_service.h" 26 #include "drv_types.h" 27 #include "usb_osintf.h" 28 29 #define FWBUFF_ALIGN_SZ 512 30 #define MAX_DUMP_FWSZ 49152 /*default = 49152 (48k)*/ 31 32 static void rtl871x_load_fw_cb(const struct firmware *firmware, void *context) 33 { 34 struct _adapter *padapter = context; 35 36 complete(>rtl8712_fw_ready); 37 if (!firmware) { 38 struct usb_device *udev = padapter->dvobjpriv.pusbdev; 39 struct usb_interface *pusb_intf = padapter->pusb_intf; 40 41 dev_err(>dev, "r8712u: Firmware request failed\n"); 42 usb_put_dev(udev); 43 usb_set_intfdata(pusb_intf, NULL); 44 return; 45 } 46 padapter->fw = firmware; 47 /* firmware available - start netdev */ 48 if (register_netdev(padapter->pnetdev)) > 49 dev_err(>dev, "r8712u: Registering netdev failed\n"); 50 } 51 --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: application/gzip
[PATCH] pci: dwc: add a check for resetting gpio
devm_gpio_request_one() could fail. The fix checks its status and issues an error if it fails. Signed-off-by: Kangjie Lu --- drivers/pci/controller/dwc/pci-exynos.c | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-exynos.c b/drivers/pci/controller/dwc/pci-exynos.c index cee5f2f590e2..e3a045e215d2 100644 --- a/drivers/pci/controller/dwc/pci-exynos.c +++ b/drivers/pci/controller/dwc/pci-exynos.c @@ -226,9 +226,12 @@ static void exynos_pcie_assert_reset(struct exynos_pcie *ep) struct dw_pcie *pci = ep->pci; struct device *dev = pci->dev; - if (ep->reset_gpio >= 0) - devm_gpio_request_one(dev, ep->reset_gpio, - GPIOF_OUT_INIT_HIGH, "RESET"); + if (ep->reset_gpio >= 0) { + if (devm_gpio_request_one(dev, ep->reset_gpio, + GPIOF_OUT_INIT_HIGH, "RESET")) + dev_err(dev, "Failed requesting reset gpio %d\n", + ep->reset_gpio); + } } static int exynos_pcie_establish_link(struct exynos_pcie *ep) -- 2.17.2 (Apple Git-113)
[PATCH] infiniband: add checks for the status of nla_put
The fix inserts multiple checks for nla_put, and issues warnings if it fails. Signed-off-by: Kangjie Lu --- drivers/infiniband/core/sa_query.c | 39 ++ 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c index be5ba5e15496..0e5d7a6dde36 100644 --- a/drivers/infiniband/core/sa_query.c +++ b/drivers/infiniband/core/sa_query.c @@ -775,28 +775,37 @@ static void ib_nl_set_path_rec_attrs(struct sk_buff *skb, /* Now build the attributes */ if (comp_mask & IB_SA_PATH_REC_SERVICE_ID) { val64 = be64_to_cpu(sa_rec->service_id); - nla_put(skb, RDMA_NLA_F_MANDATORY | LS_NLA_TYPE_SERVICE_ID, - sizeof(val64), ); + if (nla_put(skb, RDMA_NLA_F_MANDATORY | LS_NLA_TYPE_SERVICE_ID, + sizeof(val64), )) + pr_warn("nla_put failed\n"); + } + if (comp_mask & IB_SA_PATH_REC_DGID) { + if (nla_put(skb, RDMA_NLA_F_MANDATORY | LS_NLA_TYPE_DGID, + sizeof(sa_rec->dgid), _rec->dgid)) + pr_warn("nla_put failed\n"); + } + if (comp_mask & IB_SA_PATH_REC_SGID) { + if (nla_put(skb, RDMA_NLA_F_MANDATORY | LS_NLA_TYPE_SGID, + sizeof(sa_rec->sgid), _rec->sgid)) + pr_warn("nla_put failed\n"); + } + if (comp_mask & IB_SA_PATH_REC_TRAFFIC_CLASS) { + if (nla_put(skb, RDMA_NLA_F_MANDATORY | LS_NLA_TYPE_TCLASS, + sizeof(sa_rec->traffic_class), _rec->traffic_class)) + pr_warn("nla_put failed\n"); } - if (comp_mask & IB_SA_PATH_REC_DGID) - nla_put(skb, RDMA_NLA_F_MANDATORY | LS_NLA_TYPE_DGID, - sizeof(sa_rec->dgid), _rec->dgid); - if (comp_mask & IB_SA_PATH_REC_SGID) - nla_put(skb, RDMA_NLA_F_MANDATORY | LS_NLA_TYPE_SGID, - sizeof(sa_rec->sgid), _rec->sgid); - if (comp_mask & IB_SA_PATH_REC_TRAFFIC_CLASS) - nla_put(skb, RDMA_NLA_F_MANDATORY | LS_NLA_TYPE_TCLASS, - sizeof(sa_rec->traffic_class), _rec->traffic_class); if (comp_mask & IB_SA_PATH_REC_PKEY) { val16 = be16_to_cpu(sa_rec->pkey); - nla_put(skb, RDMA_NLA_F_MANDATORY | LS_NLA_TYPE_PKEY, - sizeof(val16), ); + if (nla_put(skb, RDMA_NLA_F_MANDATORY | LS_NLA_TYPE_PKEY, + sizeof(val16), )) + pr_warn("nla_put failed\n"); } if (comp_mask & IB_SA_PATH_REC_QOS_CLASS) { val16 = be16_to_cpu(sa_rec->qos_class); - nla_put(skb, RDMA_NLA_F_MANDATORY | LS_NLA_TYPE_QOS_CLASS, - sizeof(val16), ); + if (nla_put(skb, RDMA_NLA_F_MANDATORY | LS_NLA_TYPE_QOS_CLASS, + sizeof(val16), )) + pr_warn("nla_put failed\n"); } } -- 2.17.2 (Apple Git-113)
[PATCH] infiniband: fix a missing check of nla_put
nla_put() may fail. The fix adds a check for its return value, and returns -EMSGSIZE if it fails. Signed-off-by: Kangjie Lu --- drivers/infiniband/core/addr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c index 0dce94e3c495..32d033ebaa5b 100644 --- a/drivers/infiniband/core/addr.c +++ b/drivers/infiniband/core/addr.c @@ -178,7 +178,8 @@ static int ib_nl_ip_send_msg(struct rdma_dev_addr *dev_addr, /* Construct the family header first */ header = skb_put(skb, NLMSG_ALIGN(sizeof(*header))); header->ifindex = dev_addr->bound_dev_if; - nla_put(skb, attrtype, size, daddr); + if (nla_put(skb, attrtype, size, daddr)) + return -EMSGSIZE; /* Repair the nlmsg header length */ nlmsg_end(skb, nlh); -- 2.17.2 (Apple Git-113)
[PATCH -mmotm] arm64: skip kmemleak for KASAN again
Due to 871ac3d540f (kasan: initialize shadow to 0xff for tag-based mode), kmemleak is broken again with KASAN. It needs a similar fix from e55058c2983 (mm/memblock.c: skip kmemleak for kasan_init()). Signed-off-by: Qian Cai --- arch/arm64/mm/kasan_init.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/arm64/mm/kasan_init.c b/arch/arm64/mm/kasan_init.c index 48d8f2fa0d14..4b55b15707a3 100644 --- a/arch/arm64/mm/kasan_init.c +++ b/arch/arm64/mm/kasan_init.c @@ -47,8 +47,7 @@ static phys_addr_t __init kasan_alloc_raw_page(int node) { void *p = memblock_alloc_try_nid_raw(PAGE_SIZE, PAGE_SIZE, __pa(MAX_DMA_ADDRESS), - MEMBLOCK_ALLOC_ACCESSIBLE, - node); + MEMBLOCK_ALLOC_KASAN, node); return __pa(p); } -- 2.17.2 (Apple Git-113)
[PATCH] usb: chipidea: add a check for the availability of next child
of_get_next_available_child returns NULL when no child nodes are found. The fix checks its return value instead of assuming a child is found. Signed-off-by: Kangjie Lu --- drivers/usb/chipidea/ci_hdrc_msm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usb/chipidea/ci_hdrc_msm.c b/drivers/usb/chipidea/ci_hdrc_msm.c index 880009987460..7dc987b4036a 100644 --- a/drivers/usb/chipidea/ci_hdrc_msm.c +++ b/drivers/usb/chipidea/ci_hdrc_msm.c @@ -250,6 +250,8 @@ static int ci_hdrc_msm_probe(struct platform_device *pdev) ulpi_node = of_get_child_by_name(pdev->dev.of_node, "ulpi"); if (ulpi_node) { phy_node = of_get_next_available_child(ulpi_node, NULL); + if (!phy_node) + dev_err(>dev, "no child nodes found\n"); ci->hsic = of_device_is_compatible(phy_node, "qcom,usb-hsic-phy"); of_node_put(phy_node); } -- 2.17.2 (Apple Git-113)
Re: [PATCHv2] x86/kdump: bugfix, make the behavior of crashkernel=X consistent with kaslr
On 12/14/18 at 12:07pm, Pingfan Liu wrote: > Customer reported a bug on a high end server with many pcie devices, where > kernel bootup with crashkernel=384M, and kaslr is enabled. Even > though we still see much memory under 896 MB, the finding still failed > intermittently. Because currently we can only find region under 896 MB, > if w/0 ',high' specified. Then KASLR breaks 896 MB into several parts > randomly, and crashkernel reservation need be aligned to 128 MB, that's > why failure is found. It raises confusion to the end user that sometimes > crashkernel=X works while sometimes fails. > If want to make it succeed, customer can change kernel option to > "crashkernel=384M, high". Just this give "crashkernel=xx@yy" a very > limited space to behave even though its grammer looks more generic. > And we can't answer questions raised from customer that confidently: > 1) why it doesn't succeed to reserve 896 MB; > 2) what's wrong with memory region under 4G; > 3) why I have to add ',high', I only require 384 MB, not 3840 MB. > > This patch simplifies the method suggested in the mail [1]. It just goes > bottom-up to find a candidate region for crashkernel. The bottom-up may be > better compatible with the old reservation style, i.e. still want to get > memory region from 896 MB firstly, then [896 MB, 4G], finally above 4G. > > There is one trivial thing about the compatibility with old kexec-tools: > if the reserved region is above 896M, then old tool will fail to load > bzImage. But without this patch, the old tool also fail since there is no > memory below 896M can be reserved for crashkernel. > > [1]: http://lists.infradead.org/pipermail/kexec/2017-October/019571.html > Signed-off-by: Pingfan Liu > Cc: Dave Young > Cc: Andrew Morton > Cc: Baoquan He > Cc: ying...@kernel.org, > Cc: vgo...@redhat.com > Cc: ke...@lists.infradead.org > > --- > v1->v2: > improve commit log > arch/x86/kernel/setup.c | 9 ++--- > 1 file changed, 6 insertions(+), 3 deletions(-) > > diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c > index d494b9b..60f12c4 100644 > --- a/arch/x86/kernel/setup.c > +++ b/arch/x86/kernel/setup.c > @@ -541,15 +541,18 @@ static void __init reserve_crashkernel(void) > > /* 0 means: find the address automatically */ > if (crash_base <= 0) { > + if (!memblock_bottom_up()) > + memblock_set_bottom_up(true); Looking at the memblock_find_in_range_node code, it is allocating bottom up in case bottom_up is true, but it will try to allocate above kernel_end: bottom_up_start = max(start, kernel_end); If kernel lives very high eg. KASLR case, then this bottom up way does not help. So probably previous old version to try 896M first then 4G then maxmem is better. > /* >* Set CRASH_ADDR_LOW_MAX upper bound for crash memory, >* as old kexec-tools loads bzImage below that, unless >* "crashkernel=size[KMG],high" is specified. >*/ > crash_base = memblock_find_in_range(CRASH_ALIGN, > - high ? CRASH_ADDR_HIGH_MAX > - : CRASH_ADDR_LOW_MAX, > - crash_size, CRASH_ALIGN); > + (max_pfn * PAGE_SIZE), crash_size, CRASH_ALIGN); > + if (!memblock_bottom_up()) > + memblock_set_bottom_up(false); > + > if (!crash_base) { > pr_info("crashkernel reservation failed - No suitable > area found.\n"); > return; > -- > 2.7.4 >
[PATCH] keyboard: (samsung) fix a missing check of return value
of_device_is_compatible() returns false if the device is incompatible. The fix adds a check for its return value; Signed-off-by: Kangjie Lu --- drivers/input/keyboard/samsung-keypad.c | 10 +++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/input/keyboard/samsung-keypad.c b/drivers/input/keyboard/samsung-keypad.c index 1fe1aa2adf85..5ba940f3f76e 100644 --- a/drivers/input/keyboard/samsung-keypad.c +++ b/drivers/input/keyboard/samsung-keypad.c @@ -387,9 +387,13 @@ static int samsung_keypad_probe(struct platform_device *pdev) keypad->stopped = true; init_waitqueue_head(>wait); - if (pdev->dev.of_node) - keypad->type = of_device_is_compatible(pdev->dev.of_node, - "samsung,s5pv210-keypad"); + if (pdev->dev.of_node) { + error = of_device_is_compatible(pdev->dev.of_node, + "samsung,s5pv210-keypad"); + if (!error) + return -EINVAL; + keypad->type = error; + } else keypad->type = platform_get_device_id(pdev)->driver_data; -- 2.17.2 (Apple Git-113)
Re: [PATCH 01/18] drm/mediatek: update dt-bindings for mt8183
Hi, Yongqiang: I would like you to add 'dt-bindings' in title. On Mon, 2018-12-24 at 16:08 +0800, Yongqiang Niu wrote: > Update device tree binding documention for the display subsystem for > Mediatek MT8183 SOCs > > Signed-off-by: Yongqiang Niu > --- > .../devicetree/bindings/display/mediatek/mediatek,disp.txt| 11 > ++- > 1 file changed, 10 insertions(+), 1 deletion(-) > > diff --git > a/Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt > b/Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt > index 8469de5..1c66f39 100644 > --- a/Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt > +++ b/Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt > @@ -28,9 +28,12 @@ > Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.txt. > Required properties (all function blocks): > - compatible: "mediatek,-disp-", one of > "mediatek,-disp-ovl" - overlay (4 layers, blending, csc) > + "mediatek,-disp-ovl-2l" - overlay (2 layers, blending, csc) Other '-' is aliened, so do this one. > "mediatek,-disp-rdma" - read DMA / line buffer > "mediatek,-disp-wdma" - write DMA > + "mediatek,-disp-ccorr" - color correction > "mediatek,-disp-color" - color processor > + "mediatek,-disp-dither" - dither Ditto. > "mediatek,-disp-aal" - adaptive ambient light controller > "mediatek,-disp-gamma" - gamma correction > "mediatek,-disp-merge" - merge streams from two RDMA sources > @@ -40,7 +43,7 @@ Required properties (all function blocks): > "mediatek,-dpi"- DPI controller, see mediatek,dpi.txt > "mediatek,-disp-mutex" - display mutex > "mediatek,-disp-od"- overdrive > - the supported chips are mt2701, mt2712 and mt8173. > + the supported chips are mt2701, mt2712, mt8173 and mt8183. > - reg: Physical base address and length of the function block register space > - interrupts: The interrupt signal from the function block (required, except > for >merge and split function blocks). > @@ -71,6 +74,12 @@ mmsys: clock-controller@1400 { > #clock-cells = <1>; > }; > > +display_components: dispsys@1400 { > + compatible = "mediatek,mt8183-display"; "mediatek,mt8183-display" is undefined. I think this should be "mediatek,mt8183-mmsys" and you have met the same problem in [1]. You may depend on that series to develop your patches. [1] http://lists.infradead.org/pipermail/linux-mediatek/2018-November/015860.html Regards, CK > + reg = <0 0x1400 0 0x1000>; > + power-domains = < MT8183_POWER_DOMAIN_DISP>; > +}; > + > ovl0: ovl@1400c000 { > compatible = "mediatek,mt8173-disp-ovl"; > reg = <0 0x1400c000 0 0x1000>;
Re: [GIT PULL] arm64: updates for 4.21
The pull request you sent on Fri, 14 Dec 2018 16:14:13 +: > git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git > tags/arm64-upstream has been merged into torvalds/linux.git: https://git.kernel.org/torvalds/c/5694cecdb092656a822287a6691aa7ce668c8160 Thank you! -- Deet-doot-dot, I am a bot. https://korg.wiki.kernel.org/userdoc/prtracker
Re: [GIT PULL] arm64: updates for 4.21
On Fri, Dec 14, 2018 at 8:14 AM Will Deacon wrote: > > * The A76 workaround for erratum #1286807 landed in mainline after -rc3 > ("ce8c80c536da"), so there's some shuffling needed to accomodate that > in conjunction with the workaround for erratum #1165522 here. I've > included my resolution at the end of this mail. Yours dropped a "If unsure, say Y" that should have been in both config options in the Kconfig file. Mine? I don't know, since I don't do cross-compiles, but it looked sane enough. Somebody please holler if there are problems. Linus
Re: [PATCHv2] x86/kdump: bugfix, make the behavior of crashkernel=X consistent with kaslr
On 12/14/18 at 12:07pm, Pingfan Liu wrote: > Customer reported a bug on a high end server with many pcie devices, where > kernel bootup with crashkernel=384M, and kaslr is enabled. Even > though we still see much memory under 896 MB, the finding still failed > intermittently. Because currently we can only find region under 896 MB, > if w/0 ',high' specified. Then KASLR breaks 896 MB into several parts > randomly, and crashkernel reservation need be aligned to 128 MB, that's > why failure is found. It raises confusion to the end user that sometimes > crashkernel=X works while sometimes fails. > If want to make it succeed, customer can change kernel option to > "crashkernel=384M, high". Just this give "crashkernel=xx@yy" a very > limited space to behave even though its grammer looks more generic. > And we can't answer questions raised from customer that confidently: > 1) why it doesn't succeed to reserve 896 MB; > 2) what's wrong with memory region under 4G; > 3) why I have to add ',high', I only require 384 MB, not 3840 MB. > > This patch simplifies the method suggested in the mail [1]. It just goes > bottom-up to find a candidate region for crashkernel. The bottom-up may be > better compatible with the old reservation style, i.e. still want to get > memory region from 896 MB firstly, then [896 MB, 4G], finally above 4G. > > There is one trivial thing about the compatibility with old kexec-tools: > if the reserved region is above 896M, then old tool will fail to load > bzImage. But without this patch, the old tool also fail since there is no > memory below 896M can be reserved for crashkernel. > > [1]: http://lists.infradead.org/pipermail/kexec/2017-October/019571.html > Signed-off-by: Pingfan Liu > Cc: Dave Young > Cc: Andrew Morton > Cc: Baoquan He > Cc: ying...@kernel.org, > Cc: vgo...@redhat.com > Cc: ke...@lists.infradead.org > > --- > v1->v2: > improve commit log > arch/x86/kernel/setup.c | 9 ++--- > 1 file changed, 6 insertions(+), 3 deletions(-) > > diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c > index d494b9b..60f12c4 100644 > --- a/arch/x86/kernel/setup.c > +++ b/arch/x86/kernel/setup.c > @@ -541,15 +541,18 @@ static void __init reserve_crashkernel(void) > > /* 0 means: find the address automatically */ > if (crash_base <= 0) { > + if (!memblock_bottom_up()) > + memblock_set_bottom_up(true); > /* >* Set CRASH_ADDR_LOW_MAX upper bound for crash memory, >* as old kexec-tools loads bzImage below that, unless >* "crashkernel=size[KMG],high" is specified. >*/ > crash_base = memblock_find_in_range(CRASH_ALIGN, > - high ? CRASH_ADDR_HIGH_MAX > - : CRASH_ADDR_LOW_MAX, > - crash_size, CRASH_ALIGN); > + (max_pfn * PAGE_SIZE), crash_size, CRASH_ALIGN); > + if (!memblock_bottom_up()) > + memblock_set_bottom_up(false); The previous memblock_set_bottom_up(true) set it as true, so "!memblock_bottom_up()" is impossible, not sure what is the point of this condition check. Do you want to restore the original memblock direction? If so a variable to save the old direction is needed. But is this really necessary? Do you know any side effects of setting the bottom up as true? > + > if (!crash_base) { > pr_info("crashkernel reservation failed - No suitable > area found.\n"); > return; > -- > 2.7.4 > > > ___ > kexec mailing list > ke...@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/kexec Thanks Dave
[PATCH] sound: sb: fix a missing check of snd_ctl_add
snd_ctl_add() could fail, so let's check its return value and return its error code upstream upon failure. Signed-off-by: Kangjie Lu --- sound/isa/sb/sb16_main.c | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sound/isa/sb/sb16_main.c b/sound/isa/sb/sb16_main.c index 37e6ce7b0b13..c9b25dc1f78e 100644 --- a/sound/isa/sb/sb16_main.c +++ b/sound/isa/sb/sb16_main.c @@ -879,8 +879,14 @@ int snd_sb16dsp_pcm(struct snd_sb *chip, int device) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, _sb16_playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, _sb16_capture_ops); - if (chip->dma16 >= 0 && chip->dma8 != chip->dma16) - snd_ctl_add(card, snd_ctl_new1(_sb16_dma_control, chip)); + if (chip->dma16 >= 0 && chip->dma8 != chip->dma16) { + err = + snd_ctl_add(card, + snd_ctl_new1(_sb16_dma_control, + chip)); + if (err < 0) + return err; + } else pcm->info_flags = SNDRV_PCM_INFO_HALF_DUPLEX; -- 2.17.2 (Apple Git-113)
[PATCH] gus: add a check of the status of snd_ctl_add
snd_ctl_add() could fail, so let's check its status and issue an error message if it indeed fails. Signed-off-by: Kangjie Lu --- sound/isa/gus/gus_main.c | 13 +++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/sound/isa/gus/gus_main.c b/sound/isa/gus/gus_main.c index 3b8a0c880db5..33c8b66d5c8a 100644 --- a/sound/isa/gus/gus_main.c +++ b/sound/isa/gus/gus_main.c @@ -92,8 +92,17 @@ static const struct snd_kcontrol_new snd_gus_joystick_control = { static void snd_gus_init_control(struct snd_gus_card *gus) { - if (!gus->ace_flag) - snd_ctl_add(gus->card, snd_ctl_new1(_gus_joystick_control, gus)); + int ret; + + if (!gus->ace_flag) { + ret = + snd_ctl_add(gus->card, + snd_ctl_new1(_gus_joystick_control, + gus)); + if (ret) + snd_printk(KERN_ERR "gus: snd_ctl_add failed: %d\n", + ret); + } } /* -- 2.17.2 (Apple Git-113)
Re: [PATCH 07/14] clock: milbeaut: Add Milbeaut M10V clock control
Hi On 2018/11/30 17:31, Stephen Boyd wrote: + init.num_parents = parents; + init.parent_names = parent_names; + + mcm->cname = clk_name; + mcm->parent = 0; + mcm->hw.init = + + clk = clk_register(NULL, >hw); + if (IS_ERR(clk)) + goto err_clk; + + of_clk_add_provider(node, of_clk_src_simple_get, clk); + return; + +err_clk: + kfree(mcm); +err_mcm: + kfree(parent_names); +} +CLK_OF_DECLARE(m10v_clk_mux, "socionext,milbeaut-m10v-clk-mux", + m10v_clk_mux_setup); Any chance you can use a platform driver? Excuse me to re-ask you. Why do you recommend to use a platform driver? Is that current fad? Thanks Sugaya Taichi
[PATCH] rtl8712: add a check for the status of register_netdev
register_netdev() may fail, so let's check its return value, and if it fails, issue an error message. Signed-off-by: Kangjie Lu --- drivers/staging/rtl8712/hal_init.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/rtl8712/hal_init.c b/drivers/staging/rtl8712/hal_init.c index 7cdd609cab6c..7e2f8e0185d5 100644 --- a/drivers/staging/rtl8712/hal_init.c +++ b/drivers/staging/rtl8712/hal_init.c @@ -45,7 +45,8 @@ static void rtl871x_load_fw_cb(const struct firmware *firmware, void *context) } padapter->fw = firmware; /* firmware available - start netdev */ - register_netdev(padapter->pnetdev); + if (register_netdev(padapter->pnetdev)) + dev_err(>dev, "r8712u: Registering netdev failed\n"); } static const char firmware_file[] = "rtlwifi/rtl8712u.bin"; -- 2.17.2 (Apple Git-113)
[PATCH] tty: pass return value of spi_register_driver
spi_register_driver() may fail, so let's pass its return value upstream. Signed-off-by: Kangjie Lu --- drivers/tty/serial/max310x.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c index 3db48fcd6068..55e73646fcd2 100644 --- a/drivers/tty/serial/max310x.c +++ b/drivers/tty/serial/max310x.c @@ -1470,10 +1470,10 @@ static int __init max310x_uart_init(void) return ret; #ifdef CONFIG_SPI_MASTER - spi_register_driver(_spi_driver); + ret = spi_register_driver(_spi_driver); #endif - return 0; + return ret; } module_init(max310x_uart_init); -- 2.17.2 (Apple Git-113)
[PATCH] net: brcm80211: add a check for the status of usb_register
usb_register() may fail, so let's check its status and issue an error message if it fails. Signed-off-by: Kangjie Lu --- drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c index a4308c6e72d7..76cfaf6999c8 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c @@ -1550,6 +1550,10 @@ void brcmf_usb_exit(void) void brcmf_usb_register(void) { + int ret; + brcmf_dbg(USB, "Enter\n"); - usb_register(_usbdrvr); + ret = usb_register(_usbdrvr); + if (ret) + brcmf_err("usb_register failed %d\n", ret); } -- 2.17.2 (Apple Git-113)
[PATCH] slimbus: add a check for the status of platform_driver_register
platform_driver_register() may fail. The fix checks its status and issues an error message if it fails. Signed-off-by: Kangjie Lu --- drivers/slimbus/qcom-ngd-ctrl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/slimbus/qcom-ngd-ctrl.c b/drivers/slimbus/qcom-ngd-ctrl.c index 1382a8df6c75..5b923c8dedb2 100644 --- a/drivers/slimbus/qcom-ngd-ctrl.c +++ b/drivers/slimbus/qcom-ngd-ctrl.c @@ -1443,7 +1443,9 @@ static int qcom_slim_ngd_ctrl_probe(struct platform_device *pdev) init_completion(>reconf); init_completion(>qmi.qmi_comp); - platform_driver_register(_slim_ngd_driver); + ret = platform_driver_register(_slim_ngd_driver); + if (ret) + dev_err(>dev, "registering driver failed\n"); return of_qcom_slim_ngd_register(dev, ctrl); } -- 2.17.2 (Apple Git-113)