Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp572882rwr; Thu, 20 Apr 2023 03:36:25 -0700 (PDT) X-Google-Smtp-Source: AKy350ZE/vjxUraB3sHEwSo1bedA0PXtSqqLx7Us+fSmVxbzB24zu//+mtTJr1MfU32E+lBTJT3y X-Received: by 2002:a05:6a00:a1f:b0:63b:8e12:7075 with SMTP id p31-20020a056a000a1f00b0063b8e127075mr858596pfh.31.1681986985246; Thu, 20 Apr 2023 03:36:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681986985; cv=none; d=google.com; s=arc-20160816; b=RMsDf+qvbo1bKj8F6G0p+VL3KYpKjjbfNunrdMX3qn3Hvl4IKqClY942/F9EJWXgyV OiAV85lFwU/cfy4xJrxKUqhTlllsJtug5py1HcpOr0C+q/vGe+adhaKd+TpBp6YRNa4a eHa4N3wVhEhBq3M6f3T7gnNwJkrFFBec2ckq0LeZBxZ1K3solBjgxJC90sLnwXAOwbs3 VKthSk9nJoXtdFn2KqLhPh+w/PgsDKXzOSNTgejKD5CmCrHlnnduaC83h9BcvON/3j84 vfNiJJUyYZQ5t9oR8lnzux33Ckw4QCWwnGUJLggxuP3L6hDvjBsqHFdOY9O//OI2VpDI m0wA== 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=dWVXBwnoqvgJfEhpNh6vgqWzsf/b29d9lPg1AMtFby4=; b=I2MaUWJHQmoK38Qx5lpqLTjNUQj5t5cRJgzHIWZW+Fim84084CvMM4cjAfDCmN1GT7 V0/28rNt9sKVp0oXIjA6mnC91FRAMuGC00qiXsKbf3lZ4vb9zpF6cqNW2LdohVN7U1s6 PdVipH7nN+h332/nKHJfYaLitITBU2XYnKoCFHS4KbIYF3FhOj6ATcwK37VRLdT0/bc8 fmLFbknYM6c0bj1PRdiKcM64TPYa6BwqOnFwKhLDSFgIO5XGZVz0Y33IN1o3r7Mp/F6r Kvbijhujgns5IwG2Frot+AO7kZ1QU7tecm88KmWflMUTygIEEsu9PhrQqrsxejNgteOu xScQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mechatrax-com.20221208.gappssmtp.com header.s=20221208 header.b=0Ldix0ZD; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g30-20020aa79f1e000000b0063c2972543esi1269417pfr.335.2023.04.20.03.36.11; Thu, 20 Apr 2023 03:36:25 -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=pass header.i=@mechatrax-com.20221208.gappssmtp.com header.s=20221208 header.b=0Ldix0ZD; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234826AbjDTK3X (ORCPT + 99 others); Thu, 20 Apr 2023 06:29:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234446AbjDTK2X (ORCPT ); Thu, 20 Apr 2023 06:28:23 -0400 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CC2665B2 for ; Thu, 20 Apr 2023 03:26:44 -0700 (PDT) Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-63b67a26069so1171766b3a.0 for ; Thu, 20 Apr 2023 03:26:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mechatrax-com.20221208.gappssmtp.com; s=20221208; t=1681986403; x=1684578403; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=dWVXBwnoqvgJfEhpNh6vgqWzsf/b29d9lPg1AMtFby4=; b=0Ldix0ZDVzYJrbeCAjwJZzEkhXWtEH7GpGFVHQfUKuNhO83d8Xa+bM5ZBw9e3VP4dw l6IUXXpwR8ntNlDisrKqIJRL7BjZUFTjcD5hCieKSy5bVY+BWcqt7QDlxq/2Ov5EmUXa Oy14SgOjQ6/nBITaz4mKGkfj1eVroZbdJWitIW+kqt5s3aUnH4Kff0mCR389fadYRDmx ErrBdTNjylFMIkwiSeGOU2pmlc+7F+1IFRjyWQvHddK49FVPdD9XuXTI7YkKNuYFiUQM 32Im2wiLxQvFysNMyx45PWEGOfOidyVe+MO91zcK0yY7BTEpnZOqwYSD4sRBU4AK/0au uEWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681986403; x=1684578403; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=dWVXBwnoqvgJfEhpNh6vgqWzsf/b29d9lPg1AMtFby4=; b=Pq5p6EWSvMweHKVA+/MrBTvrC7r3BIBh+tioGRrYtd6vYnuxKfhG2ycduAQBfkfwse jhT2ea6u7X06DL2fc+BpJ+2CrUvqQ/7CSXLZbl+zFEWqsuIer4RpATs301N3USryfsSO kxe/c0QPLxpH9r+x6p/9x+PbBODxFzzlM8pwB3MtBbNUIc/orNj8P6E48qqUDifR+3p6 Ud5yLV7SlVRz1UP6qqlWCFWa0fxYGnKMKS8z87nhcS7AHryrUXn3Wx9ghnY3HgUReFet t9J06ES6sFLO6RhxrakNxc/hYgEa63K/meg9CU/INTpJiyQ+Ask+CY2g1rADY46oPZwG N09A== X-Gm-Message-State: AAQBX9fmg2R3MjjHpFjeOZgJ/sa3+0xYJ8mP5Vi8eYldy4mpTSrj9dlS T5ZqhddGr2xfKvnZsRBte82TodMyn/oKbWiWcxxt1Q== X-Received: by 2002:a05:6a00:2ea6:b0:639:435:1373 with SMTP id fd38-20020a056a002ea600b0063904351373mr1061703pfb.10.1681986402831; Thu, 20 Apr 2023 03:26:42 -0700 (PDT) Received: from localhost ([2400:4152:be0:9900:c85:722a:b341:5e3]) by smtp.gmail.com with UTF8SMTPSA id m11-20020a63580b000000b0051322a5aa64sm866818pgb.3.2023.04.20.03.26.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 20 Apr 2023 03:26:42 -0700 (PDT) From: Masahiro Honda To: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Masahiro Honda Subject: [PATCH v3] Fix IRQ issue by setting IRQ_DISABLE_UNLAZY flag Date: Thu, 20 Apr 2023 19:23:16 +0900 Message-Id: <20230420102316.757-1-honda@mechatrax.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 The Sigma-Delta ADCs supported by this driver can use SDO as an interrupt line to indicate the completion of a conversion. However, some devices cannot properly detect the completion of a conversion by an interrupt. This is for the reason mentioned in the following commit. commit e9849777d0e2 ("genirq: Add flag to force mask in disable_irq[_nosync]()") A read operation is performed by an extra interrupt before the completion of a conversion. This patch fixes the issue by setting IRQ_DISABLE_UNLAZY flag. Signed-off-by: Masahiro Honda --- v3: - Remove the Kconfig option. v2: https://lore.kernel.org/linux-iio/20230414102744.150-1-honda@mechatrax.com/ - Rework commit message. - Add a new entry in the Kconfig. - Call irq_clear_status_flags(irq, IRQ_DISABLE_UNLAZY) when freeing the IRQ. v1: https://lore.kernel.org/linux-iio/20230306044737.862-1-honda@mechatrax.com/ drivers/iio/adc/ad_sigma_delta.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/drivers/iio/adc/ad_sigma_delta.c b/drivers/iio/adc/ad_sigma_delta.c index d8570f620..215ecbedb 100644 --- a/drivers/iio/adc/ad_sigma_delta.c +++ b/drivers/iio/adc/ad_sigma_delta.c @@ -565,6 +565,14 @@ int ad_sd_validate_trigger(struct iio_dev *indio_dev, struct iio_trigger *trig) } EXPORT_SYMBOL_NS_GPL(ad_sd_validate_trigger, IIO_AD_SIGMA_DELTA); +static void ad_sd_free_irq(void *sd) +{ + struct ad_sigma_delta *sigma_delta = sd; + + irq_clear_status_flags(sigma_delta->spi->irq, IRQ_DISABLE_UNLAZY); + free_irq(sigma_delta->spi->irq, sigma_delta); +} + static int devm_ad_sd_probe_trigger(struct device *dev, struct iio_dev *indio_dev) { struct ad_sigma_delta *sigma_delta = iio_device_get_drvdata(indio_dev); @@ -584,11 +592,18 @@ static int devm_ad_sd_probe_trigger(struct device *dev, struct iio_dev *indio_de init_completion(&sigma_delta->completion); sigma_delta->irq_dis = true; - ret = devm_request_irq(dev, sigma_delta->spi->irq, - ad_sd_data_rdy_trig_poll, - sigma_delta->info->irq_flags | IRQF_NO_AUTOEN, - indio_dev->name, - sigma_delta); + irq_set_status_flags(sigma_delta->spi->irq, IRQ_DISABLE_UNLAZY); + ret = request_irq(sigma_delta->spi->irq, + ad_sd_data_rdy_trig_poll, + sigma_delta->info->irq_flags | IRQF_NO_AUTOEN, + indio_dev->name, + sigma_delta); + if (ret) { + irq_clear_status_flags(sigma_delta->spi->irq, IRQ_DISABLE_UNLAZY); + return ret; + } + + ret = devm_add_action_or_reset(dev, ad_sd_free_irq, sigma_delta); if (ret) return ret; -- 2.34.1