From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.127.231.40 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796116624; b=Y3zyXPLYpALiQOTGx9nVJ+uUgKpOPfMy6+HcAG+rbSBarpiK/4oB7qxAB8b9BmeOU0aM TGKEGnlM0hc1ZkI2ZF8D86jlmLMg/rKf1/s679flhxWkT6ZBOY+ohbmhlJVe7w7XKMYYe f09BTsxShkDkHfFi8BuzkMKkqDyEldJfiU0XuIkyyrWly8qYIO8lR4JOD8Pwxhsl2dD/n jORC9ESfaIWNJlqHtB85vNhxhyQ/6jSgVPs5GI4GrMQjIWGw+abwkPa0ATag3XWWym4Qu KNizQspIohcNk0THK8K7yZ3tDXZtfpv535Zi3T485tzDnc7EoAMGM6HxK8LkOl29HOA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796116624; h=DMARC-Filter:DKIM-Signature:References:User-Agent:X-Lms-Return-Path: Content-Transfer-Encoding:From:In-Reply-To:X-Original-From:To:Cc: Subject:Message-Id:Mime-Version:Content-Type:Date:Received; bh=T6TMGiBbS+xAEHA/qo1QmpN6ttZN/eHVH8pWWzWUt4U=; b=ec6vV7Z5JWNmOLCaV6fwYdV9mO6kM+1VyYV2DqX1lKG/sBRhy2tTmHY++FVhZQMFm9lD H94Hz/wvzFGDvJ16QQyDKjNwkOgkDWEEAv+78rCVxk2nls2w7lpCfvFeiWV+lSLLzWXlh eu/TFEOb2OlYNq7WhQ6oTp4P+O/eZBmOlSzsWuuVWLmnr85q8RUoMV3LO8/+tQIgvpIoK gdzomD3w0fN65Ye3uvXD1FLFMNSJe501Qs3sJBjtfwmnmPRTIilxBCP54xJvVE1bWEHz+ 9mXPAtqY0iV/UrLOOE6A2uPK2Do9etYx+a6b2wS6uXw09+m8Xl98A7HA1dpoOt6PDoA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=yunsilicon.com; spf=pass smtp.mailfrom=yunsilicon.com; dkim=pass header.d=yunsilicon.com header.i=@yunsilicon.com header.a=rsa-sha256 header.s=feishu2403070942 header.b=EZhC2MC+; arc=none smtp.remote-ip=209.127.231.40 Received: from va-2-40.ptr.blmpb.com (va-2-40.ptr.blmpb.com [209.127.231.40]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 08933606A325 for ; Tue, 1 Dec 2026 09:17:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 08933606A325 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=yunsilicon.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=yunsilicon.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=yunsilicon.com header.i=@yunsilicon.com header.a=rsa-sha256 header.s=feishu2403070942 header.b=EZhC2MC+ DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=feishu2403070942; d=yunsilicon.com; t=1796116614; h=from:subject: mime-version:from:date:message-id:subject:to:cc:reply-to:content-type: mime-version:in-reply-to:message-id; bh=T6TMGiBbS+xAEHA/qo1QmpN6ttZN/eHVH8pWWzWUt4U=; b=EZhC2MC+6+8mGYzW5/8vOJM2RVapqrx6h7mgkl7orP2u+p0gpvamewAGQeFeVOBYhRPsDL NqlirlG7s2d0txrfZAMt7rBXnluB+tZEpLfq6ukVFGw9b2PR0tK8F07jvxoUmjBuTzo3gd y110OQ+CRqyKZMlO6iN1mMvou5vC+WIsrzRON4DW7B0e/rPRjbv/3FBELOm94oneXHX0/f jEZiti2uk1Lo4tzKDXPF2Sfzu4ZbLd+H0cVCKcus+7Xyu5TntuBUfUVS2Er73zG1Tvz01R SOLfcnShHi6Wfh7OzOjPr2cYU1luBwkvmT1KSnozrC47et5FB2b4gHJPjHQ0SQ== References: <20261126145711.70868-1-tianx@yunsilicon.com> <20261126145715.70868-3-tianx@yunsilicon.com> User-Agent: Mozilla Thunderbird X-Lms-Return-Path: Content-Transfer-Encoding: quoted-printable From: "Xin Tian" In-Reply-To: X-Original-From: Xin Tian To: "Jason Xing" Cc: "Andrew Lunn" , "David S. Miller" , "Eric Dumazet" , "Jakub Kicinski" , "Paolo Abeni" , "Jason Gunthorpe" , "Leon Romanovsky" , "Junxian Huang" , , , , Subject: Re: [PATCH v2 02/11] net/xsc: add doorbell and cmdq MMIO accessors Message-Id: <7eafad4d-0ef9-4d2b-a934-8df3d3c1fe1e@yunsilicon.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Date: Tue, 1 Dec 2026 17:16:49 +0800 Received: from [127.0.0.1] ([183.193.56.176]) by smtp.feishu.cn with ESMTPS; Tue, 01 Dec 2026 17:16:51 +0800 On 11/29/2026 1:47 PM, Jason Xing wrote: > On Thu, Nov 26, 2026 at 10:57=E2=80=AFPM Xin Tian = wrote: >> Provide doorbell writers and cmdq register accessors operating at >> fixed offsets in the compressed-BAR register window. >> >> Signed-off-by: Xin Tian >> --- >> .../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/dri= vers/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_p= id); >> +void xsc_update_rx_db(struct xsc_core_device *xdev, u32 rqn, u32 next_p= id); >> +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_c= id); >> +void xsc_update_eq_ci(struct xsc_core_device *xdev, u32 eqn, u32 next_c= id, 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 +=3D -I$(srctree)/drivers/net/ethernet/yunsili= con/xsc >> >> obj-$(CONFIG_YUNSILICON_XSC_PCI) +=3D xsc_pci.o >> >> -xsc_pci-y :=3D main.o >> +xsc_pci-y :=3D main.o doorbell.o >> diff --git a/drivers/net/ethernet/yunsilicon/xsc/pci/doorbell.c b/driver= s/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 >> +#include >> + >> +#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_p= id) >> +{ >> + u32 db =3D 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 t= he CPU > to an outbound DMA buffer allocated by dma_alloc_coherent() w= ill be > visible to a DMA engine when the CPU writes to its MMIO contr= ol > 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