From patchwork Tue Jul 30 18:33:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allen X-Patchwork-Id: 13747756 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7B76FC3DA70 for ; Tue, 30 Jul 2024 18:35:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=CJet9BwGTsiRkCm4isnF6ncb/nhFhGOxt0nK/Q3v+7o=; b=Q0UzF8n3Rct+cllD7Pd/GxkuJg bmla+rQt4pA+HAzbG573s9uI9HF0Cz3IV2Z7K/g7aWMQirFL3GD3lYQW3A8ltDuNGO+6ZN0wOvS1J AE56ZXGYUB4aI+3dX9Ub8NLko4zApD/ezAJRmGbMINgJrSJlwDiA5mCXWkFPLe/WvDw13+xwAXius f9LA8V6y/J2PTo6pDyOeVKkuiAfIPtCzrrLJnJX/omcoP17HsznX74cNB/fq6NiGeci8JoQY8R1Wk KI0f0OYib0WPTn3EanGMGo6Bxg1vLPD8ULRQrjXgJlMjhvzPLh2um6t23cVsx7U709vkiAGe/U5Z0 zuMVSvbQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYrgp-0000000G9Xk-2u1k; Tue, 30 Jul 2024 18:35:15 +0000 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYrg3-0000000G9Jv-43rW for linux-arm-kernel@lists.infradead.org; Tue, 30 Jul 2024 18:34:43 +0000 Received: by mail-pg1-x533.google.com with SMTP id 41be03b00d2f7-710437d0affso3209903a12.3 for ; Tue, 30 Jul 2024 11:34:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722364467; x=1722969267; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CJet9BwGTsiRkCm4isnF6ncb/nhFhGOxt0nK/Q3v+7o=; b=cQXZNmzqulvoB22cEwUsyWI6VY1OoqqRw7sZDSPiaTtN/+NbvZJ6BaDDpfmDTjz+Cd kQFlCRKKnTbqKllAbpVlxckF6EZg7PgTdE6haeKBXLxwOo0cgApFQARZsnvxzAR3i6YR cqGr01XmQJ9vUP+iRgAm4F0iMMKsI0paQXL6tTCKc4bs58PBlmbpoHNu0MVIUqY+dCrh EAR87mnFjCfSSPbVTkBUZNJGeMoHnWsfM1RotbZYjF5JBnU3mohylaR0akG+iAU8zz6K o7GyXk8O5N45Dz0J2tLuAbDVILVJFVeb6HW7TaghMHh7C/QdMmpGA/5xHiqR5sbb/HKG 6hcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722364467; x=1722969267; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CJet9BwGTsiRkCm4isnF6ncb/nhFhGOxt0nK/Q3v+7o=; b=MgSJaxgkra7UyIx8XF2QSFYtvvIsIYD4Gxip2wm9Q0oA+ZFdE38jL7kig4yc748SeP 8D6wPySOkXstre+FnXpNXf2LPxK5T1GAPUI0S7HJc1pBiT9IOglCCkua1xunXEpJFp9Y 6r5xwa1/b2mZwfCPPOa2liGwVq+ivlTv9OokMDvg2JDwzcw3byZ3voe18ZuI68Gwt4ip K6Bm6e0u3VBfcpA2rIVuv4FzfQsQaUG1cta8hBGcFxDlAqjdhCk58yrEoDj7gqarC3si M7yayPScrbXHBrFvwOeTrMaX2AthgcdhLAr9DkNW7iG9Prj1Wb4vu2ihDWfmbQ2HcwDu mEbg== X-Forwarded-Encrypted: i=1; AJvYcCXM6NNsdYIpjSoKMXDJGIqI4bmbJSUFMZ9ETW74d7IpNLnxeXo/2lelU62PjIRV7XOns+7f9jR6UtI2kUKRP64cVEfa31hKSzw0YiQM1i4LhKyvjCQ= X-Gm-Message-State: AOJu0YxRTLz1EFLlGRW/v/oaWeUH4SU1xoNutF50Mxub1TcpMCQnFxkv m8ZMmGN9oQPyfQvibKlyfY+1pfzdgNm2czlYxivA8OnCLjBqwv81 X-Google-Smtp-Source: AGHT+IGgF9xUzhoSsyAmcfnDOvxTdaMEnsGXOm516gr3MmxOJWQ9CxoA/oJ6bYQKfm6HPOJaEuM+ZA== X-Received: by 2002:a05:6a20:12d3:b0:1c2:905c:dba with SMTP id adf61e73a8af0-1c4a153356amr10354060637.54.1722364466988; Tue, 30 Jul 2024 11:34:26 -0700 (PDT) Received: from apais-devbox.. ([2001:569:766d:6500:f2df:af9:e1f6:390e]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7a9f817f5a2sm7837763a12.24.2024.07.30.11.34.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jul 2024 11:34:26 -0700 (PDT) From: Allen Pais To: kuba@kernel.org, Sunil Goutham , "David S. Miller" , Eric Dumazet , Paolo Abeni Cc: jes@trained-monkey.org, kda@linux-powerpc.org, cai.huoqing@linux.dev, dougmill@linux.ibm.com, npiggin@gmail.com, christophe.leroy@csgroup.eu, aneesh.kumar@kernel.org, naveen.n.rao@linux.ibm.com, nnac123@linux.ibm.com, tlfalcon@linux.ibm.com, cooldavid@cooldavid.org, marcin.s.wojtas@gmail.com, mlindner@marvell.com, stephen@networkplumber.org, nbd@nbd.name, sean.wang@mediatek.com, Mark-MC.Lee@mediatek.com, lorenzo@kernel.org, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, borisp@nvidia.com, bryan.whitehead@microchip.com, UNGLinuxDriver@microchip.com, louis.peens@corigine.com, richardcochran@gmail.com, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acenic@sunsite.dk, linux-net-drivers@amd.com, netdev@vger.kernel.org, Allen Pais , linux-arm-kernel@lists.infradead.org Subject: [net-next v3 07/15] net: thunderx: Convert tasklet API to new bottom half workqueue mechanism Date: Tue, 30 Jul 2024 11:33:55 -0700 Message-Id: <20240730183403.4176544-8-allen.lkml@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240730183403.4176544-1-allen.lkml@gmail.com> References: <20240730183403.4176544-1-allen.lkml@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240730_113428_029650_E9BC3E7C X-CRM114-Status: GOOD ( 16.56 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Migrate tasklet APIs to the new bottom half workqueue mechanism. It replaces all occurrences of tasklet usage with the appropriate workqueue APIs throughout the cavium/thunderx driver. This transition ensures compatibility with the latest design and enhances performance. Reviewed-by: Sunil Goutham Signed-off-by: Allen Pais --- drivers/net/ethernet/cavium/thunder/nic.h | 5 ++-- .../net/ethernet/cavium/thunder/nicvf_main.c | 24 +++++++++---------- .../ethernet/cavium/thunder/nicvf_queues.c | 4 ++-- .../ethernet/cavium/thunder/nicvf_queues.h | 2 +- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/drivers/net/ethernet/cavium/thunder/nic.h b/drivers/net/ethernet/cavium/thunder/nic.h index 090d6b83982a..ecc175b6e7fa 100644 --- a/drivers/net/ethernet/cavium/thunder/nic.h +++ b/drivers/net/ethernet/cavium/thunder/nic.h @@ -8,6 +8,7 @@ #include #include +#include #include #include "thunder_bgx.h" @@ -295,7 +296,7 @@ struct nicvf { bool rb_work_scheduled; struct page *rb_page; struct delayed_work rbdr_work; - struct tasklet_struct rbdr_task; + struct work_struct rbdr_bh_work; /* Secondary Qset */ u8 sqs_count; @@ -319,7 +320,7 @@ struct nicvf { bool loopback_supported; struct nicvf_rss_info rss_info; struct nicvf_pfc pfc; - struct tasklet_struct qs_err_task; + struct work_struct qs_err_bh_work; struct work_struct reset_task; struct nicvf_work rx_mode_work; /* spinlock to protect workqueue arguments from concurrent access */ diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_main.c b/drivers/net/ethernet/cavium/thunder/nicvf_main.c index aebb9fef3f6e..b0878bd25cf0 100644 --- a/drivers/net/ethernet/cavium/thunder/nicvf_main.c +++ b/drivers/net/ethernet/cavium/thunder/nicvf_main.c @@ -982,9 +982,9 @@ static int nicvf_poll(struct napi_struct *napi, int budget) * * As of now only CQ errors are handled */ -static void nicvf_handle_qs_err(struct tasklet_struct *t) +static void nicvf_handle_qs_err(struct work_struct *work) { - struct nicvf *nic = from_tasklet(nic, t, qs_err_task); + struct nicvf *nic = from_work(nic, work, qs_err_bh_work); struct queue_set *qs = nic->qs; int qidx; u64 status; @@ -1069,7 +1069,7 @@ static irqreturn_t nicvf_rbdr_intr_handler(int irq, void *nicvf_irq) if (!nicvf_is_intr_enabled(nic, NICVF_INTR_RBDR, qidx)) continue; nicvf_disable_intr(nic, NICVF_INTR_RBDR, qidx); - tasklet_hi_schedule(&nic->rbdr_task); + queue_work(system_bh_highpri_wq, &nic->rbdr_bh_work); /* Clear interrupt */ nicvf_clear_intr(nic, NICVF_INTR_RBDR, qidx); } @@ -1085,7 +1085,7 @@ static irqreturn_t nicvf_qs_err_intr_handler(int irq, void *nicvf_irq) /* Disable Qset err interrupt and schedule softirq */ nicvf_disable_intr(nic, NICVF_INTR_QS_ERR, 0); - tasklet_hi_schedule(&nic->qs_err_task); + queue_work(system_bh_highpri_wq, &nic->qs_err_bh_work); nicvf_clear_intr(nic, NICVF_INTR_QS_ERR, 0); return IRQ_HANDLED; @@ -1364,8 +1364,8 @@ int nicvf_stop(struct net_device *netdev) for (irq = 0; irq < nic->num_vec; irq++) synchronize_irq(pci_irq_vector(nic->pdev, irq)); - tasklet_kill(&nic->rbdr_task); - tasklet_kill(&nic->qs_err_task); + cancel_work_sync(&nic->rbdr_bh_work); + cancel_work_sync(&nic->qs_err_bh_work); if (nic->rb_work_scheduled) cancel_delayed_work_sync(&nic->rbdr_work); @@ -1488,11 +1488,11 @@ int nicvf_open(struct net_device *netdev) nicvf_hw_set_mac_addr(nic, netdev); } - /* Init tasklet for handling Qset err interrupt */ - tasklet_setup(&nic->qs_err_task, nicvf_handle_qs_err); + /* Init bh_work for handling Qset err interrupt */ + INIT_WORK(&nic->qs_err_bh_work, nicvf_handle_qs_err); - /* Init RBDR tasklet which will refill RBDR */ - tasklet_setup(&nic->rbdr_task, nicvf_rbdr_task); + /* Init RBDR bh_work which will refill RBDR */ + INIT_WORK(&nic->rbdr_bh_work, nicvf_rbdr_bh_work); INIT_DELAYED_WORK(&nic->rbdr_work, nicvf_rbdr_work); /* Configure CPI alorithm */ @@ -1561,8 +1561,8 @@ int nicvf_open(struct net_device *netdev) cleanup: nicvf_disable_intr(nic, NICVF_INTR_MBOX, 0); nicvf_unregister_interrupts(nic); - tasklet_kill(&nic->qs_err_task); - tasklet_kill(&nic->rbdr_task); + cancel_work_sync(&nic->qs_err_bh_work); + cancel_work_sync(&nic->rbdr_bh_work); napi_del: for (qidx = 0; qidx < qs->cq_cnt; qidx++) { cq_poll = nic->napi[qidx]; diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_queues.c b/drivers/net/ethernet/cavium/thunder/nicvf_queues.c index 06397cc8bb36..ad71160879e4 100644 --- a/drivers/net/ethernet/cavium/thunder/nicvf_queues.c +++ b/drivers/net/ethernet/cavium/thunder/nicvf_queues.c @@ -461,9 +461,9 @@ void nicvf_rbdr_work(struct work_struct *work) } /* In Softirq context, alloc rcv buffers in atomic mode */ -void nicvf_rbdr_task(struct tasklet_struct *t) +void nicvf_rbdr_bh_work(struct work_struct *work) { - struct nicvf *nic = from_tasklet(nic, t, rbdr_task); + struct nicvf *nic = from_work(nic, work, rbdr_bh_work); nicvf_refill_rbdr(nic, GFP_ATOMIC); if (nic->rb_alloc_fail) { diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_queues.h b/drivers/net/ethernet/cavium/thunder/nicvf_queues.h index 8453defc296c..c6f18fb7c50e 100644 --- a/drivers/net/ethernet/cavium/thunder/nicvf_queues.h +++ b/drivers/net/ethernet/cavium/thunder/nicvf_queues.h @@ -348,7 +348,7 @@ void nicvf_xdp_sq_doorbell(struct nicvf *nic, struct snd_queue *sq, int sq_num); struct sk_buff *nicvf_get_rcv_skb(struct nicvf *nic, struct cqe_rx_t *cqe_rx, bool xdp); -void nicvf_rbdr_task(struct tasklet_struct *t); +void nicvf_rbdr_bh_work(struct work_struct *work); void nicvf_rbdr_work(struct work_struct *work); void nicvf_enable_intr(struct nicvf *nic, int int_type, int q_idx);