Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1D96AC61DB9 for ; Fri, 28 Aug 2026 09:35:25 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wzszS-00076G-9F; Fri, 28 Aug 2026 05:35:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wzszQ-00072v-NH for qemu-arm@nongnu.org; Fri, 28 Aug 2026 05:35:12 -0400 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wzszO-0008Qp-Sv for qemu-arm@nongnu.org; Fri, 28 Aug 2026 05:35:12 -0400 Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 67S675ES2515556 for ; Fri, 28 Aug 2026 09:35:09 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= QxLaD4ow/Db+lS11uQhy12T3ZTeX4yo4W/e+BsAVqcU=; b=BGCbGV60MFxZtdWM aA+RQNJObW0REMju4grjeAA2O4MVq/w38zhaeFo7BjHvA4p/nNGiNXe/JZtth2ep bGigwzVeizIgkntnGrmqpxYjeahbpIRX02D7AOTNcXM5aGTwPGzVxjSIExiFI6u3 iJMCj3nYTTQtMr3ce3U9vLsJzYp5iudOvIQpCAShoXhXOXZUUFzfbMjbVf4cejbW ye9m3vUh3yvu+GX8vrls98D2joHynDjaJpATNQVoktpaybmj8y9+Kd5HJ1nnrI2C 5dxu3hBLVNhcwvcfVOcBqH+PWSyC32kBmyKezzKdVj66/rpvw/BTZwgZpQRYplaE E0IAJg== Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4gb47n0xv0-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 28 Aug 2026 09:35:08 +0000 (GMT) Received: by mail-qt1-f199.google.com with SMTP id d75a77b69052e-52ff14b1c02so1226621cf.2 for ; Fri, 28 Aug 2026 02:35:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1787909708; x=1788514508; darn=nongnu.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=QxLaD4ow/Db+lS11uQhy12T3ZTeX4yo4W/e+BsAVqcU=; b=HauVwk3Nd2vbgRYnpQECbgODaA4J3IhnmGqpxwvtcBCxbYSR9GAni9T7SlHY094jeC z+MAljIBbkZMtF6VajakS26meUJl2TnaIIuVUjy4rW0jQ/CYr7uGn/zNMaxfSgftvnYX 8YTKH6hH6yhP+krrQVtEGH6pMzjng5cB+bHXuaNvnK/SGz4IocTYcf6lEiSR4q0eiLlc Z9gEa1UA9uDtARZzsqGspCswNZh5QdQbey2pjVdsn3aMKbo1RkfVLmrlcEgZXoIEacNJ EGOSY7WZI8DRTF2wa9n+w17Z+4ci+YWflkz+KxyKw8hdm4KivvePeG+cD5VkcNBRV2dR +4LA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787909708; x=1788514508; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=QxLaD4ow/Db+lS11uQhy12T3ZTeX4yo4W/e+BsAVqcU=; b=WueaehVAa+ReBzzBXmciws7/9Fe8C6wKkxNRtxbvqi6msa4NodWCZ2Leso2G/aU7sC mqKZBPb4oDMGlMk30d2Hw1bMLgNeTb3yPPrw7NZHlw4cAezmove3bVcXPKcVm9ltg9+M rTSjVw0KHW+hFPf4UhbBNOq5vKx4zu4MwUp3JTWkzYDdR0jNuu3RLsoJHjUxCsFHJK00 iV9vMZ9i6VyhhEXB2Gwy1038oQR8NZSHoVe9UYSgXHIqBWsBcYml8GUtoONE1R1ZdxpY HaF+xmgacPd8qb5EeOw8Wu4ck0hG6g35WPD+Wu4B6nRpPduqQg/8cGvZ6RzVeHzy5odW Vljw== X-Forwarded-Encrypted: i=1; AHgh+Ro/2GLBa8YAjD4Kk1BU5G2AWPFBBHPN0d+BPBWbu/ZjdwJ6c0HKyn7EszZPnDt6H5bqqfbQP16tPA==@nongnu.org X-Gm-Message-State: AFuF++k82J9P/cVsEe3CiUDq9GfZNuLv+kFl9w6sM/Mq62R040qSCUv6 WnWXreOB71qTFiciAdqonxEoVTZ5OAe9H1Dy/JMnnLxqmrfzIEkgqiZ/8XsFeQzKDC1Ho4hNuz9 pl0Y2m0VpS7gxnPHOT1v/0BjXZPwjfqxpHgAWd5WuPnUr+e8MUA0a9xB9KQGFJ2k= X-Gm-Gg: AR+sD136O55Lr2SCavsNNHEUIllzzreaNcfPJIgLi1zumTZP2cQLYExUGTV4X86nXdD 5hqmJ7P113Nd9TmSM6danxDpaKe+wi2QoLDzA7KPg5/Q8QffGSUutMsVUWgWcmAYcGQ+hUPAfik L3lPqXqG2Zr5LmUV2ZX5raQtFIEyDdXzXvxL88r6ARKJM58ey2k7dqfhrquiCEYuvTcgmASSEke GAan7oYNePBGKE0F06/IKDY5rHPKVseLoXfJK2CpjULhgle1ll6XCLCKi5JHJSgg/0UIoZHe+Zg sUBcBiJGimXSbdrSFzU55LfcfCVARxn7MqFbCQwwenjJFLtsqXU8GXZb1iN5cNUGTeJ0u79tgq7 2VuniD23sGLqxGY9f7NUP X-Received: by 2002:a05:622a:89:b0:52f:a2b2:2dcb with SMTP id d75a77b69052e-52fb9445df4mr54622081cf.18.1787909707933; Fri, 28 Aug 2026 02:35:07 -0700 (PDT) X-Received: by 2002:a05:622a:89:b0:52f:a2b2:2dcb with SMTP id d75a77b69052e-52fb9445df4mr54621661cf.18.1787909707382; Fri, 28 Aug 2026 02:35:07 -0700 (PDT) Received: from [192.168.0.4] ([79.127.134.41]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-482fbb2794dsm2769830f8f.25.2026.08.28.02.35.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 28 Aug 2026 02:35:06 -0700 (PDT) Message-ID: Date: Fri, 28 Aug 2026 11:35:03 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 2/4] hw/usb/aspeed-udc: Add ASPEED UDC gadget USB device To: Jamin Lin , Paolo Bonzini , Peter Maydell , =?UTF-8?Q?C=C3=A9dric_Le_Goater?= , Steven Lee , Troy Lee , Kane Chen , Andrew Jeffery , Joel Stanley , "open list:ARM TCG CPUs" , "open list:All patches CC here" Cc: Troy Lee References: <20260828090412.981841-1-jamin_lin@aspeedtech.com> <20260828090412.981841-3-jamin_lin@aspeedtech.com> Content-Language: en-US From: =?UTF-8?Q?Philippe_Mathieu-Daud=C3=A9?= In-Reply-To: <20260828090412.981841-3-jamin_lin@aspeedtech.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Authority-Analysis: v=2.4 cv=a8YAM0SF c=1 sm=1 tr=0 ts=6a91564c cx=c_pps a=WeENfcodrlLV9YRTxbY/uA==:117 a=gmLkG3rbZGp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2n X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-28_02,2026-08-27_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 phishscore=0 impostorscore=0 lowpriorityscore=0 bulkscore=0 spamscore=0 malwarescore=0 priorityscore=1501 suspectscore=0 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608280081 Received-SPF: pass client-ip=205.220.180.131; envelope-from=philmd@oss.qualcomm.com; helo=mx0b-0031df01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-arm@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-arm-bounces+qemu-arm=archiver.kernel.org@nongnu.org Sender: qemu-arm-bounces+qemu-arm=archiver.kernel.org@nongnu.org Hi Jamin, On 2026-08-28 11:04, Jamin Lin wrote: > Present the UDC gadget side to a USB host controller as a USB device > (TYPE_ASPEED_UDC_GADGET). This is a normal QEMU USB device, so it can be > attached to any USB host controller bus, not only the BMC's own EHCI. It > links back to its controller through the "udc" property. > > This patch implements the control endpoint (EP0), which is enough for the > host to enumerate the gadget. Host control transfers are handled > asynchronously: the SETUP packet is mirrored into the SETUP data buffer, > the EP0 interrupt is raised and the host packet is parked (USB_RET_ASYNC). > The guest gadget driver then drives the data and status stages by writing > UDC_EP0_CTRL; that moves data to/from the driver's DMA buffer and completes > the parked packet back to the host. > > SET_ADDRESS is the exception: it is applied synchronously, because the host > controller keeps the transfer bound to address 0 until it completes. > > The gadget connects to / disconnects from the host bus when the driver > sets or clears the upstream-enable (pull-up) bit, and is detached on reset. > > Signed-off-by: Jamin Lin > --- > include/hw/usb/aspeed-udc.h | 28 +++ > hw/usb/aspeed-udc.c | 360 +++++++++++++++++++++++++++++++++++- > hw/usb/trace-events | 5 + > 3 files changed, 390 insertions(+), 3 deletions(-) > > diff --git a/include/hw/usb/aspeed-udc.h b/include/hw/usb/aspeed-udc.h > index 58fed5f9a2..ab9d016c61 100644 > --- a/include/hw/usb/aspeed-udc.h > +++ b/include/hw/usb/aspeed-udc.h > @@ -10,11 +10,19 @@ > #define HW_USB_ASPEED_UDC_H > > #include "hw/core/sysbus.h" > +#include "hw/usb/usb.h" > #include "qom/object.h" > > #define TYPE_ASPEED_UDC "aspeed.udc" > OBJECT_DECLARE_SIMPLE_TYPE(AspeedUDCState, ASPEED_UDC) > > +/* > + * The gadget side of the controller is presented to a USB host controller's > + * bus as a single USB device that delegates back to the AspeedUDCState. > + */ > +#define TYPE_ASPEED_UDC_GADGET "aspeed.udc-gadget" > +OBJECT_DECLARE_SIMPLE_TYPE(AspeedUDCGadget, ASPEED_UDC_GADGET) > + > /* > * Register map: root/global block at 0x000 - 0x087, then one 0x10 byte bank > * per programmable endpoint from 0x200. > @@ -36,14 +44,34 @@ typedef struct AspeedUDCEP { > int index; > } AspeedUDCEP; > > +struct AspeedUDCGadget { > + USBDevice parent_obj; > + AspeedUDCState *udc; > +}; > + > struct AspeedUDCState { > SysBusDevice parent_obj; > > MemoryRegion udc_container; > MemoryRegion root_mr; > + MemoryRegion *dram_mr; > + AddressSpace dram_as; > uint32_t regs[ASPEED_UDC_ROOT_NR_REGS]; > AspeedUDCEP ep[ASPEED_UDC_NUM_EP]; > qemu_irq irq; > + > + /* gadget USB device bound to this controller (set at its realize) */ > + AspeedUDCGadget *usbgadget; Do you mind exposing this as a link property (and using the proper methods to set it)? > + > + /* > + * In-flight EP0 control transfer (host side), deferred until the guest > + * gadget driver responds via MMIO. > + */ > + USBPacket *ep0_packet; > + uint32_t ep0_setup_len; > + uint32_t ep0_offset; > + uint8_t *ep0_data; > + bool ep0_dir_in; > };