Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp546094pxb; Thu, 21 Oct 2021 04:58:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxPmegUurs0sAKrSzd02YFtW94eFsAH8DmaAK7ZKeMNATaDDHKRwPeHp8LjgmXT7g5cIA3o X-Received: by 2002:a05:6a00:a96:b0:44d:a0d5:411f with SMTP id b22-20020a056a000a9600b0044da0d5411fmr5551647pfl.65.1634817510398; Thu, 21 Oct 2021 04:58:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634817510; cv=none; d=google.com; s=arc-20160816; b=mVn5F46AfeeP27DEAIMex6EFTIa/ofDR6J0JVUyHfaIlEJi+9Wi3i+xXSfno2RsIuU XuivaRv2JmxQudU3EB9awet8gt0oL3b4A1b9k5y9U6Lq9aQTe0ScgoCc0H3hniM/Ti3v gTaIwdfd7qCgn6c7xGIc/oaogXuKqA3hZe6qzsqGlmDg09qQ3Ego54BlGze8iTspXTPq yOC0u8vUTOr+nnfUvqBxQVQxg8z5WJ9sUHaTwtskF/0qjUb1aQyP+qBrz5jZIoed1OZk m+XgcR/Tdav4FDXR9jawodAV7ptUENOlycZCgzE6POFBvwoGvL+0koUIsqIWtipxTtKJ tfuw== 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=V1jEJHNy1rpIMC1prko3vAzn6yRQlR45J0vSd88M0Wc=; b=WrObijSStBd414C1YWrc5T2TGz9MNgsRkwWL6WYvQTfaFcYJ0KUm3orUJmcbatdiTY C+ibPW6aei1IxFUz67vTm4yqx73fBnUd0H0l4M7ndwJ56IQmwtsrUZW3umnLtLnjo6Fm CfYdSozXSiTJj2WNpZmk/SKIujDh7/stepCs5EnFH0/Tq+L8EmjfmSDvSWt+Tges93ni LklK/r688rmJ8skorIATeQhE7ltfAYBW1qv7xALHicRvJMoA49BUBNEFV/Izp+MUtWuk pJaLMarbbHi0gw8C1IQwSJ3RNiLtFT9Tp6/Illfup3jFXCkVEYhGwfGZ6MJWfuW/wej1 5jmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=XOMAHUJx; 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=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l189si2203835pgd.487.2021.10.21.04.58.14; Thu, 21 Oct 2021 04:58:30 -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=@gmail.com header.s=20210112 header.b=XOMAHUJx; 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=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231156AbhJUL5v (ORCPT + 99 others); Thu, 21 Oct 2021 07:57:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230523AbhJUL5s (ORCPT ); Thu, 21 Oct 2021 07:57:48 -0400 Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4563EC06161C; Thu, 21 Oct 2021 04:55:32 -0700 (PDT) Received: by mail-lf1-x132.google.com with SMTP id g36so276740lfv.3; Thu, 21 Oct 2021 04:55:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=V1jEJHNy1rpIMC1prko3vAzn6yRQlR45J0vSd88M0Wc=; b=XOMAHUJx0i/12kKJAXzxVziVwGKqGOSnAI1TsCe02UCieVeT5TKeDLmXlDLyDxpPdH SKeavDKLW8GV/KarRKogZt01hDZtJVr+ejkVRSCu+6iaDB4g8xLkW6ZVFM/DcDwO/J88 WF2swpt7wLMziMbmB7NWpZvLgF3B+VDLcryOF6y5C019tMAI0P5bO7fKHwOytCZRivIy KJEkIeEwEjhufc6CwZEImW8gHgCgoMJ2fFE7Dgh58Nl8A8/MxNzSW21/Taho0QyVHcJZ K7zXlx5fYU9CBej/2QANlERqlDsUbcxt7bciF+I0GeV/Xt5SBWMOWvXZPnd4va5C7+/c qs4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=V1jEJHNy1rpIMC1prko3vAzn6yRQlR45J0vSd88M0Wc=; b=fmODIC4sIeGgfdmfVm+ewCLa0ujeEkiA+9MSDecxVXjhJciAe5DBalqdJ1MWfsPcQA Tof3xKPAVLVB/VTo9XhxeAAb1HVFjF1YaLiowTcJsC0A2iU8q9WayVg3+TBCmvbTFs0r XrYoJy44lQdHEAVGJDSuad26KkR2OG0HsdPfknTRLkq9F21MsewbLLlmG7MjmIGswtYH KB1mmCdH8BxSaWYrbgYQV+Ov11k2bzhqD9AgkV5jyJ/1vLGh81scBhlGbFIpw1xq3Aje jlHN84QqsmUKfqCo0ztaMeMGnnv3GAZWolm/fnUVHF6d8bVdrfP2H9a3HgWQGiNuvZiH H24w== X-Gm-Message-State: AOAM532fK6WGR0XqZrW+Dl4cA3XT2J0LvY++EzXrI8BM6u8QtEd2aPb5 vZN/Ej1BURcCTIWM/19Dbz5NHuKNCf0= X-Received: by 2002:ac2:5f06:: with SMTP id 6mr5065587lfq.516.1634817330659; Thu, 21 Oct 2021 04:55:30 -0700 (PDT) Received: from localhost.localdomain (94-29-39-10.dynamic.spd-mgts.ru. [94.29.39.10]) by smtp.gmail.com with ESMTPSA id b30sm440565lfv.288.2021.10.21.04.55.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Oct 2021 04:55:30 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Greg Kroah-Hartman , Mathias Nyman , JC Kuo , Nicolas Chauvet Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org Subject: [PATCH v1] usb: xhci: tegra: Check padctrl interrupt presence in device tree Date: Thu, 21 Oct 2021 14:55:01 +0300 Message-Id: <20211021115501.14932-1-digetx@gmail.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Older device-trees don't specify padctrl interrupt and xhci-tegra driver now fails to probe with -EINVAL using those device-trees. Check interrupt presence and disallow runtime PM suspension if it's missing to fix the trouble. Fixes: 971ee247060d ("usb: xhci: tegra: Enable ELPG for runtime/system PM") Reported-by: Nicolas Chauvet Tested-by: Nicolas Chauvet Signed-off-by: Dmitry Osipenko --- drivers/usb/host/xhci-tegra.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c index 1bf494b649bd..47927a1df3dc 100644 --- a/drivers/usb/host/xhci-tegra.c +++ b/drivers/usb/host/xhci-tegra.c @@ -1454,10 +1454,13 @@ static int tegra_xusb_probe(struct platform_device *pdev) goto put_padctl; } - tegra->padctl_irq = of_irq_get(np, 0); - if (tegra->padctl_irq <= 0) { - err = (tegra->padctl_irq == 0) ? -ENODEV : tegra->padctl_irq; - goto put_padctl; + /* Older device-trees don't specify padctrl interrupt */ + if (of_property_read_bool(np, "interrupts")) { + tegra->padctl_irq = of_irq_get(np, 0); + if (tegra->padctl_irq <= 0) { + err = (tegra->padctl_irq == 0) ? -ENODEV : tegra->padctl_irq; + goto put_padctl; + } } tegra->host_clk = devm_clk_get(&pdev->dev, "xusb_host"); @@ -1696,11 +1699,15 @@ static int tegra_xusb_probe(struct platform_device *pdev) goto remove_usb3; } - err = devm_request_threaded_irq(&pdev->dev, tegra->padctl_irq, NULL, tegra_xusb_padctl_irq, - IRQF_ONESHOT, dev_name(&pdev->dev), tegra); - if (err < 0) { - dev_err(&pdev->dev, "failed to request padctl IRQ: %d\n", err); - goto remove_usb3; + if (tegra->padctl_irq) { + err = devm_request_threaded_irq(&pdev->dev, tegra->padctl_irq, + NULL, tegra_xusb_padctl_irq, + IRQF_ONESHOT, dev_name(&pdev->dev), + tegra); + if (err < 0) { + dev_err(&pdev->dev, "failed to request padctl IRQ: %d\n", err); + goto remove_usb3; + } } err = tegra_xusb_enable_firmware_messages(tegra); @@ -2132,7 +2139,7 @@ static __maybe_unused int tegra_xusb_suspend(struct device *dev) tegra->suspended = true; pm_runtime_disable(dev); - if (device_may_wakeup(dev)) { + if (device_may_wakeup(dev) && tegra->padctl_irq) { if (enable_irq_wake(tegra->padctl_irq)) dev_err(dev, "failed to enable padctl wakes\n"); } @@ -2161,7 +2168,7 @@ static __maybe_unused int tegra_xusb_resume(struct device *dev) return err; } - if (device_may_wakeup(dev)) { + if (device_may_wakeup(dev) && tegra->padctl_irq) { if (disable_irq_wake(tegra->padctl_irq)) dev_err(dev, "failed to disable padctl wakes\n"); } @@ -2179,6 +2186,9 @@ static __maybe_unused int tegra_xusb_runtime_suspend(struct device *dev) struct tegra_xusb *tegra = dev_get_drvdata(dev); int ret; + if (!tegra->padctl_irq) + return -EOPNOTSUPP; + synchronize_irq(tegra->mbox_irq); mutex_lock(&tegra->lock); ret = tegra_xusb_enter_elpg(tegra, true); -- 2.32.0