Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1534275imu; Thu, 13 Dec 2018 17:36:20 -0800 (PST) X-Google-Smtp-Source: AFSGD/Xz5HycOg9GmZnxeMlGf39l66dPSNvf+BePCeJ+SzyLyiAQ2wjxh4qBbCoAIseBtkQ1S6Sp X-Received: by 2002:a17:902:1d4a:: with SMTP id u10mr1024086plu.122.1544751380148; Thu, 13 Dec 2018 17:36:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544751380; cv=none; d=google.com; s=arc-20160816; b=zuCHSTqEsQ2TxM3S215Wne6E/iPJGjK5FYbTT83BsXGx4GFObt8+53oocaBVT1iOqQ hYA0f686TtfQhykM1zbHTj+mLigV1TnfIEZT30ISyt7AjLTnS498ZulFsQbpL0wHaq14 Aat2D88H8DuEt48FxnUgGZapap3/KUszh/gg3Pt8KHiV/cdmGE4JkhVUek6D6a1mctQ1 rauzpTu/TW+Yb6pHkmZ45/gtRpw/K+fXIP6XDM81vGUfzDMRsZ3nCUslElQ0TEdRvCtn yLg2zp+G2iww7+kblHYvrxeS9Tc94ybsRrbegZ/uRLo7bjfmn5p7y3kHPODTJZm7150C o1yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=S8rmiMd94574Ryr5fqpe0AjQ+3eIiRjc9sdUxU2AJ4M=; b=A7sS2eyP9VzSgu1gW0oNBb5rLbKWd5MZgPqZXr0RpR7KLjCYakUHe7rOUjSQEJNjLF 7lMaj2BoS0ZwL251qGi32FRjdPTFD1ZLxpW/li5K0OvjoSSMX/ZfBqpBqabfTaas50q7 aRmOUpp9fSdKqElWwTD0hp7UFFp3+/iDr19wpNXAYJCbmucV7YFt1QKGf/XIKZRRar30 HHETj+a+lUWzqa2rUN/+nT+bcv6rlraxP/TcZ9DCLbspmN91b6ofeUyJM9vyKJzRcOtm hDUCBWVl6NUev4tZrm/3voiMARg+iWoWTYGexRG9CLLladQUZdLC412HwRZFa42k34LX +IFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=He88ijGh; 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 x61si2848531plb.303.2018.12.13.17.36.04; Thu, 13 Dec 2018 17:36:20 -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=He88ijGh; 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 S1729075AbeLNBef (ORCPT + 99 others); Thu, 13 Dec 2018 20:34:35 -0500 Received: from mail-it1-f193.google.com ([209.85.166.193]:36380 "EHLO mail-it1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727654AbeLNBee (ORCPT ); Thu, 13 Dec 2018 20:34:34 -0500 Received: by mail-it1-f193.google.com with SMTP id c9so7064275itj.1; Thu, 13 Dec 2018 17:34:33 -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:content-transfer-encoding; bh=S8rmiMd94574Ryr5fqpe0AjQ+3eIiRjc9sdUxU2AJ4M=; b=He88ijGhz+a8RgLEVPFs9hN1pRfvaPCcLTttnqZyG5bpko+FxEwXO2ktGvCuT6Mc+9 uihQ6kCkBqksPjAxVyxvtOAvjIhhXbQ/aGIED+ZzxoI9bHGbQisyOIahSx09RfOCURFS DX39odli1IzMkcQYIZC3tb693/RB0ltS1Lknt8b1ieWQDR0+93pe7sOYpU9uOlZSuRKW s41dUJBAYeUFKbF4iV8jJCUIU4qkmKqs647VFr/AnheK9aCLWWGFq/qfV721U7AFZb49 xgIsNCm/LWu1w46kPJ0AzlPhsotAf0eOw+MaDLZkM7ppq/8n29i8B8cGL/06Lin9IvUV MnxA== 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:content-transfer-encoding; bh=S8rmiMd94574Ryr5fqpe0AjQ+3eIiRjc9sdUxU2AJ4M=; b=eH0uAfC3jF3a58QVdduZqA8w5jtqYH8vW42//aqvWAOjmn9ZmuiERRt2Gi495Ax0iD QYkO1Vkma/BPcGNAg/RZmSbHYnwBd68AAkdbUKB2Tgs0lqtdE/MV9+vKQqpYFnkqpG1a VhBSFM0AQyPgA5g1GGPlq7Z+spmeiCdW/xm79Wi5KWazw5i3uWRK+yqa0TA5+lT64ZuW V5fiDuYtuw/toNicNj1qstOoCzZ5MrwT6WqaFkbolxse8Ig1dZFrCyYSgOx587YRIEn2 G48sEbx+StVmyOym+oOhrkv0W9fvaUv7FgyMxXN+n3bvIp8Z2nqK8KPAr9A7wzGDRvmY uxSw== X-Gm-Message-State: AA+aEWbn5b96eGgvW4RIz4zdLggn5BrV52pGAv9Hid3cJzFJgaiDN3Xx pX3u3PLDC91tNJvmhW4ZOeVICiic129YrYT534E= X-Received: by 2002:a24:c601:: with SMTP id j1mr1711528itg.130.1544751273593; Thu, 13 Dec 2018 17:34:33 -0800 (PST) MIME-Version: 1.0 References: <1542535751-16079-1-git-send-email-pawell@cadence.com> <1542535751-16079-9-git-send-email-pawell@cadence.com> <5BFE8883.7090802@ti.com> <6b19b55c-66d7-439e-df8f-7b311b45af5e@ti.com> In-Reply-To: From: Peter Chen Date: Fri, 14 Dec 2018 09:34:21 +0800 Message-ID: Subject: Re: [RFC PATCH v2 08/15] usb:cdns3: Implements device operations part of the API To: pawell@cadence.com Cc: nsekhar@ti.com, rogerq@ti.com, devicetree@vger.kernel.org, Greg Kroah-Hartman , linux-usb@vger.kernel.org, lkml , adouglas@cadence.com, jbergsagel@ti.com, nm@ti.com, sureshp@cadence.com, peter.chen@nxp.com, pjez@cadence.com, kurahul@cadence.com, balbi@kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Dec 12, 2018 at 3:49 AM Pawel Laszczak wrote: > > Hi, > > >On 10/12/18 7:42 AM, Peter Chen wrote: > >>>> +static struct usb_ep *cdns3_gadget_match_ep(struct usb_gadget *gadg= et, > >>>> + struct usb_endpoint_descri= ptor *desc, > >>>> + struct usb_ss_ep_comp_desc= riptor *comp_desc) > >>>> +{ > >>>> + struct cdns3_device *priv_dev =3D gadget_to_cdns3_device(gadge= t); > >>>> + struct cdns3_endpoint *priv_ep; > >>>> + unsigned long flags; > >>>> + > >>>> + priv_ep =3D cdns3_find_available_ss_ep(priv_dev, desc); > >>>> + if (IS_ERR(priv_ep)) { > >>>> + dev_err(&priv_dev->dev, "no available ep\n"); > >>>> + return NULL; > >>>> + } > >>>> + > >>>> + dev_dbg(&priv_dev->dev, "match endpoint: %s\n", priv_ep->name)= ; > >>>> + > >>>> + spin_lock_irqsave(&priv_dev->lock, flags); > >>>> + priv_ep->endpoint.desc =3D desc; > >>>> + priv_ep->dir =3D usb_endpoint_dir_in(desc) ? USB_DIR_IN : USB= _DIR_OUT; > >>>> + priv_ep->type =3D usb_endpoint_type(desc); > >>>> + > >>>> + list_add_tail(&priv_ep->ep_match_pending_list, > >>>> + &priv_dev->ep_match_list); > >>>> + spin_unlock_irqrestore(&priv_dev->lock, flags); > >>>> + return &priv_ep->endpoint; > >>>> +} > >>> Why do you need a custom match_ep? > >>> doesn't usb_ep_autoconfig suffice? > >>> > >>> You can check if EP is claimed or not by checking the ep->claimed fla= g. > >>> > >> It is a special requirement for this IP, the EP type and MaxPacketSize > >> changing can't be done at runtime, eg, at ep->enable. See below commit > >> for detail. > >> > >> usb: cdns3: gadget: configure all endpoints before set configurati= on > >> > >> Cadence IP has one limitation that all endpoints must be configure= d > >> (Type & MaxPacketSize) before setting configuration through hardwa= re > >> register, it means we can't change endpoints configuration after > >> set_configuration. > >> > >> In this patch, we add non-control endpoint through usb_ss->ep_matc= h_list, > >> which is added when the gadget driver uses usb_ep_autoconfig to co= nfigure > >> specific endpoint; When the udc driver receives set_configurion re= quest, > >> it goes through usb_ss->ep_match_list, and configure all endpoints > >> accordingly. > >> > >> At usb_ep_ops.enable/disable, we only enable and disable endpoint = through > >> ep_cfg register which can be changed after set_configuration, and = do > >> some software operation accordingly. > > > >All this should be part of comments in code along with information about > >controller versions which suffer from the errata. > > > >Is there a version of controller available which does not have the > >defect? Is there a future plan to fix this? > > > >If any of that is yes, you probably want to handle this with runtime > >detection of version (like done with DWC3_REVISION_XXX macros). > >Sometimes the hardware-read versions themselves are incorrect, so its > >better to introduce a version specific compatible too like > >"cdns,usb-1.0.0" (as hinted to by Rob Herring as well). > > > > custom match_ep is used and works with all versions of the gen1 > controller. Future (gen2) releases of the controller won=E2=80=99t have s= uch > limitation but there is no plan to change current (gen1) functionality > of the controller. > > I will add comment before cdns3_gadget_match_ep function. > Also I will change cdns,usb3 to cdns,usb3-1.0.0 and add additional > cdns,usb3-1.0.1 compatible. > > cdns,usb3-1.0.1 will be for current version of controller which I use. > cdns,usb3-1.0.0 will be for older version - Peter Chan platform. > I now that I have some changes in controller, and one of them require > some changes in DRD driver. It will be safer to add two separate > version in compatibles. > Pawel, could we have correct register to show controller version? It is better we could version judgement at runtime instead of static compatible. Peter