Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp3508886rwd; Mon, 22 May 2023 15:12:30 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7XvD4R6oY9X/n1D2cp8nHqkcPbfllDX4S/xOlGuS9/+hiRpAYNeI90XJkoNqLyoikFsfcc X-Received: by 2002:a17:902:778c:b0:1ae:5bd0:d452 with SMTP id o12-20020a170902778c00b001ae5bd0d452mr11858193pll.26.1684793550247; Mon, 22 May 2023 15:12:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684793550; cv=none; d=google.com; s=arc-20160816; b=fpXH4KGU7d4t1hXfiHAXXdXVxHH2Ohj3FUTRM89S/32zyiQL2P1NwRw6EniXWwrkB7 znSIIwMgLjMNZvpyQQYK0P13nqIYXQiGCAmVc9/YGAGsmW/rPbn8N67hTe/mInJQ4Fzh qArjPWlATNSnyGBvERRxZvTiQ9bS/GUmychI8aMfMWDpHsJ/H9xRx/S5bMe+xhiVlfGH IKOVdInurmBOfWTcMmBZTj1CxRogEe/QvgDx4VUMPUzcgSABu5fa32yBBvhtZEmRvCyL o3OwcGA8d+LEdU1O733OKbn5n2aeteBFi/gG18BwWpLT8ak+6UJKgUGe8fhh47Qf5YGi 9LKg== 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:dkim-signature; bh=89eYXGEaoXy7RfmTQ6JNTzxEcHDN8nh7UH9jZCh0zeQ=; b=r065dWcGhykEiLZb/RcAKjtCyRzNhqiuRM56E+86nl1wESxXWPUgd3uXq+Oyt3zBYG QeZwrMwnPSzOyQ7hn07deNxe+pmZlIkHh/Pyt1AHFgnsj674q9Pj4Jf7eZOHu1Cs4Nfk X4rpc8syDCNROKCiuKTEKuXdM9hKnwbJ7xxjbcqLGJ6PpRRII2Bl6g2mXzeik6c+SQDZ xcnnrVnRvUlc8JorcAYD3d538AlMlp8WSmZarqkGIdluI+1sHksUjY8q1n0DCzqjRO9k KRQQEYkcbxf41G5hgATWk30a8EyGP0jxYoaxS+39aAVEz09dj5WHpyh0B6zrzYwGPu/F rUnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jEXS02pp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f17-20020a170902ce9100b001a6f91439d8si211923plg.393.2023.05.22.15.12.14; Mon, 22 May 2023 15:12:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jEXS02pp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232014AbjEVVt7 (ORCPT + 99 others); Mon, 22 May 2023 17:49:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230379AbjEVVt5 (ORCPT ); Mon, 22 May 2023 17:49:57 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8B20DB; Mon, 22 May 2023 14:49:56 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 546816241D; Mon, 22 May 2023 21:49:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 66AFEC433EF; Mon, 22 May 2023 21:49:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684792195; bh=bk+0bpMnoVQcE+GPrhxsvgXsK2kP9pMa49S8uTwGy5Y=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=jEXS02ppHFJkO4Z1vb3+jCFGDmmQzVaMNFX9Fvn6VQinVGo7t5UIyMgQEf45v9Svh qcVx9AjINU8QG4XYh+1EX1R4wTcE5jSJc5E5Te4z/wysibDTdDLppuUjEwk1v8Fi12 btwVjNzuxc//lLb1m6bd0Occ8AgWGMorpjMhHNpMtAoz791P1CRs8FvjQ2hcBkJVPA 5BwCEBs3xohxHL683VKhGewzfV8o8W/xQgkmdwKQ2TE3qEDoJpincZ1N8/TWQ2lJN8 pY3mJTJQgM0ObIiRNh5xMV2lncPBAaqp4ekbAOe+FcILE7pkvEJTWksCJtg+1FnUlK 0ZtcgP7oW3CYA== Date: Mon, 22 May 2023 14:53:48 -0700 From: Bjorn Andersson To: Heikki Krogerus Cc: Bjorn Andersson , Prashant Malani , Doug Anderson , Laurent Pinchart , Rob Clark , Sean Paul , David Airlie , Daniel Vetter , linux-arm-msm , LKML , Abhinav Kumar , Stephen Boyd , Kuogee Hsieh , dri-devel , Vara Reddy , freedreno , Enric Balletbo i Serra , Benson Leung Subject: Re: [RFC] drm/msm/dp: Allow attaching a drm_panel Message-ID: <20230522215348.uoyboow26n2o3tel@ripper> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 22, 2023 at 03:51:01PM -0500, Bjorn Andersson wrote: > On Fri, Oct 08, 2021 at 03:38:21PM +0300, Heikki Krogerus wrote: > > Hi, > > > > On Thu, Oct 07, 2021 at 09:15:12AM -0700, Bjorn Andersson wrote: > > > The one thing that I still don't understand though is, if the typec_mux > > > is used by the typec controller to inform _the_ mux about the function > > > to be used, what's up with the complexity in typec_mux_match()? This is > > > what lead me to believe that typec_mux was enabling/disabling individual > > > altmodes, rather just flipping the physical switch at the bottom. > > > > Ah, typec_mux_match() is a mess. I'm sorry about that. I think most of > > the code in that function is not used by anybody. If I remember > > correctly, all that complexity is attempting to solve some > > hypothetical corner case(s). Probable a case where we have multiple > > muxes per port to deal with. > > > > I think it would probable be best to clean the function to the bare > > minimum by keeping only the parts that are actually used today > > (attached). > > > > Sorry for not replying to this in a timely manner Heikki. I've been > ignoring this issue for a long time now, just adding "svid" to our dts > files. But, this obviously shows up in DT validation - and I'd prefer > not defining these properties as valid. > > The attached patch works as expected. > Sorry, I must have failed at applying the patch - it doesn't work... > Could you please spin this as a proper patch, so we can get it merged? > > Regards, > Bjorn > > > thanks, > > > > -- > > heikki > > > diff --git a/drivers/usb/typec/mux.c b/drivers/usb/typec/mux.c > > index c8340de0ed495..44f168c9bd9bf 100644 > > --- a/drivers/usb/typec/mux.c > > +++ b/drivers/usb/typec/mux.c > > @@ -193,56 +193,15 @@ static int mux_fwnode_match(struct device *dev, const void *fwnode) > > static void *typec_mux_match(struct fwnode_handle *fwnode, const char *id, > > void *data) > > { > > - const struct typec_altmode_desc *desc = data; > > struct device *dev; > > - bool match; > > - int nval; > > - u16 *val; > > - int ret; > > - int i; > > > > /* > > - * Check has the identifier already been "consumed". If it > > - * has, no need to do any extra connection identification. > > + * The connection identifier will be needed with device graph (OF graph). > > + * Device graph is not supported by this code yet, so bailing out. > > */ > > - match = !id; > > - if (match) > > - goto find_mux; > > - > > - /* Accessory Mode muxes */ > > - if (!desc) { > > - match = fwnode_property_present(fwnode, "accessory"); > > - if (match) > > - goto find_mux; > > - return NULL; > > - } > > - > > - /* Alternate Mode muxes */ > > - nval = fwnode_property_count_u16(fwnode, "svid"); > > - if (nval <= 0) > > - return NULL; > > - > > - val = kcalloc(nval, sizeof(*val), GFP_KERNEL); > > - if (!val) > > - return ERR_PTR(-ENOMEM); > > - > > - ret = fwnode_property_read_u16_array(fwnode, "svid", val, nval); > > - if (ret < 0) { > > - kfree(val); > > - return ERR_PTR(ret); > > - } > > - > > - for (i = 0; i < nval; i++) { > > - match = val[i] == desc->svid; > > - if (match) { > > - kfree(val); > > - goto find_mux; > > - } > > - } > > - kfree(val); > > - return NULL; > > + if (id) We pass id as "mode-switch", so this will never be NULL. But we also only want to consider endpoints with "mode-switch", otherwise we'll fail if any of the referred endpoints is not implementing a typec_mux... So this needs the same snippet we find in typec_switch_match(): /* * Device graph (OF graph) does not give any means to identify the * device type or the device class of the remote port parent that @fwnode * represents, so in order to identify the type or the class of @fwnode * an additional device property is needed. With typec switches the * property is named "orientation-switch" (@id). The value of the device * property is ignored. */ if (id && !fwnode_property_present(fwnode, id)) return NULL; With that, this works as expected! Regards, Bjorn > > + return ERR_PTR(-ENOTSUPP); > > > > -find_mux: > > dev = class_find_device(&typec_mux_class, NULL, fwnode, > > mux_fwnode_match); > > >