Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3523747pxf; Mon, 15 Mar 2021 11:27:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx/sEzDj7+5aIgczuLhxu0MLtm5z0zKVcuSmKG1m3Kz+qynOiJjoBZBAIWHNEM+9q2Qjr1W X-Received: by 2002:a05:6402:3495:: with SMTP id v21mr31243733edc.117.1615832869836; Mon, 15 Mar 2021 11:27:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615832869; cv=none; d=google.com; s=arc-20160816; b=OY3/zjrf6IYt2V+uDAlgBv4dTTRfDIe/q150ls+CoYNcXLrI1Z19z2mpl60UUWZlGq LP2ekBj1BKoWo1IIRVbWxE9egzVWObCBMiMMyvUCRIqj+1p8mgNI/qNCgSvRdx627heA sY37wtLYhmyoiAvBb6+ZATQaQKJJTkGa5ClVizA0r6ZZzrcdSh/fRlB/4UT82jv885Y3 Y/I3ObOfs9haNDMpjIfLdJidOV9qDM4LGj7foRveee5CrhCtnQRAiPflxOKNePNjtcc+ 4CkTrnWWijPRcCUyWYiu5rQ8qRSSpYLimalXT9loM/tbcBrQEA/GyeyyRkvJu3Yp8A/d WcRQ== 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=Bg7lU3kJB5nFUZy6krtKp8P9wDOjmwTJwMCQQWs8GqY=; b=ybce6/Qfh4d+BbnfYzHtA/B1zW0c7IUO7Q291snnbTEGL8+buQuGq8oJ8VT3cYQk71 DeN5fPPLaLslt95OPRL2qKMYq+89GE6xmvVMu9Xg6ib+hmVQaTd2iEY8A/ANfQT5wgJP CLZUxHkkmjNL1hW8+hzX0w9M7Yi6EXiW90RlRZ1XyrNocTZiQL6HuPzYyTWIrx61W2el 05A1o8fyDTEUMTr1goXWL57bYoyCVC+JKcW83Y2alUz0HmqTGWu2nsWHsxIQ4jN4bEmk hhJSOWOP/pJuk09rHjDoHSfi+zAHHSd6d50V/sPZrbr5S7vPl0ypPm9iPwT+9hFBlp8l abjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hIPLfEks; 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 fx16si11214028ejb.342.2021.03.15.11.27.21; Mon, 15 Mar 2021 11:27:49 -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=hIPLfEks; 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 S235360AbhCOOaF (ORCPT + 99 others); Mon, 15 Mar 2021 10:30:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:35610 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232400AbhCON6v (ORCPT ); Mon, 15 Mar 2021 09:58:51 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3A1E764F01; Mon, 15 Mar 2021 13:58:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816708; bh=8QYM/qcOqqWgoHcZT4A8OZgDohUW6Hw8IpH8Va6rB10=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hIPLfEks8A0ZtIFpIP9EErDswyuyy2HuG0FnOTyOGXUOVZDDrBh+2arVCPEo5ijRd VIkhJvifw/sl8gsoCgpHRNIShqtHGzinxeXyKoQQt1xduDT06DPIXoaldQdeLe2qLJ efwd+hv9gus+dCO2e3fXC4V254+RBWP2cbhHz5+4= 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.10 068/290] net: stmmac: fix wrongly set buffer2 valid when sph unsupport Date: Mon, 15 Mar 2021 14:52:41 +0100 Message-Id: <20210315135544.205306691@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135541.921894249@linuxfoundation.org> References: <20210315135541.921894249@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 @@ -1279,9 +1279,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); @@ -3618,7 +3619,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++;