Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp291918lqs; Tue, 5 Mar 2024 02:03:15 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWXlBqwPPWuaweoN91nqXUzyGJOZjKybDZqze/Q192nrA83VAVSecStG5NbncrxkdfTHAOCYp/+ZJvod09nHCM2YCyfUClIo/F6xo+7lA== X-Google-Smtp-Source: AGHT+IE+XVAIBlXWsDGM2uYy9ufskyrhgzhKregtfFry9BQyrk8jQ0x6v7RLIcbrg4qM7MGIxwks X-Received: by 2002:a50:f61c:0:b0:565:f51:3b26 with SMTP id c28-20020a50f61c000000b005650f513b26mr7635103edn.30.1709632995157; Tue, 05 Mar 2024 02:03:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709632995; cv=pass; d=google.com; s=arc-20160816; b=ZQvbxMLo8PnIQkZQyaIcD9Mgqcd6sSHyP04AT2qxuPRuSR3Ai6zvjbcxm1mEatf+6R TYZHBiqJJ8voUlHjp4vTeIsLUlrlDamNJv0Vq6LEyJh+Mrp0nl9OQd+vhDdqj7TKT6CY jW5jAqSOM0/nVkfi4NhwLg+pbSm+v62FsRjGljY5BOVNKeqeUZr/YB/oF1jAXFRV2tRn oS3SsocEJxSmMoc1axpcYtFDcuT/2b3w+8HKjPTpP8qC5IjBAxgWgaZJNAjiqNITQg81 MGmPiqrF+1PT4jKU4vd1OqoZVvVIK0ko0/Cj3eIhYGseyWxAUHjAlb5JdAQ0aseZK6p2 f0Mw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Wy2p1nABTgXfpRYKETH/vZ+dBptSh0pDUx2V0CHG6aY=; fh=FNZZFDKEHimW/U9couCQO7GHgdzTSdJ6Y8YFeVnrq8Q=; b=1I0iRnKe1ZnsgmX16PCmrnrZMgj2SDVklPbUcMC6fzvsaT45VdtWWSXV5YomuhePLn oSELK+ghnzQxD5qH07MkxPAZoERuvZcpJvICceaTQBabmOrZVFB2/WSUDMrA3/urGwi3 SdYYTx8+M/Qn+yazpxWcnA/JdOyewpMq2rlfczSoeKgXyzTGtn099MBrdez3D+9jLLDw IGWtvzzmEp8gGRkgP8QoYuPQ6L7jz5/CqnJLzUm3I170yK2OVRUbZMjH16mxJp5sF2Hv c9DMihhO5QBzEiqBgcdc//d8dbP3uHlVsx5Q0o6PvihT6kP8BoEIsi6XCfEsO/YtzpiF CJyg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Q3dghNzo; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-92041-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-92041-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id i20-20020a05640242d400b005661b6a0aebsi5136563edc.162.2024.03.05.02.03.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 02:03:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-92041-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Q3dghNzo; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-92041-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-92041-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id E062D1F21FD0 for ; Tue, 5 Mar 2024 10:03:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 981135475D; Tue, 5 Mar 2024 10:03:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Q3dghNzo" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BD9054D9F9; Tue, 5 Mar 2024 10:03:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709632981; cv=none; b=okn3MITzxwXZjUyOReKnhSxNwAhNj1BaI8A/eCDJ+4hNO0CkSf7U9VHQ6aMewBikeu0hRI7IQDpzBwWCq0dJaWhy09/4elpNrbkZbEeEvjjaEFQYGej0SeNFPNgYA5ezPPBdw5tBG+9S34Imv3HQQiIyKqC7u9FL9F0Up1hbckQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709632981; c=relaxed/simple; bh=CK3hGEkomyEWi++yHT0MA62YvDNmdI7jRyt+cZI+39M=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=D8LUoWJSRkJxZLnL/ueoS+5BXqh9Q+470ocb9798O+EKA983pv2k+hSqS8t6NodPwVEUeDy26VHWajl41Z25M/8CtwyCjOgeaXlGNELOyzBlRie/S2dTdXwumrx4BhDw7eTqd/JZteFptLJZ9Nc3OTFeRQ3GrRU/9brdmR+DXSE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Q3dghNzo; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 48687C433C7; Tue, 5 Mar 2024 10:03:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709632980; bh=CK3hGEkomyEWi++yHT0MA62YvDNmdI7jRyt+cZI+39M=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Q3dghNzo7HlmbEOACI4bncZhwmZXipl+TemetSV+yqFniCeRIAGEv/1goTgQg9DKA QuDNmDvcvUkBEAxItcYPDEah06kSVtuBKKRpVu50+yiPNIQabzdSkEkvRFMgBaWT0/ HwXzBrNkDSLAPZDmNOCB5dnQAMXvO01gizNb3wldqr9DvHpXzYt2SxggwaBKv1W+M0 2VxYi7BjXCcoWjK9n3WtKDUEuZq/tQsM1B4aH1ZhH4qOQtgerQf/cIX0gGMjPPigu2 IE50Z0Q6VXaxXItvGljUFpi8L4lfoe6383qzPkDl3KLgUoT2aM70YzGNxJS93D6rk2 2seRVT/1pMKrg== Received: from johan by xi.lan with local (Exim 4.97.1) (envelope-from ) id 1rhRdb-000000004md-0LEo; Tue, 05 Mar 2024 11:03:07 +0100 Date: Tue, 5 Mar 2024 11:03:07 +0100 From: Johan Hovold To: Douglas Anderson Cc: Greg Kroah-Hartman , Stephen Boyd , Bjorn Andersson , Jiri Slaby , Konrad Dybcio , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Subject: Re: [PATCH] Revert "tty: serial: simplify qcom_geni_serial_send_chunk_fifo()" Message-ID: References: <20240304174952.1.I920a314049b345efd1f69d708e7f74d2213d0b49@changeid> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240304174952.1.I920a314049b345efd1f69d708e7f74d2213d0b49@changeid> On Mon, Mar 04, 2024 at 05:49:53PM -0800, Douglas Anderson wrote: > This reverts commit 5c7e105cd156fc9adf5294a83623d7a40c15f9b9. > > As identified by KASAN, the simplification done by the cleanup patch > was not legal. > > From tracing through the code, it can be seen that we're transmitting > from a 4096-byte circular buffer. We copy anywhere from 1-4 bytes from > it each time. The simplification runs into trouble when we get near > the end of the circular buffer. For instance, we might start out with > xmit->tail = 4094 and we want to transfer 4 bytes. With the code > before simplification this was no problem. We'd read buf[4094], > buf[4095], buf[0], and buf[1]. With the new code we'll do a > memcpy(&buf[4094], 4) which reads 2 bytes past the end of the buffer > and then skips transmitting what's at buf[0] and buf[1]. Good catch! > Running "ls -al" on large directories also made the missing bytes > obvious since columns didn't line up. I had not noticed this in my limited use of the serial console on the sc8280xp CRD, but sure enough there are garbage characters and missing characters in the output of 'ls -al' before applying this patch. > While the original code may not be the most elegant, we only talking > about copying up to 4 bytes here. Let's just go back to the code that > worked. > > Fixes: 5c7e105cd156 ("tty: serial: simplify qcom_geni_serial_send_chunk_fifo()") > Signed-off-by: Douglas Anderson Tested-by: Johan Hovold and as Jiri already pointed out: Cc: stable@vger.kernel.org # 6.4 Johan