On Tue, 28 Dec 2021 19:42:04 +0800 [email protected] wrote:
> +static void free_emac_dma_req(struct emac_dma_req *req)
emac_free_dma_req
> +prepare_err:
> + dma_unmap_single(db->dev, rxbuf, count, DMA_FROM_DEVICE);
> + return ret;
incorrect whitespace here
> @@ -599,12 +721,25 @@ static void emac_rx(struct net_device *dev)
> if (!skb)
> continue;
> skb_reserve(skb, 2);
> - rdptr = skb_put(skb, rxlen - 4);
>
> /* Read received packet from RX SRAM */
> if (netif_msg_rx_status(db))
> dev_dbg(db->dev, "RxLen %x\n", rxlen);
>
> + rdptr = skb_put(skb, rxlen - 4);
no reason to move this line
From: Conley Lee <[email protected]>
Thanks for your review. Here is the new version for this patch.
This patch adds support for the emac rx dma present on sun4i. The emac
is able to move packets from rx fifo to RAM by using dma.
Change since v4.
- rename sbk field to skb
- rename alloc_emac_dma_req to emac_alloc_dma_req
- using kzalloc(..., GPF_ATOMIC) in interrupt context to avoid
sleeping
- retry by using emac_inblk_32bit when emac_dma_inblk_32bit fails
- fix some code style issues
Change since v5.
- fix some code style issue
Signed-off-by: Conley Lee <[email protected]>
---
drivers/net/ethernet/allwinner/sun4i-emac.c | 200 ++++++++++++++++++++
1 file changed, 200 insertions(+)
diff --git a/drivers/net/ethernet/allwinner/sun4i-emac.c b/drivers/net/ethernet/allwinner/sun4i-emac.c
index cccf8a3ead5e..964227e342ee 100644
--- a/drivers/net/ethernet/allwinner/sun4i-emac.c
+++ b/drivers/net/ethernet/allwinner/sun4i-emac.c
@@ -29,6 +29,7 @@
#include <linux/platform_device.h>
#include <linux/phy.h>
#include <linux/soc/sunxi/sunxi_sram.h>
+#include <linux/dmaengine.h>
#include "sun4i-emac.h"
@@ -86,6 +87,16 @@ struct emac_board_info {
unsigned int duplex;
phy_interface_t phy_interface;
+ struct dma_chan *rx_chan;
+ phys_addr_t emac_rx_fifo;
+};
+
+struct emac_dma_req {
+ struct emac_board_info *db;
+ struct dma_async_tx_descriptor *desc;
+ struct sk_buff *skb;
+ dma_addr_t rxbuf;
+ int count;
};
static void emac_update_speed(struct net_device *dev)
@@ -205,6 +216,117 @@ static void emac_inblk_32bit(void __iomem *reg, void *data, int count)
readsl(reg, data, round_up(count, 4) / 4);
}
+static struct emac_dma_req *
+emac_alloc_dma_req(struct emac_board_info *db,
+ struct dma_async_tx_descriptor *desc, struct sk_buff *skb,
+ dma_addr_t rxbuf, int count)
+{
+ struct emac_dma_req *req;
+
+ req = kzalloc(sizeof(struct emac_dma_req), GFP_ATOMIC);
+ if (!req)
+ return NULL;
+
+ req->db = db;
+ req->desc = desc;
+ req->skb = skb;
+ req->rxbuf = rxbuf;
+ req->count = count;
+ return req;
+}
+
+static void emac_free_dma_req(struct emac_dma_req *req)
+{
+ kfree(req);
+}
+
+static void emac_dma_done_callback(void *arg)
+{
+ struct emac_dma_req *req = arg;
+ struct emac_board_info *db = req->db;
+ struct sk_buff *skb = req->skb;
+ struct net_device *dev = db->ndev;
+ int rxlen = req->count;
+ u32 reg_val;
+
+ dma_unmap_single(db->dev, req->rxbuf, rxlen, DMA_FROM_DEVICE);
+
+ skb->protocol = eth_type_trans(skb, dev);
+ netif_rx(skb);
+ dev->stats.rx_bytes += rxlen;
+ /* Pass to upper layer */
+ dev->stats.rx_packets++;
+
+ /* re enable cpu receive */
+ reg_val = readl(db->membase + EMAC_RX_CTL_REG);
+ reg_val &= ~EMAC_RX_CTL_DMA_EN;
+ writel(reg_val, db->membase + EMAC_RX_CTL_REG);
+
+ /* re enable interrupt */
+ reg_val = readl(db->membase + EMAC_INT_CTL_REG);
+ reg_val |= (0x01 << 8);
+ writel(reg_val, db->membase + EMAC_INT_CTL_REG);
+
+ db->emacrx_completed_flag = 1;
+ emac_free_dma_req(req);
+}
+
+static int emac_dma_inblk_32bit(struct emac_board_info *db,
+ struct sk_buff *skb, void *rdptr, int count)
+{
+ struct dma_async_tx_descriptor *desc;
+ dma_cookie_t cookie;
+ dma_addr_t rxbuf;
+ struct emac_dma_req *req;
+ int ret = 0;
+
+ rxbuf = dma_map_single(db->dev, rdptr, count, DMA_FROM_DEVICE);
+ ret = dma_mapping_error(db->dev, rxbuf);
+ if (ret) {
+ dev_err(db->dev, "dma mapping error.\n");
+ return ret;
+ }
+
+ desc = dmaengine_prep_slave_single(db->rx_chan, rxbuf, count,
+ DMA_DEV_TO_MEM,
+ DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
+ if (!desc) {
+ dev_err(db->dev, "prepare slave single failed\n");
+ ret = -ENOMEM;
+ goto prepare_err;
+ }
+
+ req = emac_alloc_dma_req(db, desc, skb, rxbuf, count);
+ if (!req) {
+ dev_err(db->dev, "alloc emac dma req error.\n");
+ ret = -ENOMEM;
+ goto alloc_req_err;
+ }
+
+ desc->callback_param = req;
+ desc->callback = emac_dma_done_callback;
+
+ cookie = dmaengine_submit(desc);
+ ret = dma_submit_error(cookie);
+ if (ret) {
+ dev_err(db->dev, "dma submit error.\n");
+ goto submit_err;
+ }
+
+ dma_async_issue_pending(db->rx_chan);
+ return ret;
+
+submit_err:
+ emac_free_dma_req(req);
+
+alloc_req_err:
+ dmaengine_desc_free(desc);
+
+prepare_err:
+ dma_unmap_single(db->dev, rxbuf, count, DMA_FROM_DEVICE);
+ return ret;
+}
+
/* ethtool ops */
static void emac_get_drvinfo(struct net_device *dev,
struct ethtool_drvinfo *info)
@@ -605,6 +727,19 @@ static void emac_rx(struct net_device *dev)
if (netif_msg_rx_status(db))
dev_dbg(db->dev, "RxLen %x\n", rxlen);
+ if (rxlen >= dev->mtu && db->rx_chan) {
+ reg_val = readl(db->membase + EMAC_RX_CTL_REG);
+ reg_val |= EMAC_RX_CTL_DMA_EN;
+ writel(reg_val, db->membase + EMAC_RX_CTL_REG);
+ if (!emac_dma_inblk_32bit(db, skb, rdptr, rxlen))
+ break;
+
+ /* re enable cpu receive. then try to receive by emac_inblk_32bit */
+ reg_val = readl(db->membase + EMAC_RX_CTL_REG);
+ reg_val &= ~EMAC_RX_CTL_DMA_EN;
+ writel(reg_val, db->membase + EMAC_RX_CTL_REG);
+ }
+
emac_inblk_32bit(db->membase + EMAC_RX_IO_DATA_REG,
rdptr, rxlen);
dev->stats.rx_bytes += rxlen;
@@ -659,7 +794,12 @@ static irqreturn_t emac_interrupt(int irq, void *dev_id)
reg_val = readl(db->membase + EMAC_INT_CTL_REG);
reg_val |= (0xf << 0) | (0x01 << 8);
writel(reg_val, db->membase + EMAC_INT_CTL_REG);
+ } else {
+ reg_val = readl(db->membase + EMAC_INT_CTL_REG);
+ reg_val |= (0xf << 0);
+ writel(reg_val, db->membase + EMAC_INT_CTL_REG);
}
+
spin_unlock(&db->lock);
return IRQ_HANDLED;
@@ -764,6 +904,58 @@ static const struct net_device_ops emac_netdev_ops = {
#endif
};
+static int emac_configure_dma(struct emac_board_info *db)
+{
+ struct platform_device *pdev = db->pdev;
+ struct net_device *ndev = db->ndev;
+ struct dma_slave_config conf = {};
+ struct resource *regs;
+ int err = 0;
+
+ regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (!regs) {
+ netdev_err(ndev, "get io resource from device failed.\n");
+ err = -ENOMEM;
+ goto out_clear_chan;
+ }
+
+ netdev_info(ndev, "get io resource from device: 0x%x, size = %u\n",
+ regs->start, resource_size(regs));
+ db->emac_rx_fifo = regs->start + EMAC_RX_IO_DATA_REG;
+
+ db->rx_chan = dma_request_chan(&pdev->dev, "rx");
+ if (IS_ERR(db->rx_chan)) {
+ netdev_err(ndev,
+ "failed to request dma channel. dma is disabled\n");
+ err = PTR_ERR(db->rx_chan);
+ goto out_clear_chan;
+ }
+
+ conf.direction = DMA_DEV_TO_MEM;
+ conf.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
+ conf.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
+ conf.src_addr = db->emac_rx_fifo;
+ conf.dst_maxburst = 4;
+ conf.src_maxburst = 4;
+ conf.device_fc = false;
+
+ err = dmaengine_slave_config(db->rx_chan, &conf);
+ if (err) {
+ netdev_err(ndev, "config dma slave failed\n");
+ err = -EINVAL;
+ goto out_slave_configure_err;
+ }
+
+ return err;
+
+out_slave_configure_err:
+ dma_release_channel(db->rx_chan);
+
+out_clear_chan:
+ db->rx_chan = NULL;
+ return err;
+}
+
/* Search EMAC board, allocate space and register it
*/
static int emac_probe(struct platform_device *pdev)
@@ -806,6 +998,9 @@ static int emac_probe(struct platform_device *pdev)
goto out_iounmap;
}
+ if (emac_configure_dma(db))
+ netdev_info(ndev, "configure dma failed. disable dma.\n");
+
db->clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(db->clk)) {
ret = PTR_ERR(db->clk);
@@ -888,6 +1083,11 @@ static int emac_remove(struct platform_device *pdev)
struct net_device *ndev = platform_get_drvdata(pdev);
struct emac_board_info *db = netdev_priv(ndev);
+ if (db->rx_chan) {
+ dmaengine_terminate_all(db->rx_chan);
+ dma_release_channel(db->rx_chan);
+ }
+
unregister_netdev(ndev);
sunxi_sram_release(&pdev->dev);
clk_disable_unprepare(db->clk);
--
2.31.1
Hello:
This patch was applied to netdev/net-next.git (master)
by Jakub Kicinski <[email protected]>:
On Wed, 29 Dec 2021 09:43:51 +0800 you wrote:
> From: Conley Lee <[email protected]>
>
> Thanks for your review. Here is the new version for this patch.
>
> This patch adds support for the emac rx dma present on sun4i. The emac
> is able to move packets from rx fifo to RAM by using dma.
>
> [...]
Here is the summary with links:
- [v6] sun4i-emac.c: add dma support
https://git.kernel.org/netdev/net-next/c/47869e82c8b8
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
Le Wed, Dec 29, 2021 at 09:43:51AM +0800, [email protected] a ?crit :
> From: Conley Lee <[email protected]>
>
> Thanks for your review. Here is the new version for this patch.
>
> This patch adds support for the emac rx dma present on sun4i. The emac
> is able to move packets from rx fifo to RAM by using dma.
>
> Change since v4.
> - rename sbk field to skb
> - rename alloc_emac_dma_req to emac_alloc_dma_req
> - using kzalloc(..., GPF_ATOMIC) in interrupt context to avoid
> sleeping
> - retry by using emac_inblk_32bit when emac_dma_inblk_32bit fails
> - fix some code style issues
>
> Change since v5.
> - fix some code style issue
>
Hello
I just tested this on a sun4i-a10-olinuxino-lime
I got:
[ 2.922812] sun4i-emac 1c0b000.ethernet (unnamed net_device) (uninitialized): get io resource from device: 0x1c0b000, size = 4096
[ 2.934512] sun4i-emac 1c0b000.ethernet (unnamed net_device) (uninitialized): failed to request dma channel. dma is disabled
[ 2.945740] sun4i-emac 1c0b000.ethernet (unnamed net_device) (uninitialized): configure dma failed. disable dma.
[ 2.957887] sun4i-emac 1c0b000.ethernet: eth0: at (ptrval), IRQ 19 MAC: 02:49:09:40:ab:3d
On which board did you test it and how ?
Regards
Le Sat, Jan 01, 2022 at 03:09:01PM +0800, Conley Lee a écrit :
> On 12/31/21 at 11:43上午, Corentin Labbe wrote:
> > Date: Fri, 31 Dec 2021 11:43:53 +0100
> > From: Corentin Labbe <[email protected]>
> > To: [email protected]
> > Cc: [email protected], [email protected], [email protected],
> > [email protected], [email protected],
> > [email protected], [email protected]
> > Subject: Re: [PATCH v6] sun4i-emac.c: add dma support
> >
> > Le Wed, Dec 29, 2021 at 09:43:51AM +0800, [email protected] a écrit :
> > > From: Conley Lee <[email protected]>
> > >
> > > Thanks for your review. Here is the new version for this patch.
> > >
> > > This patch adds support for the emac rx dma present on sun4i. The emac
> > > is able to move packets from rx fifo to RAM by using dma.
> > >
> > > Change since v4.
> > > - rename sbk field to skb
> > > - rename alloc_emac_dma_req to emac_alloc_dma_req
> > > - using kzalloc(..., GPF_ATOMIC) in interrupt context to avoid
> > > sleeping
> > > - retry by using emac_inblk_32bit when emac_dma_inblk_32bit fails
> > > - fix some code style issues
> > >
> > > Change since v5.
> > > - fix some code style issue
> > >
> >
> > Hello
> >
> > I just tested this on a sun4i-a10-olinuxino-lime
> >
> > I got:
> > [ 2.922812] sun4i-emac 1c0b000.ethernet (unnamed net_device) (uninitialized): get io resource from device: 0x1c0b000, size = 4096
> > [ 2.934512] sun4i-emac 1c0b000.ethernet (unnamed net_device) (uninitialized): failed to request dma channel. dma is disabled
> > [ 2.945740] sun4i-emac 1c0b000.ethernet (unnamed net_device) (uninitialized): configure dma failed. disable dma.
> > [ 2.957887] sun4i-emac 1c0b000.ethernet: eth0: at (ptrval), IRQ 19 MAC: 02:49:09:40:ab:3d
> >
> > On which board did you test it and how ?
> >
> > Regards
>
> Sorry. I sent the email with text/html format. This email is an clean version.
>
> In order to enable dma rx channel. `dmas` and `dma-names` properties
> should be added to emac section in dts:
>
> emac: ethernet@1c0b000 {
> ...
> dmas = <&dma SUN4I_DMA_DEDICATED 7>;
> dma-names = "rx";
> ...
> }
Helo
Yes I figured that out. But you should have done a patch serie adding this.
Your patch is now applied but it is a useless change without the dtb change.
You should also probably update the driver binding (Documentation/devicetree/bindings/net/allwinner,sun4i-a10-emac.yaml) since you add new members to DT node.
Furthermore, why did you add RX only and not TX dma also ?
Probably it is too late since patch is applied but it is:
Tested-by: Corentin Labbe <[email protected]>
Tested-on: sun4i-a10-olinuxino-lime
Regards
Le Mon, Jan 03, 2022 at 10:55:04AM +0800, Conley Lee a écrit :
> On 01/02/22 at 06:38下午, Corentin Labbe wrote:
> > Date: Sun, 2 Jan 2022 18:38:51 +0100
> > From: Corentin Labbe <[email protected]>
> > To: Conley Lee <[email protected]>
> > Cc: [email protected], [email protected], [email protected],
> > [email protected], [email protected],
> > [email protected], [email protected],
> > [email protected], [email protected]
> > Subject: Re: [PATCH v6] sun4i-emac.c: add dma support
> >
> > Le Sat, Jan 01, 2022 at 03:09:01PM +0800, Conley Lee a écrit :
> > > On 12/31/21 at 11:43上午, Corentin Labbe wrote:
> > > > Date: Fri, 31 Dec 2021 11:43:53 +0100
> > > > From: Corentin Labbe <[email protected]>
> > > > To: [email protected]
> > > > Cc: [email protected], [email protected], [email protected],
> > > > [email protected], [email protected],
> > > > [email protected], [email protected]
> > > > Subject: Re: [PATCH v6] sun4i-emac.c: add dma support
> > > >
> > > > Le Wed, Dec 29, 2021 at 09:43:51AM +0800, [email protected] a écrit :
> > > > > From: Conley Lee <[email protected]>
> > > > >
> > > > > Thanks for your review. Here is the new version for this patch.
> > > > >
> > > > > This patch adds support for the emac rx dma present on sun4i. The emac
> > > > > is able to move packets from rx fifo to RAM by using dma.
> > > > >
> > > > > Change since v4.
> > > > > - rename sbk field to skb
> > > > > - rename alloc_emac_dma_req to emac_alloc_dma_req
> > > > > - using kzalloc(..., GPF_ATOMIC) in interrupt context to avoid
> > > > > sleeping
> > > > > - retry by using emac_inblk_32bit when emac_dma_inblk_32bit fails
> > > > > - fix some code style issues
> > > > >
> > > > > Change since v5.
> > > > > - fix some code style issue
> > > > >
> > > >
> > > > Hello
> > > >
> > > > I just tested this on a sun4i-a10-olinuxino-lime
> > > >
> > > > I got:
> > > > [ 2.922812] sun4i-emac 1c0b000.ethernet (unnamed net_device) (uninitialized): get io resource from device: 0x1c0b000, size = 4096
> > > > [ 2.934512] sun4i-emac 1c0b000.ethernet (unnamed net_device) (uninitialized): failed to request dma channel. dma is disabled
> > > > [ 2.945740] sun4i-emac 1c0b000.ethernet (unnamed net_device) (uninitialized): configure dma failed. disable dma.
> > > > [ 2.957887] sun4i-emac 1c0b000.ethernet: eth0: at (ptrval), IRQ 19 MAC: 02:49:09:40:ab:3d
> > > >
> > > > On which board did you test it and how ?
> > > >
> > > > Regards
> > >
> > > Sorry. I sent the email with text/html format. This email is an clean version.
> > >
> > > In order to enable dma rx channel. `dmas` and `dma-names` properties
> > > should be added to emac section in dts:
> > >
> > > emac: ethernet@1c0b000 {
> > > ...
> > > dmas = <&dma SUN4I_DMA_DEDICATED 7>;
> > > dma-names = "rx";
> > > ...
> > > }
> >
> > Helo
> >
> > Yes I figured that out. But you should have done a patch serie adding this.
> > Your patch is now applied but it is a useless change without the dtb change.
> > You should also probably update the driver binding (Documentation/devicetree/bindings/net/allwinner,sun4i-a10-emac.yaml) since you add new members to DT node.
> >
> > Furthermore, why did you add RX only and not TX dma also ?
> >
> > Probably it is too late since patch is applied but it is:
> > Tested-by: Corentin Labbe <[email protected]>
> > Tested-on: sun4i-a10-olinuxino-lime
> >
> > Regards
>
> Thanks for your suggestion. I will submit a patch to add those changes
> later.
>
> And the reason why I didn't add TX support is becasuse there is no any
> public page to describe sun4i emac TX DMA register map. So, I don't known
> how to enable TX DMA at hardware level. If you has any page or datasheet
> about EMAC TX DMA, can you share with me ? Thanks.
Hello
You can find TX DMA info on the R40 Use manual (8.10.5.2 Register Name: EMAC_TX_MODE)
You should keep all people in CC when you answer to someone.
Regards
On 01/03/22 at 12:42下午, Corentin Labbe wrote:
> Date: Mon, 3 Jan 2022 12:42:58 +0100
> From: Corentin Labbe <[email protected]>
> To: Conley Lee <[email protected]>
> Cc: [email protected], [email protected], [email protected],
> [email protected], [email protected],
> [email protected], [email protected],
> [email protected]
> Subject: Re: [PATCH v6] sun4i-emac.c: add dma support
>
> Le Mon, Jan 03, 2022 at 10:55:04AM +0800, Conley Lee a écrit :
> > On 01/02/22 at 06:38下午, Corentin Labbe wrote:
> > > Date: Sun, 2 Jan 2022 18:38:51 +0100
> > > From: Corentin Labbe <[email protected]>
> > > To: Conley Lee <[email protected]>
> > > Cc: [email protected], [email protected], [email protected],
> > > [email protected], [email protected],
> > > [email protected], [email protected],
> > > [email protected], [email protected]
> > > Subject: Re: [PATCH v6] sun4i-emac.c: add dma support
> > >
> > > Le Sat, Jan 01, 2022 at 03:09:01PM +0800, Conley Lee a écrit :
> > > > On 12/31/21 at 11:43上午, Corentin Labbe wrote:
> > > > > Date: Fri, 31 Dec 2021 11:43:53 +0100
> > > > > From: Corentin Labbe <[email protected]>
> > > > > To: [email protected]
> > > > > Cc: [email protected], [email protected], [email protected],
> > > > > [email protected], [email protected],
> > > > > [email protected], [email protected]
> > > > > Subject: Re: [PATCH v6] sun4i-emac.c: add dma support
> > > > >
> > > > > Le Wed, Dec 29, 2021 at 09:43:51AM +0800, [email protected] a écrit :
> > > > > > From: Conley Lee <[email protected]>
> > > > > >
> > > > > > Thanks for your review. Here is the new version for this patch.
> > > > > >
> > > > > > This patch adds support for the emac rx dma present on sun4i. The emac
> > > > > > is able to move packets from rx fifo to RAM by using dma.
> > > > > >
> > > > > > Change since v4.
> > > > > > - rename sbk field to skb
> > > > > > - rename alloc_emac_dma_req to emac_alloc_dma_req
> > > > > > - using kzalloc(..., GPF_ATOMIC) in interrupt context to avoid
> > > > > > sleeping
> > > > > > - retry by using emac_inblk_32bit when emac_dma_inblk_32bit fails
> > > > > > - fix some code style issues
> > > > > >
> > > > > > Change since v5.
> > > > > > - fix some code style issue
> > > > > >
> > > > >
> > > > > Hello
> > > > >
> > > > > I just tested this on a sun4i-a10-olinuxino-lime
> > > > >
> > > > > I got:
> > > > > [ 2.922812] sun4i-emac 1c0b000.ethernet (unnamed net_device) (uninitialized): get io resource from device: 0x1c0b000, size = 4096
> > > > > [ 2.934512] sun4i-emac 1c0b000.ethernet (unnamed net_device) (uninitialized): failed to request dma channel. dma is disabled
> > > > > [ 2.945740] sun4i-emac 1c0b000.ethernet (unnamed net_device) (uninitialized): configure dma failed. disable dma.
> > > > > [ 2.957887] sun4i-emac 1c0b000.ethernet: eth0: at (ptrval), IRQ 19 MAC: 02:49:09:40:ab:3d
> > > > >
> > > > > On which board did you test it and how ?
> > > > >
> > > > > Regards
> > > >
> > > > Sorry. I sent the email with text/html format. This email is an clean version.
> > > >
> > > > In order to enable dma rx channel. `dmas` and `dma-names` properties
> > > > should be added to emac section in dts:
> > > >
> > > > emac: ethernet@1c0b000 {
> > > > ...
> > > > dmas = <&dma SUN4I_DMA_DEDICATED 7>;
> > > > dma-names = "rx";
> > > > ...
> > > > }
> > >
> > > Helo
> > >
> > > Yes I figured that out. But you should have done a patch serie adding this.
> > > Your patch is now applied but it is a useless change without the dtb change.
> > > You should also probably update the driver binding (Documentation/devicetree/bindings/net/allwinner,sun4i-a10-emac.yaml) since you add new members to DT node.
> > >
> > > Furthermore, why did you add RX only and not TX dma also ?
> > >
> > > Probably it is too late since patch is applied but it is:
> > > Tested-by: Corentin Labbe <[email protected]>
> > > Tested-on: sun4i-a10-olinuxino-lime
> > >
> > > Regards
> >
> > Thanks for your suggestion. I will submit a patch to add those changes
> > later.
> >
> > And the reason why I didn't add TX support is becasuse there is no any
> > public page to describe sun4i emac TX DMA register map. So, I don't known
> > how to enable TX DMA at hardware level. If you has any page or datasheet
> > about EMAC TX DMA, can you share with me ? Thanks.
>
> Hello
>
> You can find TX DMA info on the R40 Use manual (8.10.5.2 Register Name: EMAC_TX_MODE)
>
> You should keep all people in CC when you answer to someone.
>
> Regards
Haha, got it! I have been looking for the docs about emac register map
for a long time. You really help me a lot. I will submit a new patch to
add driver bidding and enable both RX and TX channels. Thanks ~
On Wed, Dec 29, 2021 at 09:43:51AM +0800, [email protected] wrote:
> From: Conley Lee <[email protected]>
>
> Thanks for your review. Here is the new version for this patch.
>
> This patch adds support for the emac rx dma present on sun4i. The emac
> is able to move packets from rx fifo to RAM by using dma.
>
> Change since v4.
> - rename sbk field to skb
> - rename alloc_emac_dma_req to emac_alloc_dma_req
> - using kzalloc(..., GPF_ATOMIC) in interrupt context to avoid
> sleeping
> - retry by using emac_inblk_32bit when emac_dma_inblk_32bit fails
> - fix some code style issues
>
> Change since v5.
> - fix some code style issue
>
> Signed-off-by: Conley Lee <[email protected]>
> ---
> drivers/net/ethernet/allwinner/sun4i-emac.c | 200 ++++++++++++++++++++
> 1 file changed, 200 insertions(+)
This is causing build failures:
$ make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 allmodconfig
$ make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 -j... -k -s
drivers/net/ethernet/allwinner/sun4i-emac.c: In function 'emac_configure_dma':
drivers/net/ethernet/allwinner/sun4i-emac.c:922:60: error: format '%x' expects argument of type 'unsigned int', but argument 3 has type 'resource_size_t' {aka 'long long unsigned int'} [-Werror=format=]
922 | netdev_info(ndev, "get io resource from device: 0x%x, size = %u\n",
| ~^
| | | unsigned int
| %llx
923 | regs->start, resource_size(regs));
| ~~~~~~~~~~~
| |
| resource_size_t {aka long long unsigned int}
drivers/net/ethernet/allwinner/sun4i-emac.c:922:71: error: format '%u' expects argument of type 'unsigned int', but argument 4 has type 'resource_size_t' {aka 'long long unsigned int'} [-Werror=format=]
922 | netdev_info(ndev, "get io resource from device: 0x%x, size = %u\n",
| ~^
| |
| unsigned int
| %llu
923 | regs->start, resource_size(regs));
| ~~~~~~~~~~~~~~~~~~~
| |
| resource_size_t {aka long long unsigned int}
--
Kees Cook
On Fri, 7 Jan 2022 15:34:18 -0800 Kees Cook wrote:
> On Wed, Dec 29, 2021 at 09:43:51AM +0800, [email protected] wrote:
> > From: Conley Lee <[email protected]>
> >
> > Thanks for your review. Here is the new version for this patch.
> >
> > This patch adds support for the emac rx dma present on sun4i. The emac
> > is able to move packets from rx fifo to RAM by using dma.
> >
> > Change since v4.
> > - rename sbk field to skb
> > - rename alloc_emac_dma_req to emac_alloc_dma_req
> > - using kzalloc(..., GPF_ATOMIC) in interrupt context to avoid
> > sleeping
> > - retry by using emac_inblk_32bit when emac_dma_inblk_32bit fails
> > - fix some code style issues
> >
> > Change since v5.
> > - fix some code style issue
> >
> > Signed-off-by: Conley Lee <[email protected]>
>
> This is causing build failures:
>
> $ make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 allmodconfig
> $ make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 -j... -k -s
> drivers/net/ethernet/allwinner/sun4i-emac.c: In function 'emac_configure_dma':
> drivers/net/ethernet/allwinner/sun4i-emac.c:922:60: error: format '%x' expects argument of type 'unsigned int', but argument 3 has type 'resource_size_t' {aka 'long long unsigned int'} [-Werror=format=]
> 922 | netdev_info(ndev, "get io resource from device: 0x%x, size = %u\n",
> | ~^
> | | | unsigned int
> | %llx
> 923 | regs->start, resource_size(regs));
> | ~~~~~~~~~~~
> | |
> | resource_size_t {aka long long unsigned int}
> drivers/net/ethernet/allwinner/sun4i-emac.c:922:71: error: format '%u' expects argument of type 'unsigned int', but argument 4 has type 'resource_size_t' {aka 'long long unsigned int'} [-Werror=format=]
> 922 | netdev_info(ndev, "get io resource from device: 0x%x, size = %u\n",
> | ~^
> | |
> | unsigned int
> | %llu
> 923 | regs->start, resource_size(regs));
> | ~~~~~~~~~~~~~~~~~~~
> | |
> | resource_size_t {aka long long unsigned int}
>
Ugh, I saw this and somehow it didn't enter my brain that it's new.
%pa right? Let me test that and send a fix before we close net-next..
Le Thu, Dec 30, 2021 at 02:00:11AM +0000, [email protected] a ?crit :
> Hello:
>
> This patch was applied to netdev/net-next.git (master)
> by Jakub Kicinski <[email protected]>:
>
> On Wed, 29 Dec 2021 09:43:51 +0800 you wrote:
> > From: Conley Lee <[email protected]>
> >
> > Thanks for your review. Here is the new version for this patch.
> >
> > This patch adds support for the emac rx dma present on sun4i. The emac
> > is able to move packets from rx fifo to RAM by using dma.
> >
> > [...]
>
> Here is the summary with links:
> - [v6] sun4i-emac.c: add dma support
> https://git.kernel.org/netdev/net-next/c/47869e82c8b8
>
> You are awesome, thank you!
> --
> Deet-doot-dot, I am a bot.
> https://korg.docs.kernel.org/patchwork/pwbot.html
>
Hello
Any news on patch which enable sun4i-emac DMA in DT ?
Regards
Le Mon, May 30, 2022 at 11:48:19AM -0700, Jakub Kicinski a ?crit :
> On Mon, 30 May 2022 06:51:14 +0200 Corentin Labbe wrote:
> > Any news on patch which enable sun4i-emac DMA in DT ?
>
> Who are you directing this question to and where's that patch posted?
I am sorry, I fail to set the right "to:"
My question was for Conley Lee.
This serie was applied but the DT part was never posted.
So sun4i-emac can handle DMA but is not enabled at all.
The DT patch is easy, so without answer, I will send it.
Regards
On Mon, 30 May 2022 06:51:14 +0200 Corentin Labbe wrote:
> Any news on patch which enable sun4i-emac DMA in DT ?
Who are you directing this question to and where's that patch posted?