Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1176728pxa; Thu, 13 Aug 2020 02:30:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwU4D7rKvGRU2IuHr3SUt4HAk2f4B3GCZwQ0hmNMk5NPyu8VLrXQ2uF0TdMUgB4bzw/2zjH X-Received: by 2002:a17:906:60d5:: with SMTP id f21mr3860422ejk.94.1597311029279; Thu, 13 Aug 2020 02:30:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597311029; cv=none; d=google.com; s=arc-20160816; b=ts5bxhaaR+BGsTHoT7o3Jit7lxcz9aG38xNIE8hSlCoqbcBWClLxZbXFO/yV5Se77A 7yruOQXRv26Y6qC+5XGTRq6FxsV1+fQWyVCe56GOWEQu2G+q5DzqhPDrOxMnwU9xVPt8 4SCJJ6JhJsdeL3c6QOlNihmMkh5BL7Q5w/WjD7TCZ6EH7WrEOzGEfhdq+IQ1Ne2LTphP 7hrHOo9fXlzuWFpJexBFNwfHf1FIOXzwz5OiIKRZo652ub53RSR5Zq4Ka5W052FsB3+l Q3ef47t1q+VZ1ThWjMejMLb7grMkk44zP7Dd9Mt3AIZ2XfohaSOHWaBlEv0GlOv4vrdA T7aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=c5wCQOX25aaOsWpq5c0leMLJU3ShjXx6gzZ+lkhN/m0=; b=BouI6JCbPfW+2VmtNfRqaqtKGg4UPi9/NM0300wjF7xquB7BAexozwQpdGAseP3DlS aYED4XtTmoZOjuA5YJomz3uYTEYeGvcG9XckCFIz2Mdhd0Kmt0cu9TF1/8XDu/u3uq4/ jqg9J+FzdeFlnPSy2StLniNt+kNrIZ5LX/wmhZXHcMXhs1SgdGD9Bh7D4naXrKIdxp4e kgxGoZNZ2GKDOcmzwU7H4sHsrizigBDo3a5r2vj+o8F2cs04S/DXgBoVXvkarBfss7UA QVqpFXNFgF2VRI49WHPIDa0fFn1ZMgX8Tr4yg6caVneaYkIYmRuQyAZ2SEYMdu4JS/Or 1vxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Vzk+YeoE; dkim=neutral (no key) header.i=@vger.kernel.org header.s=2020e header.b=b9PXrdqW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h12si2737109eje.650.2020.08.13.02.30.06; Thu, 13 Aug 2020 02:30:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Vzk+YeoE; dkim=neutral (no key) header.i=@vger.kernel.org header.s=2020e header.b=b9PXrdqW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726427AbgHMJ3W (ORCPT + 99 others); Thu, 13 Aug 2020 05:29:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726131AbgHMJ3W (ORCPT ); Thu, 13 Aug 2020 05:29:22 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8910BC061757; Thu, 13 Aug 2020 02:29:21 -0700 (PDT) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1597310959; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=c5wCQOX25aaOsWpq5c0leMLJU3ShjXx6gzZ+lkhN/m0=; b=Vzk+YeoEP4LH28amktQIViJ8D9qMr/DHRfX/C89rl4+p8WIQ7HxIwKIZi1GnX9ILYvvox7 ikl+xVRjiDXBraLXEcZqYAKR+G0Vpg5CBw7Iskmlslxe70tBQ+95nKOHzjvpjGFagzxS4B TFAKUTKl5Yt9PN9e0M7DLx2ak/iQoS6hrCwcMnsPeEhoLAYDEHYOYs19nZJUzAUcd+jVHG 4ypxj9WucKRV6r6CFoguKAjXQcZCZVllHyd9ZkIis4O4hUsISUcEYxXvLLW68jFPAsYpcj wjgTJ6Q5/xzow0FdoX9MRoFoxAbfh1hGMftqFhkqCGRgt8evsh/XPFeHx1slgg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1597310959; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=c5wCQOX25aaOsWpq5c0leMLJU3ShjXx6gzZ+lkhN/m0=; b=b9PXrdqWDzOqx5rZ1FfLBRohEdSAf3TXIS2lBOlq7JURbLGYkOh1eSvgitaTkmQyNf/VvX bnbJBkyqO+25WDCw== To: Maulik Shah , bjorn.andersson@linaro.org, maz@kernel.org, linus.walleij@linaro.org, swboyd@chromium.org, evgreen@chromium.org, mka@chromium.org Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-gpio@vger.kernel.org, agross@kernel.org, jason@lakedaemon.net, dianders@chromium.org, rnayak@codeaurora.org, ilina@codeaurora.org, lsrao@codeaurora.org, Maulik Shah Subject: Re: [PATCH v4 3/7] genirq: Introduce irq_suspend_one() and irq_resume_one() callbacks In-Reply-To: <1597058460-16211-4-git-send-email-mkshah@codeaurora.org> References: <1597058460-16211-1-git-send-email-mkshah@codeaurora.org> <1597058460-16211-4-git-send-email-mkshah@codeaurora.org> Date: Thu, 13 Aug 2020 11:29:18 +0200 Message-ID: <87pn7ulwr5.fsf@nanos.tec.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Maulik Shah writes: > From: Douglas Anderson > > The "struct irq_chip" has two callbacks in it: irq_suspend() and > irq_resume(). These two callbacks are interesting because sometimes > an irq chip needs to know about suspend/resume, but they are a bit > awkward because: > 1. They are called once for the whole irq_chip, not once per IRQ. > It's passed data for one of the IRQs enabled on that chip. That > means it's up to the irq_chip driver to aggregate. > 2. They are only called if you're using "generic-chip", which not > everyone is. > 3. The implementation uses syscore ops, which apparently have problems > with s2idle. The main point is that these callbacks are specific to generic chip and not used anywhere else. > Probably the old irq_suspend() and irq_resume() callbacks should be > deprecated. You need to analyze first what these callbacks actually do. :) > Let's introcuce a nicer API that works for all irq_chip devices. s/Let's intro/Intro/ Let's is pretty useless in a changelog especially if you read it some time after the patch got applied. > This will be called by the core and is called once per IRQ. The core > will call the suspend callback after doing its normal suspend > operations and the resume before its normal resume operations. Will be? You are adding the code which calls that unconditionally even. > +void suspend_one_irq(struct irq_desc *desc) > +{ > + struct irq_chip *chip = desc->irq_data.chip; > + > + if (chip->irq_suspend_one) > + chip->irq_suspend_one(&desc->irq_data); > +} > + > +void resume_one_irq(struct irq_desc *desc) > +{ > + struct irq_chip *chip = desc->irq_data.chip; > + > + if (chip->irq_resume_one) > + chip->irq_resume_one(&desc->irq_data); > +} There not much of a point to have these in chip.c. The functionality is clearly pm.c only. > static bool suspend_device_irq(struct irq_desc *desc) > { > + bool sync = false; > + > if (!desc->action || irq_desc_is_chained(desc) || > desc->no_suspend_depth) > - return false; > + goto exit; What? If no_suspend_depth is > 0 why would you try to tell the irq chip that this line needs to be suspended? If there is no action, then the interrupt line is in shut down state. What's the point of suspending it? Chained interrupts are special and you really have to think hard whether calling suspend for them unconditionally is a good idea. What if a wakeup irq is connected to this chained thing? > if (irqd_is_wakeup_set(&desc->irq_data)) { > irqd_set(&desc->irq_data, IRQD_WAKEUP_ARMED); > + > /* > * We return true here to force the caller to issue > * synchronize_irq(). We need to make sure that the > * IRQD_WAKEUP_ARMED is visible before we return from > * suspend_device_irqs(). > */ > - return true; > + sync = true; > + goto exit; So again. This interrupt is a wakeup source. What's the point of suspending it unconditionally. > } > > desc->istate |= IRQS_SUSPENDED; > @@ -95,7 +99,10 @@ static bool suspend_device_irq(struct irq_desc *desc) > */ > if (irq_desc_get_chip(desc)->flags & IRQCHIP_MASK_ON_SUSPEND) > mask_irq(desc); > - return true; > + > +exit: > + suspend_one_irq(desc); > + return sync; So what happens in this case: CPU0 CPU1 interrupt suspend_device_irq() handle() chip->suspend_one() action() ... chip->fiddle(); ???? What is the logic here and how is this going to work under all circumstances without having magic hacks in the irq chip to handle all the corner cases? This needs way more thoughts vs. the various states and sync requirements. Just adding callbacks, invoking them unconditionally, not giving any rationale how the whole thing is supposed to work and then let everyone figure out how to deal with the state and corner case handling at the irq chip driver level does not cut it, really. State handling is core functionality and if irq chip drivers have special requirements then they want to be communicated with flags and/or specialized callbacks. Thanks, tglx