Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp1083363rdb; Fri, 22 Dec 2023 14:21:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IH4lrSlwAwWvOAYMa9ne7RoO9RqeJ18fmN6V1Jdjotjsil8m8cZJ6nOC6f3dcAswLo9cC+u X-Received: by 2002:a05:6e02:144d:b0:35f:ea50:77a5 with SMTP id p13-20020a056e02144d00b0035fea5077a5mr299234ilo.49.1703283714109; Fri, 22 Dec 2023 14:21:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703283714; cv=none; d=google.com; s=arc-20160816; b=ygK78J9zW/8HWghKrPKdKo5RFrmPPr/n/dA/m2CXcAxawtnbL29mriTiHxxDClW2Am CZ8X4WqT7unkM+i5HMe45VOuFWLKXpheSmjGFXa2jv0L1QHzpez020yQ6lRlzklBNE8v 9Odoze1CrHGxSMYcKBJqJ5NhrNYnNEWHZxq/TZGr8uC8ISURlOTPWfnsCQ5xuo1MVZxJ UPO2hh8wZAdThZVoCH26KxOwgy4rVDnKlnptAkc+EYOxDX/WZd0lTWcT1sPm3LyeWhxe B7O4zkfrihNGW6mXJ4M17E8ojJ2xzYrJOf6Dfp18vGtgboS6AAzI2YXwJlPX+KiU3l5g s0kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=G4TYuyMVVFBv/5d5uEIDyQ93KWASjprBwJ7UzWDp5l4=; fh=RjkR7o+hGwcJxNUrLmUdlniFf3Oykdl8M4JNtL4Ov0c=; b=GKySRWWdbK71kMiqy/uckYMkhR/D6T+cJpMFNEaDFhlvh356hPiBSkAwxIXUHBdblt faFQr9SGG8S+IkU/5nXQbl9FtWkydcYmmHVD50RChayzyqT6fgMdNxEij8jevF4vv1KG hTi/QnkDDcrXqzrVCPTvUFEL8OHhbiHoGI/D9zg2n+m0oshyt8TbYLoplflA4jlLn6Vx vwg8Gmz9EecJExULr5X2b30hIgYf4Qccz6VyQKn3FAr9bAwOJ0EBzFNpDDEOQ/LFXNaD CitvNZHjB4HSyqp+k02SaXAfNl0AY4pV/WMztbzxSbfhJoZPeBZ51FMO8foJi4aEOOX6 zraQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=iMQn1FTr; spf=pass (google.com: domain of linux-kernel+bounces-10078-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10078-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 6-20020a170902c14600b001cfa7f91403si3716272plj.183.2023.12.22.14.21.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Dec 2023 14:21:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-10078-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=iMQn1FTr; spf=pass (google.com: domain of linux-kernel+bounces-10078-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10078-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 33B8C2866B5 for ; Fri, 22 Dec 2023 22:21:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B5A992F845; Fri, 22 Dec 2023 22:21:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="iMQn1FTr" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-yw1-f174.google.com (mail-yw1-f174.google.com [209.85.128.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 98BCE2EB0E for ; Fri, 22 Dec 2023 22:21:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-yw1-f174.google.com with SMTP id 00721157ae682-5d2d0661a8dso24004727b3.2 for ; Fri, 22 Dec 2023 14:21:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1703283705; x=1703888505; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=G4TYuyMVVFBv/5d5uEIDyQ93KWASjprBwJ7UzWDp5l4=; b=iMQn1FTr2YSiJYso89napnpPHsKTiQnHB1W8eKQeAGyYH6SwBgz0xzI2kX99+oMRT0 NQTzom2u71UD78ujsHdADD+2nzRlfej0ywE1S7py/kq7dVBL/cfZvG2BMFKw3yzM8w8Q f9cowlIedk6HgafHxt+3tLnqaRQfE79M8iPrA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703283705; x=1703888505; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=G4TYuyMVVFBv/5d5uEIDyQ93KWASjprBwJ7UzWDp5l4=; b=cBfh0WDXcq9ibG2XNXXdl6/wxVqYxY75McNDYt7ShH+NChrOHjZ7FMf5pyWqX/vEmn 0kJ4Cj+cqaUIQOdTk+/81yRszavnB4gxJf3tt8wPk75IrAZSEvNYY9EcCDOcxJI7X1Lu NUl0oOTbbgbeJwqL8xkwopPGW5DRiZaYiII0s9aj3Ab9jPwD3umPjXufs332BdTZNRAs qhnI7FQiVrp4aZ3+YL97RTpk75OOHFKIFG/zm8I/eevALvCz9jEGBkTJGwWGBcw787eQ MQvQVl4hj9gQyNpDf4vYZ/adKhI8c+D8BoZqtAgGMojDLz5cjSO5WfGv5Ybso5CDNwrm x1pA== X-Gm-Message-State: AOJu0Yz124ldHd8XX3+N8Tcq3aF6NnQr7qNihnKsn9E5naGjTGUYlto+ 6q9OSpRS8VnwXbW7boEgRrcfmzY+5MjhdBl1IA6Q2bgC548r X-Received: by 2002:a0d:c383:0:b0:5d8:e267:78e5 with SMTP id f125-20020a0dc383000000b005d8e26778e5mr2182094ywd.61.1703283705579; Fri, 22 Dec 2023 14:21:45 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231220235459.2965548-1-markhas@chromium.org> <20231220165423.v2.22.Ieee574a0e94fbaae01fd6883ffe2ceeb98d7df28@changeid> In-Reply-To: From: Mark Hasemeyer Date: Fri, 22 Dec 2023 15:21:34 -0700 Message-ID: Subject: Re: [PATCH v2 22/22] platform/chrome: cros_ec: Use PM subsystem to manage wakeirq To: Andy Shevchenko Cc: LKML , AngeloGioacchino Del Regno , Krzysztof Kozlowski , Tzung-Bi Shih , Raul Rangel , Konrad Dybcio , Rob Herring , Sudeep Holla , Benson Leung , Bhanu Prakash Maiya , Chen-Yu Tsai , Guenter Roeck , Lee Jones , Prashant Malani , Rob Barnes , Stephen Boyd , chrome-platform@lists.linux.dev Content-Type: text/plain; charset="UTF-8" > > + irq = platform_get_irq_resource_optional(pdev, 0, &irqres); > > + if (irq > 0) { > > ec_dev->irq = irq; > > - else if (irq != -ENXIO) { > > + if (cros_ec_should_force_irq_wake_capable()) > > + irq_wake = true; > > + else > > + irq_wake = irqres.flags & IORESOURCE_IRQ_WAKECAPABLE; > > + dev_dbg(dev, "IRQ: %i, wake_capable: %i\n", irq, irq_wake); > > + } else if (irq != -ENXIO) { > > dev_err(dev, "couldn't retrieve IRQ number (%d)\n", irq); > > return irq; > > } > > Yeah, this is confusing now. Which one should I trust more: irq or irqres.start? > What is the point to have irqres with this duplication? irqres is needed to pull the wake capability of the irq. I agree tha irq and irqres.start should have the same information. I chose irq because it's more obvious what it represents over irqres.start. It's also more concise. > > ... > > > - dev_err(dev, "couldn't register ec_dev (%d)\n", ret); > > + dev_err_probe(dev, ret, "couldn't register ec_dev (%d)\n", ret); > > return ret; > > return dev_err_probe(...); > > ... > > > + dev_err_probe(dev, ret, "Failed to init device for wakeup"); > > + return ret; > Tzung-Bi pointed out there are other areas of the driver that just use dev_err() in the probe path. My vote is to drop the use of dev_err_probe() to stay consistent with what exists. A separate patch can be sent to modify the statements to use the dev_err_probe() variant. > > ... > > > + if (!np) > > + return; > > Why do you need this now? It felt intuitive to return early from cros_ec_spi_dt_probe() if no device node exists. This does not fix any known bugs though. Dropping as irrelevant. > > ret = of_property_read_u32(np, "google,cros-ec-spi-msg-delay", &val); > > if (!ret) > > ec_spi->end_of_msg_delay = val; > > > + if (ec_dev->irq > 0 && of_property_read_bool(np, "wakeup-source")) { > > + ec_spi->irq_wake = true; > > + dev_dbg(&spi->dev, "IRQ: %i, wake_capable: %i\n", ec_dev->irq, ec_spi->irq_wake); > > + } > > if (ret) > return; > > ec_spi->irq_wake = of_property_read_bool(np, "wakeup-source")); The other interface drivers only analyze irq_wake if an irq exists. I think that makes sense and would like to stay consistent. Thinking: ec_spi->irq_wake = spi->irq > 0 && of_property_read_bool(np, "wakeup-source")); > dev_dbg(&spi->dev, "IRQ: %i, wake_capable: %s\n", ec_dev->irq, str_yes_no(ec_spi->irq_wake)); > ... > > > @@ -78,6 +80,7 @@ struct cros_ec_uart { > > u32 baudrate; > > u8 flowcontrol; > > u32 irq; > > + bool irq_wake; > > struct response_info response; > > }; > > Run `pahole` and amend respectively to avoid wasting memory. No savings to be had, but we can defrag the holes from sizes 3 and 3, to 2 and 4 by moving irq_wake above irq. pahole --reorganize -C cros_ec_uart cros_ec_uart.o struct cros_ec_uart { struct serdev_device * serdev; /* 0 8 */ u32 baudrate; /* 8 4 */ u8 flowcontrol; /* 12 1 */ bool irq_wake; /* 13 1 */ /* XXX 2 bytes hole, try to pack */ u32 irq; /* 16 4 */ /* XXX 4 bytes hole, try to pack */ struct response_info response; /* 24 64 */ /* size: 88, cachelines: 2, members: 6 */ /* sum members: 82, holes: 2, sum holes: 6 */ /* last cacheline: 24 bytes */ }; > > + dev_dbg(dev, "IRQ: %i, wake_capable: %i\n", ec_uart->irq, ec_uart->irq_wake); > > str_yes_no() from string_choices.h? SGTM