Received: by 2002:a05:7412:a986:b0:f9:90c9:de9f with SMTP id o6csp37112rdh; Wed, 20 Dec 2023 13:42:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IGb1Yxqb6RGzuOLinUwyAn/H4Q9CgO7PTdbVP9Dw2DQw0cEc10QLNfR4D/GNrv0kLY5fVqt X-Received: by 2002:a05:6808:118b:b0:3b8:3ea1:1cec with SMTP id j11-20020a056808118b00b003b83ea11cecmr20216161oil.50.1703108528946; Wed, 20 Dec 2023 13:42:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703108528; cv=none; d=google.com; s=arc-20160816; b=g4NoAX41Dts+Td0Y2eqCe3Y/ez7SjuaeTg0k+6FtyMCJsV6pbVEjlUDWaNjsBlTfkB jD++tQqvSde/k6DZlOTLdlqeL63Pdo1u/u4KJl+TlLD1lrMYMhk8FJp53HWAf3TC1qdJ wSMyaj43hxYpKIRDNGC4qQg0+VkexblaIMwThwZ9mEdin+hnifpFWoBJ3j5vTUPL4BF7 4JiwbOn04rViQBbvdrE5dRrrruY31hONT94efzSyRtLR8dQPbhTfhPS/g88TMDwB4kDE gWOlJm3aB+Fs56Gg6o5MQeExTYKGrq+u82EZMxljHE6p3/FH3U2fLtLsxBj83ww0lvOw Md3Q== 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=wIWDMjkfub9nTTJ5JI74/K00hMgRE/kdEk8xa9Y7LW0=; fh=k7iMH8f3jdahezaKT2MAd2rrImqa0ZChBm+9PoieTIM=; b=i7SqHLmwsg7wTxGa2oB8AIx1sG23LzPC8+OzWvI3Ic64diyZoCRtIzLB6zMIha8iJL 7VilzTMHApn480lJmMDXSeU033lPp3XeL8IbMVJbiGeQf23MkRUOkEI7GywcI1btDMWY WB+EM4QRkK9I4Y/IGiv/1yhbISllslNqf+m0Zkkm5jplRGuOg5uJbt7htfsSoukIB6qL Gmtwy3zsexGxVM5YtXzBiq8VXzh35P7H25sCelgxFbNNbApiT3s79rnckvjQSdVepolf OW4k9qqYgveZUbzdhXEmAzTc/AsUG/soXOAfx72ZOfSvt/7GVixo1/hNTWIRAU1Lk9sr 8wAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@hugovil.com header.s=x header.b=uYCZ3KNG; spf=pass (google.com: domain of linux-kernel+bounces-7473-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7473-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id t10-20020a0c8d8a000000b0067f047ec72bsi566642qvb.335.2023.12.20.13.42.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 13:42:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-7473-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@hugovil.com header.s=x header.b=uYCZ3KNG; spf=pass (google.com: domain of linux-kernel+bounces-7473-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7473-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id AF5C71C2235A for ; Wed, 20 Dec 2023 21:42:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BFE294B143; Wed, 20 Dec 2023 21:38:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=hugovil.com header.i=@hugovil.com header.b="uYCZ3KNG" 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 E896D495EC; Wed, 20 Dec 2023 21:38:35 +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=wIWDMjkfub9nTTJ5JI74/K00hMgRE/kdEk8xa9Y7LW0=; b=uYCZ3KNG9utyPrLOQFCRgBF6Nl /vkLFPPGzZu4iOSDQKwsx9kGJD7FMpBWrI9XxlegwaUE3iaeSlBGPPAxzAV51jnMqIvo0I201/wtR 1aL5j4WX9noqJjeATTXuVYICtmfyutP384rd9vxKV5lI9eI4rPXAgxpi/h54/vjCWj4U=; Received: from modemcable168.174-80-70.mc.videotron.ca ([70.80.174.168]:57326 helo=pettiford) by mail.hugovil.com with esmtpa (Exim 4.92) (envelope-from ) id 1rG4Gk-0002Rp-RU; Wed, 20 Dec 2023 16:38:23 -0500 Date: Wed, 20 Dec 2023 16:38:22 -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 Message-Id: <20231220163822.ce1d3893735d3334ae2d04e2@hugovil.com> In-Reply-To: References: <20231219171903.3530985-1-hugo@hugovil.com> <20231219171903.3530985-18-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. * -1.4 NICE_REPLY_A Looks like a legit reply (A) Subject: Re: [PATCH 17/18] serial: sc16is7xx: refactor EFR lock 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 18:03:18 +0200 Andy Shevchenko wrote: > On Tue, Dec 19, 2023 at 12:19:01PM -0500, Hugo Villeneuve wrote: > > From: Hugo Villeneuve > > > > Move common code for EFR lock/unlock of mutex into functions for code reuse > > and clarity. > > ... > > > @@ -333,6 +333,7 @@ struct sc16is7xx_one { > > struct sc16is7xx_one_config config; > > bool irda_mode; > > unsigned int old_mctrl; > > + u8 old_lcr; /* Value before EFR access. */ > > }; > > Have you run `pahole`? > I believe with > > unsigned int old_mctrl; > u8 old_lcr; /* Value before EFR access. */ > bool irda_mode; > > layout it will take less memory. Hi, I did not know about this tool, nice. $ pahole -C sc16is7xx_one drivers/tty/serial/sc16is7xx.o Before: /* size: 752, cachelines: 12, members: 10 */ With your proposed change: /* size: 744, cachelines: 12, members: 10 */ Will add this modification for V2, as well as other issues noted below. Thank you, Hugo > > +/* In an amazing feat of design, the Enhanced Features Register (EFR) > > /* > * This is NOT the style we use for multi-line > * comments in the serial subsystem. On contrary > * this comment can be used as a proper example. > * (Yes, I noticed it's an old comment, but take > * a chance to fix it.) > */ > > > + * shares the address of the Interrupt Identification Register (IIR). > > + * Access to EFR is switched on by writing a magic value (0xbf) to the > > + * Line Control Register (LCR). Any interrupt firing during this time will > > + * see the EFR where it expects the IIR to be, leading to > > + * "Unexpected interrupt" messages. > > + * > > + * Prevent this possibility by claiming a mutex while accessing the EFR, > > + * and claiming the same mutex from within the interrupt handler. This is > > + * similar to disabling the interrupt, but that doesn't work because the > > + * bulk of the interrupt processing is run as a workqueue job in thread > > + * context. > > + */ > > ... > > > + sc16is7xx_port_write(port, SC16IS7XX_LCR_REG, > > + SC16IS7XX_LCR_CONF_MODE_B); > > One line. (Yes, 81 character, but readability is as good as before. > > -- > With Best Regards, > Andy Shevchenko > > > >