From patchwork Thu May 15 18:52:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roy Luo X-Patchwork-Id: 890558 Received: from mail-ua1-f74.google.com (mail-ua1-f74.google.com [209.85.222.74]) (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 044AA29B232 for ; Thu, 15 May 2025 18:52:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747335168; cv=none; b=FhfsK8lSrP9cLjOPU8s8ANgHyxbsjjqM1pbvWe8nFfCxg5StPgZrCUGEcqAvm5GJEyKoGamkEse4UowD0MZcBqt9ykbTI23Ud+oSiy6rUFZ+t/JMxtN0HbcA1OnJJ7hzDTCTYHIaFO69TXwK2jFgN1A3N/W5RKqTov5/QIR5sL0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747335168; c=relaxed/simple; bh=0LjNKhbfmAib3/bCGGrxaNTDj6/FhN1QTzDXt9i+2Dg=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=WczgvTkEnFrCm/KjrzDbgE+QcRUW0vVpPX94QH8kg6ppn9VST1mzdbUb3tsCGQCfDTWsEftgG8BQeOBMxhKrXTqErp40g7antyxqFt/3+TVeFPKVomlWOsvb9rWUL9rjCJhyg9OmVi4778QskpFOFgSgDYwc0ycFoL0hVGjIomA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--royluo.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=M37H/kvt; arc=none smtp.client-ip=209.85.222.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--royluo.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="M37H/kvt" Received: by mail-ua1-f74.google.com with SMTP id a1e0cc1a2514c-87835c2bb03so207694241.3 for ; Thu, 15 May 2025 11:52:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1747335165; x=1747939965; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=DWyXRAdP87qgljLxl+HMaPV4zDEKZVcFQ9p3OniQnHM=; b=M37H/kvt3HAzYxRy423MGjcicT9FxMy76qDD9tflwllQp1ur6qZIwOIs+p2hnYdtvL /o2PAOGLM1aSU8tBsctPeuJoP6Svs7wwJ4XGflNFLOQPpuHrG82MXffzYuGPjcNsPxRw SUrek7mTeAsfOA9JjCjPUjPnY8XeuHeABA2luMC8AzwjtaUdPBuGdLY2Bmbr0jX0UIvr F18s3C+D5V1+lI6FKVLOnmyb+sks5gAgyBR86o14311U+hfGNG/xtm58wI2h4Bagh3e+ wXT78oA1D8XqUiZ38NS6dhflqUp4ELMYiSO4su7bc7xybvoBi0Q4sh1y8IJ/qFvA+up3 GR2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747335165; x=1747939965; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=DWyXRAdP87qgljLxl+HMaPV4zDEKZVcFQ9p3OniQnHM=; b=EB6NryuHsN4KQPzfYMMAuGg8H/2WoHJHWF8iLmJHqu/BfJ1qln5/Vnu/nD8YLrYmR7 USQ40yhzTB7DnXtgvy+T9mYqDOroJzkyzh1HBrYoQKBq0WwgNDrXLMcasDAc0C7ezcH5 7VpDbeHclEONiQAOQPcafD5VOTeV9bf/Jl7i9ki0IRWrTGYYO2bJPcSLtyIhnusd20X+ xduMCkapYP8tsZLlbaSwPhxHffsAA8Iiqw+DAZYE45+gAthNiQLL/fycDewwYU+V148W KFxtFxkuwklFV2WekI+gBHeZ1AF4ITsM1K75y3RRN77f+B27WevvynOd/wuOS+6I7Sov RNMg== X-Forwarded-Encrypted: i=1; AJvYcCWDLcsfQXmFgy4Dd06M85hGZcUNhedRG7K/gcGY2i8VLHXIlGCKiqPmtttQfNNO7MX9T7s5lUbuVhI=@vger.kernel.org X-Gm-Message-State: AOJu0YzxaalrmwMgEOTA2ZAcMe/WBqHKSG5FExmVWCnDZnSDz0PdUSTy qmyT7PEZ+ABqu6ED1+Mccw/C7UltCvRCEI31trS6aKeQoaajjXfYnLWpoZ+qkpRmIa9dWjbOJy7 LF7ylMQ== X-Google-Smtp-Source: AGHT+IG22pOiWebGnpFU30OwudK3lZF8XV0VjtcFcbirfzEnZEJ1trZz38ISLvHcqDC7fMy1q+bzyq8op8g= X-Received: from uabji15.prod.google.com ([2002:a05:6130:694f:b0:862:24ba:d6a3]) (user=royluo job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6102:a54:b0:4df:8259:e99 with SMTP id ada2fe7eead31-4dfa6aa8d4emr1466532137.1.1747335164831; Thu, 15 May 2025 11:52:44 -0700 (PDT) Date: Thu, 15 May 2025 18:52:27 +0000 In-Reply-To: <20250515185227.1507363-1-royluo@google.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250515185227.1507363-1-royluo@google.com> X-Mailer: git-send-email 2.49.0.1112.g889b7c5bd8-goog Message-ID: <20250515185227.1507363-3-royluo@google.com> Subject: [PATCH v2 2/2] usb: dwc3: Force full reset on xhci removal From: Roy Luo To: royluo@google.com, mathias.nyman@intel.com, quic_ugoswami@quicinc.com, Thinh.Nguyen@synopsys.com, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: stable@vger.kernel.org During an xhci host controller reset (via `USBCMD.HCRST`), reading DWC3 registers can return zero instead of their actual values. This applies not only to registers within the xhci memory space but also those in the broader DWC3 IP block. By default, the xhci driver doesn't wait for the reset handshake to complete during teardown. This can cause problems when the DWC3 controller is operating as a dual role device and is switching from host to device mode, the invalid register read caused by ongoing HCRST could lead to gadget mode startup failures and unintended register overwrites. To mitigate this, enable xhci-full-reset-on-remove-quirk to ensure that xhci_reset() completes its full reset handshake during xhci removal. Cc: stable@vger.kernel.org Fixes: 6ccb83d6c497 ("usb: xhci: Implement xhci_handshake_check_state() helper") Signed-off-by: Roy Luo --- drivers/usb/dwc3/host.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c index b48e108fc8fe..ea865898308f 100644 --- a/drivers/usb/dwc3/host.c +++ b/drivers/usb/dwc3/host.c @@ -126,7 +126,7 @@ static int dwc3_host_get_irq(struct dwc3 *dwc) int dwc3_host_init(struct dwc3 *dwc) { - struct property_entry props[6]; + struct property_entry props[7]; struct platform_device *xhci; int ret, irq; int prop_idx = 0; @@ -182,6 +182,9 @@ int dwc3_host_init(struct dwc3 *dwc) if (DWC3_VER_IS_WITHIN(DWC3, ANY, 300A)) props[prop_idx++] = PROPERTY_ENTRY_BOOL("quirk-broken-port-ped"); + if (dwc->dr_mode == USB_DR_MODE_OTG) + props[prop_idx++] = PROPERTY_ENTRY_BOOL("xhci-full-reset-on-remove-quirk"); + if (prop_idx) { ret = device_create_managed_software_node(&xhci->dev, props, NULL); if (ret) {