Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3516507pxf; Mon, 15 Mar 2021 11:16:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzUp1Dnh6LnW5dEA8Tf2SLnOhLN5WMLD8KBho5WPwNPdfZfqhfUt1EOCB55INxRCgnPXdAe X-Received: by 2002:a05:6402:4395:: with SMTP id o21mr30931777edc.22.1615832207602; Mon, 15 Mar 2021 11:16:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615832207; cv=none; d=google.com; s=arc-20160816; b=ozslmnCMIHNApN6k9Qvsxc7OMZXAZvsXlDjnLxTwr3s3adiRJyo1WMpS8S9HlgGHzf TWfILrbG0gOnQPLw62LzdtLrHqfMlPLM9RCoTvAd7ooWGLqfZcLXNnRiu3WWjv363P4F CevGxtwQSt32Vi7+IBkKMd4inwjQLeUwg9mjeAKvnrQ7HP54vailEgSp5/UUNdJj2P/f oiOdjnV47q6ri8NFzd94asbYYMaQvcjq8QvEd9LnFbM3UsiWpqT6g7hIaYxWyTWnAS+7 lNEjnQcYpzOPt3JSHzwX3zeSMOJ1uUv2dEnkehqgzh2Y4+dBupBWzJLjs4CtEemKFTLJ 2MXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=2e9ewWY0T8S7jIF8aNkAvCnfC+bCy3hfYxG3cxvz19E=; b=mY85H3Ee6WOQ47OVTXt7IYYbBTa1t7yJzOAitjDbh6Tvcprcf5gWWMgX0FS0zKufq1 rT7dWGCV92ZKJfQGtIWdZQhYLJ/vH5Pf1FzvJsnIUIT/FhlleKPOfuvratJk75WT5E3B erQyOF2EXyyxNjoW9owzqSkfg3Cog+s+nQKY80ILWsOI0NFk3AdkOkO9GiDmSXaRSIUq hh5PXzp5d/FgIysXW6jJrrpf8GlVTGAhDIMxXMoEMc7U+Y7z9V4HVF9xgau6BXOWCzqn wH439x3I/A4Xprb50hY+O9ypcUL4DaL2iC6hLwx2d0VzFzX69EXfgDuOeZk8lIwiKp3a J3ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="B/tzyd5y"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h1si12089406ejf.242.2021.03.15.11.16.25; Mon, 15 Mar 2021 11:16:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="B/tzyd5y"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232597AbhCOOOD (ORCPT + 99 others); Mon, 15 Mar 2021 10:14:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:36764 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232564AbhCON7D (ORCPT ); Mon, 15 Mar 2021 09:59:03 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B7EAC64F5C; Mon, 15 Mar 2021 13:58:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816716; bh=JtBJTvl/hSd6qVgLfM+wPeaj8TIgm/5wvFxCOPJBIDY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B/tzyd5yEioxwFYUpLBKW6A0q7MUAUrGjOffT74bwhNPPRpXfhctcpwRUO9LV3yny JjqUGVhpWlt2iyQOwSqltEN/6W/ARlaLdcrMQ92sUfCk1hq/4yrej4ouUScO+j/uTM 5lIbmBnKv3fLgV6ZkNyDKVqfZSf04GP4Iw1vd4eg= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Joakim Zhang , Jakub Kicinski Subject: [PATCH 5.11 082/306] net: stmmac: fix wrongly set buffer2 valid when sph unsupport Date: Mon, 15 Mar 2021 14:52:25 +0100 Message-Id: <20210315135510.422397107@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135507.611436477@linuxfoundation.org> References: <20210315135507.611436477@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman From: Joakim Zhang commit 396e13e11577b614db77db0bbb6fca935b94eb1b upstream. In current driver, buffer2 available only when hardware supports split header. Wrongly set buffer2 valid in stmmac_rx_refill when refill buffer address. You can see that desc3 is 0x81000000 after initialization, but turn out to be 0x83000000 after refill. Fixes: 67afd6d1cfdf ("net: stmmac: Add Split Header support and enable it in XGMAC cores") Signed-off-by: Joakim Zhang Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c | 9 +++++++-- drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c | 2 +- drivers/net/ethernet/stmicro/stmmac/hwif.h | 2 +- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 8 ++++++-- 4 files changed, 15 insertions(+), 6 deletions(-) --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c @@ -499,10 +499,15 @@ static void dwmac4_get_rx_header_len(str *len = le32_to_cpu(p->des2) & RDES2_HL; } -static void dwmac4_set_sec_addr(struct dma_desc *p, dma_addr_t addr) +static void dwmac4_set_sec_addr(struct dma_desc *p, dma_addr_t addr, bool buf2_valid) { p->des2 = cpu_to_le32(lower_32_bits(addr)); - p->des3 = cpu_to_le32(upper_32_bits(addr) | RDES3_BUFFER2_VALID_ADDR); + p->des3 = cpu_to_le32(upper_32_bits(addr)); + + if (buf2_valid) + p->des3 |= cpu_to_le32(RDES3_BUFFER2_VALID_ADDR); + else + p->des3 &= cpu_to_le32(~RDES3_BUFFER2_VALID_ADDR); } static void dwmac4_set_tbs(struct dma_edesc *p, u32 sec, u32 nsec) --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c @@ -292,7 +292,7 @@ static void dwxgmac2_get_rx_header_len(s *len = le32_to_cpu(p->des2) & XGMAC_RDES2_HL; } -static void dwxgmac2_set_sec_addr(struct dma_desc *p, dma_addr_t addr) +static void dwxgmac2_set_sec_addr(struct dma_desc *p, dma_addr_t addr, bool is_valid) { p->des2 = cpu_to_le32(lower_32_bits(addr)); p->des3 = cpu_to_le32(upper_32_bits(addr)); --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h @@ -91,7 +91,7 @@ struct stmmac_desc_ops { int (*get_rx_hash)(struct dma_desc *p, u32 *hash, enum pkt_hash_types *type); void (*get_rx_header_len)(struct dma_desc *p, unsigned int *len); - void (*set_sec_addr)(struct dma_desc *p, dma_addr_t addr); + void (*set_sec_addr)(struct dma_desc *p, dma_addr_t addr, bool buf2_valid); void (*set_sarc)(struct dma_desc *p, u32 sarc_type); void (*set_vlan_tag)(struct dma_desc *p, u16 tag, u16 inner_tag, u32 inner_type); --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -1303,9 +1303,10 @@ static int stmmac_init_rx_buffers(struct return -ENOMEM; buf->sec_addr = page_pool_get_dma_addr(buf->sec_page); - stmmac_set_desc_sec_addr(priv, p, buf->sec_addr); + stmmac_set_desc_sec_addr(priv, p, buf->sec_addr, true); } else { buf->sec_page = NULL; + stmmac_set_desc_sec_addr(priv, p, buf->sec_addr, false); } buf->addr = page_pool_get_dma_addr(buf->page); @@ -3648,7 +3649,10 @@ static inline void stmmac_rx_refill(stru DMA_FROM_DEVICE); stmmac_set_desc_addr(priv, p, buf->addr); - stmmac_set_desc_sec_addr(priv, p, buf->sec_addr); + if (priv->sph) + stmmac_set_desc_sec_addr(priv, p, buf->sec_addr, true); + else + stmmac_set_desc_sec_addr(priv, p, buf->sec_addr, false); stmmac_refill_desc3(priv, rx_q, p); rx_q->rx_count_frames++;