Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp1527174rdb; Fri, 1 Dec 2023 22:28:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IGgmmPUbAv55Ha/9bWXEMfus6HHVMxqnYwwMx0DW1Wh4WA+qj0auK97+iR84R+4q1eTlMLJ X-Received: by 2002:a05:6a00:1311:b0:6ce:2732:57e with SMTP id j17-20020a056a00131100b006ce2732057emr894787pfu.47.1701498515342; Fri, 01 Dec 2023 22:28:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701498515; cv=none; d=google.com; s=arc-20160816; b=xu1fcN8pffGCs9Qru4z7wfT6344cc+OW3FeyAdhNOlstPiHEns0Ywemi+RhvSOX2CK kueaqisDgTG0kioulZ3E+/nVlcZ1oFnfpwyrqCmJsN2CVgY/D+4ohg2DLW8aSJw0t7/L 5KvP65aux7UAUO8YC6hUZY4nFaH/VPgvywplu7xu+LCfncyDBIV0T95ZjQsTqMqvFYOD OWFmqpmTFEmBQApC+Yx6FxYod9ARw1Ku5G55LymVNBc4x6dJnEARRdPHvQW8UgrXiWaT KCFE3h29kXx96WxV2MmQzA9mN4Lc30LS/e2EpkCV6mRfIzikNzlQBAS7at4Suoja9GOY t9Bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=tbZ3baswrVIXCpv17EXNLNQ6fCKKgX8I1X1ug4sHQRo=; fh=u3xFoD2J9NLEjrcgcUZQrHXrlsLZ56yVHx++OrpUe1g=; b=ZM9rrwm8lGUPB4TKVrw6loD6SRwmV9CqU2DvWp5LaxXcVVusxHp5+7sDaO2b8FmWil kr/Twbq9bzEZtQFHP6/eTyHbkWYkcCP2HubzPJem2mbskG9EDkEOM0mt3Du0Elfyamwi f4Fhgmke7ugedIAOxvCBriQ8hfM7xYdyR2TFy1grGJ8SeVNt5+fsGuxx8lH2HkXxvoEz pVVbSRFLGDan+/jDF6gGJuG+HiK9MLv34ev7jCJBZ8PPd+v7dzXfqgo31pZvyD6OW4SY t7oR92tKxg2jEZ9Ts4lFi0kZ196OssbcbwlPjLI2+HtDnoZrB9JaZol3R0VV0iIHx3cu rl6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=YglY1EA2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id q23-20020a62e117000000b006cda3292e38si4393340pfh.358.2023.12.01.22.28.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 22:28:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=YglY1EA2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id D485E80B6C1A; Fri, 1 Dec 2023 22:28:32 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229489AbjLBG2S (ORCPT + 99 others); Sat, 2 Dec 2023 01:28:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229379AbjLBG2R (ORCPT ); Sat, 2 Dec 2023 01:28:17 -0500 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65E72F1 for ; Fri, 1 Dec 2023 22:28:23 -0800 (PST) Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1d0477a0062so84775ad.0 for ; Fri, 01 Dec 2023 22:28:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1701498503; x=1702103303; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=tbZ3baswrVIXCpv17EXNLNQ6fCKKgX8I1X1ug4sHQRo=; b=YglY1EA2yEd6/FYjxTbHAGTkC+hloqwMvNU+aEl1QJDbjtmggqyyOocdeuetVZMn3K zZLhB7p6QPVWXs0YLKpFo/ckvmV9FMJM0hSfC1yX7DFKtCWDcf6SDDaCeivY2FbPvo63 YJWqdfh6l3bWs0kAV3IJ9pgm1qPCBIwHkkiz0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701498503; x=1702103303; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tbZ3baswrVIXCpv17EXNLNQ6fCKKgX8I1X1ug4sHQRo=; b=RsVHWvNjNscBG/OOhQicqpL+EWB8+bEyFPcklwGG1swQfKug1JXw+7FrFcYZg6UZQ9 Gf1ps7qVIku6krFvXmMh8boYwtHzbEO8TxgInU5NmU3m3eDdGqMVFVyVX/Z+DuVMx276 1/ofPDyOCrfeeA5hCOFH/axBzy5tGhSTqTEVdjKNzzDTIpOFuZAhlro81BxabFAZDErn fLOQybSmFeOn7IM2E8TO3uqvqACNMm9oZhqfanf9/kpkqo1vC6lFQBHKFDlAdMLfWZLK csV7BiZqc093ih9/TzB+bUjIDoRqqpDJqkZtpE/FtzakgI1JNU+0oKVnyKwYwGvmDpon Ehng== X-Gm-Message-State: AOJu0YwSb9aDYbBUf6xnZFy1hON/9HL07kN2OkuNeVQScmOHWQoDaflB HbSjiTbg2uspp3nNc50XpyS+8D5gk5Yms3QV/QXQUg== X-Received: by 2002:a17:903:428a:b0:1cf:acbf:d0b5 with SMTP id ju10-20020a170903428a00b001cfacbfd0b5mr333159plb.1.1701498502612; Fri, 01 Dec 2023 22:28:22 -0800 (PST) MIME-Version: 1.0 References: <20231201183113.343256-1-dianders@chromium.org> <20231201102946.v2.3.Ie00e07f07f87149c9ce0b27ae4e26991d307e14b@changeid> In-Reply-To: <20231201102946.v2.3.Ie00e07f07f87149c9ce0b27ae4e26991d307e14b@changeid> From: Grant Grundler Date: Fri, 1 Dec 2023 22:28:11 -0800 Message-ID: Subject: Re: [PATCH net v2 3/3] r8152: Choose our USB config with choose_configuration() rather than probe() To: Douglas Anderson Cc: linux-usb@vger.kernel.org, Greg Kroah-Hartman , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Grant Grundler , Hayes Wang , Simon Horman , =?UTF-8?Q?Bj=C3=B8rn_Mork?= , netdev@vger.kernel.org, Brian Geffon , Alan Stern , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Fri, 01 Dec 2023 22:28:33 -0800 (PST) On Fri, Dec 1, 2023 at 10:31=E2=80=AFAM Douglas Anderson wrote: > > If you deauthorize the r8152 device (by writing 0 to the "authorized" > field in sysfs) and then reauthorize it (by writing a 1) then it no > longer works. This is because when you do the above we lose the > special configuration that we set in rtl8152_cfgselector_probe(). > Deauthorizing causes the config to be set to -1 and then reauthorizing > runs the default logic for choosing the best config. > > I made an attempt to fix it so that the config is kept across > deauthorizing / reauthorizing [1] but it was a bit ugly. > > Let's instead use the new USB core feature to override > choose_configuration(). > > This patch relies upon the patches ("usb: core: Don't force USB > generic_subclass drivers to define probe()") and ("usb: core: Allow > subclassed USB drivers to override usb_choose_configuration()") > > [1] https://lore.kernel.org/r/20231130154337.1.Ie00e07f07f87149c9ce0b27ae= 4e26991d307e14b@changeid > > Fixes: ec51fbd1b8a2 ("r8152: add USB device driver for config selection") > Suggested-by: Alan Stern > Signed-off-by: Douglas Anderson Reviewed-by: Grant Grundler > --- > > Changes in v2: > - ("Choose our USB config with choose_configuration()...) new for v2. > > drivers/net/usb/r8152.c | 16 +++++----------- > 1 file changed, 5 insertions(+), 11 deletions(-) > > diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c > index 2c5c1e91ded6..0da723d11326 100644 > --- a/drivers/net/usb/r8152.c > +++ b/drivers/net/usb/r8152.c > @@ -10053,7 +10053,7 @@ static struct usb_driver rtl8152_driver =3D { > .disable_hub_initiated_lpm =3D 1, > }; > > -static int rtl8152_cfgselector_probe(struct usb_device *udev) > +static int rtl8152_cfgselector_choose_configuration(struct usb_device *u= dev) > { > struct usb_host_config *c; > int i, num_configs; > @@ -10080,19 +10080,13 @@ static int rtl8152_cfgselector_probe(struct usb= _device *udev) > if (i =3D=3D num_configs) > return -ENODEV; > > - if (usb_set_configuration(udev, c->desc.bConfigurationValue)) { > - dev_err(&udev->dev, "Failed to set configuration %d\n", > - c->desc.bConfigurationValue); > - return -ENODEV; > - } > - > - return 0; > + return c->desc.bConfigurationValue; > } > > static struct usb_device_driver rtl8152_cfgselector_driver =3D { > - .name =3D MODULENAME "-cfgselector", > - .probe =3D rtl8152_cfgselector_probe, > - .id_table =3D rtl8152_table, > + .name =3D MODULENAME "-cfgselector", > + .choose_configuration =3D rtl8152_cfgselector_choose_configuratio= n, > + .id_table =3D rtl8152_table, > .generic_subclass =3D 1, > .supports_autosuspend =3D 1, > }; > -- > 2.43.0.rc2.451.g8631bc7472-goog >