Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1755055rdb; Thu, 7 Dec 2023 08:01:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IEB6lVkFQd2h76hdyw7x8l2Nyj4Z2aaK+K/rYFlNrS0EoO7Uko0id2btXDG1LL0m1TaPDzU X-Received: by 2002:a05:6871:314a:b0:1fb:75b:2b8b with SMTP id lu10-20020a056871314a00b001fb075b2b8bmr2713330oac.71.1701964885049; Thu, 07 Dec 2023 08:01:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701964885; cv=none; d=google.com; s=arc-20160816; b=pdGS2QcAc3JDEPy+dKlF/Z4GFkM8IlGuVK1oyWSC1/fOrqyqtuBFINcIbS6cntaD6B a5dNpPeFPthWKHjh45uLKh5jzAbceePE83gKEuAmahZTSA0dAzEry9t+T0cu/L5jZtoY +VsLvUqG1KVXtGxySLYhLCvMzTUjvnAw2ENwRlBqU/aEtXxuUoVgDrO/irXR5LNNSwph oaHXF+hBi09qKK2Blxg8CIrzjU5LTsFHNCi1JolMT0/ZKiRGLKEhB/m4cDsKvVYAFBVQ JdoA73TXA9pr/wpO1jqsNEkv/F05W8vmApI5uPsB+7lfpyA9CwQ+jN19ZKLwxaWntzH+ aJdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=oqilAyRt/ISpv7H5Yl5CvDXx3wSk8+v8tlTDPANyaWY=; fh=JoHzsP06Gjtb3aMflUrgsKMWEQRNLm97emoB+TjJU5M=; b=E5Rtrws4UGLkWIJPKUCRYTDJbDj6pIMSXRCNVK52jrhhjWkcBAoqq1KqsGAg6BpwdO J0NSQk7xHo1X6rYxQfwPQwxh5yCKi50nXwfC3YQlr7mHi9EcSGzQeI3M4BMAQL6WDYja nTDM/AmVwM4d8AFMoPDfIHQsTUj2BitgwK3/gGcgqVu5FoDazu3Jt0E/T0A8stcOzkh7 21QCP8SvfT3D6Oi/vXkcuDRcO7SwyyIfboA5Sa9TlWkU9BQ34fzK+L6Kr3JeJK41kzWf OQ5PXsdGi9aT9uzxxI3qUe51ZCscwZkSLs6ALaWYpD3ZDHglFY1ykHZ5E/Ads3do4o9J 3w3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=J+HzaMOm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id pb38-20020a05687179a600b001fb3b4eba84si25461oac.45.2023.12.07.08.01.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 08:01:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=J+HzaMOm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id A369880C256A; Thu, 7 Dec 2023 08:01:20 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232960AbjLGQBF (ORCPT + 99 others); Thu, 7 Dec 2023 11:01:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1443690AbjLGQAo (ORCPT ); Thu, 7 Dec 2023 11:00:44 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98F53121; Thu, 7 Dec 2023 08:00:50 -0800 (PST) Received: from [10.3.2.161] (zone.collabora.co.uk [167.235.23.81]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dmitry.osipenko) by madras.collabora.co.uk (Postfix) with ESMTPSA id BE36A660739F; Thu, 7 Dec 2023 16:00:47 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1701964848; bh=o60ZivJAjuNVk9lMONJuI83P129Uc3ICsB0e+skvORE=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=J+HzaMOmkobFxYMAtj8seSUoTES01PM+gUy6AJ1Rby/oRd0J7+PDOezsV5mD/tn6K EkSmnkdqoJuT8pb2R0q7hAurSYtX9c9b2lEnTDBPrmyJ/TIrJppmb14MZFbw8y86I3 FqvfijCWVaKSW5bq6BY73mzVmS6dSpfajFksSpBuz1tD8SlmOMXZ7zYvChz2eZ+FD/ NKR9hvbaqcvGJHK2sB9UhMf5OUH9dBlNMribUGYAOrOZ3fqexBu7YRmg4XGYHuJH1h 71YB2AJZxJOwZKdvEGbB7jC0hPO+HAoOew1HOrDkHkjJlB9iER4S6RVUXfxJ/7FuB9 3wlZgxaWA9ALg== Message-ID: <95cc7716-ba01-e239-e7c0-eba0b7da7955@collabora.com> Date: Thu, 7 Dec 2023 19:00:42 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH v2] i2c: rk3x: fix potential spinlock recursion on poll Content-Language: en-US To: Dragan Simic , Jensen Huang Cc: Heiko Stuebner , Andi Shyti , linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Chris Morgan , Benjamin Bara References: <20231207082200.16388-1-jensenhuang@friendlyarm.com> <5e11553952c02ad20591992be4284bbd@manjaro.org> From: Dmitry Osipenko In-Reply-To: <5e11553952c02ad20591992be4284bbd@manjaro.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Thu, 07 Dec 2023 08:01:20 -0800 (PST) On 12/7/23 17:10, Dragan Simic wrote: > On 2023-12-07 10:25, Jensen Huang wrote: >> On Thu, Dec 7, 2023 at 4:37 PM Dragan Simic wrote: >>> >>> On 2023-12-07 09:21, Jensen Huang wrote: >>> > Possible deadlock scenario (on reboot): >>> > rk3x_i2c_xfer_common(polling) >>> >     -> rk3x_i2c_wait_xfer_poll() >>> >         -> rk3x_i2c_irq(0, i2c); >>> >             --> spin_lock(&i2c->lock); >>> >             ... >>> >         >>> >         -> rk3x_i2c_irq(0, i2c); >>> >             --> spin_lock(&i2c->lock); (deadlock here) >>> > >>> > Store the IRQ number and disable/enable it around the polling >>> transfer. >>> > This patch has been tested on NanoPC-T4. >>> >>> In case you haven't already seen the related discussion linked below, >>> please have a look.  I also added more people to the list of recipients, >>> in an attempt to make everyone aware of the different approaches to >>> solving this issue. >>> >>> https://lore.kernel.org/all/655177f4.050a0220.d85c9.3ba0@mx.google.com/T/#m6fc9c214452fec6681843e7f455978c35c6f6c8b >> >> Thank you for providing the information. I hadn't seen this link before. >> After carefully looking into the related discussion, it appears that >> Dmitry Osipenko is already working on a suitable patch. To avoid >> duplication >> or conflicts, my patch can be discarded. > > Thank you for responding so quickly.  Perhaps it would be best to hear > from Dmitry as well, before discarding anything.  It's been a while > since Dmitry wrote about working on the patch, so he might have > abandoned it. This patch is okay. In general, will be better to have IRQ disabled by default like I did in my variant, it should allow to remove the spinlock entirely. Of course this also can be done later on in a follow up patches. Jensen, feel free to use my variant of the patch, add my s-o-b+co-developed tags to the commit msg if you'll do. Otherwise I'll be able to send my patch next week. -- Best regards, Dmitry