From patchwork Thu Apr 20 10:23:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Masahiro Honda X-Patchwork-Id: 13218441 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 D1AE3C77B78 for ; Thu, 20 Apr 2023 10:29:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234804AbjDTK30 (ORCPT ); Thu, 20 Apr 2023 06:29:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234776AbjDTK2Z (ORCPT ); Thu, 20 Apr 2023 06:28:25 -0400 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4EB7B5FDC for ; Thu, 20 Apr 2023 03:26:45 -0700 (PDT) Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-63b67a26069so1171767b3a.0 for ; Thu, 20 Apr 2023 03:26:45 -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=lgPLp9K//9TKwNhiuCH1KwwcphLURcxqNhX/A6OOTu/KLTqeWp8U57lGp34XaGKCbi 1j+TfI0uK66u55WS3hbcpOfhA51/bc0DdKTRsoDKW7xTQSEQcvvWC2cmIRyyryaLwlTC xPjxBW8bUqpxM9eACBBXV1VWToH6fjOTDOirxhD/rMJn4PG9pXilkzK+0tUYAHiP6/Kj cK+VFA3UsN325f3o+AK7prHhGbaowXDPffyo+tqboNmHe9HNOH042q33yDV5Sq0H75nX IgTYfl01RrclSHmwTiDJ6R3GJXbOqkPcwyanY2JiJf/nMKk3QJHAx+m9f7ggbsQvARXr geCA== X-Gm-Message-State: AAQBX9fZSh41JKZkGm1e9bpreEEJxMMik2J06J4gmYWzCzV+DGUFfkoQ de9RWAUDuA+qnVnC+5TDSwOGRg== X-Google-Smtp-Source: AKy350YlQ8URYw5pfPw41j2TebmTXO1VDvHzF/Bl7v6qnnqgyk3Ds35wW+w+P5P7iuM9LmY2dGeZfQ== 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 Precedence: bulk List-ID: X-Mailing-List: linux-iio@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 Reviewed-by: Nuno Sá 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;