mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Xin Tian" <tianx@yunsilicon.com>
To: "Jason Xing" <kerneljasonxing@gmail.com>
Cc: "Andrew Lunn" <andrew+netdev@lunn.ch>,
	 "David S. Miller" <davem@davemloft.net>,
	 "Eric Dumazet" <edumazet@google.com>,
	"Jakub Kicinski" <kuba@kernel.org>,
	 "Paolo Abeni" <pabeni@redhat.com>,
	"Jason Gunthorpe" <jgg@ziepe.ca>,
	 "Leon Romanovsky" <leon@kernel.org>,
	 "Junxian Huang" <huangjunxian6@hisilicon.com>,
	<weihg@yunsilicon.com>,  <linux-kernel@vger.kernel.org>,
	<netdev@vger.kernel.org>,  <linux-rdma@vger.kernel.org>
Subject: Re: [PATCH v2 02/11] net/xsc: add doorbell and cmdq MMIO accessors
Date: Tue, 1 Dec 2026 17:16:49 +0800	[thread overview]
Message-ID: <7eafad4d-0ef9-4d2b-a934-8df3d3c1fe1e@yunsilicon.com> (raw)
In-Reply-To: <CAL+tcoC+ggpjnOfSDrDVGhWwvMU4uGum8S2cM1YTgSC=uNYzig@mail.gmail.com>

