From patchwork Fri Oct 6 14:41:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 730929 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7130BE81E05 for ; Fri, 6 Oct 2023 14:41:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232587AbjJFOlj (ORCPT ); Fri, 6 Oct 2023 10:41:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232589AbjJFOlc (ORCPT ); Fri, 6 Oct 2023 10:41:32 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC835CE for ; Fri, 6 Oct 2023 07:41:27 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20231006144124euoutp01047b4b48731673485ab1bcc30f6b62c5~Li7K3rPu_1590615906euoutp01Q for ; Fri, 6 Oct 2023 14:41:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20231006144124euoutp01047b4b48731673485ab1bcc30f6b62c5~Li7K3rPu_1590615906euoutp01Q 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 To: linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Marek Szyprowski , Kamal Dasu , Broadcom internal kernel review list , Andi Shyti , Florian Fainelli , Wolfram Sang 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 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprJKsWRmVeSWpSXmKPExsWy7djP87qTZRRSDQ7esrK4/7WD0WJt71EW i3Xb7jFb7N5wmMli0+NrrBYdf78wWlzeNYfNYu2Ru+wWd/fPZXTg9Jh1/yybx6ZVnWwem5fU e/RtWcXo8XmTXABrFJdNSmpOZllqkb5dAlfGh4dX2Qq2C1Vc/7CWqYGxj7+LkYNDQsBEYvIZ li5GLg4hgRWMEgcPt7JBOF8YJSatnMsK4XxmlNi0/QxzFyMnWMeu09MZQWwhgeWMEh8WO8J1 nLr/iR0kwSZgKNH1tosNxBYRSJb4+fE32FhmgQVMEjff32QD2S0sYC+xo9MMpIZFQFVi+cfn rCA2L1B4y/Q7rBDL5CX2HzzLDBEXlDg58wkLiM0MFG/eOpsZZKaEwEoOidPH1kFd5yKx9uUK RghbWOLV8S3sELaMxOnJPSwQDe2MEgt+32eCcCYwSjQ8vwXVYS1x59wvsOuYBTQl1u/Shwg7 Svy5f4kNEmB8EjfeCkIcwScxadt0Zogwr0RHmxBEtZrErOPr4NYevHAJqsRDov2mLiTcYiXW Ll/IOoFRYRaSz2Yh+WwWwgkLGJlXMYqnlhbnpqcWG+WllusVJ+YWl+al6yXn525iBKae0/+O f9nBuPzVR71DjEwcjIcYJTiYlUR40xtkUoV4UxIrq1KL8uOLSnNSiw8xSnOwKInzqqbIpwoJ pCeWpGanphakFsFkmTg4pRqYpB841Pl3TdpbvdssueO+isfumfWv53zmmFR5v9vNNXiGzsXC 8g0Nb/je1ugbS/fqflecsDP88afHOk5q9h8OL39w3kxYp6Jo1QYvi6c7zf9V866rYj2nYXzl 8Ol/rm0ZseF9XVPOZL1wDnsy68Np6Qv1Jmd7I3z+zbAMvBnV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t8Mr10Tkxsxmoup/kV628t2n9a 4U5OfeCJ6sjXq/TCnGaz9ph+aXdTXLH7gQ7Xwv8XNnIl5EmpVV9L3LKfvfHxeU+LmMLAqiD3 yylvVJUkHfzM60UnFfU/7K9TTHfjy+LUDTTdbK3EUpyRaKjFXFScCADgiVurAwMAAA== X-CMS-MailID: 20231006144123eucas1p111cbbdbd70927ffbd697f7edf6b7ae1c X-Msg-Generator: CA X-RootMTR: 20231006144123eucas1p111cbbdbd70927ffbd697f7edf6b7ae1c X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20231006144123eucas1p111cbbdbd70927ffbd697f7edf6b7ae1c References: Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org 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 Reviewed-by: Florian Fainelli Reviewed-by: Andi Shyti --- drivers/i2c/busses/i2c-brcmstb.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) 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, };