From patchwork Fri Mar 1 05:25:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manikandan Muralidharan X-Patchwork-Id: 208645 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp872915dyb; Thu, 29 Feb 2024 21:27:10 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXEKKAuo+vA++Vd/5V9cBz3aklXm7QcxW8hYqNAVLVqUplvmVHtTpSxBAUKKMAZpjCwBm/Fgr+rlm6/fsFy+MY0KQK1vg== X-Google-Smtp-Source: AGHT+IHflZz8BU6BFYwLjOAaRhneSERHG6Dymd1G3D9u5ZJGkWfKXjeFnZhf+yzM7G8BumYoND/9 X-Received: by 2002:a05:6808:3091:b0:3c1:d24d:8880 with SMTP id bl17-20020a056808309100b003c1d24d8880mr875274oib.0.1709270830622; Thu, 29 Feb 2024 21:27:10 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709270830; cv=pass; d=google.com; s=arc-20160816; b=wsHIopMm49OlH5fuf37PXP75GiX13tcVkqVip3GGij7X3uWiZ3WYGX3ppFKA6zOopr PshLJZDTRBuYzbip1PuQvqJqqWSGrJtYHFk6kAXZkXh9SmRzOKR7iuCmfjP8MK/zlcrI zvHTees1l2s+WCiGBtncywH8gEjD6p8VTOL3MmOxjeHZvHuEBdVCd/eum7zlm+DW3FZM 6qfnbSktOVTI+bg1NjzvTR2M8jdBdeWzCGh2F0+gMjzP8XJlgwP52rpOYZGCqX7xOnBu Ub26AIdfn9VM6IZBdNQ1vxIpetmDF5A9tF9Mn77wLiwhcAtgFSoW9anzzfNL9Zb8Lf/8 5P5g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=1aCtw31Up0emr7Mp17tgdpk0IEerpp8FZcW5qjqdKjc=; fh=7zDsz27mBsgtoAIkbjOnm5GqQoRyvNqJW2tpYGq12lU=; b=z0s7MPw08fwxKVCDlnwQzdfogvrovnd2gq0jH6POHuogdPPKWN9OLaJX58UtY59Cbv zfn+RBRo3mXt++kBRONpT2Ysz75QGklH64TUun6PXezHuYONMzHVph0ToaEgKZ2IWj1r 0vbCY5F9T8mzRb4BDogNEtGn1vthNiMaATi3q0zN0ZLPrGgLWm5KXYqQ+TgzZvfEmhxk 1qX79aAfgQWf8V/LN2jcnhhi04x40M7mLoML0prZmEEY6mIdALc5+oUXNEsOc3+8QlQb w9gMtSlDP/5HDampv1neoFnjIRO8dljwLw66qntZ6qOQkp8dVoM8HGnXqW89kmONQFXT XxjA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=JgH7ppQK; arc=pass (i=1 spf=pass spfdomain=microchip.com dkim=pass dkdomain=microchip.com dmarc=pass fromdomain=microchip.com); spf=pass (google.com: domain of linux-kernel+bounces-87917-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87917-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=REJECT dis=NONE) header.from=microchip.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id n7-20020aa79847000000b006e5840bb198si2711919pfq.130.2024.02.29.21.27.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 21:27:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-87917-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=JgH7ppQK; arc=pass (i=1 spf=pass spfdomain=microchip.com dkim=pass dkdomain=microchip.com dmarc=pass fromdomain=microchip.com); spf=pass (google.com: domain of linux-kernel+bounces-87917-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87917-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=REJECT dis=NONE) header.from=microchip.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 86763282E2D for ; Fri, 1 Mar 2024 05:26:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EB76F52F60; Fri, 1 Mar 2024 05:26:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b="JgH7ppQK" Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 80BFD5026D for ; Fri, 1 Mar 2024 05:26:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=68.232.153.233 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709270792; cv=none; b=KzggwBK+pMmEGVk+/9VGPkoPuuvi1bu27ggK4F99/+cO/6RjJpYUpTP87Wb5IeFkz9oOCGOxVVlB9+pU+mAFu6QNMWCcXeKF6J/UOBycdiz6ZdEVk035j81r3TA3bLqOV4dOCim07ITBAcQKen4STItrhDODbknicqh9iK1QDis= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709270792; c=relaxed/simple; bh=EJ7HICHgLilFrtLK8BajK1eVr4wt6O4I9e6krZgg5WE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PnttEXgtIodD3XV9Sao1IHCcLcYF58ede2GVQ2vaSE9K9VyYLmVu1CZ2OyB2eqPDetVTZHo+xRNKD7vo4t+7pXqZvNDEeWV293TnNlsX83i6+O+oSyatoEzPV+l44MnnGA1x0M8pofCn22nZoZjtqD0apWyTyvVk44Fczs2i4z4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=microchip.com; spf=pass smtp.mailfrom=microchip.com; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b=JgH7ppQK; arc=none smtp.client-ip=68.232.153.233 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=microchip.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=microchip.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1709270791; x=1740806791; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=EJ7HICHgLilFrtLK8BajK1eVr4wt6O4I9e6krZgg5WE=; b=JgH7ppQKn7Fj5UFWMnh9BfTsRfht2jzjT75qpGega+efQO9W1+L2+EBu M3gsZgLb/Hg0YdpM1KHJ8luTFdrhvjYI0rFWtxrIQ1LfSTz7qr50HsRap 6U3yFdzU9yIFm6kH2A7vyGIhsBlRB+L3+4WCOLhvt+H0lkHDWj2ntTOKX uNsAVj5CshUWP7nNnizqnA23hBnPTquKugSiXwKh3hh6ZgZRTFYcAtFms o16XNR1v8u1y9ZUKRGkgtURTkCInKllRB2JhIsWBl0IjyDWnvhZHIYV1/ cm1UNKFOZCo9qls1lQwL3lyQnt9Nb7JTMF/vg4SdyHM8OPCNuJluE4lmb w==; X-CSE-ConnectionGUID: epEW2Y4BQQKheh4DRATFNw== X-CSE-MsgGUID: KupV2im5SROLBogtWp8nUw== X-IronPort-AV: E=Sophos;i="6.06,195,1705388400"; d="scan'208";a="247809239" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa5.microchip.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 29 Feb 2024 22:26:28 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 29 Feb 2024 22:26:19 -0700 Received: from che-lt-i67131.microchip.com (10.10.85.11) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Thu, 29 Feb 2024 22:26:11 -0700 From: Manikandan Muralidharan To: , , , , , , , , , , , , , CC: , , , , , , , , "Manikandan Muralidharan" Subject: [PATCH v9 3/8] drm: atmel_hlcdc: replace regmap_read with regmap_read_poll_timeout Date: Fri, 1 Mar 2024 10:55:29 +0530 Message-ID: <20240301052534.38651-4-manikandan.m@microchip.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240301052534.38651-1-manikandan.m@microchip.com> References: <20240301052534.38651-1-manikandan.m@microchip.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792300370011188402 X-GMAIL-MSGID: 1792300370011188402 Replace regmap_read with regmap_read_poll_timeout to neatly handle retries Signed-off-by: Manikandan Muralidharan --- .../gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c | 44 +++++++++++-------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c index cc5cf4c2faf7..b229692a27ca 100644 --- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c +++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c @@ -203,19 +203,22 @@ static void atmel_hlcdc_crtc_atomic_disable(struct drm_crtc *c, pm_runtime_get_sync(dev->dev); regmap_write(regmap, ATMEL_HLCDC_DIS, ATMEL_HLCDC_DISP); - while (!regmap_read(regmap, ATMEL_HLCDC_SR, &status) && - (status & ATMEL_HLCDC_DISP)) - cpu_relax(); + if (regmap_read_poll_timeout(regmap, ATMEL_HLCDC_SR, status, + !(status & ATMEL_HLCDC_DISP), + 10, 1000)) + dev_warn(dev->dev, "Atmel LCDC status register DISPSTS timeout\n"); regmap_write(regmap, ATMEL_HLCDC_DIS, ATMEL_HLCDC_SYNC); - while (!regmap_read(regmap, ATMEL_HLCDC_SR, &status) && - (status & ATMEL_HLCDC_SYNC)) - cpu_relax(); + if (regmap_read_poll_timeout(regmap, ATMEL_HLCDC_SR, status, + !(status & ATMEL_HLCDC_SYNC), + 10, 1000)) + dev_warn(dev->dev, "Atmel LCDC status register LCDSTS timeout\n"); regmap_write(regmap, ATMEL_HLCDC_DIS, ATMEL_HLCDC_PIXEL_CLK); - while (!regmap_read(regmap, ATMEL_HLCDC_SR, &status) && - (status & ATMEL_HLCDC_PIXEL_CLK)) - cpu_relax(); + if (regmap_read_poll_timeout(regmap, ATMEL_HLCDC_SR, status, + !(status & ATMEL_HLCDC_PIXEL_CLK), + 10, 1000)) + dev_warn(dev->dev, "Atmel LCDC status register CLKSTS timeout\n"); clk_disable_unprepare(crtc->dc->hlcdc->sys_clk); pinctrl_pm_select_sleep_state(dev->dev); @@ -241,20 +244,23 @@ static void atmel_hlcdc_crtc_atomic_enable(struct drm_crtc *c, clk_prepare_enable(crtc->dc->hlcdc->sys_clk); regmap_write(regmap, ATMEL_HLCDC_EN, ATMEL_HLCDC_PIXEL_CLK); - while (!regmap_read(regmap, ATMEL_HLCDC_SR, &status) && - !(status & ATMEL_HLCDC_PIXEL_CLK)) - cpu_relax(); - + if (regmap_read_poll_timeout(regmap, ATMEL_HLCDC_SR, status, + status & ATMEL_HLCDC_PIXEL_CLK, + 10, 1000)) + dev_warn(dev->dev, "Atmel LCDC status register CLKSTS timeout\n"); regmap_write(regmap, ATMEL_HLCDC_EN, ATMEL_HLCDC_SYNC); - while (!regmap_read(regmap, ATMEL_HLCDC_SR, &status) && - !(status & ATMEL_HLCDC_SYNC)) - cpu_relax(); + if (regmap_read_poll_timeout(regmap, ATMEL_HLCDC_SR, status, + status & ATMEL_HLCDC_SYNC, + 10, 1000)) + dev_warn(dev->dev, "Atmel LCDC status register LCDSTS timeout\n"); regmap_write(regmap, ATMEL_HLCDC_EN, ATMEL_HLCDC_DISP); - while (!regmap_read(regmap, ATMEL_HLCDC_SR, &status) && - !(status & ATMEL_HLCDC_DISP)) - cpu_relax(); + if (regmap_read_poll_timeout(regmap, ATMEL_HLCDC_SR, status, + status & ATMEL_HLCDC_DISP, + 10, 1000)) + dev_warn(dev->dev, "Atmel LCDC status register DISPSTS timeout\n"); + pm_runtime_put_sync(dev->dev);