From patchwork Wed Jul 3 10:19:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 168406 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp687837ilk; Wed, 3 Jul 2019 03:19:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqzHQVQKtqDv9yMsPj/Tdd3Zor59LiWyqNrtpokjNiNu8gLtCv8jMJOg83zjvuj4iRHK3Oj9 X-Received: by 2002:a65:62ca:: with SMTP id m10mr36203745pgv.57.1562149171982; Wed, 03 Jul 2019 03:19:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562149171; cv=none; d=google.com; s=arc-20160816; b=ky7socfaH+7gmbH+JhvxR5B/BYp6k5dWyVgwmIWppOfjyAqc39rk3WbLrTB3nUMAvp l/EgktCXk1aQrW2VYH0ImOFIBFs6+HbFH2ixKF0Qdd6lORXyln0LYMvGL+xoRifgYN6E JdA3nOw7siPExIrQdYyJZ+Yhaeuzsu246H2dj2ie/eafB1IjJ39eGqQjaSZ00drc7f+o cywuSm/aNLGh3wrR9Ub/qe+tMV5Pmf78+TpzgDrcoceV9OiqrpUBbVVJ8ubCaaEiiFLl W1f1teIKsEdhq5wsqVTv8rY9TA/P+t3qEwgPXziUCE9C//HItDjEThS8k8FfzBqgC6ka f/ww== 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:dkim-signature; bh=F7JFqzRXqxTzUkcqfAtcONZlOP60PRysVxN4UPvDiWY=; b=tRHT4SqDyWITLfy5q2JhwfNDSxRPqB04d8tOcNavQY5J/ZYU6+JcKnhH+xp7a4O0KD 5pb5n8MmhHS48XaLh8zmSic2JwTCQWhn1bGtPm10iVoB/bgxgdIYJKY5bu1RxkVlVOA0 ZnhapI92WjWmf0iagQag6HaEWIxvL8J32lnp1WRLPZPMj89HkU3hywGwKQcZoYgzL5pV +pKpr79mSKJnc/XQpQ5bL0OCmI/MnxFa6n9LB9yY27eyaa7k1S5czARf5U7sRKhVDRkg ktbliND0aKdIVwMSx3Rpq+sII1Pl4+UaY7rIIlFByDQUfP/1pIrAy37QZQSA2ofthNdg l7vA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TXAox2sd; 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 c18si1965596pgc.80.2019.07.03.03.19.31; Wed, 03 Jul 2019 03:19:31 -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=TXAox2sd; 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 S1727004AbfGCKTN (ORCPT + 9 others); Wed, 3 Jul 2019 06:19:13 -0400 Received: from mail-lf1-f68.google.com ([209.85.167.68]:41569 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727088AbfGCKTM (ORCPT ); Wed, 3 Jul 2019 06:19:12 -0400 Received: by mail-lf1-f68.google.com with SMTP id 62so1365575lfa.8 for ; Wed, 03 Jul 2019 03:19:10 -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:in-reply-to:references; bh=F7JFqzRXqxTzUkcqfAtcONZlOP60PRysVxN4UPvDiWY=; b=TXAox2sdWXBNBf+PRssojPI1C03UgoSeeRHKksHkDwWknje+kVCYI4gFwiCbZCxfEY IkgI+mvbjSXUUB6DVZ5qMJ7mz1RVdPm+ypWOjvbis+zWk4d+AihqA88rbKHidV14PiWR J8yJAfhdWtjTPK5Z2v3TiM8zork4wBqowDNGMSUVhiUMESHKEwOevdnHTiqLv97ldpif SoRPCvwrJb0POJBqOSvXIBcFJr1Ti2uZmbHkbFTyPyKisAtav9ThkI6MNIQR4DREmk8a ykPZHSrZYB4zt4dFwXwUr5VzE2AeqmubgnYNxQYwvfm+NLCO8HuyyY1LMKIpDwtXbVPI LK9w== 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; bh=F7JFqzRXqxTzUkcqfAtcONZlOP60PRysVxN4UPvDiWY=; b=kRiGfg8oqhn08rQRnJ1MzVH1eHsl6R2EzpCBlhQoTVfl9Q4VB/pkmBw+D40jU7VRiY DglFZkTXB64pxqwQ4ubqqNRxBgL2NR8UOOM1I56WKITUJzbBEvshqHP2iUbEvcRhZ67r AB9VHE0ymUJlvrLSe5keAA4Lf+UGoxiUOE+hWyUZBPGI2X3mLZyhegR1AOjLRejyf2Cr sxvddZ3GHstbem0qM4BMIxX2q8S3ySH7+7B/sOsiwShH0w1xgsIbGX+/hRnzaPP8WEC9 cc1gJ20TbvjMBR97iXRkSfy+NvLN/6omdsQxczyr7dlMJYYxJ1RbK6baNKy9V64vSJ6v r7sg== X-Gm-Message-State: APjAAAUDZd9UEDo2LJ0VUnnS44YNOFQoxWjBN/v1TXITPQXUfjnOqQSO /OgtoCdjPM7rPRLKnNMQo0svmQ== X-Received: by 2002:ac2:46d5:: with SMTP id p21mr17199495lfo.133.1562149149849; Wed, 03 Jul 2019 03:19:09 -0700 (PDT) Received: from localhost.localdomain (59-201-94-178.pool.ukrtel.net. [178.94.201.59]) by smtp.gmail.com with ESMTPSA id i9sm67267lfl.10.2019.07.03.03.19.08 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 03 Jul 2019 03:19:09 -0700 (PDT) From: Ivan Khoronzhuk To: grygorii.strashko@ti.com, hawk@kernel.org, davem@davemloft.net Cc: ast@kernel.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, xdp-newbies@vger.kernel.org, ilias.apalodimas@linaro.org, netdev@vger.kernel.org, daniel@iogearbox.net, jakub.kicinski@netronome.com, john.fastabend@gmail.com, Ivan Khoronzhuk Subject: [PATCH v6 net-next 2/5] net: ethernet: ti: davinci_cpdma: add dma mapped submit Date: Wed, 3 Jul 2019 13:19:00 +0300 Message-Id: <20190703101903.8411-3-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190703101903.8411-1-ivan.khoronzhuk@linaro.org> References: <20190703101903.8411-1-ivan.khoronzhuk@linaro.org> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org In case if dma mapped packet needs to be sent, like with XDP page pool, the "mapped" submit can be used. This patch adds dma mapped submit based on regular one. Signed-off-by: Ivan Khoronzhuk --- drivers/net/ethernet/ti/davinci_cpdma.c | 89 ++++++++++++++++++++++--- drivers/net/ethernet/ti/davinci_cpdma.h | 4 ++ 2 files changed, 83 insertions(+), 10 deletions(-) -- 2.17.1 diff --git a/drivers/net/ethernet/ti/davinci_cpdma.c b/drivers/net/ethernet/ti/davinci_cpdma.c index 5cf1758d425b..8da46394c0e7 100644 --- a/drivers/net/ethernet/ti/davinci_cpdma.c +++ b/drivers/net/ethernet/ti/davinci_cpdma.c @@ -139,6 +139,7 @@ struct submit_info { int directed; void *token; void *data; + int flags; int len; }; @@ -184,6 +185,8 @@ static struct cpdma_control_info controls[] = { (directed << CPDMA_TO_PORT_SHIFT)); \ } while (0) +#define CPDMA_DMA_EXT_MAP BIT(16) + static void cpdma_desc_pool_destroy(struct cpdma_ctlr *ctlr) { struct cpdma_desc_pool *pool = ctlr->pool; @@ -1015,6 +1018,7 @@ static int cpdma_chan_submit_si(struct submit_info *si) struct cpdma_chan *chan = si->chan; struct cpdma_ctlr *ctlr = chan->ctlr; int len = si->len; + int swlen = len; struct cpdma_desc __iomem *desc; dma_addr_t buffer; u32 mode; @@ -1036,16 +1040,22 @@ static int cpdma_chan_submit_si(struct submit_info *si) chan->stats.runt_transmit_buff++; } - buffer = dma_map_single(ctlr->dev, si->data, len, chan->dir); - ret = dma_mapping_error(ctlr->dev, buffer); - if (ret) { - cpdma_desc_free(ctlr->pool, desc, 1); - return -EINVAL; - } - mode = CPDMA_DESC_OWNER | CPDMA_DESC_SOP | CPDMA_DESC_EOP; cpdma_desc_to_port(chan, mode, si->directed); + if (si->flags & CPDMA_DMA_EXT_MAP) { + buffer = (u32)si->data; + dma_sync_single_for_device(ctlr->dev, buffer, len, chan->dir); + swlen |= CPDMA_DMA_EXT_MAP; + } else { + buffer = dma_map_single(ctlr->dev, si->data, len, chan->dir); + ret = dma_mapping_error(ctlr->dev, buffer); + if (ret) { + cpdma_desc_free(ctlr->pool, desc, 1); + return -EINVAL; + } + } + /* Relaxed IO accessors can be used here as there is read barrier * at the end of write sequence. */ @@ -1055,7 +1065,7 @@ static int cpdma_chan_submit_si(struct submit_info *si) writel_relaxed(mode | len, &desc->hw_mode); writel_relaxed((uintptr_t)si->token, &desc->sw_token); writel_relaxed(buffer, &desc->sw_buffer); - writel_relaxed(len, &desc->sw_len); + writel_relaxed(swlen, &desc->sw_len); desc_read(desc, sw_len); __cpdma_chan_submit(chan, desc); @@ -1079,6 +1089,32 @@ int cpdma_chan_idle_submit(struct cpdma_chan *chan, void *token, void *data, si.data = data; si.len = len; si.directed = directed; + si.flags = 0; + + spin_lock_irqsave(&chan->lock, flags); + if (chan->state == CPDMA_STATE_TEARDOWN) { + spin_unlock_irqrestore(&chan->lock, flags); + return -EINVAL; + } + + ret = cpdma_chan_submit_si(&si); + spin_unlock_irqrestore(&chan->lock, flags); + return ret; +} + +int cpdma_chan_idle_submit_mapped(struct cpdma_chan *chan, void *token, + dma_addr_t data, int len, int directed) +{ + struct submit_info si; + unsigned long flags; + int ret; + + si.chan = chan; + si.token = token; + si.data = (void *)(u32)data; + si.len = len; + si.directed = directed; + si.flags = CPDMA_DMA_EXT_MAP; spin_lock_irqsave(&chan->lock, flags); if (chan->state == CPDMA_STATE_TEARDOWN) { @@ -1103,6 +1139,32 @@ int cpdma_chan_submit(struct cpdma_chan *chan, void *token, void *data, si.data = data; si.len = len; si.directed = directed; + si.flags = 0; + + spin_lock_irqsave(&chan->lock, flags); + if (chan->state != CPDMA_STATE_ACTIVE) { + spin_unlock_irqrestore(&chan->lock, flags); + return -EINVAL; + } + + ret = cpdma_chan_submit_si(&si); + spin_unlock_irqrestore(&chan->lock, flags); + return ret; +} + +int cpdma_chan_submit_mapped(struct cpdma_chan *chan, void *token, + dma_addr_t data, int len, int directed) +{ + struct submit_info si; + unsigned long flags; + int ret; + + si.chan = chan; + si.token = token; + si.data = (void *)(u32)data; + si.len = len; + si.directed = directed; + si.flags = CPDMA_DMA_EXT_MAP; spin_lock_irqsave(&chan->lock, flags); if (chan->state != CPDMA_STATE_ACTIVE) { @@ -1140,10 +1202,17 @@ static void __cpdma_chan_free(struct cpdma_chan *chan, uintptr_t token; token = desc_read(desc, sw_token); - buff_dma = desc_read(desc, sw_buffer); origlen = desc_read(desc, sw_len); - dma_unmap_single(ctlr->dev, buff_dma, origlen, chan->dir); + buff_dma = desc_read(desc, sw_buffer); + if (origlen & CPDMA_DMA_EXT_MAP) { + origlen &= ~CPDMA_DMA_EXT_MAP; + dma_sync_single_for_cpu(ctlr->dev, buff_dma, origlen, + chan->dir); + } else { + dma_unmap_single(ctlr->dev, buff_dma, origlen, chan->dir); + } + cpdma_desc_free(pool, desc, 1); (*chan->handler)((void *)token, outlen, status); } diff --git a/drivers/net/ethernet/ti/davinci_cpdma.h b/drivers/net/ethernet/ti/davinci_cpdma.h index 9343c8c73c1b..0271a20c2e09 100644 --- a/drivers/net/ethernet/ti/davinci_cpdma.h +++ b/drivers/net/ethernet/ti/davinci_cpdma.h @@ -77,8 +77,12 @@ int cpdma_chan_stop(struct cpdma_chan *chan); int cpdma_chan_get_stats(struct cpdma_chan *chan, struct cpdma_chan_stats *stats); +int cpdma_chan_submit_mapped(struct cpdma_chan *chan, void *token, + dma_addr_t data, int len, int directed); int cpdma_chan_submit(struct cpdma_chan *chan, void *token, void *data, int len, int directed); +int cpdma_chan_idle_submit_mapped(struct cpdma_chan *chan, void *token, + dma_addr_t data, int len, int directed); int cpdma_chan_idle_submit(struct cpdma_chan *chan, void *token, void *data, int len, int directed); int cpdma_chan_process(struct cpdma_chan *chan, int quota); From patchwork Wed Jul 3 10:19:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 168403 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp687575ilk; Wed, 3 Jul 2019 03:19:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqzSW0nKsPVrz/LRfVgwu1dqAEpoO9VweiN3PeTdijcBQfIKhHnrE170aOSV/0f2Y70Z6JqZ X-Received: by 2002:a17:902:bb90:: with SMTP id m16mr39173191pls.54.1562149158030; Wed, 03 Jul 2019 03:19:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562149158; cv=none; d=google.com; s=arc-20160816; b=O+DRUsihZ5j1u4a58JGOOIbkjznUNOsQdEqVs5BW0zflwhgdn8MZ2Gz48eFPpoMLoD q+cyN0JVoZ8VOUeDdAu30V0cWnYMixy5IQLCbu/9KtYMKFISITgIA5cQArjoQSNrYeS+ ow9ADB5SgW6hoeldJtAO6maUgJiRPYsNldcchbM6sfLLOwKRpAqT4UxkGRBsnAnlIXAo JJmIunuV7KNN6AilzmZN8jf1PImCZM/ws7BYebiYq2TM5shZUQB+smS25FXr9FYGksdU fExAs2EIG6pD3iuDE+Nsjf5o0shf61TTrRQZ+syA6XQMByMM/tnIWPpyCCDa9U54uZVm l7Kw== 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:dkim-signature; bh=NO88iVnC5CJGavQX1+oifd5FyeZJrmYwPjjZG7dx1kY=; b=NpMjfqv2Cr+AZkf3r3S/mSV0b8XObIN6oOQNVVUBl+X+4Nc6BidRsfeRimyUhHIRhZ VEFeAL5z2y3rneMUmDZ6q2H29a1Ex6EhpKeOTLKR3wvCnxCm7LSnW3UwDDb9RMSMiSI/ jnE4Nh8gBkgNDu9UYaCdni4a4MmkoS+E8D5mag9lR4Eq3SMEpWuA8ug700LaGX9LjZmy kbFTpCBSGFtiTqn45xstdSbRBJ8bM2UIB8qe57FxoM5lFIh93Jsom+yK8J0uiTP0W9qa zD+Xt0rgtKb8fc2rGXliFjFMARu5xd9ez6IeiVY9eaeAhgKXU1BeYLDl6l21PxEVHPiL 1PWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xWYBTfuK; 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 h38si1847795plb.149.2019.07.03.03.19.17; Wed, 03 Jul 2019 03:19:18 -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=xWYBTfuK; 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 S1727188AbfGCKTO (ORCPT + 9 others); Wed, 3 Jul 2019 06:19:14 -0400 Received: from mail-lf1-f49.google.com ([209.85.167.49]:35633 "EHLO mail-lf1-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727108AbfGCKTN (ORCPT ); Wed, 3 Jul 2019 06:19:13 -0400 Received: by mail-lf1-f49.google.com with SMTP id p197so1385765lfa.2 for ; Wed, 03 Jul 2019 03:19:11 -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:in-reply-to:references; bh=NO88iVnC5CJGavQX1+oifd5FyeZJrmYwPjjZG7dx1kY=; b=xWYBTfuK3oxbaw2ihXoCR1u2W/q6BAnSu9cuBDvpQcBnRxJrqDr3icL3pTOdlndgs+ QXqo/j3RtvVa44pp6toHXNoIlGVhbRYMfCOW8QQO2ghQ06fy4ypjGdNgj7T9Gi5S4nOH fDFkAFjhlOlGDQMVULlWzD8KpUv90CS0+hkcx7poj8wdLN0h+GvIUWY7wWwFh/2e/zKZ Th5PGNeqgL0oopeVwiQuJfIXZrkJ/8ZHoOdgNR+0vdq+sL/bAraUeu0UcPNrBlJaB9XP 8/dgRutS7yeilCIy6OCRqECJt9lk/TMVy8V9XXmgTQE9iCu5K6dIjLmym3X+11dbFgqG 0OKw== 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; bh=NO88iVnC5CJGavQX1+oifd5FyeZJrmYwPjjZG7dx1kY=; b=YRt0o/rSlbY8cBCNy26+ezdXuLriIwi+csV52G91F+91Wa1MO3z/KEqd3oj2xUEpJ1 G/QUZrsbD3Ns0bDenjRTVtmm5fldQr0UHVcU/nGJEAsOWzj9gVPGzwpQXJjGPOyR3m9l Sdu6wIH+xJeKY65ozjA/uQFCIyjz1UZKzX2aQVnUORX8hQ8HnvPOFbn2tFBfgQ022ZY1 AI4+CsPmi5b+XxwEBvHajyKH5zsJF9KOAGFKxEgiqnt9VU7eHm2Prbqdq9kDvoNp2TL3 BHCJ5/2BwmRemN5uoKP4G0+ifWXERlUJaGwDBSGsFCp9P2tkBTYUoKAuOS9vMPERx6PK EJkw== X-Gm-Message-State: APjAAAU+GmMBMFYLHNtu7X/vE1HilvR78WZlEBllguwLI6vBqhcUu+7q 2Lt506K3i+JuvIo+oAKb8VQiEg== X-Received: by 2002:ac2:419a:: with SMTP id z26mr14069127lfh.21.1562149150989; Wed, 03 Jul 2019 03:19:10 -0700 (PDT) Received: from localhost.localdomain (59-201-94-178.pool.ukrtel.net. [178.94.201.59]) by smtp.gmail.com with ESMTPSA id i9sm67267lfl.10.2019.07.03.03.19.09 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 03 Jul 2019 03:19:10 -0700 (PDT) From: Ivan Khoronzhuk To: grygorii.strashko@ti.com, hawk@kernel.org, davem@davemloft.net Cc: ast@kernel.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, xdp-newbies@vger.kernel.org, ilias.apalodimas@linaro.org, netdev@vger.kernel.org, daniel@iogearbox.net, jakub.kicinski@netronome.com, john.fastabend@gmail.com, Ivan Khoronzhuk Subject: [PATCH v6 net-next 3/5] net: ethernet: ti: davinci_cpdma: allow desc split while down Date: Wed, 3 Jul 2019 13:19:01 +0300 Message-Id: <20190703101903.8411-4-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190703101903.8411-1-ivan.khoronzhuk@linaro.org> References: <20190703101903.8411-1-ivan.khoronzhuk@linaro.org> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org That's possible to set ring params while interfaces are down. When interface gets up it uses number of descs to fill rx queue and on later on changes to create rx pools. Usually, this resplit can happen after phy is up, but it can be needed before this, so allow it to happen while setting number of rx descs, when interfaces are down. Also, if no dependency on intf state, move it to cpdma layer, where it should be. Signed-off-by: Ivan Khoronzhuk --- drivers/net/ethernet/ti/cpsw_ethtool.c | 9 ++++----- drivers/net/ethernet/ti/davinci_cpdma.c | 10 +++++++++- drivers/net/ethernet/ti/davinci_cpdma.h | 3 +-- 3 files changed, 14 insertions(+), 8 deletions(-) -- 2.17.1 diff --git a/drivers/net/ethernet/ti/cpsw_ethtool.c b/drivers/net/ethernet/ti/cpsw_ethtool.c index f60dc1dfc443..08d7aaee8299 100644 --- a/drivers/net/ethernet/ti/cpsw_ethtool.c +++ b/drivers/net/ethernet/ti/cpsw_ethtool.c @@ -664,15 +664,14 @@ int cpsw_set_ringparam(struct net_device *ndev, cpsw_suspend_data_pass(ndev); - cpdma_set_num_rx_descs(cpsw->dma, ering->rx_pending); - - if (cpsw->usage_count) - cpdma_chan_split_pool(cpsw->dma); + ret = cpdma_set_num_rx_descs(cpsw->dma, ering->rx_pending); + if (ret) + goto err; ret = cpsw_resume_data_pass(ndev); if (!ret) return 0; - +err: dev_err(cpsw->dev, "cannot set ring params, closing device\n"); dev_close(ndev); return ret; diff --git a/drivers/net/ethernet/ti/davinci_cpdma.c b/drivers/net/ethernet/ti/davinci_cpdma.c index 8da46394c0e7..4167b0b77c8e 100644 --- a/drivers/net/ethernet/ti/davinci_cpdma.c +++ b/drivers/net/ethernet/ti/davinci_cpdma.c @@ -1423,8 +1423,16 @@ int cpdma_get_num_tx_descs(struct cpdma_ctlr *ctlr) return ctlr->num_tx_desc; } -void cpdma_set_num_rx_descs(struct cpdma_ctlr *ctlr, int num_rx_desc) +int cpdma_set_num_rx_descs(struct cpdma_ctlr *ctlr, int num_rx_desc) { + unsigned long flags; + int ret; + + spin_lock_irqsave(&ctlr->lock, flags); ctlr->num_rx_desc = num_rx_desc; ctlr->num_tx_desc = ctlr->pool->num_desc - ctlr->num_rx_desc; + ret = cpdma_chan_split_pool(ctlr); + spin_unlock_irqrestore(&ctlr->lock, flags); + + return ret; } diff --git a/drivers/net/ethernet/ti/davinci_cpdma.h b/drivers/net/ethernet/ti/davinci_cpdma.h index 0271a20c2e09..d3cfe234d16a 100644 --- a/drivers/net/ethernet/ti/davinci_cpdma.h +++ b/drivers/net/ethernet/ti/davinci_cpdma.h @@ -116,8 +116,7 @@ enum cpdma_control { int cpdma_control_get(struct cpdma_ctlr *ctlr, int control); int cpdma_control_set(struct cpdma_ctlr *ctlr, int control, int value); int cpdma_get_num_rx_descs(struct cpdma_ctlr *ctlr); -void cpdma_set_num_rx_descs(struct cpdma_ctlr *ctlr, int num_rx_desc); +int cpdma_set_num_rx_descs(struct cpdma_ctlr *ctlr, int num_rx_desc); int cpdma_get_num_tx_descs(struct cpdma_ctlr *ctlr); -int cpdma_chan_split_pool(struct cpdma_ctlr *ctlr); #endif