On 11/29/2026 1:47 PM, Jason Xing wrote:
> On Thu, Nov 26, 2026 at 10:57 PM Xin Tian <tianx@yunsilicon.com> wrote:
>> Provide doorbell writers and cmdq register accessors operating at
>> fixed offsets in the compressed-BAR register window.
>>
>> Signed-off-by: Xin Tian <tianx@yunsilicon.com>
>> ---
>>   .../ethernet/yunsilicon/xsc/common/xsc_core.h |  15 ++
>>   .../net/ethernet/yunsilicon/xsc/pci/Makefile  |   2 +-
>>   .../ethernet/yunsilicon/xsc/pci/doorbell.c    | 148 ++++++++++++++++++
>>   3 files changed, 164 insertions(+), 1 deletion(-)
>>   create mode 100644 drivers/net/ethernet/yunsilicon/xsc/pci/doorbell.c
>>
>> diff --git a/drivers/net/ethernet/yunsilicon/xsc/common/xsc_core.h b/drivers/net/ethernet/yunsilicon/xsc/common/xsc_core.h
>> index 2d0eda8a2..9580d89a1 100644
>> --- a/drivers/net/ethernet/yunsilicon/xsc/common/xsc_core.h
>> +++ b/drivers/net/ethernet/yunsilicon/xsc/common/xsc_core.h
>> @@ -32,4 +32,19 @@ struct xsc_core_device {
>>          int                     bar_num;
>>   };
>>
>> +void xsc_update_tx_db(struct xsc_core_device *xdev, u32 sqn, u32 next_pid);
>> +void xsc_update_rx_db(struct xsc_core_device *xdev, u32 rqn, u32 next_pid);
>> +void xsc_arm_cq(struct xsc_core_device *xdev, u32 cqn, u32 next_cid, u8 solicited);
>> +void xsc_update_cq_ci(struct xsc_core_device *xdev, u32 cqn, u32 next_cid);
>> +void xsc_update_eq_ci(struct xsc_core_device *xdev, u32 eqn, u32 next_cid, u8 arm);
>> +void xsc_update_cmdq_req_pid(struct xsc_core_device *xdev, u32 req_pid);
>> +void xsc_update_cmdq_rsp_cid(struct xsc_core_device *xdev, u32 rsp_cid);
>> +u32 xsc_get_cmdq_req_pid(struct xsc_core_device *xdev);
>> +u32 xsc_get_cmdq_rsp_pid(struct xsc_core_device *xdev);
>> +u32 xsc_get_cmdq_rsp_cid(struct xsc_core_device *xdev);
>> +void xsc_set_cmdq_req_buf_addr(struct xsc_core_device *xdev, u32 haddr, u32 laddr);
>> +void xsc_set_cmdq_rsp_buf_addr(struct xsc_core_device *xdev, u32 haddr, u32 laddr);
>> +u32 xsc_read_cmdq_err_status(struct xsc_core_device *xdev);
>> +void xsc_clear_cmdq_err_status(struct xsc_core_device *xdev, u32 status);
>> +
>>   #endif
>> diff --git a/drivers/net/ethernet/yunsilicon/xsc/pci/Makefile b/drivers/net/ethernet/yunsilicon/xsc/pci/Makefile
>> index c163aa950..4a08b92cd 100644
>> --- a/drivers/net/ethernet/yunsilicon/xsc/pci/Makefile
>> +++ b/drivers/net/ethernet/yunsilicon/xsc/pci/Makefile
>> @@ -6,4 +6,4 @@ ccflags-y += -I$(srctree)/drivers/net/ethernet/yunsilicon/xsc
>>
>>   obj-$(CONFIG_YUNSILICON_XSC_PCI) += xsc_pci.o
>>
>> -xsc_pci-y := main.o
>> +xsc_pci-y := main.o doorbell.o
>> diff --git a/drivers/net/ethernet/yunsilicon/xsc/pci/doorbell.c b/drivers/net/ethernet/yunsilicon/xsc/pci/doorbell.c
>> new file mode 100644
>> index 000000000..5bd64be67
>> --- /dev/null
>> +++ b/drivers/net/ethernet/yunsilicon/xsc/pci/doorbell.c
>> @@ -0,0 +1,148 @@
>> +// SPDX-License-Identifier: GPL-2.0
>> +/* Copyright (C) 2024 - 2026, Shanghai Yunsilicon Technology Co., Ltd.
>> + * All rights reserved.
>> + */
>> +
>> +#include <linux/kernel.h>
>> +#include <linux/pci.h>
>> +
>> +#include "common/xsc_core.h"
>> +#include "common/xsc_reg.h"
>> +
>> +/* doorbell words */
>> +#define XSC_TX_DB_DATA0_NEXT_PID_MASK  GENMASK(15, 0)
>> +#define XSC_TX_DB_DATA0_QP_ID_MASK     GENMASK(30, 16)
>> +#define XSC_RX_DB_DATA0_NEXT_PID_MASK  GENMASK(12, 0)
>> +#define XSC_RX_DB_DATA0_QP_ID_MASK     GENMASK(27, 13)
>> +#define XSC_CQ_DB_DATA0_NEXT_CID_MASK  GENMASK(15, 0)
>> +#define XSC_CQ_DB_DATA0_CQ_ID_MASK     GENMASK(30, 16)
>> +#define XSC_CQ_DB_DATA0_ARM            BIT(31)
>> +#define XSC_EQ_DB_DATA0_NEXT_CID_MASK  GENMASK(10, 0)
>> +#define XSC_EQ_DB_DATA0_EQ_ID_MASK     GENMASK(21, 11)
>> +#define XSC_EQ_DB_DATA0_ARM            BIT(22)
>> +
>> +static u32 xsc_read32(void __iomem *bar, u32 off)
>> +{
>> +       return readl(bar + off);
>> +}
>> +
>> +static void xsc_write32(void __iomem *bar, u32 off, u32 val)
>> +{
>> +       writel(val, bar + off);
>> +}
>> +
>> +void xsc_update_tx_db(struct xsc_core_device *xdev, u32 sqn, u32 next_pid)
>> +{
>> +       u32 db = FIELD_PREP(XSC_TX_DB_DATA0_NEXT_PID_MASK, next_pid) |
>> +                FIELD_PREP(XSC_TX_DB_DATA0_QP_ID_MASK, sqn);
>> +
>> +       /* Make sure that descriptors are written before
>> +        * updating doorbell record and ringing the doorbell
>> +        */
>> +       wmb();
>> +
>> +       writel(db, xdev->bar + TX_DB_FUNC_MEM_ADDR);
> writel() already guarantees that prior memory writes are complete
> before the MMIO store. Please see Documentation/memory-barriers.txt,
> "readX(), writeX()" rule 3:
>
>          3. A writeX() by a CPU thread to the peripheral will first wait for the
>             completion of all prior writes to memory either issued by, or
>             propagated to, the same thread. This ensures that writes by the CPU
>             to an outbound DMA buffer allocated by dma_alloc_coherent() will be
>             visible to a DMA engine when the CPU writes to its MMIO control
>             register to trigger the transfer.
>
> So I don't see the reason for keeping wmb() when using writel()?
> idpf_rx_buf_hw_update() is a good example.
>
> Thanks,
> Jason

Correct. Will drop all five wmb() calls before writel(), not just tx.


Thanks,

Xin

  reply	other threads:[~2026-12-01  9:17 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26 14:57 [PATCH v2 00/11] net/xsc: add the Yunsilicon XSC ethernet driver Xin Tian
2026-11-26 14:57 ` [PATCH v2 01/11] net/xsc: add Yunsilicon XSC ethernet PCI driver Xin Tian
2026-11-27 15:57   ` netdev-bot+sashiko
2026-11-28 17:32   ` Andrew Lunn
2026-12-01  9:48     ` Xin Tian
2026-11-29  2:53   ` Jason Xing
2026-11-26 14:57 ` [PATCH v2 02/11] net/xsc: add doorbell and cmdq MMIO accessors Xin Tian
2026-11-27 15:57   ` netdev-bot+sashiko
2026-11-29  5:47   ` Jason Xing
2026-12-01  9:16     ` Xin Tian [this message]
2026-11-26 14:57 ` [PATCH v2 03/11] net/xsc: add the command queue Xin Tian
2026-11-27 15:57   ` netdev-bot+sashiko
2026-11-29  7:30   ` Jason Xing
2026-12-01  9:22     ` Xin Tian
2026-11-26 14:57 ` [PATCH v2 04/11] net/xsc: query HCA capabilities and reset function Xin Tian
2026-11-27 15:57   ` netdev-bot+sashiko
2026-11-29  7:48   ` Jason Xing
2026-12-01  9:24     ` Xin Tian
2026-11-26 14:57 ` [PATCH v2 05/11] net/xsc: add event queues and MSI-X Xin Tian
2026-11-27 15:57   ` netdev-bot+sashiko
2026-11-26 14:57 ` [PATCH v2 06/11] net/xsc: add CQ and QP helpers Xin Tian
2026-11-27 15:57   ` netdev-bot+sashiko
2026-11-26 14:57 ` [PATCH v2 07/11] net/xsc: add the ethernet netdev Xin Tian
2026-11-27 15:57   ` netdev-bot+sashiko
2026-11-28 17:49   ` Andrew Lunn
2026-11-26 14:57 ` [PATCH v2 08/11] net/xsc: add the single TX/RX channel Xin Tian
2026-11-27 15:58   ` netdev-bot+sashiko
2026-11-26 14:57 ` [PATCH v2 09/11] net/xsc: report link state changes Xin Tian
2026-11-27 15:58   ` netdev-bot+sashiko
2026-11-26 14:57 ` [PATCH v2 10/11] net/xsc: add the transmit path Xin Tian
2026-11-27 15:58   ` netdev-bot+sashiko
2026-11-26 14:57 ` [PATCH v2 11/11] net/xsc: add the receive path Xin Tian
2026-11-27 15:58   ` netdev-bot+sashiko

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=7eafad4d-0ef9-4d2b-a934-8df3d3c1fe1e@yunsilicon.com \
    --to=tianx@yunsilicon.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=huangjunxian6@hisilicon.com \
    --cc=jgg@ziepe.ca \
    --cc=kerneljasonxing@gmail.com \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=weihg@yunsilicon.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

all inboxes | Powered by JetHome®