From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16B96C433DB for ; Fri, 15 Jan 2021 13:28:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D6F8723382 for ; Fri, 15 Jan 2021 13:28:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731589AbhAON2Q (ORCPT ); Fri, 15 Jan 2021 08:28:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731502AbhAON2Q (ORCPT ); Fri, 15 Jan 2021 08:28:16 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D00DEC0613D3 for ; Fri, 15 Jan 2021 05:27:52 -0800 (PST) Received: from [192.168.0.20] (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 89D6D527; Fri, 15 Jan 2021 14:27:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1610717270; bh=1e+Cq1tmwETjYMmNBUSatTqVYwWvGeI0xiVYiJsCsDI=; h=Reply-To:Subject:To:Cc:References:From:Date:In-Reply-To:From; b=sqv0D1jsL8LKyJ4mkZVaBSp3v+v0Mmxpf2VDkLzplqCDpBrbwWhvHHSF3C3PoslZj aVEuGaueqNjb9GDGEBTQyo+INSGMzuN7pjZLNCZWXNpqSRg1ehI+lpWypfVDsppxpt fSVS+ePaThzM5WOcLhHOU9LRcv0N+k3h+pDexeso= Reply-To: kieran.bingham+renesas@ideasonboard.com Subject: Re: [PATCH] drm: rcar-du: Use drmm_encoder_alloc() to manage encoder To: Laurent Pinchart Cc: David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, linux-renesas-soc@vger.kernel.org, Geert Uytterhoeven References: <20210113170253.443820-1-kieran.bingham+renesas@ideasonboard.com> From: Kieran Bingham Organization: Ideas on Board Message-ID: <62ed8b3b-1bf8-31a7-da9e-012788afbf87@ideasonboard.com> Date: Fri, 15 Jan 2021 13:27:47 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Hi Laurent, On 13/01/2021 22:45, Laurent Pinchart wrote: > Hi Kieran, > > Thank you for the patch. > > On Wed, Jan 13, 2021 at 05:02:53PM +0000, Kieran Bingham wrote: >> The encoder allocation was converted to a DRM managed resource at the >> same time as the addition of a new helper drmm_encoder_alloc() which >> simplifies the same process. >> >> Convert the custom drm managed resource allocation of the encoder >> with the helper to simplify the implementation, and prevent hitting a >> WARN_ON() due to the handling the drm_encoder_init() call directly >> without registering a .destroy() function op. >> >> Fixes: f5f16725edbc ("drm: rcar-du: Use DRM-managed allocation for encoders") > > We could equally point to the patch that has added drmm_encoder_alloc(), > but I'm fine taking the blame :-) Perhaps, we could point there indeed, I'm surprised that patch/series didn't seem to add any users of drmm_encoder_alloc() as far as I can see. I don't think this is a "blame" though. Just a reference to the most relevant change. > Reviewed-by: Laurent Pinchart > Thanks. Kieran >> Reported-by: Geert Uytterhoeven >> Signed-off-by: Kieran Bingham >> --- >> drivers/gpu/drm/rcar-du/rcar_du_encoder.c | 31 +++++------------------ >> 1 file changed, 6 insertions(+), 25 deletions(-) >> >> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_encoder.c b/drivers/gpu/drm/rcar-du/rcar_du_encoder.c >> index ba8c6038cd63..ca3761772211 100644 >> --- a/drivers/gpu/drm/rcar-du/rcar_du_encoder.c >> +++ b/drivers/gpu/drm/rcar-du/rcar_du_encoder.c >> @@ -48,21 +48,12 @@ static unsigned int rcar_du_encoder_count_ports(struct device_node *node) >> static const struct drm_encoder_funcs rcar_du_encoder_funcs = { >> }; >> >> -static void rcar_du_encoder_release(struct drm_device *dev, void *res) >> -{ >> - struct rcar_du_encoder *renc = res; >> - >> - drm_encoder_cleanup(&renc->base); >> - kfree(renc); >> -} >> - >> int rcar_du_encoder_init(struct rcar_du_device *rcdu, >> enum rcar_du_output output, >> struct device_node *enc_node) >> { >> struct rcar_du_encoder *renc; >> struct drm_bridge *bridge; >> - int ret; >> >> /* >> * Locate the DRM bridge from the DT node. For the DPAD outputs, if the >> @@ -101,26 +92,16 @@ int rcar_du_encoder_init(struct rcar_du_device *rcdu, >> return -ENOLINK; >> } >> >> - renc = kzalloc(sizeof(*renc), GFP_KERNEL); >> - if (renc == NULL) >> - return -ENOMEM; >> - >> - renc->output = output; >> - >> dev_dbg(rcdu->dev, "initializing encoder %pOF for output %u\n", >> enc_node, output); >> >> - ret = drm_encoder_init(&rcdu->ddev, &renc->base, &rcar_du_encoder_funcs, >> - DRM_MODE_ENCODER_NONE, NULL); >> - if (ret < 0) { >> - kfree(renc); >> - return ret; >> - } >> + renc = drmm_encoder_alloc(&rcdu->ddev, struct rcar_du_encoder, base, >> + &rcar_du_encoder_funcs, DRM_MODE_ENCODER_NONE, >> + NULL); >> + if (!renc) >> + return -ENOMEM; >> >> - ret = drmm_add_action_or_reset(&rcdu->ddev, rcar_du_encoder_release, >> - renc); >> - if (ret) >> - return ret; >> + renc->output = output; >> >> /* >> * Attach the bridge to the encoder. The bridge will create the > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 89087C433DB for ; Fri, 15 Jan 2021 13:27:54 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C0E4D23382 for ; Fri, 15 Jan 2021 13:27:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C0E4D23382 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 48D906E40D; Fri, 15 Jan 2021 13:27:53 +0000 (UTC) Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by gabe.freedesktop.org (Postfix) with ESMTPS id B3BB16E40D for ; Fri, 15 Jan 2021 13:27:52 +0000 (UTC) Received: from [192.168.0.20] (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 89D6D527; Fri, 15 Jan 2021 14:27:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1610717270; bh=1e+Cq1tmwETjYMmNBUSatTqVYwWvGeI0xiVYiJsCsDI=; h=Reply-To:Subject:To:Cc:References:From:Date:In-Reply-To:From; b=sqv0D1jsL8LKyJ4mkZVaBSp3v+v0Mmxpf2VDkLzplqCDpBrbwWhvHHSF3C3PoslZj aVEuGaueqNjb9GDGEBTQyo+INSGMzuN7pjZLNCZWXNpqSRg1ehI+lpWypfVDsppxpt fSVS+ePaThzM5WOcLhHOU9LRcv0N+k3h+pDexeso= Subject: Re: [PATCH] drm: rcar-du: Use drmm_encoder_alloc() to manage encoder To: Laurent Pinchart References: <20210113170253.443820-1-kieran.bingham+renesas@ideasonboard.com> From: Kieran Bingham Organization: Ideas on Board Message-ID: <62ed8b3b-1bf8-31a7-da9e-012788afbf87@ideasonboard.com> Date: Fri, 15 Jan 2021 13:27:47 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-GB X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: kieran.bingham+renesas@ideasonboard.com Cc: David Airlie , linux-renesas-soc@vger.kernel.org, Geert Uytterhoeven , dri-devel@lists.freedesktop.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Hi Laurent, On 13/01/2021 22:45, Laurent Pinchart wrote: > Hi Kieran, > > Thank you for the patch. > > On Wed, Jan 13, 2021 at 05:02:53PM +0000, Kieran Bingham wrote: >> The encoder allocation was converted to a DRM managed resource at the >> same time as the addition of a new helper drmm_encoder_alloc() which >> simplifies the same process. >> >> Convert the custom drm managed resource allocation of the encoder >> with the helper to simplify the implementation, and prevent hitting a >> WARN_ON() due to the handling the drm_encoder_init() call directly >> without registering a .destroy() function op. >> >> Fixes: f5f16725edbc ("drm: rcar-du: Use DRM-managed allocation for encoders") > > We could equally point to the patch that has added drmm_encoder_alloc(), > but I'm fine taking the blame :-) Perhaps, we could point there indeed, I'm surprised that patch/series didn't seem to add any users of drmm_encoder_alloc() as far as I can see. I don't think this is a "blame" though. Just a reference to the most relevant change. > Reviewed-by: Laurent Pinchart > Thanks. Kieran >> Reported-by: Geert Uytterhoeven >> Signed-off-by: Kieran Bingham >> --- >> drivers/gpu/drm/rcar-du/rcar_du_encoder.c | 31 +++++------------------ >> 1 file changed, 6 insertions(+), 25 deletions(-) >> >> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_encoder.c b/drivers/gpu/drm/rcar-du/rcar_du_encoder.c >> index ba8c6038cd63..ca3761772211 100644 >> --- a/drivers/gpu/drm/rcar-du/rcar_du_encoder.c >> +++ b/drivers/gpu/drm/rcar-du/rcar_du_encoder.c >> @@ -48,21 +48,12 @@ static unsigned int rcar_du_encoder_count_ports(struct device_node *node) >> static const struct drm_encoder_funcs rcar_du_encoder_funcs = { >> }; >> >> -static void rcar_du_encoder_release(struct drm_device *dev, void *res) >> -{ >> - struct rcar_du_encoder *renc = res; >> - >> - drm_encoder_cleanup(&renc->base); >> - kfree(renc); >> -} >> - >> int rcar_du_encoder_init(struct rcar_du_device *rcdu, >> enum rcar_du_output output, >> struct device_node *enc_node) >> { >> struct rcar_du_encoder *renc; >> struct drm_bridge *bridge; >> - int ret; >> >> /* >> * Locate the DRM bridge from the DT node. For the DPAD outputs, if the >> @@ -101,26 +92,16 @@ int rcar_du_encoder_init(struct rcar_du_device *rcdu, >> return -ENOLINK; >> } >> >> - renc = kzalloc(sizeof(*renc), GFP_KERNEL); >> - if (renc == NULL) >> - return -ENOMEM; >> - >> - renc->output = output; >> - >> dev_dbg(rcdu->dev, "initializing encoder %pOF for output %u\n", >> enc_node, output); >> >> - ret = drm_encoder_init(&rcdu->ddev, &renc->base, &rcar_du_encoder_funcs, >> - DRM_MODE_ENCODER_NONE, NULL); >> - if (ret < 0) { >> - kfree(renc); >> - return ret; >> - } >> + renc = drmm_encoder_alloc(&rcdu->ddev, struct rcar_du_encoder, base, >> + &rcar_du_encoder_funcs, DRM_MODE_ENCODER_NONE, >> + NULL); >> + if (!renc) >> + return -ENOMEM; >> >> - ret = drmm_add_action_or_reset(&rcdu->ddev, rcar_du_encoder_release, >> - renc); >> - if (ret) >> - return ret; >> + renc->output = output; >> >> /* >> * Attach the bridge to the encoder. The bridge will create the > _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel