Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp6170467rwr; Mon, 24 Apr 2023 15:07:25 -0700 (PDT) X-Google-Smtp-Source: AKy350bllcVoabltDN/gKkjkVT2n8W6w8rfpPV6b0MCuUGYd976fh87VUumKmGznqLSAcg1Sksq6 X-Received: by 2002:a17:90b:1103:b0:23f:1165:b49f with SMTP id gi3-20020a17090b110300b0023f1165b49fmr13919732pjb.38.1682374044832; Mon, 24 Apr 2023 15:07:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682374044; cv=none; d=google.com; s=arc-20160816; b=SLQrmtplQcjiPM3nsvfOvFIn6zbZDeH+8nWheYj5ggq9KqYUPJbfWCwVqHgmXb9F2a Jxkt9tSwUyX8xiczLRQ+PL5W1kYvnxd/Vow5T4v+MbPWSpgthVVbPkvTawx9cA3fQwuK KnuSaFh9UWRCXvHfaJjbkXpjgTgqxrO+kTzEVieMw7h2XkWT445rhOxOn9KSB0r7gsS9 X2XV+3Utl5X8ZZwu5HNSLBCRQrYXOEWODYYhSYL8/O834Ekujh20jXRWAGC6N5Vc+tiU XtdJlQ5/Wi4wgMsSeEjEDXArzJb0Jh63uoQFJVcFOefLbCMJqIgyI6qXzNmEIqkEEjyW tSFg== 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; bh=rDTJYZVskM/PB1lqQZH9TWhbOK/vDChyMDl/e0mKbR8=; b=fb1tgyTWk3n8/1YT+HLsa/90VTX5fNvMRd6SPU6BlfFWE/re7QIrVwhtbuuVJwrxMR XXjv0+hAAE8A8V3Wa/CBX8WhRuvdtwz+0ndcSMWwO4ySFnuDR3dipFs9QYCG68yJD/su vAdbhfTPHutz4AS+3aHRPSbFYvDmnN9Pu0ZnaCnm208+XpDK1l10sdNnKVZVwW4J0Tho CuICnntYzrVHDpIlf+BxyZbeaVgKRPbg4vTgk3HaV9SIQGgRwW6LPlYAd3q0XFnPvAxJ SWnuWGJaEZw2EuqkgbUlAtqkH8iGju2NsWwvaGmT70Z8Lugtn+fMQaaBbggdcf5t+Msz KAHA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p13-20020a17090b010d00b002496cedea8esi12057804pjz.24.2023.04.24.15.07.03; Mon, 24 Apr 2023 15:07:24 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229688AbjDXWDQ (ORCPT + 99 others); Mon, 24 Apr 2023 18:03:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229514AbjDXWDO (ORCPT ); Mon, 24 Apr 2023 18:03:14 -0400 Received: from relay07.th.seeweb.it (relay07.th.seeweb.it [5.144.164.168]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02D941BD8 for ; Mon, 24 Apr 2023 15:03:11 -0700 (PDT) Received: from SoMainline.org (94-211-6-86.cable.dynamic.v4.ziggo.nl [94.211.6.86]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by m-r2.th.seeweb.it (Postfix) with ESMTPSA id C77C83F364; Tue, 25 Apr 2023 00:03:02 +0200 (CEST) Date: Tue, 25 Apr 2023 00:03:01 +0200 From: Marijn Suijten To: Abhinav Kumar Cc: Rob Clark , Dmitry Baryshkov , Sean Paul , David Airlie , Daniel Vetter , ~postmarketos/upstreaming@lists.sr.ht, AngeloGioacchino Del Regno , Konrad Dybcio , Martin Botka , Jami Kettunen , Jordan Crouse , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 3/3] drm/msm/dpu: Pass catalog pointers directly from RM instead of IDs Message-ID: References: <20230418-dpu-drop-useless-for-lookup-v2-0-acb08e82ef19@somainline.org> <20230418-dpu-drop-useless-for-lookup-v2-3-acb08e82ef19@somainline.org> <50d22e0c-84b3-0678-eb06-30fb66fd24cf@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <50d22e0c-84b3-0678-eb06-30fb66fd24cf@quicinc.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, 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 2023-04-21 16:25:15, Abhinav Kumar wrote: > > > On 4/21/2023 1:53 PM, Marijn Suijten wrote: > > The Resource Manager already iterates over all available blocks from the > > catalog, only to pass their ID to a dpu_hw_xxx_init() function which > > uses an _xxx_offset() helper to search for and find the exact same > > catalog pointer again to initialize the block with, fallible error > > handling and all. > > > > Instead, pass const pointers to the catalog entries directly to these > > _init functions and drop the for loops entirely, saving on both > > readability complexity and unnecessary cycles at boot. > > > > Signed-off-by: Marijn Suijten > > Reviewed-by: Dmitry Baryshkov > > Overall, a nice cleanup! > > One comment below. > > > --- > > drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c | 37 +++++---------------- > > drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.h | 14 ++++---- > > drivers/gpu/drm/msm/disp/dpu1/dpu_hw_dsc.c | 32 +++--------------- > > drivers/gpu/drm/msm/disp/dpu1/dpu_hw_dsc.h | 11 +++---- > > drivers/gpu/drm/msm/disp/dpu1/dpu_hw_dspp.c | 38 ++++----------------- > > drivers/gpu/drm/msm/disp/dpu1/dpu_hw_dspp.h | 12 +++---- > > drivers/gpu/drm/msm/disp/dpu1/dpu_hw_interrupts.h | 2 +- > > drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.c | 40 ++++++----------------- > > drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.h | 12 +++---- > > drivers/gpu/drm/msm/disp/dpu1/dpu_hw_lm.c | 38 ++++----------------- > > drivers/gpu/drm/msm/disp/dpu1/dpu_hw_lm.h | 10 +++--- > > drivers/gpu/drm/msm/disp/dpu1/dpu_hw_merge3d.c | 33 +++---------------- > > drivers/gpu/drm/msm/disp/dpu1/dpu_hw_merge3d.h | 14 ++++---- > > drivers/gpu/drm/msm/disp/dpu1/dpu_hw_pingpong.c | 33 +++---------------- > > drivers/gpu/drm/msm/disp/dpu1/dpu_hw_pingpong.h | 14 ++++---- > > drivers/gpu/drm/msm/disp/dpu1/dpu_hw_sspp.c | 39 ++++------------------ > > drivers/gpu/drm/msm/disp/dpu1/dpu_hw_sspp.h | 12 +++---- > > drivers/gpu/drm/msm/disp/dpu1/dpu_hw_vbif.c | 33 +++---------------- > > drivers/gpu/drm/msm/disp/dpu1/dpu_hw_vbif.h | 11 +++---- > > drivers/gpu/drm/msm/disp/dpu1/dpu_hw_wb.c | 33 ++++--------------- > > drivers/gpu/drm/msm/disp/dpu1/dpu_hw_wb.h | 11 +++---- > > drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 17 +++++----- > > drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c | 18 +++++----- > > 23 files changed, 139 insertions(+), 375 deletions(-) > > > > > > > -struct dpu_hw_intf *dpu_hw_intf_init(enum dpu_intf idx, > > - void __iomem *addr, > > - const struct dpu_mdss_cfg *m) > > +struct dpu_hw_intf *dpu_hw_intf_init(const struct dpu_intf_cfg *cfg, > > + void __iomem *addr) > > { > > struct dpu_hw_intf *c; > > - const struct dpu_intf_cfg *cfg; > > + > > + if (cfg->type == INTF_NONE) { > > + pr_err("Cannot create interface hw object for INTF_NONE type\n"); > > + return ERR_PTR(-EINVAL); > > + } > > The caller of dpu_hw_intf_init which is the RM already has protection > for INTF_NONE, see below > > for (i = 0; i < cat->intf_count; i++) { > struct dpu_hw_intf *hw; > const struct dpu_intf_cfg *intf = &cat->intf[i]; > > if (intf->type == INTF_NONE) { > DPU_DEBUG("skip intf %d with type none\n", i); > continue; > } > if (intf->id < INTF_0 || intf->id >= INTF_MAX) { > DPU_ERROR("skip intf %d with invalid id\n", > intf->id); > continue; > } > hw = dpu_hw_intf_init(intf->id, mmio, cat); > > So this part can be dropped. I mainly intended to keep original validation where _intf_offset would skip INTF_NONE, and error out. RM init is hence expected to filter out INTF_NONE instead of running into that `-EINVAL`, which I maintained here. If you think there won't be another caller of dpu_hw_intf_init, and that such validation is hence excessive, I can remove it in a followup v3. - Marijn > > c = kzalloc(sizeof(*c), GFP_KERNEL); > > if (!c) > > return ERR_PTR(-ENOMEM); > > > > - cfg = _intf_offset(idx, m, addr, &c->hw); > > - if (IS_ERR_OR_NULL(cfg)) { > > - kfree(c); > > - pr_err("failed to create dpu_hw_intf %d\n", idx); > > - return ERR_PTR(-EINVAL); > > - } > > + c->hw.blk_addr = addr + cfg->base; > > + c->hw.log_mask = DPU_DBG_MASK_INTF; > > > >