Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp249659rdf; Tue, 21 Nov 2023 01:18:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IEfHbQjBSQGfl1DrecPaXFP4NSGCDt7+Zz5WM9Edw1HgIFYE5vKlUKe7OmBMP5MevyqyIQk X-Received: by 2002:a17:902:c40a:b0:1cc:3fce:8aa8 with SMTP id k10-20020a170902c40a00b001cc3fce8aa8mr9115597plk.6.1700558281342; Tue, 21 Nov 2023 01:18:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700558281; cv=none; d=google.com; s=arc-20160816; b=qpPQlX8rWPNTse53Si174+vIXosQLqYqr0LcxEEMSiR6jOxQN4BAxHYSTSs5agRz44 7jKxvj48orIA7DsbHNd3ekNRM8YJjQiQ6SHsHLXCiALbzl2zW49e2yJya5kq2o9Aid8x SUFi59lnc9RmDgvkidyEal+7Tcs8BpN1RFnhGQdirwLD4C49vNnDa7H33FhO/wq2rZWs nqTwllsZcTVhlVKPdtN5sqisBj4HzAS/W3GAYsXbgsMHmDJPx+WCBrP++ZaMxS+ebAA3 BCtYAlWHFhBuCYg/H6tZvDXlODEuoX/vukJ6Bh1oljaf6qCtde1zyuB/QMdjq6/U2VDC 4WwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=AUjqbYD9ZTUcFjr80m5xn68qaPHphMbDCylzdZHhAAU=; fh=S68kHggh1eTyu6orkIFJYr+R6qmH3wr5Ec56Oeu90eM=; b=hrLighRX0rF0WFZcIpUXu2LaMXBDwH/2Zf5o4GCQRvuqcN9058+QB2GxI9Kv46RWws 29sVh3En95K4yY+Mm13YsA3yc4bwPbY1ZCDwv5s095XemFYbYsePDhd1H0GaQvu2E3sU 1kaJ7agfGj2S+LkxH9qBQeGr/JdkPBFNH3dQfmPqIJwSjENH0hJJkVvyxpPQHS+REKZs 7C6eDS67xD+WYde2qk3NEE3JA+NpLlU2ShaEL252Uun2I+QpdaBjxU0qRQvqxDLUWlxt EKq18OGKxQTpVQYbzcHNT61qtiiFnAPwKh/O25mngnnvnJyTcMFwRjiIcKoHd2BDtHhW f9ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="EY9G3e//"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id l12-20020a170903120c00b001c9af7debbasi10370023plh.520.2023.11.21.01.18.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 01:18:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="EY9G3e//"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 601DC80BE629; Tue, 21 Nov 2023 01:17:58 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231372AbjKUJRr (ORCPT + 99 others); Tue, 21 Nov 2023 04:17:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229454AbjKUJRq (ORCPT ); Tue, 21 Nov 2023 04:17:46 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06810C1; Tue, 21 Nov 2023 01:17:43 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 96403C433C7; Tue, 21 Nov 2023 09:17:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700558262; bh=KiJ/ru65Ua8lo4s4fh4OjLQfr8e6MLSoBb/RDxWensY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=EY9G3e//vJF7k13VmW76Yg4tqo4bYwC2YfDojOjvxuSr9VIw4idRrZhBvYcNt5EFP SHaFaNcHn3iQA/LpGwavpXPMJMW19y14mBeHfC8DLz/r8WAZBA3w6hBwEMwd3H3qVh 9ZKHx6kkjJ81fj5Dj5azu2nLiIaxaSeFlZWd9KFEosC8kjJPW6B3C9xuKYC8b3ETnh VcyG/gcTVUImvNkZpZx881dhtUmhnH6cnWL+a5f/U4Q6n0otk6WOinYAZyvLu79cqT +NdLMfiSgo7tuW7fllRQflnxVNvgMN2UX85GgfSolv6r7erH4kW+9Bux8cWc3ECHPp SjA5WXIvgy4LQ== Received: from johan by xi.lan with local (Exim 4.96.2) (envelope-from ) id 1r5MtF-00047b-1C; Tue, 21 Nov 2023 10:17:53 +0100 Date: Tue, 21 Nov 2023 10:17:53 +0100 From: Johan Hovold To: Andrew Halaney Cc: Johan Hovold , Greg Kroah-Hartman , Andy Gross , Bjorn Andersson , Konrad Dybcio , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Thinh Nguyen , Wesley Cheng , Krishna Kurapati PSSNV , linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH 2/3] USB: dwc3: qcom: fix wakeup after probe deferral Message-ID: References: <20231120161607.7405-1-johan+linaro@kernel.org> <20231120161607.7405-3-johan+linaro@kernel.org> <3ff65t36p6n3k7faw2z75t2vfi6rb5p64x7wqosetsksbhhwli@5xaxnm7zz4tu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3ff65t36p6n3k7faw2z75t2vfi6rb5p64x7wqosetsksbhhwli@5xaxnm7zz4tu> X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Tue, 21 Nov 2023 01:17:58 -0800 (PST) On Mon, Nov 20, 2023 at 02:50:52PM -0600, Andrew Halaney wrote: > On Mon, Nov 20, 2023 at 11:39:07AM -0600, Andrew Halaney wrote: > > On Mon, Nov 20, 2023 at 05:16:06PM +0100, Johan Hovold wrote: > > > The Qualcomm glue driver is overriding the interrupt trigger types > > > defined by firmware when requesting the wakeup interrupts during probe. > > > > > > This can lead to a failure to map the DP/DM wakeup interrupts after a > > > probe deferral as the firmware defined trigger types do not match the > > > type used for the initial mapping: > > > > > > irq: type mismatch, failed to map hwirq-14 for interrupt-controller@b220000! > > > irq: type mismatch, failed to map hwirq-15 for interrupt-controller@b220000! > > > > > > Fix this by not overriding the firmware provided trigger types when > > > requesting the wakeup interrupts. > > > > This series looks good to me and makes sense except for one point that > > I'm struggling to understand. What exactly is the relationship with this > > failure and probe deferral? > > Eric Chanudet pointed out to me (thanks!) offlist that if you: > > 1. Probe > 2. Grab the IRQ > 3. Request it (and muck with the trigger from the firmware default) > 4. Defer out > 5. Reprobe > 6. Grab the IRQ again > > You get that error, which I played with some this afternoon... > and can confirm. > > It really seems like maybe we should consider reworking messing with the > trigger type at all (which is done later for runtime/system suspend) > in a follow-up series? > > As far as I can tell if you were to remove the driver and reprobe after > a suspend you'd hit similar. Correct, but people don't go around unloading modules (unlike probe deferral which anyone can hit). It's a development (debugging) feature so there being some corner cases are not that big of a deal. > I've been sitting here scratching my head a > bit trying to reason out why keeping it as IRQ_TYPE_EDGE_BOTH isn't > acceptable in dwc3_qcom_enable_interrupts()... Correct me if you think > that playing with the trigger there is really ok, but it seems like you > run the same risks if you do that and then modprobe -r dwc3-qcom. Changing the trigger type during runtime depending on use-case should be fine. It just doesn't play well with the kernel's interrupt mapping code, which assumes that if an interrupt already has a mapping then it is a shared interrupt. I considered addressing that in the core code, but yeah, I don't want too much time since the remaining issue only affects module unload and there are other ways to avoid that issue too. > I get that dwc3_qcom_enable_interrupts() limits the scope of what wakes us > up to what we expect given the current device (or lack thereof), but it > doesn't seem like you're really meant to play with the IRQ triggers, > or at least the warning you shared makes me think it is not a great idea > if you plan to probe the device ever again in the future. > > I'll post the current comment in dwc3_qcom_enable_interrupts() to > explain the "limits the scope of what wakes us up" a bit more clearly: > > /* > * Configure DP/DM line interrupts based on the USB2 device attached to > * the root hub port. When HS/FS device is connected, configure the DP line > * as falling edge to detect both disconnect and remote wakeup scenarios. When > * LS device is connected, configure DM line as falling edge to detect both > * disconnect and remote wakeup. When no device is connected, configure both > * DP and DM lines as rising edge to detect HS/HS/LS device connect scenario. > */ Yes, that is how it is currently implemented and I intend to change that shortly. I just wanted to get the fixes out first. Specifically, I consider the current implementation to be broken in that it generates wakeup events on disconnect which is generally not want you want. Consider closing the lid of your laptop and disconnecting a USB mouse before putting it in your backpack. Now it's no longer suspended as you would expect it to be. With the devictrees soon fixed, we could also do away with changing the trigger type, but since this is how it was implemented initially we now need to consider backward compatibility with the broken DTs. We've dealt with that before, but yeah, getting things right from the start would have been so much better. Johan