From patchwork Fri May 24 02:55:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Qian Wang X-Patchwork-Id: 10959051 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 CC4C415A6 for ; Fri, 24 May 2019 02:55:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A6BB4287AE for ; Fri, 24 May 2019 02:55:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9A0242881D; Fri, 24 May 2019 02:55:54 +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 84840287AE for ; Fri, 24 May 2019 02:55:53 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 207E888FB2; Fri, 24 May 2019 02:55:52 +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-eopbgr30066.outbound.protection.outlook.com [40.107.3.66]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0C41188FB2 for ; Fri, 24 May 2019 02:55:50 +0000 (UTC) Received: from VE1PR08MB5006.eurprd08.prod.outlook.com (10.255.159.31) by VE1PR08MB4736.eurprd08.prod.outlook.com (10.255.112.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1878.24; Fri, 24 May 2019 02:55:46 +0000 Received: from VE1PR08MB5006.eurprd08.prod.outlook.com ([fe80::206b:5cf6:97e:1358]) by VE1PR08MB5006.eurprd08.prod.outlook.com ([fe80::206b:5cf6:97e:1358%7]) with mapi id 15.20.1922.017; Fri, 24 May 2019 02:55:45 +0000 From: "james qian wang (Arm Technology China)" To: Liviu Dudau , "airlied@linux.ie" , Brian Starkey , "maarten.lankhorst@linux.intel.com" , "sean@poorly.run" Subject: [PATCH] drm/komeda: Refine function to_d71_input_id Thread-Topic: [PATCH] drm/komeda: Refine function to_d71_input_id Thread-Index: AQHVEdwuBJcfhXXS+U+jyK/WXjH9OA== Date: Fri, 24 May 2019 02:55:45 +0000 Message-ID: <20190524025525.19134-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: HK0PR01CA0028.apcprd01.prod.exchangelabs.com (2603:1096:203:3e::16) To VE1PR08MB5006.eurprd08.prod.outlook.com (2603:10a6:803:113::31) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 4f9cc606-7c04-4580-f719-08d6dff3508f x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600141)(711020)(4605104)(4618075)(2017052603328)(7193020); SRVR:VE1PR08MB4736; x-ms-traffictypediagnostic: VE1PR08MB4736: x-ms-exchange-purlcount: 1 nodisclaimer: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:5236; x-forefront-prvs: 0047BC5ADE x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(376002)(136003)(346002)(39860400002)(396003)(366004)(199004)(189003)(36756003)(486006)(316002)(476003)(2616005)(6306002)(6512007)(6436002)(305945005)(478600001)(50226002)(14444005)(256004)(7736002)(86362001)(81166006)(6486002)(8676002)(71200400001)(966005)(2201001)(8936002)(81156014)(71190400001)(53936002)(2501003)(25786009)(5660300002)(2906002)(4326008)(386003)(14454004)(66446008)(1076003)(6506007)(52116002)(66556008)(66066001)(54906003)(99286004)(110136005)(3846002)(186003)(6116002)(64756008)(103116003)(66946007)(102836004)(26005)(55236004)(68736007)(73956011)(66476007); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR08MB4736; H:VE1PR08MB5006.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: BDS40woZHowihxgx+RHI6Up9maH3rYbYsTtHMHsetYayN9VSSBd0qugAKoLOXkcKeS1h6vFwdrEAbKjAOXIivEY2fBzoa36T4c2gfHvK1p+w76tqlykJ6ckaRwIg+xxW3W8Uha0hH+izd9pwsvulMRgyDMNMR7QHb0SmmSZMvW7QXryZd5NMWe2o6Gtky4e6ZPCIZsKB/jWIcCfJFqfh7NcKobucSZhYb9XWLlA70GUTjCIU2VIwdQJu41nLsg0IBPSFCRZUqZ/PdrLbFMxmn6kjHSL+GajqiAvfJVcPTg/hWHqlpHPLt0oKvkIgYGkDSISM9NEDehr0c7Fzf6tbrUnqBl9z/4/ZKy7Z2Hrkb7Z+VG7L3h3Xfp7atC0msPp21fKe0kkmNj1l0WohFImm4j9103HHm76hmavQPGivXKE= MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4f9cc606-7c04-4580-f719-08d6dff3508f X-MS-Exchange-CrossTenant-originalarrivaltime: 24 May 2019 02:55:45.8153 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4736 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector1-arm-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=eVSu/nEfhJKftFbch/0iUkLJh2GfIX7qVgVQ1SbPFlY=; b=ePWRj/pn7HJN4XcbX3jleVptaM0xoETMNKaJBFlG96ahPyk6NulbDepKdzbqCnNyqcmrjedNPA1XMqCowGohjEX/b0nbmkB/qphd3quf0C+M1tpHtRXa+XhJPUBhe+R/65GHquLJyQMZzYT6qBZom1P1tZ0P5odv8BaJtRWWqhU= X-Mailman-Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=james.qian.wang@arm.com; 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 , "Oscar Zhang \(Arm Technology China\)" , "Tiannan Zhu \(Arm Technology China\)" , "Jonathan Chai \(Arm Technology China\)" , "linux-kernel@vger.kernel.org" , "dri-devel@lists.freedesktop.org" , "Julien Yin \(Arm Technology China\)" , "Channing Chen \(Arm Technology China\)" , "james qian wang \(Arm Technology China\)" , "Yiqi Kang \(Arm Technology China\)" , "thomas Sun \(Arm Technology China\)" , "Lowry Li \(Arm Technology China\)" , Ben Davis Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Since the component_state->input[i] is only valid when it is active, the content of input[i] is undefined if it is inactive. The user must check the state->active_inputs with input index firstly before using state->input[i]. Refine the function to_d71_input_id and directly move such check into it. Simplify the using and avoid problem that caller forget the valid check. Depends on: - https://patchwork.freedesktop.org/series/60856/ Signed-off-by: James Qian Wang (Arm Technology China) --- .../arm/display/komeda/d71/d71_component.c | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c b/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c index d101a5cc2766..fff9fc8fab15 100644 --- a/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c +++ b/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c @@ -156,11 +156,15 @@ static u32 to_ad_ctrl(u64 modifier) return afbc_ctrl; } -static inline u32 to_d71_input_id(struct komeda_component_output *output) +static inline u32 to_d71_input_id(struct komeda_component_state *st, int idx) { - struct komeda_component *comp = output->component; + struct komeda_component_output *input = &st->inputs[idx]; - return comp ? (comp->hw_id + output->output_port) : 0; + /* if input is not active, set hw input_id(0) to disable it */ + if (has_bit(idx, st->active_inputs)) + return input->component->hw_id + input->output_port; + else + return 0; } static void d71_layer_update_fb(struct komeda_component *c, @@ -388,7 +392,7 @@ static void d71_wb_layer_update(struct komeda_component *c, ctrl |= LW_TBU_EN; malidp_write32(reg, BLK_IN_SIZE, HV_SIZE(st->hsize, st->vsize)); - malidp_write32(reg, BLK_INPUT_ID0, to_d71_input_id(&state->inputs[0])); + malidp_write32(reg, BLK_INPUT_ID0, to_d71_input_id(state, 0)); malidp_write32_mask(reg, BLK_CONTROL, mask, ctrl); } @@ -512,15 +516,15 @@ static void d71_compiz_update(struct komeda_component *c, struct komeda_compiz_state *st = to_compiz_st(state); u32 __iomem *reg = c->reg; u32 __iomem *id_reg, *cfg_reg; - u32 index, input_hw_id; + u32 index; for_each_changed_input(state, index) { id_reg = reg + index; cfg_reg = reg + index * CU_PER_INPUT_REGS; - input_hw_id = to_d71_input_id(&state->inputs[index]); if (state->active_inputs & BIT(index)) { compiz_enable_input(id_reg, cfg_reg, - input_hw_id, &st->cins[index]); + to_d71_input_id(state, index), + &st->cins[index]); } else { malidp_write32(id_reg, BLK_INPUT_ID0, 0); malidp_write32(cfg_reg, CU_INPUT0_CONTROL, 0); @@ -696,7 +700,7 @@ static void d71_scaler_update(struct komeda_component *c, ctrl |= SC_CTRL_LS; malidp_write32(reg, BLK_CONTROL, ctrl); - malidp_write32(reg, BLK_INPUT_ID0, to_d71_input_id(&state->inputs[0])); + malidp_write32(reg, BLK_INPUT_ID0, to_d71_input_id(state, 0)); } static void d71_scaler_dump(struct komeda_component *c, struct seq_file *sf) @@ -772,7 +776,7 @@ static void d71_merger_update(struct komeda_component *c, for_each_changed_input(state, index) malidp_write32(reg, MG_INPUT_ID0 + index * 4, - to_d71_input_id(&state->inputs[index])); + to_d71_input_id(state, index)); malidp_write32(reg, MG_SIZE, HV_SIZE(st->hsize_merged, st->vsize_merged)); @@ -839,13 +843,11 @@ static void d71_improc_update(struct komeda_component *c, { struct komeda_improc_state *st = to_improc_st(state); u32 __iomem *reg = c->reg; - u32 index, input_hw_id; + u32 index; - for_each_changed_input(state, index) { - input_hw_id = state->active_inputs & BIT(index) ? - to_d71_input_id(&state->inputs[index]) : 0; - malidp_write32(reg, BLK_INPUT_ID0 + index * 4, input_hw_id); - } + for_each_changed_input(state, index) + malidp_write32(reg, BLK_INPUT_ID0 + index * 4, + to_d71_input_id(state, index)); malidp_write32(reg, BLK_SIZE, HV_SIZE(st->hsize, st->vsize)); }