Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1349240imu; Tue, 11 Dec 2018 18:06:11 -0800 (PST) X-Google-Smtp-Source: AFSGD/VL1KuIMcdm2KckTH51uNvw8EV+gLqved+LktFI6WKVVtp3BRe0VpCYdG+EDTxH2rCIh626 X-Received: by 2002:a17:902:112c:: with SMTP id d41mr17593015pla.144.1544580371576; Tue, 11 Dec 2018 18:06:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544580371; cv=none; d=google.com; s=arc-20160816; b=bnYXuXLt7/udyyIP+FVYjA0AY8RNiZRcdQmuyD550Bd1jWpvD9Cs5ALio9fW4y7NXo dHCAUt62zF2DmImMnpYhjwYD8lIYl4JLrQB7O+cPBr0vq4nQefr2pIBlijsXauRH+NB3 HCL5YZ2yK8ejYaAwS4L1Kz0Phc8UoRnpaMyVmkW4heaYxboQ4OSNq+Lmqn/VpVsp2zlt 2SeQKKotvXVmAOIwnrhGASaOOPyQSdehdTp3hOLrnFN9EYHTbmbkTkr1NBPirN92gFY0 HKmrLTTiO2NlBjXoDGHXOJ1LBd3iaXg7ipYCO4oQoEF58pu/Y35WJdZYhLmTufuSpM0U HNQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=IYDjAh2fffOPQ6dIhZwOJp5LyUcdcAg+jzmXYOjIbPk=; b=YufsCBWKAWXqI/DAX22oI50bpIfFc9xdvQTMylZOZqF+vxEZ2jn4IoLcF9cLW/asiP oz2UwL6x0hOxmlnQtBXx0rxkWIMjh3U9KMURmJYN6hy7GpHMec9WWNrgY7nbb4hjBIWP /07LLJBMikdb5PwUbp85kG/vWMxBxtufDg4pdh8QVmqWlsXTsS7hYPb1K3fk/SOQJH+w C/+hDyjs4IgnQbSwDNqzOFNwcfuBztg7jB/H2XTDpi1u3LGQ9HMKP7oOMwPJnUmRy8Kd GTguWdsOszn+Vzvvy5T6fbt4Ajr+ALH/FnEbAtA71IOieYKsck8HqZNynryTxOqWhjgn 6C1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=W7Y1rMiI; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v30si13078590pga.45.2018.12.11.18.05.32; Tue, 11 Dec 2018 18:06:11 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=W7Y1rMiI; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726251AbeLLCEm (ORCPT + 99 others); Tue, 11 Dec 2018 21:04:42 -0500 Received: from mail-io1-f68.google.com ([209.85.166.68]:44486 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726201AbeLLCEm (ORCPT ); Tue, 11 Dec 2018 21:04:42 -0500 Received: by mail-io1-f68.google.com with SMTP id r200so13525638iod.11; Tue, 11 Dec 2018 18:04:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=IYDjAh2fffOPQ6dIhZwOJp5LyUcdcAg+jzmXYOjIbPk=; b=W7Y1rMiIO3PXxBvGJXZ/UzWm8Y4s74E1uly8iVy3QW94nxNUxWbhePY9rMIQa/J87q 7BSYIN8QVKpXDDhwU76FSCLxNB5nUwvvzkqDJTslOJkC6YQXcLrgTDedIi5Ho7rHV97p 7CqACRSg3BF8/Zfldy7RUcYjutwtDmnAt/MJltco7s5ebUEQPU3NYzASGHejH5oeZqQP 9wK+ss27XpxEjuGMP4NksGw00dGZY2rKkV/IQP9kP63PneR7940TWBiOR/O1UjYWsSV8 S1mPxyQJDR+ScMGvhSRtwt23Mv0xGazVWHYkx2r2pJp3/zg7ZTBzhlHv9XBc48n4Wnxj R6uQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=IYDjAh2fffOPQ6dIhZwOJp5LyUcdcAg+jzmXYOjIbPk=; b=XPHsf8M3xZEVvlgHcBt7fWkEgurv0+hBeXXN/iP9F9cm9wWB+ND94xzf08upL9a/C0 lE2OjagDTzBOA0FR/ZL70MvV4M/KyDeMLkOQfHTmKBa0/WyZEt/LviJ/rc9OwEpZskoG GTgV9if+PUsUwtO4oQzBo1w7bAsLePdNj8IprDRNQDhvSfAMck/i6+95qm/ZoK5mwSRy AEmV5PZDVnr/MljS0X1iOnlfOXxMEMGKFnkGsC9R7sc8qlVwfmzP8k+UGM4jnUDWSBLP aKkx72IoTwyHTEhc4uXlvIELtUhwJuakp36Uqm5V35rjCwyvFUJb/ddYy42milSLQPzw DBLQ== X-Gm-Message-State: AA+aEWZeGAQnxsMf9sKb9WIE6IcLFBmxe+I/RqZBfTJJZYKlf7Iy+2eu AOwIcHZ+m29ME9gOzOd4bZZNCEDd1gL8IEpLaSE= X-Received: by 2002:a5d:8989:: with SMTP id m9mr15667867iol.216.1544580280915; Tue, 11 Dec 2018 18:04:40 -0800 (PST) MIME-Version: 1.0 References: <1544445555-17325-1-git-send-email-pawell@cadence.com> <1544445555-17325-3-git-send-email-pawell@cadence.com> <87h8fkmfar.fsf@linux.intel.com> In-Reply-To: From: Peter Chen Date: Wed, 12 Dec 2018 10:04:25 +0800 Message-ID: Subject: Re: [PATCH v1 2/2] usb:cdns3 Add Cadence USB3 DRD Driver To: pawell@cadence.com Cc: balbi@kernel.org, devicetree@vger.kernel.org, Greg Kroah-Hartman , linux-usb@vger.kernel.org, rogerq@ti.com, lkml , adouglas@cadence.com, jbergsagel@ti.com, nsekhar@ti.com, nm@ti.com, sureshp@cadence.com, peter.chen@nxp.com, pjez@cadence.com, kurahul@cadence.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > >> + tmode = le16_to_cpu(ctrl->wIndex); > >> + > >> + if (!set || (tmode & 0xff) != 0) > >> + return -EINVAL; > >> + > >> + switch (tmode >> 8) { > >> + case TEST_J: > >> + case TEST_K: > >> + case TEST_SE0_NAK: > >> + case TEST_PACKET: > >> + cdns3_set_register_bit(&priv_dev->regs->usb_cmd, > >> + USB_CMD_STMODE | > >> + USB_STS_TMODE_SEL(tmode - 1)); > > > >I'm 90% sure this won't work. There's a reason why we only enter the > >requested test mode from status stage. How have you tested this? > What's the reason? It can work although the code is a little different with above, I tested it using USBxHSETT tool at Windows. > From USB spec: > "The transition to test mode must be complete no later than 3 ms after the completion of the status stage of the > request." > But I don't remember any issues with this test on other ours drivers. Maybe status stage > is armed in this case by controller. I have to confirm how it works with hardware team. > Driver doesn't know when status stage was completed. We don't have > any event on status stage completion. I haven't checked it yet with tester on this driver. > > >> + irqreturn_t ret = IRQ_NONE; > >> + unsigned long flags; > >> + u32 reg; > >> + > >> + priv_dev = cdns->gadget_dev; > >> + spin_lock_irqsave(&priv_dev->lock, flags); > > > >you're already running in hardirq context. Why do you need this lock at > >all? I would be better to use the hardirq handler to mask your > >interrupts, so they don't fire again, then used the top-half (softirq) > >handler to actually handle the interrupts. > This controller may be ran at SMP environment, register and flag access needs to be protected among CPUs running. > Yes, spin_lock_irqsave is not necessary here. > > Do you mean replacing devm_request_irq with a request_threaded_irq ? > I have single interrupt line shared between Host, Driver, DRD/OTG. > I'm not sure if it will work more efficiently. > > > > >> + /* check USB device interrupt */ > >> + reg = readl(&priv_dev->regs->usb_ists); > >> + writel(reg, &priv_dev->regs->usb_ists); > >> + > >> + if (reg) { > >> + dev_dbg(priv_dev->dev, "IRQ: usb_ists: %08X\n", reg); > > > >I strongly advise against using dev_dbg() for debugging. Even more so > >inside your IRQ handler. Felipe, I use Dynamic Debug for debugging, and show debug messages with "dmesg" after testing/debugging. I see dwc3 using trace, any benefits for switching to trace? > Ok, It's not necessary in this place, especially, that there is invoked trace point > inside cdns3_check_usb_interrupt_proceed which makes the same. > Peter