From patchwork Wed Jul 10 08:38:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jian-Hong Pan X-Patchwork-Id: 11038329 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C9EF014DB for ; Wed, 10 Jul 2019 08:44:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B9E1F28874 for ; Wed, 10 Jul 2019 08:44:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ACFF5288E6; Wed, 10 Jul 2019 08:44:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2FDCC28874 for ; Wed, 10 Jul 2019 08:44:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727591AbfGJIoP (ORCPT ); Wed, 10 Jul 2019 04:44:15 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:44492 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726580AbfGJIoP (ORCPT ); Wed, 10 Jul 2019 04:44:15 -0400 Received: by mail-pf1-f195.google.com with SMTP id t16so755237pfe.11 for ; Wed, 10 Jul 2019 01:44:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=endlessm-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZxB6K90WEOCOsXFUiDbe1sddkLrl4+FMawAXBSkTyfs=; b=Yv02FiX2qw7jZOKTrsoiIMkDDSP78zsxI2V+pkdLGpN8sQ2V9lYpCBTujbjLOd4+XX cDHNZGrU/OY6+FRbsNHKPd9Pi/5iY4BUy8RRb4v/YuXTqTo96k3IM3BvQBPijRhv5ykC 3M8lrau2R5HxxkFPUp0vn7kIiIuFkU0VmWVtqF8NQ8810MvhOKhoHVeynE63w6hpwNtX zqpv0eFQplEjHM793bOPiK6GZZjpPSpLCWoz9X38kBQ8V6Pt15H4jijSHphDEN+Qtimw aurOy9tnyBXRUbgisvNaPCNVSUb0EOgeJPbdyErfH7PHrnO69wdgHiS3AqX/zHyZLQcm S23w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZxB6K90WEOCOsXFUiDbe1sddkLrl4+FMawAXBSkTyfs=; b=We30GlltNYb1gfe2fj+MCaOwr/7wLhuK4lIaLwRDnGmpH2SkwCCLk41+i9oOctAFey Ar0rjThJoFy/5rqQjBBbHDFRKW8FIUp4VKm9VCoCLL9YnZZCr/oeb9QD2GLcfMCx2+9C aTN/eQFmDkwbi26sEx7uSy13CLBYxCLPpDBiDVqF9xANl5DiDE9hqLB+I9F36G0zTfHW Rp/qbaMNiUw8jkc7z3q9UrkZ4HyQ64qR0VaEs3or91wuKStAdwK0c9kIvzMSIuaSioi3 hqoZftyEHRowLgaue6KLQdcRpASoFzHWOc7iPKAMJB/2suJwkuq9pEZYfdrNyr6z4zF2 2VoQ== X-Gm-Message-State: APjAAAUUhIWEpMhuJdB9ZT13EGXmAauTMchZRHQWm8MJ1y+WSpYaXb3v 19d/cfirX1zshYuW2kLAcg0EyQ== X-Google-Smtp-Source: APXvYqx6r3nK/XJfM+4IfR4WIlijQtiFKtASr2UXeXiYiziTXmlsNyQAr1EFL/V112AK8JqshhpfCw== X-Received: by 2002:a63:7d05:: with SMTP id y5mr32971869pgc.425.1562748254525; Wed, 10 Jul 2019 01:44:14 -0700 (PDT) Received: from localhost.localdomain (123-204-46-122.static.seed.net.tw. [123.204.46.122]) by smtp.gmail.com with ESMTPSA id v5sm1378133pgq.66.2019.07.10.01.44.10 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 10 Jul 2019 01:44:14 -0700 (PDT) From: Jian-Hong Pan To: Yan-Hsuan Chuang , Kalle Valo , "David S . Miller" , Larry Finger , David Laight , Christoph Hellwig Cc: linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux@endlessm.com, Daniel Drake , Jian-Hong Pan , stable@vger.kernel.org Subject: [PATCH v3 2/2] rtw88: pci: Use DMA sync instead of remapping in RX ISR Date: Wed, 10 Jul 2019 16:38:27 +0800 Message-Id: <20190710083825.7115-2-jian-hong@endlessm.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190709161550.GA8703@infradead.org> References: <20190709161550.GA8703@infradead.org> MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Since each skb in RX ring is reused instead of new allocation, we can treat the DMA in a more efficient way by DMA synchronization. Signed-off-by: Jian-Hong Pan Cc: --- v2: - New patch by following [PATCH v3 1/2] rtw88: pci: Rearrange the memory usage for skb in RX ISR. v3: - Remove rtw_pci_sync_rx_desc_cpu and call dma_sync_single_for_cpu in rtw_pci_rx_isr directly. - Remove the return value of rtw_pci_sync_rx_desc_device. - Use DMA_FROM_DEVICE instead of PCI_DMA_FROMDEVICE. drivers/net/wireless/realtek/rtw88/pci.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/pci.c b/drivers/net/wireless/realtek/rtw88/pci.c index e9fe3ad896c8..485d30c06935 100644 --- a/drivers/net/wireless/realtek/rtw88/pci.c +++ b/drivers/net/wireless/realtek/rtw88/pci.c @@ -206,6 +206,23 @@ static int rtw_pci_reset_rx_desc(struct rtw_dev *rtwdev, struct sk_buff *skb, return 0; } +static void rtw_pci_sync_rx_desc_device(struct rtw_dev *rtwdev, dma_addr_t dma, + struct rtw_pci_rx_ring *rx_ring, + u32 idx, u32 desc_sz) +{ + struct device *dev = rtwdev->dev; + struct rtw_pci_rx_buffer_desc *buf_desc; + int buf_sz = RTK_PCI_RX_BUF_SIZE; + + dma_sync_single_for_device(dev, dma, buf_sz, DMA_FROM_DEVICE); + + buf_desc = (struct rtw_pci_rx_buffer_desc *)(rx_ring->r.head + + idx * desc_sz); + memset(buf_desc, 0, sizeof(*buf_desc)); + buf_desc->buf_size = cpu_to_le16(RTK_PCI_RX_BUF_SIZE); + buf_desc->dma = cpu_to_le32(dma); +} + static int rtw_pci_init_rx_ring(struct rtw_dev *rtwdev, struct rtw_pci_rx_ring *rx_ring, u8 desc_size, u32 len) @@ -782,8 +799,8 @@ static void rtw_pci_rx_isr(struct rtw_dev *rtwdev, struct rtw_pci *rtwpci, rtw_pci_dma_check(rtwdev, ring, cur_rp); skb = ring->buf[cur_rp]; dma = *((dma_addr_t *)skb->cb); - pci_unmap_single(rtwpci->pdev, dma, RTK_PCI_RX_BUF_SIZE, - PCI_DMA_FROMDEVICE); + dma_sync_single_for_cpu(rtwdev->dev, dma, RTK_PCI_RX_BUF_SIZE, + DMA_FROM_DEVICE); rx_desc = skb->data; chip->ops->query_rx_desc(rtwdev, rx_desc, &pkt_stat, &rx_status); @@ -818,7 +835,8 @@ static void rtw_pci_rx_isr(struct rtw_dev *rtwdev, struct rtw_pci *rtwpci, next_rp: /* new skb delivered to mac80211, re-enable original skb DMA */ - rtw_pci_reset_rx_desc(rtwdev, skb, ring, cur_rp, buf_desc_sz); + rtw_pci_sync_rx_desc_device(rtwdev, dma, ring, cur_rp, + buf_desc_sz); /* host read next element in ring */ if (++cur_rp >= ring->r.len)