From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) (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 842033C108E for ; Tue, 30 Jun 2026 09:24:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782811459; cv=none; b=frXG3MJ9UiX3Te0YuGiCCMgkZpF3acbRIqjawqrOU3TDyUadQZ7QvCGKpTrj0KdvxA8yt/8Y6PWgHlWyshyz2Vj+166/BLCLOtQgogfparKL8U5vQ0ZkT+X87vmbbpYhu/OG5pqvyIuedFckTiIOA954SMrVigYfYgKrbQRhVjI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782811459; c=relaxed/simple; bh=DSXO47dqiPcwJfKuU1KNg+1jFmWOpLphUUtOWngiiv8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=emXNz+EwiCVOoR5/KZf4vtTmu5x6L707cAs/qZ357M0Zd2X48CALJzrqVMqk2JAlv7Uc2fdwD2Z3x5GMxHvYPsZWbdwQ90u3LP1vUeMEOjS2tWLasLXA0kY+nOf2cYOFNeSz1YXlgAK6tJN1J10Ojg9yN9bb19MchtEGI4UQ+AM= 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=dYMmQQub; arc=none smtp.client-ip=209.85.167.46 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="dYMmQQub" Received: by mail-lf1-f46.google.com with SMTP id 2adb3069b0e04-5aeb8870485so1562618e87.2 for ; Tue, 30 Jun 2026 02:24:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782811455; x=1783416255; darn=vger.kernel.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=kLzfT8hyM7bvw41Q2FKIKHl9y+5Q/tsB2aEBetAZ+7Q=; b=dYMmQQubkXHN0mQUEPtOg3yQAaX91pBLjVohG63RSenpZuPGBtiYTmW8IlBgShyYjO p+lBzkvaMrihbvXAt+kHYux86RWC53IIjPhu+IrNfRdTwj6O6ctbMSyLniuvEFSofO4U W6q7jc5JZ7eIKa9JoRkyP1oww0wx2cjqqX7Z/9KAnyh5ELrP5Ogs0P/c3lgnRJavA9f3 I3+2m3LjxSq2mG6WKOjRoXP/b4Sf6aUv5gT5Yz697UR0fU/hpI2iPgnaKWNcWVbIZNVK VMh6C3bIOsCN06P8UTDHruLImNWo/wW0ODhwoGH27umSWyxw3nb8LvBPrM9jRlPx1qC3 hLfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782811455; x=1783416255; h=references:in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=kLzfT8hyM7bvw41Q2FKIKHl9y+5Q/tsB2aEBetAZ+7Q=; b=GU0T41vGW6akuVtVh0KfOzQyCsjxuLIJNh+dgNDLtbqMllvMM/+kZSYLl0KRWH5D1q vUo9eSsOOZO/Tscbroega8K/ZRLEKSDScbo3thIxRIva19LAqfGVfWqH1rXdthGEHuW3 JDPVxLrmXvdlehZ1lDb5goA5/SOJdUbNHJ1bx+6skWAcXG3MIS9kRlRC0LRE87xqaVnw tzzG1edeqKlOgRRx0V9Ga7EYH12+3rc7IZOklWyqg6HFTq8xcjXoiDNngi5jf8gk4GCt WL0e4ehmLAo+vpqCtgA+bw/rg9A1uug1U23MDkeZ+FlihP1au5FWRXh+hNp97zg8HN51 9Gng== X-Forwarded-Encrypted: i=1; AHgh+RqSC14WI8eLB2oUA+1UUk9wNgvmLUg5y/9frML6y5fHNGYlv9hROT55zV/nWxmaIgsOF+fVdJoCqS568q8=@vger.kernel.org X-Gm-Message-State: AOJu0YxOZyMu318wwmIlytDxb5vxF7n1Q4qPjF8A1ixGEM0iqdOxSNax h/KrNtQXrkzgVntJsdNxP3yHea/30nFPPYcms6tLUIg0J9xhA/0jTQDD X-Gm-Gg: AfdE7ckFXxl//st7d8DwBf8Ks7P30GB/5iHHNuQIdzgquHKItEC/oA9tHs76gOPk1CC u7zxSVu+LcEfoK8MrxInQVSfKIbDUlJ0egGhXCFysTZc2dGYLE+VS8WO8PC3QtH4u+zSKjhIqIP DDX7kweixTUINTQ5YfzqIOLSxvxo/n8981tgqZNe9T15qldKc+5nCcikIN2T1PoLHIKLH3lHV+F apRtsTLH7rgbwY3fIQ3LlcS9mc3N2vLyVFJQRSuJ74GgDGW4xgX+6rF5hqnqaiNmgfev8kxON8T HwAucTVMGnko0LJhXk68HfbQ+UM/18hPlBjSbfG0Q7JyzfVYCxK2wfSBheyG4bnBjpEGT8Bw9RE c7SyWbzhfYAqBX9JOtRRtg9Ue33mlkHpL3Wk9HuhP8AKqSnwWjSojevp8wGVTu8GhZXmPnNSJP1 KYhpVP7uUY/aAETjWbeZ1pyWpuPIt8+t0GKTqzBYxZ X-Received: by 2002:a05:6512:2520:b0:5ae:addb:d657 with SMTP id 2adb3069b0e04-5aebdb98e7emr671358e87.27.1782811453125; Tue, 30 Jun 2026 02:24:13 -0700 (PDT) Received: from localhost (c-85-228-45-68.bbcust.telenor.se. [85.228.45.68]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5aebe4a0a72sm415433e87.62.2026.06.30.02.24.12 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 30 Jun 2026 02:24:12 -0700 (PDT) From: Eli Billauer To: gregkh@linuxfoundation.org Cc: arnd@arndb.de, linux-kernel@vger.kernel.org, Eli Billauer Subject: [PATCH 3/7] char: xillybus: Avoid possible bandwidth inefficiency Date: Tue, 30 Jun 2026 11:23:26 +0200 Message-Id: <20260630092330.43534-4-eli.billauer@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20260630092330.43534-1-eli.billauer@gmail.com> References: <20260630092330.43534-1-eli.billauer@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: The host flow controls the payload data flow from the FPGA by sending OPCODE_SET_CHECKPOINT messages. Fix the condition for sending such a message, to correctly handle the case where leap < 0. The previous expression leap > (fifo->size >> 3) was not intended to evaluate true when leap is negative. However, due to C's integer promotion rules, leap (of s32 type) is promoted to unsigned int when compared with the unsigned fifo->size >> 3 expression. As a result, negative leap values are interpreted as large positive numbers, causing the condition to evaluate true unintentionally. Consequently, the device receives correctly formed checkpoint messages that encourage it to send data, but too frequently. This may cause the device to send short data chunks, wasting USB bandwidth. Signed-off-by: Eli Billauer --- drivers/char/xillybus/xillyusb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/char/xillybus/xillyusb.c b/drivers/char/xillybus/xillyusb.c index ab5f9159aa17..7d2434c02fa7 100644 --- a/drivers/char/xillybus/xillyusb.c +++ b/drivers/char/xillybus/xillyusb.c @@ -1507,8 +1507,8 @@ static ssize_t xillyusb_read(struct file *filp, char __user *userbuf, */ if (chan->read_data_ok && - (leap > (fifo->size >> 3) || - (checkpoint_for_complete && leap > 0))) { + (leap > 0 && (leap > (fifo->size >> 3) || + checkpoint_for_complete))) { chan->in_current_checkpoint = checkpoint; rc = xillyusb_send_opcode(xdev, chan_num, OPCODE_SET_CHECKPOINT, -- 2.34.1