Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp430299rdb; Fri, 6 Oct 2023 07:42:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGOawEqbpCkxoE76p2ms09Y9iMh9dE04f0n6BOOT+xGzRcfROs3aSbL7N/h6TYDTttHcbNh X-Received: by 2002:a17:90a:898a:b0:26f:392f:f901 with SMTP id v10-20020a17090a898a00b0026f392ff901mr8919633pjn.14.1696603355426; Fri, 06 Oct 2023 07:42:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696603355; cv=none; d=google.com; s=arc-20160816; b=DxLrYVL6Rz60bfeBaziUa8nhmdyqdkb7HZwjk1OFpZhn4r/JStauUhh7nTZAPpgTXb hPrbbFHPPEWT3J6RZxRNCxuyHqx83tj/BLWAujElYiGDkxZfQ1E9XhdfHQfwL00AayKR 0Rsmt1YE7GGMRt0S0QpKugcKis5mu0l+/rI6pvqGTHbDgcMObOtlfXetCPjQO9+kcLc7 UHu7wdBibLHgXa/UJ4owVlx/SLv2FiSvN/MCDxZbAKxtoe6nBi8rus+P79oTqwVYNzC4 RtwncQFNq8rpIc2HxGU8NNv7FTfc71Sc5quBjcR4nvKqOCffWC71g3J6FXK37X2JYHtq eGow== 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 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id h24-20020a17090aa89800b00274cf8042b6si5875963pjq.102.2023.10.06.07.42.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 07:42:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; 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 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id AF22881CCD92; Fri, 6 Oct 2023 07:42:32 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230158AbjJFOlr (ORCPT + 99 others); Fri, 6 Oct 2023 10:41:47 -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 ); 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 ; 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 ; 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 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 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprJKsWRmVeSWpSXmKPExsWy7djP87qTZRRSDQ7esrK4/7WD0WJt71EW i3Xb7jFb7N5wmMli0+NrrBYdf78wWlzeNYfNYu2Ru+wWd/fPZXTg9Jh1/yybx6ZVnWwem5fU e/RtWcXo8XmTXABrFJdNSmpOZllqkb5dAlfGh4dX2Qq2C1Vc/7CWqYGxj7+LkYNDQsBEYvIZ li5GLg4hgRWMEgcPt7JBOF8YJSatnMsK4XxmlNi0/QxzFyMnWMeu09MZQW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VkamSvp1NSmpO Zllqkb5dgl7Gh4dX2Qq2C1Vc/7CWqYGxj7+LkZNDQsBEYtfp6YxdjFwcQgJLGSUmrpvMDpGQ kTg5rYEVwhaW+HOtiw2i6BOjxKdH3YwgCTYBQ4mutyAJDg4RgVSJHRsUQWqYBRYxSdz41MEK EhcWsJfY0WkGUs4ioCqx/ONzsJm8QOEt0+9AzZeX2H/wLDNEXFDi5MwnLCA2M1C8eets5gmM fLOQpGYhSS1gZFrFKJJaWpybnltspFecmFtcmpeul5yfu4kRGPTbjv3csoNx5auPeocYmTgY DzFKcDArifCmN8ikCvGmJFZWpRblxxeV5qQWH2I0BbpvIrOUaHI+MO7ySuINzQxMDU3MLA1M Lc2MlcR5PQs6EoUE0hNLUrNTUwtSi2D6mDg4pRqYFj6fw9NxU493jpH746vVlzb8N3W4+vQv k3C2+Mmk7YqcMVwcc9Z4Lcl1YfRY05PNkPlE8Abz0u1fjNmcapOe6Whkvp254NzkGN/7LC1T njceX606f7thjky00i/zFfWCxV8zeKa1Pft+d/MJK9+/ay/s+NZ/ex2XWFX9AQW9DbNUbNTt btu+8jLk0pypL+i2Ne0Tk3p2DbP72zUuVTLJ30olQlc3eyt8Mr10Tkxsxmoup/kV628t2n9a 4U5OfeCJ6sjXq/TCnGaz9ph+aXdTXLH7gQ7Xwv8XNnIl5EmpVV9L3LKfvfHxeU+LmMLAqiD3 yylvVJUkHfzM60UnFfU/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: 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 pete.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 (pete.vger.email [0.0.0.0]); Fri, 06 Oct 2023 07:42:32 -0700 (PDT) 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 --- 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, }; -- 2.34.1