Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5688917pxj; Wed, 23 Jun 2021 07:00:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxr9WRqsi7bBrIbKGF3owqGuoX9SVsieGrLhNmFHcehEwdneJGCOUHXP3DOQ++in4cfG6A X-Received: by 2002:a6b:d009:: with SMTP id x9mr7299778ioa.199.1624456850611; Wed, 23 Jun 2021 07:00:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624456850; cv=none; d=google.com; s=arc-20160816; b=H+CXd9eZFL86mZE4j++CgSiw0rMetUTmmR5tan7jF+SRFT93ohpYsfUXRF+pKlPZkO tT4p6fk0yVKEImrULsF4faZMs+o0yxrI05N7k69QGtoPHhKS+tiIUZuu0Qu7DuE0kEdm t3Z0vb866Rnflp2YNTWCoLup8oIs0dsLiMnibGYtV/5rN6/p9/ixT3uiQV1XHF/pDOvN khA+JeZrEzzBLJtewlXa1kXIfFxAeOSZEr3hA6METeNkbKNmkUEY6efBnQXVG+PnbTCa oCgzLfxCbbN5zcGAcjj5z6Q2Of22RCw1p2JbA+T7WR84BtH2lybwmZLSfx23O2bujhQj m9MA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=rpXelkp1ieVvra6uAbRm4CfoDxzK3GNCbHoIY09r3b0=; b=A7OJy8YyUXSJPezJVurkmaTHRJA5uimp/TP3G1NjnRlVz0JIysmkyrEyNALI099mMT qkaxdrJPfc9t31jFpxpU5JoSQY8+XL49a+U7cpmlchWbTM754CMXNyfepb6K8w6P1Ce6 qxJiFG0u4ldfI/2GEMcKOXmiDc8onjRo7OqvIIP5bKiwIEEeJ6Tv9P9QrvRkaZRfSpec THK4liZOtB/VjuMyMihr43gI+sFSmbd/LxJ+7qO99/s0PB3cVelOEVAi7bdsRINd6G8Q DMyBRBynFM8JPkVWr3iFebOppc+tlzTpqOmN90S3SrCJUlC8Ha6ojkU714mNUR2y2nAJ GvfQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l12si250383ilv.105.2021.06.23.07.00.37; Wed, 23 Jun 2021 07:00:50 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230430AbhFWOBf (ORCPT + 99 others); Wed, 23 Jun 2021 10:01:35 -0400 Received: from netrider.rowland.org ([192.131.102.5]:45973 "HELO netrider.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S230274AbhFWOBe (ORCPT ); Wed, 23 Jun 2021 10:01:34 -0400 Received: (qmail 492480 invoked by uid 1000); 23 Jun 2021 09:59:15 -0400 Date: Wed, 23 Jun 2021 09:59:15 -0400 From: Alan Stern To: Claudiu.Beznea@microchip.com Cc: gregkh@linuxfoundation.org, Nicolas.Ferre@microchip.com, alexandre.belloni@bootlin.com, Ludovic.Desroches@microchip.com, Cristian.Birsan@microchip.com, linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] usb: host: ohci-at91: suspend/resume ports after/before OHCI accesses Message-ID: <20210623135915.GB491169@rowland.harvard.edu> References: <20210609121027.70951-1-claudiu.beznea@microchip.com> <20210609230735.GA1861855@rowland.harvard.edu> <0621eaba-db4d-a174-1b15-535e804b52ac@microchip.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0621eaba-db4d-a174-1b15-535e804b52ac@microchip.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 23, 2021 at 12:47:56PM +0000, Claudiu.Beznea@microchip.com wrote: > On 10.06.2021 02:07, Alan Stern wrote: > > EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe > > > > On Wed, Jun 09, 2021 at 03:10:27PM +0300, Claudiu Beznea wrote: > >> On SAMA7G5 suspending ports will cut the access to OHCI registers and > >> any subsequent access to them will lead to CPU being blocked trying to > >> access that memory. Same thing happens on resume: if OHCI memory is > >> accessed before resuming ports the CPU will block on that access. The > >> OCHI memory is accessed on suspend/resume though > >> ohci_suspend()/ohci_resume(). > > > > That sounds very strange. > > The clock scheme for OHCI and EHCI IPs on SAMA7G5 is as follows > (I hope it is readable): > > Main Xtal > | > +-------------+ > | | > +---------------------------+ \ / | > | +------+ | 60MHz +--------------------+ | > | | | | | |------+ > | | Port |<----------| UTMI Transceiver A | | | > | | | | | |----+ | > | USB 2.0 EHCI |Router| | +--------------------+ | | | > | Host Controller | | | 60MHz +--------------------+ | | | > | | |<----------| UTMI Transceiver B |<-+ | | > | | | | +--------------------+ | | | > | | | | 60MHz +--------------------+ | | | > | | |<----------| UTMI Transceiver C |<-+ | | > | | | | +--------------------+ | | > | +------+ | | | > | | | | > +---------------------------+ | | > | | > +---------------------------+ | | > | +------+ | UHP48M | | > | | Root | |<---------------------------------+ | > | USB 1.1 OHCI | hub | | | > | Host Controller | and | | UHP12M | > | | host | |<-----------------------------------+ > | | SIE | | > | +------+ | > | | > +---------------------------+ > > Where UTMI transceiver A generates the 48MHz and 12MHz clocks for OHCI > full-speed operations. > > The ports control is done through AT91_SFR_OHCIICR via > ohci_at91_port_suspend() function where. Setting 0 in AT91_SFR_OHCIICR > means suspend is controlled by EHCI-OHCI and 1 forces the port suspend. > Suspending the port A will cut the clocks for OHCI. I want to mention that > AT91_SFR_OHCIICR register is not in the same memory space of OHCI, EHCI IPs > and is clocked by other clocks. > > > Suppose one of the ports is suspended, so access to the > > OHCI registers is blocked. Then how can you resume the port? > > For run-time control (via ohci_at91_hub_control()), I agree with you that > the current implemented approach is not healthy (taking into account the > clock scheme above) and the fact that we do force the ports suspend on > ohci_at91_hub_control(). For suspend/resume it should be OK as the ports > are suspended at the end of any OHCI accesses (I don't know how the Linux > USB subsystem behaves so please do correct me if I'm wrong). (I haven't checked the details recently, so I'm not certain about this.) In some -- perhaps all -- cases, we don't suspend the ports at all during system suspend. We just rely on the USB devices automatically going into suspend when the root hub stops sending packets. > > Don't you have to > > access the OHCI registers in order to tell the controller to do the port resume? > > On our implementation we control the port suspend/resume via > AT91_SFR_OHCIICR, a special kind of register, memory mapped at different > address (compared w/ OHCI, EHCI IPs), so clocked by other clocks. > > > > > What happens when there's more than one port, and one of them is suspended while > > the other one is still running? How can you communicate with the active port if > > access to the OHCI registers is blocked? > > For this kind of scenario (the run-time suspend of a port, not system > suspend/resume) a different mechanism should be implemented taking into > account the clock schema presented above. Okay, I see. It seems like the driver will need some significant changes to handle runtime power management properly. One thing you might consider changing: The name of the ohci_at91_port_suspend routine is misleading. It doesn't really handle suspending the port; instead it handles the clocks that drive the entire OHCI controller. Right? Alan Stern