Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp878656pxk; Thu, 17 Sep 2020 20:07:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxe+sFNDC0kPe89bhUg26XCcRMQzE9UdMt1R0rfsQhVx/Q2a8HKh67JyPH8psFDVF+WF23i X-Received: by 2002:a17:906:edd6:: with SMTP id sb22mr32171314ejb.499.1600398471675; Thu, 17 Sep 2020 20:07:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600398471; cv=none; d=google.com; s=arc-20160816; b=kWlKScUaNVcav8n3Fy1Y5YumX7ooKJw5uvqAz9iqWTpqV8LOeS3nV29vZFWoo7LXlJ p9PFkhn+SivR6uiQxSVvdtOY4W/xjyw0DjxM5u+KJne942+a11ZcLBcN4QlOXSGZVG69 /i4Mz5t59Tc/QCnOU/vx2tVIZBmRV3LV1eHDES+ed2BkB+OSjp3K9ebH5LfsNLaDifbE I908hbswYUUfJ58wRmKKKO7kxg9poxbx2w7iytZ7vQGwtUov/r+3f2jMgug4CO3rHnkv z4+9UZ7TDmCmJo86BmthT4SlJZXutGECJvsDzv282CLu6Ckf7RzPYsRF8h+MOR9VrJvb 4L5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=eIuhU2FM82x453eT52Is0/QZ07GLhzrd43ybCqM2ecg=; b=BcZRk7tNRKNZLlVu8pWvIiCwHfEWRI3WsJVpdRBDDUzBWXuXvqI/ea5yizH3VrKtQL SaIQbQ7zshy75Mz+vTKyzsLCtiLMB5+pQxuMNVXnxkrsA2rE/4ItYhCt7b4K3lvSv1LP 0dPGl9j9AIzI+nSmwSx4MHIoHxj+fdyYvf1/aoCVaNznEGxp+Lv4wvGGiQ6WK7LRszkE VG16zuu7PDIVTVi0Y5Vliz0mUtaWq2aIXncQWYC/IBYtF1iSSFVE7AxQrqD7a4w77RmF tPVZ9V4O5JyOYS68xe+KNMKQb2nu5qasC3hzLh8ramL9QDV+S/QtJ7N6vTCQboHG5FXp 5ijA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Nu4Ysi22; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s19si1252336ejv.149.2020.09.17.20.07.28; Thu, 17 Sep 2020 20:07:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Nu4Ysi22; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727827AbgIRDEB (ORCPT + 99 others); Thu, 17 Sep 2020 23:04:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:52690 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727404AbgIRCEz (ORCPT ); Thu, 17 Sep 2020 22:04:55 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C464E23600; Fri, 18 Sep 2020 02:04:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394694; bh=Vy3oNGCIxgcE+Ef5pKgHXhU+95PX0TzT+/AzkAtliUE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Nu4Ysi22Totlw5552tjLj2ISGHhwcVpsmv9D1mG7ZwqvuzcUHtHxy+Hm/uR0bszNk Vx4Bzj60mXHfPrcg3dy442gC0Pfsu5T/0VV//VAafjTzu7PJHOI7gZj23xh48z2XfO x4v/mzhSky0ZdIdpZ6nB8SlF+cEBzS4Q7Eh0agLk= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jordan Crouse , Eric Anholt , Rob Clark , Sasha Levin , dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 5.4 182/330] drm/msm/a5xx: Always set an OPP supported hardware value Date: Thu, 17 Sep 2020 21:58:42 -0400 Message-Id: <20200918020110.2063155-182-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020110.2063155-1-sashal@kernel.org> References: <20200918020110.2063155-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jordan Crouse [ Upstream commit 0478b4fc5f37f4d494245fe7bcce3f531cf380e9 ] If the opp table specifies opp-supported-hw as a property but the driver has not set a supported hardware value the OPP subsystem will reject all the table entries. Set a "default" value that will match the default table entries but not conflict with any possible real bin values. Also fix a small memory leak and free the buffer allocated by nvmem_cell_read(). Signed-off-by: Jordan Crouse Reviewed-by: Eric Anholt Signed-off-by: Rob Clark Signed-off-by: Sasha Levin --- drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c index 7829247de60e0..de0ea1d09a54f 100644 --- a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c @@ -1407,18 +1407,31 @@ static const struct adreno_gpu_funcs funcs = { static void check_speed_bin(struct device *dev) { struct nvmem_cell *cell; - u32 bin, val; + u32 val; + + /* + * If the OPP table specifies a opp-supported-hw property then we have + * to set something with dev_pm_opp_set_supported_hw() or the table + * doesn't get populated so pick an arbitrary value that should + * ensure the default frequencies are selected but not conflict with any + * actual bins + */ + val = 0x80; cell = nvmem_cell_get(dev, "speed_bin"); - /* If a nvmem cell isn't defined, nothing to do */ - if (IS_ERR(cell)) - return; + if (!IS_ERR(cell)) { + void *buf = nvmem_cell_read(cell, NULL); + + if (!IS_ERR(buf)) { + u8 bin = *((u8 *) buf); - bin = *((u32 *) nvmem_cell_read(cell, NULL)); - nvmem_cell_put(cell); + val = (1 << bin); + kfree(buf); + } - val = (1 << bin); + nvmem_cell_put(cell); + } dev_pm_opp_set_supported_hw(dev, &val, 1); } -- 2.25.1