From patchwork Mon Sep 9 23:19:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 13797691 X-Patchwork-Delegate: kuba@kernel.org Received: from out-185.mta0.migadu.com (out-185.mta0.migadu.com [91.218.175.185]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BE17E210EC for ; Mon, 9 Sep 2024 23:19:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.185 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725923954; cv=none; b=H0SZ6obA96SYVlqd31YbZ9TcSmyEnJMAHvEg7c45gDDoClp0v4Jq8U7dd6RnZxPr5pSJyRhhy26Ip2qFddSw9P6GnznP7S8k8E6wVKAiIJ35cnhgQV07ZpGiP4iA4vuUTyv3DNFit+RYI86iIqBvg4Sar7quOm9v9Rv4PflpGoQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725923954; c=relaxed/simple; bh=Knlly1UiaXRGEzPixfJLe8iKOl23J9M2bOChjJKWJBA=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=MivU2aP1ay6XbeN0buM60KJy97zh59Vx+Q1++iSuZ5f+J3Zr83Srx0kl43UsIJ3j33GgrXs6emTPav3xWVFe1J9fC6he/EHY1u/LQZzjKjYOPaehylP173LQQ5yMRJrKhfgGL9Vs0zDUaS0DXibF/s0nXXd6n+7+1vosnepKVmk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=runfKUP0; arc=none smtp.client-ip=91.218.175.185 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="runfKUP0" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1725923950; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=chp+yovhyTsetuFlGaROcWrUCF7VpX8MgZ8KKDRJoRA=; b=runfKUP0ngU7IMdjKm5h/rIhJ9TJEWgfeYJfoH9j31CVNeSomZghRhBSs4qgirl3k3Ib3u qyKyUlRYy10X9K9aoKa3NVC0jVbcLLjLYcH59k7KqZpugremKpaIg9LUKpNhGKY6bJDgrs GyKr2h7XUFktFnsFUX8zZvvgYma7ryQ= From: Sean Anderson To: Radhey Shyam Pandey , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org Cc: Robert Hancock , linux-kernel@vger.kernel.org, Michal Simek , linux-arm-kernel@lists.infradead.org, Sean Anderson Subject: [PATCH net] net: xilinx: axienet: Schedule NAPI in two steps Date: Mon, 9 Sep 2024 19:19:04 -0400 Message-Id: <20240909231904.1322387-1-sean.anderson@linux.dev> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Patchwork-Delegate: kuba@kernel.org As advised by Documentation/networking/napi.rst, masking IRQs after calling napi_schedule can be racy. Avoid this by only masking/scheduling if napi_schedule_prep returns true. Additionally, since we are running in an IRQ context we can use the irqoff variant as well. Fixes: 9e2bc267e780 ("net: axienet: Use NAPI for TX completion path") Fixes: cc37610caaf8 ("net: axienet: implement NAPI and GRO receive") Signed-off-by: Sean Anderson Reviewed-by: Shannon Nelson --- drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c index 9eb300fc3590..4f67072d5149 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c @@ -1222,9 +1222,10 @@ static irqreturn_t axienet_tx_irq(int irq, void *_ndev) u32 cr = lp->tx_dma_cr; cr &= ~(XAXIDMA_IRQ_IOC_MASK | XAXIDMA_IRQ_DELAY_MASK); - axienet_dma_out32(lp, XAXIDMA_TX_CR_OFFSET, cr); - - napi_schedule(&lp->napi_tx); + if (napi_schedule_prep(&lp->napi_tx)) { + axienet_dma_out32(lp, XAXIDMA_TX_CR_OFFSET, cr); + __napi_schedule_irqoff(&lp->napi_tx); + } } return IRQ_HANDLED; @@ -1266,9 +1267,10 @@ static irqreturn_t axienet_rx_irq(int irq, void *_ndev) u32 cr = lp->rx_dma_cr; cr &= ~(XAXIDMA_IRQ_IOC_MASK | XAXIDMA_IRQ_DELAY_MASK); - axienet_dma_out32(lp, XAXIDMA_RX_CR_OFFSET, cr); - - napi_schedule(&lp->napi_rx); + if (napi_schedule_prep(&lp->napi_rx)) { + axienet_dma_out32(lp, XAXIDMA_RX_CR_OFFSET, cr); + __napi_schedule_irqoff(&lp->napi_rx); + } } return IRQ_HANDLED;