Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1059431pxk; Mon, 31 Aug 2020 08:43:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzuBCP+TTYGNZHCPVJ0uAGEjIF4FTWVnyLUbxvuUvAV3dLNVaBMCMEp9iPWQ9R2bTxbCCqx X-Received: by 2002:a50:c3c4:: with SMTP id i4mr1777172edf.244.1598888615991; Mon, 31 Aug 2020 08:43:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598888615; cv=none; d=google.com; s=arc-20160816; b=qGIqcTbWa5GZ4eS4xicSW159LxzGqMh5QrBi15qPCIJAbTLKN9VCVQsALn3QC8BqY4 E53JYYSSNECGNQ/TgB899s4wQwbF1Hf4GfeFUIi5I17LeAMYu8RYwdQdbiB+MnlqxO6p w/V44b5WVv5h/1pNyRVUkn8ePgiSsV8GjF3QDnpT8O4cUQNhhXGVT2epjaFxmvls8FKa bvp/mFz7G2Y+nS+7v8yFYzxtr6/Qgy4yvwbZ+Tx3e7juOqBY0PS1F0Q+cAbhTnFx7R51 vqA+uhDi3e/EZVOxsi5XmpzeQCNbI7ZYJXoPrvOoye4QJGZf1McYkPIWkVojK7ATQnGm oXsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=fnpmRwVmXiisQ823FvBpEzFxz6l4m3FuPb1b3RIVi00=; b=m88RraG5j3U9k8ATI9Ruw3Cji0diGlg4SUzbpl7j2XDnzR1kWultlQtJwUFcAZ6SK+ ozUt9fFbxXeGMrMcn9CuSgB9H3Uo4UC2q6racp1iYobnX9erya7ZF52PK5L7SlNe/2bd VKVeeOTEYyO9D/+sdv9Ir5L2qJLR9gMKoR2t2YWhS1HKE7MkNb2aNH4fjDNa5FdHsAEe MTOE3tmdj85oFPrma2I1CholJGgIXzfOaMVc6ukSmCL59n8qQngfsnmuEnDY63ebekRN 4bQR1WUSW1TZMRUZrRsleyolTcDAR8hKW4GF4Q/zOvQWNklLkKyTN/EiuBsU30bxH0qE x92A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0HD1eT5T; 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 a23si5513130edn.432.2020.08.31.08.43.12; Mon, 31 Aug 2020 08:43:35 -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=0HD1eT5T; 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 S1729160AbgHaPj4 (ORCPT + 99 others); Mon, 31 Aug 2020 11:39:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:39092 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728521AbgHaPaB (ORCPT ); Mon, 31 Aug 2020 11:30:01 -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 6E72720767; Mon, 31 Aug 2020 15:29:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598887800; bh=2S3ivuzEZGfnY77yUs2AAU8aYTRtxOGZowmybDPmTt0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0HD1eT5TwPXxdSLB3Q9rr6nmdnYp6+H7xzTlH0ESfIiICYAdMmfOPBl7DdEkiJXZD 3grQ0DsqPtxGi1KLjEgE4IMOu1Zy8v8DrjXWC11zJ++8wUEuUOcSjBwApnd59Yiywi 7BNz75E9XNDzUKSawkrl0RXvsTubYdc0lK9RBmJE= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Ofir Bitton , Oded Gabbay , Sasha Levin Subject: [PATCH AUTOSEL 5.8 16/42] habanalabs: set clock gating according to mask Date: Mon, 31 Aug 2020 11:29:08 -0400 Message-Id: <20200831152934.1023912-16-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200831152934.1023912-1-sashal@kernel.org> References: <20200831152934.1023912-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ofir Bitton [ Upstream commit f44d23b9095abd91dad9f5f3add2a3149833ec83 ] Once clock gating is set we enable clock gating according to mask, we should also disable clock gating according to relevant bits. Signed-off-by: Ofir Bitton Reviewed-by: Oded Gabbay Signed-off-by: Oded Gabbay Signed-off-by: Sasha Levin --- drivers/misc/habanalabs/gaudi/gaudi.c | 44 +++++++++++++-------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/drivers/misc/habanalabs/gaudi/gaudi.c b/drivers/misc/habanalabs/gaudi/gaudi.c index 0261f60df5633..8b6cf722ddf8e 100644 --- a/drivers/misc/habanalabs/gaudi/gaudi.c +++ b/drivers/misc/habanalabs/gaudi/gaudi.c @@ -2564,6 +2564,7 @@ static void gaudi_set_clock_gating(struct hl_device *hdev) { struct gaudi_device *gaudi = hdev->asic_specific; u32 qman_offset; + bool enable; int i; /* In case we are during debug session, don't enable the clock gate @@ -2573,46 +2574,43 @@ static void gaudi_set_clock_gating(struct hl_device *hdev) return; for (i = GAUDI_PCI_DMA_1, qman_offset = 0 ; i < GAUDI_HBM_DMA_1 ; i++) { - if (!(hdev->clock_gating_mask & - (BIT_ULL(gaudi_dma_assignment[i])))) - continue; + enable = !!(hdev->clock_gating_mask & + (BIT_ULL(gaudi_dma_assignment[i]))); qman_offset = gaudi_dma_assignment[i] * DMA_QMAN_OFFSET; - WREG32(mmDMA0_QM_CGM_CFG1 + qman_offset, QMAN_CGM1_PWR_GATE_EN); + WREG32(mmDMA0_QM_CGM_CFG1 + qman_offset, + enable ? QMAN_CGM1_PWR_GATE_EN : 0); WREG32(mmDMA0_QM_CGM_CFG + qman_offset, - QMAN_UPPER_CP_CGM_PWR_GATE_EN); + enable ? QMAN_UPPER_CP_CGM_PWR_GATE_EN : 0); } for (i = GAUDI_HBM_DMA_1 ; i < GAUDI_DMA_MAX ; i++) { - if (!(hdev->clock_gating_mask & - (BIT_ULL(gaudi_dma_assignment[i])))) - continue; + enable = !!(hdev->clock_gating_mask & + (BIT_ULL(gaudi_dma_assignment[i]))); qman_offset = gaudi_dma_assignment[i] * DMA_QMAN_OFFSET; - WREG32(mmDMA0_QM_CGM_CFG1 + qman_offset, QMAN_CGM1_PWR_GATE_EN); + WREG32(mmDMA0_QM_CGM_CFG1 + qman_offset, + enable ? QMAN_CGM1_PWR_GATE_EN : 0); WREG32(mmDMA0_QM_CGM_CFG + qman_offset, - QMAN_COMMON_CP_CGM_PWR_GATE_EN); + enable ? QMAN_COMMON_CP_CGM_PWR_GATE_EN : 0); } - if (hdev->clock_gating_mask & (BIT_ULL(GAUDI_ENGINE_ID_MME_0))) { - WREG32(mmMME0_QM_CGM_CFG1, QMAN_CGM1_PWR_GATE_EN); - WREG32(mmMME0_QM_CGM_CFG, QMAN_COMMON_CP_CGM_PWR_GATE_EN); - } + enable = !!(hdev->clock_gating_mask & (BIT_ULL(GAUDI_ENGINE_ID_MME_0))); + WREG32(mmMME0_QM_CGM_CFG1, enable ? QMAN_CGM1_PWR_GATE_EN : 0); + WREG32(mmMME0_QM_CGM_CFG, enable ? QMAN_COMMON_CP_CGM_PWR_GATE_EN : 0); - if (hdev->clock_gating_mask & (BIT_ULL(GAUDI_ENGINE_ID_MME_2))) { - WREG32(mmMME2_QM_CGM_CFG1, QMAN_CGM1_PWR_GATE_EN); - WREG32(mmMME2_QM_CGM_CFG, QMAN_COMMON_CP_CGM_PWR_GATE_EN); - } + enable = !!(hdev->clock_gating_mask & (BIT_ULL(GAUDI_ENGINE_ID_MME_2))); + WREG32(mmMME2_QM_CGM_CFG1, enable ? QMAN_CGM1_PWR_GATE_EN : 0); + WREG32(mmMME2_QM_CGM_CFG, enable ? QMAN_COMMON_CP_CGM_PWR_GATE_EN : 0); for (i = 0, qman_offset = 0 ; i < TPC_NUMBER_OF_ENGINES ; i++) { - if (!(hdev->clock_gating_mask & - (BIT_ULL(GAUDI_ENGINE_ID_TPC_0 + i)))) - continue; + enable = !!(hdev->clock_gating_mask & + (BIT_ULL(GAUDI_ENGINE_ID_TPC_0 + i))); WREG32(mmTPC0_QM_CGM_CFG1 + qman_offset, - QMAN_CGM1_PWR_GATE_EN); + enable ? QMAN_CGM1_PWR_GATE_EN : 0); WREG32(mmTPC0_QM_CGM_CFG + qman_offset, - QMAN_COMMON_CP_CGM_PWR_GATE_EN); + enable ? QMAN_COMMON_CP_CGM_PWR_GATE_EN : 0); qman_offset += TPC_QMAN_OFFSET; } -- 2.25.1