Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp2160567pxb; Fri, 25 Mar 2022 12:10:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy+yVc/S7hurtCNZ/N0SU49YZQg5/2gjbZtquAreB4xgEcaOHY7y3Q25WIv2/MLVezxEuHG X-Received: by 2002:a17:90a:5a86:b0:1bf:7860:c0f6 with SMTP id n6-20020a17090a5a8600b001bf7860c0f6mr26429928pji.213.1648235399914; Fri, 25 Mar 2022 12:09:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1648235399; cv=pass; d=google.com; s=arc-20160816; b=Ud48gkAw+l+i0SAZUNZsjjrsxOp/9wXQ7ronDPrBhUx6OBD6KM+UsIlqs+aww+hTkl fv7Z90900520+kyvt0xGfUDCIPNIguTWPUN1JgLbPZMMOnMjeAm3TUSAQawr/RVNLU7w ghBc8AnG0m2kD3P+Nk/5w5S98LwCKCoc/iZoq0KNM7LvvWQ8eHQET+kGX2DJLQbkMnBE /Zzsz9PrP3CPRpqxELPTELGFQqWQB/KrhracrbGP2BEZaBy4b3Xr2vL1lEsT+s5KNmnW V8VsIqWhhX9gFCrXT64O84icfymhN4cVdZqOiB1yZll9zWU0Pz7Y9iD9XfiGACelz3rc kPKQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:from:references:to:content-language:subject:user-agent :date:message-id:dkim-signature; bh=JCGYO3Bura0e2tky5kDzaxkj+p0yfec8xezurPKAmTs=; b=Pefc1olmn/Z68Yq+yr7Qo1Vf8fZjrnJ2FqKGnWvWsYoNMy11aUyyWkxrhKw28qImPo c3lKYoyj96bbQWRDbOk81Jm4TVqkU4WvZDyqaNTqcnXkq2B/VuLDPM36w4bE/LdDBGf9 uG4EQ8bkKBmrapzDkYBpEmWi863qeRwr+Lo2b3jeNwapzJbJFI1cZKD3P9DfYSyw3C46 IEE7Wgco317oqYFJrbCOA3ukoon6VryA3LUXx49AEWpMfQiUwDdtAasHrhO8hmi/KN3Z jsdOw7/wAvr0jjmuflz6A0oOx4Pm7X49Wud+MtqFWfdMY01o6XGXJ71mCVDbCcaO6iPW kdeA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=A8FrB4dd; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id r9-20020a170902e3c900b00153b2d16641si2741771ple.585.2022.03.25.12.09.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 12:09:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=A8FrB4dd; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F08A4207A17; Fri, 25 Mar 2022 11:16:21 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355895AbiCYHAE (ORCPT + 99 others); Fri, 25 Mar 2022 03:00:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354451AbiCYHAB (ORCPT ); Fri, 25 Mar 2022 03:00:01 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2076.outbound.protection.outlook.com [40.107.220.76]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36D7135DF7 for ; Thu, 24 Mar 2022 23:58:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H/S3LMHUas/Fj19fS93S+zCD9p5/glHVyP08YCJlhGvSODTntPXQcNBXpGm1LqoVSBRP7qZVOndyDIp/doQIibFbBmeVijTev+6vHhlOrppq7pvzAd63I+rJiw3aNa05j30u+M44pxSTluMXiRXMtDQh84dq4tnOSHcjgH3asTlKjdQBke4pBzJrEkr2fmleWmXdolEAUkO/A8B+P4zDldH8poK8tjP7oTCcoSrdYQ2ulVxG54jOkewqZPaZjUxQr/vtezXszK7S5rrecES9DJOpp097hh4/lxC6T6AuSYLnDI2zM+/GDx83Mh9+oB7o6HMpz7JpdzTMhZhzwRfrMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=JCGYO3Bura0e2tky5kDzaxkj+p0yfec8xezurPKAmTs=; b=TuI1Eqr8E1UQMv2DEWuBd/33ulaqLfxKhbZzSIrsDcc3qqe64xz8FLFI6tiIdZVrcS6MEpR+jFHAp53eP2qyQQacaZPDmmOULvOg6P+uB+wISBoIk6KSSJTt0KvC5QG+eqHH24L3k/aEJ8hhvnmKwREif6pCnyd9noRzmjux+lhWQj99FxS+/Dnjww+0wmul/OJaW3uJh0KUsBq80Lfe8OI3EnjAkiuwbSYLD2fOQvaVkuM4p3z7H5hR4C1Cr/0IzOsI0JgeBfBPirDclHv01f016cU+1FgXVzpZnCNL0j10/tYEdvFW6SJd8DiVHMkhjdenIUs521xA8jkB/FEIgQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JCGYO3Bura0e2tky5kDzaxkj+p0yfec8xezurPKAmTs=; b=A8FrB4dd+lfs7wfWcyRVLAgq4JSbOyzs3jggKffznBhbaz/T6H4yeu5z1Rk94WLmKPz/bnx/1YVMoKsyQd2A8B4un7lDjRhb/Ysjd0ZMq4vCzfd8ILvgIX9uGSc+Zvew+DazT7cbTYYF+6GEE5zdJpIMilbAjlhmikCpBXzXdvo= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from BN8PR12MB3587.namprd12.prod.outlook.com (2603:10b6:408:43::13) by BY5PR12MB3794.namprd12.prod.outlook.com (2603:10b6:a03:1aa::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.17; Fri, 25 Mar 2022 06:58:21 +0000 Received: from BN8PR12MB3587.namprd12.prod.outlook.com ([fe80::404f:1fc8:9f4c:f185]) by BN8PR12MB3587.namprd12.prod.outlook.com ([fe80::404f:1fc8:9f4c:f185%6]) with mapi id 15.20.5102.017; Fri, 25 Mar 2022 06:58:20 +0000 Message-ID: <2125c5b2-b377-076a-4177-d5ef482eb657@amd.com> Date: Fri, 25 Mar 2022 07:58:10 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH v2 3/25] drm/amdgpu: Disable ABM when AC mode Content-Language: en-US To: Ryan Lin , harry.wentland@amd.com, sunpeng.li@amd.com, alexander.deucher@amd.com, David1.Zhou@amd.com, airlied@linux.ie, daniel@ffwll.ch, seanpaul@chromium.org, bas@basnieuwenhuizen.nl, nicholas.kazlauskas@amd.com, sashal@kernel.org, markyacoub@google.com, victorchengchi.lu@amd.com, ching-shih.li@amd.corp-partner.google.com, Rodrigo.Siqueira@amd.com, ddavenport@chromium.org, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, leon.li@amd.com References: <20220325040515.4073706-1-tsung-hua.lin@amd.com> From: =?UTF-8?Q?Christian_K=c3=b6nig?= In-Reply-To: <20220325040515.4073706-1-tsung-hua.lin@amd.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: AM7PR02CA0012.eurprd02.prod.outlook.com (2603:10a6:20b:100::22) To BN8PR12MB3587.namprd12.prod.outlook.com (2603:10b6:408:43::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c920c1f7-0b35-411d-9e0b-08da0e2cd8ce X-MS-TrafficTypeDiagnostic: BY5PR12MB3794:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iJHd6nJaYBlxT9O7rm8CS/CFOs8XyPns1mdgOJz0VdxHF2DhyaHJWuJdwH3JPdF8ABM+oKoindWQQKjcgoGaaYpvddjGby07QjzPWcLy3qpeABjKw2TbOkkfqRqXPa9Q6Q1283xOlXSsOp80Oa1xo2c+qV0KO/PcBcBFwIWRCQupHWJpduLw41t2kKqD/wx0KChHAODJvbvSK/pBRfa2nTzC5nVHDSC6rFGmNrSOIrZEleD93fWYLr9jVyIvkNzuc3L8eKwrJ2nFm/gPYJ8W4MIOao6eVwHsu28PVo9D1htuyFSlKODrn3ynj5ZlLn5qsIXEz/AqFRmp86OmIqy9BUmUEc/SHzH4+eP1SF5cKBwd2i/CLs8zkbY4lP1Ej170czsq8e0yJklqmCGHeR1Ppq7HtIzquS/+E4lyyIOysvhI8g9RJXE5bJ0rAmt51T+F4rnNWQSqo2XlGrT1eZHnr68If5BolqZhtIxLUivw4e3OKKRZUlVFl4c9EO6fVXTP5Mp3cdaRPasS3wqyWTaAMZNfcZ5ZOoucnlqHlFU++4Qbzs+MyqhCAuPAHMO3SyltStg7V7J9HxYZW4WAVVTBsPYMe4ACY4CsQqYN1bJHX3KXRhZ+2qYbU/ZOQBE+CaDdDKighKwAlwy/Y10yUBJzfvT2pLYxNl10GGlSTvZEbn9+2EiTVjaz17WrD3vTO2yf2xtUpQMkQJ7xF4IGJ6+KESY90nLVEi2t2cDw3BH3QShU4vn6uvHauu5NgTKPnDwr+BW8FWPLH8gdZdngZbP65w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN8PR12MB3587.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(86362001)(66946007)(8676002)(66556008)(31686004)(6512007)(31696002)(66476007)(2906002)(5660300002)(26005)(316002)(7416002)(6486002)(186003)(36756003)(508600001)(83380400001)(921005)(6636002)(38100700002)(6666004)(2616005)(6506007)(8936002)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?ZVU3aWgxOW1ONU5yVWRSY3hrQ1JtM2phb04yWnhmd0ZUeFlGK3hSQ2VscFhN?= =?utf-8?B?SlR6T2ZLSGlkcldROURSdFZMcEEyalZsV3RaUTBwczM0NzdpdkZyOWlHU0Uz?= =?utf-8?B?czVKajNHZDhhZ3RRL3pXcFNHOHFZd0c3YUVCaXRoWlNrdzdhb0M2WGdFWXZP?=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wwRFJWSVNSV2FEQy8wZHR5Tk5Zd09ZNk9y?= =?utf-8?B?MU84TDNTenBob1RxWDdtVXpvNXZjZTB5cFBIVlBhRUZRa3Nid0tkZ1dlcTFh?= =?utf-8?B?eW9BbUdTYk1XU3pJWHRqWHlWaDNYVER0SnNLTjVnNGY4YjZ3SUgxMGJQOHNQ?= =?utf-8?B?Zlg5emVYc2VvOTVmdE4wc0hoU1RPL3VrQ3BKc29vb1pwMERTME1FSFJOUlVq?= =?utf-8?B?ZS9SMThrNnJJZm9Pbk0zNS93TGZIcktJak0rdUdNdXVrMVlUV21tb1FlS0hj?= =?utf-8?B?eWlvMElJOEtPZmFBMXJwUGM1UG9YeFNnV2ZnblNqdGVQUGt6bHNwVk5lS3Yv?= =?utf-8?B?NXhrUzNYWUVvSm43RURqaU9DSWlPVnBOcStIbjlDeTk4UjBacVNjdz09?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: c920c1f7-0b35-411d-9e0b-08da0e2cd8ce X-MS-Exchange-CrossTenant-AuthSource: BN8PR12MB3587.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Mar 2022 06:58:20.7147 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 9i7SkFahVMssI8iobMqNUchJpVpGBx5WXrTMvIuzk7ixdnZ1xiv4fkkWvzMq+3me X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB3794 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=no 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 Am 25.03.22 um 05:05 schrieb Ryan Lin: > Disable ABM feature when the system is running on AC mode to get > the more perfect contrast of the display. > > Signed-off-by: Ryan Lin > > --- > drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 4 ++ > drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 1 + > drivers/gpu/drm/amd/display/dc/dce/dmub_abm.c | 58 ++++++++++++------- > drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h | 1 + > 4 files changed, 42 insertions(+), 22 deletions(-) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c > index c560c1ab62ecb..bc8bb9aad2e36 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c > @@ -822,6 +822,10 @@ static int amdgpu_acpi_event(struct notifier_block *nb, > struct amdgpu_device *adev = container_of(nb, struct amdgpu_device, acpi_nb); > struct acpi_bus_event *entry = (struct acpi_bus_event *)data; > > + if (strcmp(entry->device_class, "battery") == 0) { String comparison in a hot path is not something we usually like to see in the kernel. Isn't there any other way to detect that? Like a flag or similar? Regards, Christian. > + adev->pm.ac_power = power_supply_is_system_supplied() > 0; > + } > + > if (strcmp(entry->device_class, ACPI_AC_CLASS) == 0) { > if (power_supply_is_system_supplied() > 0) > DRM_DEBUG_DRIVER("pm: AC\n"); > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c > index abfcc1304ba0c..3a0afe7602727 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c > @@ -3454,6 +3454,7 @@ int amdgpu_device_init(struct amdgpu_device *adev, > > adev->gfx.gfx_off_req_count = 1; > adev->pm.ac_power = power_supply_is_system_supplied() > 0; > + adev->pm.old_ac_power = true; > > atomic_set(&adev->throttling_logging_enabled, 1); > /* > diff --git a/drivers/gpu/drm/amd/display/dc/dce/dmub_abm.c b/drivers/gpu/drm/amd/display/dc/dce/dmub_abm.c > index 54a1408c8015c..478a734b66926 100644 > --- a/drivers/gpu/drm/amd/display/dc/dce/dmub_abm.c > +++ b/drivers/gpu/drm/amd/display/dc/dce/dmub_abm.c > @@ -23,6 +23,8 @@ > * > */ > > +#include > +#include "amdgpu.h" > #include "dmub_abm.h" > #include "dce_abm.h" > #include "dc.h" > @@ -51,6 +53,7 @@ > #define DISABLE_ABM_IMMEDIATELY 255 > > > +extern uint amdgpu_dm_abm_level; > > static void dmub_abm_enable_fractional_pwm(struct dc_context *dc) > { > @@ -117,28 +120,6 @@ static void dmub_abm_init(struct abm *abm, uint32_t backlight) > dmub_abm_enable_fractional_pwm(abm->ctx); > } > > -static unsigned int dmub_abm_get_current_backlight(struct abm *abm) > -{ > - struct dce_abm *dce_abm = TO_DMUB_ABM(abm); > - unsigned int backlight = REG_READ(BL1_PWM_CURRENT_ABM_LEVEL); > - > - /* return backlight in hardware format which is unsigned 17 bits, with > - * 1 bit integer and 16 bit fractional > - */ > - return backlight; > -} > - > -static unsigned int dmub_abm_get_target_backlight(struct abm *abm) > -{ > - struct dce_abm *dce_abm = TO_DMUB_ABM(abm); > - unsigned int backlight = REG_READ(BL1_PWM_TARGET_ABM_LEVEL); > - > - /* return backlight in hardware format which is unsigned 17 bits, with > - * 1 bit integer and 16 bit fractional > - */ > - return backlight; > -} > - > static bool dmub_abm_set_level(struct abm *abm, uint32_t level) > { > union dmub_rb_cmd cmd; > @@ -148,6 +129,9 @@ static bool dmub_abm_set_level(struct abm *abm, uint32_t level) > int edp_num; > uint8_t panel_mask = 0; > > + if (power_supply_is_system_supplied() > 0) > + level = 0; > + > get_edp_links(dc->dc, edp_links, &edp_num); > > for (i = 0; i < edp_num; i++) { > @@ -170,6 +154,36 @@ static bool dmub_abm_set_level(struct abm *abm, uint32_t level) > return true; > } > > +static unsigned int dmub_abm_get_current_backlight(struct abm *abm) > +{ > + struct dce_abm *dce_abm = TO_DMUB_ABM(abm); > + unsigned int backlight = REG_READ(BL1_PWM_CURRENT_ABM_LEVEL); > + struct dc_context *dc = abm->ctx; > + struct amdgpu_device *adev = dc->driver_context; > + > + if (adev->pm.ac_power != adev->pm.old_ac_power) { > + dmub_abm_set_level(abm, amdgpu_dm_abm_level); > + adev->pm.ac_power = power_supply_is_system_supplied() > 0; > + adev->pm.old_ac_power = adev->pm.ac_power; > + } > + > + /* return backlight in hardware format which is unsigned 17 bits, with > + * 1 bit integer and 16 bit fractional > + */ > + return backlight; > +} > + > +static unsigned int dmub_abm_get_target_backlight(struct abm *abm) > +{ > + struct dce_abm *dce_abm = TO_DMUB_ABM(abm); > + unsigned int backlight = REG_READ(BL1_PWM_TARGET_ABM_LEVEL); > + > + /* return backlight in hardware format which is unsigned 17 bits, with > + * 1 bit integer and 16 bit fractional > + */ > + return backlight; > +} > + > static bool dmub_abm_init_config(struct abm *abm, > const char *src, > unsigned int bytes, > diff --git a/drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h b/drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h > index f6e0e7d8a0077..de459411a0e83 100644 > --- a/drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h > +++ b/drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h > @@ -445,6 +445,7 @@ struct amdgpu_pm { > uint32_t smu_prv_buffer_size; > struct amdgpu_bo *smu_prv_buffer; > bool ac_power; > + bool old_ac_power; > /* powerplay feature */ > uint32_t pp_feature; >