Received: by 2002:ab2:784b:0:b0:1fd:adc2:8405 with SMTP id m11csp298056lqp; Mon, 10 Jun 2024 04:46:38 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU/H7Q8lk8l/vHhlJMbPbS0rkv/cccqduLbsgxBT0piSybqlfr2gnDWzXNFsXHmJoKq480dKtPo8fx1LxPzh5JQWO1qmc0Kt2ogB28yQQ== X-Google-Smtp-Source: AGHT+IHQKLmTkVZY00apb3bZ4PmXkLkpJKgy/7ECYV0fq3ZBZqKDLukvzcPLds5IdgTWnJ2L6vYq X-Received: by 2002:a2e:a418:0:b0:2eb:e7dd:1f88 with SMTP id 38308e7fff4ca-2ebe7dd2244mr18356811fa.25.1718019998296; Mon, 10 Jun 2024 04:46:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718019998; cv=pass; d=google.com; s=arc-20160816; b=W1LUsd7gPWiGxrIgQLlJ1KLWX2efLlQ87Y99qZkZrJw+3+sYy/I9shrJhksCAUx0Fl euYoW8i1bUtlBIJwLrTkJ4je39XC86G7oMOzCKbflvrZb4o5AvsnBuo1xiqKHlNkFJBE GhhXXD2PC4ZrQxXvt7DXpANiBTI43MEG2abi2sCND7JfGVIsUIuFt9toifTlTC2IlFoB JaYUyGGDN2+A2XVDmnC+wjdVR7z674Uqsfkhx1zEAvid3kZ88QPtlE9AhZnGjBKjfGlG 6BEkOepdBoMuA0nSuWuOt2cLMlUxxb+1vuOef2doqe1rUfav97K6c9CMw+lxuxfQIDG7 z+UA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=2iK4IsuByPlunVBIPa84PXOTmIsAWUdTQwWl9Bv3pV0=; fh=q3fWKKIbeJV9NDgUNwQd3BV9fAiv53xdAvmQpD8mH0E=; b=O110NEpY27MvPCo8KD8TkvcB15MdGmTV6UVp6EV5d6pk7CPsVazv0YMutwA0Xr9hDy 87HCi/vJuzjI1j8rED8JuEhlQ1E0K4B8KVhvEZToFlv7zuGetShEMjUgmD2PL/t53Uhi nz191VaOg3qsfwqHqDklk0CV8kTOXl8TenpVUG68CHuxv/hxlHByPHBmqM2kTRUzxTdA xXmvNWTQj7kCOvKkoxdEgox+zpQXjHChho3LNnWuTDihMoXDH5lil8F8vCnjg24ik0/V tHHdXaNMGTZJsJl5yzJ6Ne5OfRu2BivFBx9s/aJV0xAYm+0G41o6Pw2EdUuZMhXaOxWn J1qQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=c8dUo9Ad; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-208097-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208097-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a6f16616545si149468966b.13.2024.06.10.04.46.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 04:46:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-208097-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=c8dUo9Ad; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-208097-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208097-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id CE81F1F220DA for ; Mon, 10 Jun 2024 11:46:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7E29F7EEFF; Mon, 10 Jun 2024 11:46:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="c8dUo9Ad" Received: from mail-yw1-f177.google.com (mail-yw1-f177.google.com [209.85.128.177]) (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 E8BDB7E103 for ; Mon, 10 Jun 2024 11:46:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718019977; cv=none; b=R1F/0Kv5YdRmA/BbqxV+eKShUMTRyaZBuTrmDkPuVdKB3B/UGQDk3YHGN9oAULzl/ePwTbjvSXZuXxDnd9SmtMmAuX31cL/RTlIRMIPaFE9fEfHePf+1j99pOWO4VxyGm4cznTnSKyzGK2Ww1A0Dv+pEqvauxt/ciyq/AFpUaIE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718019977; c=relaxed/simple; bh=euJKBP0BTUasb5iwo16OMHsaHKsK2u0WdU7AvYTzRfk=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=aSxeDVz2cY3ktJXfD5+ErWKk2M5vWZ18vJBCRhuYb15kEfeP8f0z+jmM+9rv4lDWPqQMwv2SKLQDZyJC1N6viwAdNG1GIaCbdbSSzxIS0zcrR9oQK4YCfw4IUjysg/Fa8E4YYSXl5lj2ovv0Ru6LWd3RZDr9jtztKp2WeUHHK0k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=c8dUo9Ad; arc=none smtp.client-ip=209.85.128.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-yw1-f177.google.com with SMTP id 00721157ae682-62ceb6a4e97so19929117b3.1 for ; Mon, 10 Jun 2024 04:46:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718019975; x=1718624775; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=2iK4IsuByPlunVBIPa84PXOTmIsAWUdTQwWl9Bv3pV0=; b=c8dUo9AdL1CHiAa9zsECMAp3MdemMhXGklR/xickcbZyRGfCmhudx09GvP212wBxWG PaAnGE7syOUeuTzKkspRrekdwvV6QGWcZFT43dlQzbV+K0SM7O2Z+fNvqbVH4huLx2cc NWQrn9wf7o6DRlLtLreOYb5l0ptuZtFh1g8OVYUpiPCX0gN2Q49QACVqyec50skKd/3S K+aF3q0PqgomgEMRGiF4J0veE1Q7F6hD5R4XETAmJloih9DAKYAdTQmDbljgmAT3D2aN YPgZbvuQ52NqE4d66UA9fuHNM5k3lz+jTUxzdfixe38Ny9H0F41UyQQJovYoouK8mPu4 FHlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718019975; x=1718624775; h=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=2iK4IsuByPlunVBIPa84PXOTmIsAWUdTQwWl9Bv3pV0=; b=lVJshAunorkGLoIEFll717J0HBUQqEuIO6ia09JF30Fko1RsB0hFjk2vDRThrJHWmu 9VjOlpFJdaajrQipDSJapHYbi3ZyRb6FTnf+PxQ62mUNx9z17UUcqDL9w8njg5OqzRvl fFQ6VfSC+KRrvZV9DolvHASf5HtSLf5LEfy99HaHm2SCduZ/aycysj9P6U4lt25UTm3Q clUYUe0mxpU5j51w6E1gLbiY5Rkzzu+cuvD8CcBwoszaFWVq9BdHsTGHQEgvjzjiLBY8 MDuKi2jfChyxFuUfrHfQeveh4VfHGlRmGc1YAOXadPtjyZtL5fBY2RvzI85ONNmfrz9e 20/g== X-Forwarded-Encrypted: i=1; AJvYcCVkrEAumf9aScncwPtuN/4vzU7AYTpwUv549F9DwMyHyMT2zzXxt2A9CGGXMgU7EkxqQYrK4kCPuaLwi5RRa9iQ3eYbvIv2K/VIPfZK X-Gm-Message-State: AOJu0YxDA/59hB8e1ubLEVE/BB2GQI8t57Rghl7wljnYrMEUlpA3ztmT cw9mT4vKMfLEcjREMjQePoLfR9XKMHN0/K6WTqYJ63xVrUJuKS86nMSmAMxqSpbNLl0/e1oskuw FCDqRAa9lH6H7mXgXTjsG2ukiVOMGrqxVMTVG7A== X-Received: by 2002:a0d:d403:0:b0:617:d49f:d5b9 with SMTP id 00721157ae682-62cd55cc44emr86886597b3.14.1718019974751; Mon, 10 Jun 2024 04:46:14 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240607-bridge-hdmi-connector-v5-0-ab384e6021af@linaro.org> <20240607-bridge-hdmi-connector-v5-2-ab384e6021af@linaro.org> <20240610-secret-rottweiler-from-asgard-132f75@houat> In-Reply-To: <20240610-secret-rottweiler-from-asgard-132f75@houat> From: Dmitry Baryshkov Date: Mon, 10 Jun 2024 14:46:03 +0300 Message-ID: Subject: Re: [PATCH v5 2/9] drm/bridge-connector: switch to using drmm allocations To: Maxime Ripard Cc: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Thomas Zimmermann , David Airlie , Daniel Vetter , Rob Clark , Abhinav Kumar , Sean Paul , Marijn Suijten , dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" On Mon, 10 Jun 2024 at 11:04, Maxime Ripard wrote: > > Hi, > > On Fri, Jun 07, 2024 at 04:22:59PM GMT, Dmitry Baryshkov wrote: > > Turn drm_bridge_connector to using drmm_kzalloc() and > > drmm_connector_init() and drop the custom destroy function. The > > drm_connector_unregister() and fwnode_handle_put() are already handled > > by the drm_connector_cleanup() and so are safe to be dropped. > > > > Acked-by: Maxime Ripard > > Signed-off-by: Dmitry Baryshkov > > --- > > drivers/gpu/drm/drm_bridge_connector.c | 23 +++++------------------ > > 1 file changed, 5 insertions(+), 18 deletions(-) > > > > diff --git a/drivers/gpu/drm/drm_bridge_connector.c b/drivers/gpu/drm/drm_bridge_connector.c > > index 982552c9f92c..e093fc8928dc 100644 > > --- a/drivers/gpu/drm/drm_bridge_connector.c > > +++ b/drivers/gpu/drm/drm_bridge_connector.c > > @@ -15,6 +15,7 @@ > > #include > > #include > > #include > > +#include > > #include > > #include > > > > @@ -193,19 +194,6 @@ drm_bridge_connector_detect(struct drm_connector *connector, bool force) > > return status; > > } > > > > -static void drm_bridge_connector_destroy(struct drm_connector *connector) > > -{ > > - struct drm_bridge_connector *bridge_connector = > > - to_drm_bridge_connector(connector); > > - > > - drm_connector_unregister(connector); > > - drm_connector_cleanup(connector); > > - > > - fwnode_handle_put(connector->fwnode); > > - > > - kfree(bridge_connector); > > -} > > - > > static void drm_bridge_connector_debugfs_init(struct drm_connector *connector, > > struct dentry *root) > > { > > @@ -224,7 +212,6 @@ static const struct drm_connector_funcs drm_bridge_connector_funcs = { > > .reset = drm_atomic_helper_connector_reset, > > .detect = drm_bridge_connector_detect, > > .fill_modes = drm_helper_probe_single_connector_modes, > > - .destroy = drm_bridge_connector_destroy, > > .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, > > .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, > > .debugfs_init = drm_bridge_connector_debugfs_init, > > @@ -328,7 +315,7 @@ struct drm_connector *drm_bridge_connector_init(struct drm_device *drm, > > int connector_type; > > int ret; > > > > - bridge_connector = kzalloc(sizeof(*bridge_connector), GFP_KERNEL); > > + bridge_connector = drmm_kzalloc(drm, sizeof(*bridge_connector), GFP_KERNEL); > > So you make destroy's kfree call unnecessary here ... > > > if (!bridge_connector) > > return ERR_PTR(-ENOMEM); > > > > @@ -383,9 +370,9 @@ struct drm_connector *drm_bridge_connector_init(struct drm_device *drm, > > return ERR_PTR(-EINVAL); > > } > > > > - ret = drm_connector_init_with_ddc(drm, connector, > > - &drm_bridge_connector_funcs, > > - connector_type, ddc); > > + ret = drmm_connector_init(drm, connector, > > + &drm_bridge_connector_funcs, > > + connector_type, ddc); > > ... and here of drm_connector_cleanup. > > drm_connector_unregister wasn't needed, so can ignore it, but you leak a reference to > connector->fwnode since you don't call fwnode_handle_put anymore. > > We should register a drmm action right below the call to fwnode_handle_get too. But drm_connector_cleanup() already contains fwnode_handle_put(connector->fwnode). Isn't that enough? -- With best wishes Dmitry