From patchwork Mon Jan 22 15:35:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Oliver Neukum X-Patchwork-Id: 13525673 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DD95747F5F for ; Mon, 22 Jan 2024 15:35:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705937755; cv=none; b=lHgU3qMjLcdKa5hss0WUsXVanaKv314yvkxabpHVzzMIrQ4lwThuBTBZwzGHG14WLR8wZ03f/BkDGaimoj9uXuzSEQvEnqn4975CUOxM2TBwdbrwh0akUlFrwzgnKoR0j1RZ6r0Jyz3f2erUcs4Rzoh7ume4Xfo2TvS7bA6BXgc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705937755; c=relaxed/simple; bh=gbfotE8uRZMENhVqOdxmaID1ywbYDpqE+kW+J/ez3f0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=gsxlxe64NaFmssvCPgbpDNaO7Wdd3xjxBc8V7zfzJlxc8KhLDds96o9NO/GqNaoiY5mp9DnoJ2MBIU4k8g4ccBHY6Oz6iUcqbPg+ATRhdm3fypyXnEtEAMCljs1nUBcYamp8xXEBn94/8TVSFg+B6usEGGDYqWDniaqTXwEZr6Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=ZWOTJm5k; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=ZWOTJm5k; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="ZWOTJm5k"; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="ZWOTJm5k" Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [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-out2.suse.de (Postfix) with ESMTPS id 2D5591FC0C; Mon, 22 Jan 2024 15:35:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1705937752; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=qRog1bfDbNZUkziveZXN2DZnmCR291QpD3OieOymXqs=; b=ZWOTJm5kcR4JWoiH54KOupxgnypv/fgj+I2+CX54Lq3HhtqGYn2BSrqJ+Aq8sz/tBZ1X9B cSeHFOZKobw+HLrVMEvZOElZxTw4VK98jKk8uVYOmFCM0iT86YgljlbT7V/hwuL2FL+OLP OyndRdyKbXBJjABNb+tkt8c2qdbUTk0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1705937752; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=qRog1bfDbNZUkziveZXN2DZnmCR291QpD3OieOymXqs=; b=ZWOTJm5kcR4JWoiH54KOupxgnypv/fgj+I2+CX54Lq3HhtqGYn2BSrqJ+Aq8sz/tBZ1X9B cSeHFOZKobw+HLrVMEvZOElZxTw4VK98jKk8uVYOmFCM0iT86YgljlbT7V/hwuL2FL+OLP OyndRdyKbXBJjABNb+tkt8c2qdbUTk0= 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 E347713995; Mon, 22 Jan 2024 15:35:51 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id UgRDNVeLrmUKbAAAD6G6ig (envelope-from ); Mon, 22 Jan 2024 15:35:51 +0000 From: Oliver Neukum To: jun.li@freescale.com, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org Cc: Oliver Neukum Subject: [PATCH] USB: hub: check for alternate port before enabling A_ALT_HNP_SUPPORT Date: Mon, 22 Jan 2024 16:35:32 +0100 Message-ID: <20240122153545.12284-1-oneukum@suse.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Authentication-Results: smtp-out2.suse.de; none X-Spam-Level: X-Spam-Score: -0.30 X-Spamd-Result: default: False [-0.30 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[] X-Spam-Flag: NO The OTG 1.3 spec has the feature A_ALT_HNP_SUPPORT, which tells a device that it is connected to the wrong port. Some devices refuse to operate if you enable that feature, because it indicates to them that they ought to request to be connected to another port. According to the spec this feature may be used based only the following three conditions: 6.5.3 a_alt_hnp_support Setting this feature indicates to the B-device that it is connected to an A-device port that is not capable of HNP, but that the A-device does have an alternate port that is capable of HNP. The A-device is required to set this feature under the following conditions: • the A-device has multiple receptacles • the A-device port that connects to the B-device does not support HNP • the A-device has another port that does support HNP A check for the third and first condition is missing. Add it. Signed-off-by: Oliver Neukum Fixes: 7d2d641c44269 ("usb: otg: don't set a_alt_hnp_support feature for OTG 2.0 device") --- drivers/usb/core/hub.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index ffd7c99e24a3..d46777479849 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -2388,17 +2388,25 @@ static int usb_enumerate_device_otg(struct usb_device *udev) } } else if (desc->bLength == sizeof (struct usb_otg_descriptor)) { - /* Set a_alt_hnp_support for legacy otg device */ - err = usb_control_msg(udev, - usb_sndctrlpipe(udev, 0), - USB_REQ_SET_FEATURE, 0, - USB_DEVICE_A_ALT_HNP_SUPPORT, - 0, NULL, 0, - USB_CTRL_SET_TIMEOUT); - if (err < 0) - dev_err(&udev->dev, - "set a_alt_hnp_support failed: %d\n", - err); + /* + * We are operating on a legacy OTP device + * These should be told that they are operating + * on the wrong port if we have another port that does + * support HNP + */ + if (bus->otg_port != 0) { + /* Set a_alt_hnp_support for legacy otg device */ + err = usb_control_msg(udev, + usb_sndctrlpipe(udev, 0), + USB_REQ_SET_FEATURE, 0, + USB_DEVICE_A_ALT_HNP_SUPPORT, + 0, NULL, 0, + USB_CTRL_SET_TIMEOUT); + if (err < 0) + dev_err(&udev->dev, + "set a_alt_hnp_support failed: %d\n", + err); + } } } #endif