From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=195.135.223.130 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796201093; b=ei4rqW2Qvmt/Rme9c4veohSvYheAt+1Pl41NYimjH71ITheDR+9rIDELbpHKM5KhEAGp X3Y34mI/8uorZQ+LiSpuYyWhXGmYDGuF4eTpEhcLZKxMDGc0eIf2ckeSfpznw+3XV70Ub qxXkZUA/MF/S0BOOIlw+60uow8Hj4zn/P7x6IT89Q3Ptx27UcoxjUKowA3R8T+Q2XVhDc sKdRTkZT6TNsjBpka+APz3smB0V8p64Q+Ryl5PracwQERuArC6cKlVDUrrOuE2tGahcik AggJFI1PDVgm7QzlLx2CrjGj9uh/ZGdqv07gT8LYZKd957mNSw6k0mA6otk6rV6nBMw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796201093; h=DMARC-Filter:Received:DKIM-Signature:DKIM-Signature:DKIM-Signature: DKIM-Signature:Received:Received:Date:Message-ID:From:To:Cc:Subject: In-Reply-To:References:User-Agent:MIME-Version:Content-Type: X-Spamd-Result:X-Spam-Score:X-Spam-Level:X-Spam-Flag; bh=nSOr9jUiJlMVKSucPrgbQL9RqR2n/4QaT2bBxL71ki0=; b=mxcdmy9B9NWNFOBzyNasbl1fcks1ioEKXcLCa7V0L3JGqJWn+yxv9i4ED302DE7+EodA aMFix30RMidbhYCMUPnKN/70B5oU1YIuU6jUs/9LP2a3hvddb57plp+rHp4TYSDwcb3NJ tcQNIMLtxai+ZUGlvS6BrlJgyRUsfbo2kZwB/g/rFfWnAQSCn4Ip0FxAtn3LBPl8G/UfS xJuw7WHRxQpyy1X60xreEcFiA4Uu0lEXiUcmifu/bIGCVHoxp4PwsqmRRasCGCqFauCjW XJ+bAUv7/zUaU8U+ZWMc8KgRabIbBwlwoTN0CeBKZ6dChQDF7otI3MqsZBgLhMU0NIg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=hjG1NhTJ; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=iwKlx+N9; dkim=pass header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=o8PsiVpA; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=1f7cy0Rh; arc=none smtp.remote-ip=195.135.223.130 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 13680606A31A; Wed, 2 Dec 2026 08:44:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 13680606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=hjG1NhTJ; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=iwKlx+N9; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=o8PsiVpA; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=1f7cy0Rh Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id E2A99222F7; Wed, 2 Dec 2026 08:44:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1796201091; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=nSOr9jUiJlMVKSucPrgbQL9RqR2n/4QaT2bBxL71ki0=; b=hjG1NhTJ7VSuJNHCnnMBaZJvA8ip08byq4n2FePK8gxs8AV2V+vsB8piWXgaBxy6/0ejaf J8dgpsVrSedUpf6kWeOCKhDPZwsL/Gb/9FlEm+XxGwjxmfo1+9VxTM8CxtQxt4uIHm3YHL TJ25DvhqskO1+oyaottxNVqoJvUu0gY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1796201091; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=nSOr9jUiJlMVKSucPrgbQL9RqR2n/4QaT2bBxL71ki0=; b=iwKlx+N9lM0nCdx55mNFWg6cXKwzmOMfZhFp+n3qKjdX94J2MaIe75wUIdxZhoLYyXmm7P 4J0leDswPshWTkAw== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1796201089; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=nSOr9jUiJlMVKSucPrgbQL9RqR2n/4QaT2bBxL71ki0=; b=o8PsiVpAzl4r70rjgNBRgTa8bOGDpRCvVYar1rWQAaCFsevqQFt1nZuIj4ktdO9gydvhza OuuRKS+1oz6JQna6OfqPLLSb9lKh4WdQ3bmX7wW9hcljdckpCFn9/2VqdQLVzStv30YU7z 8cjrxpv4nEgMc1tqgFnAuXALtW9aa5g= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1796201089; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=nSOr9jUiJlMVKSucPrgbQL9RqR2n/4QaT2bBxL71ki0=; b=1f7cy0Rh2gWuhMLRAm0tA26Te6yNeofmSMZP5O/TYiNSSJyjMHXEXJ2DbZXT3FHPsVQt4R ZR1ze5Y+JUg21TDg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 6275513505; Wed, 2 Dec 2026 08:44:49 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id DKFvC4HaD2uufQAAD6G6ig (envelope-from ); Wed, 02 Dec 2026 08:44:49 +0000 Date: Wed, 02 Dec 2026 09:44:48 +0100 Message-ID: <87pkvkxe9r.wl-tiwai@suse.de> From: Takashi Iwai To: Jaegyun Lee Cc: Greg Kroah-Hartman , Neill Kapron , Takashi Iwai , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH] usb: gadget: midi2: do not repeat a MIDI 1.0 message at a request boundary In-Reply-To: <20261129140209.547953-1-dreams200260@gmail.com> References: <20261129140209.547953-1-dreams200260@gmail.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) Emacs/30.2 Mule/6.0 X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-Spamd-Result: default: False [-12.30 / 50.00]; SUSE_INTERNAL_BYPASS(-9.00)[]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; FREEMAIL_TO(0.00)[gmail.com]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; RCPT_COUNT_SEVEN(0.00)[7]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:email] X-Spam-Score: -12.30 X-Spam-Level: X-Spam-Flag: NO On Sun, 29 Nov 2026 15:02:09 +0100, Jaegyun Lee wrote: > > In MIDI 1.0 mode (altset 0) process_midi1_transmit() converts UMP data > from user space into USB-MIDI 1.0 packets through a per-cable byte > buffer (midi2->midi1_port[cable].buf/pending). process_midi1_byte() > returns true when the packet it just wrote filled the USB request > (req_buf_size - length <= 4) and the request was queued: > > memcpy(req->buf + req->length, p, sizeof(p)); > req->length += sizeof(p); > ... > if (midi2->info.req_buf_size - req->length <= 4) { > queue_request_ep_raw(req); > *req_p = NULL; > return true; > } > > and process_midi1_pending_buf() then keeps byte c at the head of the > buffer: > > if (process_midi1_byte(midi2, cable, port->buf[c], req_p)) { > port->pending -= c; > if (port->pending) > memmove(port->buf, port->buf + c, port->pending); > return true; > } > > Byte c has already been turned into a packet, but it is kept at the > head of the buffer and the running-status state is not advanced, so on > the next pass it is converted again with the same state: the last MIDI > 1.0 message of every full request (127 packets = 508 bytes) is sent > twice. > > Reproduced by having the gadget write 1000 distinct MIDI 1.0 note-on > UMPs to /dev/snd/umpCD0 while the host reads the MIDI 1.0 IN > endpoint: > > host /dev/bus/usb/001/002, gadget /dev/snd/umpC3D0, MIDI 1.0 IN ep 0x81, sending 1000 note-ons > DUPLICATE note-on #126 (note 126 vel 1) = packet 127, byte offset 508 of the stream > DUPLICATE note-on #252 (note 124 vel 2) = packet 254, byte offset 1016 of the stream > DUPLICATE note-on #382 (note 126 vel 3) = packet 385, byte offset 1540 of the stream > DUPLICATE note-on #508 (note 124 vel 4) = packet 512, byte offset 2048 of the stream > DUPLICATE note-on #638 (note 126 vel 5) = packet 643, byte offset 2572 of the stream > DUPLICATE note-on #764 (note 124 vel 6) = packet 770, byte offset 3080 of the stream > DUPLICATE note-on #894 (note 126 vel 7) = packet 901, byte offset 3604 of the stream > RESULT sent=1000 received_packets=1007 note_on=1007 in_order=1000 duplicates=7 other=0 transfers=11 > > Advance the state and drop byte c too when the request is full. > > Fixes: d6468be779af ("usb: gadget: midi2: MIDI 1.0 interface (altset 0) support") > Cc: stable@vger.kernel.org > Assisted-by: ZCode:GLM-5.4 > Signed-off-by: Jaegyun Lee Reviewed-by: Takashi Iwai thanks, Takashi