From patchwork Mon Dec 24 09:25:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Qian Wang X-Patchwork-Id: 10742135 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E136F13AD for ; Mon, 24 Dec 2018 09:25:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CFC0026E96 for ; Mon, 24 Dec 2018 09:25:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C40D828F33; Mon, 24 Dec 2018 09:25:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 146A526E96 for ; Mon, 24 Dec 2018 09:25:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4A8D36E553; Mon, 24 Dec 2018 09:25:42 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-eopbgr30052.outbound.protection.outlook.com [40.107.3.52]) by gabe.freedesktop.org (Postfix) with ESMTPS id 989BA6E551 for ; Mon, 24 Dec 2018 09:25:40 +0000 (UTC) Received: from AM3PR08MB0611.eurprd08.prod.outlook.com (10.163.188.149) by AM3PR08MB0262.eurprd08.prod.outlook.com (10.161.35.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1446.23; Mon, 24 Dec 2018 09:25:36 +0000 Received: from AM3PR08MB0611.eurprd08.prod.outlook.com ([fe80::3c73:534c:9c6e:352d]) by AM3PR08MB0611.eurprd08.prod.outlook.com ([fe80::3c73:534c:9c6e:352d%2]) with mapi id 15.20.1446.026; Mon, 24 Dec 2018 09:25:36 +0000 From: "james qian wang (Arm Technology China)" To: Liviu Dudau Subject: [PATCH 02/11] drm/komeda: Add komeda_release_unclaimed_resources Thread-Topic: [PATCH 02/11] drm/komeda: Add komeda_release_unclaimed_resources Thread-Index: AQHUm2qgbpr3MDaMjUmvP8RL3EQTdw== Date: Mon, 24 Dec 2018 09:25:36 +0000 Message-ID: <20181224092435.2792-3-james.qian.wang@arm.com> References: <20181224092435.2792-1-james.qian.wang@arm.com> In-Reply-To: <20181224092435.2792-1-james.qian.wang@arm.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [113.29.88.7] x-clientproxiedby: SYXPR01CA0099.ausprd01.prod.outlook.com (2603:10c6:0:2e::32) To AM3PR08MB0611.eurprd08.prod.outlook.com (2a01:111:e400:c408::21) x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM3PR08MB0262; 6:idlLqi5AjrQ0r0iAXiIgFxhD8ssHbbS2fBQawLR7iqYSUEmVdyPsXZ/+p8KcFihQqYT/wXoHLVffi+pMMj+hNvLxOW4IpEwFrEiYsSSW4yQhV+XX/7wcCi4mLE8sE5Cz1vtLkwjfeIl4PkmHstgxgI0ILrT4NQqjJDC9YKnmXrezFCbuVZ6CzMVSEVsVgk8h+kZBqMRMHbCFKuXUTxodwuMc7U2ycKbvePgn7pSNkP/+WZ3XWcQp/yWrmdyicyyy522NdU0Pvm+ildKGPOjvHPpJu/kDR7hOQfWPekK66F3mFGy6AdcJZvdXlU7SYITfgsph/yiB6JkQBSUQiuy8fxNMf+Z8pvVTNXKn3Dsqvnzf6DN480a7q0g6ZqDRF1fvSVEq4XB4kTdeZ0EryJ4vptwlL8YCHMhRtfUMqH30Bh0Lls7TILIdvAXxw7j9Pvb5XlUBF+0Wuy/lGXAnWJHgXA==; 5:1ZgqSP6+ORZWIGW5iAOPCtwXXznmpP3etLxXp1aH1Timk+7vIdYiBqW7peWDZSwRROhd4STEtHQNta7u0qMigR+2reJLmA2bMtbj6YcCx/tguA4Web41fXWt/gc05UHLMFWU1m/DOm/0f2iBlWCAYMoGRli2ZgHkmEuZqTOMycQ=; 7:tKafw3usvwm9ZwHU8B64RbtAJJyONOxTozzDOaeWplbbg2q8TpE9lkvrs21p313wVwaZpzrmVkS3CYm9zSa1ixaDx7iKe/ZZXzlqIN2lLXu4jxTubYK0ib7i2uaG33zbt+ska48XztpxvV0ju6TNmQ== x-ms-office365-filtering-correlation-id: 7c28083e-988d-4f00-f20d-08d66981c2bb x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:AM3PR08MB0262; x-ms-traffictypediagnostic: AM3PR08MB0262: nodisclaimer: True x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(3230021)(908002)(999002)(5005026)(6040522)(2401047)(8121501046)(10201501046)(3231475)(944501520)(52105112)(3002001)(93006095)(93001095)(6055026)(6041310)(20161123560045)(20161123562045)(20161123564045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095); SRVR:AM3PR08MB0262; BCL:0; PCL:0; RULEID:; SRVR:AM3PR08MB0262; x-forefront-prvs: 0896BFCE6C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(366004)(136003)(376002)(39850400004)(346002)(199004)(189003)(4326008)(256004)(305945005)(53936002)(6862004)(71190400001)(71200400001)(486006)(7736002)(97736004)(446003)(2906002)(52116002)(6116002)(76176011)(1076003)(6436002)(86362001)(6512007)(5660300001)(11346002)(186003)(26005)(68736007)(3846002)(2616005)(476003)(55236004)(386003)(102836004)(6506007)(25786009)(103116003)(14454004)(105586002)(99286004)(54906003)(37006003)(6486002)(106356001)(316002)(8676002)(81166006)(81156014)(8936002)(6636002)(36756003)(478600001)(66066001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM3PR08MB0262; H:AM3PR08MB0611.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: INRGs08h2PKDgHaUggLeFDOtRhyMwWdxE1aW4zCetaVLAnX8IVpHuWsLWTjctIvmJkBcors+jtnKA0/LtJweuGW/IppwUjjGTVMJy1qjFz7KBEFoivC+RY4TqEBKWJptzE5f67DVMkO91u//mE/cgWWOl9V4rTUCYLsTtbLF6y2Aln7445CiabNnMabybAIfljx5Ye3CSYLOcI+D1wBVyDoraJcAGKIu1SRlM0+KoTLaIHLzc2cHxjcUf2y3ZD/ry8z966TkH2yPBfwFIGS61H7ruwwU9Z1NScSGuJsMZWoRgG0za+hvdLwZiyaHyxFy spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7c28083e-988d-4f00-f20d-08d66981c2bb X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Dec 2018 09:25:36.2211 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM3PR08MB0262 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nd , Ayan Halder , "Tiannan Zhu \(Arm Technology China\)" , "airlied@linux.ie" , "Jonathan Chai \(Arm Technology China\)" , Alexandru-Cosmin Gheorghe , "linux-kernel@vger.kernel.org" , "dri-devel@lists.freedesktop.org" , "Julien Yin \(Arm Technology China\)" , "yamada.masahiro@socionext.com" , "james qian wang \(Arm Technology China\)" , "malidp@foss.arm.com" , "Yiqi Kang \(Arm Technology China\)" , "maxime.ripard@bootlin.com" , "thomas Sun \(Arm Technology China\)" , "Jin Gao \(Arm Technology China\)" , "Lowry Li \(Arm Technology China\)" , "sean@poorly.run" Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Komeda driver treats KMS-CRTC/PLANE as user which will acquire pipeline resources, but we still need to release the unclaimed resources. crtc_atomic_check is the final check stage, so beside build a display data pipeline according the crtc_state, but still needs to release/disable the unclaimed pipeline resources. Signed-off-by: James (Qian) Wang --- .../gpu/drm/arm/display/komeda/komeda_crtc.c | 27 +++++++++ .../drm/arm/display/komeda/komeda_pipeline.h | 3 + .../display/komeda/komeda_pipeline_state.c | 58 +++++++++++++++++++ 3 files changed, 88 insertions(+) diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c index c896e46203ed..f84024aae155 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c +++ b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c @@ -14,6 +14,32 @@ #include "komeda_dev.h" #include "komeda_kms.h" +/* crtc_atomic_check is the final check stage, so beside build a display data + * pipeline according the crtc_state, but still needs to release/disable the + * unclaimed pipeline resources. + */ +static int +komeda_crtc_atomic_check(struct drm_crtc *crtc, + struct drm_crtc_state *state) +{ + struct komeda_crtc *kcrtc = to_kcrtc(crtc); + struct komeda_crtc_state *kcrtc_st = to_kcrtc_st(state); + int err; + + if (state->active) { + err = komeda_build_display_data_flow(kcrtc, kcrtc_st); + if (err) + return err; + } + + /* release unclaimed pipeline resources */ + err = komeda_release_unclaimed_resources(kcrtc->master, kcrtc_st); + if (err) + return err; + + return 0; +} + void komeda_crtc_handle_event(struct komeda_crtc *kcrtc, struct komeda_events *evts) { @@ -33,6 +59,7 @@ void komeda_crtc_handle_event(struct komeda_crtc *kcrtc, } struct drm_crtc_helper_funcs komeda_crtc_helper_funcs = { + .atomic_check = komeda_crtc_atomic_check, }; static const struct drm_crtc_funcs komeda_crtc_funcs = { diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h index bc4ed1513348..9a17d0152021 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h +++ b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h @@ -418,4 +418,7 @@ int komeda_build_layer_data_flow(struct komeda_layer *layer, int komeda_build_display_data_flow(struct komeda_crtc *kcrtc, struct komeda_crtc_state *kcrtc_st); +int komeda_release_unclaimed_resources(struct komeda_pipeline *pipe, + struct komeda_crtc_state *kcrtc_st); + #endif /* _KOMEDA_PIPELINE_H_*/ diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c index 05386e9d1749..920d2b40e9cc 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c +++ b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c @@ -42,6 +42,18 @@ komeda_pipeline_get_state(struct komeda_pipeline *pipe, return priv_to_pipe_st(priv_st); } +struct komeda_pipeline_state * +komeda_pipeline_get_new_state(struct komeda_pipeline *pipe, + struct drm_atomic_state *state) +{ + struct drm_private_state *priv_st; + + priv_st = drm_atomic_get_new_private_obj_state(state, &pipe->obj); + if (priv_st) + return priv_to_pipe_st(priv_st); + return NULL; +} + /* Assign a pipeline crtc */ struct komeda_pipeline_state * komeda_pipeline_get_state_and_set_crtc(struct komeda_pipeline *pipe, @@ -478,3 +490,49 @@ int komeda_build_display_data_flow(struct komeda_crtc *kcrtc, return 0; } + +void komeda_pipeline_unbound_components(struct komeda_pipeline *pipe, + struct komeda_pipeline_state *new) +{ + struct drm_atomic_state *drm_st = new->obj.state; + struct komeda_pipeline_state *old = priv_to_pipe_st(pipe->obj.state); + struct komeda_component_state *c_st; + struct komeda_component *c; + u32 disabling_comps, id; + + WARN_ON(!old); + + disabling_comps = (~new->active_comps) & old->active_comps; + + /* unbound all disabling component */ + dp_for_each_set_bit(id, disabling_comps) { + c = komeda_pipeline_get_component(pipe, id); + c_st = komeda_component_get_state_and_set_user(c, + drm_st, NULL, new->crtc); + WARN_ON(IS_ERR(c_st)); + } +} + +/* release unclaimed pipeline resource */ +int komeda_release_unclaimed_resources(struct komeda_pipeline *pipe, + struct komeda_crtc_state *kcrtc_st) +{ + struct drm_atomic_state *drm_st = kcrtc_st->base.state; + struct komeda_pipeline_state *st; + + /* ignore the pipeline which is not affected */ + if (!pipe || !has_bit(pipe->id, kcrtc_st->affected_pipes)) + return 0; + + if (has_bit(pipe->id, kcrtc_st->active_pipes)) + st = komeda_pipeline_get_new_state(pipe, drm_st); + else + st = komeda_pipeline_get_state_and_set_crtc(pipe, drm_st, NULL); + + if (WARN_ON(IS_ERR_OR_NULL(st))) + return -EINVAL; + + komeda_pipeline_unbound_components(pipe, st); + + return 0; +}