Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp379040ybm; Fri, 29 May 2020 02:25:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwz3rNREAa7BM2MkTslslOFT/E6xOElEFBXZJc2VjLFJGV2UxoPhVwjBavjac9NznLjb44n X-Received: by 2002:a50:9e49:: with SMTP id z67mr7536311ede.236.1590744333192; Fri, 29 May 2020 02:25:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590744333; cv=none; d=google.com; s=arc-20160816; b=qlBcVqi53yKmDdHS8I5FYAJHo2ITZ0YTstEktZ3+kSijtyowziJJIdgKvqzu6CW4NX 7ti58RqMMphDnDK8MQ26tSbp+2Hq2sm5bGtuVjw7X05L9Q9zfNe7AZotF5C2CcQ1O9WN prqhafXfBiMQL28/z4cRdM9bfdB2qMfGXK4J1iAT8DXiWK7ecVN1RpJl7ERIq7bX9cVX 16uYFy5vy7zc27xQipfq4TYlBnw4c1hFvZY48Fj4K5e+qlcEEA5qlFC9z0YtOPb1JxMi pXp5cbiHx2Mf+ZOWbyofz87sI+nUTKANFr53I8MOlrknN7c/l5zr+icXQR7TUZ4xuxtx e93A== 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=NOKlv7zM4LRTruut6jgdhOjKQWFJHmbjuA06RuI5wcQ=; b=UEoudnp98513mWEwNSwKFOcix9f3WszZew9QTwCzLlyAFmdr7opjHHkhtVeW8TjYsU fB6Vv9BvD7ZzEot9TCDkJb35TWEVeBOJsjKSqBMX+bxfOvtkNeKHDwXzwqKW1TmrHD+X gKAkrqB1s3uBiy++HSITpL9AhyxmAoWEMpjyeRX7BpFBa4ccjM6bJe9ZO4z7HH59utCm mZBZvfAuAo4Tw9b68Qx7nRztSP+VHAENI0QL1coasSWEmKIasAEUU8tqHK5Egnk1puk+ tnrxZZU3pjzrVHY9QYrg/z2PV55ynWgAtn6xIBbid2wnKtly/YF81x/o8uFAisa5my+Y XxDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=GQgGtA2y; 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=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id si29si246701ejb.40.2020.05.29.02.25.09; Fri, 29 May 2020 02:25:33 -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=@mediatek.com header.s=dk header.b=GQgGtA2y; 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=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726799AbgE2JXV (ORCPT + 99 others); Fri, 29 May 2020 05:23:21 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:37427 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726644AbgE2JXS (ORCPT ); Fri, 29 May 2020 05:23:18 -0400 X-UUID: bb431eba164c4b839de1b208f8d91198-20200529 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=NOKlv7zM4LRTruut6jgdhOjKQWFJHmbjuA06RuI5wcQ=; b=GQgGtA2y+2a6srv8ldiq1g47YvQxUB5fqMKbjAE7fE7jc9Z0A920YW63wNAiBq7cCJQzGepW/zyhJbtxkTSsv8m5AIXVBa7mPrrbfENcr+XFVx28dNov42ThCTdi16+lo+cXr6V9XKbqZx5nh9euHX0i8iLYMZ7OnhaLiXzyZDQ=; X-UUID: bb431eba164c4b839de1b208f8d91198-20200529 Received: from mtkcas10.mediatek.inc [(172.21.101.39)] by mailgw02.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0809 with TLS) with ESMTP id 47945482; Fri, 29 May 2020 17:23:14 +0800 Received: from mtkcas08.mediatek.inc (172.21.101.126) by mtkmbs02n2.mediatek.inc (172.21.101.101) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 29 May 2020 17:23:11 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas08.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 29 May 2020 17:23:10 +0800 From: Stanley Chu To: , , , , CC: , , , , , , , , , , , , , , , Stanley Chu Subject: [PATCH v2 4/5] scsi: ufs-mediatek: Fix unbalanced clock on/off Date: Fri, 29 May 2020 17:23:09 +0800 Message-ID: <20200529092310.1106-5-stanley.chu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20200529092310.1106-1-stanley.chu@mediatek.com> References: <20200529092310.1106-1-stanley.chu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-SNTS-SMTP: 83DAA400323415FEC60197EA0FAEFFA75DFAD431B49159932AD28C3CD9C819842000:8 X-MTK: N Content-Transfer-Encoding: base64 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org TWVkaWFUZWsgVUZTIGNsb2NrcyBhcmUgc2VwYXJhdGVkIHRvIHR3byBwYXJ0cyBhbmQgY29udHJv bGxlZA0KYnkgZGlmZmVyZW50IG1vZHVsZXM6IHVmcy1tZWRpYXRlayBhbmQgcGh5LXVmcy1tZWRp YXRlay4NCg0KSWYgYm90aCBBdXRv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