Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp265434pxb; Wed, 18 Nov 2020 04:06:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJxZ5D9WH5pxVVSjuzxn+mjvFWrroAhqIRMhrbtFUrO0xTRUqvFC1XYlC95IzOuzTwJ00bA1 X-Received: by 2002:a05:6402:234a:: with SMTP id r10mr26166985eda.311.1605701163926; Wed, 18 Nov 2020 04:06:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605701163; cv=none; d=google.com; s=arc-20160816; b=mq6dWuJN21Xh9KRDqespXsxefaqDlmj1EJWMUwnQGFVnMmNSUoaHTojQpblW/F6LLA EM+BgQ9Kgo2QCEHxd4f3ZoYr3jJwGwQ70ecMQAUXb6XjBNreof36G3tSwIqYINzvDaDQ xiPR5gzQnciJQ+iQJraRGN4wQA4PZF2hQyHf1HtsTZ24xjpUDXJU2nS+sy/FVLoOIAov IVprp7m+Hw+K++kuy8DS/+9DxVweI1PjGfBvHsC3CqQm7toyCA+p11DCAWYY8UISBtA9 jZBI8tKvtwJxQQIbTpTg+P7m+YNmt+Sm1god3YjsVhtQRPSkZiLBpFRYCt11Arwg4F98 t7Vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:ironport-sdr :ironport-sdr; bh=UPSJBiP118Ujev126/wr5cUl9drKEJI4vGTjymSN2KI=; b=oIHmGKuYQ0fpCfCfZZtphMSasku62LT67jqzD4zWqTyyEtWKfADyC5sx9/tsAFuZeA gbJSbROWr5ntJWFY5hzIJ28H/DE4/SonCimDH3v2uLrnFcj4viQTBwgdT+zgjEwynmn6 sOhYEumzAsPRbqZS2FjeB9cukl5fbJs0GSamGcL9TTaNn7pp2jeqjTgfhJVCsyI+6Pj7 QIAhC09VYa3O/rNQFQJAhyE5qBtbC5l8BLdcqq5HU4qgXn70F7AA12lxXixVB1BLJWnZ QGRO0pS6bksgrD103tBCV8VJxDIQKlimOJgHyco9h1raHUxGap/Kaf7vtAThoje9SFY0 UIgQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o24si16861246edq.9.2020.11.18.04.05.41; Wed, 18 Nov 2020 04:06:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726751AbgKRMEO (ORCPT + 99 others); Wed, 18 Nov 2020 07:04:14 -0500 Received: from mga05.intel.com ([192.55.52.43]:4837 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726299AbgKRMEO (ORCPT ); Wed, 18 Nov 2020 07:04:14 -0500 IronPort-SDR: 7qNHeMshNgNIIpvmIBt8u2WjJMBBIsvfIFjwwKUrAEac0gA3oLAxTdcQiEZzb68bwx3J47RoEn Fa3jszg790PQ== X-IronPort-AV: E=McAfee;i="6000,8403,9808"; a="255815670" X-IronPort-AV: E=Sophos;i="5.77,486,1596524400"; d="scan'208";a="255815670" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Nov 2020 04:04:13 -0800 IronPort-SDR: Mbimcke64Rmpf1jMY/9ir/N/g3HWTelPECz5ErmG1nkn4XxAhWyzPvYkG9QfaGhYsL/jKAQYaL eTDJ15wmQ79A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,486,1596524400"; d="scan'208";a="430813669" Received: from kuha.fi.intel.com ([10.237.72.162]) by fmsmga001.fm.intel.com with SMTP; 18 Nov 2020 04:04:11 -0800 Received: by kuha.fi.intel.com (sSMTP sendmail emulation); Wed, 18 Nov 2020 14:04:08 +0200 Date: Wed, 18 Nov 2020 14:04:08 +0200 From: Heikki Krogerus To: Prashant Malani Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, gregkh@linuxfoundation.org, enric.balletbo@collabora.com Subject: Re: [PATCH v3 03/11] usb: typec: Add plug num_altmodes sysfs attr Message-ID: <20201118120408.GL3437448@kuha.fi.intel.com> References: <20201116201150.2919178-1-pmalani@chromium.org> <20201116201150.2919178-4-pmalani@chromium.org> <20201117124143.GI3437448@kuha.fi.intel.com> <20201117174016.GA1819103@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201117174016.GA1819103@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 17, 2020 at 09:40:16AM -0800, Prashant Malani wrote: > Hi Heikki, > > On Tue, Nov 17, 2020 at 02:41:43PM +0200, Heikki Krogerus wrote: > > On Mon, Nov 16, 2020 at 12:11:42PM -0800, Prashant Malani wrote: > > > Add a field to the typec_plug struct to record the number of available > > > altmodes as well as the corresponding sysfs attribute to expose this to > > > userspace. > > > > > > This allows userspace to determine whether there are any > > > remaining alternate modes left to be registered by the kernel driver. It > > > can begin executing any policy state machine after all available > > > alternate modes have been registered with the connector class framework. > > > > > > This value is set to "-1" initially, signifying that a valid number of > > > alternate modes haven't been set for the plug. The sysfs file remains > > > hidden as long as the attribute value is -1. > > > > Why couldn't we just keep it hidden for as long as the number of > > alt modes is 0? If you already explained that, then I apologise, I've > > forgotten. > > > > No worries :) > > Succinctly, because 0 is a valid value for "number of altmodes > supported". > > If we keep the attribute hidden for 0, then there won't > be a way for userspace to determine that PD discovery is done and we > don't expect any more cable plug altmodes to be registered by the kernel > Type C port driver (it can determine this by comparing > "number_of_altmodes" against the actual number of alt modes registered > by the Type C port driver). > > If we keep "number_of_altmodes" hidden even for 0, the userspace cannot > differentiate between "this cable doesn't support any altmodes" and > "it does altmodes, but the PD stack hasn't completed PD Discovery > including DiscoverIdentity yet". > > For reference, here is the initial patch and mini-discussion around it > back in July for port-partner altmodes [1] (I've followed a similar > logic here). > > Hope this helps the rationale a bit more. Got it. Thanks for the explanation (again :-). Reviewed-by: Heikki Krogerus > Best regards, > > -Prashant > > [1]: > https://lore.kernel.org/linux-usb/20200701082230.GF856968@kuha.fi.intel.com/ thanks, -- heikki