From patchwork Tue Oct 25 08:18:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Cosmin Tanislav X-Patchwork-Id: 10584 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp876725wru; Tue, 25 Oct 2022 01:25:12 -0700 (PDT) X-Google-Smtp-Source: AMsMyM678sWMbS+vZbH6wEr68VmNFqXPDoA827WWlMw7tK1P33udphF6hyqC5l8CIMLFjmNFuTAf X-Received: by 2002:a17:907:6e03:b0:78e:1c82:1f2a with SMTP id sd3-20020a1709076e0300b0078e1c821f2amr30330658ejc.611.1666686312534; Tue, 25 Oct 2022 01:25:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666686312; cv=none; d=google.com; s=arc-20160816; b=EXxayfVhbhUVul6ggzM9vBE4JeGijrd0XrXFJHOvQRZsadQTZ+N5PWVBPCV1XaXzkg MPleLdLe8uzTcZSgZ5xc3uHB6Llk0oc5cJTrccdKXey4n3bYBD19uracwjPiHj5TUDVY xQHCXonPQHxbcXjW7jSkF4jRl+nSb6MNmhkCS6argX9lYhVt02UUIQFMl9IbM+8yWtxg 3iftqvCsoB+wzOg+BLd5UrYnieXMK0koOjnxt+Gvi7Ux5SO9/y21mUOkhVFGhfGd+X01 Z8AOTausSgKPIuFxEcGs2cpzcTpugXC/9CP1o3Lc6xhBlzfkWQYaC7DdYJfdz9RJZGwD L7EQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from :dkim-signature; bh=nq+6K44iGtvwt7RZnqV6tCJGlCcDC94XFaEhvgeSpes=; b=hD14Qrl8yIoVnUf7B0kKIO9EOKkpkRsIanHf5rfzhIIwcofqqCroaQBUnuJyeQuOT4 wL8sB1q0fk395SLN55DqADjJVf/RusWvgXf4YLl5I/LrxQXNKa4rNNweAD++RBSKe/GY n1BPHSR0VbKEvOwlr1nscEm3c+oA2HDechl3O3UmcXYl/BO4z0ApboC1/T8kzapc7npV uRKklZCT44b+srRHlleih7L9c813wgMM1qBa7YtWH8zRvDyrelObLMlaX20fd11WJ0sj Qi1aESo20yPEolh50dqpef5OT+duDWCsJtoel5hX4bOrtiInJPAT7v1M8hnInfxh1w7d U2Yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20210112 header.b=ETxSDcIZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i6-20020a1709064fc600b0078dee0fce23si2400820ejw.123.2022.10.25.01.24.48; Tue, 25 Oct 2022 01:25:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20210112 header.b=ETxSDcIZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231847AbiJYITA (ORCPT + 99 others); Tue, 25 Oct 2022 04:19:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231325AbiJYIS6 (ORCPT ); Tue, 25 Oct 2022 04:18:58 -0400 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54D90C2C96; Tue, 25 Oct 2022 01:18:57 -0700 (PDT) Received: by mail-ej1-x62d.google.com with SMTP id k2so10617361ejr.2; Tue, 25 Oct 2022 01:18:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nq+6K44iGtvwt7RZnqV6tCJGlCcDC94XFaEhvgeSpes=; b=ETxSDcIZrrSrZGIQdBGYPcZq6/mykFB26hAVtUCorr9T+q04n6MOVfv4vdEq1i7DYZ wKC1EudemHm4VQdgNAeM/40POVtlz48h5VO6jiL7IYdcOYyUZySxFLQjpSrZ+zrEH4aA DH7Jz7dctc9eTYnt/kAY8sauTBABkZpBACSGuVPwJ97K4ymEag5acp7FV71Scj8qEyY2 8j+5D+/ebr6ZR/SZi6+bisIZzm9JqJ7wQFNyw//YwFARWGf1+XRlYa3W5VUz36ubPgha 3Z13MWZrGtfwMp+lA76dJE5FarrC05oJ/fhgY3SvBjNPGP3sNFSjGBYJDWyALghEWQNG 0+Lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nq+6K44iGtvwt7RZnqV6tCJGlCcDC94XFaEhvgeSpes=; b=PiDzLY/iojkPn3T8aGH6vp6TTwXtIh6IOjav6xg0vkuIsMzDUFytzexQ7Hh+SZNEDs SFRviSmDr+ZFLHtsdqBo4eU3iUWzPRkauxuA9Ryl4WoAFzX33O29/5sKJSOXorSL9VOi fZvJLXeQsZtiem0nIBCVMpiA0T7hyNduZtKqApn0CIaG6syEZEhTCIT0QL9i4I4v+hZS Y0LM5/YIC76E4mVXCljrPhP0Lgn0V9clN6jaL7ul9W8AChFRRd6OEKUwPnZ0YzFMIoOb 8tUZCmT8SyV1LMEdZQ/X10QYpaHHCOk/vzD5gqPUjpZ7jOBR+LBf+Lnv4Z8dJhZleFaU wt3g== X-Gm-Message-State: ACrzQf1EvyO4M+ucY3vXVQNWZGCGJtwTsgm54gfS3eWqWjSWjjHjPQdg bNvsm1Xi1GaloPmQBCxdpsU= X-Received: by 2002:a17:906:fd84:b0:730:acee:d067 with SMTP id xa4-20020a170906fd8400b00730aceed067mr31520230ejb.206.1666685935948; Tue, 25 Oct 2022 01:18:55 -0700 (PDT) Received: from localhost.localdomain ([5.2.194.157]) by smtp.gmail.com with ESMTPSA id l1-20020a1709060cc100b007822196378asm992898ejh.176.2022.10.25.01.18.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Oct 2022 01:18:55 -0700 (PDT) From: Cosmin Tanislav Cc: Lars-Peter Clausen , Michael Hennerich , =?utf-8?q?Nuno_S=C3=A1?= , Jonathan Cameron , Rob Herring , Krzysztof Kozlowski , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Cosmin Tanislav Subject: [PATCH v3 1/4] iio: temperature: ltc2983: make bulk write buffer DMA-safe Date: Tue, 25 Oct 2022 11:18:39 +0300 Message-Id: <20221025081842.1896748-2-demonsingur@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221025081842.1896748-1-demonsingur@gmail.com> References: <20221025081842.1896748-1-demonsingur@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747647267228367051?= X-GMAIL-MSGID: =?utf-8?q?1747647267228367051?= From: Cosmin Tanislav regmap_bulk_write() does not guarantee implicit DMA-safety, even though the current implementation duplicates the given buffer. Do not rely on it. Fixes: f110f3188e56 ("iio: temperature: Add support for LTC2983") Signed-off-by: Cosmin Tanislav Reviewed-by: Nuno Sá --- drivers/iio/temperature/ltc2983.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/iio/temperature/ltc2983.c b/drivers/iio/temperature/ltc2983.c index b652d2b39bcf..ca1bb5f48988 100644 --- a/drivers/iio/temperature/ltc2983.c +++ b/drivers/iio/temperature/ltc2983.c @@ -209,6 +209,7 @@ struct ltc2983_data { * Holds the converted temperature */ __be32 temp __aligned(IIO_DMA_MINALIGN); + __be32 chan_val; }; struct ltc2983_sensor { @@ -313,19 +314,18 @@ static int __ltc2983_fault_handler(const struct ltc2983_data *st, return 0; } -static int __ltc2983_chan_assign_common(const struct ltc2983_data *st, +static int __ltc2983_chan_assign_common(struct ltc2983_data *st, const struct ltc2983_sensor *sensor, u32 chan_val) { u32 reg = LTC2983_CHAN_START_ADDR(sensor->chan); - __be32 __chan_val; chan_val |= LTC2983_CHAN_TYPE(sensor->type); dev_dbg(&st->spi->dev, "Assign reg:0x%04X, val:0x%08X\n", reg, chan_val); - __chan_val = cpu_to_be32(chan_val); - return regmap_bulk_write(st->regmap, reg, &__chan_val, - sizeof(__chan_val)); + st->chan_val = cpu_to_be32(chan_val); + return regmap_bulk_write(st->regmap, reg, &st->chan_val, + sizeof(st->chan_val)); } static int __ltc2983_chan_custom_sensor_assign(struct ltc2983_data *st,