From patchwork Tue Mar 7 23:47:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 659892 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp37989wrb; Tue, 7 Mar 2023 15:50:26 -0800 (PST) X-Google-Smtp-Source: AK7set+2MkBaBz7TFfX0SNaT7BOTWZkuGV0zpk6ROJVdWf7Ld9ttRZXRVF8qX1L7On7I9tAEcE7b X-Received: by 2002:ac8:5a08:0:b0:3bf:daae:7ee3 with SMTP id n8-20020ac85a08000000b003bfdaae7ee3mr29072480qta.53.1678233025880; Tue, 07 Mar 2023 15:50:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678233025; cv=none; d=google.com; s=arc-20160816; b=XYeQEM8qHk98YjIdoK10fhzvfo95wjgStNT0u7b+aPX1DmGTRTxHUJRi3Swe3tNGBX 423JJvRpaBU0aemMO2aUHCXMyuVkPMJQu9wsPiKsAstM+DbEuXd6PTZKKI6zVF1qjNQm 155EIxwVFl5OpHBW1/Fi0gEbsY3fcCckX1/09fAh4SB689bQxOdqAHWeGkRUMMKGYuby GAGmAJOSRPV7c1aeFNjPViiuhWZ0puTneYhUPaEN0htbGgcQhz2M9WEnBIg0y7ENgb23 QLrISAn4v67cn830xHf9Hm/kXBdJPW1rC70/lOv9/V2ldbqYdsCkU44cPGFUFA1Y/qmL 1ozw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=G/7TZdWIWI2bPNX8WYjN36RNDgq59bbWj+qZFqKNCyM=; b=biRLq41KanhIfCKpPh2S+wkgsUznqaO3l5Rgwqyd+mRcUZcp3ErSyUKQsNVLr8p2IN 3ZuwLff6htS/VdeXqZloGEKuYufDgfHdCXoj1oMJUJ/HyQIBiB+HcyM4VzXa2BJNF1Lu uW2AKCV9NCUxJp4ywu3u5CXEYdQ2v2pUDkhskFgD4uMf96Y0gaiN3x5cwy9XQC0Ts4oj GOsrirxjVJykL/raqJLgmwbqXUsQbbLuw85sH1gH5Jh7ZTwcmiYM2e/Cu8lIwvtJXULa OG5xlh+rmLDeP6kQJ88E2RhPmDSGY3/GShS0BKjLxavLeTdGaUvtDB5/DswbGcH2Ys95 tt5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=s4imKU1p; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id u11-20020a05622a198b00b003ba00143b44si10673954qtc.584.2023.03.07.15.50.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Mar 2023 15:50:25 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=s4imKU1p; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZh3c-0005uD-6n; Tue, 07 Mar 2023 18:49:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZh3B-0005Eq-K0 for qemu-devel@nongnu.org; Tue, 07 Mar 2023 18:48:58 -0500 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pZh39-0002tK-SX for qemu-devel@nongnu.org; Tue, 07 Mar 2023 18:48:57 -0500 Received: by mail-wm1-x32d.google.com with SMTP id j19-20020a05600c191300b003eb3e1eb0caso179496wmq.1 for ; Tue, 07 Mar 2023 15:48:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678232935; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=G/7TZdWIWI2bPNX8WYjN36RNDgq59bbWj+qZFqKNCyM=; b=s4imKU1pSGCI846VbPzI+gH3Zvldo+Pu1mqmXJhhbHsfZYtSTokO+Ixo0RHMYbv++8 AX3rM3XgejjEl9QSIb1+Os5bPqfdP33KYUCUcp4i0RXdPbWCPIe8rbImkB0sWnT5RNG0 Yqw0ZUee9FfJOPqthq/AFgxxxQnm4i6DHWtV9ww7AzTIsJoARv0j890yCq4sdeBUtQMm 3ARWxfZSmLiCTHtt7rpEs5G4nwljHsswPx1ogveNdad1FtLBacW53niKDU/v2dJmVBac P28RBRd7bLhfQhH6W4w1KExD03wTS/namSaFaauTQZmcQAV8ikP7EHsxDbCiGBGsMS9v zlOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678232935; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=G/7TZdWIWI2bPNX8WYjN36RNDgq59bbWj+qZFqKNCyM=; b=dlb+6OKNk3IWrLC56oP/lfavG70iGX+nh2y7gRvQ3LjwNU23h/5UYo7e+VIDdN0Vh1 gzxVBV13QvCJcYgUepEsG2aytNaLCsXnxFGmYBt05SHxpzqgR7TXDfNGyQnW1VgpRhTy BgsNlyrnG9R4GQW1PBl4meuhuARxrAo6Be2wEVMhT8gxAnDs5YuwjS3XLSxvnL8965WF dEc3WOeHXEwvFDTekvfSdrAEvjcwHtZr28sUrkJ6XsOTXZV2HBEBuU7tY9n0S/OimTTs Mo8QyP6mfEg6AIPF4aXWT8kiSTrB0IafG++jLVX/WUP8zJyjlF7/AzJTvxGomm49ZRJc GHYg== X-Gm-Message-State: AO0yUKXk7Fe2nEpXHjLNEDTFYoHzr3i23w2zki+zBtwkKI4biPUAgVV2 iml8TkwPY9OW/elI5OH/PLNhllm2bm8wlhvK4e8= X-Received: by 2002:a1c:7c16:0:b0:3df:9858:c02e with SMTP id x22-20020a1c7c16000000b003df9858c02emr14118530wmc.3.1678232934902; Tue, 07 Mar 2023 15:48:54 -0800 (PST) Received: from localhost.localdomain (57.red-88-29-179.dynamicip.rima-tde.net. [88.29.179.57]) by smtp.gmail.com with ESMTPSA id z9-20020adfec89000000b002425be3c9e2sm13720376wrn.60.2023.03.07.15.48.53 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 07 Mar 2023 15:48:54 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, BALATON Zoltan , Gerd Hoffmann , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 17/20] hw/usb/ohci: Implement resume on connection status change Date: Wed, 8 Mar 2023 00:47:08 +0100 Message-Id: <20230307234711.55375-18-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230307234711.55375-1-philmd@linaro.org> References: <20230307234711.55375-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=philmd@linaro.org; helo=mail-wm1-x32d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: BALATON Zoltan If certain bit is set remote wake up should change state from suspended to resume and generate interrupt. There was a todo comment for this, implement that by moving existing resume logic to a function and call that. Signed-off-by: BALATON Zoltan Acked-by: Gerd Hoffmann Message-Id: <35c4d4ccf2f73e6a87cdbd28fb6a1b33de72ed74.1676916640.git.balaton@eik.bme.hu> [PMD: Have ohci_resume() return a boolean] Signed-off-by: Philippe Mathieu-Daudé --- hw/usb/hcd-ohci.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c index 6f8b543243..88d2b4b13c 100644 --- a/hw/usb/hcd-ohci.c +++ b/hw/usb/hcd-ohci.c @@ -1410,6 +1410,18 @@ static void ohci_set_hub_status(OHCIState *ohci, uint32_t val) } } +/* This is the one state transition the controller can do by itself */ +static bool ohci_resume(OHCIState *s) +{ + if ((s->ctl & OHCI_CTL_HCFS) == OHCI_USB_SUSPEND) { + trace_usb_ohci_remote_wakeup(s->name); + s->ctl &= ~OHCI_CTL_HCFS; + s->ctl |= OHCI_USB_RESUME; + return true; + } + return false; +} + /* * Sets a flag in a port status reg but only set it if the port is connected. * If not set ConnectStatusChange flag. If flag is enabled return 1. @@ -1426,7 +1438,10 @@ static int ohci_port_set_if_connected(OHCIState *ohci, int i, uint32_t val) if (!(ohci->rhport[i].ctrl & OHCI_PORT_CCS)) { ohci->rhport[i].ctrl |= OHCI_PORT_CSC; if (ohci->rhstatus & OHCI_RHS_DRWE) { - /* TODO: CSC is a wakeup event */ + /* CSC is a wakeup event */ + if (ohci_resume(ohci)) { + ohci_set_interrupt(ohci, OHCI_INTR_RD); + } } return 0; } @@ -1828,11 +1843,7 @@ static void ohci_wakeup(USBPort *port1) intr = OHCI_INTR_RHSC; } /* Note that the controller can be suspended even if this port is not */ - if ((s->ctl & OHCI_CTL_HCFS) == OHCI_USB_SUSPEND) { - trace_usb_ohci_remote_wakeup(s->name); - /* This is the one state transition the controller can do by itself */ - s->ctl &= ~OHCI_CTL_HCFS; - s->ctl |= OHCI_USB_RESUME; + if (ohci_resume(s)) { /* * In suspend mode only ResumeDetected is possible, not RHSC: * see the OHCI spec 5.1.2.3.