From patchwork Tue Sep 10 09:20:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 826952 Delivered-To: patch@linaro.org Received: by 2002:adf:ab1c:0:b0:367:895a:4699 with SMTP id q28csp206194wrc; Tue, 10 Sep 2024 02:22:21 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWE0zQ1eS1oG7Lt46fGkiTafUUI/qHATmdKDcl/XIHpFULeVd74NVsdTzplAH0/G64Hrg511Q==@linaro.org X-Google-Smtp-Source: AGHT+IFtha5I00BjbbmvIFmFAYkqLwC63K3hQx7ceFvK//I0xBMrZfi+XkLv/IkmMXJipluz6hzG X-Received: by 2002:a5d:5088:0:b0:374:b9a7:5ed6 with SMTP id ffacd0b85a97d-378895cb7b8mr8296369f8f.22.1725960141614; Tue, 10 Sep 2024 02:22:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725960141; cv=none; d=google.com; s=arc-20240605; b=G6Wc7Wiwf9zuQbWRzuHejW9/kycYIxQK/UYE91r5gYEYgu78XqUYObgThSu23uHta7 x8B7h6ya8j6j/YBfz+o4JwYHchXlArgw9lTEFn+o8W3uodiqVy4Ts/D5COUJj2vnznd/ SZZef8VOjtTAnl+WaRF8fHsphdkSKRt/ZnES9l7IdH7idA/GbUVKpJRgZpFnnpmDkAtV VCKlQ4DgIuEGTed/VUbICXq+oYFSrG44gJsPb+JR1DExGPW0EQETH5wFQTjonhupr9xe EMOFjv0fCMUQfl9F+BK+yQdOScYHl1CvhNtBaUfMKT/wKb7eHqOd7L8bmskwzIJ1AGJe jDPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=FiZ7d/zss0qv1wKmPr1Qcf9QsjkyREN4pR1f7/QXCVA=; fh=uVKLv1QSS99cNt9xKJtMKFbrHuaW/J+XdopzN72C91A=; b=gEJl6oUL2LY6HsmoZk1q5k42l+toxLVJxwZKvWCVX6A+2+5/7tR3p+v77x7a3875gA PrSXwIJPNNeTPfqv/+1RIPoIlRW4GCMMQYkxlaWsYCbRYoiiqOjLlg/rTtGSmAnA4ynu KEs40LHSNd+GShlKz4Lc9W4AoFCLu3wVz55eQ1wvMIr9gvKu//q8Qh78AVzgf7/ggiEF y7OV0ij0IMs8W3ps/4B4Jfy9iTSIgI2eZeJ3uDs8zq2QQwJ3Yt2pjnjimunGfM0924XI AFuT7U+RSZZDXao1cBJVO3y6w/iZ7i1Sc8x99UGoRcyPPx1AryH6HXlo0naO5l1HAbdV PnBg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Bi43sfFX; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id ffacd0b85a97d-378956cfceasi2780911f8f.879.2024.09.10.02.22.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2024 02:22:21 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Bi43sfFX; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C386B88FAA; Tue, 10 Sep 2024 11:20:45 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Bi43sfFX"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A42DB88FA4; Tue, 10 Sep 2024 11:20:42 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id BB0FF88F88 for ; Tue, 10 Sep 2024 11:20:40 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=neil.armstrong@linaro.org Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-42cae4eb026so29308135e9.0 for ; Tue, 10 Sep 2024 02:20:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725960036; x=1726564836; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=FiZ7d/zss0qv1wKmPr1Qcf9QsjkyREN4pR1f7/QXCVA=; b=Bi43sfFXEgBAXAMXRYqEhXlQTO1R5uR0X3TmKkK+EX3vISSSJ2D9BHmQMI+7cl3xs3 XFPfIYnpkfTf0vGnIYLUZpyDb6IEuESl1TcPWjuESvM/CHtzyTZA5cUGSzynxYsoSNhm zZRlunMBMO7HuPQl9bjQjbI19gUClzQB46Rz5psikemv5FCLxb+i5exJOHcwhCu03Atm FQmd5412aZ2VjgfBD7xrEXemv0i4awa2xOY1bkBJuWHqYzNjzTU6S1lY+TJfAcNJT4E8 BUCRsH2kEOpBZ3vg/Ezq/SSE3DTJfw+PUOi5/Hu+pePrA2nUmHXfAYQaNOkClBiwmn4F 25Xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725960036; x=1726564836; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FiZ7d/zss0qv1wKmPr1Qcf9QsjkyREN4pR1f7/QXCVA=; b=i5hIajNwZuWrBynpNeZHS2OezSAVh177iu/f+okjgxdQaVUQ6Rbe9N3Qwc7/8d8sRb ePKNOJ2KEP0/iYT0LUejGHHyiCS+27BgLcYp21GuwVCChRtH1jgWrdsJrREoWXLYuawk 39MZ2zbVynAungem8+G3thgG+/DoFd4QFL+trddIwu2MZuH/QzV4uJiap3C65qL+kr5r b7e54kL9ET7AO1bry1+KYA4Vuojocx47KGd4HvhCGs9aV86hnXrQZBLXRyPsS+Vv1m9J ZRPJ7kSuN73UJEsWoHXze1dO5C4Cqm8pQ0DTZobrNw7WuU2LmZI5qwmci5YIV2vhRG+r FALw== X-Gm-Message-State: AOJu0YyoZ7tVYcYHKRZiGMQn3bc2edpE4tBmPRtYVsxsMAUIux1R+Y3s BGhdJ2VL6EGqemhgQ5ZyGlYiSmVLvCbOZjh+cp64lk12lmuj5pwZ7grS2QO1+7USG7QpdIHaOJH 3 X-Received: by 2002:a05:600c:4506:b0:427:ab29:30cf with SMTP id 5b1f17b1804b1-42c9f9768a5mr105140035e9.4.1725960036412; Tue, 10 Sep 2024 02:20:36 -0700 (PDT) Received: from arrakeen.starnux.net ([2a01:e0a:982:cbb0:52eb:f6ff:feb3:451a]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42cb099acf6sm101256245e9.9.2024.09.10.02.20.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2024 02:20:36 -0700 (PDT) From: neil.armstrong@linaro.org Date: Tue, 10 Sep 2024 11:20:27 +0200 Subject: [PATCH 10/13] ufs: Add missing memory barriers MIME-Version: 1.0 Message-Id: <20240910-topic-ufs-enhancements-v1-10-3ee0bffacc64@linaro.org> References: <20240910-topic-ufs-enhancements-v1-0-3ee0bffacc64@linaro.org> In-Reply-To: <20240910-topic-ufs-enhancements-v1-0-3ee0bffacc64@linaro.org> To: Tom Rini , Bhupesh Sharma , Neha Malcom Francis Cc: u-boot@lists.denx.de, u-boot-qcom@groups.io, Neil Armstrong , Bhupesh Sharma X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1550; i=neil.armstrong@linaro.org; h=from:subject:message-id; bh=5oG/hJDRzgrfw1H7DuKQEcfPeZJkmu0N1nxQo6XZS64=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBm4A9ZVkHT19ZhlfhIdSkNnKZzoCEsYUXcZSYKd92F 7bJ4EfSJAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCZuAPWQAKCRB33NvayMhJ0SIhEA C80FMzpCUoL7uXVNU45bWmcf0QdEPKhUxv7NOy9+DXJzpZ0DUP1YnL4beBxKlYwSR7I5RJkvlVjX4m HJhQdWxjMno62b2CUzNl46hGlqprRmBGQEu6U1MVfeWgkDfJJgkTgjBj4821oavZgLEBLucRcRQn3d +S3EfrCcMuSvKjxu2+j+YL9DD36Ie//1CaovgO0D0qPr4Nhh1DyfmGRemPl4jmaXDkVUUNeTYsGiTV gZM9MBSh72byTc7V0FI9ov8JHzF3xzzWrgJVacazrlSCdlsyyP6yOBZHu+lmQB7BNnnFljolDLNxqR 5UfEPlKB+bDhG5eos294bw5Ej/Zq8b3KtV6QFzT1jSPTLZDkHxmY9jm1crrLMXWChIZehhgI0WdccZ yI9vM8Zxctb0vKh2CKtC6Hw1nJNw0+S8skBL0zg2k86qqsKSU7yVFxYGVr12rK+0hxyj4vapN2wa7j xGRT7NgOCzNsUKWNK2QFN7yEyqNbrRk5yOUvAPer6QHPZKeqNinystndrcovseBaPHMJ83KE6IFK6h CoaFjBUwbDBpP+I4ndvSFBftTlNujch46roOIbRSFvjE51iNOpE9ue9Uhl1bq8og43O37Bn+jlM8Zl IgKcyAfMoVTMifmjnc6dQ/tCAcqFS0TpUgZk7bvQL7fi6+fAMnANYR1jfHgA== X-Developer-Key: i=neil.armstrong@linaro.org; a=openpgp; fpr=89EC3D058446217450F22848169AB7B1A4CFF8AE X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: Bhupesh Sharma Add missing wmb() and mb() barriers in the u-boot UFS core framework driver to allow registers updates to happen before follow-up read operations. This makes the barrier placement similar to the Linux UFS driver. Signed-off-by: Bhupesh Sharma --- drivers/ufs/ufs.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/ufs/ufs.c b/drivers/ufs/ufs.c index 565a6af1404..5d4e5424358 100644 --- a/drivers/ufs/ufs.c +++ b/drivers/ufs/ufs.c @@ -432,6 +432,12 @@ static int ufshcd_make_hba_operational(struct ufs_hba *hba) ufshcd_writel(hba, upper_32_bits((dma_addr_t)hba->utmrdl), REG_UTP_TASK_REQ_LIST_BASE_H); + /* + * Make sure base address and interrupt setup are updated before + * enabling the run/stop registers below. + */ + wmb(); + /* * UCRDY, UTMRLDY and UTRLRDY bits must be 1 */ @@ -861,6 +867,9 @@ static int ufshcd_send_command(struct ufs_hba *hba, unsigned int task_tag) ufshcd_writel(hba, 1 << task_tag, REG_UTP_TRANSFER_REQ_DOOR_BELL); + /* Make sure doorbell reg is updated before reading interrupt status */ + wmb(); + start = get_timer(0); do { intr_status = ufshcd_readl(hba, REG_INTERRUPT_STATUS); @@ -1994,6 +2003,8 @@ int ufshcd_probe(struct udevice *ufs_dev, struct ufs_hba_ops *hba_ops) REG_INTERRUPT_STATUS); ufshcd_writel(hba, 0, REG_INTERRUPT_ENABLE); + mb(); + err = ufshcd_hba_enable(hba); if (err) { dev_err(hba->dev, "Host controller enable failed\n");