Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp1788916rdb; Mon, 8 Jan 2024 10:11:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IFkZaAVNpwtCmwILkYe+091fYgcGS3kgN4DQZRvNMPV6dBgNeVahkP5KDj0/wu+01ktoCsi X-Received: by 2002:a05:622a:19a2:b0:429:9a89:33d with SMTP id u34-20020a05622a19a200b004299a89033dmr1284260qtc.46.1704737477699; Mon, 08 Jan 2024 10:11:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704737477; cv=none; d=google.com; s=arc-20160816; b=ub2TGr+rsSwyOFzpqaKqU2SLBNkiY8NqPHLaUOPzw6FZK1eKi79yUljKdi02h712rU 5hErMJ/FeLQgRzzKFA3NAVmXkz80w7FcOpTKuL/D8Em4zo5It06wWtFZlBANdI+tZPzm cnJySYB8Tyj+rt6VF1ygNN8Cmlv38VZCdBk5ucQ46JjGR5C7BCdl71wPOALTS/Nl/LoL Hry1N8kF5WzZadqFp2B6W0ma8v7RPlfsIO5R0v0XiH8IE4wUV4FAyEg9S/nBxgYb3WjV 42EVxO0wdQhEuPE/97H6p15uLu/CmNN1JIB94mIbs2Zv2mIzd9wSGI83pEznIBJiD/HJ 2reQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=cW3/52u923rUZekNz8/9LAnvs2y92KpYma+wacAjnTE=; fh=MDNFHsEAeUHj5MKT5OOX0uYOvjCuUblpLREQxa22Q8c=; b=a2KOSkCPfeFgt8GblBpO3r6viyEJL292GAP2AQryFCtOQkmvZ0WuRZhNK0ykwBlUWs AUnG98EFvpTvPqqtizLMmPQrD83VpQV0efg/aIsePLB7dNcVc5K3YSBLK6OsYETvwR7D AZHWSr2XyX5Q8yBf0pOUi1zk86aJBdoDria+QF+nmsnz6fmYER3PDRsCFvBS/y2cMFMt M3jAGi+Hl7bIjSqMvLo+E9LVXgCQO686huJOnmDZ31KAKZjCDpGncm7keyB6t1Zs2caO xOqeVFOHQz5VvTiNw2xoy7JD51EPxzbADuyYSsKODj8ScsEHqSfoakp/qVg3ir/5z+eu DK3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=N37iDMzO; spf=pass (google.com: domain of linux-kernel+bounces-19934-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19934-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id f6-20020ac85d06000000b00429975fb2ebsi250072qtx.506.2024.01.08.10.11.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 10:11:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-19934-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=N37iDMzO; spf=pass (google.com: domain of linux-kernel+bounces-19934-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19934-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 753EB1C21E51 for ; Mon, 8 Jan 2024 18:11:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3092755E42; Mon, 8 Jan 2024 18:03:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="N37iDMzO" X-Original-To: linux-kernel@vger.kernel.org Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B672A55C12; Mon, 8 Jan 2024 18:03:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 408BoIoV025456; Mon, 8 Jan 2024 18:02:52 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=qcppdkim1; bh=cW3/52u923rUZekNz8/9L Anvs2y92KpYma+wacAjnTE=; b=N37iDMzOZUq0CKK2SF8XWvW/udLwoKiMXp/Uo Pn7sJx/sybXuhC/NCu/bquS4HPgi/bFNDxxCk5869NIwb+qQRYFMByZ8QCDeEuNI HEieZ7wjQD8K17j2kpRpfY4gEZG5lM0dXFle6a0iZ7LjFsi/khHZUD3OhRTpEjdu vepoRhQo6jaQ+92qALsj0VpMXN0MMXf7TQdVsyINJgrb1dDZ+8atQTmV8fnWR5Vh wy0JCcQ4r5nU5qhlpESyKs/sZGZ2ThuRLVkUQBJVcGmwUAZ2fgFAUH3SyRMghbYx 4yUKxees3RH2Dm5Je4E8oCJ76qfUmQzAgkb1BrxO1MdI1LRsw== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3vgbjyhg5k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 08 Jan 2024 18:02:52 +0000 (GMT) Received: from nalasex01c.na.qualcomm.com (nalasex01c.na.qualcomm.com [10.47.97.35]) by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 408I2Obp027117 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 8 Jan 2024 18:02:24 GMT Received: from hu-bjorande-lv.qualcomm.com (10.49.16.6) by nalasex01c.na.qualcomm.com (10.47.97.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Mon, 8 Jan 2024 10:02:24 -0800 Date: Mon, 8 Jan 2024 10:02:23 -0800 From: Bjorn Andersson To: Johan Hovold CC: Bjorn Andersson , Konrad Dybcio , Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Wesley Cheng , Thinh Nguyen , Felipe Balbi , Philipp Zabel , , , , , Krishna Kurapati PSSNV Subject: Re: [PATCH 06/12] usb: dwc3: qcom: Add dwc3 core reference in driver state Message-ID: <20240108180223.GK1315173@hu-bjorande-lv.qualcomm.com> References: <20231016-dwc3-refactor-v1-0-ab4a84165470@quicinc.com> <20231016-dwc3-refactor-v1-6-ab4a84165470@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: X-ClientProxiedBy: nalasex01a.na.qualcomm.com (10.47.209.196) To nalasex01c.na.qualcomm.com (10.47.97.35) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: TW63nP16Eh9jn7-rOIH8U91wuAlO_iug X-Proofpoint-ORIG-GUID: TW63nP16Eh9jn7-rOIH8U91wuAlO_iug X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-09_02,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 malwarescore=0 mlxlogscore=999 impostorscore=0 bulkscore=0 phishscore=0 suspectscore=0 adultscore=0 spamscore=0 clxscore=1015 priorityscore=1501 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311290000 definitions=main-2401080153 On Wed, Nov 22, 2023 at 01:18:33PM +0100, Johan Hovold wrote: > On Mon, Oct 16, 2023 at 08:11:14PM -0700, Bjorn Andersson wrote: > > In the coming changes the Qualcomm DWC3 glue will be able to either > > manage the DWC3 core as a child platform_device, or directly instantiate > > it within its own context. > > > > Introduce a reference to the dwc3 core state and make the driver > > reference the dwc3 core either the child device or this new reference. > > > > As the new member isn't assigned, and qcom->dwc_dev is assigned in all > > current cases, the change should have no functional impact. > > > > Signed-off-by: Bjorn Andersson > > --- > > drivers/usb/dwc3/dwc3-qcom.c | 100 +++++++++++++++++++++++++++++++++++-------- > > 1 file changed, 83 insertions(+), 17 deletions(-) > > > > diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c > > index 7c810712d246..901e5050363b 100644 > > --- a/drivers/usb/dwc3/dwc3-qcom.c > > +++ b/drivers/usb/dwc3/dwc3-qcom.c > > @@ -67,7 +67,8 @@ struct dwc3_acpi_pdata { > > struct dwc3_qcom { > > struct device *dev; > > void __iomem *qscratch_base; > > - struct platform_device *dwc_dev; > > + struct platform_device *dwc_dev; /* only used when core is separate device */ > > + struct dwc3 *dwc; /* not used when core is separate device */ > > Hmm. This quickly become really messy and hard to maintain. It may be > fine as an intermediate step as part of this series, but why can't you > do the conversion fully so that the Qualcomm glue driver never registers > a core platform device? Is it just about where the core driver looks for > DT properties? > In the new driver model, pdev->dev.of_node needs to contain the resources for both the glue and the core. For most of the information, that's a matter of copying properties and child nodes from the child of_node, but e.g. reg and interrupts needs to be merged. As mentioned in my other reply, extcon is serviced to both nodes, so without the callbacks that will break, at least - and I'd have to check to see if the of_graphs can be handled... That said, part of the reason for doing this shuffle is to make sure that dwc is always a valid pointer, and while keeping this scheme of two modes we will not be able to assume this anywhere in the code - and hence continue to rely on luck. One way around this would be to follow the of_platform_populate() with a check to see if the core was registered and if so grab the dwc pointer, otherwise of_platform_depopulate() the core again and probe defer. It will come with a penalty for devices running on the old binding, and we don't protect ourselves from the core being unbound while we're holding a pointer to its internal data. But it looks like a much better position to me. (In this case I think dwc_dev becomes a local variable using during probe, and the rest of the code would operate on dwc) Regards, Bjorn