Message ID | 20231006144117.4079796-1-m.szyprowski@samsung.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp379422vqo; Fri, 6 Oct 2023 07:42:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHXNNF6yuYzm19mmjkLikvVBlXFDRPBs+5ky5v/8yhn/oMlc/ILZOrWQeDKAw9GCMPL+Owj X-Received: by 2002:a17:902:ce86:b0:1c4:4a4d:cc6 with SMTP id f6-20020a170902ce8600b001c44a4d0cc6mr5934756plg.19.1696603323809; Fri, 06 Oct 2023 07:42:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696603323; cv=none; d=google.com; s=arc-20160816; b=VvYtF8RHpaSL9FzBbXD63upud89vP5GPjKaGHGaQ/Ku2TdodY1tGsNurpMZyOJUuDO 8gU06SyRZP6a3d+YfVV75y/Ey4gJixFPYPPeLfsyBKzhcgQjiNnhCx9oD4raSOd0QBdW kvAgu5eHtG1OkK1N4TowXGKOjdgHVtPFOjmITf7mHIi5HwD0Nfh2Y4UigDTMkAe+GIhD /b11AkUzdcMgdea9X1GpbNo5wRoU1lR5uFgLFJmdDmxCC1u/DS369ys4yn3GIAfqgEtV fC9aWRRTLutO4s1PsVcNAPtPe0cSh5wC6b1wpsKzFd1MG2wcbUEP0hQaMoQUkqKeeWhB TAuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:cms-type:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :dkim-filter; bh=Dh7echwJPUUeAbJ+0c1vCQ3HcyHKHNDzK9iXWzkT8xU=; fh=M65tD0PCIecmYurvvims0wtSyP3ec3RuFPst6iEHwyg=; b=Zt15H8r+Y12BCDk7IyuceOvPqRk2SgVhjJntb0KZVxb1GsRcBVkMlicpic22Up0gq1 STZ5aRdNIEjrWzoTs+TpnSgpGWOHkE86xczNa3aiVb9aRGhD+vO2/+IwzkwMrQ0QRD9J nKzQcgZvF7MUpSr6YffenvlmSoRa1LVOR5UJR8SatAQFdtIu+j0Fg8IzM/nUfiLclQ9E NMEDqbqiNh/SJZBI1Ik5ZSZAKcX3/GiQQvdb+/GUSSVYC2AFqNIeNfUetwkNTMX6CjXq vc5QpFxKLKZWxyb65IiAh14zbxjM2W38NOMvQcqU3EYUIjXsWjDnKWDwNKmIVxr3fuE2 eQjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=kAvcjwDb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id lc6-20020a170902fa8600b001b9ffda162csi3594316plb.441.2023.10.06.07.42.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 07:42:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=kAvcjwDb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 214898050034; Fri, 6 Oct 2023 07:42:01 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232603AbjJFOls (ORCPT <rfc822;ezelljr.billy@gmail.com> + 18 others); Fri, 6 Oct 2023 10:41:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232586AbjJFOlc (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 6 Oct 2023 10:41:32 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC577CA for <linux-kernel@vger.kernel.org>; Fri, 6 Oct 2023 07:41:27 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20231006144124euoutp025ff7815926b93447ac29b1c616b326f9~Li7K3oFTI2481524815euoutp02e for <linux-kernel@vger.kernel.org>; Fri, 6 Oct 2023 14:41:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20231006144124euoutp025ff7815926b93447ac29b1c616b326f9~Li7K3oFTI2481524815euoutp02e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1696603284; bh=Dh7echwJPUUeAbJ+0c1vCQ3HcyHKHNDzK9iXWzkT8xU=; h=From:To:Cc:Subject:Date:References:From; b=kAvcjwDbQ8uyqjjOyaq2bcmYF8VAs9JyFAqkdGX48sD9469FZrTRQYrc8lnhb9uUf X2iDRyU4Ks8XP115ruZpM0GjkncrcL4qUJuh1fR+Bx2qYy+24LqKhSJ8l2F96sYgSk kCuyWY5WIhOHGSaGVot22skqVt6k2mqi09C9h5Ho= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20231006144124eucas1p2ec745c7967b0a8c29d3e6cd7aeadd2ac~Li7Kk8e9F1761517615eucas1p2A; Fri, 6 Oct 2023 14:41:24 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 24.8C.11320.39C10256; Fri, 6 Oct 2023 15:41:23 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20231006144123eucas1p111cbbdbd70927ffbd697f7edf6b7ae1c~Li7KOyOMx0476904769eucas1p19; Fri, 6 Oct 2023 14:41:23 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20231006144123eusmtrp1acdc5ca3ce8295dd231945fafd843a51~Li7KOCMTM2739727397eusmtrp1s; Fri, 6 Oct 2023 14:41:23 +0000 (GMT) X-AuditID: cbfec7f4-97dff70000022c38-1a-65201c937127 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 1A.1B.25043.39C10256; Fri, 6 Oct 2023 15:41:23 +0100 (BST) Received: from AMDC4653.digital.local (unknown [106.120.51.32]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20231006144122eusmtip2e8ec28b6b97e8170c2297b1b8331364a~Li7Jn79bK1471614716eusmtip2p; Fri, 6 Oct 2023 14:41:22 +0000 (GMT) From: Marek Szyprowski <m.szyprowski@samsung.com> To: linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Marek Szyprowski <m.szyprowski@samsung.com>, Kamal Dasu <kamal.dasu@broadcom.com>, Broadcom internal kernel review list <bcm-kernel-feedback-list@broadcom.com>, Andi Shyti <andi.shyti@kernel.org>, Florian Fainelli <florian.fainelli@broadcom.com>, Wolfram Sang <wsa@kernel.org> Subject: [PATCH] i2c: brcmstb: Add support for atomic transfers Date: Fri, 6 Oct 2023 16:41:17 +0200 Message-Id: <20231006144117.4079796-1-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0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FfU/7K9TTHfjy+LUDTTdbK3EUpyRaKjFXFScCADgiVurAwMAAA== X-CMS-MailID: 20231006144123eucas1p111cbbdbd70927ffbd697f7edf6b7ae1c X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20231006144123eucas1p111cbbdbd70927ffbd697f7edf6b7ae1c X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20231006144123eucas1p111cbbdbd70927ffbd697f7edf6b7ae1c References: <CGME20231006144123eucas1p111cbbdbd70927ffbd697f7edf6b7ae1c@eucas1p1.samsung.com> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Fri, 06 Oct 2023 07:42:01 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779017526567900749 X-GMAIL-MSGID: 1779017526567900749 |
Series |
i2c: brcmstb: Add support for atomic transfers
|
|
Commit Message
Marek Szyprowski
Oct. 6, 2023, 2:41 p.m. UTC
Add support for atomic transfers using polling mode with interrupts
intentionally disabled to get rid of the warning introduced by commit
63b96983a5dd ("i2c: core: introduce callbacks for atomic transfers")
during system reboot and power-off.
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
---
drivers/i2c/busses/i2c-brcmstb.c | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
Comments
On 10/6/23 07:41, Marek Szyprowski wrote: > Add support for atomic transfers using polling mode with interrupts > intentionally disabled to get rid of the warning introduced by commit > 63b96983a5dd ("i2c: core: introduce callbacks for atomic transfers") > during system reboot and power-off. Is there an existing system that you have access to which needs atomic transfer support, or is this a forward looking change? > > Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
On 09.10.2023 22:41, Florian Fainelli wrote: > On 10/6/23 07:41, Marek Szyprowski wrote: >> Add support for atomic transfers using polling mode with interrupts >> intentionally disabled to get rid of the warning introduced by commit >> 63b96983a5dd ("i2c: core: introduce callbacks for atomic transfers") >> during system reboot and power-off. > > Is there an existing system that you have access to which needs atomic > transfer support, or is this a forward looking change? Frankly speaking I've observed the mentioned warning during system reboot on RaspberryPi4 with linux-next kernel compiled from multi_v7_defconfig. It looks that this driver is used by VC4 DRM for DDC. This issue doesn't look critical, but the fix seems to be trivial, thus my patch. Best regards
Hi, I admit that I don't understand the I²C subsystem very well, but doesn't this introduce a potential race condition? > ... > @@ -240,7 +241,7 @@ static int brcmstb_i2c_wait_for_completion(struct brcmstb_i2c_dev *dev) > ... > - if (dev->irq >= 0) { > + if (dev->irq >= 0 && !dev->atomic) { > ... > @@ -287,7 +288,7 @@ static int brcmstb_send_i2c_cmd(struct brcmstb_i2c_dev *dev, > ... > - if (dev->irq >= 0) > + if (dev->irq >= 0 && !dev->atomic) > ... > +static int brcmstb_i2c_xfer_atomic(struct i2c_adapter *adapter, > + struct i2c_msg msgs[], int num) > ... > + dev->atomic = true; > + ret = brcmstb_i2c_xfer(adapter, msgs, num); > + dev->atomic = false; > ... What happens when one of the if() branches is taken in one thread while another thread is just executing the assignment of the atomic flag? My expectation would be that the first tread still sees the old flag value and happily executes the branch, while brcmstb_i2c_xfer_atomic() sets the flag just after and initiates a transfer. I'd expect that access to the flag must be atomic as well, so maybe something like https://www.kernel.org/doc/html/latest/core-api/wrappers/atomic_t.html is needed, or some other synchronization mechanism. Or is it guaranteed that brcmstb_i2c_wait_for_completion() and brcmstb_send_i2c_cmd() can only be called from the same thread as brcmstb_i2c_xfer_atomic() ? Regards, Gregor
On 11.10.2023 12:23, Gregor Riepl wrote: > I admit that I don't understand the I²C subsystem very well, but > doesn't this introduce a potential race condition? > > > ... > > @@ -240,7 +241,7 @@ static int > brcmstb_i2c_wait_for_completion(struct brcmstb_i2c_dev *dev) > > ... >> - if (dev->irq >= 0) { >> + if (dev->irq >= 0 && !dev->atomic) { > > ... > > @@ -287,7 +288,7 @@ static int brcmstb_send_i2c_cmd(struct > brcmstb_i2c_dev *dev, > > ... >> - if (dev->irq >= 0) >> + if (dev->irq >= 0 && !dev->atomic) > > ... > > +static int brcmstb_i2c_xfer_atomic(struct i2c_adapter *adapter, > > + struct i2c_msg msgs[], int num) > > ... >> + dev->atomic = true; >> + ret = brcmstb_i2c_xfer(adapter, msgs, num); >> + dev->atomic = false; >> ... > > What happens when one of the if() branches is taken in one thread > while another thread is just executing the assignment of the atomic > flag? My expectation would be that the first tread still sees the old > flag value and happily executes the branch, while > brcmstb_i2c_xfer_atomic() sets the flag just after and initiates a > transfer. > > I'd expect that access to the flag must be atomic as well, so maybe > something like > https://www.kernel.org/doc/html/latest/core-api/wrappers/atomic_t.html > is needed, or some other synchronization mechanism. > > Or is it guaranteed that brcmstb_i2c_wait_for_completion() and > brcmstb_send_i2c_cmd() can only be called from the same thread as > brcmstb_i2c_xfer_atomic() ? Atomic i2c transfers are some kind of a special case. I guess that i2c core takes care of NOT multiplexing atomic and standard i2c transfers. No special locking/protection is needed in the bus drivers. This is at least what I see from commits like 08960b022fb6 ("i2c: tegra-bpmp: convert to use new atomic callbacks") or 3d11a12ece85 ("i2c: ocores: enable atomic xfers"). Best regards
Hi Marek, On Fri, Oct 06, 2023 at 04:41:17PM +0200, Marek Szyprowski wrote: > Add support for atomic transfers using polling mode with interrupts > intentionally disabled to get rid of the warning introduced by commit > 63b96983a5dd ("i2c: core: introduce callbacks for atomic transfers") > during system reboot and power-off. > > Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Reviewed-by: Andi Shyti <andi.shyti@kernel.org> Andi
> I guess that i2c core takes care of NOT multiplexing atomic and standard > i2c transfers. Atomic transfers are only used iff the system is in a certain state, check i2c_in_atomic_xfer_mode(). Then and only then, transfers are atomic. All of them. Neither bus drivers nor clients can choose them.
On 10/11/2023 2:57 AM, Marek Szyprowski wrote: > On 09.10.2023 22:41, Florian Fainelli wrote: >> On 10/6/23 07:41, Marek Szyprowski wrote: >>> Add support for atomic transfers using polling mode with interrupts >>> intentionally disabled to get rid of the warning introduced by commit >>> 63b96983a5dd ("i2c: core: introduce callbacks for atomic transfers") >>> during system reboot and power-off. >> >> Is there an existing system that you have access to which needs atomic >> transfer support, or is this a forward looking change? > > Frankly speaking I've observed the mentioned warning during system > reboot on RaspberryPi4 with linux-next kernel compiled from > multi_v7_defconfig. It looks that this driver is used by VC4 DRM for > DDC. This issue doesn't look critical, but the fix seems to be trivial, > thus my patch. Makes sense, thanks for confirming this fixes an actual issue you have seen and providing a fix for it.
diff --git a/drivers/i2c/busses/i2c-brcmstb.c b/drivers/i2c/busses/i2c-brcmstb.c index acee76732544..38f276c99193 100644 --- a/drivers/i2c/busses/i2c-brcmstb.c +++ b/drivers/i2c/busses/i2c-brcmstb.c @@ -160,6 +160,7 @@ struct brcmstb_i2c_dev { struct completion done; u32 clk_freq_hz; int data_regsz; + bool atomic; }; /* register accessors for both be and le cpu arch */ @@ -240,7 +241,7 @@ static int brcmstb_i2c_wait_for_completion(struct brcmstb_i2c_dev *dev) int ret = 0; unsigned long timeout = msecs_to_jiffies(I2C_TIMEOUT); - if (dev->irq >= 0) { + if (dev->irq >= 0 && !dev->atomic) { if (!wait_for_completion_timeout(&dev->done, timeout)) ret = -ETIMEDOUT; } else { @@ -287,7 +288,7 @@ static int brcmstb_send_i2c_cmd(struct brcmstb_i2c_dev *dev, return rc; /* only if we are in interrupt mode */ - if (dev->irq >= 0) + if (dev->irq >= 0 && !dev->atomic) reinit_completion(&dev->done); /* enable BSC CTL interrupt line */ @@ -520,6 +521,23 @@ static int brcmstb_i2c_xfer(struct i2c_adapter *adapter, } +static int brcmstb_i2c_xfer_atomic(struct i2c_adapter *adapter, + struct i2c_msg msgs[], int num) +{ + struct brcmstb_i2c_dev *dev = i2c_get_adapdata(adapter); + int ret; + + if (dev->irq >= 0) + disable_irq(dev->irq); + dev->atomic = true; + ret = brcmstb_i2c_xfer(adapter, msgs, num); + dev->atomic = false; + if (dev->irq >= 0) + enable_irq(dev->irq); + + return ret; +} + static u32 brcmstb_i2c_functionality(struct i2c_adapter *adap) { return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | I2C_FUNC_10BIT_ADDR @@ -528,6 +546,7 @@ static u32 brcmstb_i2c_functionality(struct i2c_adapter *adap) static const struct i2c_algorithm brcmstb_i2c_algo = { .master_xfer = brcmstb_i2c_xfer, + .master_xfer_atomic = brcmstb_i2c_xfer_atomic, .functionality = brcmstb_i2c_functionality, };