From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 301A7C54E8F for ; Mon, 11 May 2020 10:08:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0D5C720720 for ; Mon, 11 May 2020 10:08:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589191723; bh=WtEq/1kpgVLewTDkwfFKbHjTtwrkAeHhRFFbWBnnn6I=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=MbpBSHUYHzZPiap/pbwjrOtPVSh8xvqqigloVRaQTaqNRCDnwQ/+i8ROUYYDS7r7R b/NxGgz/wYo//m5d4g2a/dhxnKPcisuW1PCvO8jw86zLgLyDWnn6vlzUNuZfHe2Zk+ IKIR9ijzbdn0w9nN6k2+2wJyTCAV7WmSQoyXtow4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729264AbgEKKIm (ORCPT ); Mon, 11 May 2020 06:08:42 -0400 Received: from mail-ed1-f65.google.com ([209.85.208.65]:42311 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725983AbgEKKIm (ORCPT ); Mon, 11 May 2020 06:08:42 -0400 Received: by mail-ed1-f65.google.com with SMTP id s10so7421038edy.9; Mon, 11 May 2020 03:08:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=ADM8r+B0dzyP5A/vqyNmonnjvaPcrODBmZPyMqMMxIs=; b=qwcJ/U4lMnxfhStkH1TeBu1nnGL/VamUIPI6uUaTqGgUn0w7hZ4ovPOHFR7Ee0GRqh 8aum25vzSOgS6GWJhlNKm7Orn2BdSq7VcGYZJw0xddzStZylWAMXIjLcpa+Rykkf3lJq z378MI3yjLb4rzqfQNtW4GcfjS/8giGCHfFfvtNCW+66oQ3y6ZRx18DR3MVHQBqiqask Y2+c5G3KLnKqmkHlsSzjEl3GCCp6VPSZ1DIv0xSRvch+u5g0vneXHBWYsAxZGxSV1Ig2 zNST5BafTWPyc8Poy3r8rmc13QG5JpajmW8QOMz+s1ZVyxarri0pJxLzXL4ofao7mwZa aP+w== X-Gm-Message-State: AGi0PuYSNg2M7CI1jFMj9Mwzy3wA7he6JUv1S+XD17eDhY8JNVMshxdO 7+D/kh9NsTDziCPzYuhLNUF8aXvK X-Google-Smtp-Source: APiQypIIjKKjypDAYbOFH4MiQWndpu/est9zg63nnHoe6ueUE/9p66tdn9yO2ilqbrvMJLoHMfCWHw== X-Received: by 2002:a05:6402:28e:: with SMTP id l14mr12321849edv.184.1589191719680; Mon, 11 May 2020 03:08:39 -0700 (PDT) Received: from kozik-lap ([194.230.155.237]) by smtp.googlemail.com with ESMTPSA id ga1sm1242231ejb.65.2020.05.11.03.08.38 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 May 2020 03:08:39 -0700 (PDT) Date: Mon, 11 May 2020 12:08:36 +0200 From: Krzysztof Kozlowski To: Jonathan Bakker Cc: kgene@kernel.org, gregkh@linuxfoundation.org, jslaby@suse.com, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] tty: serial: samsung: Correct clock selection logic Message-ID: <20200511100836.GA16828@kozik-lap> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 08, 2020 at 06:34:33PM -0700, Jonathan Bakker wrote: > Some variants of the samsung tty driver can pick which clock > to use for their baud rate generation. In the DT conversion, > a default clock was selected to be used if a specific one wasn't > assigned and then a comparison of which clock rate worked better > was done. Unfortunately, the comparison was implemented in such > a way that only the default clock was ever actually compared. > Fix this by iterating through all possible clocks, except when a > specific clock has already been picked via clk_sel (which is > only possible via board files). > > Signed-off-by: Jonathan Bakker > --- > drivers/tty/serial/samsung_tty.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/tty/serial/samsung_tty.c b/drivers/tty/serial/samsung_tty.c > index 73f951d65b93..9d2b4be44209 100644 > --- a/drivers/tty/serial/samsung_tty.c > +++ b/drivers/tty/serial/samsung_tty.c > @@ -1281,14 +1281,14 @@ static unsigned int s3c24xx_serial_getclk(struct s3c24xx_uart_port *ourport, > struct s3c24xx_uart_info *info = ourport->info; > struct clk *clk; > unsigned long rate; > - unsigned int cnt, baud, quot, clk_sel, best_quot = 0; > + unsigned int cnt, baud, quot, best_quot = 0; > char clkname[MAX_CLK_NAME_LENGTH]; > int calc_deviation, deviation = (1 << 30) - 1; > > - clk_sel = (ourport->cfg->clk_sel) ? ourport->cfg->clk_sel : > - ourport->info->def_clk_sel; > for (cnt = 0; cnt < info->num_clks; cnt++) { > - if (!(clk_sel & (1 << cnt))) > + /* Keep selected clock if provided */ Makes sense and good catch. Reviewed-by: Krzysztof Kozlowski I wonder about the s3c24xx_serial_enable_baudclk() which has similar pattern - is there testing only def_clk_sel on purpose? Best regards, Krzysztof > + if (ourport->cfg->clk_sel && > + !(ourport->cfg->clk_sel & (1 << cnt))) > continue; > > sprintf(clkname, "clk_uart_baud%d", cnt); > -- > 2.20.1 > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.7 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 61554C54E4B for ; Mon, 11 May 2020 10:08:47 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1D68520720 for ; Mon, 11 May 2020 10:08:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="NXUTWzL1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1D68520720 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=NFdJafz1FYNHKrfwJ2qhm/hHVDQOih2Fe6dBwWQvkc0=; b=NXUTWzL1ikijV2 zpmOo5dJHJMAiPzHw6n0doZ4rW9k/oryoKWNtKm4bumSF6z4Bh/p6+uKh41440NxQeE1yTv1Wt6sG i12+U0DCmre93VUaWgh3UabCIoqAXd/q2lYKArawtvl0YLFryK+4UWbWR9c3SZ1CpPVoez3ZSAdls KXd2XW9Ot3w37SHNupb/2ZYIClWL6O2gzSrh8D86UYG7qSwVsRi4mGB8CU5sTKBHpZuSm0JHrXhme 0PnUe9Tnyml3NSs9Zu4/09XrNz2XUIr6U3ysEfLxbZFhYhJeJGuBJ1q3fwgaXD1Gi23Kj00KiYr8t l3HrTOxKPwYxlJQa5RvA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jY5Mb-0003Jq-MU; Mon, 11 May 2020 10:08:45 +0000 Received: from mail-ed1-f68.google.com ([209.85.208.68]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jY5MX-0003JV-LH for linux-arm-kernel@lists.infradead.org; Mon, 11 May 2020 10:08:42 +0000 Received: by mail-ed1-f68.google.com with SMTP id g16so7440628eds.1 for ; Mon, 11 May 2020 03:08:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=ADM8r+B0dzyP5A/vqyNmonnjvaPcrODBmZPyMqMMxIs=; b=N4I2RtizfT9fFpQ7hS+PtKvaO2BisfUQzfD/+IuDB4oSwuoFFG99xRvbnoWQBrVL0H KHcTivdcjjVLfdpqJmcij51yju0R54d6hxLXYbGp67Pxqtg0MppGTLRYwDZI/bmgmLCY eCruEDDx/MKzt2RjYqTlZOe5oxM9sbWHrUUbl5aEMK/2GZOKwppjwcjhu50JXqMVVH3R O9RNS2tYHvkwCnuNNpOGht5X/3Ah/Dd6oz7UftVbfkjJk09GjfZheMDn1QsI1L/cyr2x JFCdglvvgexq3OmNKwfbntGTt8yTh+V/v5uzSdq8wKF4gIQstHTsEYD+8D5HlhOu7z7Q zNnA== X-Gm-Message-State: AGi0Pubh5mbqLB2fxMU8ZDqP7wI2vufkJxf8uOYwPnDb6MKbx8pZa6NO g2ADMaol/g38IdvpGGe2OfE= X-Google-Smtp-Source: APiQypIIjKKjypDAYbOFH4MiQWndpu/est9zg63nnHoe6ueUE/9p66tdn9yO2ilqbrvMJLoHMfCWHw== X-Received: by 2002:a05:6402:28e:: with SMTP id l14mr12321849edv.184.1589191719680; Mon, 11 May 2020 03:08:39 -0700 (PDT) Received: from kozik-lap ([194.230.155.237]) by smtp.googlemail.com with ESMTPSA id ga1sm1242231ejb.65.2020.05.11.03.08.38 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 May 2020 03:08:39 -0700 (PDT) Date: Mon, 11 May 2020 12:08:36 +0200 From: Krzysztof Kozlowski To: Jonathan Bakker Subject: Re: [PATCH] tty: serial: samsung: Correct clock selection logic Message-ID: <20200511100836.GA16828@kozik-lap> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200511_030841_695915_ECFE77DC X-CRM114-Status: GOOD ( 18.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-samsung-soc@vger.kernel.org, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, kgene@kernel.org, linux-serial@vger.kernel.org, jslaby@suse.com, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, May 08, 2020 at 06:34:33PM -0700, Jonathan Bakker wrote: > Some variants of the samsung tty driver can pick which clock > to use for their baud rate generation. In the DT conversion, > a default clock was selected to be used if a specific one wasn't > assigned and then a comparison of which clock rate worked better > was done. Unfortunately, the comparison was implemented in such > a way that only the default clock was ever actually compared. > Fix this by iterating through all possible clocks, except when a > specific clock has already been picked via clk_sel (which is > only possible via board files). > > Signed-off-by: Jonathan Bakker > --- > drivers/tty/serial/samsung_tty.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/tty/serial/samsung_tty.c b/drivers/tty/serial/samsung_tty.c > index 73f951d65b93..9d2b4be44209 100644 > --- a/drivers/tty/serial/samsung_tty.c > +++ b/drivers/tty/serial/samsung_tty.c > @@ -1281,14 +1281,14 @@ static unsigned int s3c24xx_serial_getclk(struct s3c24xx_uart_port *ourport, > struct s3c24xx_uart_info *info = ourport->info; > struct clk *clk; > unsigned long rate; > - unsigned int cnt, baud, quot, clk_sel, best_quot = 0; > + unsigned int cnt, baud, quot, best_quot = 0; > char clkname[MAX_CLK_NAME_LENGTH]; > int calc_deviation, deviation = (1 << 30) - 1; > > - clk_sel = (ourport->cfg->clk_sel) ? ourport->cfg->clk_sel : > - ourport->info->def_clk_sel; > for (cnt = 0; cnt < info->num_clks; cnt++) { > - if (!(clk_sel & (1 << cnt))) > + /* Keep selected clock if provided */ Makes sense and good catch. Reviewed-by: Krzysztof Kozlowski I wonder about the s3c24xx_serial_enable_baudclk() which has similar pattern - is there testing only def_clk_sel on purpose? Best regards, Krzysztof > + if (ourport->cfg->clk_sel && > + !(ourport->cfg->clk_sel & (1 << cnt))) > continue; > > sprintf(clkname, "clk_uart_baud%d", cnt); > -- > 2.20.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel