Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp256187rdb; Thu, 21 Dec 2023 08:17:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IERalrXJvMsQPhB2A782TJicT7XUd0OOA5ENZTNpmAwoZBNQrrzLOw+PX+qhksBUCJ+5B2v X-Received: by 2002:a17:90a:5806:b0:28a:9748:d7e4 with SMTP id h6-20020a17090a580600b0028a9748d7e4mr8011592pji.14.1703175467508; Thu, 21 Dec 2023 08:17:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703175467; cv=none; d=google.com; s=arc-20160816; b=GnExpj8SZ/LbnEzMk1L/FSaRLTogYqMtnN7mxkgDZxv2FuwMLB/ifYA+63nkSJF5wH MS3g9GgGEO2C4sdFVbSPghvdMMddVTFNQ1MEPVXBznweyBtW+pn3gyZ+RTYjnlSQRxZD Uo9YN+UUROfZJL3CDRfB3l0GmjS/e1xzb2zVgWaQeDKO6I34ode1gRBFofovTyNoUzTg yZOrKT+ZsCEAsW4o9/JjuoNp96rRUMp+8jYv7tU6QX1HgziLcgiI1l804gY0Da7EFPlO kzyrMZASd1JHP44GVe6pp/QhwZ3gVeKaDAhBlmZHTVld1nvDyoiuZ2L74bkIvgd/8tSO mD2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=subject:content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :cc:to:from:date:dkim-signature; bh=w58q1EZLNvdrYMtYLHciABWJyucaztQhQ1k0qWMzqJc=; fh=TIT0x25DfGbD6gfnOYQbDPQaE4jM70JMLmvdc6VqpXc=; b=u/HWwks23V1jaxlQvQ6WhK1SKzMOesXfHA5RGGFB2ZV4Qr4S90HhjMp5PbvuK/kKup zBoHl/T+d6gaDVTIHtG+HRbdo9a0vZHpqIPkXaMUPLnHrUJSp74sbEkIT1vCGOh9aFrF YrplmE35s5dVkxoFBO3kLZ0txnqm84JjH8isIhZLV6XSv+qY1ZiRQ2v/hvdWse+82jJa N/0Td29/m/0WnubvaJw348SRKOROHqEdK0Xf4gAqkn5Nhd67mAvdZ/yMLLmNpr+rX5qY iCi5sHcJALsf5ITuOBlQJH4WDA+hM/CCf1LznicFCS2pGcvZPiblUPgxVEyCwGVB7mpN oQtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@hugovil.com header.s=x header.b=k26iM+Dx; spf=pass (google.com: domain of linux-kernel+bounces-8746-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8746-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id g13-20020a17090a7d0d00b0028b6aa45c29si5149164pjl.59.2023.12.21.08.17.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 08:17:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-8746-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@hugovil.com header.s=x header.b=k26iM+Dx; spf=pass (google.com: domain of linux-kernel+bounces-8746-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8746-linux.lists.archive=gmail.com@vger.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 A28CAB25DB0 for ; Thu, 21 Dec 2023 16:15:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1758962808; Thu, 21 Dec 2023 16:13:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=hugovil.com header.i=@hugovil.com header.b="k26iM+Dx" X-Original-To: linux-kernel@vger.kernel.org Received: from mail.hugovil.com (mail.hugovil.com [162.243.120.170]) (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 8E350627FB; Thu, 21 Dec 2023 16:13:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hugovil.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hugovil.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=hugovil.com ; s=x; h=Subject:Content-Transfer-Encoding:Mime-Version:Message-Id:Cc:To:From :Date:subject:date:message-id:reply-to; bh=w58q1EZLNvdrYMtYLHciABWJyucaztQhQ1k0qWMzqJc=; b=k26iM+DxO+STVASN/voeZEecT/ oic5XSBzoiCRdjBIu2fQ09ZZGfOCRFIsxJLCQ8qTkhj3AwnD95SwCzfhT0rluAjDDZxXg7/WVM3s1 WqeUYruGFdANef/q6GM8kMtYGXmTRXdEdiqHQqQGFAb4QWBqP+8punhkVxom/UAqN5pI=; Received: from modemcable168.174-80-70.mc.videotron.ca ([70.80.174.168]:56104 helo=pettiford) by mail.hugovil.com with esmtpa (Exim 4.92) (envelope-from ) id 1rGLg2-0006VT-3M; Thu, 21 Dec 2023 11:13:38 -0500 Date: Thu, 21 Dec 2023 11:13:37 -0500 From: Hugo Villeneuve To: Hugo Villeneuve Cc: Andy Shevchenko , gregkh@linuxfoundation.org, jirislaby@kernel.org, jringle@gridpoint.com, kubakici@wp.pl, phil@raspberrypi.org, bo.svangard@embeddedart.se, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, Hugo Villeneuve , stable@vger.kernel.org, Yury Norov Message-Id: <20231221111337.2c1af5bbe4920268dac25e8f@hugovil.com> In-Reply-To: <20231221105639.17910de5e7d7a486834bd856@hugovil.com> References: <20231219171903.3530985-1-hugo@hugovil.com> <20231219171903.3530985-3-hugo@hugovil.com> <20231221105639.17910de5e7d7a486834bd856@hugovil.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) 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-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 70.80.174.168 X-SA-Exim-Mail-From: hugo@hugovil.com X-Spam-Level: X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * -0.0 T_SCC_BODY_TEXT_LINE No description available. * -3.8 NICE_REPLY_A Looks like a legit reply (A) Subject: Re: [PATCH 02/18] serial: sc16is7xx: fix invalid sc16is7xx_lines bitfield in case of probe error X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.hugovil.com) On Thu, 21 Dec 2023 10:56:39 -0500 Hugo Villeneuve wrote: > On Wed, 20 Dec 2023 17:40:42 +0200 > Andy Shevchenko wrote: > > > On Tue, Dec 19, 2023 at 12:18:46PM -0500, Hugo Villeneuve wrote: > > > From: Hugo Villeneuve > > > > > > If an error occurs during probing, the sc16is7xx_lines bitfield may be left > > > in a state that doesn't represent the correct state of lines allocation. > > > > > > For example, in a system with two SC16 devices, if an error occurs only > > > during probing of channel (port) B of the second device, sc16is7xx_lines > > > final state will be 00001011b instead of the expected 00000011b. > > > > > > This is caused in part because of the "i--" in the for/loop located in > > > the out_ports: error path. > > > > > > Fix this by checking the return value of uart_add_one_port() and set line > > > allocation bit only if this was successful. This allows the refactor of > > > the obfuscated for(i--...) loop in the error path, and properly call > > > uart_remove_one_port() only when needed, and properly unset line allocation > > > bits. > > > > > > Also use same mechanism in remove() when calling uart_remove_one_port(). > > > > Yes, this seems to be the correct one to fix the problem described in > > the patch 1. I dunno why the patch 1 even exists. > > Hi, > this will indeed fix the problem described in patch 1. > > However, if I remove patch 1, and I simulate the same probe error as > described in patch 1, now we get stuck forever when trying to > remove the driver. This is something that I observed before and > that patch 1 also corrected. > > The problem is caused in sc16is7xx_remove() when calling this function > > kthread_flush_worker(&s->kworker); > > I am not sure how best to handle that without patch 1. Also, if we manage to get past kthread_flush_worker() and kthread_stop() (commented out for testing purposes), we get another bug: # rmmod sc16is7xx ... crystal-duart-24m already disabled WARNING: CPU: 2 PID: 340 at drivers/clk/clk.c:1090 clk_core_disable+0x1b0/0x1e0 ... Call trace: clk_core_disable+0x1b0/0x1e0 clk_disable+0x38/0x60 sc16is7xx_remove+0x1e4/0x240 [sc16is7xx] This one is caused by calling clk_disable_unprepare(). But clk_disable_unprepare() has already been called in probe error handling code. Patch 1 also fixed this... Hugo Villeneuve