Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4098069pxu; Wed, 9 Dec 2020 08:18:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJzZJTcEytDx9J/ARXekEkcPsTkqVtuj7Xg1SbO4xqUBDEY3yl+WYRXg7tmuOE0s8RI3bFlU X-Received: by 2002:aa7:c049:: with SMTP id k9mr2702237edo.49.1607530717882; Wed, 09 Dec 2020 08:18:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607530717; cv=none; d=google.com; s=arc-20160816; b=JcxmsMMkiT25npuUU8baYnSWvZQLRxK5FcpCC1PxMkJ8KDCKiH2ynzRXm8H+8wT8Lr F+iPaL1W5fg+8fmFJ3n3twr9Z75pcR78RzOBbn3OImq6WzK4EXGrP6a4bhYZmq+Aa5x4 /Cz4b1FfzhXsr88cRIVqNWc4v3sjXk4i9gL1OrkVgj06hm+eiAJdOUoo3yYv0Tb3q1dW cknxECnf3Y5W5TjD1835aEIAxg6sHdMty3YtFA2wn3ueaclNfGkvycJG3Y9Yp0sNsSHW KfzaGp4B0ISuqIPLU610oClfJ3/HoyTf/uuxhft6eG8RxF7r/YaUYTV9047mC2UYobUu vVHQ== 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=b3n6dK//RFB80LAYpkVsUot5VuWEmgZwC6ahayoyfVU=; b=W3Gdsl3vlt5jYMsgjQDQlrltn+bv1ilrQF7aqz9PMPPUOW1XNZfx7xTsl8Y3ln7sxJ PC5NYN+aQjBOmWA4eZWQ4twoPmvXV9Nv0Vw+GCkwnrjsP5x6BJvRVYlH7uWoaYrHbq1u rq8aNDXgguNEjQcQ/R0ddGZm4ixy5lBvAwsPf1CcoFGSTWucD31g8Fr6tSqgEp/kU5nN M8UB0xyT6Gd3r2ChtdK22Yd/bdg3JjIbq44sBKHmatKwoTp/uCF6zX1dpzW37qYSQzYS X7tA4ttVFZy5TE7WhNDLo8DZk/wzvV/UPx22XwEg1KD0SZ9QQBMS24Jyi2KxX8nYB9Ec ciWg== 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 n27si970622ejc.673.2020.12.09.08.18.14; Wed, 09 Dec 2020 08:18:37 -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 S1730549AbgLIQPp (ORCPT + 99 others); Wed, 9 Dec 2020 11:15:45 -0500 Received: from mga01.intel.com ([192.55.52.88]:42263 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730122AbgLIQPp (ORCPT ); Wed, 9 Dec 2020 11:15:45 -0500 IronPort-SDR: qhAQ9V4Boh4uBpx0YNL/irxMbiGn8GKEFJ9ANBaBOI06RE4kF08V9z8M5jo0gmtm1+egbUz3b2 35PQETpUp93g== X-IronPort-AV: E=McAfee;i="6000,8403,9829"; a="192405890" X-IronPort-AV: E=Sophos;i="5.78,405,1599548400"; d="scan'208";a="192405890" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Dec 2020 08:13:59 -0800 IronPort-SDR: nDfX4tYjT8ZYFGG8XF2PmutHkMhsyiA+r1JGwdPpFqhYyDcKiGLPDtuMLvOl0vVQSBK0L05XKQ uGzn7QomKmbg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.78,405,1599548400"; d="scan'208";a="437847788" Received: from kuha.fi.intel.com ([10.237.72.162]) by fmsmga001.fm.intel.com with SMTP; 09 Dec 2020 08:13:56 -0800 Received: by kuha.fi.intel.com (sSMTP sendmail emulation); Wed, 09 Dec 2020 18:13:56 +0200 Date: Wed, 9 Dec 2020 18:13:56 +0200 From: Heikki Krogerus To: Prashant Malani Cc: "open list:USB NETWORKING DRIVERS" , Greg Kroah-Hartman , Benson Leung , Jonathan Corbet , "open list:DOCUMENTATION" , open list Subject: Re: [PATCH] usb: typec: Add bus type for plug alt modes Message-ID: <20201209161356.GI680328@kuha.fi.intel.com> References: <20201203030846.51669-1-pmalani@chromium.org> <20201208093734.GD680328@kuha.fi.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 08, 2020 at 03:45:19PM -0800, Prashant Malani wrote: > Hi Heikki, > > Thanks a lot for looking at the patch. > > On Tue, Dec 8, 2020 at 1:37 AM Heikki Krogerus wrote: > > > > On Wed, Dec 02, 2020 at 07:08:47PM -0800, Prashant Malani wrote: > > > Add the Type C bus for plug alternate modes which are being > > > registered via the Type C connector class. This ensures that udev events > > > get generated when plug alternate modes are registered (and not just for > > > partner/port alternate modes), even though the Type C bus doesn't link > > > plug alternate mode devices to alternate mode drivers. > > > > I still don't understand how is the uevent related to the bus? If you > > check the device_add() function, on line 2917, kobject_uevent() is > > called unconditionally. The device does not need a bus for that event > > to be generated. > > My initial thought process was to see what is the difference in the adev device > initialization between partner altmode and plug altmode (the only difference I saw in > typec_register_altmode() was regarding the bus field). > > Yes, kobject_uevent() is called unconditionally, but it's return value isn't checked, > so we don't know if it succeeded or not. > > In the case of cable plug altmode, I see it fail with the following error[1]: > > [ 114.431409] kobject: 'port1-plug0.0' (000000004ad42956): kobject_uevent_env: filter function caused the event to drop! > > I think the filter function which is called is this one: drivers/base/core.c: dev_uevent_filter() [2] > > static int dev_uevent_filter(struct kset *kset, struct kobject *kobj) > { > struct kobj_type *ktype = get_ktype(kobj); > > if (ktype == &device_ktype) { > struct device *dev = kobj_to_dev(kobj); > if (dev->bus) > return 1; > if (dev->class) > return 1; > } > return 0; > } > > So, both the "if (dev->bus)" and "if (dev->class)" checks are failing here. In the case of partner alt modes, bus is set by the class.c code > so this check likely returns 1 in that case. OK. I understand the issue now. So I would say that the proper solution to this problem is to link the alt modes with the class instead of the bus. That is much smaller change IMO. thanks, -- heikki