Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7044178imu; Wed, 14 Nov 2018 10:48:15 -0800 (PST) X-Google-Smtp-Source: AJdET5cgGyq5ML76W7DSMO0BjJx8mxXMldDog7SBabovm4z2lGtbI6PMGoTA559S9dnGr6yL2Yul X-Received: by 2002:aa7:8354:: with SMTP id z20mr3086440pfm.81.1542221295809; Wed, 14 Nov 2018 10:48:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542221295; cv=none; d=google.com; s=arc-20160816; b=OyevBsjRAA7KRkSUsijg62mV7a6QMnS/Slii7DHA5G3qTiGSHy7hWjsjv1hW8SwgaP iRZOKGFEmcuotX1+pkln0FpegqqRFTOd8/gKtEin0osRFCGe8mVPEKZF84jlbGynctu/ wPbz2EtPa+2SuWn1jnGWIlhVpyrtbcs7q2klwgKvs2pg0O2CfBMh2zg2kWaCGu6Mo/Mo vhSrZ8TvvzATCxMXdkwTDHnIIZEwtjTYtPCzIBgWWOMYrvWCAuYKGN2g0aiWEQ8Sz76F odcvfpPuqL6Bo2LITahcGOUd8NSO0usvnFswvbCbvjkOAGzlJSOiAjQbIJcvQhIPcgOP 4amQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:in-reply-to :subject:cc:to:from:date; bh=uG6K2aXuFywRJQmEIv1vi/iDJeJpHD3q/H/NPo5iWZQ=; b=syQjfdPE9yG6EeWzeUR0Rkc1w6NMdNFACkNJh1jyvbDIVW2hTLBM57fahiAxunZdbn L9o3wSFaLFrED+Bumz+MMNfJ9bCTfINxRY0EvgbGwFd+YtVcOHW8T2C1hO4rfVrOhzS8 +Nl9/VlcUzxWkP8SZ66dXnZy6LpJIbiU6Fe6Jn0Ldw91J0cqokYb8+zwrdPqdqgWdsv+ M6KLNMYvbGoB8rMysgxLMU4BvxhftJQ0+mJ4ElFPU8i8hRJ5+2I6ZjQrkyjILeYz2iWs 1hCaOWxd1/Eo4ie5VuvxNEMGEru1bKHSzF+JuuizHzrj7shITD0SU0i7sxkZGeS+9y4M x3LQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q1-v6si4571299plb.14.2018.11.14.10.48.00; Wed, 14 Nov 2018 10:48:15 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731448AbeKOEv1 (ORCPT + 99 others); Wed, 14 Nov 2018 23:51:27 -0500 Received: from iolanthe.rowland.org ([192.131.102.54]:48302 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1727761AbeKOEv1 (ORCPT ); Wed, 14 Nov 2018 23:51:27 -0500 Received: (qmail 6270 invoked by uid 2102); 14 Nov 2018 13:47:04 -0500 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 14 Nov 2018 13:47:04 -0500 Date: Wed, 14 Nov 2018 13:47:04 -0500 (EST) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Ben Dooks cc: gregkh@linuxfoundation.org, , , , Ben Dooks Subject: Re: [PATCH] USB: host: ehci: allow tine of highspeed nak-count In-Reply-To: <20181114171315.27549-1-ben-linux@fluff.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 14 Nov 2018, Ben Dooks wrote: > From: Ben Dooks > > At least some systems benefit with less scheduling if the NAK count > value is set higher than the default 4. For instance a Tegra3 with > an SMSC9512 showed less interrupt load when this was changed to 14. Interesting. Why do you think this is? In theory, increasing the NAK count RL value should cause a higher memory bus load and perhaps a slight rise in the interrupt load (transfers will complete a little more quickly because the controller tries harder to poll the endpoints and see if they are ready). > To allow the changing of this value, add a sysfs node to each of > the controllers to allow run-time changing. > > Signed-off-by: Ben Dooks The patch looks okay to me. Acked-by: Alan Stern Alan Stern > --- > drivers/usb/host/ehci-hcd.c | 1 + > drivers/usb/host/ehci-q.c | 4 +-- > drivers/usb/host/ehci-sysfs.c | 52 +++++++++++++++++++++++++++++++++-- > drivers/usb/host/ehci.h | 1 + > 4 files changed, 54 insertions(+), 4 deletions(-) > > diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c > index 8608ac513fb7..799262951f41 100644 > --- a/drivers/usb/host/ehci-hcd.c > +++ b/drivers/usb/host/ehci-hcd.c > @@ -526,6 +526,7 @@ static int ehci_init(struct usb_hcd *hcd) > hw->hw_qtd_next = EHCI_LIST_END(ehci); > ehci->async->qh_state = QH_STATE_LINKED; > hw->hw_alt_next = QTD_NEXT(ehci, ehci->async->dummy->qtd_dma); > + ehci->nak_tune_hs = EHCI_TUNE_RL_HS; > > /* clear interrupt enables, set irq latency */ > if (log2_irq_thresh < 0 || log2_irq_thresh > 6) > diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c > index 327630405695..ccb754893b5a 100644 > --- a/drivers/usb/host/ehci-q.c > +++ b/drivers/usb/host/ehci-q.c > @@ -898,12 +898,12 @@ qh_make ( > case USB_SPEED_HIGH: /* no TT involved */ > info1 |= QH_HIGH_SPEED; > if (type == PIPE_CONTROL) { > - info1 |= (EHCI_TUNE_RL_HS << 28); > + info1 |= ehci->nak_tune_hs << 28; > info1 |= 64 << 16; /* usb2 fixed maxpacket */ > info1 |= QH_TOGGLE_CTL; /* toggle from qtd */ > info2 |= (EHCI_TUNE_MULT_HS << 30); > } else if (type == PIPE_BULK) { > - info1 |= (EHCI_TUNE_RL_HS << 28); > + info1 |= ehci->nak_tune_hs << 28; > /* The USB spec says that high speed bulk endpoints > * always use 512 byte maxpacket. But some device > * vendors decided to ignore that, and MSFT is happy > diff --git a/drivers/usb/host/ehci-sysfs.c b/drivers/usb/host/ehci-sysfs.c > index 8f75cb7b197c..d710d35282a6 100644 > --- a/drivers/usb/host/ehci-sysfs.c > +++ b/drivers/usb/host/ehci-sysfs.c > @@ -145,19 +145,66 @@ static ssize_t uframe_periodic_max_store(struct device *dev, > } > static DEVICE_ATTR_RW(uframe_periodic_max); > > +static ssize_t nak_tune_hs_show(struct device *dev, > + struct device_attribute *attr, > + char *buf) > +{ > + struct ehci_hcd *ehci; > + > + ehci = hcd_to_ehci(dev_get_drvdata(dev)); > + return scnprintf(buf, PAGE_SIZE, "%d\n", ehci->nak_tune_hs); > +} > + > +static ssize_t nak_tune_hs_store(struct device *dev, > + struct device_attribute *attr, > + const char *buf, size_t count) > +{ > + struct ehci_hcd *ehci; > + unsigned val; > + unsigned long flags; > + > + ehci = hcd_to_ehci(dev_get_drvdata(dev)); > + > + if (kstrtouint(buf, 0, &val) < 0) > + return -EINVAL; > + > + if (val >= 15) { > + ehci_info(ehci, "invalid value for nak_tune_hs (%d)\n", val); > + return -EINVAL; > + } > + > + spin_lock_irqsave (&ehci->lock, flags); > + ehci->nak_tune_hs = val; > + spin_unlock_irqrestore (&ehci->lock, flags); > + return count; > +} > + > +static DEVICE_ATTR_RW(nak_tune_hs); > > static inline int create_sysfs_files(struct ehci_hcd *ehci) > { > struct device *controller = ehci_to_hcd(ehci)->self.controller; > int i = 0; > > + i = device_create_file(controller, &dev_attr_nak_tune_hs); > + if (i) > + goto out; > + > + i = device_create_file(controller, &dev_attr_uframe_periodic_max); > + if (i) > + goto out_nak; > + > /* with integrated TT there is no companion! */ > if (!ehci_is_TDI(ehci)) > i = device_create_file(controller, &dev_attr_companion); > if (i) > - goto out; > + goto out_all; > > - i = device_create_file(controller, &dev_attr_uframe_periodic_max); > + return 0; > +out_all: > + device_remove_file(controller, &dev_attr_uframe_periodic_max); > +out_nak: > + device_remove_file(controller, &dev_attr_nak_tune_hs); > out: > return i; > } > @@ -170,5 +217,6 @@ static inline void remove_sysfs_files(struct ehci_hcd *ehci) > if (!ehci_is_TDI(ehci)) > device_remove_file(controller, &dev_attr_companion); > > + device_remove_file(controller, &dev_attr_nak_tune_hs); > device_remove_file(controller, &dev_attr_uframe_periodic_max); > } > diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h > index c8e9a48e1d51..1fb6f1ad8128 100644 > --- a/drivers/usb/host/ehci.h > +++ b/drivers/usb/host/ehci.h > @@ -154,6 +154,7 @@ struct ehci_hcd { /* one per controller */ > dma_addr_t periodic_dma; > struct list_head intr_qh_list; > unsigned i_thresh; /* uframes HC might cache */ > + u32 nak_tune_hs; > > union ehci_shadow *pshadow; /* mirror hw periodic table */ > struct list_head intr_unlink_wait; >