Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp239821rdb; Thu, 21 Dec 2023 07:57:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IGojGCed8bsNL1DAmBalH5HeQOjCKH9qbBda3JlM2sVzhY/TBuZZKdahD9K/Y24jDNNipAB X-Received: by 2002:a17:90a:1689:b0:28b:f270:dac5 with SMTP id o9-20020a17090a168900b0028bf270dac5mr677507pja.97.1703174230286; Thu, 21 Dec 2023 07:57:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703174230; cv=none; d=google.com; s=arc-20160816; b=bY5/LhBoYSTnKHb1aEbcfLB8XBZiAf0SJVBMa53D6q0YIv88CYuHCsrtFmo36n2P7Q 61cp++0d3pH2rXvFhGvo79ccw3stULCKQ0BHqPwEghBwix5N5aHEyVUhjd53E3LHnntc Vhw5NZmySlU3vB7MkhrIAOKZGosH3bxxrIlpF5BnS0Ygofju809sAZstjpKo6492BJkA vKjOVa+NlOtzys/yxRr7+QhoZbgsJvaJ2RqxoWE2LEYGzRu/gs8+5stc0NkA7i6TeLa3 eM8KmznBZiqUvgJCdkDjGpQzcUckdpIWV4S7bfYc1B7nSSinrp+qMkb1sb6fhftyf9rk iCdg== 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=JCLYMxeRwt5JrQfRfdHodCm2prGrLkM65PPIWmowE3A=; fh=ie3XgEIPR7J+aiGk2/deTgQtutOBySwGBhMOY+rWXvo=; b=qyNa2m+hc+/yk/sM9lLGzU2DCKG7lmWPjobp9/kU/v7xsUflC1Y9wDFVECa7hrMiuQ HUHPOtTNUQC9g6WcUCDqOjFXVygKTx6fgAgGCOHBCOEd/PpkfeyXwOBHi4mTDCS9GaEO QrUGtraInOC68HLegBwnDt28n5rqwNyFPWhuNI5caoxkd4ASIzrNC4gPlrufAP0VqQka q1wGDLDMzpyRZsn6NPdInaWcds+E+S8XVNmAxMFdj2bH6LB6dO/tstyBCxW0eO/Nt6QY cwpWY5nqaeOd8dHz4r4+BNJkO4tPGylS+bbvlFYUeR0ohP6AQupenwOv/LrSOnUa6Fc/ EXrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@hugovil.com header.s=x header.b=p8MjdsOc; spf=pass (google.com: domain of linux-kernel+bounces-8717-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8717-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id m8-20020a17090ab78800b0028b9b0b2bbesi4900548pjr.189.2023.12.21.07.57.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 07:57:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-8717-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@hugovil.com header.s=x header.b=p8MjdsOc; spf=pass (google.com: domain of linux-kernel+bounces-8717-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8717-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id EB06E283B69 for ; Thu, 21 Dec 2023 15:57:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5AB4755E4F; Thu, 21 Dec 2023 15:57:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=hugovil.com header.i=@hugovil.com header.b="p8MjdsOc" 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 59B6B539FD; Thu, 21 Dec 2023 15:56:57 +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=JCLYMxeRwt5JrQfRfdHodCm2prGrLkM65PPIWmowE3A=; b=p8MjdsOcSA6R1jyYUyjMYwdd1/ 9tgAI41l716pDbFL0Btga1Klf/Cp9g9+ttKFa2UCs45kM0l7qqWiz3VLtaMgPbPa1N+y1TIZBPeZk 9tNo5RX7PiQc5u3PWtxZaca2IBuyF5EAO182otm24gXTcxGqx//pjmQEanincCvqUtpE=; Received: from modemcable168.174-80-70.mc.videotron.ca ([70.80.174.168]:49388 helo=pettiford) by mail.hugovil.com with esmtpa (Exim 4.92) (envelope-from ) id 1rGLPb-0006IC-LX; Thu, 21 Dec 2023 10:56:40 -0500 Date: Thu, 21 Dec 2023 10:56:39 -0500 From: Hugo Villeneuve To: Andy Shevchenko Cc: 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: <20231221105639.17910de5e7d7a486834bd856@hugovil.com> In-Reply-To: References: <20231219171903.3530985-1-hugo@hugovil.com> <20231219171903.3530985-3-hugo@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 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. Hugo Villeneuve