Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1176433lqa; Sun, 28 Apr 2024 23:39:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUT7zvmIgvN23knSH/bkmg2pdf5Hk57/dfasGUYW21GUDQ2A3Vmffp0z2FoMwPYoPKVTKlvJ1OzzsstpwyFvk9bKMidNq5v8p3aJ3w6oA== X-Google-Smtp-Source: AGHT+IGkY5Gs1YHUcKCUddjaYxIxEZFov53tDUObM2CN+dDMM4y0LasnC3Nc2ideBf+V1D5IjLuR X-Received: by 2002:a9d:6756:0:b0:6ee:3710:2310 with SMTP id w22-20020a9d6756000000b006ee37102310mr1851280otm.4.1714372790602; Sun, 28 Apr 2024 23:39:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714372790; cv=pass; d=google.com; s=arc-20160816; b=pFUEy3Y0t0TuxRz7LJnpapCNY2frp53SFpZdXbXXlqlzO+dG6HY5koRXnOYPGlSkTb Ytkck9NiyauiUohx2ZSBcm3iNDbo+pruRcq+X3ZtbvP5tJUI8HMdn+P7/tQgTXkO7+X3 8mzkjXOlpbr2TFnO47Y48mkOzj60NVEP9VZNgaNyD6aeRNSQ2t7CyeC48flIz42wIY5v ifLMl5U4uD9jvJ78P+HAR6lg32y0vwOhsdsgzkuE11c6Io3kAPQ0OCBS0bk20Y7O8DDg ePuPTs3MT/v6eg/cWza81CJRLoM83p5b2idOEBwJ0B0bRc6IRBFxzgdZ/xH2wD7OXFhK S8ug== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id; bh=OY9oeBWyxdXXlsTYn0DXXRwkgynS0Yhyhd4AqIGsWyY=; fh=bb/tiVNoraVTzZLy4nRg5TCX75cUjU/flQ/PlU9tBGE=; b=0Lu4tYztQs7LMBNLEF+94N/Sxd4guvUx44ehUmDYdiDTR4ijFdtxd7s4WWrHtaGEAL SX6MUIwQffruyI6ZOp1SuDeWnKXnPKMimvozhuBwEg3MeBAfXvrCDCNN/ZySxQaztZG4 bc3upPWCFSYMRQWkiVxgIX6Ls2RYEGa/q2mBu+0f7gQ5ZCiXQ4C7YZn/V7sW3TzvlOQP ckkb77BmFTWWlg6satzwjpNxN+K6LvR/zd8El0YRQuB6yPrK7MdqOnYOC25gAPYvQp/s tvIrRDmOPyUlMvXCxaxAKJ/NJ14p9BRjvBqS60Z3xpORTgRqw6GSAe3IZzo6WhVYgzU6 SllQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-161814-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-161814-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id j65-20020a638b44000000b005dc957fe128si9883984pge.74.2024.04.28.23.39.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Apr 2024 23:39:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-161814-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-161814-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-161814-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id AABC7B20F0C for ; Mon, 29 Apr 2024 06:39:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7C19B11CB4; Mon, 29 Apr 2024 06:39:29 +0000 (UTC) Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.54]) (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 462D21118A; Mon, 29 Apr 2024 06:39:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714372768; cv=none; b=REOPkz1WtdUSWQp/Kpg6j+yOFX6+Pb2dIfyGBvJ2nm0Cjj6UJW8kKzgMNJkZsoLTE0tHsdQfFcJUGdzdkxoZvvDEpp7FgL//+nk5hO1jUA+w6NAqa2JtSfiJ/D4Pw/KFycqvsxBa4irSGMZ3AD5Is84KaeXAUsaFgV2KaOD11cg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714372768; c=relaxed/simple; bh=0uTdj+DLwPtNgb7rqdkpWnQhW3OkgzuJ/zq7PblRgPQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=acoRHsKZxFg05v+wIqhjCDxi8K2ErfdhEy13hiMW1gWMlxDG9Y72PC2qyKpPYyetSsMqZELOCzWYf2x1Tz4MFbMGwUAFaIj5voqQ65XJ673aghQwkDj46XoOspuyLLVce+4W46+L/8pMIF5LKJvXOEYhwQAB6hMwhlqs7+5VGK8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.208.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-f54.google.com with SMTP id 4fb4d7f45d1cf-56e477db7fbso6665006a12.3; Sun, 28 Apr 2024 23:39:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714372764; x=1714977564; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=OY9oeBWyxdXXlsTYn0DXXRwkgynS0Yhyhd4AqIGsWyY=; b=kJ96GsWAilVwV663nLUbsrt7nzMB0bGWMwTB9hPzBRlhuDbBjs5nXiRb0Nsys6tgMY ZdLnLDYPxACOnHSxp5BPI2cC7ZM8YBUyt2hiV5hm0eGvzVMCAuTT7/rZIh3kkfANOZe5 OIO4JKD7Ef7/bOxPveBEG6uCSN1VtFmViyJZsRiNVKHIDWl4OgvIZOGdqq0da7zGPHXG KAnGKJf1GSB8aMlfzd91qIU7Yt+EVXHRX3mupqyjsvQSyy9/NMYKBBFikR6nVwg06+Mu cmwsJmTtDzAxqsw4FfkW1SpWXXFqIrn25LoMEMNWuniTYuqg2Ms+P5y7+e1WggWoTtox wo0Q== X-Forwarded-Encrypted: i=1; AJvYcCU1tIEMgUIhJzdWqLjSMqH2wDmS5zeRnlpMU52YxDU0B3rYl2eQW3vlHaqv8W5p8o2lLc+/Fd5yOrwa+S/rpPLL6l1L3KR8PK2sp+qA67SRxTXrq5UZVt4xh7gtzAmS95WhjPtjpRVWLaCynknneg1KHMafXPPav5ZOv3p+UJxnUc90 X-Gm-Message-State: AOJu0YyZz0bvZbpe9eSDBlIaQghsjol4mDMrixTuBIbpYQbm5f9AQj2i D5a5rttVxt04Fq6CoNA8Y+HZvcAkRtOFKq2MTgBvwI3eI2MYCIkA X-Received: by 2002:a50:a6da:0:b0:56e:60d:9b16 with SMTP id f26-20020a50a6da000000b0056e060d9b16mr6416549edc.6.1714372764391; Sun, 28 Apr 2024 23:39:24 -0700 (PDT) Received: from ?IPV6:2a0b:e7c0:0:107::aaaa:69? ([2a0b:e7c0:0:107::aaaa:69]) by smtp.gmail.com with ESMTPSA id c26-20020aa7c99a000000b00572405680e8sm4224454edt.21.2024.04.28.23.39.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 28 Apr 2024 23:39:23 -0700 (PDT) Message-ID: <17d2cc58-cf68-430d-9248-25abe4c5b0f0@kernel.org> Date: Mon, 29 Apr 2024 08:39:22 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] serial: sc16is7xx: fix bug in sc16is7xx_set_baud() when using prescaler To: Hugo Villeneuve , Greg Kroah-Hartman , Jon Ringle Cc: ria.freelander@gmail.com, Hugo Villeneuve , stable@vger.kernel.org, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org References: <20240426135937.3810959-1-hugo@hugovil.com> Content-Language: en-US From: Jiri Slaby Autocrypt: addr=jirislaby@kernel.org; keydata= xsFNBE6S54YBEACzzjLwDUbU5elY4GTg/NdotjA0jyyJtYI86wdKraekbNE0bC4zV+ryvH4j rrcDwGs6tFVrAHvdHeIdI07s1iIx5R/ndcHwt4fvI8CL5PzPmn5J+h0WERR5rFprRh6axhOk rSD5CwQl19fm4AJCS6A9GJtOoiLpWn2/IbogPc71jQVrupZYYx51rAaHZ0D2KYK/uhfc6neJ i0WqPlbtIlIrpvWxckucNu6ZwXjFY0f3qIRg3Vqh5QxPkojGsq9tXVFVLEkSVz6FoqCHrUTx wr+aw6qqQVgvT/McQtsI0S66uIkQjzPUrgAEtWUv76rM4ekqL9stH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PL+9fbILqJPHgAwW35rpnq4f/EYTykbk1sa13Tav6btJ+4QOgbcezWI wZ5w/JVfEJW9JXp3BFAVzRQ5nVrrLDAJZ8Y5ioWcm99JtSIIxXxt9FJaGc1Bgsi5K/+dyTKL wLMJgiBzbVx8G+fCJJ9YtlNOPWhbKPlrQ8+AY52Aagi9WNhe6XfJdh5g6ptiOILm330mkR4g W6nEgZVyIyTq3ekOuruftWL99qpP5zi+eNrMmLRQx9iecDNgFr342R9bTDlb1TLuRb+/tJ98 f/bIWIr0cqQmqQ33FgRhrG1+Xml6UXyJ2jExmlO8JljuOGeXYh6ZkIEyzqzffzBLXZCujlYQ DFXpyMNVJ2ZwPmX2mWEoYuaBU0JN7wM+/zWgOf2zRwhEuD3A2cO2PxoiIfyUEfB9SSmffaK/ S4xXoB6wvGENZ85Hg37C7WDNdaAt6Xh2uQIly5grkgvWppkNy4ZHxE+jeNsU7tg= In-Reply-To: <20240426135937.3810959-1-hugo@hugovil.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 26. 04. 24, 15:59, Hugo Villeneuve wrote: > From: Hugo Villeneuve > > When using a high speed clock with a low baud rate, the 4x prescaler is > automatically selected if required. In that case, sc16is7xx_set_baud() > properly configures the chip registers, but returns an incorrect baud > rate by not taking into account the prescaler value. This incorrect baud > rate is then fed to uart_update_timeout(). > > For example, with an input clock of 80MHz, and a selected baud rate of 50, > sc16is7xx_set_baud() will return 200 instead of 50. > > Fix this by first changing the prescaler variable to hold the selected > prescaler value instead of the MCR bitfield. Then properly take into > account the selected prescaler value in the return value computation. > > Also add better documentation about the divisor value computation. > > Fixes: dfeae619d781 ("serial: sc16is7xx") > Cc: stable@vger.kernel.org > Signed-off-by: Hugo Villeneuve > --- > drivers/tty/serial/sc16is7xx.c | 23 ++++++++++++++++++----- > 1 file changed, 18 insertions(+), 5 deletions(-) > > diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c > index 03cf30e20b75..dcd6c5615401 100644 > --- a/drivers/tty/serial/sc16is7xx.c > +++ b/drivers/tty/serial/sc16is7xx.c > @@ -555,16 +555,28 @@ static bool sc16is7xx_regmap_noinc(struct device *dev, unsigned int reg) > return reg == SC16IS7XX_RHR_REG; > } > > +/* > + * Configure programmable baud rate generator (divisor) according to the > + * desired baud rate. > + * > + * From the datasheet, the divisor is computed according to: > + * > + * XTAL1 input frequency > + * ----------------------- > + * prescaler > + * divisor = --------------------------- > + * baud-rate x sampling-rate > + */ > static int sc16is7xx_set_baud(struct uart_port *port, int baud) > { > struct sc16is7xx_one *one = to_sc16is7xx_one(port, port); > u8 lcr; > - u8 prescaler = 0; > + int prescaler = 1; Ugh, why do you move to signed arithmetics? regards, -- js suse labs