Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4595405iob; Sun, 8 May 2022 18:37:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzPS/N4cnzcl76cxezN8R0VEha9fhWD4G28z6w+HQJTaPIUnX9yKwMlgo0X/N8yNGW6I8Uf X-Received: by 2002:a17:90a:5515:b0:1dc:c1f1:59bd with SMTP id b21-20020a17090a551500b001dcc1f159bdmr20300155pji.81.1652060238013; Sun, 08 May 2022 18:37:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652060238; cv=none; d=google.com; s=arc-20160816; b=ESqFphHUb01ps6rSbZQPrilTG9inwIod78ZGcL7RhiwJLrFGxcZ0IkN0eKhkel8Nvi CXRNP7hjw88XeyyOOiN6qr2BTeYE34fX8pxf4Rjdi7qS9IVq2R/zX1bu23oYAJ7xBGwn BLu9R/5/IKWJNfY6tRHws+8R1AAKmHIsucw8spTrgMS5mQFNblDEKqC6jCS5LKNQFSyP 89iBdNpAzr7ZxqgU+0lAytuYojnS5UM5p4VYBmu8Px2mHUFaF5/H3Jfv8CasarUaJqoz +VmlvFMUlAN+p5vZp4BJ61NLYDITk9Z/My3fQ05wx5izMTlEZGbZ8sNXeFX5jg9hX7p2 aeFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=QsLmijEooSiXfbLfva7oeI6L4KtnWX5pjKwE7m2Q6CM=; b=ga7qhm//mFEq4vTbNZ63FF31LRBzFo7i1yPKSZ6C1EkTyJBtUrwNWSeLP9jraGoEgN F/M8tdNRErWA+cZSTxboKUjMUO2E/4XLeIbqSwyim+g9JT98sH7cv66izHS3i4j9cx16 dDTsOMpPPC0GmQRvE+d2vZpWqd01mXW1xKiAdhT/vhIbYHj++DHlgCMQgk19tboSGls/ wk8psnq5kWEBdAen0WDL0Y72p7GRWa2pc30ed+cZVPqRmBCPONpFCkrRpbiXtGNnBh7s NYW54vXOhiOuVD4agfdRmoU/kyaSMCRdTmqdo3kzT1Tw/b7czdPVrrvRmEsuy5XDB6Bk ElnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HLY18bGt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id x7-20020a170902a38700b0015d3c09862bsi9823401pla.225.2022.05.08.18.37.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 18:37:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HLY18bGt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 09E3235275; Sun, 8 May 2022 18:36:54 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1382501AbiEFGte (ORCPT + 99 others); Fri, 6 May 2022 02:49:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385495AbiEFGtZ (ORCPT ); Fri, 6 May 2022 02:49:25 -0400 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BB6C1B79C for ; Thu, 5 May 2022 23:45:42 -0700 (PDT) Received: by mail-ed1-x531.google.com with SMTP id d6so7592680ede.8 for ; Thu, 05 May 2022 23:45:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=QsLmijEooSiXfbLfva7oeI6L4KtnWX5pjKwE7m2Q6CM=; b=HLY18bGtl3gXLNmbQUg99B1iBQLAwTI73xDls7bmlM7Atl1v7DmFE2PcTvy7fRqWv3 cVhBk4+6E7fhI09kT9VcDaHgJEs7KhTzCOS/sSCWmLq4aaxu0dUWkcWIEIDKsruo1S8z xhK+foqGRyepaKwC0aGsRiehU6B0IVGHpEnIeA5aN90KrxEd+Ia/da5kznhDU/kMrSPd jhUdlfcEUJOtuSA7modVtdyfgruNGmXYgarew9GNKSSuv4JnBenYLBYvd+mgwbKgWhhB PuMJcztI0/op/SKdzU/gFZKbXROKSUWhKeGavhMaGOpomqJHv63pRFmhEuDjF9icILzv N2sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=QsLmijEooSiXfbLfva7oeI6L4KtnWX5pjKwE7m2Q6CM=; b=QT+pf5iRmAOoE3gZiGaIpLS/3tncRhl5bjtG2oCuYgsUih9nRDGxWvuOVBQpHDBOlO fiwak7Eub4aETHHRYibFwAPLxXBLQkoQ4YMzgqmRtA7LF1vuRfWdbGQyvGQrE30J3DiU yU5A2fNuBDkCPLjwZVrqoFnKVV4Vm6QjU3wLO2CL9Co52tD+kLITEwP2wZcFoDgdbFqH FarSGx+UYMDZP+AKdJmSZVE6tzCTZENyVc56xgXC/r/kmj9Mf/yzaumLaxeQeUVEZMwh 9JANdVOxz8mCoYdQkxjdI9I2m8Zv/+VovnO1CloxzyajPaUHcdPQbHXs0Kh4Mt2dIr9E 15vw== X-Gm-Message-State: AOAM530SqvLj119ABIOY7t7YAbAV3jIWQaGoVROstURmRD8ULp7QpMFa hytZoT3P8V3Z+YnRrYGlbJ+zAQ== X-Received: by 2002:a05:6402:1115:b0:427:e77b:a70e with SMTP id u21-20020a056402111500b00427e77ba70emr1983121edv.320.1651819541183; Thu, 05 May 2022 23:45:41 -0700 (PDT) Received: from [192.168.0.222] (xdsl-188-155-176-92.adslplus.ch. [188.155.176.92]) by smtp.gmail.com with ESMTPSA id y5-20020a50f1c5000000b0042617ba63afsm1850341edl.57.2022.05.05.23.45.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 05 May 2022 23:45:40 -0700 (PDT) Message-ID: <584df17c-3ffc-4290-a2dd-c803987dccfe@linaro.org> Date: Fri, 6 May 2022 08:45:39 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Subject: Re: [PATCH RFC v5 6/6] usb: dwc3: dwc3-exynos: add host init Content-Language: en-US To: Daehwan Jung , Felipe Balbi , Greg Kroah-Hartman , Alim Akhtar , Mathias Nyman , Lukas Bulwahn , Tony Lindgren , Juergen Gross , Arnd Bergmann , Matthias Kaehlcke Cc: open list , "open list:DESIGNWARE USB3 DRD IP DRIVER" , "moderated list:ARM/SAMSUNG S3C, S5P AND EXYNOS ARM ARCHITECTURES" , "open list:ARM/SAMSUNG S3C, S5P AND EXYNOS ARM ARCHITECTURES" , sc.suh@samsung.com, taehyun.cho@samsung.com, jh0801.jung@samsung.com, eomji.oh@samsung.com References: <1651818679-10594-1-git-send-email-dh10.jung@samsung.com> <1651818679-10594-7-git-send-email-dh10.jung@samsung.com> From: Krzysztof Kozlowski In-Reply-To: <1651818679-10594-7-git-send-email-dh10.jung@samsung.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/05/2022 08:31, Daehwan Jung wrote: > This is for xHCI Host Controller driver on Exynos SOC. https://elixir.bootlin.com/linux/v5.17.1/source/Documentation/process/submitting-patches.rst#L95 > It registers vendor ops before loading xhci platform driver. It does not explain why do you need it, why do you do it, what is this going to achieve or give us. > > Signed-off-by: Daehwan Jung > --- > drivers/usb/dwc3/dwc3-exynos.c | 100 ++++++++++++++++++++++++++++++++- > 1 file changed, 99 insertions(+), 1 deletion(-) > > diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-exynos.c > index 0ecf20eeceee..c22ea5cd6ab0 100644 > --- a/drivers/usb/dwc3/dwc3-exynos.c > +++ b/drivers/usb/dwc3/dwc3-exynos.c > @@ -17,6 +17,12 @@ > #include > #include > > +#include "core.h" > + > +#if IS_ENABLED(CONFIG_USB_XHCI_EXYNOS) This symbol does not exist at this point, so your patch does not look like correctly ordered. > +int xhci_exynos_register_vendor_ops(void); > +#endif > + > #define DWC3_EXYNOS_MAX_CLOCKS 4 > > struct dwc3_exynos_driverdata { > @@ -27,6 +33,7 @@ struct dwc3_exynos_driverdata { > > struct dwc3_exynos { > struct device *dev; > + struct dwc3 *dwc; > > const char **clk_names; > struct clk *clks[DWC3_EXYNOS_MAX_CLOCKS]; > @@ -46,12 +53,81 @@ static int dwc3_exynos_remove_child(struct device *dev, void *unused) > return 0; > } > > +#if IS_ENABLED(CONFIG_USB_XHCI_EXYNOS) > +static int dwc3_exynos_host_init(struct dwc3_exynos *exynos) > +{ > + struct dwc3 *dwc = exynos->dwc; > + struct device *dev = exynos->dev; > + struct platform_device *xhci; > + struct resource *res; > + struct platform_device *dwc3_pdev = to_platform_device(dwc->dev); > + int ret = 0; > + > + /* Configuration xhci resources */ > + xhci_exynos_register_vendor_ops(); Why this is always being called? Runtime features should not be added like that. > + > + res = platform_get_resource(dwc3_pdev, IORESOURCE_MEM, 0); > + if (!res) { > + dev_err(dev, "missing memory resource\n"); > + return -ENODEV; > + } > + dwc->xhci_resources[0].start = res->start; > + dwc->xhci_resources[0].end = dwc->xhci_resources[0].start + > + DWC3_XHCI_REGS_END; > + dwc->xhci_resources[0].flags = res->flags; > + dwc->xhci_resources[0].name = res->name; > + > + res = platform_get_resource(dwc3_pdev, IORESOURCE_IRQ, 0); > + if (!res) { > + dev_err(dev, "missing irq resource\n"); > + return -ENODEV; > + } > + > + dwc->xhci_resources[1].start = dwc->irq_gadget; > + dwc->xhci_resources[1].end = dwc->irq_gadget; > + dwc->xhci_resources[1].flags = res->flags; > + dwc->xhci_resources[1].name = res->name; > + > + xhci = platform_device_alloc("xhci-hcd", PLATFORM_DEVID_AUTO); > + if (!xhci) { > + dev_err(dwc->dev, "couldn't allocate xHCI device\n"); > + return -ENOMEM; > + } > + > + xhci->dev.parent = dwc->dev; Remove any duplicates spaces/tabs which should not be in the code (no need for indenting '='). > + ret = dma_set_mask_and_coherent(&xhci->dev, DMA_BIT_MASK(36)); > + if (ret) { > + pr_err("xhci dma set mask ret = %d\n", ret); > + return ret; > + } > + > + ret = platform_device_add_resources(xhci, dwc->xhci_resources, > + DWC3_XHCI_RESOURCES_NUM); But this should be properly indented, how checkpatch asks. > + if (ret) { > + dev_err(dwc->dev, "couldn't add resources to xHCI device\n"); > + goto err; > + } > + > + ret = platform_device_add(xhci); > + if (ret) { > + dev_err(dwc->dev, "couldn't add xHCI device\n"); > + goto err; > + } > + > + return 0; > +err: > + platform_device_put(xhci); > + return ret; > +} > +#endif > + > static int dwc3_exynos_probe(struct platform_device *pdev) > { > struct dwc3_exynos *exynos; > struct device *dev = &pdev->dev; > - struct device_node *node = dev->of_node; > + struct device_node *node = dev->of_node, *dwc3_np; > const struct dwc3_exynos_driverdata *driver_data; > + struct platform_device *dwc3_pdev; > int i, ret; > > exynos = devm_kzalloc(dev, sizeof(*exynos), GFP_KERNEL); > @@ -109,6 +185,12 @@ static int dwc3_exynos_probe(struct platform_device *pdev) > goto vdd10_err; > } > > + dwc3_np = of_get_compatible_child(node, "snps,dwc3"); > + if (!dwc3_np) { > + dev_err(dev, "failed to find dwc3 core child!\n"); Please keep messages consistent with other, so start with capital letter and do not shout. > + goto vdd33_err; > + } > + > if (node) { > ret = of_platform_populate(node, NULL, NULL, dev); > if (ret) { > @@ -121,6 +203,22 @@ static int dwc3_exynos_probe(struct platform_device *pdev) > goto populate_err; > } > > + dwc3_pdev = of_find_device_by_node(dwc3_np); > + exynos->dwc = platform_get_drvdata(dwc3_pdev); Driver should not poke into its child. You violate device layering here. No, no. This is a glue driver, not a "let's do something inside DWC3" driver. > + if (!exynos->dwc) { > + ret = -EPROBE_DEFER; > + dev_err(dev, "failed to get dwc3 core node!\n"); Again no reason for shouting. > + goto populate_err; > + } > + > +#if IS_ENABLED(CONFIG_USB_XHCI_EXYNOS) > + /* USB host initialization. */ > + ret = dwc3_exynos_host_init(exynos); > + if (ret) { > + dev_err(dev, "USB host pre-initialization fail!\n"); > + goto populate_err; > + } > +#endif > return 0; > > populate_err: Best regards, Krzysztof