Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp6215159rwr; Mon, 24 Apr 2023 16:04:00 -0700 (PDT) X-Google-Smtp-Source: AKy350ZNjbT6HAgZcJ8WZ62NBnlHL726DuKoHkMd3Xg4N0WlSjTceZOaoQtzbuONAFNKDGeOnYWT X-Received: by 2002:a17:90b:1a8f:b0:234:28ac:ec4a with SMTP id ng15-20020a17090b1a8f00b0023428acec4amr14166755pjb.2.1682377440007; Mon, 24 Apr 2023 16:04:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682377439; cv=none; d=google.com; s=arc-20160816; b=ReI465hEEZO5IvuKX+XzNRn/JO1rfL0QM7b/Ws3PGccAREaNwKoTPNIwp1rZb8Yhfv H86QrQHB2VDY7Sz48XeR7+lKXR4Gp+dY4nYR5CJ1faHdLudbWYlbAjMoDuO51pfw5+B7 FUu+CzuT9iStAsAgiAQD/bETeTzN9DMGgZBBoSWT8j+OhdrZNvcG1H9QDkUwiCIP8Nqp fXVgJyxQJGCMZejBqCHpf+IWPBjb7/c2R987yA6cBAYM917pg4O8LF5g6a992qBItrdk ZqGoAls4O6gT+s5f6xNWXyQ0RUBgngDLh9BHP/VYiVqMqRalsenM8zEdz9pe5eCBpS+s lR4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=urRO9IkUTIq77dWBTXZerCEWau63FaL24inu94rfVRU=; b=BErh3ap4oFkAD2kg9kZwQr2jnCTiFjiXESLnzodUR0gr/M+PwzKftfMJ5WMNv4KOVy 8Y0EfNiLpTlnTQbCbG7vobN24Eh9zoDmWKEv1oTlLRXwiolbMRyO68/brIxf4W1x7/mH yCxL3WVKk1ilDY7VPZHdX8UzMWzEeQeMCoaKZQwyFc8SXUKV2pLklXScUZJFTNy0JKpu 2YkjS9UKlmsZ7m6d6jl5IFYBqb0XJwQRiNORnhusD+krHjy7VRXoCs4a2CGMnkf48hor ghzsQUwZlnqImQ9zJEkW6QEer7RfrBRwOADGqUxgAZzQxjGng1Q4Dww/dWO9YSdvLjRC f+QA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Fj1zGw/w"; 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=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i10-20020a17090332ca00b001a6b273fef3si12568174plr.442.2023.04.24.16.03.46; Mon, 24 Apr 2023 16:03:59 -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=@linaro.org header.s=google header.b="Fj1zGw/w"; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233109AbjDXWzG (ORCPT + 99 others); Mon, 24 Apr 2023 18:55:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233106AbjDXWzE (ORCPT ); Mon, 24 Apr 2023 18:55:04 -0400 Received: from mail-yw1-x1130.google.com (mail-yw1-x1130.google.com [IPv6:2607:f8b0:4864:20::1130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FB1A7AA3 for ; Mon, 24 Apr 2023 15:55:03 -0700 (PDT) Received: by mail-yw1-x1130.google.com with SMTP id 00721157ae682-54fb9384c2dso59946627b3.2 for ; Mon, 24 Apr 2023 15:55:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1682376902; x=1684968902; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=urRO9IkUTIq77dWBTXZerCEWau63FaL24inu94rfVRU=; b=Fj1zGw/wYbq+07TYyjORi45sEzGM7qvwbMznjo8nS4KsNBNm4YzAM1V+WPLq9gsxuI kh0qqol2A8VD75bHUtunyouL5wqCJvHHLwdZ2kIqA9ySn3bhEWrKjlYZtsHegztjKUek La5Yx4yKHV6f5OaZKYUZYPBhjeDEdOVk/Gs+Rw/cLwqKZlSO8OMPqhHjnwHSFZ35IxhL x2DB+Z6QIgVqv2TvjEjVPJdV6A6Ddflyu/S5QJIuXqvqKaim8U35+mA9wGz96CbIQvgW ihtl8N66kc1MVo+ymSNznW98yAKPwYpwDXFDxdxqpYnHXHepsGxigg4Io8lpVJAtAyAA ICVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682376902; x=1684968902; 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=urRO9IkUTIq77dWBTXZerCEWau63FaL24inu94rfVRU=; b=kckc5BCcp2cSusQTw6IcWpUZvqdz+1DzB5yRVamiHZe9NLesRdHfxchU79FEV0xOWk cHbDaJF2icWC82QCbCwkAdusFMUt/7xK9Oa5KHgZpv+Uzl2472BuOVIrCaJOzFSgwOwb rsb1LfkQ8NLMFupJNs8nxhKNI7gzQ2GKJEm7k044wussxS2Ru6ITeypqNtgMLBpq/YiA Jn0Pvbn+5aOsOOApFnEFTBfFrcyMnZwZzdICWO06jQ28xq7NdeFrWPS97NofnSVNnCrv 8O5h2Pe3N+C7/zuMFwp8aEB7vdDzM36xnDsLJdd8Yd20GpKGJMdDsB/g8896veAm89gd cVUA== X-Gm-Message-State: AAQBX9fPWQfQaat40qVgnKTQtNZTyUGjOl5qqLM/3YgzPqUlBe2EHRjf NM5MSi4Ef9k0iuhI6TInUx8qRW4MQj64eUWNVXCYVw== X-Received: by 2002:a81:4e10:0:b0:54c:16e:6581 with SMTP id c16-20020a814e10000000b0054c016e6581mr9732607ywb.37.1682376902478; Mon, 24 Apr 2023 15:55:02 -0700 (PDT) MIME-Version: 1.0 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> In-Reply-To: From: Dmitry Baryshkov Date: Tue, 25 Apr 2023 01:54:51 +0300 Message-ID: Subject: Re: [PATCH v2 3/3] drm/msm/dpu: Pass catalog pointers directly from RM instead of IDs To: Marijn Suijten Cc: Abhinav Kumar , Rob Clark , 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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 Tue, 25 Apr 2023 at 01:03, Marijn Suijten wrote: > > 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. I'd prefer to see the checks at dpu_rm to be dropped. dpu_hw_intf_init() (and other dpu_hw_foo_init() functions) should be self-contained. If they can not init HW block (e.g. because the index is out of the boundaries), they should return an error. > > - 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; > > > > > > > -- With best wishes Dmitry