From patchwork Thu Jul 4 14:11:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 168471 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2332901ilk; Thu, 4 Jul 2019 07:11:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqzZb1nP/NsOG2nhQk23dZq0R7TfaD/rNdFo75nL5+NN81jInREgBlJI1/VqmUjQqo9v9Afh X-Received: by 2002:a17:902:b94a:: with SMTP id h10mr50313215pls.125.1562249477259; Thu, 04 Jul 2019 07:11:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562249477; cv=none; d=google.com; s=arc-20160816; b=YJfjsY064er7KmNau6yu7SjEM9IrDbgyuB/8KdUrYdIwJXb+W3ySArYHB5V0DFk1Nl mNOdIMpnsqz5v58t5oJQFZb6rvkyaib39aFbldN2xX2qdUNflQ2uX8vZDSsEI6ExkNpJ CY7zzMLD22MYbn3sJQUJAdO60PFjikq3MGeRvU3vpIvQEc/iFfz1jS6MI6EUdVSUSrUi bOo8jKP8QP+thfhFRLqETxe0/ICJHUo/aOxwkKN/WpD77vixgFqrDm41KQK6cxjFYNTD b0X5ucRXQZfoQc7MBpdvOl5++N9KDR/r3pbgeBJE/ZFSMiLt2rdY+gSfglJ+bXsDCm4M a1sQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=xMgsYX1AlkZeW8QfKJgEPDAQtSAEWuuhGQkYf2wCav8=; b=SsjjKLGdyAkwqYXXsk3N/I8vfCoEQ9i/TGWr5xJmPkpj3fqVjLNLdqQN+lm5yEs/b2 c/dOascTaS5vmNNu2GLus+GWsF4cNxdgDFaCRzCSt8ELOnoJxcuJFxc3gSkqch1yehpn slmN3hWg5LaU0ETmS9O9OFmATk/8KxTZmABLb59imC0YfO6F7zaC0JvztIxs/ANtx0YH kBPYUMgVu6oZ0OBQgWpfn4imMoI/J+6rOKBRIMDRA/0v9Eb/iVtjBtjYsgpRUCVXO/7F ogaHZfZoqb6f1cSvMTHEMAYTWo5UWxWidtTVjtv6ryXDnfdxI0hhKQ41zK26ppWnE6vS HNfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vyw9BL0m; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q10si5637224pgf.529.2019.07.04.07.11.17; Thu, 04 Jul 2019 07:11:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vyw9BL0m; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727246AbfGDOLQ (ORCPT + 9 others); Thu, 4 Jul 2019 10:11:16 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:33049 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727196AbfGDOLP (ORCPT ); Thu, 4 Jul 2019 10:11:15 -0400 Received: by mail-wm1-f65.google.com with SMTP id h19so5396836wme.0 for ; Thu, 04 Jul 2019 07:11:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=xMgsYX1AlkZeW8QfKJgEPDAQtSAEWuuhGQkYf2wCav8=; b=vyw9BL0mwIX+t4a0LrutWaKwJqzmyGeqRhJb4ZLLGoziYIzVnwLFAsg38XMko247xQ oDfCs28QNM2NWDPKsRnZTYKV5WSYOFHeb5zPAFvNt8n/HaQ9RiKkl6CipF3LP7oW83Ze S/dyaeQN/78RuVxKaTijc2D7xFdIYc5JfAWW8rvJMT1BtLz3HjAOpLg1EBb5MAc8AZUf yHxoBay/CEfGgv5p7n6n8zrvjGBDfMZWgWSeeQnDkFgXzCFVYRYvaJoKrZcQtmnqJefK vFItL199LiCzdCZ4RG/YRn0z5sjv97WncHKyF9X5RpFPbHGJK+/72FbjBeij5SOO0d/h yTYQ== 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; bh=xMgsYX1AlkZeW8QfKJgEPDAQtSAEWuuhGQkYf2wCav8=; b=X5griqwvEMGMk6hg9WDqCHWIU5S7VdD6RrLF8J1Fk/edwEDzFXBLiszMt+ECsmo3Tf s9wsk3vmpMYHEwHenQbTiIukv07EXOjxpfBhwetLUWx4wmJrlFb3MiocbI6bkBjgmUQV m2Z3qkYD4RGOW+Tt9TBf03muPB3FqlVDaVjSFB0AWU/Tde1gyZUJ5N/Qo+zvYME8ox9P mbwyiC+VAkuhmNpIvEPBH7WEoRw47Yn1PvxUetTgFnwtCdsLT6OV3VNKxa2iG7Be4HlP hHGjOTqnvydRH5d3ir9Aa/EDQPJoC7o8V4tyUdHax3ngsvC2jVmBTBq6m5s7hUSxXs6m Tzxg== X-Gm-Message-State: APjAAAUocc7rfi8E+hPvY6EvqHAJtijNa0IvV+MjrKvDma6F6fnFu9EJ EFy9ZT8ylOxkuW9YyPZcjev1K7FDQf1Lbw== X-Received: by 2002:a7b:cb94:: with SMTP id m20mr12250754wmi.144.1562249473191; Thu, 04 Jul 2019 07:11:13 -0700 (PDT) Received: from apalos.lan (athedsl-428434.home.otenet.gr. [79.131.225.144]) by smtp.gmail.com with ESMTPSA id l11sm5477712wrw.97.2019.07.04.07.11.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 04 Jul 2019 07:11:12 -0700 (PDT) From: Ilias Apalodimas To: netdev@vger.kernel.org, jaswinder.singh@linaro.org Cc: ard.biesheuvel@linaro.org, arnd@arndb.de, Ilias Apalodimas Subject: [PATCH] net: netsec: Sync dma for device on buffer allocation Date: Thu, 4 Jul 2019 17:11:09 +0300 Message-Id: <1562249469-14807-1-git-send-email-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Quoting Arnd, We have to do a sync_single_for_device /somewhere/ before the buffer is given to the device. On a non-cache-coherent machine with a write-back cache, there may be dirty cache lines that get written back after the device DMA's data into it (e.g. from a previous memset from before the buffer got freed), so you absolutely need to flush any dirty cache lines on it first. Since the coherency is configurable in this device make sure we cover all configurations by explicitly syncing the allocated buffer for the device before refilling it's descriptors Signed-off-by: Ilias Apalodimas --- drivers/net/ethernet/socionext/netsec.c | 5 +++++ 1 file changed, 5 insertions(+) -- 2.20.1 diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c index 5544a722543f..e05a7191336d 100644 --- a/drivers/net/ethernet/socionext/netsec.c +++ b/drivers/net/ethernet/socionext/netsec.c @@ -727,6 +727,7 @@ static void *netsec_alloc_rx_data(struct netsec_priv *priv, { struct netsec_desc_ring *dring = &priv->desc_ring[NETSEC_RING_RX]; + enum dma_data_direction dma_dir; struct page *page; page = page_pool_dev_alloc_pages(dring->page_pool); @@ -742,6 +743,10 @@ static void *netsec_alloc_rx_data(struct netsec_priv *priv, * cases and reserve enough space for headroom + skb_shared_info */ *desc_len = PAGE_SIZE - NETSEC_RX_BUF_NON_DATA; + dma_dir = page_pool_get_dma_dir(dring->page_pool); + dma_sync_single_for_device(priv->dev, + *dma_handle - NETSEC_RXBUF_HEADROOM, + PAGE_SIZE, dma_dir); return page_address(page); }