Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp606214ybl; Fri, 10 Jan 2020 03:56:26 -0800 (PST) X-Google-Smtp-Source: APXvYqzThOXxfemc1Flnb2pTC/VCxyeqJQEXnKjENZ/+ievQqhLWFyF0LJqZfRSTNMWgujSkaT8J X-Received: by 2002:aca:f555:: with SMTP id t82mr1954139oih.103.1578657386589; Fri, 10 Jan 2020 03:56:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578657386; cv=none; d=google.com; s=arc-20160816; b=CWQ1A1njWGSWT5rvnbZ3reJEIBLSPMEqXLB0VRNdbrYvRN/W3lsE5ihGTSU/GlOGzz qeQXtTEfSV+LZTsNC6TrW5ndBj05ppzAa81fd/U/nuQp3Ql3AcqPb+amRMKrFXqNodBB j1EOeumQzsM1x2MiFcB8ErhC3tXOQP8zC+cujR9+MUv7sRjxKQ/rqEbqnPumasA6H4gz iD3SRqHbhtJHx1e6AIdh8u5tkff+nDCceMZegD8UduqaKLC60Jjw/NDduVtg5zGr0L55 UUZas0Y83DiKd5o3bx90cSxeRDnMVwWa7QaHj8Q9I6o1P1FOdD4A5Ri77h7xQtl8bIVL FieQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=KP7K+f5ZotuIVNN9ky+hIq4GdYIR8Qn0Oi5Y3fyOagg=; b=xzFmV1tPpFxKGBnHO2HWMU9AHcR9hmWm7awOFY9xluXkzAE/RRnGMiB/WCSVc6jCOg J30U4m93lQIzrVEqPZ+LCOcHHeSV9NEskmVgdbCfUohCMawIbEGcZ8yOrU422WTIYVa/ nWv6GXx/iME1kTvTBCZTck2T3oiOu14DuZbS9bWBAp0W6+bUDzUAGfmZe/Qo7kUDPz6b hvncfjAnQv4+GWYSlyfg4kosIlr2OSSaZ2EPiEMwzvSKwWsAt2Zu7OJCYiJ0/maqDisC wdKy4zksHPuE1lN8WTDQcdhCf089Hl8bZbYWBK18e+7fKGnX916rsCdec9s7jpMShVjz FOOg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z1si1090077otp.70.2020.01.10.03.56.14; Fri, 10 Jan 2020 03:56:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728239AbgAJLyy (ORCPT + 99 others); Fri, 10 Jan 2020 06:54:54 -0500 Received: from foss.arm.com ([217.140.110.172]:43218 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728142AbgAJLyl (ORCPT ); Fri, 10 Jan 2020 06:54:41 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 14F7813A1; Fri, 10 Jan 2020 03:54:41 -0800 (PST) Received: from donnerap.arm.com (donnerap.cambridge.arm.com [10.1.197.44]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9FCA23F73B; Fri, 10 Jan 2020 03:54:39 -0800 (PST) From: Andre Przywara To: "David S . Miller" , Radhey Shyam Pandey Cc: Michal Simek , Robert Hancock , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Rob Herring , Mark Rutland , devicetree@vger.kernel.org Subject: [PATCH 13/14] net: axienet: Allow DMA to beyond 4GB Date: Fri, 10 Jan 2020 11:54:14 +0000 Message-Id: <20200110115415.75683-14-andre.przywara@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200110115415.75683-1-andre.przywara@arm.com> References: <20200110115415.75683-1-andre.przywara@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org With all DMA address accesses wrapped, we can actually support 64-bit DMA if this option was chosen at IP integration time. Since there is no way to autodetect the actual address bus width, we make use of the existing "xlnx,addrwidth" DT property to let the driver know about the width. The value in this property should match the "Address Width" parameter used when synthesizing the IP. This increases the DMA mask to let the kernel choose buffers from memory at higher addresses. Cc: Rob Herring Cc: Mark Rutland Cc: devicetree@vger.kernel.org Signed-off-by: Andre Przywara --- .../net/ethernet/xilinx/xilinx_axienet_main.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c index f7f593df0c11..e036834549b3 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c @@ -1786,6 +1786,7 @@ static int axienet_probe(struct platform_device *pdev) struct net_device *ndev; const void *mac_addr; struct resource *ethres; + int addr_width = 32; u32 value; ndev = alloc_etherdev(sizeof(*lp)); @@ -1915,6 +1916,8 @@ static int axienet_probe(struct platform_device *pdev) &dmares); lp->rx_irq = irq_of_parse_and_map(np, 1); lp->tx_irq = irq_of_parse_and_map(np, 0); + of_property_read_u32(np, "xlnx,addrwidth", &addr_width); + of_node_put(np); lp->eth_irq = platform_get_irq(pdev, 0); } else { @@ -1944,6 +1947,9 @@ static int axienet_probe(struct platform_device *pdev) * We can detect this case by writing all 1's to one such register * and see if that sticks: when the IP is configured for 32 bits * only, those registers are RES0. + * We can't autodetect the actual width this way, so we still use + * a 32-bit DMA mask and rely on the xlnk,addrwidth DT property + * to set this properly. * Those MSB registers were introduced in IP v7.1, which we check first. */ if ((axienet_ior(lp, XAE_ID_OFFSET) >> 24) >= 0x9) { @@ -1961,6 +1967,19 @@ static int axienet_probe(struct platform_device *pdev) } } + if (!(lp->features & XAE_FEATURE_DMA_64BIT)) { + if (addr_width > 32) + dev_warn(&pdev->dev, "trimming DMA width from %d to 32 bits\n", + addr_width); + addr_width = 32; + } + + ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(addr_width)); + if (ret) { + dev_err(&pdev->dev, "No suitable DMA available\n"); + goto free_netdev; + } + /* Check for Ethernet core IRQ (optional) */ if (lp->eth_irq <= 0) dev_info(&pdev->dev, "Ethernet core IRQ not defined\n"); -- 2.17.1