Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3209753pxb; Sun, 7 Feb 2021 01:23:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJzpVFRHbzGoX8d2omVeLB2/55d6E2qwXPB8A1aLnLiCd9tPgFmK9DzD3xzW6W0t5HgzDHPy X-Received: by 2002:a05:6402:10c3:: with SMTP id p3mr1150662edu.67.1612689802040; Sun, 07 Feb 2021 01:23:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612689802; cv=none; d=google.com; s=arc-20160816; b=qmKbSHsOI2qbe+ejzMxiid4Y6etvrWPTkyrTpEatDIIKt3ur/AeiJEObjoK55ij1vZ EIzGc+Mblf4nhhiGRg0nCL8kWt5ZXsGpR63JSrJkHv3VugCU30YdI6uwJx1hVn6TjUEN +4jLxudUYAl6tgeC9gqU3Tz+E3VjtBZ6NT4jTU4jzNVsKYkMNQP22EPSk5LuDRB/igOy 24HrU6mRtJIapFsbem40CNsjtQTYYNOjC7xll3yf2p5LugXz0RJ0Ubcx2bZKT1NqmFpI Xh+5Y3soQHr95+c4hKQNlEtkFXtSx/KQD875zKdAeg7ZLxefRlFNv92MM3bArEbIceiS hLxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=hH0hY4oxe/6A9YAVTF6tnGfhqrUwc5XKO0rsbM3u6Uo=; b=YMC7zcEzRmNEKmcciRz2PGQRrxeSGY3cVvZpkJbftEfvjKxM05BiCiSugBQlCnvKSs WFDFU5KRYELNQ6+j0wvK0/Q5FsuCKUHj5eE/YWHP8/uIuSE/E+ZzdqVbD8ANoP3XYvZd JWGjPR3qjXjErgn4o+098xn7Z5GZ/YWxdHY3sutFZe8YeGe2bNg7XPPwYziu+epdsmtn AlmlrgXgZ6hoIOu6an+wjacP0fk4d1AEO70S4OMCYrFL4ejAv6Rt+EixYxkrTqpVEk2a /IN1Ea7ntZE6V4EC6pSvEUbpZW2BCveT0t4smLsn55aMUdu+i+q1uJHxocGvoBXxyF7h 8QYQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c22si8764642ejd.523.2021.02.07.01.22.59; Sun, 07 Feb 2021 01:23:22 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229650AbhBGJVB (ORCPT + 99 others); Sun, 7 Feb 2021 04:21:01 -0500 Received: from jabberwock.ucw.cz ([46.255.230.98]:40420 "EHLO jabberwock.ucw.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229548AbhBGJVA (ORCPT ); Sun, 7 Feb 2021 04:21:00 -0500 Received: by jabberwock.ucw.cz (Postfix, from userid 1017) id A18411C0B77; Sun, 7 Feb 2021 10:20:16 +0100 (CET) Date: Sun, 7 Feb 2021 10:20:15 +0100 From: Pavel Machek To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Subbaraya Sundeep , Kevin Hao , Jakub Kicinski Subject: Re: [PATCH 5.10 04/57] net: octeontx2: Make sure the buffer is 128 byte aligned Message-ID: <20210207092015.GA32297@amd> References: <20210205140655.982616732@linuxfoundation.org> <20210205140656.168305608@linuxfoundation.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="BOKacYhQ+x31HxR3" Content-Disposition: inline In-Reply-To: <20210205140656.168305608@linuxfoundation.org> User-Agent: Mutt/1.5.23 (2014-03-12) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --BOKacYhQ+x31HxR3 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi! > commit db2805150a0f27c00ad286a29109397a7723adad upstream. >=20 > The octeontx2 hardware needs the buffer to be 128 byte aligned. > But in the current implementation of napi_alloc_frag(), it can't > guarantee the return address is 128 byte aligned even the request size > is a multiple of 128 bytes, so we have to request an extra 128 bytes and > use the PTR_ALIGN() to make sure that the buffer is aligned correctly. >=20 > +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c > @@ -473,10 +473,11 @@ dma_addr_t __otx2_alloc_rbuf(struct otx2 > dma_addr_t iova; > u8 *buf; > =20 > - buf =3D napi_alloc_frag(pool->rbsize); > + buf =3D napi_alloc_frag(pool->rbsize + OTX2_ALIGN); > if (unlikely(!buf)) > return -ENOMEM; > =20 > + buf =3D PTR_ALIGN(buf, OTX2_ALIGN); So we allocate a buffer, then change it, and then pass modified pointer to the page_frag_free(buf); in the error path. That... can't be right, right? > iova =3D dma_map_single_attrs(pfvf->dev, buf, pool->rbsize, > DMA_FROM_DEVICE, DMA_ATTR_SKIP_CPU_SYNC); > if (unlikely(dma_mapping_error(pfvf->dev, iova))) { BTW otx2_alloc_rbuf and __otx2_alloc_rbuf should probably return s64, as they return negative error code... Best regards, Pavel --=20 http://www.livejournal.com/~pavelmachek --BOKacYhQ+x31HxR3 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAmAfsM8ACgkQMOfwapXb+vIl0QCgk69H52jrBg3QTdCu0tD/nL/q SQoAn2S0Dij/cUdtTKroFagyHVfIUxfi =9MqR -----END PGP SIGNATURE----- --BOKacYhQ+x31HxR3--