Re: [PATCH] clk: ti: Fix FAPLL udelay in clk_enable with clk_prepare
On Tue, Sep 22, 2015 at 02:23:05PM -0700, Tony Lindgren wrote: > As recently pointed out (again) by Thomas and Russell, we must not > wait in in clk_enable. The wait for PLL to lock needs to happen > in clk_prepare instead. > > It seems this is a common copy paste error with the PLL drivers, > and similar fixes should be applied to other PLL drivers after > testing. > > Cc: Brian Hutchinson> Cc: Felipe Balbi > Cc: Grygorii Strashko > Cc: Nishanth Menon > Cc: Russell King - ARM Linux As this moves things in the right direction (and only based on that): Acked-by: Russell King > Cc: Thomas Gleixner > Cc: Sekhar Nori > Signed-off-by: Tony Lindgren > --- > drivers/clk/ti/fapll.c | 18 +- > 1 file changed, 9 insertions(+), 9 deletions(-) > > diff --git a/drivers/clk/ti/fapll.c b/drivers/clk/ti/fapll.c > index f4b2e98..e1db74a 100644 > --- a/drivers/clk/ti/fapll.c > +++ b/drivers/clk/ti/fapll.c > @@ -37,7 +37,7 @@ > #define FAPLL_PWD_OFFSET 4 > > #define MAX_FAPLL_OUTPUTS7 > -#define FAPLL_MAX_RETRIES1000 > +#define FAPLL_MAX_RETRIES5 > > #define to_fapll(_hw)container_of(_hw, struct fapll_data, hw) > #define to_synth(_hw)container_of(_hw, struct fapll_synth, > hw) > @@ -126,7 +126,7 @@ static int ti_fapll_wait_lock(struct fapll_data *fd) > if (retries-- <= 0) > break; > > - udelay(1); > + usleep_range(200, 300); > } > > pr_err("%s failed to lock\n", fd->name); > @@ -134,7 +134,7 @@ static int ti_fapll_wait_lock(struct fapll_data *fd) > return -ETIMEDOUT; > } > > -static int ti_fapll_enable(struct clk_hw *hw) > +static int ti_fapll_prepare(struct clk_hw *hw) > { > struct fapll_data *fd = to_fapll(hw); > u32 v = readl_relaxed(fd->base); > @@ -146,7 +146,7 @@ static int ti_fapll_enable(struct clk_hw *hw) > return 0; > } > > -static void ti_fapll_disable(struct clk_hw *hw) > +static void ti_fapll_unprepare(struct clk_hw *hw) > { > struct fapll_data *fd = to_fapll(hw); > u32 v = readl_relaxed(fd->base); > @@ -155,7 +155,7 @@ static void ti_fapll_disable(struct clk_hw *hw) > writel_relaxed(v, fd->base); > } > > -static int ti_fapll_is_enabled(struct clk_hw *hw) > +static int ti_fapll_is_prepared(struct clk_hw *hw) > { > struct fapll_data *fd = to_fapll(hw); > u32 v = readl_relaxed(fd->base); > @@ -261,7 +261,7 @@ static int ti_fapll_set_rate(struct clk_hw *hw, unsigned > long rate, > v |= pre_div_p << FAPLL_MAIN_DIV_P_SHIFT; > v |= mult_n << FAPLL_MAIN_MULT_N_SHIFT; > writel_relaxed(v, fd->base); > - if (ti_fapll_is_enabled(hw)) > + if (ti_fapll_is_prepared(hw)) > ti_fapll_wait_lock(fd); > ti_fapll_clear_bypass(fd); > > @@ -269,9 +269,9 @@ static int ti_fapll_set_rate(struct clk_hw *hw, unsigned > long rate, > } > > static struct clk_ops ti_fapll_ops = { > - .enable = ti_fapll_enable, > - .disable = ti_fapll_disable, > - .is_enabled = ti_fapll_is_enabled, > + .prepare = ti_fapll_prepare, > + .unprepare = ti_fapll_unprepare, > + .is_prepared = ti_fapll_is_prepared, > .recalc_rate = ti_fapll_recalc_rate, > .get_parent = ti_fapll_get_parent, > .round_rate = ti_fapll_round_rate, > -- > 2.1.4 > -- FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up according to speedtest.net. -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] clk: ti: Fix FAPLL udelay in clk_enable with clk_prepare
As recently pointed out (again) by Thomas and Russell, we must not wait in in clk_enable. The wait for PLL to lock needs to happen in clk_prepare instead. It seems this is a common copy paste error with the PLL drivers, and similar fixes should be applied to other PLL drivers after testing. Cc: Brian HutchinsonCc: Felipe Balbi Cc: Grygorii Strashko Cc: Nishanth Menon Cc: Russell King - ARM Linux Cc: Thomas Gleixner Cc: Sekhar Nori Signed-off-by: Tony Lindgren --- drivers/clk/ti/fapll.c | 18 +- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/clk/ti/fapll.c b/drivers/clk/ti/fapll.c index f4b2e98..e1db74a 100644 --- a/drivers/clk/ti/fapll.c +++ b/drivers/clk/ti/fapll.c @@ -37,7 +37,7 @@ #define FAPLL_PWD_OFFSET 4 #define MAX_FAPLL_OUTPUTS 7 -#define FAPLL_MAX_RETRIES 1000 +#define FAPLL_MAX_RETRIES 5 #define to_fapll(_hw) container_of(_hw, struct fapll_data, hw) #define to_synth(_hw) container_of(_hw, struct fapll_synth, hw) @@ -126,7 +126,7 @@ static int ti_fapll_wait_lock(struct fapll_data *fd) if (retries-- <= 0) break; - udelay(1); + usleep_range(200, 300); } pr_err("%s failed to lock\n", fd->name); @@ -134,7 +134,7 @@ static int ti_fapll_wait_lock(struct fapll_data *fd) return -ETIMEDOUT; } -static int ti_fapll_enable(struct clk_hw *hw) +static int ti_fapll_prepare(struct clk_hw *hw) { struct fapll_data *fd = to_fapll(hw); u32 v = readl_relaxed(fd->base); @@ -146,7 +146,7 @@ static int ti_fapll_enable(struct clk_hw *hw) return 0; } -static void ti_fapll_disable(struct clk_hw *hw) +static void ti_fapll_unprepare(struct clk_hw *hw) { struct fapll_data *fd = to_fapll(hw); u32 v = readl_relaxed(fd->base); @@ -155,7 +155,7 @@ static void ti_fapll_disable(struct clk_hw *hw) writel_relaxed(v, fd->base); } -static int ti_fapll_is_enabled(struct clk_hw *hw) +static int ti_fapll_is_prepared(struct clk_hw *hw) { struct fapll_data *fd = to_fapll(hw); u32 v = readl_relaxed(fd->base); @@ -261,7 +261,7 @@ static int ti_fapll_set_rate(struct clk_hw *hw, unsigned long rate, v |= pre_div_p << FAPLL_MAIN_DIV_P_SHIFT; v |= mult_n << FAPLL_MAIN_MULT_N_SHIFT; writel_relaxed(v, fd->base); - if (ti_fapll_is_enabled(hw)) + if (ti_fapll_is_prepared(hw)) ti_fapll_wait_lock(fd); ti_fapll_clear_bypass(fd); @@ -269,9 +269,9 @@ static int ti_fapll_set_rate(struct clk_hw *hw, unsigned long rate, } static struct clk_ops ti_fapll_ops = { - .enable = ti_fapll_enable, - .disable = ti_fapll_disable, - .is_enabled = ti_fapll_is_enabled, + .prepare = ti_fapll_prepare, + .unprepare = ti_fapll_unprepare, + .is_prepared = ti_fapll_is_prepared, .recalc_rate = ti_fapll_recalc_rate, .get_parent = ti_fapll_get_parent, .round_rate = ti_fapll_round_rate, -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 1/3] mailbox/omap: Add ti,mbox-send-noirq quirk to fix AM33xx CPU Idle
The mailbox framework controls the transmission queue and requires either its controller implementations or clients to run the state machine for the Tx queue. The OMAP mailbox controller uses a Tx-ready interrupt as the equivalent of a Tx-done interrupt to run this Tx queue state-machine. The WkupM3 processor on AM33xx and AM43xx SoCs is used to offload certain PM tasks, like doing the necessary operations for Device PM suspend/resume or for entering lower c-states during cpuidle. The CPUIdle on AM33xx requires the messages to be sent without having to trigger the Tx-ready interrupts, as the interrupt would immediately terminate the CPUIdle operation. Support for this has been added by introducing a DT quirk, "ti,mbox-send-noirq" and using it to modify the normal OMAP mailbox controller behavior on the sub-mailboxes used to communicate with the WkupM3 remote processor. This also requires the wkup_m3_ipc driver to adjust its mailbox usage logic to run the Tx state machine. NOTE: - AM43xx does not communicate with WkupM3 for CPU Idle, so is not affected by this behavior. But, it uses the same IPC driver for PM suspend/resume functionality, so requires the quirk as well, because of changes to the common wkup_m3_ipc driver. Signed-off-by: Dave Gerlach[s-a...@ti.com: revise logic and update comments/patch description] Signed-off-by: Suman Anna --- v2->v3: Unchanged. .../devicetree/bindings/mailbox/omap-mailbox.txt | 8 drivers/mailbox/omap-mailbox.c | 49 -- 2 files changed, 53 insertions(+), 4 deletions(-) diff --git a/Documentation/devicetree/bindings/mailbox/omap-mailbox.txt b/Documentation/devicetree/bindings/mailbox/omap-mailbox.txt index d1a0433..9b40c49 100644 --- a/Documentation/devicetree/bindings/mailbox/omap-mailbox.txt +++ b/Documentation/devicetree/bindings/mailbox/omap-mailbox.txt @@ -75,6 +75,14 @@ data that represent the following: Cell #3 (usr_id) - mailbox user id for identifying the interrupt line associated with generating a tx/rx fifo interrupt. +Optional Properties: + +- ti,mbox-send-noirq: Quirk flag to allow the client user of this sub-mailbox +to send messages without triggering a Tx ready interrupt, +and to control the Tx ticker. Should be used only on +sub-mailboxes used to communicate with WkupM3 remote +processor on AM33xx/AM43xx SoCs. + Mailbox Users: == A device needing to communicate with a target processor device should specify diff --git a/drivers/mailbox/omap-mailbox.c b/drivers/mailbox/omap-mailbox.c index a3dbfd9..b7f636f 100644 --- a/drivers/mailbox/omap-mailbox.c +++ b/drivers/mailbox/omap-mailbox.c @@ -38,6 +38,8 @@ #include #include +#include "mailbox.h" + #define MAILBOX_REVISION 0x000 #define MAILBOX_MESSAGE(m) (0x040 + 4 * (m)) #define MAILBOX_FIFOSTATUS(m) (0x080 + 4 * (m)) @@ -106,6 +108,7 @@ struct omap_mbox_fifo_info { int rx_irq; const char *name; + bool send_no_irq; }; struct omap_mbox { @@ -119,6 +122,7 @@ struct omap_mbox { u32 ctx[OMAP4_MBOX_NR_REGS]; u32 intr_type; struct mbox_chan*chan; + boolsend_no_irq; }; /* global variables for the mailbox devices */ @@ -418,6 +422,9 @@ static int omap_mbox_startup(struct omap_mbox *mbox) goto fail_request_irq; } + if (mbox->send_no_irq) + mbox->chan->txdone_method = TXDONE_BY_ACK; + _omap_mbox_enable_irq(mbox, IRQ_RX); return 0; @@ -586,13 +593,27 @@ static void omap_mbox_chan_shutdown(struct mbox_chan *chan) mutex_unlock(>cfg_lock); } -static int omap_mbox_chan_send_data(struct mbox_chan *chan, void *data) +static int omap_mbox_chan_send_noirq(struct omap_mbox *mbox, void *data) { - struct omap_mbox *mbox = mbox_chan_to_omap_mbox(chan); int ret = -EBUSY; - if (!mbox) - return -EINVAL; + if (!mbox_fifo_full(mbox)) { + _omap_mbox_enable_irq(mbox, IRQ_RX); + mbox_fifo_write(mbox, (mbox_msg_t)data); + ret = 0; + _omap_mbox_disable_irq(mbox, IRQ_RX); + + /* we must read and ack the interrupt directly from here */ + mbox_fifo_read(mbox); + ack_mbox_irq(mbox, IRQ_RX); + } + + return ret; +} + +static int omap_mbox_chan_send(struct omap_mbox *mbox, void *data) +{ + int ret = -EBUSY; if (!mbox_fifo_full(mbox)) { mbox_fifo_write(mbox, (mbox_msg_t)data); @@ -604,6 +625,22 @@ static int omap_mbox_chan_send_data(struct mbox_chan *chan, void *data) return ret; } +static int omap_mbox_chan_send_data(struct mbox_chan *chan, void
[PATCH v3 3/3] soc: ti: Add wkup_m3_ipc driver
Introduce a wkup_m3_ipc driver to handle communication between the MPU and Cortex M3 wkup_m3 present on am335x. This driver is responsible for actually booting the wkup_m3_rproc and also handling all IPC which is done using the IPC registers in the control module, a mailbox, and a separate interrupt back from the wkup_m3. A small API is exposed for executing specific power commands, which include configuring for low power mode, request a transition to a low power mode, and status info on a previous transition. Signed-off-by: Dave Gerlach--- v2->v3: - Added wkup_m3_ipc_ops to hold pointers to functions provided, don't export anymore - Add wkup_m3_ipc_get and wkup_m3_ipc_put to return handle to wkup_m3_ipc and ops struct - Add MODULE_DEVICE_TABLE - General probe function cleanup drivers/soc/ti/Kconfig | 10 + drivers/soc/ti/Makefile | 1 + drivers/soc/ti/wkup_m3_ipc.c | 508 +++ include/linux/wkup_m3_ipc.h | 55 + 4 files changed, 574 insertions(+) create mode 100644 drivers/soc/ti/wkup_m3_ipc.c create mode 100644 include/linux/wkup_m3_ipc.h diff --git a/drivers/soc/ti/Kconfig b/drivers/soc/ti/Kconfig index 7266b21..3557c5e 100644 --- a/drivers/soc/ti/Kconfig +++ b/drivers/soc/ti/Kconfig @@ -28,4 +28,14 @@ config KEYSTONE_NAVIGATOR_DMA If unsure, say N. +config WKUP_M3_IPC + tristate "TI AMx3 Wkup-M3 IPC Driver" + depends on WKUP_M3_RPROC + depends on OMAP2PLUS_MBOX + help + TI AM33XX and AM43XX have a Cortex M3, the Wakeup M3, to handle + low power transitions. This IPC driver provides the necessary API + to communicate and use the Wakeup M3 for PM features like suspend + resume and boots it using wkup_m3_rproc driver. + endif # SOC_TI diff --git a/drivers/soc/ti/Makefile b/drivers/soc/ti/Makefile index 135bdad..48ff3a7 100644 --- a/drivers/soc/ti/Makefile +++ b/drivers/soc/ti/Makefile @@ -4,3 +4,4 @@ obj-$(CONFIG_KEYSTONE_NAVIGATOR_QMSS) += knav_qmss.o knav_qmss-y := knav_qmss_queue.o knav_qmss_acc.o obj-$(CONFIG_KEYSTONE_NAVIGATOR_DMA) += knav_dma.o +obj-$(CONFIG_WKUP_M3_IPC) += wkup_m3_ipc.o diff --git a/drivers/soc/ti/wkup_m3_ipc.c b/drivers/soc/ti/wkup_m3_ipc.c new file mode 100644 index 000..8823cc8 --- /dev/null +++ b/drivers/soc/ti/wkup_m3_ipc.c @@ -0,0 +1,508 @@ +/* + * AMx3 Wkup M3 IPC driver + * + * Copyright (C) 2015 Texas Instruments, Inc. + * + * Dave Gerlach + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define AM33XX_CTRL_IPC_REG_COUNT 0x8 +#define AM33XX_CTRL_IPC_REG_OFFSET(m) (0x4 + 4 * (m)) + +/* AM33XX M3_TXEV_EOI register */ +#define AM33XX_CONTROL_M3_TXEV_EOI 0x00 + +#define AM33XX_M3_TXEV_ACK (0x1 << 0) +#define AM33XX_M3_TXEV_ENABLE (0x0 << 0) + +#define IPC_CMD_DS00x4 +#define IPC_CMD_STANDBY0xc +#define IPC_CMD_IDLE 0x10 +#define IPC_CMD_RESET 0xe +#define DS_IPC_DEFAULT 0x +#define M3_VERSION_UNKNOWN 0x +#define M3_BASELINE_VERSION0x191 +#define M3_STATUS_RESP_MASK(0x << 16) +#define M3_FW_VERSION_MASK 0x + +#define M3_STATE_UNKNOWN 0 +#define M3_STATE_RESET 1 +#define M3_STATE_INITED2 +#define M3_STATE_MSG_FOR_LP3 +#define M3_STATE_MSG_FOR_RESET 4 + +static struct wkup_m3_ipc *m3_ipc_state; + +static void am33xx_txev_eoi(struct wkup_m3_ipc *m3_ipc) +{ + writel(AM33XX_M3_TXEV_ACK, + m3_ipc->ipc_mem_base + AM33XX_CONTROL_M3_TXEV_EOI); +} + +static void am33xx_txev_enable(struct wkup_m3_ipc *m3_ipc) +{ + writel(AM33XX_M3_TXEV_ENABLE, + m3_ipc->ipc_mem_base + AM33XX_CONTROL_M3_TXEV_EOI); +} + +static void wkup_m3_ctrl_ipc_write(struct wkup_m3_ipc *m3_ipc, + u32 val, int ipc_reg_num) +{ + if (WARN(ipc_reg_num < 0 || ipc_reg_num > AM33XX_CTRL_IPC_REG_COUNT, +"ipc register operation out of range")) + return; + + writel(val, m3_ipc->ipc_mem_base + + AM33XX_CTRL_IPC_REG_OFFSET(ipc_reg_num)); +} + +static unsigned int wkup_m3_ctrl_ipc_read(struct wkup_m3_ipc *m3_ipc, +
[PATCH v3 0/3] soc: ti: Introduce wkup_m3_ipc driver
Hi, This series is version 3 of the code to introduce a wkup_m3_ipc driver to handle communication between the MPU and Cortex M3 present on TI AM335x and AM437x SoCs. v2 of this series can be found at [1]. Only patch 3 has been changed based on a request from Tony and a few cleanups: - Rather than exporting all of the functionality of the driver, added wkup_m3_ipc_get and wkup_m3_ipc_put to allow users to just get a handle containing an ops structure for use. - Changed all ops (previously exported functions) to take pointer to struct wkup_m3_ipc as an argument now that user code will get this from wkup_m3_ipc_get. - General cleanup to probe function - Added MODULE_DEVICE_TABLE so driver can probe automatically. The series containing the DT nodes can be found here [2]. The actual dt nodes for wkup_m3_ipc (last two patches) have been merged but discussion is still open for the ti,mbox-send-noirq flag patches and depends on the comments provided for the omap-mailbox change presented in patch 1 of this series. A full branch containing all necessary PM code for both am335x and am437x has been pushed here [3] to provide a big picture view of the plan for this series. This driver relies on the firmware at [4] in the next-upstream branch being present in /lib/firmware in the rootfs or built in to the kernel. Regards, Dave [1] https://lkml.org/lkml/2015/7/17/797 [2] https://lkml.org/lkml/2015/7/17/813 [3] https://github.com/dgerlach/linux-pm/tree/pm-v4.3-rc1-amx3-suspend [4] https://git.ti.com/ti-cm3-pm-firmware Dave Gerlach (3): mailbox/omap: Add ti,mbox-send-noirq quirk to fix AM33xx CPU Idle Documentation: dt: add bindings for TI Wakeup M3 IPC device soc: ti: Add wkup_m3_ipc driver .../devicetree/bindings/mailbox/omap-mailbox.txt | 8 + .../devicetree/bindings/soc/ti/wkup_m3_ipc.txt | 57 +++ drivers/mailbox/omap-mailbox.c | 49 +- drivers/soc/ti/Kconfig | 10 + drivers/soc/ti/Makefile| 1 + drivers/soc/ti/wkup_m3_ipc.c | 508 + include/linux/wkup_m3_ipc.h| 55 +++ 7 files changed, 684 insertions(+), 4 deletions(-) create mode 100644 Documentation/devicetree/bindings/soc/ti/wkup_m3_ipc.txt create mode 100644 drivers/soc/ti/wkup_m3_ipc.c create mode 100644 include/linux/wkup_m3_ipc.h -- 2.4.6 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 2/3] Documentation: dt: add bindings for TI Wakeup M3 IPC device
Add the device tree bindings document for the TI Wakeup M3 IPC device on AM33xx and AM43xx SoCs. These devices are used by the TI wkup_m3_ipc driver, and contain the registers upon which the IPC protocol to communicate with the Wakeup M3 processor is implemented. Signed-off-by: Dave GerlachSigned-off-by: Suman Anna --- v2->v3: Unchanged. .../devicetree/bindings/soc/ti/wkup_m3_ipc.txt | 57 ++ 1 file changed, 57 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/ti/wkup_m3_ipc.txt diff --git a/Documentation/devicetree/bindings/soc/ti/wkup_m3_ipc.txt b/Documentation/devicetree/bindings/soc/ti/wkup_m3_ipc.txt new file mode 100644 index 000..4015504 --- /dev/null +++ b/Documentation/devicetree/bindings/soc/ti/wkup_m3_ipc.txt @@ -0,0 +1,57 @@ +Wakeup M3 IPC Driver += + +The TI AM33xx and AM43xx family of devices use a small Cortex M3 co-processor +(commonly referred to as Wakeup M3 or CM3) to help with various low power tasks +that cannot be controlled from the MPU, like suspend/resume and certain deep +C-states for CPU Idle. Once the wkup_m3_ipc driver uses the wkup_m3_rproc driver +to boot the wkup_m3, it handles communication with the CM3 using IPC registers +present in the SoC's control module and a mailbox. The wkup_m3_ipc exposes an +API to allow the SoC PM code to execute specific PM tasks. + +Wkup M3 Device Node: + +A wkup_m3_ipc device node is used to represent the IPC registers within an +SoC. + +Required properties: + +- compatible: Should be, + "ti,am3352-wkup-m3-ipc" for AM33xx SoCs + "ti,am4372-wkup-m3-ipc" for AM43xx SoCs +- reg: Contains the IPC register address space to communicate + with the Wakeup M3 processor +- interrupts: Contains the interrupt information for the wkup_m3 + interrupt that signals the MPU. +- ti,rproc:phandle to the wkup_m3 rproc node so the IPC driver + can boot it. +- mboxes: phandles used by IPC framework to get correct mbox + channel for communication. Must point to appropriate + mbox_wkupm3 child node. + +Example: + +/* AM33xx */ + l4_wkup: l4_wkup@44c0 { + ... + + scm: scm@21 { + compatible = "ti,am3-scm", "simple-bus"; + reg = <0x21 0x2000>; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0 0x21 0x2000>; + + ... + + wkup_m3_ipc: wkup_m3_ipc@1324 { + compatible = "ti,am3352-wkup-m3-ipc"; + reg = <0x1324 0x24>; + interrupts = <78>; + ti,rproc = <_m3>; + mboxes = < _wkupm3>; + }; + + ... + }; + }; -- 2.4.6 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 00/38] Fixes related to incorrect usage of unsigned types
On 09/21/2015 03:42 PM, David Howells wrote: > Andrzej Hajdawrote: > >> Semantic patch finds comparisons of types: >> unsigned < 0 >> unsigned >= 0 >> The former is always false, the latter is always true. >> Such comparisons are useless, so theoretically they could be >> safely removed, but their presence quite often indicates bugs. > > Or someone has left them in because they don't matter and there's the > possibility that the type being tested might be or become signed under some > circumstances. If the comparison is useless, I'd expect the compiler to just > discard it - for such cases your patch is pointless. > > If I have, for example: > > unsigned x; > > if (x == 0 || x > 27) > give_a_range_error(); > > I will write this as: > > unsigned x; > > if (x <= 0 || x > 27) > give_a_range_error(); > > because it that gives a way to handle x being changed to signed at some point > in the future for no cost. In which case, your changing the <= to an == > "because the < part of the case is useless" is arguably wrong. This is why I have not checked for such cases - I have skipped checks of type unsigned <= 0 exactly for the reasons above. However I have left two other checks as they seems to me more suspicious - they are always true or false. But as Dmitry and Andrew pointed out Linus have quite strong opinion against removing range checks in such cases as he finds it clearer. I think it applies to patches 29-36. I am not sure about patches 26-28,37. Regards Andrzej > > David > -- > To unsubscribe from this list: send the line "unsubscribe linux-wireless" in > the body of a message to majordomo-u79uwxl29ty76z2rm5m...@public.gmane.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 3/3] mfd: Add battery charger as subdevice to the tps65217.
2015-09-20 6:19 GMT+02:00 Lee Jones: > On Tue, 08 Sep 2015, Enric Balletbo i Serra wrote: > >> Add tps65217 battery charger subdevice. >> >> Signed-off-by: Enric Balletbo i Serra >> --- >> drivers/mfd/tps65217.c | 4 >> 1 file changed, 4 insertions(+) > > Applied, thanks. > Many thanks, any feedback about ? [PATCH 1/3] devicetree: Add TPS65217 charger binding [PATCH 2/3] power_supply: Add support for tps65217-charger. Or should go through another tree ? >> diff --git a/drivers/mfd/tps65217.c b/drivers/mfd/tps65217.c >> index 55add04..d32b5442 100644 >> --- a/drivers/mfd/tps65217.c >> +++ b/drivers/mfd/tps65217.c >> @@ -39,6 +39,10 @@ static const struct mfd_cell tps65217s[] = { >> .name = "tps65217-bl", >> .of_compatible = "ti,tps65217-bl", >> }, >> + { >> + .name = "tps65217-charger", >> + .of_compatible = "ti,tps65217-charger", >> + }, >> }; >> >> /** > > -- > Lee Jones > Linaro STMicroelectronics Landing Team Lead > Linaro.org │ Open source software for ARM SoCs > Follow Linaro: Facebook | Twitter | Blog -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/3] power_supply: Add support for tps65217-charger.
Hi, On Tue, Sep 08, 2015 at 10:09:38AM +0200, Enric Balletbo i Serra wrote: > This patch adds support for the tps65217 charger driver. This driver is > responsible for controlling the charger aspect of the tps65217 mfd. > Currently, this mainly consists of turning on and off the charger, but > some other features of the charger can be supported through this driver. Driver looks mostly fine. I have two comments though: > [...] > > +static int tps65217_ac_get_property(struct power_supply *psy, > + enum power_supply_property psp, > + union power_supply_propval *val) > +{ > + struct tps65217_charger *charger = power_supply_get_drvdata(psy); > + > + if (psp == POWER_SUPPLY_PROP_ONLINE) { > + val->intval = charger->ac_online; > + charger->prev_ac_online = charger->ac_online; I think prev_ac_online should be set at the beginning of tps65217_charger_irq(). > [...] > > +static int tps65217_charger_probe(struct platform_device *pdev) > +{ > > [...] > > + charger->ac = power_supply_register(>dev, > + _charger_desc, NULL); > + if (IS_ERR(charger->ac)) { > + dev_err(>dev, "failed: power supply register\n"); > + return PTR_ERR(charger->ac); > + } You can use devm_power_supply_register(...) to simplify the driver a bit more. -- Sebastian signature.asc Description: Digital signature
[PATCH v3 19/24] dmaengine: edma: Simplify the interrupt handling
With the merger of the arch/arm/common/edma.c code into the dmaengine driver, there is no longer need to have per channel callback/data storage for interrupt events. Signed-off-by: Peter Ujfalusi--- drivers/dma/edma.c | 447 - 1 file changed, 204 insertions(+), 243 deletions(-) diff --git a/drivers/dma/edma.c b/drivers/dma/edma.c index d872efed0760..03f411cc900b 100644 --- a/drivers/dma/edma.c +++ b/drivers/dma/edma.c @@ -154,12 +154,6 @@ struct edmacc_param { #define TCCHEN BIT(22) #define ITCCHENBIT(23) -/*ch_status paramater of callback function possible values*/ -#define EDMA_DMA_COMPLETE 1 -#define EDMA_DMA_CC_ERROR 2 -#define EDMA_DMA_TC1_ERROR 3 -#define EDMA_DMA_TC2_ERROR 4 - struct edma_pset { u32 len; dma_addr_t addr; @@ -243,12 +237,6 @@ struct edma_cc { */ unsigned long *edma_unused; - struct dma_interrupt_data { - void (*callback)(unsigned channel, unsigned short ch_status, - void *data); - void *data; - } *intr_data; - struct dma_device dma_slave; struct edma_chan*slave_chans; int dummy_slot; @@ -464,24 +452,18 @@ static int prepare_unused_channel_list(struct device *dev, void *data) return 0; } -static void edma_setup_interrupt(struct edma_cc *ecc, unsigned lch, - void (*callback)(unsigned channel, u16 ch_status, void *data), - void *data) +static void edma_setup_interrupt(struct edma_cc *ecc, unsigned lch, bool enable) { lch = EDMA_CHAN_SLOT(lch); - if (!callback) - edma_shadow0_write_array(ecc, SH_IECR, lch >> 5, -BIT(lch & 0x1f)); - - ecc->intr_data[lch].callback = callback; - ecc->intr_data[lch].data = data; - - if (callback) { + if (enable) { edma_shadow0_write_array(ecc, SH_ICR, lch >> 5, BIT(lch & 0x1f)); edma_shadow0_write_array(ecc, SH_IESR, lch >> 5, BIT(lch & 0x1f)); + } else { + edma_shadow0_write_array(ecc, SH_IECR, lch >> 5, +BIT(lch & 0x1f)); } } @@ -774,8 +756,6 @@ static void edma_clean_channel(struct edma_cc *ecc, unsigned channel) * edma_alloc_channel - allocate DMA channel and paired parameter RAM * @ecc: pointer to edma_cc struct * @channel: specific channel to allocate; negative for "any unmapped channel" - * @callback: optional; to be issued on DMA completion or errors - * @data: passed to callback * @eventq_no: an EVENTQ_* constant, used to choose which Transfer * Controller (TC) executes requests using this channel. Use * EVENTQ_DEFAULT unless you really need a high priority queue. @@ -802,9 +782,7 @@ static void edma_clean_channel(struct edma_cc *ecc, unsigned channel) * Returns the number of the channel, else negative errno. */ static int edma_alloc_channel(struct edma_cc *ecc, int channel, - void (*callback)(unsigned channel, u16 ch_status, void *data), - void *data, - enum dma_event_q eventq_no) + enum dma_event_q eventq_no) { unsigned done = 0; int ret = 0; @@ -860,9 +838,7 @@ static int edma_alloc_channel(struct edma_cc *ecc, int channel, edma_stop(ecc, EDMA_CTLR_CHAN(ecc->id, channel)); edma_write_slot(ecc, channel, _paramset); - if (callback) - edma_setup_interrupt(ecc, EDMA_CTLR_CHAN(ecc->id, channel), -callback, data); + edma_setup_interrupt(ecc, EDMA_CTLR_CHAN(ecc->id, channel), true); edma_map_dmach_to_queue(ecc, channel, eventq_no); @@ -895,7 +871,7 @@ static void edma_free_channel(struct edma_cc *ecc, unsigned channel) if (channel >= ecc->num_channels) return; - edma_setup_interrupt(ecc, channel, NULL, NULL); + edma_setup_interrupt(ecc, channel, false); /* REVISIT should probably take out of shadow region 0 */ edma_write_slot(ecc, channel, _paramset); @@ -925,146 +901,6 @@ static void edma_assign_channel_eventq(struct edma_cc *ecc, unsigned channel, edma_map_dmach_to_queue(ecc, channel, eventq_no); } -/* eDMA interrupt handler */ -static irqreturn_t dma_irq_handler(int irq, void *data) -{ - struct edma_cc *ecc = data; - int ctlr; - u32 sh_ier; - u32 sh_ipr; - u32 bank; - - ctlr = ecc->id; - if (ctlr < 0) - return IRQ_NONE; - - dev_dbg(ecc->dev, "dma_irq_handler\n"); - - sh_ipr = edma_shadow0_read_array(ecc, SH_IPR, 0); - if (!sh_ipr) { - sh_ipr =
[PATCH v3 08/24] ARM/dmaengine: edma: Remove limitation on the number of eDMA controllers
Since the driver stack no longer depends on lookup with id number in a global array of pointers, the limitation for the number of eDMAs are no longer needed. We can handle as many eDMAs in legacy and DT boot as we have memory for them to allocate the needed structures. Signed-off-by: Peter Ujfalusi--- arch/arm/common/edma.c | 22 +- drivers/dma/edma.c | 17 - 2 files changed, 13 insertions(+), 26 deletions(-) diff --git a/arch/arm/common/edma.c b/arch/arm/common/edma.c index 03692520812a..5b747f1bc8b5 100644 --- a/arch/arm/common/edma.c +++ b/arch/arm/common/edma.c @@ -1227,24 +1227,7 @@ static int edma_probe(struct platform_device *pdev) .parent = >dev, }; - /* When booting with DT the pdev->id is -1 */ - if (dev_id < 0) - dev_id = arch_num_cc; - - if (dev_id >= EDMA_MAX_CC) { - dev_err(dev, - "eDMA3 with device id 0 and 1 is supported (id: %d)\n", - dev_id); - return -EINVAL; - } - if (node) { - /* Check if this is a second instance registered */ - if (arch_num_cc) { - dev_err(dev, "only one EDMA instance is supported via DT\n"); - return -ENODEV; - } - info = edma_setup_info_from_dt(dev, node); if (IS_ERR(info)) { dev_err(dev, "failed to get DT data\n"); @@ -1278,6 +1261,11 @@ static int edma_probe(struct platform_device *pdev) cc->dev = dev; cc->id = dev_id; + /* When booting with DT the pdev->id is -1 */ + if (dev_id < 0) { + cc->id = 0; + dev_id = arch_num_cc; + } dev_set_drvdata(dev, cc); cc->base = devm_ioremap_resource(dev, mem); diff --git a/drivers/dma/edma.c b/drivers/dma/edma.c index 53d48b2a700d..fc91ab9dd1bb 100644 --- a/drivers/dma/edma.c +++ b/drivers/dma/edma.c @@ -991,14 +991,12 @@ static void edma_dma_init(struct edma_cc *ecc, struct dma_device *dma, INIT_LIST_HEAD(>channels); } -static struct of_dma_filter_info edma_filter_info = { - .filter_fn = edma_filter_fn, -}; - static int edma_probe(struct platform_device *pdev) { struct edma_cc *ecc; struct device_node *parent_node = pdev->dev.parent->of_node; + struct platform_device *parent_pdev = + to_platform_device(pdev->dev.parent); int ret; ret = dma_set_mask_and_coherent(>dev, DMA_BIT_MASK(32)); @@ -1015,7 +1013,10 @@ static int edma_probe(struct platform_device *pdev) if (!ecc->cc) return -ENODEV; - ecc->ctlr = pdev->id; + ecc->ctlr = parent_pdev->id; + if (ecc->ctlr < 0) + ecc->ctlr = 0; + ecc->dummy_slot = edma_alloc_slot(ecc->cc, EDMA_SLOT_ANY); if (ecc->dummy_slot < 0) { dev_err(>dev, "Can't allocate PaRAM dummy slot\n"); @@ -1038,10 +1039,8 @@ static int edma_probe(struct platform_device *pdev) platform_set_drvdata(pdev, ecc); if (parent_node) { - dma_cap_set(DMA_SLAVE, edma_filter_info.dma_cap); - dma_cap_set(DMA_CYCLIC, edma_filter_info.dma_cap); - of_dma_controller_register(parent_node, of_dma_simple_xlate, - _filter_info); + of_dma_controller_register(parent_node, of_dma_xlate_by_chan_id, + >dma_slave); } dev_info(>dev, "TI EDMA DMA engine driver\n"); -- 2.5.2 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 04/24] ARM: davinci/common: Convert edma driver to handle one eDMA instance per driver
Currently we have one device created to handle all (maximum 2) eDMAs in the system. With this change all eDMA instance will have it's own device/driver. This change is needed for further cleanups in the eDMA driver stack since the one device/driver to handle all eDMAs in the system was not flexible enough and prevents the upcoming work. Signed-off-by: Peter Ujfalusi--- arch/arm/common/edma.c| 356 +++--- arch/arm/mach-davinci/devices-da8xx.c | 110 --- arch/arm/mach-davinci/dm355.c | 21 +- arch/arm/mach-davinci/dm365.c | 25 +-- arch/arm/mach-davinci/dm644x.c| 21 +- arch/arm/mach-davinci/dm646x.c| 27 ++- 6 files changed, 234 insertions(+), 326 deletions(-) diff --git a/arch/arm/common/edma.c b/arch/arm/common/edma.c index e9c4cb16a47e..7c2fe527e53b 100644 --- a/arch/arm/common/edma.c +++ b/arch/arm/common/edma.c @@ -235,6 +235,7 @@ static inline void clear_bits(int offset, int len, unsigned long *p) /* actual number of DMA channels and slots on this silicon */ struct edma { + struct device *dev; /* how many dma resources of each type */ unsignednum_channels; unsignednum_region; @@ -246,6 +247,7 @@ struct edma { const s8*noevent; struct edma_soc_info *info; + int id; /* The edma_inuse bit for each PaRAM slot is clear unless the * channel is in use ... by ARM or DSP, for QDMA, or whatever. @@ -258,9 +260,6 @@ struct edma { */ DECLARE_BITMAP(edma_unused, EDMA_MAX_DMACH); - unsignedirq_res_start; - unsignedirq_res_end; - struct dma_interrupt_data { void (*callback)(unsigned channel, unsigned short ch_status, void *data); @@ -349,17 +348,6 @@ setup_dma_interrupt(unsigned lch, } } -static int irq2ctlr(int irq) -{ - if (irq >= edma_cc[0]->irq_res_start && irq <= edma_cc[0]->irq_res_end) - return 0; - else if (irq >= edma_cc[1]->irq_res_start && - irq <= edma_cc[1]->irq_res_end) - return 1; - - return -1; -} - /** * * DMA interrupt handler @@ -367,16 +355,17 @@ static int irq2ctlr(int irq) */ static irqreturn_t dma_irq_handler(int irq, void *data) { + struct edma *cc = data; int ctlr; u32 sh_ier; u32 sh_ipr; u32 bank; - ctlr = irq2ctlr(irq); + ctlr = cc->id; if (ctlr < 0) return IRQ_NONE; - dev_dbg(data, "dma_irq_handler\n"); + dev_dbg(cc->dev, "dma_irq_handler\n"); sh_ipr = edma_shadow0_read_array(ctlr, SH_IPR, 0); if (!sh_ipr) { @@ -394,7 +383,7 @@ static irqreturn_t dma_irq_handler(int irq, void *data) u32 slot; u32 channel; - dev_dbg(data, "IPR%d %08x\n", bank, sh_ipr); + dev_dbg(cc->dev, "IPR%d %08x\n", bank, sh_ipr); slot = __ffs(sh_ipr); sh_ipr &= ~(BIT(slot)); @@ -404,11 +393,11 @@ static irqreturn_t dma_irq_handler(int irq, void *data) /* Clear the corresponding IPR bits */ edma_shadow0_write_array(ctlr, SH_ICR, bank, BIT(slot)); - if (edma_cc[ctlr]->intr_data[channel].callback) - edma_cc[ctlr]->intr_data[channel].callback( + if (cc->intr_data[channel].callback) + cc->intr_data[channel].callback( EDMA_CTLR_CHAN(ctlr, channel), EDMA_DMA_COMPLETE, - edma_cc[ctlr]->intr_data[channel].data); + cc->intr_data[channel].data); } } while (sh_ipr); @@ -423,15 +412,16 @@ static irqreturn_t dma_irq_handler(int irq, void *data) */ static irqreturn_t dma_ccerr_handler(int irq, void *data) { + struct edma *cc = data; int i; int ctlr; unsigned int cnt = 0; - ctlr = irq2ctlr(irq); + ctlr = cc->id; if (ctlr < 0) return IRQ_NONE; - dev_dbg(data, "dma_ccerr_handler\n"); + dev_dbg(cc->dev, "dma_ccerr_handler\n"); if ((edma_read_array(ctlr, EDMA_EMR, 0) == 0) && (edma_read_array(ctlr, EDMA_EMR, 1) == 0) && @@ -446,8 +436,8 @@ static irqreturn_t dma_ccerr_handler(int irq, void *data) else if (edma_read_array(ctlr, EDMA_EMR, 1)) j = 1; if (j >= 0) { -
[PATCH v3 09/24] ARM: davinci: Use platform_device_register_full() to create pdev for eDMA
Convert the eDMA platform device creation to use struct platform_device_info XX __initconst and platform_device_register_full() This will allow us to cleanly specify the dma_mask for the devices in an upcoming patch. Signed-off-by: Peter Ujfalusi--- arch/arm/mach-davinci/devices-da8xx.c | 38 ++- arch/arm/mach-davinci/dm355.c | 20 +++--- arch/arm/mach-davinci/dm644x.c| 20 +++--- arch/arm/mach-davinci/dm646x.c| 18 ++--- 4 files changed, 57 insertions(+), 39 deletions(-) diff --git a/arch/arm/mach-davinci/devices-da8xx.c b/arch/arm/mach-davinci/devices-da8xx.c index 9ae049ae816a..9f7d266faa0c 100644 --- a/arch/arm/mach-davinci/devices-da8xx.c +++ b/arch/arm/mach-davinci/devices-da8xx.c @@ -213,48 +213,50 @@ static struct resource da850_edma1_resources[] = { }, }; -static struct platform_device da8xx_edma0_device = { +static const struct platform_device_info da8xx_edma0_device __initconst = { .name = "edma", .id = 0, - .dev = { - .platform_data = _edma0_pdata, - }, - .num_resources = ARRAY_SIZE(da8xx_edma0_resources), - .resource = da8xx_edma0_resources, + .res= da8xx_edma0_resources, + .num_res= ARRAY_SIZE(da8xx_edma0_resources), + .data = _edma0_pdata, + .size_data = sizeof(da8xx_edma0_pdata), }; -static struct platform_device da850_edma1_device = { +static const struct platform_device_info da850_edma1_device __initconst = { .name = "edma", .id = 1, - .dev = { - .platform_data = _edma1_pdata, - }, - .num_resources = ARRAY_SIZE(da850_edma1_resources), - .resource = da850_edma1_resources, + .res= da850_edma1_resources, + .num_res= ARRAY_SIZE(da850_edma1_resources), + .data = _edma1_pdata, + .size_data = sizeof(da850_edma1_pdata), }; int __init da830_register_edma(struct edma_rsv_info *rsv) { + struct platform_device *edma_pdev; + da8xx_edma0_pdata.rsv = rsv; - return platform_device_register(_edma0_device); + edma_pdev = platform_device_register_full(_edma0_device); + return IS_ERR(edma_pdev) ? PTR_ERR(edma_pdev) : 0; } int __init da850_register_edma(struct edma_rsv_info *rsv[2]) { - int ret; + struct platform_device *edma_pdev; if (rsv) { da8xx_edma0_pdata.rsv = rsv[0]; da850_edma1_pdata.rsv = rsv[1]; } - ret = platform_device_register(_edma0_device); - if (ret) { + edma_pdev = platform_device_register_full(_edma0_device); + if (IS_ERR(edma_pdev)) { pr_warn("%s: Failed to register eDMA0\n", __func__); - return ret; + return PTR_ERR(edma_pdev); } - return platform_device_register(_edma1_device); + edma_pdev = platform_device_register_full(_edma1_device); + return IS_ERR(edma_pdev) ? PTR_ERR(edma_pdev) : 0; } static struct resource da8xx_i2c_resources0[] = { diff --git a/arch/arm/mach-davinci/dm355.c b/arch/arm/mach-davinci/dm355.c index a50bb9c66952..5f10c6695e31 100644 --- a/arch/arm/mach-davinci/dm355.c +++ b/arch/arm/mach-davinci/dm355.c @@ -613,12 +613,13 @@ static struct resource edma_resources[] = { /* not using (or muxing) TC*_ERR */ }; -static struct platform_device dm355_edma_device = { - .name = "edma", - .id = 0, - .dev.platform_data = _edma_pdata, - .num_resources = ARRAY_SIZE(edma_resources), - .resource = edma_resources, +static const struct platform_device_info dm355_edma_device __initconst = { + .name = "edma", + .id = 0, + .res= edma_resources, + .num_res= ARRAY_SIZE(edma_resources), + .data = _edma_pdata, + .size_data = sizeof(dm355_edma_pdata), }; static struct resource dm355_asp1_resources[] = { @@ -1057,13 +1058,18 @@ int __init dm355_init_video(struct vpfe_config *vpfe_cfg, static int __init dm355_init_devices(void) { + struct platform_device *edma_pdev; int ret = 0; if (!cpu_is_davinci_dm355()) return 0; davinci_cfg_reg(DM355_INT_EDMA_CC); - platform_device_register(_edma_device); + edma_pdev = platform_device_register_full(_edma_device); + if (IS_ERR(edma_pdev)) { + pr_warn("%s: Failed to register eDMA\n", __func__); + return PTR_ERR(edma_pdev); + } ret = davinci_init_wdt(); if (ret) diff --git a/arch/arm/mach-davinci/dm644x.c b/arch/arm/mach-davinci/dm644x.c index d759ca8e58e8..aa3453b40d5f 100644 --- a/arch/arm/mach-davinci/dm644x.c +++
[PATCH v3 12/24] dmaengine: edma: Parameter alignment and long line fixes
Makes the code a bit more readable. Signed-off-by: Peter Ujfalusi--- drivers/dma/edma.c | 84 -- 1 file changed, 44 insertions(+), 40 deletions(-) diff --git a/drivers/dma/edma.c b/drivers/dma/edma.c index 49158ab1c798..46c0cbf1fe20 100644 --- a/drivers/dma/edma.c +++ b/drivers/dma/edma.c @@ -294,31 +294,33 @@ static inline void edma_or(struct edma_cc *ecc, int offset, unsigned or) val |= or; edma_write(ecc, offset, val); } -static inline unsigned int edma_read_array(struct edma_cc *ecc, int offset, int i) +static inline unsigned int edma_read_array(struct edma_cc *ecc, int offset, + int i) { return edma_read(ecc, offset + (i << 2)); } static inline void edma_write_array(struct edma_cc *ecc, int offset, int i, - unsigned val) + unsigned val) { edma_write(ecc, offset + (i << 2), val); } static inline void edma_modify_array(struct edma_cc *ecc, int offset, int i, - unsigned and, unsigned or) +unsigned and, unsigned or) { edma_modify(ecc, offset + (i << 2), and, or); } -static inline void edma_or_array(struct edma_cc *ecc, int offset, int i, unsigned or) +static inline void edma_or_array(struct edma_cc *ecc, int offset, int i, +unsigned or) { edma_or(ecc, offset + (i << 2), or); } static inline void edma_or_array2(struct edma_cc *ecc, int offset, int i, int j, - unsigned or) + unsigned or) { edma_or(ecc, offset + ((i*2 + j) << 2), or); } -static inline void edma_write_array2(struct edma_cc *ecc, int offset, int i, int j, - unsigned val) +static inline void edma_write_array2(struct edma_cc *ecc, int offset, int i, +int j, unsigned val) { edma_write(ecc, offset + ((i*2 + j) << 2), val); } @@ -326,42 +328,43 @@ static inline unsigned int edma_shadow0_read(struct edma_cc *ecc, int offset) { return edma_read(ecc, EDMA_SHADOW0 + offset); } -static inline unsigned int edma_shadow0_read_array(struct edma_cc *ecc, int offset, - int i) +static inline unsigned int edma_shadow0_read_array(struct edma_cc *ecc, + int offset, int i) { return edma_read(ecc, EDMA_SHADOW0 + offset + (i << 2)); } -static inline void edma_shadow0_write(struct edma_cc *ecc, int offset, unsigned val) +static inline void edma_shadow0_write(struct edma_cc *ecc, int offset, + unsigned val) { edma_write(ecc, EDMA_SHADOW0 + offset, val); } -static inline void edma_shadow0_write_array(struct edma_cc *ecc, int offset, int i, - unsigned val) +static inline void edma_shadow0_write_array(struct edma_cc *ecc, int offset, + int i, unsigned val) { edma_write(ecc, EDMA_SHADOW0 + offset + (i << 2), val); } static inline unsigned int edma_parm_read(struct edma_cc *ecc, int offset, - int param_no) + int param_no) { return edma_read(ecc, EDMA_PARM + offset + (param_no << 5)); } -static inline void edma_parm_write(struct edma_cc *ecc, int offset, int param_no, - unsigned val) +static inline void edma_parm_write(struct edma_cc *ecc, int offset, + int param_no, unsigned val) { edma_write(ecc, EDMA_PARM + offset + (param_no << 5), val); } -static inline void edma_parm_modify(struct edma_cc *ecc, int offset, int param_no, - unsigned and, unsigned or) +static inline void edma_parm_modify(struct edma_cc *ecc, int offset, + int param_no, unsigned and, unsigned or) { edma_modify(ecc, EDMA_PARM + offset + (param_no << 5), and, or); } static inline void edma_parm_and(struct edma_cc *ecc, int offset, int param_no, - unsigned and) +unsigned and) { edma_and(ecc, EDMA_PARM + offset + (param_no << 5), and); } static inline void edma_parm_or(struct edma_cc *ecc, int offset, int param_no, - unsigned or) + unsigned or) { edma_or(ecc, EDMA_PARM + offset + (param_no << 5), or); } @@ -388,8 +391,8 @@ static void edma_map_dmach_to_queue(struct edma_cc *ecc, unsigned ch_no, queue_no = ecc->default_queue; queue_no &= 7; - edma_modify_array(ecc, EDMA_DMAQNUM, (ch_no >> 3), - ~(0x7 << bit), queue_no << bit); + edma_modify_array(ecc, EDMA_DMAQNUM, (ch_no >> 3), ~(0x7 << bit), + queue_no << bit); } static void edma_assign_priority_to_queue(struct edma_cc *ecc, int queue_no, @@ -1134,8 +1137,7 @@
[PATCH v3 11/24] dmaengine: edma: Allocate memory dynamically for bitmaps and structures
Instead of using defines to specify the size of different arrays and bitmaps, allocate the memory for them based on the information we get from the HW itself. Since these defines are set based on the worst case, there are devices where they are not valid. Signed-off-by: Peter Ujfalusi--- drivers/dma/edma.c | 62 ++ 1 file changed, 34 insertions(+), 28 deletions(-) diff --git a/drivers/dma/edma.c b/drivers/dma/edma.c index f31c463f94bd..49158ab1c798 100644 --- a/drivers/dma/edma.c +++ b/drivers/dma/edma.c @@ -113,23 +113,6 @@ #define CHMAP_EXISTBIT(24) /* - * This will go away when the private EDMA API is folded - * into this driver and the platform device(s) are - * instantiated in the arch code. We can only get away - * with this simplification because DA8XX may not be built - * in the same kernel image with other DaVinci parts. This - * avoids having to sprinkle dmaengine driver platform devices - * and data throughout all the existing board files. - */ -#ifdef CONFIG_ARCH_DAVINCI_DA8XX -#define EDMA_CTLRS 2 -#define EDMA_CHANS 32 -#else -#define EDMA_CTLRS 1 -#define EDMA_CHANS 64 -#endif /* CONFIG_ARCH_DAVINCI_DA8XX */ - -/* * Max of 20 segments per channel to conserve PaRAM slots * Also note that MAX_NR_SG should be atleast the no.of periods * that are required for ASoC, otherwise DMA prep calls will @@ -140,16 +123,12 @@ #define EDMA_MAX_SLOTS MAX_NR_SG #define EDMA_DESCRIPTORS 16 -#define EDMA_MAX_PARAMENTRY 512 - #define EDMA_CHANNEL_ANY -1 /* for edma_alloc_channel() */ #define EDMA_SLOT_ANY -1 /* for edma_alloc_slot() */ #define EDMA_CONT_PARAMS_ANY1001 #define EDMA_CONT_PARAMS_FIXED_EXACT1002 #define EDMA_CONT_PARAMS_FIXED_NOT_EXACT 1003 -#define EDMA_MAX_CC 2 - /* PaRAM slots are laid out like this */ struct edmacc_param { u32 opt; @@ -256,22 +235,22 @@ struct edma_cc { /* The edma_inuse bit for each PaRAM slot is clear unless the * channel is in use ... by ARM or DSP, for QDMA, or whatever. */ - DECLARE_BITMAP(edma_inuse, EDMA_MAX_PARAMENTRY); + unsigned long *edma_inuse; /* The edma_unused bit for each channel is clear unless * it is not being used on this platform. It uses a bit * of SOC-specific initialization code. */ - DECLARE_BITMAP(edma_unused, EDMA_CHANS); + unsigned long *edma_unused; struct dma_interrupt_data { void (*callback)(unsigned channel, unsigned short ch_status, void *data); void *data; - } intr_data[EDMA_CHANS]; + } *intr_data; struct dma_device dma_slave; - struct edma_chanslave_chans[EDMA_CHANS]; + struct edma_chan*slave_chans; int dummy_slot; }; @@ -431,6 +410,8 @@ static int prepare_unused_channel_list(struct device *dev, void *data) { struct platform_device *pdev = to_platform_device(dev); struct edma_cc *ecc = data; + int dma_req_min = EDMA_CTLR_CHAN(ecc->id, 0); + int dma_req_max = dma_req_min + ecc->num_channels; int i, count; struct of_phandle_args dma_spec; @@ -466,11 +447,15 @@ static int prepare_unused_channel_list(struct device *dev, void *data) /* For non-OF case */ for (i = 0; i < pdev->num_resources; i++) { struct resource *res = >resource[i]; + int dma_req; + + if (!(res->flags & IORESOURCE_DMA)) + continue; - if ((res->flags & IORESOURCE_DMA) && (int)res->start >= 0) { + dma_req = (int)res->start; + if (dma_req >= dma_req_min && dma_req < dma_req_max) clear_bit(EDMA_CHAN_SLOT(pdev->resource[i].start), ecc->edma_unused); - } } return 0; @@ -1953,7 +1938,7 @@ static void __init edma_chan_init(struct edma_cc *ecc, { int i, j; - for (i = 0; i < EDMA_CHANS; i++) { + for (i = 0; i < ecc->num_channels; i++) { struct edma_chan *echan = [i]; echan->ch_num = EDMA_CTLR_CHAN(ecc->id, i); echan->ecc = ecc; @@ -,6 +2207,27 @@ static int edma_probe(struct platform_device *pdev) if (ret) return ret; + /* Allocate memory based on the information we got from the IP */ + ecc->slave_chans = devm_kcalloc(dev, ecc->num_channels, + sizeof(*ecc->slave_chans), GFP_KERNEL); + if (!ecc->slave_chans) + return -ENOMEM; + + ecc->intr_data = devm_kcalloc(dev, ecc->num_channels, + sizeof(*ecc->intr_data), GFP_KERNEL);
[PATCH v3 06/24] ARM: common: edma: Internal API to use pointer to 'struct edma'
Merge the iomem into the 'struct edma' and change the internal (static) functions to use pointer to the edma_cc instead of the ctlr number. Signed-off-by: Peter Ujfalusi--- arch/arm/common/edma.c | 400 - 1 file changed, 197 insertions(+), 203 deletions(-) diff --git a/arch/arm/common/edma.c b/arch/arm/common/edma.c index d82fceda13a3..0b4c0ee59ed9 100644 --- a/arch/arm/common/edma.c +++ b/arch/arm/common/edma.c @@ -114,108 +114,141 @@ #define EDMA_MAX_PARAMENTRY 512 /*/ +struct edma { + struct device *dev; + void __iomem *base; + + /* how many dma resources of each type */ + unsignednum_channels; + unsignednum_region; + unsignednum_slots; + unsignednum_tc; + enum dma_event_qdefault_queue; -static void __iomem *edmacc_regs_base[EDMA_MAX_CC]; + /* list of channels with no even trigger; terminated by "-1" */ + const s8*noevent; + + struct edma_soc_info *info; + int id; + + /* The edma_inuse bit for each PaRAM slot is clear unless the +* channel is in use ... by ARM or DSP, for QDMA, or whatever. +*/ + DECLARE_BITMAP(edma_inuse, EDMA_MAX_PARAMENTRY); -static inline unsigned int edma_read(unsigned ctlr, int offset) + /* The edma_unused bit for each channel is clear unless +* it is not being used on this platform. It uses a bit +* of SOC-specific initialization code. +*/ + DECLARE_BITMAP(edma_unused, EDMA_MAX_DMACH); + + struct dma_interrupt_data { + void (*callback)(unsigned channel, unsigned short ch_status, + void *data); + void *data; + } intr_data[EDMA_MAX_DMACH]; +}; +/*/ + +static inline unsigned int edma_read(struct edma *cc, int offset) { - return (unsigned int)__raw_readl(edmacc_regs_base[ctlr] + offset); + return (unsigned int)__raw_readl(cc->base + offset); } -static inline void edma_write(unsigned ctlr, int offset, int val) +static inline void edma_write(struct edma *cc, int offset, int val) { - __raw_writel(val, edmacc_regs_base[ctlr] + offset); + __raw_writel(val, cc->base + offset); } -static inline void edma_modify(unsigned ctlr, int offset, unsigned and, - unsigned or) +static inline void edma_modify(struct edma *cc, int offset, unsigned and, + unsigned or) { - unsigned val = edma_read(ctlr, offset); + unsigned val = edma_read(cc, offset); val &= and; val |= or; - edma_write(ctlr, offset, val); + edma_write(cc, offset, val); } -static inline void edma_and(unsigned ctlr, int offset, unsigned and) +static inline void edma_and(struct edma *cc, int offset, unsigned and) { - unsigned val = edma_read(ctlr, offset); + unsigned val = edma_read(cc, offset); val &= and; - edma_write(ctlr, offset, val); + edma_write(cc, offset, val); } -static inline void edma_or(unsigned ctlr, int offset, unsigned or) +static inline void edma_or(struct edma *cc, int offset, unsigned or) { - unsigned val = edma_read(ctlr, offset); + unsigned val = edma_read(cc, offset); val |= or; - edma_write(ctlr, offset, val); + edma_write(cc, offset, val); } -static inline unsigned int edma_read_array(unsigned ctlr, int offset, int i) +static inline unsigned int edma_read_array(struct edma *cc, int offset, int i) { - return edma_read(ctlr, offset + (i << 2)); + return edma_read(cc, offset + (i << 2)); } -static inline void edma_write_array(unsigned ctlr, int offset, int i, +static inline void edma_write_array(struct edma *cc, int offset, int i, unsigned val) { - edma_write(ctlr, offset + (i << 2), val); + edma_write(cc, offset + (i << 2), val); } -static inline void edma_modify_array(unsigned ctlr, int offset, int i, +static inline void edma_modify_array(struct edma *cc, int offset, int i, unsigned and, unsigned or) { - edma_modify(ctlr, offset + (i << 2), and, or); + edma_modify(cc, offset + (i << 2), and, or); } -static inline void edma_or_array(unsigned ctlr, int offset, int i, unsigned or) +static inline void edma_or_array(struct edma *cc, int offset, int i, unsigned or) { - edma_or(ctlr, offset + (i << 2), or); + edma_or(cc, offset + (i << 2), or); } -static inline void edma_or_array2(unsigned ctlr, int offset, int i, int j, +static inline void edma_or_array2(struct edma *cc, int offset, int i, int j, unsigned or) { - edma_or(ctlr, offset + ((i*2 + j) << 2), or); + edma_or(cc, offset + ((i*2 + j) << 2), or); } -static inline void
[PATCH v3 14/24] dmaengine: edma: Cleanup regarding the use of dev around the code
Be consistent and do not mix the use of dev, >dev, etc in the functions. Signed-off-by: Peter Ujfalusi--- drivers/dma/edma.c | 21 ++--- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/dma/edma.c b/drivers/dma/edma.c index f5010c8f6273..2332142c36db 100644 --- a/drivers/dma/edma.c +++ b/drivers/dma/edma.c @@ -1177,7 +1177,7 @@ static void edma_execute(struct edma_chan *echan) j = i + edesc->processed; edma_write_slot(ecc, echan->slot[i], >pset[j].param); edesc->sg_len += edesc->pset[j].len; - dev_vdbg(echan->vchan.chan.device->dev, + dev_vdbg(dev, "\n pset[%d]:\n" " chnum\t%d\n" " slot\t%d\n" @@ -1828,7 +1828,6 @@ err_no_chan: static void edma_free_chan_resources(struct dma_chan *chan) { struct edma_chan *echan = to_edma_chan(chan); - struct device *dev = chan->device->dev; int i; /* Terminate transfers */ @@ -1850,7 +1849,7 @@ static void edma_free_chan_resources(struct dma_chan *chan) echan->alloced = false; } - dev_dbg(dev, "freeing channel for %u\n", echan->ch_num); + dev_dbg(chan->device->dev, "freeing channel for %u\n", echan->ch_num); } /* Send pending descriptor to hardware */ @@ -2174,13 +2173,13 @@ static int edma_probe(struct platform_device *pdev) return ret; } - ret = dma_set_mask_and_coherent(>dev, DMA_BIT_MASK(32)); + ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32)); if (ret) return ret; - ecc = devm_kzalloc(>dev, sizeof(*ecc), GFP_KERNEL); + ecc = devm_kzalloc(dev, sizeof(*ecc), GFP_KERNEL); if (!ecc) { - dev_err(>dev, "Can't allocate controller\n"); + dev_err(dev, "Can't allocate controller\n"); return -ENOMEM; } @@ -2324,7 +2323,7 @@ static int edma_probe(struct platform_device *pdev) ecc->dummy_slot = edma_alloc_slot(ecc, EDMA_SLOT_ANY); if (ecc->dummy_slot < 0) { - dev_err(>dev, "Can't allocate PaRAM dummy slot\n"); + dev_err(dev, "Can't allocate PaRAM dummy slot\n"); return ecc->dummy_slot; } @@ -2333,7 +2332,7 @@ static int edma_probe(struct platform_device *pdev) dma_cap_set(DMA_CYCLIC, ecc->dma_slave.cap_mask); dma_cap_set(DMA_MEMCPY, ecc->dma_slave.cap_mask); - edma_dma_init(ecc, >dma_slave, >dev); + edma_dma_init(ecc, >dma_slave, dev); edma_chan_init(ecc, >dma_slave, ecc->slave_chans); @@ -2345,7 +2344,7 @@ static int edma_probe(struct platform_device *pdev) of_dma_controller_register(node, of_dma_xlate_by_chan_id, >dma_slave); - dev_info(>dev, "TI EDMA DMA engine driver\n"); + dev_info(dev, "TI EDMA DMA engine driver\n"); return 0; @@ -2359,8 +2358,8 @@ static int edma_remove(struct platform_device *pdev) struct device *dev = >dev; struct edma_cc *ecc = dev_get_drvdata(dev); - if (pdev->dev.of_node) - of_dma_controller_free(pdev->dev.of_node); + if (dev->of_node) + of_dma_controller_free(dev->of_node); dma_async_device_unregister(>dma_slave); edma_free_slot(ecc, ecc->dummy_slot); -- 2.5.2 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 13/24] dmaengine: edma: Use devm_kcalloc when possible
When allocating a memory for number of items it is better (looks better) to use devm_kcalloc. Signed-off-by: Peter Ujfalusi--- drivers/dma/edma.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/dma/edma.c b/drivers/dma/edma.c index 46c0cbf1fe20..f5010c8f6273 100644 --- a/drivers/dma/edma.c +++ b/drivers/dma/edma.c @@ -2034,7 +2034,7 @@ static int edma_setup_from_hw(struct device *dev, struct edma_soc_info *pdata, * priority. So Q0 is the highest priority queue and the last queue has * the lowest priority. */ - queue_priority_map = devm_kzalloc(dev, (ecc->num_tc + 1) * sizeof(s8), + queue_priority_map = devm_kcalloc(dev, ecc->num_tc + 1, sizeof(s8), GFP_KERNEL); if (!queue_priority_map) return -ENOMEM; @@ -2065,7 +2065,7 @@ static int edma_xbar_event_map(struct device *dev, struct edma_soc_info *pdata, u32 shift, offset, mux; int ret, i; - xbar_chans = devm_kzalloc(dev, (nelm + 2) * sizeof(s16), GFP_KERNEL); + xbar_chans = devm_kcalloc(dev, nelm + 2, sizeof(s16), GFP_KERNEL); if (!xbar_chans) return -ENOMEM; -- 2.5.2 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 16/24] dmaengine: edma: Use the edma_write_slot instead open coded memcpy_toio
edma_write_slot() is for writing an entire paRAM slot. Signed-off-by: Peter Ujfalusi--- drivers/dma/edma.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/dma/edma.c b/drivers/dma/edma.c index fe8cde21b497..d759abc80bef 100644 --- a/drivers/dma/edma.c +++ b/drivers/dma/edma.c @@ -949,8 +949,7 @@ static void edma_free_channel(struct edma_cc *ecc, unsigned channel) edma_setup_interrupt(ecc, channel, NULL, NULL); /* REVISIT should probably take out of shadow region 0 */ - memcpy_toio(ecc->base + PARM_OFFSET(channel), _paramset, - PARM_SIZE); + edma_write_slot(ecc, channel, _paramset); clear_bit(channel, ecc->edma_inuse); } -- 2.5.2 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 15/24] dmaengine: edma: Use dev_dbg instead pr_debug
We have access to dev, so it is better to use the dev_dbg for debug prints. Signed-off-by: Peter Ujfalusi--- drivers/dma/edma.c | 22 +++--- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/dma/edma.c b/drivers/dma/edma.c index 2332142c36db..fe8cde21b497 100644 --- a/drivers/dma/edma.c +++ b/drivers/dma/edma.c @@ -655,14 +655,14 @@ static int edma_start(struct edma_cc *ecc, unsigned channel) /* EDMA channels without event association */ if (test_bit(channel, ecc->edma_unused)) { - pr_debug("EDMA: ESR%d %08x\n", j, -edma_shadow0_read_array(ecc, SH_ESR, j)); + dev_dbg(ecc->dev, "ESR%d %08x\n", j, + edma_shadow0_read_array(ecc, SH_ESR, j)); edma_shadow0_write_array(ecc, SH_ESR, j, mask); return 0; } /* EDMA channel with event association */ - pr_debug("EDMA: ER%d %08x\n", j, + dev_dbg(ecc->dev, "ER%d %08x\n", j, edma_shadow0_read_array(ecc, SH_ER, j)); /* Clear any pending event or error */ edma_write_array(ecc, EDMA_ECR, j, mask); @@ -670,8 +670,8 @@ static int edma_start(struct edma_cc *ecc, unsigned channel) /* Clear any SER */ edma_shadow0_write_array(ecc, SH_SECR, j, mask); edma_shadow0_write_array(ecc, SH_EESR, j, mask); - pr_debug("EDMA: EER%d %08x\n", j, -edma_shadow0_read_array(ecc, SH_EER, j)); + dev_dbg(ecc->dev, "EER%d %08x\n", j, + edma_shadow0_read_array(ecc, SH_EER, j)); return 0; } @@ -709,8 +709,8 @@ static void edma_stop(struct edma_cc *ecc, unsigned channel) /* clear possibly pending completion interrupt */ edma_shadow0_write_array(ecc, SH_ICR, j, mask); - pr_debug("EDMA: EER%d %08x\n", j, -edma_shadow0_read_array(ecc, SH_EER, j)); + dev_dbg(ecc->dev, "EER%d %08x\n", j, + edma_shadow0_read_array(ecc, SH_EER, j)); /* REVISIT: consider guarding against inappropriate event * chaining by overwriting with dummy_paramset. @@ -779,8 +779,8 @@ static int edma_trigger_channel(struct edma_cc *ecc, unsigned channel) edma_shadow0_write_array(ecc, SH_ESR, (channel >> 5), mask); - pr_debug("EDMA: ESR%d %08x\n", (channel >> 5), -edma_shadow0_read_array(ecc, SH_ESR, (channel >> 5))); + dev_dbg(ecc->dev, "ESR%d %08x\n", (channel >> 5), + edma_shadow0_read_array(ecc, SH_ESR, (channel >> 5))); return 0; } @@ -810,8 +810,8 @@ static void edma_clean_channel(struct edma_cc *ecc, unsigned channel) int j = (channel >> 5); unsigned int mask = BIT(channel & 0x1f); - pr_debug("EDMA: EMR%d %08x\n", j, -edma_read_array(ecc, EDMA_EMR, j)); + dev_dbg(ecc->dev, "EMR%d %08x\n", j, + edma_read_array(ecc, EDMA_EMR, j)); edma_shadow0_write_array(ecc, SH_ECR, j, mask); /* Clear the corresponding EMR bits */ edma_write_array(ecc, EDMA_EMCR, j, mask); -- 2.5.2 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 07/24] ARM/dmaengine: edma: Public API to use private struct pointer
Instead of relying on indexes pointing to edma private date in the global pointer array, pass the private data pointer via the public API. Signed-off-by: Peter Ujfalusi--- arch/arm/common/edma.c | 305 ++--- drivers/dma/edma.c | 79 +- include/linux/platform_data/edma.h | 38 +++-- 3 files changed, 214 insertions(+), 208 deletions(-) diff --git a/arch/arm/common/edma.c b/arch/arm/common/edma.c index 0b4c0ee59ed9..03692520812a 100644 --- a/arch/arm/common/edma.c +++ b/arch/arm/common/edma.c @@ -130,7 +130,7 @@ struct edma { struct edma_soc_info *info; int id; - + boolunused_chan_list_done; /* The edma_inuse bit for each PaRAM slot is clear unless the * channel is in use ... by ARM or DSP, for QDMA, or whatever. */ @@ -264,7 +264,6 @@ static inline void clear_bits(int offset, int len, unsigned long *p) } /*/ -static struct edma *edma_cc[EDMA_MAX_CC]; static int arch_num_cc; /* dummy param set used to (re)initialize parameter RAM slots */ @@ -490,14 +489,18 @@ static irqreturn_t dma_ccerr_handler(int irq, void *data) static int prepare_unused_channel_list(struct device *dev, void *data) { struct platform_device *pdev = to_platform_device(dev); - int i, count, ctlr; + struct edma *cc = data; + int i, count; struct of_phandle_args dma_spec; if (dev->of_node) { + struct platform_device *dma_pdev; + count = of_property_count_strings(dev->of_node, "dma-names"); if (count < 0) return 0; for (i = 0; i < count; i++) { + if (of_parse_phandle_with_args(dev->of_node, "dmas", "#dma-cells", i, _spec)) @@ -508,8 +511,12 @@ static int prepare_unused_channel_list(struct device *dev, void *data) continue; } + dma_pdev = of_find_device_by_node(dma_spec.np); + if (_pdev->dev != cc->dev) + continue; + clear_bit(EDMA_CHAN_SLOT(dma_spec.args[0]), - edma_cc[0]->edma_unused); + cc->edma_unused); of_node_put(dma_spec.np); } return 0; @@ -517,11 +524,11 @@ static int prepare_unused_channel_list(struct device *dev, void *data) /* For non-OF case */ for (i = 0; i < pdev->num_resources; i++) { - if ((pdev->resource[i].flags & IORESOURCE_DMA) && - (int)pdev->resource[i].start >= 0) { - ctlr = EDMA_CTLR(pdev->resource[i].start); + struct resource *res = >resource[i]; + + if ((res->flags & IORESOURCE_DMA) && (int)res->start >= 0) { clear_bit(EDMA_CHAN_SLOT(pdev->resource[i].start), - edma_cc[ctlr]->edma_unused); + cc->edma_unused); } } @@ -530,8 +537,6 @@ static int prepare_unused_channel_list(struct device *dev, void *data) /*---*/ -static bool unused_chan_list_done; - /* Resource alloc/free: dma channels, parameter RAM slots */ /** @@ -564,77 +569,73 @@ static bool unused_chan_list_done; * * Returns the number of the channel, else negative errno. */ -int edma_alloc_channel(int channel, +int edma_alloc_channel(struct edma *cc, int channel, void (*callback)(unsigned channel, u16 ch_status, void *data), void *data, enum dma_event_q eventq_no) { - unsigned i, done = 0, ctlr = 0; + unsigned done = 0; int ret = 0; - if (!unused_chan_list_done) { + if (!cc->unused_chan_list_done) { /* * Scan all the platform devices to find out the EDMA channels * used and clear them in the unused list, making the rest * available for ARM usage. */ - ret = bus_for_each_dev(_bus_type, NULL, NULL, - prepare_unused_channel_list); + ret = bus_for_each_dev(_bus_type, NULL, cc, + prepare_unused_channel_list); if (ret < 0) return ret; - unused_chan_list_done = true; + cc->unused_chan_list_done = true; } if (channel >= 0) { - ctlr = EDMA_CTLR(channel); + if (cc->id != EDMA_CTLR(channel)) { +
[PATCH v3 17/24] dmaengine: edma: Print warning when linking slots from different eDMA
Warning message in case of linking between paRAM slots in different eDMA controllers. Signed-off-by: Peter Ujfalusi--- drivers/dma/edma.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/dma/edma.c b/drivers/dma/edma.c index d759abc80bef..b0102984e98d 100644 --- a/drivers/dma/edma.c +++ b/drivers/dma/edma.c @@ -598,6 +598,9 @@ static void edma_free_slot(struct edma_cc *ecc, unsigned slot) */ static void edma_link(struct edma_cc *ecc, unsigned from, unsigned to) { + if (unlikely(EDMA_CTLR(from) != EDMA_CTLR(to))) + dev_warn(ecc->dev, "Ignoring eDMA instance for linking\n"); + from = EDMA_CHAN_SLOT(from); to = EDMA_CHAN_SLOT(to); if (from >= ecc->num_slots || to >= ecc->num_slots) -- 2.5.2 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 00/38] Fixes related to incorrect usage of unsigned types
On 09/22/2015 11:13 AM, Andrzej Hajda wrote: On 09/21/2015 03:42 PM, David Howells wrote: Andrzej Hajdawrote: Semantic patch finds comparisons of types: unsigned < 0 unsigned >= 0 The former is always false, the latter is always true. Such comparisons are useless, so theoretically they could be safely removed, but their presence quite often indicates bugs. Or someone has left them in because they don't matter and there's the possibility that the type being tested might be or become signed under some circumstances. If the comparison is useless, I'd expect the compiler to just discard it - for such cases your patch is pointless. If I have, for example: unsigned x; if (x == 0 || x > 27) give_a_range_error(); I will write this as: unsigned x; if (x <= 0 || x > 27) give_a_range_error(); because it that gives a way to handle x being changed to signed at some point in the future for no cost. In which case, your changing the <= to an == "because the < part of the case is useless" is arguably wrong. This is why I have not checked for such cases - I have skipped checks of type unsigned <= 0 exactly for the reasons above. However I have left two other checks as they seems to me more suspicious - they are always true or false. But as Dmitry and Andrew pointed out Linus have quite strong opinion against removing range checks in such cases as he finds it clearer. I think it applies to patches 29-36. I am not sure about patches 26-28,37. Dropped 30/38 and 31/38 from LED tree then. -- Best Regards, Jacek Anaszewski -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 10/24] ARM: davinci: Add set dma_mask to eDMA devices
The upcoming change to merge the arch/arm/common/edma.c into drivers/dma/edma.c will need this change when booting daVinci devices in no DT mode. Signed-off-by: Peter Ujfalusi--- arch/arm/Kconfig |1 - arch/arm/common/Kconfig |3 - arch/arm/common/Makefile |1 - arch/arm/common/edma.c| 1431 arch/arm/mach-davinci/devices-da8xx.c |2 + arch/arm/mach-davinci/dm355.c |1 + arch/arm/mach-davinci/dm644x.c|1 + arch/arm/mach-davinci/dm646x.c|1 + arch/arm/mach-omap2/Kconfig |1 - drivers/dma/Kconfig |1 - drivers/dma/edma.c| 1447 +++-- include/linux/platform_data/edma.h| 74 -- 12 files changed, 1394 insertions(+), 1570 deletions(-) delete mode 100644 arch/arm/common/edma.c diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 471a3670cd3e..704e4ab6d552 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -714,7 +714,6 @@ config ARCH_DAVINCI select GENERIC_CLOCKEVENTS select GENERIC_IRQ_CHIP select HAVE_IDE - select TI_PRIV_EDMA select USE_OF select ZONE_DMA help diff --git a/arch/arm/common/Kconfig b/arch/arm/common/Kconfig index c3a4e9ceba34..9353184d730d 100644 --- a/arch/arm/common/Kconfig +++ b/arch/arm/common/Kconfig @@ -17,6 +17,3 @@ config SHARP_PARAM config SHARP_SCOOP bool - -config TI_PRIV_EDMA - bool diff --git a/arch/arm/common/Makefile b/arch/arm/common/Makefile index 6ee5959a813b..27f23b15b1ea 100644 --- a/arch/arm/common/Makefile +++ b/arch/arm/common/Makefile @@ -15,6 +15,5 @@ obj-$(CONFIG_MCPM)+= mcpm_head.o mcpm_entry.o mcpm_platsmp.o vlock.o CFLAGS_REMOVE_mcpm_entry.o = -pg AFLAGS_mcpm_head.o := -march=armv7-a AFLAGS_vlock.o := -march=armv7-a -obj-$(CONFIG_TI_PRIV_EDMA) += edma.o obj-$(CONFIG_BL_SWITCHER) += bL_switcher.o obj-$(CONFIG_BL_SWITCHER_DUMMY_IF) += bL_switcher_dummy_if.o diff --git a/arch/arm/common/edma.c b/arch/arm/common/edma.c deleted file mode 100644 index 5b747f1bc8b5.. --- a/arch/arm/common/edma.c +++ /dev/null @@ -1,1431 +0,0 @@ -/* - * EDMA3 support for DaVinci - * - * Copyright (C) 2006-2009 Texas Instruments. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -/* Offsets matching "struct edmacc_param" */ -#define PARM_OPT 0x00 -#define PARM_SRC 0x04 -#define PARM_A_B_CNT 0x08 -#define PARM_DST 0x0c -#define PARM_SRC_DST_BIDX 0x10 -#define PARM_LINK_BCNTRLD 0x14 -#define PARM_SRC_DST_CIDX 0x18 -#define PARM_CCNT 0x1c - -#define PARM_SIZE 0x20 - -/* Offsets for EDMA CC global channel registers and their shadows */ -#define SH_ER 0x00/* 64 bits */ -#define SH_ECR 0x08/* 64 bits */ -#define SH_ESR 0x10/* 64 bits */ -#define SH_CER 0x18/* 64 bits */ -#define SH_EER 0x20/* 64 bits */ -#define SH_EECR0x28/* 64 bits */ -#define SH_EESR0x30/* 64 bits */ -#define SH_SER 0x38/* 64 bits */ -#define SH_SECR0x40/* 64 bits */ -#define SH_IER 0x50/* 64 bits */ -#define SH_IECR0x58/* 64 bits */ -#define SH_IESR0x60/* 64 bits */ -#define SH_IPR 0x68/* 64 bits */ -#define SH_ICR 0x70/* 64 bits */ -#define SH_IEVAL 0x78 -#define SH_QER 0x80 -#define SH_QEER0x84 -#define SH_QEECR 0x88 -#define SH_QEESR 0x8c -#define SH_QSER0x90 -#define SH_QSECR 0x94 -#define SH_SIZE0x200 - -/* Offsets for EDMA CC global registers */ -#define EDMA_REV 0x -#define EDMA_CCCFG 0x0004 -#define EDMA_QCHMAP0x0200 /* 8 registers */ -#define EDMA_DMAQNUM 0x0240 /* 8 registers (4 on OMAP-L1xx) */ -#define EDMA_QDMAQNUM 0x0260 -#define EDMA_QUETCMAP 0x0280 -#define EDMA_QUEPRI0x0284
[PATCH v3 22/24] dmaengine: edma: Read channel mapping support only once from HW
Instead of directly reading it from CCCFG register take the information out once when we set up the configuration from the HW. Signed-off-by: Peter Ujfalusi--- drivers/dma/edma.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/dma/edma.c b/drivers/dma/edma.c index c8350248c0c6..a818d2bf8709 100644 --- a/drivers/dma/edma.c +++ b/drivers/dma/edma.c @@ -223,6 +223,7 @@ struct edma_cc { unsignednum_region; unsignednum_slots; unsignednum_tc; + boolchmap_exist; enum dma_event_qdefault_queue; boolunused_chan_list_done; @@ -1904,11 +1905,14 @@ static int edma_setup_from_hw(struct device *dev, struct edma_soc_info *pdata, value = GET_NUM_EVQUE(cccfg); ecc->num_tc = value + 1; + ecc->chmap_exist = (cccfg & CHMAP_EXIST) ? true : false; + dev_dbg(dev, "eDMA3 CC HW configuration (cccfg: 0x%08x):\n", cccfg); dev_dbg(dev, "num_region: %u\n", ecc->num_region); dev_dbg(dev, "num_channels: %u\n", ecc->num_channels); dev_dbg(dev, "num_slots: %u\n", ecc->num_slots); dev_dbg(dev, "num_tc: %u\n", ecc->num_tc); + dev_dbg(dev, "chmap_exist: %s\n", ecc->chmap_exist ? "yes" : "no"); /* Nothing need to be done if queue priority is provided */ if (pdata->queue_priority_mapping) @@ -2197,7 +2201,7 @@ static int edma_probe(struct platform_device *pdev) queue_priority_mapping[i][1]); /* Map the channel to param entry if channel mapping logic exist */ - if (edma_read(ecc, EDMA_CCCFG) & CHMAP_EXIST) + if (ecc->chmap_exist) edma_direct_dmach_to_param_mapping(ecc); for (i = 0; i < ecc->num_region; i++) { @@ -2267,7 +2271,7 @@ static int edma_pm_resume(struct device *dev) queue_priority_mapping[i][1]); /* Map the channel to param entry if channel mapping logic */ - if (edma_read(ecc, EDMA_CCCFG) & CHMAP_EXIST) + if (ecc->chmap_exist) edma_direct_dmach_to_param_mapping(ecc); for (i = 0; i < ecc->num_channels; i++) { -- 2.5.2 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 20/24] dmaengine: edma: Move the pending error check into helper function
In the ccerr interrupt handler the code checks for pending errors in the error status registers in two different places. Move the check out to a helper function. Signed-off-by: Peter Ujfalusi--- drivers/dma/edma.c | 20 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/dma/edma.c b/drivers/dma/edma.c index 03f411cc900b..30e3c54d86e3 100644 --- a/drivers/dma/edma.c +++ b/drivers/dma/edma.c @@ -1608,6 +1608,16 @@ static void edma_error_handler(struct edma_chan *echan) spin_unlock(>vchan.lock); } +static inline bool edma_error_pending(struct edma_cc *ecc) +{ + if (edma_read_array(ecc, EDMA_EMR, 0) || + edma_read_array(ecc, EDMA_EMR, 1) || + edma_read(ecc, EDMA_QEMR) || edma_read(ecc, EDMA_CCERR)) + return true; + + return false; +} + /* eDMA error interrupt handler */ static irqreturn_t dma_ccerr_handler(int irq, void *data) { @@ -1622,10 +1632,7 @@ static irqreturn_t dma_ccerr_handler(int irq, void *data) dev_dbg(ecc->dev, "dma_ccerr_handler\n"); - if ((edma_read_array(ecc, EDMA_EMR, 0) == 0) && - (edma_read_array(ecc, EDMA_EMR, 1) == 0) && - (edma_read(ecc, EDMA_QEMR) == 0) && - (edma_read(ecc, EDMA_CCERR) == 0)) + if (!edma_error_pending(ecc)) return IRQ_NONE; while (1) { @@ -1678,10 +1685,7 @@ static irqreturn_t dma_ccerr_handler(int irq, void *data) } } } - if ((edma_read_array(ecc, EDMA_EMR, 0) == 0) && - (edma_read_array(ecc, EDMA_EMR, 1) == 0) && - (edma_read(ecc, EDMA_QEMR) == 0) && - (edma_read(ecc, EDMA_CCERR) == 0)) + if (!edma_error_pending(ecc)) break; cnt++; if (cnt > 10) -- 2.5.2 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 18/24] dmaengine: edma: Consolidate the comments for functions
Remove or rewrite the comments for the internal functions. Signed-off-by: Peter Ujfalusi--- drivers/dma/edma.c | 86 +++--- 1 file changed, 11 insertions(+), 75 deletions(-) diff --git a/drivers/dma/edma.c b/drivers/dma/edma.c index b0102984e98d..d872efed0760 100644 --- a/drivers/dma/edma.c +++ b/drivers/dma/edma.c @@ -486,19 +486,7 @@ static void edma_setup_interrupt(struct edma_cc *ecc, unsigned lch, } /* - * paRAM management functions - */ - -/** - * edma_write_slot - write parameter RAM data for slot - * @ecc: pointer to edma_cc struct - * @slot: number of parameter RAM slot being modified - * @param: data to be written into parameter RAM slot - * - * Use this to assign all parameters of a transfer at once. This - * allows more efficient setup of transfers than issuing multiple - * calls to set up those parameters in small pieces, and provides - * complete control over all transfer options. + * paRAM slot management functions */ static void edma_write_slot(struct edma_cc *ecc, unsigned slot, const struct edmacc_param *param) @@ -509,15 +497,6 @@ static void edma_write_slot(struct edma_cc *ecc, unsigned slot, memcpy_toio(ecc->base + PARM_OFFSET(slot), param, PARM_SIZE); } -/** - * edma_read_slot - read parameter RAM data from slot - * @ecc: pointer to edma_cc struct - * @slot: number of parameter RAM slot being copied - * @param: where to store copy of parameter RAM data - * - * Use this to read data from a parameter RAM slot, perhaps to - * save them as a template for later reuse. - */ static void edma_read_slot(struct edma_cc *ecc, unsigned slot, struct edmacc_param *param) { @@ -568,15 +547,6 @@ static int edma_alloc_slot(struct edma_cc *ecc, int slot) return EDMA_CTLR_CHAN(ecc->id, slot); } -/** - * edma_free_slot - deallocate DMA parameter RAM - * @ecc: pointer to edma_cc struct - * @slot: parameter RAM slot returned from edma_alloc_slot() - * - * This deallocates the parameter RAM slot allocated by edma_alloc_slot(). - * Callers are responsible for ensuring the slot is inactive, and will - * not be activated. - */ static void edma_free_slot(struct edma_cc *ecc, unsigned slot) { @@ -686,10 +656,9 @@ static int edma_start(struct edma_cc *ecc, unsigned channel) * @ecc: pointer to edma_cc struct * @channel: channel being deactivated * - * When @lch is a channel, any active transfer is paused and - * all pending hardware events are cleared. The current transfer - * may not be resumed, and the channel's Parameter RAM should be - * reinitialized before being reused. + * Any active transfer is paused and all pending hardware events are cleared. + * The current transfer may not be resumed, and the channel's Parameter RAM + * should be reinitialized before being reused. */ static void edma_stop(struct edma_cc *ecc, unsigned channel) { @@ -721,13 +690,9 @@ static void edma_stop(struct edma_cc *ecc, unsigned channel) } } -/** - * edma_pause - pause dma on a channel - * @ecc: pointer to edma_cc struct - * @channel: on which edma_start() has been called - * - * This temporarily disables EDMA hardware events on the specified channel, - * preventing them from triggering new transfers on its behalf +/* + * Temporarily disable EDMA hardware events on the specified channel, + * preventing them from triggering new transfers */ static void edma_pause(struct edma_cc *ecc, unsigned channel) { @@ -745,13 +710,7 @@ static void edma_pause(struct edma_cc *ecc, unsigned channel) } } -/** - * edma_resume - resumes dma on a paused channel - * @ecc: pointer to edma_cc struct - * @channel: on which edma_pause() has been called - * - * This re-enables EDMA hardware events on the specified channel. - */ +/* Re-enable EDMA hardware events on the specified channel. */ static void edma_resume(struct edma_cc *ecc, unsigned channel) { if (ecc->id != EDMA_CTLR(channel)) { @@ -787,19 +746,6 @@ static int edma_trigger_channel(struct edma_cc *ecc, unsigned channel) return 0; } -/** - * - * It cleans ParamEntry qand bring back EDMA to initial state if media has - * been removed before EDMA has finished.It is usedful for removable media. - * Arguments: - * ch_no - channel no - * - * Return: zero on success, or corresponding error no on failure - * - * FIXME this should not be needed ... edma_stop() should suffice. - * - */ - static void edma_clean_channel(struct edma_cc *ecc, unsigned channel) { if (ecc->id != EDMA_CTLR(channel)) { @@ -956,14 +902,7 @@ static void edma_free_channel(struct edma_cc *ecc, unsigned channel) clear_bit(channel, ecc->edma_inuse); } -/* - * edma_assign_channel_eventq - move given channel to desired eventq -
[PATCH v3 23/24] dmaengine: edma: Rename bitfields for slot and channel usage tracking
The names chosen for the bitfields were quite confusing and given no real information on what they are used for... edma_inuse -> slot_inuse: tracks the slot usage/availability edma_unused -> channel_unused: tracks the channel usage/availability Signed-off-by: Peter Ujfalusi--- drivers/dma/edma.c | 48 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/drivers/dma/edma.c b/drivers/dma/edma.c index a818d2bf8709..a30f6ae69bff 100644 --- a/drivers/dma/edma.c +++ b/drivers/dma/edma.c @@ -227,16 +227,16 @@ struct edma_cc { enum dma_event_qdefault_queue; boolunused_chan_list_done; - /* The edma_inuse bit for each PaRAM slot is clear unless the + /* The slot_inuse bit for each PaRAM slot is clear unless the * channel is in use ... by ARM or DSP, for QDMA, or whatever. */ - unsigned long *edma_inuse; + unsigned long *slot_inuse; - /* The edma_unused bit for each channel is clear unless + /* The channel_unused bit for each channel is clear unless * it is not being used on this platform. It uses a bit * of SOC-specific initialization code. */ - unsigned long *edma_unused; + unsigned long *channel_unused; struct dma_device dma_slave; struct edma_chan*slave_chans; @@ -430,7 +430,7 @@ static int prepare_unused_channel_list(struct device *dev, void *data) continue; clear_bit(EDMA_CHAN_SLOT(dma_spec.args[0]), - ecc->edma_unused); + ecc->channel_unused); of_node_put(dma_spec.np); } return 0; @@ -447,7 +447,7 @@ static int prepare_unused_channel_list(struct device *dev, void *data) dma_req = (int)res->start; if (dma_req >= dma_req_min && dma_req < dma_req_max) clear_bit(EDMA_CHAN_SLOT(pdev->resource[i].start), - ecc->edma_unused); + ecc->channel_unused); } return 0; @@ -511,17 +511,17 @@ static int edma_alloc_slot(struct edma_cc *ecc, int slot) if (slot < 0) { slot = ecc->num_channels; for (;;) { - slot = find_next_zero_bit(ecc->edma_inuse, + slot = find_next_zero_bit(ecc->slot_inuse, ecc->num_slots, slot); if (slot == ecc->num_slots) return -ENOMEM; - if (!test_and_set_bit(slot, ecc->edma_inuse)) + if (!test_and_set_bit(slot, ecc->slot_inuse)) break; } } else if (slot < ecc->num_channels || slot >= ecc->num_slots) { return -EINVAL; - } else if (test_and_set_bit(slot, ecc->edma_inuse)) { + } else if (test_and_set_bit(slot, ecc->slot_inuse)) { return -EBUSY; } @@ -538,7 +538,7 @@ static void edma_free_slot(struct edma_cc *ecc, unsigned slot) return; edma_write_slot(ecc, slot, _paramset); - clear_bit(slot, ecc->edma_inuse); + clear_bit(slot, ecc->slot_inuse); } /** @@ -610,7 +610,7 @@ static int edma_start(struct edma_cc *ecc, unsigned channel) unsigned int mask = BIT(channel & 0x1f); /* EDMA channels without event association */ - if (test_bit(channel, ecc->edma_unused)) { + if (test_bit(channel, ecc->channel_unused)) { dev_dbg(ecc->dev, "ESR%d %08x\n", j, edma_shadow0_read_array(ecc, SH_ESR, j)); edma_shadow0_write_array(ecc, SH_ESR, j, mask); @@ -814,11 +814,11 @@ static int edma_alloc_channel(struct edma_cc *ecc, int channel, if (channel < 0) { channel = 0; for (;;) { - channel = find_next_bit(ecc->edma_unused, + channel = find_next_bit(ecc->channel_unused, ecc->num_channels, channel); if (channel == ecc->num_channels) break; - if (!test_and_set_bit(channel, ecc->edma_inuse)) { + if (!test_and_set_bit(channel, ecc->slot_inuse)) { done = 1; break; } @@ -828,7 +828,7 @@ static int edma_alloc_channel(struct edma_cc *ecc, int channel, return -ENOMEM; } else if (channel >= ecc->num_channels) {
[PATCH v3 21/24] dmaengine: edma: Simplify and optimize ccerr interrupt handler
No need to run through the bits in QEMR and CCERR events since they will not trigger any action, so just clearing the errors there is fine. In case of the missed event the loop can be optimized so we spend less time to handle the event. Signed-off-by: Peter Ujfalusi--- drivers/dma/edma.c | 64 -- 1 file changed, 23 insertions(+), 41 deletions(-) diff --git a/drivers/dma/edma.c b/drivers/dma/edma.c index 30e3c54d86e3..c8350248c0c6 100644 --- a/drivers/dma/edma.c +++ b/drivers/dma/edma.c @@ -1625,6 +1625,7 @@ static irqreturn_t dma_ccerr_handler(int irq, void *data) int i; int ctlr; unsigned int cnt = 0; + unsigned int val; ctlr = ecc->id; if (ctlr < 0) @@ -1637,54 +1638,35 @@ static irqreturn_t dma_ccerr_handler(int irq, void *data) while (1) { int j = -1; - if (edma_read_array(ecc, EDMA_EMR, 0)) + if ((val = edma_read_array(ecc, EDMA_EMR, 0))) j = 0; - else if (edma_read_array(ecc, EDMA_EMR, 1)) + else if ((val = edma_read_array(ecc, EDMA_EMR, 1))) j = 1; if (j >= 0) { - dev_dbg(ecc->dev, "EMR%d %08x\n", j, - edma_read_array(ecc, EDMA_EMR, j)); - for (i = 0; i < 32; i++) { + unsigned long emr = val; + + dev_dbg(ecc->dev, "EMR%d 0x%08x\n", j, val); + for (i = find_next_bit(, 32, 0); i < 32; +i = find_next_bit(, 32, i + 1)) { int k = (j << 5) + i; - if (edma_read_array(ecc, EDMA_EMR, j) & - BIT(i)) { - /* Clear the corresponding EMR bits */ - edma_write_array(ecc, EDMA_EMCR, j, + /* Clear the corresponding EMR bits */ + edma_write_array(ecc, EDMA_EMCR, j, BIT(i)); + /* Clear any SER */ + edma_shadow0_write_array(ecc, SH_SECR, j, BIT(i)); - /* Clear any SER */ - edma_shadow0_write_array(ecc, SH_SECR, - j, BIT(i)); - edma_error_handler(>slave_chans[k]); - } - } - } else if (edma_read(ecc, EDMA_QEMR)) { - dev_dbg(ecc->dev, "QEMR %02x\n", - edma_read(ecc, EDMA_QEMR)); - for (i = 0; i < 8; i++) { - if (edma_read(ecc, EDMA_QEMR) & BIT(i)) { - /* Clear the corresponding IPR bits */ - edma_write(ecc, EDMA_QEMCR, BIT(i)); - edma_shadow0_write(ecc, SH_QSECR, - BIT(i)); - - /* NOTE: not reported!! */ - } - } - } else if (edma_read(ecc, EDMA_CCERR)) { - dev_dbg(ecc->dev, "CCERR %08x\n", - edma_read(ecc, EDMA_CCERR)); - /* FIXME: CCERR.BIT(16) ignored! much better -* to just write CCERRCLR with CCERR value... -*/ - for (i = 0; i < 8; i++) { - if (edma_read(ecc, EDMA_CCERR) & BIT(i)) { - /* Clear the corresponding IPR bits */ - edma_write(ecc, EDMA_CCERRCLR, BIT(i)); - - /* NOTE: not reported!! */ - } + edma_error_handler(>slave_chans[k]); } + } else if ((val = edma_read(ecc, EDMA_QEMR))) { + dev_dbg(ecc->dev, "QEMR 0x%02x\n", val); + /* Not reported, just clear the interrupt reason. */ + edma_write(ecc, EDMA_QEMCR, val); + edma_shadow0_write(ecc, SH_QSECR, val); + } else if ((val = edma_read(ecc, EDMA_CCERR))) { + dev_warn(ecc->dev, "CCERR 0x%08x\n", val); + /* Not reported, just clear the interrupt reason. */ + edma_write(ecc, EDMA_CCERRCLR, val); } + if (!edma_error_pending(ecc)) break; cnt++;
[PATCH v3 00/24] dmaengine/ARM: Merge the edma drivers into one
Hi, Changes since v2: - devm_kasprintf format string fixed - Additional patch to enable dynamic paRAM slot usage when the channel mapping is supported by the eDMA module. On am335x we have 256 paRAM slots and 64 DMA channels, this means that we had 64 slots 'locked away' all the time. The dynamic paRAM slot logic will allow us to use all 256 slots freely for any purpose. Changes since v1: - Convert edma platform device registration to use platform_device_register_full - Moved the PM callback also to the dmaengine driver - missed in v1 - Commit message added to: ARM/dmaengine: edma: Remove limitation on the number of eDMA controllers - New patch which reads the flag for the channel mapping support in one place Cover letter: with this series the edma two driver setup will be changed to have only one driver to support eDMA3. The legacy edma interface will be removed and eDMA can only be used via dmaengine API from this point on. In order to do the merge the following improvements has been done: - One driver instance per eDMA: - Any number of eDMA instances are supported (both legacy and DT boot) - Not relying on global variables, arrays, etc - Code simplification and optimizations in several places This change will also help us to do bigger changes in the eDMA driver since, since now we have only one driver to work with. The series has been tested on: da850-evm (OMAP-L138) - with legacy and DT boot (both eDMA0 and eDMA1 is enabled) - In code swapping the eDMA instances in legacy mode to make sure the second instance is handled correctly. am335x-evmsk - DT boot I think this series could go via the dmaengine tree. Changes are trivial under arch/arm/ Regards, Peter --- Peter Ujfalusi (24): ARM: common: edma: Fix channel parameter for irq callbacks ARM: common: edma: Remove unused functions dmaengine: edma: Simplify and optimize the edma_execute path ARM: davinci/common: Convert edma driver to handle one eDMA instance per driver ARM/dmaengine: edma: Move of_dma_controller_register to the dmaengine driver ARM: common: edma: Internal API to use pointer to 'struct edma' ARM/dmaengine: edma: Public API to use private struct pointer ARM/dmaengine: edma: Remove limitation on the number of eDMA controllers ARM: davinci: Use platform_device_register_full() to create pdev for eDMA ARM: davinci: Add set dma_mask to eDMA devices dmaengine: edma: Allocate memory dynamically for bitmaps and structures dmaengine: edma: Parameter alignment and long line fixes dmaengine: edma: Use devm_kcalloc when possible dmaengine: edma: Cleanup regarding the use of dev around the code dmaengine: edma: Use dev_dbg instead pr_debug dmaengine: edma: Use the edma_write_slot instead open coded memcpy_toio dmaengine: edma: Print warning when linking slots from different eDMA dmaengine: edma: Consolidate the comments for functions dmaengine: edma: Simplify the interrupt handling dmaengine: edma: Move the pending error check into helper function dmaengine: edma: Simplify and optimize ccerr interrupt handler dmaengine: edma: Read channel mapping support only once from HW dmaengine: edma: Rename bitfields for slot and channel usage tracking dmaengine: edma: Dynamic paRAM slot handling if HW supports it arch/arm/Kconfig |1 - arch/arm/common/Kconfig |3 - arch/arm/common/Makefile |1 - arch/arm/common/edma.c| 1876 - arch/arm/mach-davinci/devices-da8xx.c | 122 +-- arch/arm/mach-davinci/dm355.c | 40 +- arch/arm/mach-davinci/dm365.c | 25 +- arch/arm/mach-davinci/dm644x.c| 40 +- arch/arm/mach-davinci/dm646x.c| 44 +- arch/arm/mach-omap2/Kconfig |1 - drivers/dma/Kconfig |1 - drivers/dma/edma.c| 1569 --- include/linux/platform_data/edma.h| 101 -- 13 files changed, 1523 insertions(+), 2301 deletions(-) delete mode 100644 arch/arm/common/edma.c -- 2.5.2 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 03/24] dmaengine: edma: Simplify and optimize the edma_execute path
The code path in edma_execute() and edma_callback() can be simplified and make it more optimal. There is not need to call in to edma_execute() when the transfer has been finished for example. Also the handling of missed/first or next batch of paRAMs can be done in a more optimal way. Signed-off-by: Peter Ujfalusi--- drivers/dma/edma.c | 76 +- 1 file changed, 29 insertions(+), 47 deletions(-) diff --git a/drivers/dma/edma.c b/drivers/dma/edma.c index 3e5d4f193005..19fa49d6f555 100644 --- a/drivers/dma/edma.c +++ b/drivers/dma/edma.c @@ -154,15 +154,11 @@ static void edma_execute(struct edma_chan *echan) struct device *dev = echan->vchan.chan.device->dev; int i, j, left, nslots; - /* If either we processed all psets or we're still not started */ - if (!echan->edesc || - echan->edesc->pset_nr == echan->edesc->processed) { - /* Get next vdesc */ + if (!echan->edesc) { + /* Setup is needed for the first transfer */ vdesc = vchan_next_desc(>vchan); - if (!vdesc) { - echan->edesc = NULL; + if (!vdesc) return; - } list_del(>node); echan->edesc = to_edma_desc(>tx); } @@ -220,28 +216,26 @@ static void edma_execute(struct edma_chan *echan) echan->ecc->dummy_slot); } - if (edesc->processed <= MAX_NR_SG) { - dev_dbg(dev, "first transfer starting on channel %d\n", - echan->ch_num); - edma_start(echan->ch_num); - } else { - dev_dbg(dev, "chan: %d: completed %d elements, resuming\n", - echan->ch_num, edesc->processed); - edma_resume(echan->ch_num); - } - - /* -* This happens due to setup times between intermediate transfers -* in long SG lists which have to be broken up into transfers of -* MAX_NR_SG -*/ if (echan->missed) { + /* +* This happens due to setup times between intermediate +* transfers in long SG lists which have to be broken up into +* transfers of MAX_NR_SG +*/ dev_dbg(dev, "missed event on channel %d\n", echan->ch_num); edma_clean_channel(echan->ch_num); edma_stop(echan->ch_num); edma_start(echan->ch_num); edma_trigger_channel(echan->ch_num); echan->missed = 0; + } else if (edesc->processed <= MAX_NR_SG) { + dev_dbg(dev, "first transfer starting on channel %d\n", + echan->ch_num); + edma_start(echan->ch_num); + } else { + dev_dbg(dev, "chan: %d: completed %d elements, resuming\n", + echan->ch_num, edesc->processed); + edma_resume(echan->ch_num); } } @@ -259,20 +253,17 @@ static int edma_terminate_all(struct dma_chan *chan) * echan->edesc is NULL and exit.) */ if (echan->edesc) { - int cyclic = echan->edesc->cyclic; - + edma_stop(echan->ch_num); + /* Move the cyclic channel back to default queue */ + if (echan->edesc->cyclic) + edma_assign_channel_eventq(echan->ch_num, + EVENTQ_DEFAULT); /* * free the running request descriptor * since it is not in any of the vdesc lists */ edma_desc_free(>edesc->vdesc); - echan->edesc = NULL; - edma_stop(echan->ch_num); - /* Move the cyclic channel back to default queue */ - if (cyclic) - edma_assign_channel_eventq(echan->ch_num, - EVENTQ_DEFAULT); } vchan_get_all_descriptors(>vchan, ); @@ -725,41 +716,33 @@ static void edma_callback(unsigned ch_num, u16 ch_status, void *data) edesc = echan->edesc; - /* Pause the channel for non-cyclic */ - if (!edesc || (edesc && !edesc->cyclic)) - edma_pause(echan->ch_num); - + spin_lock(>vchan.lock); switch (ch_status) { case EDMA_DMA_COMPLETE: - spin_lock(>vchan.lock); - if (edesc) { if (edesc->cyclic) { vchan_cyclic_callback(>vdesc); + goto out; } else if (edesc->processed == edesc->pset_nr) { dev_dbg(dev, "Transfer complete, stopping channel %d\n", ch_num); edesc->residue = 0;
[PATCH v3 02/24] ARM: common: edma: Remove unused functions
We no longer have users for these functions so they can be removed. Remove also unused enums from the header file. Signed-off-by: Peter Ujfalusi--- arch/arm/common/edma.c | 376 - include/linux/platform_data/edma.h | 33 2 files changed, 409 deletions(-) diff --git a/arch/arm/common/edma.c b/arch/arm/common/edma.c index 56fc339571f9..e9c4cb16a47e 100644 --- a/arch/arm/common/edma.c +++ b/arch/arm/common/edma.c @@ -510,62 +510,6 @@ static irqreturn_t dma_ccerr_handler(int irq, void *data) return IRQ_HANDLED; } -static int reserve_contiguous_slots(int ctlr, unsigned int id, -unsigned int num_slots, -unsigned int start_slot) -{ - int i, j; - unsigned int count = num_slots; - int stop_slot = start_slot; - DECLARE_BITMAP(tmp_inuse, EDMA_MAX_PARAMENTRY); - - for (i = start_slot; i < edma_cc[ctlr]->num_slots; ++i) { - j = EDMA_CHAN_SLOT(i); - if (!test_and_set_bit(j, edma_cc[ctlr]->edma_inuse)) { - /* Record our current beginning slot */ - if (count == num_slots) - stop_slot = i; - - count--; - set_bit(j, tmp_inuse); - - if (count == 0) - break; - } else { - clear_bit(j, tmp_inuse); - - if (id == EDMA_CONT_PARAMS_FIXED_EXACT) { - stop_slot = i; - break; - } else { - count = num_slots; - } - } - } - - /* -* We have to clear any bits that we set -* if we run out parameter RAM slots, i.e we do find a set -* of contiguous parameter RAM slots but do not find the exact number -* requested as we may reach the total number of parameter RAM slots -*/ - if (i == edma_cc[ctlr]->num_slots) - stop_slot = i; - - j = start_slot; - for_each_set_bit_from(j, tmp_inuse, stop_slot) - clear_bit(j, edma_cc[ctlr]->edma_inuse); - - if (count) - return -EBUSY; - - for (j = i - num_slots + 1; j <= i; ++j) - memcpy_toio(edmacc_regs_base[ctlr] + PARM_OFFSET(j), - _paramset, PARM_SIZE); - - return EDMA_CTLR_CHAN(ctlr, i - num_slots + 1); -} - static int prepare_unused_channel_list(struct device *dev, void *data) { struct platform_device *pdev = to_platform_device(dev); @@ -818,186 +762,11 @@ void edma_free_slot(unsigned slot) } EXPORT_SYMBOL(edma_free_slot); - -/** - * edma_alloc_cont_slots- alloc contiguous parameter RAM slots - * The API will return the starting point of a set of - * contiguous parameter RAM slots that have been requested - * - * @id: can only be EDMA_CONT_PARAMS_ANY or EDMA_CONT_PARAMS_FIXED_EXACT - * or EDMA_CONT_PARAMS_FIXED_NOT_EXACT - * @count: number of contiguous Paramter RAM slots - * @slot - the start value of Parameter RAM slot that should be passed if id - * is EDMA_CONT_PARAMS_FIXED_EXACT or EDMA_CONT_PARAMS_FIXED_NOT_EXACT - * - * If id is EDMA_CONT_PARAMS_ANY then the API starts looking for a set of - * contiguous Parameter RAM slots from parameter RAM 64 in the case of - * DaVinci SOCs and 32 in the case of DA8xx SOCs. - * - * If id is EDMA_CONT_PARAMS_FIXED_EXACT then the API starts looking for a - * set of contiguous parameter RAM slots from the "slot" that is passed as an - * argument to the API. - * - * If id is EDMA_CONT_PARAMS_FIXED_NOT_EXACT then the API initially tries - * starts looking for a set of contiguous parameter RAMs from the "slot" - * that is passed as an argument to the API. On failure the API will try to - * find a set of contiguous Parameter RAM slots from the remaining Parameter - * RAM slots - */ -int edma_alloc_cont_slots(unsigned ctlr, unsigned int id, int slot, int count) -{ - /* -* The start slot requested should be greater than -* the number of channels and lesser than the total number -* of slots -*/ - if ((id != EDMA_CONT_PARAMS_ANY) && - (slot < edma_cc[ctlr]->num_channels || - slot >= edma_cc[ctlr]->num_slots)) - return -EINVAL; - - /* -* The number of parameter RAM slots requested cannot be less than 1 -* and cannot be more than the number of slots minus the number of -* channels -*/ - if (count < 1 || count > - (edma_cc[ctlr]->num_slots - edma_cc[ctlr]->num_channels)) - return -EINVAL; - - switch (id) { - case EDMA_CONT_PARAMS_ANY: - return reserve_contiguous_slots(ctlr, id, count, -
[PATCH v3 05/24] ARM/dmaengine: edma: Move of_dma_controller_register to the dmaengine driver
If the of_dma_controller is registered in the non dmaengine driver we could have race condition: the of_dma_controller has been registered, but the dmaengine driver is not yet probed. Drivers requesting DMA channels during this window will fail since we do not yet have dmaengine drivers registered. Signed-off-by: Peter Ujfalusi--- arch/arm/common/edma.c | 10 -- drivers/dma/edma.c | 16 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/arch/arm/common/edma.c b/arch/arm/common/edma.c index 7c2fe527e53b..d82fceda13a3 100644 --- a/arch/arm/common/edma.c +++ b/arch/arm/common/edma.c @@ -29,7 +29,6 @@ #include #include #include -#include #include #include @@ -1191,10 +1190,6 @@ static int edma_of_parse_dt(struct device *dev, return ret; } -static struct of_dma_filter_info edma_filter_info = { - .filter_fn = edma_filter_fn, -}; - static struct edma_soc_info *edma_setup_info_from_dt(struct device *dev, struct device_node *node) { @@ -1209,11 +1204,6 @@ static struct edma_soc_info *edma_setup_info_from_dt(struct device *dev, if (ret) return ERR_PTR(ret); - dma_cap_set(DMA_SLAVE, edma_filter_info.dma_cap); - dma_cap_set(DMA_CYCLIC, edma_filter_info.dma_cap); - of_dma_controller_register(dev->of_node, of_dma_simple_xlate, - _filter_info); - return info; } #else diff --git a/drivers/dma/edma.c b/drivers/dma/edma.c index 19fa49d6f555..fcb4680efed7 100644 --- a/drivers/dma/edma.c +++ b/drivers/dma/edma.c @@ -25,6 +25,7 @@ #include #include #include +#include #include @@ -987,9 +988,14 @@ static void edma_dma_init(struct edma_cc *ecc, struct dma_device *dma, INIT_LIST_HEAD(>channels); } +static struct of_dma_filter_info edma_filter_info = { + .filter_fn = edma_filter_fn, +}; + static int edma_probe(struct platform_device *pdev) { struct edma_cc *ecc; + struct device_node *parent_node = pdev->dev.parent->of_node; int ret; ret = dma_set_mask_and_coherent(>dev, DMA_BIT_MASK(32)); @@ -1024,6 +1030,13 @@ static int edma_probe(struct platform_device *pdev) platform_set_drvdata(pdev, ecc); + if (parent_node) { + dma_cap_set(DMA_SLAVE, edma_filter_info.dma_cap); + dma_cap_set(DMA_CYCLIC, edma_filter_info.dma_cap); + of_dma_controller_register(parent_node, of_dma_simple_xlate, + _filter_info); + } + dev_info(>dev, "TI EDMA DMA engine driver\n"); return 0; @@ -1037,7 +1050,10 @@ static int edma_remove(struct platform_device *pdev) { struct device *dev = >dev; struct edma_cc *ecc = dev_get_drvdata(dev); + struct device_node *parent_node = pdev->dev.parent->of_node; + if (parent_node) + of_dma_controller_free(parent_node); dma_async_device_unregister(>dma_slave); edma_free_slot(ecc->dummy_slot); -- 2.5.2 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 01/24] ARM: common: edma: Fix channel parameter for irq callbacks
In case when the interrupt happened for the second eDMA the channel number was incorrectly passed to the client driver. Signed-off-by: Peter UjfalusiCC: --- arch/arm/common/edma.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/arm/common/edma.c b/arch/arm/common/edma.c index 873dbfcc7dc9..56fc339571f9 100644 --- a/arch/arm/common/edma.c +++ b/arch/arm/common/edma.c @@ -406,7 +406,8 @@ static irqreturn_t dma_irq_handler(int irq, void *data) BIT(slot)); if (edma_cc[ctlr]->intr_data[channel].callback) edma_cc[ctlr]->intr_data[channel].callback( - channel, EDMA_DMA_COMPLETE, + EDMA_CTLR_CHAN(ctlr, channel), + EDMA_DMA_COMPLETE, edma_cc[ctlr]->intr_data[channel].data); } } while (sh_ipr); @@ -460,7 +461,8 @@ static irqreturn_t dma_ccerr_handler(int irq, void *data) if (edma_cc[ctlr]->intr_data[k]. callback) { edma_cc[ctlr]->intr_data[k]. - callback(k, + callback( + EDMA_CTLR_CHAN(ctlr, k), EDMA_DMA_CC_ERROR, edma_cc[ctlr]->intr_data [k].data); -- 2.5.2 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 24/24] dmaengine: edma: Dynamic paRAM slot handling if HW supports it
If the eDMA3 has support for channel paRAM slot mapping we can utilize it to allocate slots on demand and save precious slots for real transfers. On am335x the eDMA has 64 channels which means we can unlock 64 paRAM slots out from the available 256. Signed-off-by: Peter Ujfalusi--- drivers/dma/edma.c | 96 +- 1 file changed, 51 insertions(+), 45 deletions(-) diff --git a/drivers/dma/edma.c b/drivers/dma/edma.c index a30f6ae69bff..3591bc2584e5 100644 --- a/drivers/dma/edma.c +++ b/drivers/dma/edma.c @@ -391,11 +391,13 @@ static void edma_assign_priority_to_queue(struct edma_cc *ecc, int queue_no, edma_modify(ecc, EDMA_QUEPRI, ~(0x7 << bit), ((priority & 0x7) << bit)); } -static void edma_direct_dmach_to_param_mapping(struct edma_cc *ecc) +static void edma_set_chmap(struct edma_cc *ecc, int channel, int slot) { - int i; - for (i = 0; i < ecc->num_channels; i++) - edma_write_array(ecc, EDMA_DCHMAP , i , (i << 5)); + if (ecc->chmap_exist) { + channel = EDMA_CHAN_SLOT(channel); + slot = EDMA_CHAN_SLOT(slot); + edma_write_array(ecc, EDMA_DCHMAP , channel , (slot << 5)); + } } static int prepare_unused_channel_list(struct device *dev, void *data) @@ -506,10 +508,18 @@ static void edma_read_slot(struct edma_cc *ecc, unsigned slot, */ static int edma_alloc_slot(struct edma_cc *ecc, int slot) { - if (slot > 0) + if (slot > 0) { slot = EDMA_CHAN_SLOT(slot); + /* Requesting entry paRAM slot for a HW triggered channel. */ + if (ecc->chmap_exist && slot < ecc->num_channels) + slot = EDMA_SLOT_ANY; + } + if (slot < 0) { - slot = ecc->num_channels; + if (ecc->chmap_exist) + slot = 0; + else + slot = ecc->num_channels; for (;;) { slot = find_next_zero_bit(ecc->slot_inuse, ecc->num_slots, @@ -519,7 +529,7 @@ static int edma_alloc_slot(struct edma_cc *ecc, int slot) if (!test_and_set_bit(slot, ecc->slot_inuse)) break; } - } else if (slot < ecc->num_channels || slot >= ecc->num_slots) { + } else if (slot >= ecc->num_slots) { return -EINVAL; } else if (test_and_set_bit(slot, ecc->slot_inuse)) { return -EBUSY; @@ -534,7 +544,7 @@ static void edma_free_slot(struct edma_cc *ecc, unsigned slot) { slot = EDMA_CHAN_SLOT(slot); - if (slot < ecc->num_channels || slot >= ecc->num_slots) + if (slot >= ecc->num_slots) return; edma_write_slot(ecc, slot, _paramset); @@ -785,7 +795,6 @@ static void edma_clean_channel(struct edma_cc *ecc, unsigned channel) static int edma_alloc_channel(struct edma_cc *ecc, int channel, enum dma_event_q eventq_no) { - unsigned done = 0; int ret = 0; if (!ecc->unused_chan_list_done) { @@ -812,24 +821,12 @@ static int edma_alloc_channel(struct edma_cc *ecc, int channel, } if (channel < 0) { - channel = 0; - for (;;) { - channel = find_next_bit(ecc->channel_unused, - ecc->num_channels, channel); - if (channel == ecc->num_channels) - break; - if (!test_and_set_bit(channel, ecc->slot_inuse)) { - done = 1; - break; - } - channel++; - } - if (!done) - return -ENOMEM; + channel = find_next_bit(ecc->channel_unused, ecc->num_channels, + 0); + if (channel == ecc->num_channels) + return -EBUSY; } else if (channel >= ecc->num_channels) { return -EINVAL; - } else if (test_and_set_bit(channel, ecc->slot_inuse)) { - return -EBUSY; } /* ensure access through shadow region 0 */ @@ -837,7 +834,6 @@ static int edma_alloc_channel(struct edma_cc *ecc, int channel, /* ensure no events are pending */ edma_stop(ecc, EDMA_CTLR_CHAN(ecc->id, channel)); - edma_write_slot(ecc, channel, _paramset); edma_setup_interrupt(ecc, EDMA_CTLR_CHAN(ecc->id, channel), true); @@ -876,7 +872,6 @@ static void edma_free_channel(struct edma_cc *ecc, unsigned channel) /* REVISIT should probably take out of shadow region 0 */ edma_write_slot(ecc, channel, _paramset); - clear_bit(channel, ecc->slot_inuse); } /* Move channel to a specific
Re: [PATCH 3/3] mfd: Add battery charger as subdevice to the tps65217.
Hi, On Tue, Sep 22, 2015 at 09:43:50AM +0200, Enric Balletbo Serra wrote: > 2015-09-20 6:19 GMT+02:00 Lee Jones: > > On Tue, 08 Sep 2015, Enric Balletbo i Serra wrote: > > > >> Add tps65217 battery charger subdevice. > >> > >> Signed-off-by: Enric Balletbo i Serra > >> --- > >> drivers/mfd/tps65217.c | 4 > >> 1 file changed, 4 insertions(+) > > > > Applied, thanks. > > > > Many thanks, any feedback about ? > > [PATCH 1/3] devicetree: Add TPS65217 charger binding > [PATCH 2/3] power_supply: Add support for tps65217-charger. > > Or should go through another tree ? Those go through my tree. I'm currently catching up with my backlog. I will have a look at these later. -- Sebastian signature.asc Description: Digital signature