Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp5147184rwr; Mon, 8 May 2023 19:19:32 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7NGPoBroA5oJbpjSsmztzL7rbOEYvTbXChIekKi7iormO5hUcszJ0sF/iC5Y86KZS02bXO X-Received: by 2002:a17:90a:d193:b0:250:91f7:f66c with SMTP id fu19-20020a17090ad19300b0025091f7f66cmr4260868pjb.27.1683598771753; Mon, 08 May 2023 19:19:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683598771; cv=none; d=google.com; s=arc-20160816; b=hfBwMgw1F/9ZOCo68ksw1v6TZq72GxguGAFPtLPuIF5KVyeNGa4iTTBMNUxSfBSUd+ Kc/lY7UskZN+O2GPeqlS6rIn0A1cBbJxKHAg0HgeJEBin9lASGNJXhuST6vet4JMBCJs VMQfBiRS+vWYIN4mWbJyRQPFIwAeuqNiTB0K8PDoOlwc9JOGQR1oinxYLxrdiAfoPF8x 3Xyb3yUArPfmUf8hCOl72nlxGzYLy6aTZ0DMWocyPzqGVksrZ2M5QCLiXc9u16cbvoT2 ijOZ1d5MGfcBOYmBzLeScI/asqQRztFjAVySoh1grYuaCFcBYh7wnH2rxwxPAABEOeql NzhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=Ji2HhlHFfCXY74FqMvczOZ+BR43BKRG9fT3pCghkDOc=; b=XvSSMq5jBhidSfs6LODA0tidQOiId/qJkUQCnCr9DOg0t8zhwhkhJ2000DVkPmoZ/H hI3I/9TWupJo0fPdZOar8b2Jcyi7KGUzmSrefsC6NHXunjAth/DQPqTMYyp5VnTzuQIm iLd92c1L7Q4qgXJyRdKgfttIDKh6xUXWjODSM40/bRAx7cwiTyWbVXjWXjrq5nFvwFpx XAdel3j9BxXXAlKJ1G4QpNFgOF17hZSiiQZWy36CacIUTKvZ7QC0YUiL3y+kkZYLTp17 y1ghhXjAkArgq3LA8zEJiAe1feiupUgYx7SU4YwG5jioU2wFTkg+VhXoNhce7JEHiUyT DjvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@denx.de header.s=phobos-20191101 header.b=UXvkBSM7; 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=denx.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s13-20020a63924d000000b0051b71bd43b9si335798pgn.784.2023.05.08.19.19.17; Mon, 08 May 2023 19:19:31 -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=@denx.de header.s=phobos-20191101 header.b=UXvkBSM7; 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=denx.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234134AbjEICOP (ORCPT + 99 others); Mon, 8 May 2023 22:14:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234147AbjEICOL (ORCPT ); Mon, 8 May 2023 22:14:11 -0400 Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9ABC9EE1; Mon, 8 May 2023 19:14:08 -0700 (PDT) Received: from [127.0.0.1] (p578adb1c.dip0.t-ipconnect.de [87.138.219.28]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 6682385FD2; Tue, 9 May 2023 04:14:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1683598446; bh=Ji2HhlHFfCXY74FqMvczOZ+BR43BKRG9fT3pCghkDOc=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=UXvkBSM7YUZrBsk3SPuAJ54ycJwY/CoXwC5HR4ZqFMNbkndwzGlW+1qC7TkjUJtup 1ND/b9iAlZsSdqnShsm2ndKVgANyB6Ua66mwWq4W5pgfxyVEV+KQDtKYFYfH2WukPr /RvlF9A/TMhUVLofvdmWKphePRZm86BXC+dn2hVnEMdmFz0kGovJd0hG2jdt7SUF+t M7KSwldGXKDzgxhbpTNZfb4ASgxiMNKY0bHWCMQ08qS/KAiRYBF7XduOEoNNgaErYs Qz70fW70rkcTNIsPc0PpfFod6d/izuaSlRdyLfhP45MgGI5k4j01a8FvEbeEJi9YYI f6D+sZW4prluw== Message-ID: <05b44685-d6a7-5f6e-0f55-04c96e94a9e1@denx.de> Date: Tue, 9 May 2023 02:02:39 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH v5 2/6] drm: lcdif: Drop unnecessary NULL pointer check on lcdif->bridge Content-Language: en-US To: Liu Ying , dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: stefan@agner.ch, airlied@gmail.com, daniel@ffwll.ch, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, krzysztof.kozlowski@linaro.org, LW@karo-electronics.de, alexander.stein@ew.tq-group.com References: <20230508055740.635256-1-victor.liu@nxp.com> <20230508055740.635256-3-victor.liu@nxp.com> From: Marek Vasut In-Reply-To: <20230508055740.635256-3-victor.liu@nxp.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean X-Spam-Status: No, score=-6.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 5/8/23 07:57, Liu Ying wrote: Hi, > diff --git a/drivers/gpu/drm/mxsfb/lcdif_kms.c b/drivers/gpu/drm/mxsfb/lcdif_kms.c > index 262bc43b1079..e54200a9fcb9 100644 > --- a/drivers/gpu/drm/mxsfb/lcdif_kms.c > +++ b/drivers/gpu/drm/mxsfb/lcdif_kms.c > @@ -394,7 +394,7 @@ static void lcdif_crtc_mode_set_nofb(struct lcdif_drm_private *lcdif, > struct drm_display_mode *m = &lcdif->crtc.state->adjusted_mode; > u32 bus_flags = 0; > > - if (lcdif->bridge && lcdif->bridge->timings) > + if (lcdif->bridge->timings) > bus_flags = lcdif->bridge->timings->input_bus_flags; > else if (bridge_state) > bus_flags = bridge_state->input_bus_cfg.flags; > @@ -463,30 +463,21 @@ static void lcdif_crtc_atomic_enable(struct drm_crtc *crtc, > struct drm_display_mode *m = &lcdif->crtc.state->adjusted_mode; > struct drm_bridge_state *bridge_state = NULL; > struct drm_device *drm = lcdif->drm; > - u32 bus_format = 0; > + u32 bus_format; > dma_addr_t paddr; > > - /* If there is a bridge attached to the LCDIF, use its bus format */ > - if (lcdif->bridge) { > - bridge_state = > - drm_atomic_get_new_bridge_state(state, > - lcdif->bridge); > - if (!bridge_state) > - bus_format = MEDIA_BUS_FMT_FIXED; > - else > - bus_format = bridge_state->input_bus_cfg.format; > - > - if (bus_format == MEDIA_BUS_FMT_FIXED) { > - dev_warn_once(drm->dev, > - "Bridge does not provide bus format, assuming MEDIA_BUS_FMT_RGB888_1X24.\n" > - "Please fix bridge driver by handling atomic_get_input_bus_fmts.\n"); > - bus_format = MEDIA_BUS_FMT_RGB888_1X24; > - } > - } > + bridge_state = drm_atomic_get_new_bridge_state(state, lcdif->bridge); > + if (!bridge_state) > + bus_format = MEDIA_BUS_FMT_FIXED; > + else > + bus_format = bridge_state->input_bus_cfg.format; The code below seems to change the logic slightly. Could it happen that: - bridge_state is valid (i.e. non-NULL) - bridge_state->input_bus_cfg.format is set to 0 (i.e. not set) ? (note that MEDIA_BUS_FMT_FIXED is defined as 0x0001) > - /* If all else fails, default to RGB888_1X24 */ > - if (!bus_format) > + if (bus_format == MEDIA_BUS_FMT_FIXED) { > + dev_warn_once(drm->dev, > + "Bridge does not provide bus format, assuming MEDIA_BUS_FMT_RGB888_1X24.\n" > + "Please fix bridge driver by handling atomic_get_input_bus_fmts.\n"); > bus_format = MEDIA_BUS_FMT_RGB888_1X24; > + } > > clk_set_rate(lcdif->clk, m->crtc_clock * 1000); [...]