Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 62331C433FE for ; Mon, 28 Nov 2022 19:53:56 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 73246852B3; Mon, 28 Nov 2022 20:53:00 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=konsulko.com header.i=@konsulko.com header.b="YJLcB0dL"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 68FDD852E2; Mon, 28 Nov 2022 20:52:57 +0100 (CET) Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 17B71852D5 for ; Mon, 28 Nov 2022 20:52:55 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=trini@konsulko.com Received: by mail-ed1-x532.google.com with SMTP id z20so16884769edc.13 for ; Mon, 28 Nov 2022 11:52:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=2EJ2nArnBwk4aeZuEkr/wAr8KH9rLfsKffo68jiDqmA=; b=YJLcB0dLCE0TU/hr/3Qrs3PsvSL63p6HUcapNzkvJY6xGikf60+83bHrSdx2Vo7SpR B5jIRhkFr8RdkPWgxydO0FbdoagpK0l1xC64ZWAqCoIMoOFHge6NaqomTpstfqbFB/h3 acrnK6RAIbJFToLRU0UjVFCwRcohheRa1hUyU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=2EJ2nArnBwk4aeZuEkr/wAr8KH9rLfsKffo68jiDqmA=; b=JJwH2dOOix6VSCp+2WkiL0j0ZRAd8AA4GlGXcAjFwj4klPMoFCfvwIEmrWfNe2jh4z 5Uuqo7YoXUHiAwcpzzqKZ6gGnJeu5czSiRlx+pj7lbYbXr3axPvvOt3o5HW0UfdbU7x5 8wJoP1REZGSBuxSZbHA36yGoLUWx9LwZTudoJNwAvnfk/fw864lX0xhbGBi+bwu3jPgN wI7WrCzv0zjzifkERpjRJJqQB546li/IMkLRrQ96yMZQAax0mjSIis9SoCuQnnLxUE09 5/eIyofJHPhhAAZAq8t58FlwA1xbkX63hk6Jsk9U7eYd4rsRCKZ9X6TX8Yruqwtie7+X M8oA== X-Gm-Message-State: ANoB5plDmV0WnSciEcYWQS3edzMFco8KBOJCY7a9NLb0dg8uxbyB3c6V WCXkIS/XQc+LePIveRi6EcB2g2SfQUEbHw== X-Google-Smtp-Source: AA0mqf76AF3NG6soIjDJkaUYmSF7NdFSukaXPz5KFK4DKPGBm6OGDVHHAAxs1dwLWiJ1+e6pTUy0Yw== X-Received: by 2002:a05:6402:1bc4:b0:46a:342d:dcb3 with SMTP id ch4-20020a0564021bc400b0046a342ddcb3mr25961267edb.227.1669665174694; Mon, 28 Nov 2022 11:52:54 -0800 (PST) Received: from bill-the-cat (2603-6081-7b00-6400-69da-bdfc-6a2b-e036.res6.spectrum.com. [2603:6081:7b00:6400:69da:bdfc:6a2b:e036]) by smtp.gmail.com with ESMTPSA id b18-20020a1709063cb200b007ae38d837c5sm5358464ejh.174.2022.11.28.11.52.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Nov 2022 11:52:54 -0800 (PST) Date: Mon, 28 Nov 2022 14:52:51 -0500 From: Tom Rini To: Yaron Micher Cc: u-boot@lists.denx.de, joe.hershberger@ni.com, rfried.dev@gmail.com Subject: Re: [PATCH] net: macb: Fix race caused by flushing unwanted descriptors Message-ID: <20221128195251.GO3787616@bill-the-cat> References: <20221110173134.439-1-yaronm@hailo.ai> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="crFW2+mWrWMXeHsA" Content-Disposition: inline In-Reply-To: <20221110173134.439-1-yaronm@hailo.ai> X-Clacks-Overhead: GNU Terry Pratchett X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean --crFW2+mWrWMXeHsA Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Nov 10, 2022 at 07:31:34PM +0200, Yaron Micher wrote: > The rx descriptor list is in cached memory, and there may be multiple > descriptors per cache-line. After reclaim_rx_buffers marks a descriptor > as unused it does a cache flush, which causes the entire cache-line to > be written to memory, which may override other descriptors in the same > cache-line that the controller may have written to. >=20 > The fix skips freeing descriptors that are not the last in a cache-line, > and if the freed descriptor is the last one in a cache-line, it marks > all the descriptors in the cache-line as unused. > This is similarly to what is done in drivers/net/fec_mxc.c >=20 > In my case this bug caused tftpboot to fail some times when other > packets are sent to u-boot in addition to the ongoing tftp (e.g. ping). > The driver would stop receiving new packets because it is waiting > on a descriptor that is marked unused, when in reality the descriptor > contains a new unprocessed packet but while freeing the previous buffer > descriptor & flushing the cache, the driver accidentally marked the > descriptor as unused. >=20 > Signed-off-by: Yaron Micher Applied to u-boot/master, thanks! --=20 Tom --crFW2+mWrWMXeHsA Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGzBAABCgAdFiEEGjx/cOCPqxcHgJu/FHw5/5Y0tywFAmOFEZMACgkQFHw5/5Y0 tywsCgv/TGWr0ftMQLzoReEaC7mabRoD4tiB69FDmRCayjyZ7YECHG0VVycpLLFe 1kvSGV3UW5f27tnPSJaK0Gy0OmnEyMbVcGyvgeDk8kJX9H1MsKuGifalasZgtTDw Zh5IkShQCoPRd6J0RTJskZKomZOG+Dl336qgPcJhJIvOVKR4GsnjlSlFC6Hg44MJ OdDL2yWGI1j9Jed5J9Rule7obKJD8g3yIuc450bHE0gMLHt9n18MN7F4KHMU44j6 9dIhDr9MDF0xo3kTl9j23eq8x+a1ueT90aTBPOUfYPwapv0Uc6HxTULYI2Xm30mT oZ3HOaE4c/ZBOFmLT0y17CmPfCIb28SpaD1HSB2uxGeDPj8GtnSKXy2ziye7xZ7b CNxfVGR9ZVgvqytRE2KgxWjaUb76co6bclv02MSRWxAypHqWfZBcIwJabmH7E79m cJAiqOnMVapXVdNkyfvcj9OYGzExeBIf/tal8Yr0AyRWI0UUJ1PoVOePfUzno0AY 7wNcM9Rf =2zyU -----END PGP SIGNATURE----- --crFW2+mWrWMXeHsA--