From patchwork Thu Oct 12 17:42:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timur Tabi X-Patchwork-Id: 825002 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=codeaurora.org header.i=@codeaurora.org header.b="bCOD66fF"; dkim=pass (1024-bit key) header.d=codeaurora.org header.i=@codeaurora.org header.b="D7HUqaN7"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3yCdTJ2D7gz9s7M for ; Fri, 13 Oct 2017 04:42:12 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751759AbdJLRmJ (ORCPT ); Thu, 12 Oct 2017 13:42:09 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:55030 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750814AbdJLRmI (ORCPT ); Thu, 12 Oct 2017 13:42:08 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 1CBF56073E; Thu, 12 Oct 2017 17:42:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1507830128; bh=/X2C3DhOsjmFoMwZa0fQ7ICTFccYzznlBSfzrje2U0w=; h=From:To:Cc:Subject:Date:From; b=bCOD66fF913/z6ZuscnF/GfrhoXBRTXOB4vpAYG20o4FNYqW9Fb8Sdh0ZyfwnEt78 eIXNtEi9xfXKQSG6+m/V1T81/QXSfNaUwgxfu93sCxEiq6ZtHayZgPya69ZNtxfJQj wzM/zmRj29iDDNROdqxwiQs6eTcJgkOXce9g6nYU= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED, T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from timur-ubuntu.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: timur@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 3E2FB60209; Thu, 12 Oct 2017 17:42:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1507830127; bh=/X2C3DhOsjmFoMwZa0fQ7ICTFccYzznlBSfzrje2U0w=; h=From:To:Cc:Subject:Date:From; b=D7HUqaN710zvEzyFJAR8dhmnLFVn3+G0u0xTTWf+lf8iti1tXJXjWhg0xBStamOwL 700GaxpiZJJnfVJjXezwKJorvinutpT6kddpRDPjTnxoLb1V4+2vG/ZH3Je+Jub3cb QuVrpqiYdROgKiERaJvWnsDEjTOjlEopyt/aSAEk= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 3E2FB60209 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=timur@codeaurora.org From: Timur Tabi To: "David S. Miller" , netdev@vger.kernel.org, David.Laight@ACULAB.COM Cc: timur@codeaurora.org Subject: [PATCH] Revert "net: qcom/emac: enforce DMA address restrictions" Date: Thu, 12 Oct 2017 12:42:04 -0500 Message-Id: <1507830124-19294-1-git-send-email-timur@codeaurora.org> X-Mailer: git-send-email 1.9.1 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This reverts commit df1ec1b9d0df57e96011f175418dc95b1af46821. It turns out that memory allocated via dma_alloc_coherent is always aligned to the size of the buffer, so there's no way the RRD and RFD can ever be in separate 32-bit regions. Signed-off-by: Timur Tabi --- drivers/net/ethernet/qualcomm/emac/emac-mac.c | 39 +++++++++++---------------- 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/drivers/net/ethernet/qualcomm/emac/emac-mac.c b/drivers/net/ethernet/qualcomm/emac/emac-mac.c index 0f5ece5d9507..9cbb27263742 100644 --- a/drivers/net/ethernet/qualcomm/emac/emac-mac.c +++ b/drivers/net/ethernet/qualcomm/emac/emac-mac.c @@ -734,11 +734,6 @@ static int emac_rx_descs_alloc(struct emac_adapter *adpt) rx_q->rrd.size = rx_q->rrd.count * (adpt->rrd_size * 4); rx_q->rfd.size = rx_q->rfd.count * (adpt->rfd_size * 4); - /* Check if the RRD and RFD are aligned properly, and if not, adjust. */ - if (upper_32_bits(ring_header->dma_addr) != - upper_32_bits(ring_header->dma_addr + ALIGN(rx_q->rrd.size, 8))) - ring_header->used = ALIGN(rx_q->rrd.size, 8); - rx_q->rrd.dma_addr = ring_header->dma_addr + ring_header->used; rx_q->rrd.v_addr = ring_header->v_addr + ring_header->used; ring_header->used += ALIGN(rx_q->rrd.size, 8); @@ -772,18 +767,11 @@ int emac_mac_rx_tx_rings_alloc_all(struct emac_adapter *adpt) /* Ring DMA buffer. Each ring may need up to 8 bytes for alignment, * hence the additional padding bytes are allocated. - * - * Also double the memory allocated for the RRD so that we can - * re-align it if necessary. The EMAC has a restriction that the - * upper 32 bits of the base addresses for the RFD and RRD rings - * must be the same. It is extremely unlikely that this is not the - * case, since the rings are only a few KB in size. However, we - * need to check for this anyway, and if the two rings are not - * compliant, then we re-align. */ - ring_header->size = ALIGN(num_tx_descs * (adpt->tpd_size * 4), 8) + - ALIGN(num_rx_descs * (adpt->rfd_size * 4), 8) + - ALIGN(num_rx_descs * (adpt->rrd_size * 4), 8) * 2; + ring_header->size = num_tx_descs * (adpt->tpd_size * 4) + + num_rx_descs * (adpt->rfd_size * 4) + + num_rx_descs * (adpt->rrd_size * 4) + + 8 + 2 * 8; /* 8 byte per one Tx and two Rx rings */ ring_header->used = 0; ring_header->v_addr = dma_zalloc_coherent(dev, ring_header->size, @@ -792,23 +780,26 @@ int emac_mac_rx_tx_rings_alloc_all(struct emac_adapter *adpt) if (!ring_header->v_addr) return -ENOMEM; - ret = emac_rx_descs_alloc(adpt); - if (ret) { - netdev_err(adpt->netdev, "error: Rx Queue alloc failed\n"); - goto err_alloc_rx; - } + ring_header->used = ALIGN(ring_header->dma_addr, 8) - + ring_header->dma_addr; ret = emac_tx_q_desc_alloc(adpt, &adpt->tx_q); if (ret) { - netdev_err(adpt->netdev, "transmit queue allocation failed\n"); + netdev_err(adpt->netdev, "error: Tx Queue alloc failed\n"); goto err_alloc_tx; } + ret = emac_rx_descs_alloc(adpt); + if (ret) { + netdev_err(adpt->netdev, "error: Rx Queue alloc failed\n"); + goto err_alloc_rx; + } + return 0; -err_alloc_tx: - emac_rx_q_bufs_free(adpt); err_alloc_rx: + emac_tx_q_bufs_free(adpt); +err_alloc_tx: dma_free_coherent(dev, ring_header->size, ring_header->v_addr, ring_header->dma_addr);