Received: by 2002:ab2:3319:0:b0:1ef:7a0f:c32d with SMTP id i25csp858008lqc; Fri, 8 Mar 2024 13:58:36 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXiD0juDkuyGLfxccmDvqMRHp+/A+mJl8CJuzVihsuXqspOZryeUVGzBcsjpGBZOA61fdioQA+BtqbzwmNt/DAZfTVjtR8zhJm2DFFymw== X-Google-Smtp-Source: AGHT+IGPacygJ0GrwAsniFGUbnEL67OvXBT6B55BYd0n3hW9RMm8/53vPI18HeAtzfq5vGNbPvo9 X-Received: by 2002:a05:620a:44d6:b0:788:488f:59d4 with SMTP id y22-20020a05620a44d600b00788488f59d4mr434752qkp.61.1709935116684; Fri, 08 Mar 2024 13:58:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709935116; cv=pass; d=google.com; s=arc-20160816; b=sZggHkzxIAWY+/Np92nBjcECpjtvGpamg/yfGmgYGyqGTTZSg5vqTZHCSl7dR9Zv6t UohOJVbg1PYILRQOFeaO4lUyvOKHVGB3AbDKV4kjnjCeL57Gms06yOukz89iYAqTzh2W moCJDKcL2QYuYNtQUxH5nnCELBLyxgtQh2fqFYi8xahDQCAYpJuJXGO2GJoCVHgdgB1S n6Qef4E1fDjU/Iyngyy/oYYK+9KfgXZBsx4l2ff2+bObWUVyVzM9A39lcfdyR046esWy ypyXxbgIyyMK4PEIEGqE47LnXm1eqMNxT3OftPY7tLRRkcoxUmqME8JzJzN+3hEQZD1+ VZ3w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:references :in-reply-to:subject:cc:to:from; bh=ssskNoWRSgCf0JIsEmdc/9vm6xbNQG/h290+Hjyy4Ms=; fh=hwWs5tNUdnL8e+4hhg0JbPNDxgEBT+HL1LuJugcRus4=; b=j2LFZK5voTPqobOhN+FQRBU35c9IS5QoYXUOZ49Te7eZL3VMFQEyIorRV+xIbWlC8/ yPO/bxOJWNJF8/D9NjxxsjKWtub/M+4Cm/xL1nmDptqxj2uOhP3jewPC3cuMwgdt07YI nEAJCfaIa2UymybKoQDspaGuAN7eUcKh6GfezcZHUDp/aDB2DiCeE97hlaAsReU4le+9 58QoV8GGDqnNXe9cdzSBGTz22XMOGOl4XvuqGCWt8UWHgUnqJ/d1apvkPoTpLUp2BFyP xodmZbEi2QwgL/cfO3Tb7ZRMSNChPlcbQdmynOlLO9GrhWhcx5oZKytmXD9vzTwrakYy Ifkw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=baylibre.com); spf=pass (google.com: domain of linux-kernel+bounces-97618-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-97618-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id yf2-20020a05620a3bc200b00788205afcfesi348684qkn.661.2024.03.08.13.58.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 13:58:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-97618-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=baylibre.com); spf=pass (google.com: domain of linux-kernel+bounces-97618-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-97618-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 5ADB71C20F21 for ; Fri, 8 Mar 2024 21:58:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D03D05FB9E; Fri, 8 Mar 2024 21:58:29 +0000 (UTC) Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) (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 9053F5EE96 for ; Fri, 8 Mar 2024 21:58:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709935109; cv=none; b=h2WIfIxyIXS/tXRwuBeVFpLIfE/mlEVyovbgeyR+cgayae3H+ljkGgQU3UF4z8JQlRcqusWo6FQQGQHKm++dHOo5pBsPHsDT1UswfdkJui3ojLZrHG9mDI/vWh//zaTWxkfNvhvrwylsw0oZac1uzQLwUCNu69QYoDFFg31Svzo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709935109; c=relaxed/simple; bh=jdRp3ycnJ2inLRjB5QbGRF0M5UnIWgjy+M+stLJdElI=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=IcMXtrrHX6qJOiC2oDF0X4CAzAYW/kZD7TTd3RwmGyBByz8RwB2IQnwIvyppxSE/Khfi8N35D0S/UksHV1dnb/c/RJh49CNkVYKk1qmaf8Io15WE/WFL/Lxy/c4c0au0xr2l4Q23Xuker7cwCbJj+7iCCUmoc1ABtcT6uFUCEts= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=baylibre.com; arc=none smtp.client-ip=209.85.210.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Received: by mail-pf1-f182.google.com with SMTP id d2e1a72fcca58-6e61851dbaeso1649847b3a.2 for ; Fri, 08 Mar 2024 13:58:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709935107; x=1710539907; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ssskNoWRSgCf0JIsEmdc/9vm6xbNQG/h290+Hjyy4Ms=; b=CWR4INm4s8NSNvjIVc5EohvkrEqThODQRQdTAfO2KCa3JstOM7NQb3R0nZBAcddM8z CX/ODtWZqcWd6XuLVRY6CLBO3ocxon6rp99u7ovksFVKC4kB2fKT13RUgAMPt32foOWv dNwpb0Tmzd40ThmcxXhY3bW6mEl7s0h/daH71lAdJD7b6o5AlFeLBnW3d/GAqeuXqzkZ 9HAHzwN8Fvg2cEk6PLtqdxmB1kFz+nCRXDjmvS9xc/z4WwKNPjd2IJQqkkqVxIgC6oXI vKFr8H8vl5KyKroETlEyoM7bWyTf1ALENhMwhyzQKC6kB/u+W8/dD3Z6bcksEftQYqog xDzw== X-Forwarded-Encrypted: i=1; AJvYcCWEytTrPoL0sXKDJYCtxXlKkNqMVD5VzIZLej8IWWMePMRsGi7NXL3OsUZFRC2sAL7/5J+4Dig8lQBljpD08zuY5qnTcTeXFRk84egn X-Gm-Message-State: AOJu0YyER9DJwHuNhQq0QreiouWLm/x+2EW9ZeVpjiDt4S5CSl/pBSHg OhjhP8ueKDma/mzQi5icWxiBrdK4Fqa5X5rRdWw/eKnPFSr+7TqJ1TJD1QCl/Qo= X-Received: by 2002:a05:6a20:1454:b0:1a0:e944:15b7 with SMTP id a20-20020a056a20145400b001a0e94415b7mr357270pzi.5.1709935106742; Fri, 08 Mar 2024 13:58:26 -0800 (PST) Received: from localhost (71-212-63-227.tukw.qwest.net. [71.212.63.227]) by smtp.gmail.com with ESMTPSA id g19-20020a631113000000b005cd8044c6fesm167442pgl.23.2024.03.08.13.58.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 13:58:26 -0800 (PST) From: Kevin Hilman To: =?utf-8?Q?Th=C3=A9o?= Lebrun , Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Roger Quadros , Peter Chen , Pawel Laszczak , Nishanth Menon , Vignesh Raghavendra , Tero Kristo Cc: Thomas Petazzoni , =?utf-8?Q?Gr=C3=A9gor?= =?utf-8?Q?y?= Clement , Alan Stern , linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, =?utf-8?Q?Th=C3=A9o?= Lebrun Subject: Re: [PATCH v4 4/9] usb: cdns3-ti: support reset-on-resume behavior In-Reply-To: <20240307-j7200-usb-suspend-v4-4-5ec7615431f3@bootlin.com> References: <20240307-j7200-usb-suspend-v4-0-5ec7615431f3@bootlin.com> <20240307-j7200-usb-suspend-v4-4-5ec7615431f3@bootlin.com> Date: Fri, 08 Mar 2024 13:58:25 -0800 Message-ID: <7h4jdgperi.fsf@baylibre.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Th=C3=A9o Lebrun writes: > Add match data support, with one boolean to indicate whether the > hardware resets after a system-wide suspend. If hardware resets, we > force execute ->runtime_resume() at system-wide resume to run the > hardware init sequence. Is "whether the hardware resets after a system-wide suspend" really a function of the IP itself, or rather whether the IP is in a power domain that might power down? > No compatible exploits this functionality, just yet. > > Signed-off-by: Th=C3=A9o Lebrun > --- > drivers/usb/cdns3/cdns3-ti.c | 27 +++++++++++++++++++++++++++ > 1 file changed, 27 insertions(+) > > diff --git a/drivers/usb/cdns3/cdns3-ti.c b/drivers/usb/cdns3/cdns3-ti.c > index 4c8a557e6a6f..f76327566798 100644 > --- a/drivers/usb/cdns3/cdns3-ti.c > +++ b/drivers/usb/cdns3/cdns3-ti.c > @@ -57,9 +57,14 @@ struct cdns_ti { > unsigned vbus_divider:1; > struct clk *usb2_refclk; > struct clk *lpm_clk; > + const struct cdns_ti_match_data *match_data; > int usb2_refclk_rate_code; > }; >=20=20 > +struct cdns_ti_match_data { > + bool reset_on_resume; > +}; > + > static const int cdns_ti_rate_table[] =3D { /* in KHZ */ > 9600, > 10000, > @@ -101,6 +106,7 @@ static int cdns_ti_probe(struct platform_device *pdev) > platform_set_drvdata(pdev, data); >=20=20 > data->dev =3D dev; > + data->match_data =3D device_get_match_data(dev); >=20=20 > data->usbss =3D devm_platform_ioremap_resource(pdev, 0); > if (IS_ERR(data->usbss)) { > @@ -220,8 +226,29 @@ static int cdns_ti_runtime_resume(struct device *dev) > return 0; > } >=20=20 > +static int cdns_ti_suspend(struct device *dev) > +{ > + struct cdns_ti *data =3D dev_get_drvdata(dev); > + > + if (data->match_data && data->match_data->reset_on_resume) > + return pm_runtime_force_suspend(dev); > + else > + return 0; > +} > + > +static int cdns_ti_resume(struct device *dev) > +{ > + struct cdns_ti *data =3D dev_get_drvdata(dev); > + > + if (data->match_data && data->match_data->reset_on_resume) > + return pm_runtime_force_resume(dev); > + else > + return 0; > +} Conditionally forcing runtime suspend/resume based on a property of the IP doesn't feel right to me. IMO, the device should always runtime suspend/resume, and in the runtime PM hooks is where the conditional logic should be. And speaking of the conditional logic... let's go back to whether "resets_on_resume" is a property of the IP or the enclosing power domain. Instead of having an IP-specific flag, another way of approaching this when ->runtime_resume() is called every time is simply for that hook to check if a reset has happend. Sometimes you can tell this simply by reading a register that has been previously programmed by the driver but has a known reset. Simply check that regisister and you can tell whether context has been lost. Doing it this way makes the driver "smart" and then you don't have to rely on bool flag based on the IP and dependent on the DT compatible. Kevin