dt-bindings: lgm-dma: Added intel,dma-sw-desc property.
Subsystems (2)
PATCH v2 1/3 dt-bindings: lgm-dma: Added intel,dma-sw-desc property.
If the intel,dma-sw-desc property is present, it indicates that the DMA driver is responsible for managing the DMA engine, including handing the DMA descriptors.
If this property is present, the system defaults to a mode where another hardware component takes control of the DMA engine. In this case, the hardware can generate and manage descriptors independently, without driver involvement.
This property only takes effect on HDMA(DMAV3x).
--- Documentation/devicetree/bindings/dma/intel,ldma.yaml | 6 ++++++ 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/dma/intel,ldma.yaml +6 -0
@@ -80,6 +80,12 @@ properties: if it is disabled, the DMA RX will still support programmable fixed burst size of 2,4,8,16. It only applies to RX DMA and memcopy DMA. + intel,dma-sw-desc: + type: boolean + description: + Indicates that the DMA driver should operate in software-managed mode. + If this property is not present, it implies that DMA descriptors are managed and generated by another hardware component that controls the DMA engine. + required: - compatible - reg
Signature · 1 line
2.43.5
PATCH v2 2/3 dmaengine: lgm-dma: splitting CDMA and HDMA functions.
To reduce functional complexity, CDMA and HDMA operations are split into separate files.
CDMA refers to the legacy DMAv22 that supports software-based management. In contrast, HDMA refers to DMAv3x and supports hardware-managed mode.
In HDMA hardware mode, the driver is only responsible for configuring the descriptor base address and descriptor length. The actual generation and updating of descriptors are handled by another hardware component without diver intervention.
--- drivers/dma/lgm/Makefile | 2 +- drivers/dma/lgm/lgm-cdma.c | 485 +++++++++++++++++ drivers/dma/lgm/lgm-dma.c | 1014 ++++++------------------------------ drivers/dma/lgm/lgm-dma.h | 311 +++++++++++ drivers/dma/lgm/lgm-hdma.c | 214 ++++++++ 5 files changed, 1176 insertions(+), 850 deletions(-) create mode 100644 drivers/dma/lgm/lgm-cdma.c create mode 100644 drivers/dma/lgm/lgm-dma.h create mode 100644 drivers/dma/lgm/lgm-hdma.c
drivers/dma/lgm/Makefile +1 -1
@@ -1,2 +1,2 @@ # SPDX-License-Identifier: GPL-2.0 -obj-$(CONFIG_INTEL_LDMA) += lgm-dma.o +obj-$(CONFIG_INTEL_LDMA) += lgm-dma.o lgm-cdma.o lgm-hdma.o
drivers/dma/lgm/lgm-cdma.c new file +485 -0
485 lines not on this page · raw message
drivers/dma/lgm/lgm-dma.c +165 -849
1,317 lines not on this page · raw message
drivers/dma/lgm/lgm-dma.h new file +311 -0
311 lines not on this page · raw message
drivers/dma/lgm/lgm-hdma.c new file +214 -0
214 lines not on this page · raw message
Signature · 1 line
2.43.5
PATCH v2 3/3 dmaengine: lgm-dma: Added Software management functions on HDMA.
In reply to Zhu YixinA new devicetree property 'intel,dma-sw-desc', has been introduced to distinguish between software-managed and hardware-managed DMA modes.
In software mode, the driver is responsible for handling the DMA interrupts, as well as preparing and updating the DMA descriptors.
--- drivers/dma/lgm/lgm-hdma.c | 377 ++++++++++++++++++++++++++++++++++++- 1 file changed, 369 insertions(+), 8 deletions(-)
drivers/dma/lgm/lgm-hdma.c +369 -8
@@ -24,14 +24,64 @@#include "lgm-dma.h" /* Descriptor fields */ +#define DESC_DATA_LEN GENMASK(13, 0) +#define DESC_BP_EXT GENMASK(26, 23) +#define DESC_EOP BIT(28) +#define DESC_SOP BIT(29) +#define DESC_C BIT(30) +#define DESC_OWN BIT(31)#define DMA_DFT_DESC_NUM 1024 +/* RX sideband information from DMA */ +struct dma_rx_data { +unsigned int data_len; +unsigned int chno; +}; + +struct dw4_desc_hw { +u32 dw0; +u32 dw1; +u32 dw2; +u32 dw3; +} __packed__aligned(8) ; + +struct dw4_desc_sw { +struct virt_dma_desc vd; +struct ldma_chan *chan; +struct dw4_desc_hw *desc_hw; +}; + +/** +* hdma TX need some sideband info to switch in dw0 and dw1 +*/ +struct chan_cfg { +u32 desc_dw0; +u32 desc_dw1; +}; + +struct hdma_chan { +struct dw4_desc_sw *ds; +struct chan_cfg cfg; +struct ldma_chan *c; +int prep_idx;/* desc prep idx*/ +int comp_idx;/* desc comp idx*/ +int prep_desc_cnt; +struct tasklet_struct task; +}; +static int hdma_ctrl_init (struct ldma_dev *d);static int hdma_port_init (struct ldma_dev *d,struct ldma_port *p);static int hdma_chan_init (struct ldma_dev *d,struct ldma_chan *c);static int hdma_irq_init (struct ldma_dev *d,struct platform_device *pdev);static void hdma_func_init (struct ldma_dev *d,struct dma_device *dma_dev);static void hdma_free_chan_resources (struct dma_chan *dma_chan); +static void dma_chan_complete (struct tasklet_struct *t); + +static inline +struct dw4_desc_sw *to_lgm_dma_dw4_desc (struct virt_dma_desc *vd) +{ + return container_of(vd, struct dw4_desc_sw, vd); +}static inline bool is_dma_chan_tx (struct ldma_dev *d) {
@@ -74,6 +124,8 @@ static inline void hdma_free_desc_resource(struct virt_dma_desc *vd)static int hdma_chan_init (struct ldma_dev *d,struct ldma_chan *c) { +struct hdma_chan *chan; + c->data_endian =DMA_DFT_ENDIAN ; c->desc_endian =DMA_DFT_ENDIAN ; c->data_endian_en = false;
@@ -88,12 +140,164 @@ static int hdma_chan_init(struct ldma_dev *d, struct ldma_chan *c) c->vchan.desc_free = hdma_free_desc_resource;vchan_init (&c->vchan, &d->dma_dev); + chan =devm_kzalloc (d->dev,sizeof (*chan),GFP_KERNEL ); +if (!chan) +return -ENOMEM ; + + c->priv = chan; + chan->c = c; +tasklet_setup (&chan->task, dma_chan_complete); +return 0 ; } +static inline void hdma_get_irq_off (int high,u32 *en_off,u32 *cr_off) +{ +if (!high) { + *cr_off =DMA_IRNCR ; + *en_off =DMA_IRNEN ; + }else { + *cr_off =DMA_IRNCR1 ; + *en_off =DMA_IRNEN1 ; + } +} + +static inline +void hdma_chan_int_enable (struct ldma_dev *d,struct ldma_chan *c) +{ +unsigned long flags; +u32 val, en_off, cr_off, cid; + +spin_lock_irqsave (&d->dev_lock, flags); +/* select DMA channel */ +ldma_update_bits (d,DMA_CS_MASK , c->nr,DMA_CS ); +/* Enable EOP interrupt */ +ldma_update_bits (d,DMA_CI_EOP ,DMA_CI_EOP ,DMA_CIE ); + + val = c->nr >=MAX_LOWER_CHANS ?1 :0 ; + cid = c->nr >=MAX_LOWER_CHANS ? c->nr -MAX_LOWER_CHANS : c->nr; +hdma_get_irq_off (val, &en_off, &cr_off); +ldma_update_bits (d,BIT (cid),BIT (cid), en_off); + +spin_unlock_irqrestore (&d->dev_lock, flags); +} + +static void dma_chan_complete (struct tasklet_struct *t) +{ +struct hdma_chan *chan =from_tasklet (chan, t, task); +struct ldma_chan *c = chan->c; +struct ldma_dev *d =chan_to_ldma_dev (c); + +/* check how many valid descriptor from DMA */ +while (chan->prep_desc_cnt >0 ) { +struct dma_rx_data *data; +struct dmaengine_desc_callback cb; +struct dma_async_tx_descriptor *tx; +struct dw4_desc_sw *desc_sw; +struct dw4_desc_hw *desc_hw; + + desc_sw = chan->ds + chan->comp_idx; + desc_hw = desc_sw->desc_hw; +dma_map_single (d->dev, desc_hw, +sizeof (*desc_hw),DMA_FROM_DEVICE ); + +/* desc still in processing, stop */ +if (!FIELD_GET (DESC_C , desc_hw->dw3)) +break ; + + tx = &desc_sw->vd.tx; +dmaengine_desc_get_callback (tx, &cb); + +if (is_dma_chan_rx (d)) { + data = (struct dma_rx_data *)cb.callback_param; + data->data_len =FIELD_GET (DESC_DATA_LEN , desc_hw->dw3); + data->chno = c->nr; + } + +dma_cookie_complete (tx); + chan->comp_idx = (chan->comp_idx +1 ) % c->desc_cnt; + chan->prep_desc_cnt -=1 ; +dmaengine_desc_callback_invoke (&cb,NULL ); + } + +hdma_chan_int_enable (d, c); +} + +static u64 hdma_irq_stat (struct ldma_dev *d,int high) +{ +u32 irnen, irncr, en_off, cr_off, cid; +unsigned long flags; +u64 ret; + +spin_lock_irqsave (&d->dev_lock, flags); + +hdma_get_irq_off (high, &en_off, &cr_off); + + irncr =readl (d->base + cr_off); + irnen =readl (d->base + en_off); + +if (!irncr || !irnen || !(irncr & irnen)) { +writel (irncr, d->base + cr_off); +spin_unlock_irqrestore (&d->dev_lock, flags); +return 0 ; + } + +/* disable EOP interrupt for the channel */ +for_each_set_bit (cid, (const unsigned long *)&irncr, d->chan_nrs) { +/* select DMA channel */ +ldma_update_bits (d,DMA_CS_MASK , cid,DMA_CS ); +/* Clear EOP interrupt status */ +writel (readl (d->base +DMA_CIS ), d->base +DMA_CIS ); +/* Disable EOP interrupt */ +writel (0 , d->base +DMA_CIE ); + } + +/* ACK interrupt */ +writel (irncr, d->base + cr_off); + irnen &= ~irncr; +/* Disable interrupt */ +writel (irnen, d->base + en_off); + +spin_unlock_irqrestore (&d->dev_lock, flags); + +if (high) + ret = (u64 )irncr <<32 ; +else + ret = (u64 )irncr; + +return ret; +} + +static irqreturn_t hdma_interrupt (int irq,void *dev_id) +{ +struct ldma_dev *d = dev_id; +struct hdma_chan *chan; +u32 cid; +u64 stat; + + stat =hdma_irq_stat (d,0 ) |hdma_irq_stat (d,1 ); +if (!stat) +return IRQ_HANDLED ; + +for_each_set_bit (cid, (const unsigned long *)&stat, d->chan_nrs) { + chan = (struct hdma_chan *)d->chans[cid].priv; +tasklet_schedule (&chan->task); + } + +return IRQ_HANDLED ; +} +static int hdma_irq_init (struct ldma_dev *d,struct platform_device *pdev) { -return 0 ; +if (d->flags &DMA_CHAN_HW_DESC ) +return 0 ; + + d->irq =platform_get_irq (pdev,0 ); +if (d->irq <0 ) +return d->irq; + +return devm_request_irq (d->dev, d->irq, hdma_interrupt,0 , +DRIVER_NAME , d); }/**
@@ -102,40 +306,178 @@ static int hdma_irq_init(struct ldma_dev *d, struct platform_device *pdev)static int hdma_alloc_chan_resources (struct dma_chan *dma_chan) {struct ldma_chan *c =to_ldma_chan (dma_chan); +struct hdma_chan *chan = (struct hdma_chan *)c->priv;struct device *dev = c->vchan.chan.device->dev; +struct dw4_desc_sw *desc_sw; +struct dw4_desc_hw *desc_hw; +size_t desc_sz; +int i;/* HW allocate DMA descriptors */ - c->flags |=CHAN_IN_USE ; -dev_dbg (dev,"Alloc DMA channel %u\n" , c->nr); +if (ldma_chan_is_hw_desc (c)) { + c->flags |=CHAN_IN_USE ; +dev_dbg (dev,"desc in hw\n" ); +return 0 ; + } -return 0 ; +if (!c->desc_cnt) { +dev_err (dev,"descriptor count is not set\n" ); +return -EINVAL ; + } + + desc_sz = c->desc_cnt *sizeof (*desc_hw); + + c->desc_base =kzalloc (desc_sz,GFP_KERNEL ); +if (!c->desc_base) +return -ENOMEM ; + + c->desc_phys =dma_map_single (dev, c->desc_base, + desc_sz,DMA_TO_DEVICE ); +if (dma_mapping_error (dev, c->desc_phys)) { +dev_err (dev,"dma mapping error for dma desc list\n" ); + goto desc_err; + } + + desc_sz = c->desc_cnt *sizeof (*desc_sw); + chan->ds =kzalloc (desc_sz,GFP_KERNEL ); + +if (!chan->ds) + goto desc_err; + + desc_hw = (struct dw4_desc_hw *)c->desc_base; +for (i =0 ; i < c->desc_cnt; i++) { + desc_sw = chan->ds + i; + desc_sw->chan = c; + desc_sw->desc_hw = desc_hw + i; + } + +dev_dbg (dev,"Alloc DMA CH: %u, phy addr: 0x%llx, desc cnt: %u\n" , + c->nr, c->desc_phys, c->desc_cnt); + +ldma_chan_desc_hw_cfg (c, c->desc_phys, c->desc_cnt); +ldma_chan_on (c); + +return c->desc_cnt; + +desc_err: +kfree (c->desc_base); +return -EINVAL ; }static void hdma_free_chan_resources (struct dma_chan *dma_chan) {struct ldma_chan *c =to_ldma_chan (dma_chan); +struct hdma_chan *chan = (struct hdma_chan *)c->priv;struct device *dev = c->vchan.chan.device->dev;ldma_chan_reset (c);/* HW allocate DMA descriptors */ - c->flags &= ~CHAN_IN_USE ; +if (ldma_chan_is_hw_desc (c)) { + c->flags &= ~CHAN_IN_USE ; +dev_dbg (dev,"%s: desc in hw\n" , __func__); +return ; + } + +vchan_free_chan_resources (&c->vchan); +kfree (chan->ds); +kfree (c->desc_base);dev_dbg (dev,"Free DMA channel %u\n" , c->nr); } +static int +hdma_slave_config (struct dma_chan *dma_chan,struct dma_slave_config *cfg) +{ +struct ldma_chan *c =to_ldma_chan (dma_chan); +struct hdma_chan *chan = (struct hdma_chan *)c->priv; + +if (cfg->peripheral_config) +memcpy (&chan->cfg, cfg->peripheral_config,sizeof (chan->cfg)); + +return 0 ; +} + +static void hdma_desc_set_own (struct dw4_desc_sw *desc_sw) +{ +struct ldma_chan *c = desc_sw->chan; +struct dw4_desc_hw *desc_hw; +struct device *dev = c->vchan.chan.device->dev; + + desc_hw = desc_sw->desc_hw; + desc_hw->dw3 |=DESC_OWN ; + +dma_map_single (dev, desc_hw,sizeof (*desc_hw),DMA_TO_DEVICE ); +} + +static void hdma_execute_pending (struct ldma_chan *c) +{ +struct virt_dma_desc *vd =NULL ; +struct dw4_desc_sw *desc_sw; + +do { + vd =vchan_next_desc (&c->vchan); +if (!vd) +break ; +list_del (&vd->node); + desc_sw =to_lgm_dma_dw4_desc (vd); +hdma_desc_set_own (desc_sw); + }while (vd); +} +static void hdma_issue_pending (struct dma_chan *dma_chan) {struct ldma_chan *c =to_ldma_chan (dma_chan); +unsigned long flags; -ldma_chan_on (c); +if (ldma_chan_is_hw_desc (c)) { +ldma_chan_on (c); +return ; + } + +spin_lock_irqsave (&c->vchan.lock, flags); +if (vchan_issue_pending (&c->vchan)) +hdma_execute_pending (c); +spin_unlock_irqrestore (&c->vchan.lock, flags); }static enum dma_status hdma_tx_status (struct dma_chan *dma_chan,dma_cookie_t cookie,struct dma_tx_state *txstate) { -return DMA_COMPLETE ; +struct ldma_chan *c =to_ldma_chan (dma_chan); + +if (ldma_chan_is_hw_desc (c)) +return DMA_COMPLETE ; + +return dma_cookie_status (dma_chan, cookie, txstate); +} + +/** +* initializa the HW DMA descriptor. +*/ +static void +hdma_setup_desc (struct ldma_chan *c,struct dw4_desc_hw *desc_hw, +dma_addr_t paddr,unsigned int len) +{ +struct hdma_chan *chan = (struct hdma_chan *)c->priv; +u32 dw3 =0 ; + + desc_hw->dw0 = chan->cfg.desc_dw0; + desc_hw->dw1 = chan->cfg.desc_dw1; + desc_hw->dw2 =lower_32_bits (paddr);/* physicall address */ + + dw3 =FIELD_PREP (DESC_DATA_LEN , len); + dw3 |=FIELD_PREP (DESC_BP_EXT ,upper_32_bits (paddr)); + dw3 |=FIELD_PREP (DESC_SOP ,1 ); + dw3 |=FIELD_PREP (DESC_EOP ,1 ); + desc_hw->dw3 = dw3; +} + +static inline +bool hdma_desc_empty (struct hdma_chan *chan,unsigned int desc_cnt) +{ +return (chan->prep_desc_cnt == desc_cnt); }/**
@@ -177,14 +519,32 @@ hdma_prep_slave_sg(struct dma_chan *dma_chan, struct scatterlist *sgl, unsigned long flags, void *context) { struct ldma_chan *c = to_ldma_chan(dma_chan); +struct hdma_chan *chan = (struct hdma_chan *)c->priv;struct device *dev = c->vchan.chan.device->dev; +struct dw4_desc_hw *desc_hw; +struct dw4_desc_sw *desc_sw;if (!sgl || sglen <1 ) {dev_err (dev,"%s param error!\n" , __func__);return NULL ; } -return hdma_chan_hw_desc_cfg (dma_chan, sgl->dma_address, sglen); +if (ldma_chan_is_hw_desc (c)) +return hdma_chan_hw_desc_cfg (dma_chan, sgl->dma_address, sglen); + +if (hdma_desc_empty (chan, c->desc_cnt)) +return NULL ; + + desc_sw = chan->ds + chan->prep_idx; + chan->prep_idx = (chan->prep_idx +1 ) % c->desc_cnt; + desc_hw = desc_sw->desc_hw; + chan->prep_desc_cnt +=1 ; + +hdma_setup_desc (c, desc_sw->desc_hw, +sg_dma_address (sgl),sg_dma_len (sgl)); + +return vchan_tx_prep (&c->vchan, &desc_sw->vd, +DMA_CTRL_ACK ); }static void hdma_func_init (struct ldma_dev *d,struct dma_device *dma_dev)
@@ -197,6 +557,7 @@ static void hdma_func_init(struct ldma_dev *d, struct dma_device *dma_dev) dma_dev->device_resume = ldma_resume_chan; dma_dev->device_pause = ldma_pause_chan; dma_dev->device_prep_slave_sg = hdma_prep_slave_sg; + dma_dev->device_config = hdma_slave_config; dma_dev->src_addr_widths =BIT (DMA_SLAVE_BUSWIDTH_2_BYTES ) | BIT(DMA_SLAVE_BUSWIDTH_4_BYTES) |
Signature · 1 line
2.43.5
Re: [PATCH v2 3/3] dmaengine: lgm-dma: Added Software management functions on HDMA.
drivers/dma/lgm/lgm-hdma.c line 55
Quoted 9 lines · Zhu Yixin
drivers/dma/lgm/lgm-hdma.c +9
-0+ +struct dw4_desc_sw { +struct virt_dma_desc vd; +struct ldma_chan *chan; +struct dw4_desc_hw *desc_hw; +}; + +/** +* hdma TX need some sideband info to switch in dw0 and dw1
That's not a kerneldoc.
Please run standard kernel tools for static analysis, like coccinelle, smatch and sparse, and fix reported warnings. Also please check for warnings when building with W=1. Most of these commands (checks or W=1 build) can build specific targets, like some directory, to narrow the scope to only your code. The code here looks like it needs a fix. Feel free to get in touch if the warning is not clear.
Best regards,
Krzysztof
RE: [PATCH v2 3/3] dmaengine: lgm-dma: Added Software management functions on HDMA.
Hi Krzysztof,
Quoted 5 lines · Krzysztof
Quoted 3 lines
+/**
+ * hdma TX need some sideband info to switch in dw0 and dw1That's not a kerneldoc.
I will change it to /* */ format in the next patch submit.
Quoted 11 lines
Please run standard kernel tools for static analysis, like coccinelle, smatch and sparse, and fix reported warnings. Also please check for warnings when building with W=1. Most of these commands (checks or W=1 build) can build specific targets, like some directory, to narrow the scope to only your code. The code here looks like it needs a fix. Feel free to get in touch if the warning is not clear.
Best regards,
Krzysztof
Thanks for reminding me to run these checks.
-W1 gave me warning on lgm-hdma.c. I'll fix it in the next patch submit. Coccinelle, smatch and sparse didn't report any meaningful warning.
make CROSS_COMPILE=x86_64-buildroot-linux-musl- CHECK="sparse" C=1 drivers/dma/lgm/
CALL scripts/checksyscalls.sh
DESCEND objtool
INSTALL libsubcmd_headers
CC drivers/dma/lgm/lgm-dma.o CHECK drivers/dma/lgm/lgm-dma.c CC drivers/dma/lgm/lgm-cdma.o CHECK drivers/dma/lgm/lgm-cdma.c CC drivers/dma/lgm/lgm-hdma.o CHECK drivers/dma/lgm/lgm-hdma.c AR drivers/dma/lgm/built-in.a
make CROSS_COMPILE=x86_64-buildroot-linux-musl- CHECK="smatch -p=kernel" C=1 drivers/dma/lgm/
CALL scripts/checksyscalls.sh
DESCEND objtool
INSTALL libsubcmd_headers
CC drivers/dma/lgm/lgm-dma.o CHECK drivers/dma/lgm/lgm-dma.c CC drivers/dma/lgm/lgm-cdma.o CHECK drivers/dma/lgm/lgm-cdma.c CC drivers/dma/lgm/lgm-hdma.o CHECK drivers/dma/lgm/lgm-hdma.c AR drivers/dma/lgm/built-in.a
Coccinelle give me some warnings, but I feel it is not my code related.
make CROSS_COMPILE=x86_64-buildroot-linux-musl- CHECK="scripts/coccicheck" C=1 drivers/dma/lgm/
CALL scripts/checksyscalls.sh
DESCEND objtool
INSTALL libsubcmd_headers
CC drivers/dma/lgm/lgm-dma.o
CHECK drivers/dma/lgm/lgm-dma.c
...
warning: line 140: should noop_llseek be a metavariable?
warning: line 222: should nonseekable_open be a metavariable?
warning: line 289: should nonseekable_open be a metavariable?
warning: line 337: should nonseekable_open be a metavariable?
Please let me know if the command or parameter is not properly set.
Best regards,
Yixin
Quoted 11 lines · Zhu Yixin
If the intel,dma-sw-desc property is present, it indicates that the DMA driver is responsible for managing the DMA engine, including handing the DMA descriptors.
If this property is present, the system defaults to a mode where another hardware component takes control of the DMA engine. In this case, the hardware can generate and manage descriptors independently, without driver involvement.This property only takes effect on HDMA(DMAV3x).
Signed-off-by Zhu Yixin <[email protected]>
Where is the changelog?
Quoted 9 lines
--- Documentation/devicetree/bindings/dma/intel,ldma.yaml | 6 ++++++ 1 file changed, 6 insertions(+)Documentation/devicetree/bindings/dma/intel,ldma.yaml +0
-0
Documentation/devicetree/bindings/dma/intel,ldma.yaml properties: · line 87
Quoted 8 lines
Documentation/devicetree/bindings/dma/intel,ldma.yaml +5
-0@@ -80,6 +80,12 @@ properties: if it is disabled, the DMA RX will still support programmable fixed burst size of 2,4,8,16. It only applies to RX DMA and memcopy DMA. + intel,dma-sw-desc: + type: boolean + description: + Indicates that the DMA driver should operate in software-managed mode. + If this property is not present, it implies that DMA descriptors are managed and generated by another hardware component that controls the DMA engine.
Nothing improved:
1. Still wrongly wrapped.
2. Still SW property.
I don't think you read the feedback. You need to describe hardware, not SW.
Best regards,
Krzysztof
Hi Krzysztof,
Quoted 4 lines · Krzysztof
Where is the changelog?
Sorry for missing the changelog. I will include it in V3 patch.
Quoted 11 lines
Documentation/devicetree/bindings/dma/intel,ldma.yaml properties:
Quoted 5 lines
Documentation/devicetree/bindings/dma/intel,ldma.yaml +5
-0+ intel,dma-sw-desc: + type: boolean + description: + Indicates that the DMA driver should operate in + software-managedmode.
Quoted 2 lines
+ If this property is not present, it implies that DMA
+ descriptors aremanaged and generated by another hardware component that controls the DMA engine.
Quoted 8 lines
Nothing improved:
1. Still wrongly wrapped.
2. Still SW property.I don't think you read the feedback. You need to describe hardware, not SW.
Best regards,
Krzysztof
Could you please give me some advice with regarding to the device tree attribute?
My understanding is if I can create a phandle link to describe the DMA descriptors are provided by some HW component. That follows the comments. Something like this:
intel,dma-desc-provider = <&xxx_hw>;
Then it describes some HW component manages the DMA descriptors. Without it, it means SW manage the DMA descriptors. Please correct me if my understanding is wrong.
However, in the existing driver, HW manages descriptor mode is the default mode. I can't create such link in the device tree without breaking the devicetree ABI. So, is it okay I create an attribute like below ?
Intel,dma-desc-provider = "CPU"; // it means CPU manage DMA descriptors.
Intel,dma-desc-provider = "XXX_HW"; // it means XX_HW manage DMA descriptors.
Please advise.
Best regards,
Yixin
Quoted 29 lines · Yi xin Zhu
Hi Krzysztof,
Quoted 4 lines · Krzysztof
Where is the changelog?
Sorry for missing the changelog. I will include it in V3 patch.
Quoted 11 lines
Documentation/devicetree/bindings/dma/intel,ldma.yaml properties:
Quoted 5 lines
Documentation/devicetree/bindings/dma/intel,ldma.yaml +5
-0+ intel,dma-sw-desc: + type: boolean + description: + Indicates that the DMA driver should operate in + software-managedmode.
Quoted 2 lines
+ If this property is not present, it implies that DMA
+ descriptors aremanaged and generated by another hardware component that controls the DMA engine.
Quoted 8 lines
Nothing improved:
1. Still wrongly wrapped.
2. Still SW property.I don't think you read the feedback. You need to describe hardware, not SW.
Best regards,
Krzysztof
Quoted 7 lines
Could you please give me some advice with regarding to the device tree attribute?
My understanding is if I can create a phandle link to describe the DMA descriptors are provided by some HW component. That follows the comments. Something like this:intel,dma-desc-provider = <
&xxx_hw>;Then it describes some HW component manages the DMA descriptors.
It is not sufficient to tell. Creating phandles representing fake hardware is still not hardware description.
Quoted 2 lines
Without it, it means SW manage the DMA descriptors. Please correct me if my understanding is wrong.
Yes, it is wrong, because you focus on syntax instead of on the hardware problem or hardware characteristic.
Quoted 8 lines
However, in the existing driver, HW manages descriptor mode is the default mode. I can't create such link in the device tree without breaking the devicetree ABI. So, is it okay I create an attribute like below ?
Intel,dma-desc-provider = "CPU"; // it means CPU manage DMA descriptors.
Intel,dma-desc-provider = "
XXX_HW"; // it meansXX_HWmanage DMA descriptors.
And how is it not a OS policy? Bring reasoning and arguments, otherwise I cannot help you. Your reply above has zero hardware-related arguments, zero facts, zero hardware description.
Best regards,
Krzysztof
Hi Krzysztof,
Quoted 8 lines · Krzysztof
And how is it not a OS policy? Bring reasoning and arguments, otherwise I cannot help you. Your reply above has zero hardware-related arguments, zero facts, zero hardware description.
Best regards,
Krzysztof
Let me first describe the DMA hardware capability. The DMA IP is designed with two control paths.
1. Hardware descriptor mode. The DMA can be connected to another HW component that provides Descriptors to DMA to automate DMA transfers.
2. Software descriptor mode. The DMA IP also has interface to CPU via registers to allow CPU to manage the DMA transfers.
Which mode DMA works in depends on SoC level configuration. In the SoC, it could be some of the DMA instances work in hardware descriptor mode while other DMA instances work in software descriptor mode or all in HW/SW mode.
Can I take it as a hardware capability setting?
If I can't, any other approach I can use to achieve the same target?
Best regards,
Yixin
Quoted 11 lines · Yi xin Zhu
Hi Krzysztof,
Quoted 8 lines · Krzysztof
And how is it not a OS policy? Bring reasoning and arguments, otherwise I cannot help you. Your reply above has zero hardware-related arguments, zero facts, zero hardware description.
Best regards,
Krzysztof
Quoted 7 lines
Let me first describe the DMA hardware capability. The DMA IP is designed with two control paths.
1. Hardware descriptor mode. The DMA can be connected to another HW component that provides Descriptors to DMA to automate DMA transfers.
2. Software descriptor mode. The DMA IP also has interface to CPU via registers to allow CPU to manage the DMA transfers.Which mode DMA works in depends on SoC level configuration. In the SoC, it could be some
What is a "SoC level configuration"?
From your explanation 1+2 it feels like consumer chooses it. Where is a full DTS showing all this?
Quoted 3 lines
of the DMA instances work in hardware descriptor mode while other DMA instances work in software descriptor mode or all in HW/SW mode.
Best regards,
Krzysztof
Hi Krzysztof,
Quoted 8 lines · Krzysztof
What is a "SoC level configuration"?
From your explanation 1+2 it feels like consumer chooses it. Where is a full DTS showing all this?
Quoted 6 lines
Quoted 3 lines
of the DMA instances work in hardware descriptor mode while other DMA instances work in software descriptor mode or all in HW/SW mode.
Best regards,
Krzysztof
In the LGM SoC, The DMA instances are default connected to CBM(central buffer manager) to automate the DMA descriptors. It can also be detached from CBM to use it in different use cases individually.
In the HW descriptor case, the device tree would be like:
dma1tx: dma-controller@e7300000 {
compatible = "intel,lgm-dma1tx";
reg = <0xe7300000 0x1000>;
...
#dma-cells = <3>;
intel,dma-poll-cnt = <16>;
};cbm: cbm@e1000000 {
dmas = <&dma1tx 0 0 64>, <&dma1tx 1 0 64> ... <&dma1tx 15 0 64>;
};
DMA HW feature, desc_fod(descriptor fetch on demand) and desc_in_sram are turned on in the DMA controller in this case. These HW features are defined in platform data in the existing DMA driver as default enabled.
static const struct ldma_inst_data dma1tx = {
...
.desc_fod = true;
.desc_in_sram = true;
};In the SW descriptor management case, the device tree would be like:
dma1tx: dma-controller@e7300000 {
compatible = "intel,lgm-dma1tx";
reg = <0xe7300000 0x1000>;
...
#dma-cells = <3>;
intel,dma-poll-cnt = <16>;
intel,dma-sw-desc;
};eth: eth@a00000 {
dmas = <&dma1tx 0 0 64>;
};
Ethernet driver is an example to use the DMA to transfer data. In the SW descriptor management case, DMA driver must turn off DMA HW feature desc_fod and desc_in_sram to give the control to CPU.
Best regards,
Yixin
Quoted 46 lines · Yi xin Zhu
Hi Krzysztof,
Quoted 8 lines · Krzysztof
What is a "SoC level configuration"?
From your explanation 1+2 it feels like consumer chooses it. Where is a full DTS showing all this?
Quoted 6 lines
Quoted 3 lines
of the DMA instances work in hardware descriptor mode while other DMA instances work in software descriptor mode or all in HW/SW mode.
Best regards,
KrzysztofIn the LGM SoC, The DMA instances are default connected to CBM(central buffer manager) to automate the DMA descriptors. It can also be detached from CBM to use it in different use cases individually.
In the HW descriptor case, the device tree would be like:
dma1tx: dma-controller@e7300000 { compatible = "intel,lgm-dma1tx"; reg = <0xe7300000 0x1000>; ... #dma-cells = <3>; intel,dma-poll-cnt = <16>; };cbm: cbm@e1000000 { dmas = <&dma1tx 0 0 64>, <&dma1tx 1 0 64> ... <&dma1tx 15 0 64>;};
DMA HW feature,
desc_fod(descriptor fetch on demand)anddesc_in_sramare turned on in the DMA controller in this case. These HW features are defined in platform data in the existing DMA driver as default enabled.static const struct ldma_inst_data dma1tx = { ... .desc_fod = true; .desc_in_sram = true; };In the SW descriptor management case, the device tree would be like:
Quoted 7 lines
dma1tx: dma-controller@e7300000 {
compatible = "intel,lgm-dma1tx";
reg = <0xe7300000 0x1000>;
...
#dma-cells = <3>;
intel,dma-poll-cnt = <16>;
intel,dma-sw-desc;That's then implied by compatible, no? If you disagree, please post complete upstream DTS.
Best regards,
Krzysztof