devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lorenzo Bianconi <lorenzo@kernel.org>
To: AngeloGioacchino Del Regno  <angelogioacchino.delregno@collabora.com>
Cc: netdev@vger.kernel.org, nbd@nbd.name, john@phrozen.org,
	sean.wang@mediatek.com, Mark-MC.Lee@mediatek.com,
	davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, matthias.bgg@gmail.com,
	linux-mediatek@lists.infradead.org, lorenzo.bianconi@redhat.com,
	Bo.Jiao@mediatek.com, sujuan.chen@mediatek.com,
	ryder.Lee@mediatek.com, evelyn.tsai@mediatek.com,
	devicetree@vger.kernel.org, robh+dt@kernel.org,
	daniel@makrotopia.org, krzysztof.kozlowski+dt@linaro.org
Subject: Re: [PATCH v3 net-next 3/8] net: ethernet: mtk_wed: introduce wed mcu support
Date: Thu, 3 Nov 2022 18:57:11 +0100	[thread overview]
Message-ID: <Y2QA989WNCTuqnDU@lore-desk> (raw)
In-Reply-To: <5248b495-710b-ad72-7813-869dc660cf31@collabora.com>

[-- Attachment #1: Type: text/plain, Size: 5426 bytes --]

> Il 03/11/22 10:28, Lorenzo Bianconi ha scritto:
> > From: Sujuan Chen <sujuan.chen@mediatek.com>
> > 
> > Introduce WED mcu support used to configure WED WO chip.
> > This is a preliminary patch in order to add RX Wireless
> > Ethernet Dispatch available on MT7986 SoC.
> > 
> > Tested-by: Daniel Golle <daniel@makrotopia.org>
> > Co-developed-by: Lorenzo Bianconi <lorenzo@kernel.org>
> > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> > Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
> > ---
> >   drivers/net/ethernet/mediatek/Makefile       |   2 +-
> >   drivers/net/ethernet/mediatek/mtk_wed_mcu.c  | 364 +++++++++++++++++++
> >   drivers/net/ethernet/mediatek/mtk_wed_regs.h |   1 +
> >   drivers/net/ethernet/mediatek/mtk_wed_wo.h   | 152 ++++++++
> >   include/linux/soc/mediatek/mtk_wed.h         |  29 ++
> >   5 files changed, 547 insertions(+), 1 deletion(-)
> >   create mode 100644 drivers/net/ethernet/mediatek/mtk_wed_mcu.c
> >   create mode 100644 drivers/net/ethernet/mediatek/mtk_wed_wo.h
> > 
> > diff --git a/drivers/net/ethernet/mediatek/Makefile b/drivers/net/ethernet/mediatek/Makefile
> > index 45ba0970504a..d4bdefa77159 100644
> > --- a/drivers/net/ethernet/mediatek/Makefile
> > +++ b/drivers/net/ethernet/mediatek/Makefile
> > @@ -5,7 +5,7 @@
> >   obj-$(CONFIG_NET_MEDIATEK_SOC) += mtk_eth.o
> >   mtk_eth-y := mtk_eth_soc.o mtk_sgmii.o mtk_eth_path.o mtk_ppe.o mtk_ppe_debugfs.o mtk_ppe_offload.o
> > -mtk_eth-$(CONFIG_NET_MEDIATEK_SOC_WED) += mtk_wed.o
> > +mtk_eth-$(CONFIG_NET_MEDIATEK_SOC_WED) += mtk_wed.o mtk_wed_mcu.o
> >   ifdef CONFIG_DEBUG_FS
> >   mtk_eth-$(CONFIG_NET_MEDIATEK_SOC_WED) += mtk_wed_debugfs.o
> >   endif
> > diff --git a/drivers/net/ethernet/mediatek/mtk_wed_mcu.c b/drivers/net/ethernet/mediatek/mtk_wed_mcu.c
> > new file mode 100644
> > index 000000000000..20987eecfb52
> > --- /dev/null
> > +++ b/drivers/net/ethernet/mediatek/mtk_wed_mcu.c
> 
> ..snip..
> 
> > +
> > +int mtk_wed_mcu_init(struct mtk_wed_wo *wo)
> > +{
> > +	u32 val;
> > +	int ret;
> > +
> > +	skb_queue_head_init(&wo->mcu.res_q);
> > +	init_waitqueue_head(&wo->mcu.wait);
> > +	mutex_init(&wo->mcu.mutex);
> > +
> > +	ret = mtk_wed_mcu_load_firmware(wo);
> > +	if (ret)
> > +		return ret;
> > +
> > +	do {
> > +		/* get dummy cr */
> > +		val = wed_r32(wo->hw->wed_dev,
> > +			      MTK_WED_SCR0 + 4 * MTK_WED_DUMMY_CR_FWDL);
> > +	} while (val && !time_after(jiffies, jiffies + MTK_FW_DL_TIMEOUT));
> 
> Here you can use readx_poll_timeout() instead: please do so.

ack, I will fix it in v4

> 
> > +
> > +	return val ? -EBUSY : 0;
> > +}
> > +
> > +MODULE_FIRMWARE(MT7986_FIRMWARE_WO0);
> > +MODULE_FIRMWARE(MT7986_FIRMWARE_WO1);
> > diff --git a/drivers/net/ethernet/mediatek/mtk_wed_regs.h b/drivers/net/ethernet/mediatek/mtk_wed_regs.h
> > index e270fb336143..c940b3bb215b 100644
> > --- a/drivers/net/ethernet/mediatek/mtk_wed_regs.h
> > +++ b/drivers/net/ethernet/mediatek/mtk_wed_regs.h
> > @@ -152,6 +152,7 @@ struct mtk_wdma_desc {
> >   #define MTK_WED_RING_RX(_n)				(0x400 + (_n) * 0x10)
> > +#define MTK_WED_SCR0					0x3c0
> >   #define MTK_WED_WPDMA_INT_TRIGGER			0x504
> >   #define MTK_WED_WPDMA_INT_TRIGGER_RX_DONE		BIT(1)
> >   #define MTK_WED_WPDMA_INT_TRIGGER_TX_DONE		GENMASK(5, 4)
> > diff --git a/drivers/net/ethernet/mediatek/mtk_wed_wo.h b/drivers/net/ethernet/mediatek/mtk_wed_wo.h
> > new file mode 100644
> > index 000000000000..2ef3ccdec5bf
> > --- /dev/null
> > +++ b/drivers/net/ethernet/mediatek/mtk_wed_wo.h
> > @@ -0,0 +1,152 @@
> 
> 
> ..snip..
> 
> > +
> > +#define MTK_WO_MCU_CFG_LS_BASE				0 /* XXX: 0x15194000 */
> 
> Since that definition is zero, you can safely remove it: like so, the ones
> following will be a bit more readable.

(removing the XXX) this is a pattern already used in the driver and in mt76. I
would prefer to keep it as it is.

> 
> > +#define MTK_WO_MCU_CFG_LS_HW_VER_ADDR			(MTK_WO_MCU_CFG_LS_BASE + 0x000)
> > +#define MTK_WO_MCU_CFG_LS_FW_VER_ADDR			(MTK_WO_MCU_CFG_LS_BASE + 0x004)
> > +#define MTK_WO_MCU_CFG_LS_CFG_DBG1_ADDR			(MTK_WO_MCU_CFG_LS_BASE + 0x00c)
> > +#define MTK_WO_MCU_CFG_LS_CFG_DBG2_ADDR			(MTK_WO_MCU_CFG_LS_BASE + 0x010)
> > +#define MTK_WO_MCU_CFG_LS_WF_MCCR_ADDR			(MTK_WO_MCU_CFG_LS_BASE + 0x014)
> > +#define MTK_WO_MCU_CFG_LS_WF_MCCR_SET_ADDR		(MTK_WO_MCU_CFG_LS_BASE + 0x018)
> > +#define MTK_WO_MCU_CFG_LS_WF_MCCR_CLR_ADDR		(MTK_WO_MCU_CFG_LS_BASE + 0x01c)
> > +#define MTK_WO_MCU_CFG_LS_WF_MCU_CFG_WM_WA_ADDR		(MTK_WO_MCU_CFG_LS_BASE + 0x050)
> > +#define MTK_WO_MCU_CFG_LS_WM_BOOT_ADDR_ADDR		(MTK_WO_MCU_CFG_LS_BASE + 0x060)
> > +#define MTK_WO_MCU_CFG_LS_WA_BOOT_ADDR_ADDR		(MTK_WO_MCU_CFG_LS_BASE + 0x064)
> 
> ..snip..
> 
> > +
> > +static inline int
> > +mtk_wed_mcu_check_msg(struct mtk_wed_wo *wo, struct sk_buff *skb)
> > +{
> > +	struct mtk_wed_mcu_hdr *hdr = (struct mtk_wed_mcu_hdr *)skb->data;
> > +
> > +	if (hdr->version)
> 
> 	if (hdr->version || skb->len < sizeof(*hdr) || skb->len != le16_to_cpu(hdr->length))
> 		return -EINVAL;

This is just a matter of test, I would prefer as it is.

> 
> 
> > +		return -EINVAL;
> > +
> > +	if (skb->len < sizeof(*hdr))
> > +		return -EINVAL;
> > +
> > +	if (skb->len != le16_to_cpu(hdr->length))
> > +		return -EINVAL;
> > +
> > +	return 0;
> > +}
> > +
> 
> Regards,
> Angelo
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

  reply	other threads:[~2022-11-03 17:57 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-03  9:27 [PATCH v3 net-next 0/8] introduce WED RX support to MT7986 SoC Lorenzo Bianconi
2022-11-03  9:28 ` [PATCH v3 net-next 1/8] arm64: dts: mediatek: mt7986: add support for RX Wireless Ethernet Dispatch Lorenzo Bianconi
2022-11-03 14:13   ` AngeloGioacchino Del Regno
2022-11-03 17:58     ` Lorenzo Bianconi
2022-11-04  9:05     ` Lorenzo Bianconi
2022-11-04  9:10       ` AngeloGioacchino Del Regno
2022-11-03  9:28 ` [PATCH v3 net-next 2/8] dt-bindings: net: mediatek: add WED RX binding for MT7986 eth driver Lorenzo Bianconi
2022-11-03 15:08   ` Krzysztof Kozlowski
2022-11-03 17:51     ` Lorenzo Bianconi
2022-11-03 18:00       ` Krzysztof Kozlowski
2022-11-03 18:29         ` Lorenzo Bianconi
2022-11-07 10:04           ` Krzysztof Kozlowski
2022-11-08 14:20             ` Lorenzo Bianconi
2022-12-06  3:18             ` Sujuan Chen (陈素娟)
2022-11-03  9:28 ` [PATCH v3 net-next 3/8] net: ethernet: mtk_wed: introduce wed mcu support Lorenzo Bianconi
2022-11-03 14:23   ` AngeloGioacchino Del Regno
2022-11-03 17:57     ` Lorenzo Bianconi [this message]
2022-11-04  2:33   ` Daniel Golle
2022-11-04  8:30     ` Lorenzo Bianconi
2022-11-03  9:28 ` [PATCH v3 net-next 4/8] net: ethernet: mtk_wed: introduce wed wo support Lorenzo Bianconi
2022-11-03  9:28 ` [PATCH v3 net-next 5/8] net: ethernet: mtk_wed: rename tx_wdma array in rx_wdma Lorenzo Bianconi
2022-11-03  9:28 ` [PATCH v3 net-next 6/8] net: ethernet: mtk_wed: add configure wed wo support Lorenzo Bianconi
2022-11-03  9:28 ` [PATCH v3 net-next 7/8] net: ethernet: mtk_wed: add rx mib counters Lorenzo Bianconi
2022-11-03  9:28 ` [PATCH v3 net-next 8/8] MAINTAINERS: update MEDIATEK ETHERNET entry Lorenzo Bianconi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y2QA989WNCTuqnDU@lore-desk \
    --to=lorenzo@kernel.org \
    --cc=Bo.Jiao@mediatek.com \
    --cc=Mark-MC.Lee@mediatek.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=daniel@makrotopia.org \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=edumazet@google.com \
    --cc=evelyn.tsai@mediatek.com \
    --cc=john@phrozen.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=kuba@kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=lorenzo.bianconi@redhat.com \
    --cc=matthias.bgg@gmail.com \
    --cc=nbd@nbd.name \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=robh+dt@kernel.org \
    --cc=ryder.Lee@mediatek.com \
    --cc=sean.wang@mediatek.com \
    --cc=sujuan.chen@mediatek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).