From patchwork Mon Nov 21 15:08:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Walle X-Patchwork-Id: 23891 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1651105wrr; Mon, 21 Nov 2022 07:19:39 -0800 (PST) X-Google-Smtp-Source: AA0mqf5kEzRVmvziPRXkN+p9vyEOrC8vkD67AyJABRAdS5hn52OqUTwES5MMQ++dJleq0wziLJou X-Received: by 2002:a17:906:bcc1:b0:73d:715c:5730 with SMTP id lw1-20020a170906bcc100b0073d715c5730mr15717981ejb.293.1669043979251; Mon, 21 Nov 2022 07:19:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669043979; cv=none; d=google.com; s=arc-20160816; b=DXFZ7u9pwb/DoUx+MdUwS0VwXpcv904+Io3Q/3LaXZqkHe0Ll/26sa7xZCxR+J+eW/ Yp/hYCWQmpRVh6ahqwKVb79uN7j+lGdhhS/oAWDEpXrpLx2xSUZgvZBAzWILIRcBuZbS hIdbjAWmZ26KrHc97UXZGj0zqslnVBTmna/LAg8BXj0S6AB73flKWT/B2HZrI2PpnFUt GRrLxuRjpwXhWY98RvozFZXP2v4ihuZTAvtUhW6nw56YDQVTZzn1RbPUlKVzg0hJODtE oukD3TafvPrx4XrbD7ySbJOHfC57WxegaZ8gy07unRUMZoTnjF5vsCvjbwuag+H8XltD VmQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=ShPOxC+vc6kAIrStj2HW/8mEr6+lT3FK4X9HcTeMoPg=; b=EAL6geK+dO2Wfc9ojg9ir2NR2gKf+PPwQtb7XislzVpPrJjp4Lj+Jcx2vGx034EEFM Y0d48S5MDOoUFVJgKP28JtxBU0vIIGTRizK0bmYM2MjI7ZWJEldiql5d9IIQGIFFlqEN EToBfIzbZDqGChmxuNhLL5YHV3lMcPMN1IpFtGio3ULT8lykfQ7FkN7eQlnueWuZgYcy 0DrLQE5pvoguXv8vaImuKZEBAMUYViUzN22U9GRjED/D9jtwlJMo5w1ZFFztnJCv24mI gbLHQn/mLB0uFbyl1efHlnDOgy2gDvARI2ZgEajOAif1OrkqzCq3HnX3zzEipF9czUzY s2gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2022082101 header.b=IlQZyAYQ; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=walle.cc Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hv20-20020a17090760d400b007ae94428c13si10192155ejc.525.2022.11.21.07.19.12; Mon, 21 Nov 2022 07:19:39 -0800 (PST) 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=pass header.i=@walle.cc header.s=mail2022082101 header.b=IlQZyAYQ; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=walle.cc Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232096AbiKUPOt (ORCPT + 99 others); Mon, 21 Nov 2022 10:14:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229463AbiKUPOI (ORCPT ); Mon, 21 Nov 2022 10:14:08 -0500 Received: from mail.3ffe.de (0001.3ffe.de [159.69.201.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40B3DCFA73; Mon, 21 Nov 2022 07:08:56 -0800 (PST) Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.3ffe.de (Postfix) with ESMTPSA id 25C74230D; Mon, 21 Nov 2022 16:08:54 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1669043334; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=ShPOxC+vc6kAIrStj2HW/8mEr6+lT3FK4X9HcTeMoPg=; b=IlQZyAYQe3hDv2l9ZeBmKXQKfgyanqyB4reG447B/lnDD+KEp2prY3rs7NN6MBwQIZTujf 4+k0EtLtEjuLyHIlA84BP6Ljkw16yvuRd9bND2jqLLJyRiBWvUQGZHOxysCJy/6a0ZtZHn h4c2PbqpQthoCw+pX/ds8ufPoZNFnDDk8IGlURzWFyaogGzIhbYHbC3jFwEDWC4YLeM8oo JMSWuUjWARbv2CwwG5kuGfSbHMzROgcEP4UtO5bB4BoeCIHPtDyfiNOe5V9qIueDN9uUnO R3o3R0RWAh1nGrifXKUVI+aGoHu5c+vJ7YXmMdI254Lu8qqqNMm0xRpdGDqv7g== From: Michael Walle To: Mark Brown , Greg Kroah-Hartman , "Rafael J . Wysocki" , Linus Walleij , Bartosz Golaszewski Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, William Breathitt Gray , Michael Walle Subject: [PATCH 1/2] regmap: add regmap_might_sleep() Date: Mon, 21 Nov 2022 16:08:42 +0100 Message-Id: <20221121150843.1562603-1-michael@walle.cc> X-Mailer: git-send-email 2.30.2 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,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 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?1750119459233327388?= X-GMAIL-MSGID: =?utf-8?q?1750119459233327388?= With the dawn of MMIO gpio-regmap users, it is desirable to let gpio-regmap ask the regmap if it might sleep during an access so it can pass that information to gpiochip. Add a new regmap_might_sleep() to query the regmap. Signed-off-by: Michael Walle --- drivers/base/regmap/regmap.c | 13 +++++++++++++ include/linux/regmap.h | 7 +++++++ 2 files changed, 20 insertions(+) diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index c6d6d53e8cd3..d12d669157f2 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -3486,6 +3486,19 @@ int regmap_get_reg_stride(struct regmap *map) } EXPORT_SYMBOL_GPL(regmap_get_reg_stride); +/** + * regmap_might_sleep() - Returns whether a regmap access might sleep. + * + * @map: Register map to operate on. + * + * Returns true if an access to the register might sleep, else false. + */ +bool regmap_might_sleep(struct regmap *map) +{ + return map->can_sleep; +} +EXPORT_SYMBOL_GPL(regmap_might_sleep); + int regmap_parse_val(struct regmap *map, const void *buf, unsigned int *val) { diff --git a/include/linux/regmap.h b/include/linux/regmap.h index ca3434dca3a0..3faf5d5dbb26 100644 --- a/include/linux/regmap.h +++ b/include/linux/regmap.h @@ -1219,6 +1219,7 @@ static inline int regmap_write_bits(struct regmap *map, unsigned int reg, int regmap_get_val_bytes(struct regmap *map); int regmap_get_max_register(struct regmap *map); int regmap_get_reg_stride(struct regmap *map); +bool regmap_might_sleep(struct regmap *map); int regmap_async_complete(struct regmap *map); bool regmap_can_raw_write(struct regmap *map); size_t regmap_get_raw_read_max(struct regmap *map); @@ -1905,6 +1906,12 @@ static inline int regmap_get_reg_stride(struct regmap *map) return -EINVAL; } +static inline bool regmap_might_sleep(struct regmap *map) +{ + WARN_ONCE(1, "regmap API is disabled"); + return true; +} + static inline int regcache_sync(struct regmap *map) { WARN_ONCE(1, "regmap API is disabled"); From patchwork Mon Nov 21 15:08:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Walle X-Patchwork-Id: 23892 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1651193wrr; Mon, 21 Nov 2022 07:19:47 -0800 (PST) X-Google-Smtp-Source: AA0mqf5PF3GZhu5+zbGWO0Gos8tzSjA1LImEqwMFGEpMxl3f00kXrdfQCrfkqhbx8wjQ3PwsC3Fo X-Received: by 2002:a17:907:7784:b0:7ad:9ad7:e882 with SMTP id ky4-20020a170907778400b007ad9ad7e882mr3076631ejc.520.1669043987378; Mon, 21 Nov 2022 07:19:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669043987; cv=none; d=google.com; s=arc-20160816; b=RBlKn0oJOi99DFBLNTMeyU4ke1pwAcypD+3/CvjtHyaJlJVhHVJw5+pnWL5Crtzbtn NUgfESVTWT/HL7NFabK8EpYc80NIaEebGnWHV83aggKgBCgVVROH/pTnVhh7FQ6bHgnm VRVDYB1ODppOtvu0P7q/0JlquNUIQfkfPYp6uS1qTjilgI+pDLEodqjs/be+oteYmSEK pGhTWxa4t8ApH2oF/0xULL1FD8YMivdwSpQonIUZUHSW/8Rsg+v+NOOi/3pVTkmF2jMP 0jdWO/H7hgkHGVSQPprMzWggZQAlWJtlLpX0pm05tU1owNh5SmERaTZiYEsribQd3iuC M9mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=leF0rqvNFin/1YVVB08bOiO69am1F2uIpeYktbX9kXM=; b=QFG8XF3c77JI8OTz2gsZI2zDLwSxN4qAHc1P2d9yM3DZoK2Frj0TC2s66rTWDXtZy9 dZVJSJYIym/M4+/876S1knFThb9FyKnwTGJdrbXi1GL1KIigGPLljSPNPLLMtXkphTik O6KUvCen23+1p4JAHIII2qdxKTetu2WBkiq4eF3uPR6OcreTIoA5mmwJtyVi9WQRIpxf lzPA2o65iI3rSrbIdkekIv1ozOH6iWc1MB7fXNEHUMJiPX1eFopAi9uEbMtM0fXDhY24 k77OCfhIh1PPYwOlyBczaV4cHIv8XgX7d0ovO/IqzH3I0nlB+8pR69ICTXQblelI6Ggs Ha6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2022082101 header.b=WLEMcral; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=walle.cc Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g10-20020a170906538a00b00782539a0286si7915198ejo.142.2022.11.21.07.19.16; Mon, 21 Nov 2022 07:19:47 -0800 (PST) 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=pass header.i=@walle.cc header.s=mail2022082101 header.b=WLEMcral; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=walle.cc Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232192AbiKUPOv (ORCPT + 99 others); Mon, 21 Nov 2022 10:14:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230396AbiKUPOJ (ORCPT ); Mon, 21 Nov 2022 10:14:09 -0500 Received: from mail.3ffe.de (0001.3ffe.de [159.69.201.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCB49CFA75; Mon, 21 Nov 2022 07:08:56 -0800 (PST) Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.3ffe.de (Postfix) with ESMTPSA id B1D1B2457; Mon, 21 Nov 2022 16:08:54 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1669043334; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=leF0rqvNFin/1YVVB08bOiO69am1F2uIpeYktbX9kXM=; b=WLEMcralFkvdQ3X3BkLNbp2YryPL/4UP92IPZzQe63g5lsLkTDdVyB/PZDU6+iX1oYE4sf BW6BPDDIMDmnXiv94s+4eWiuQfrXndaAc4zw0bxEh09RSNEZ+mg4IbCYyxYVvBkO81iKQo CavkrLVfelp58iAhn94ypzgH2cAs+Im0ldc3f14zbrlx/Xt6PGTvjJDVqTuZkqLo+y2Dbr CXH4Q40/vrQL/qVT5GrAZfPiOh0VB2z5MBfJ4nEFLD7C84jD4zZhpgMrqGKnvX/qxKD0jE 0EBkQclmUkxOczQS3T6OrQ2WxGOcG+7fYxasq30RgF52Vh3QZHUpHJq1yh+aTQ== From: Michael Walle To: Mark Brown , Greg Kroah-Hartman , "Rafael J . Wysocki" , Linus Walleij , Bartosz Golaszewski Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, William Breathitt Gray , Michael Walle Subject: [PATCH 2/2] gpio: regmap: use new regmap_might_sleep() Date: Mon, 21 Nov 2022 16:08:43 +0100 Message-Id: <20221121150843.1562603-2-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221121150843.1562603-1-michael@walle.cc> References: <20221121150843.1562603-1-michael@walle.cc> 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,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 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?1750119467666734792?= X-GMAIL-MSGID: =?utf-8?q?1750119467666734792?= Now that the regmap can be queried whether it might sleep, we can get rid of the conservative setting "can_sleep = true". New drivers which want to use gpio-regmap and can access the registers memory-mapped won't have the restriction that their consumers have to use the gpiod_*cansleep() variants anymore. Signed-off-by: Michael Walle --- drivers/gpio/gpio-regmap.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/drivers/gpio/gpio-regmap.c b/drivers/gpio/gpio-regmap.c index 6383136cbe59..16404ca6ac38 100644 --- a/drivers/gpio/gpio-regmap.c +++ b/drivers/gpio/gpio-regmap.c @@ -249,15 +249,7 @@ struct gpio_regmap *gpio_regmap_register(const struct gpio_regmap_config *config chip->ngpio = config->ngpio; chip->names = config->names; chip->label = config->label ?: dev_name(config->parent); - - /* - * If our regmap is fast_io we should probably set can_sleep to false. - * Right now, the regmap doesn't save this property, nor is there any - * access function for it. - * The only regmap type which uses fast_io is regmap-mmio. For now, - * assume a safe default of true here. - */ - chip->can_sleep = true; + chip->can_sleep = regmap_might_sleep(config->regmap); chip->get = gpio_regmap_get; if (gpio->reg_set_base && gpio->reg_clr_base)