Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp1397941ybb; Fri, 29 Mar 2019 03:50:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqxQ5JlHDUgzv+xwwoxNMX5XWeWO3zO1H0XZChYM3o3xlNxs1l563abqrqLlyY7jUboTEMWW X-Received: by 2002:a17:902:be04:: with SMTP id r4mr34532769pls.218.1553856613897; Fri, 29 Mar 2019 03:50:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553856613; cv=none; d=google.com; s=arc-20160816; b=WLMFHClDkbnVTfUH14CP8hqXCCkSpXekdiK2iJKXxVkmo4tozrMTSCCXGLGyP6exI5 +eCXnS4uyjFqrypzAirX/9HrGFbqYGgkVfMl6HvuWrg6BzqSbrGCs/NOFrRu+kqSYTP2 6PqQoc9sy5bPL2KFg+oSLFMYubXc/YIGGdkCVQ4vV59ieGED+oAQ1uWQyAK6qtiMvTtD DDDCJi6+4cEbwuTr4j0Nk23oXVndLaiDKGChGtaa4eyH3bJjZ9YJRNmtadnukPVaMywc VjeVOPt/d4ecshkmmDI83MvAgwghxS0b7BYKX9NDt6Zxr/TO7YgpI9ShJzhDS4TZQx+P OYZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=+FMJpHugX4SREzyTNZDB59YJRIL/XjymqI9vDg91snc=; b=Eu5sgzs9oTgcbdYBv6565uS+BJXwNr7MpvtWHxkgsH/f7RS7p4kvvL1ySIjfpYZzMH ZfmYhBaI7UZKVzsWdfZ51V0FvNDRQJlk1rmN7iAo7W7WoKSZazgxZbVTQAXLZzIGaEDG kpvOpU9piKBpWuag2CTwdtjW93qSkaUsIK821p/VUGNz6dFRSeLiMNxIc42HN+by477S aThgQ+cZ1eCIDrlqSHNvnHBAYopiWpObUsT+4vT1ih6sw9TkemgvWE1RaPazlCYYPbRI 4EWBaDAiH+k0ZOW19R4P9INVqPvQpRJfNyKUF43uB0E9Vy41YlPEB2ybUqphrz7zkA+W y6zw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=iki.fi Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w12si1569038pgr.104.2019.03.29.03.49.58; Fri, 29 Mar 2019 03:50:13 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=iki.fi Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729301AbfC2Ksv (ORCPT + 99 others); Fri, 29 Mar 2019 06:48:51 -0400 Received: from emh07.mail.saunalahti.fi ([62.142.5.117]:53434 "EHLO emh07.mail.saunalahti.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728711AbfC2Ksv (ORCPT ); Fri, 29 Mar 2019 06:48:51 -0400 Received: from darkstar.musicnaut.iki.fi (85-76-9-223-nat.elisa-mobile.fi [85.76.9.223]) by emh07.mail.saunalahti.fi (Postfix) with ESMTP id 37AC3B0059; Fri, 29 Mar 2019 12:48:48 +0200 (EET) Date: Fri, 29 Mar 2019 12:48:47 +0200 From: Aaro Koskinen To: Jose Abreu Cc: "David S. Miller" , Alexandre Torgue , Giuseppe Cavallaro , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Aaro Koskinen Subject: Re: [PATCH 1/6] net: stmmac: use correct DMA buffer size in the RX descriptor Message-ID: <20190329104847.GF16484@darkstar.musicnaut.iki.fi> References: <20190327203540.1884-1-aaro.koskinen@iki.fi> <20190327203540.1884-2-aaro.koskinen@iki.fi> <5c480a83-dfcf-c20c-f277-4449a7b41403@synopsys.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5c480a83-dfcf-c20c-f277-4449a7b41403@synopsys.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Fri, Mar 29, 2019 at 10:02:20AM +0000, Jose Abreu wrote: > On 3/27/2019 8:35 PM, Aaro Koskinen wrote: > > From: Aaro Koskinen > > > > We always program the maximum DMA buffer size into the receive descriptor, > > although the allocated size may be less. E.g. with the default MTU size > > we allocate only 1536 bytes. If somebody sends us a bigger frame, then > > memory may get corrupted. > > > > Fix by using exact buffer sizes. > > > > Signed-off-by: Aaro Koskinen > > So, I'm seeing that the maximum allowed buffer size that can be > put in the descriptor changes between enhanced descriptors to > normal descriptors (8KB vs. 2KB right ?). There are two size fields, so it's 16KB vs 4 KB. > Shouldn't stmmac_main know about this limit before trying to init > descriptors ? Yes, and that is not a problem. > We do limit the MTU according to HW version but I would rather > prefer not having to need to calculate min() values in the > descriptor code and just use the value as is ... I don't think the calculation can be avoided, as the passed value can be bigger than a single field can hold, or less than the maximum. A.