From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D5A0A431E4F for ; Tue, 7 Jul 2026 17:50:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783446631; cv=none; b=K44TumDBTFwrY18RHqY+26lSRHiz9XheKNvU6HhT/fYpFiHJaJuRbHxSFj5XYz9om42mziloxddqlh2DOAhBnvJGMHAsmrnt4ccWuraEMVh34RGxp96HFjMFh76UKl4/WJ58cpDdGEVtVd+kiWj8fbTHtXBnVOP/4aHf5Jp0S7U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783446631; c=relaxed/simple; bh=ItSfkmnlK6BHWdpxMHBvTF/ysEYEUmQQQU27gwke/l8=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=dTKYV38y0KohKByH7lg+J1EfKiRP/I+jy/I1Km2dTJtEuNRdOKV7iq4ZkNE0p9yFI2iOTSqN5r90WHSsM8PhyK1Pv3TVOZ6ghTlamcFbcLMlEmx8NAd1AvNVowv6RsQL/IQFkf+qjgeMV71r/W8mmjwD3zbcrsLUuqChJWIwn7E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=CzBImRtM; arc=none smtp.client-ip=209.85.128.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CzBImRtM" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-493b691cb44so32192925e9.0 for ; Tue, 07 Jul 2026 10:50:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783446628; x=1784051428; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=cRE02Adizye6h3/KW0gtqPZj1uT3Ybf4N/0s4ldktFE=; b=CzBImRtMIDf8vTK827S3/lPEdmwGgaxu54g7fknJ5TEnF2BfruR8mI8F2fyxUhYkDm DvyDz5T+YDXJvXAczZUaN7dEoI5LaCCoGKsY+uRkwgtz1hZHLyZMcETaWpJQriifLA0D yJmNVfTY8zL4qkHRKKj/j1EcSohqkd9H4GXxTFpiyXbQ7kFTx+6c8hUNk/PGm+jlsjKs n72/UGsUCJBxnp96fCtRIMwD1Q5x1OkwBS2tO4etQSLYKwsxazzQi/Rpw08sshuB6H+2 czwdgGma6Va+nk2KfMk0emPApPU+W3ZNJomQdM/kPfsbzCCgEMMxaaWGMCuKXGW3u88P lSog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783446628; x=1784051428; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=cRE02Adizye6h3/KW0gtqPZj1uT3Ybf4N/0s4ldktFE=; b=dJueIQaaajQ2o1Mk6Xamf97CtRXLIfnUw3c70RyEtxopfJwBE0Y8OlfjLejd2X6Vgi 0kbUM9TCA7GDzR82t2WB2S7S5otyvpl1yZMvu5RsoRUZN9wrVv6aDgZkq6FUkHzVYaZX 0aB2ffyf9p+Y0zEP2nneh46Cah5v759BdalAblOyxPN2xw5CUymwZ6hZTCMiByRxt867 x59NjhU8qJodEX9xCW1DzyOlCr+hY/VXrdMsRZkX43GswHkQt1lDZyIIiQgjPNBE81j/ X6YvWfZ7jtGXIzBN8jE8/Ly8Mudccd8X9VJE1eCc37AfAnV9ekwr+cdZEkUJ3ggW6DE6 6Rbg== X-Forwarded-Encrypted: i=1; AHgh+RoaBHLMbHpaDpjq7oZN5JGZQJHA2INW15hg1MQyFtJYe5L3TzmYvOzM26zqwjbYZd0o/jT2LywIIebr+iE=@vger.kernel.org X-Gm-Message-State: AOJu0YxqKm0at/V/fQuEtPn0smydoLr06zT3GHZ2m1b5o3HHzafI/tns 0il9IG/iIjarubvulTYxkjeA3vmi9LgaanhmFAr5hZetiOi8Q8JWlMT7 X-Gm-Gg: AfdE7clmYnSWgtXQwcOhgxtOCsgE4XZL+j2ktfU4JbiJ20OVWyAao58nnl6OjZe51lh Sk46+4sEThhXSWyZxjH/ZolaNZS7mhEpXk2TGxqa9GEEi6v6BG0T/EpRD0alYZ3yP0sCk2xwAR+ DkTyU9ArrpkJaWa4Zb5f2LWoEP9XamJrsJ84dBkFgrEEwWX1kHouL2tSr6jWV7EwU/TY9/N7jKK HqWOMuH1GpbSgWFX6xaSOGemS3gRqEbccMsj6R0EUdqwPRClrOIYlv5P+4J45Krqx3UmZOVNyEM A19CsMJQY+7kc+g7faIOjnSt4uCFv1WymMDIEpEu5bxDaSNqAlTqK2FYLIlUnb/TlWHDB7hydio WSqbuWjd5axp5pWXf6OiuE864x+3dtAopWyU+rVVIqgQCulj2ZwkV7VQE+h6Aq42ucvDmiFr4Kh bRygZsUzdBg+3Ulou8KeOtSpxZN4oAdYyL1tgp0PfWgfchYIRyCbhhGa08 X-Received: by 2002:a05:600c:8283:b0:493:b8cd:2555 with SMTP id 5b1f17b1804b1-493df066947mr72993875e9.3.1783446627922; Tue, 07 Jul 2026 10:50:27 -0700 (PDT) Received: from pumpkin (host-92-21-50-228.as13285.net. [92.21.50.228]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-493e0ec6e64sm127359695e9.0.2026.07.07.10.50.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jul 2026 10:50:27 -0700 (PDT) Date: Tue, 7 Jul 2026 18:50:25 +0100 From: David Laight To: Paul Mbewe Cc: , , , , , , , , Subject: Re: [PATCH 2/2] serial: sc16is7xx: set TX FIFO trigger level to half FIFO to prevent underruns Message-ID: <20260707185025.2645b7b4@pumpkin> In-Reply-To: <20260707150344.353068-1-paultyson.mbewe@ziehl-abegg.de> References: <418f9ae5-8827-475c-b465-1271a784fbf1.bc56e27e-ecd8-43ae-bb87-75bfd472a28d.b2c59f9a-984f-45fd-b27f-021ecf433626@emailsignatures365.codetwo.com> <20260707150344.353068-1-paultyson.mbewe@ziehl-abegg.de> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) 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=UTF-8 Content-Transfer-Encoding: quoted-printable On Tue, 7 Jul 2026 17:03:44 +0200 Paul Mbewe wrote: > Hi David, Maarten, >=20 > Thanks, I double-checked this with finer TXLVL instrumentation, and the > root cause is clearer now: the failures are stale-TXLVL under-fills, not a > separate THRI re-arm issue. >=20 > > You need the refill path to be much faster then the drain path. >=20 > Agreed. The issue is that sc16is7xx reads TXLVL once and sizes the FIFO > write from that value. On this SPI-backed path, hardirq/softirq activity, > RT scheduling and the synchronous SPI transfer wait can delay the refill > while the UART continues draining. So the TXLVL value can become stale > before the write completes. >=20 > One failing example: >=20 > =C2=A0 tx_start=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 txlvl=3D9=C2=A0 txlvl= _read_us=3D580 > =C2=A0 tx_pre_write=C2=A0=C2=A0 sent=3D9=C2=A0=C2=A0 pre_write_us=3D16 > =C2=A0 tx_segment=C2=A0=C2=A0=C2=A0=C2=A0 sent=3D9=C2=A0=C2=A0 seg_us=3D3= 64 > =C2=A0 tx_post_write=C2=A0 txlvl_before=3D9 sent=3D9 txlvl_after=3D12 pen= ding_after=3D29 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 post_gap_us=3D12 post_txlvl_us=3D130 >=20 > Here TXLVL is free space, and the trigger is 8 free spaces. The driver > read 9 free spaces and wrote 9 bytes, but the post-write read still saw > 12 free spaces with data pending. Even allowing for the post-write read > window, the FIFO was not reliably pushed below the trigger, so no new > threshold crossing was expected. All failing samples I have checked show > the same pattern. That now makes sense. One extra thing you might check. Does filling the tx buffer clear the IER bit? If it does you can save a slow read by doing the tx-refill first (when there it tc data pending). You might also be able to leave the tx interrupt permanently enabled. It seems to be triggered by crossing the threshold rather than being based on space in the fifo. Did you try putting the second scope channel of the spi clock/data to get the scope to show you the pattern of transfers and the latencies? David