Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp756000rwd; Thu, 1 Jun 2023 06:15:58 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5VXT6+UkVnMRKtRCFYEUwDmH2Xy7ULIATMM1WUzYcWk+UgwkE8q9utcC4577cvYLxpFGCu X-Received: by 2002:a05:6a00:98f:b0:645:c730:f826 with SMTP id u15-20020a056a00098f00b00645c730f826mr7878601pfg.24.1685625358090; Thu, 01 Jun 2023 06:15:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685625358; cv=none; d=google.com; s=arc-20160816; b=n+UVmLv+oZjwN6jmmRT/27YC1CDrtolXVsNSzb9UXrUszqzVFClRoqTp9piwtthyi/ MMq04n3m9HoouRPsxSUUj67HVpvyDsb06rW8xmYwNuWcdkq1HLSd33y8NE1Td5GCtU85 ygzNTGPM9TZ95fGE2dLXoxSHoseU4ywlbrhpXEJjlJVi7ejK/BBw8g2eVBEhcIxEYUL+ p4PS5uX5vwAT9bFkIF+02nzIHfrM2lipjHmok7pv7dxNAp1oVGDkWgJIUtMufIhl0Ex3 ZvGRJPidJUVs7RWMGanoY/xx5fRGachC/hLZyF+oqFHpIyXuFIviwKu5O5/ufZ+YB+uW ITzg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=7draYKi8O8bY9wpEzwPd85VAVlOaAQazTlzk61kz37k=; b=BpBah0Fq5txLS/nqYOnh3yMzWrEpa/kycrhxuJfrCkn5iqFo/+HZmvUPDIwD2LECRa fSsCYZHCj9KmdfW4WY3qphTEu7hmeSX/9cwHNfg0JWNGnCWsHqkz6E+KiMi6DZrNerVL OtbRHGivtxvX/y4OXYd9MnFLrGRxeijpzJSsQJJ7pAwFUAoIokTatpv4f/9xDFaq/7z8 y+26fMp5x5e8x6WN67ohdGaS2r1pcQYqKJx2IAMVvUeXYl1XT6w587C2gmyOeca40nX8 fZEbBOr5oKQDCzTLZO7TIfmouddoIFrH1L7DvO3HWQZBr6NqHIp0jFfZblKYU+JwHJgN hr8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=mfj8jc21; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d16-20020aa797b0000000b0064f6c2c05bcsi5357174pfq.81.2023.06.01.06.15.44; Thu, 01 Jun 2023 06:15:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=mfj8jc21; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233148AbjFAMr4 (ORCPT + 99 others); Thu, 1 Jun 2023 08:47:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231812AbjFAMrz (ORCPT ); Thu, 1 Jun 2023 08:47:55 -0400 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F403123; Thu, 1 Jun 2023 05:47:54 -0700 (PDT) Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1b0314f057cso3089595ad.1; Thu, 01 Jun 2023 05:47:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685623674; x=1688215674; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=7draYKi8O8bY9wpEzwPd85VAVlOaAQazTlzk61kz37k=; b=mfj8jc21WKJhT/qxElCYvsyZMZvrzYH0y2VRVsz1o2Ixfe2g6kojtfVHpKZVUe66q7 p/oUzXPuloa/KBguAEz04854ms5IKBa89iYQMrXYv67jcn9lI7VKaLVQE5qeSgUJmy4t jb6T+HVBIF7dYl7OQkwYxpqcOsckJiQOOxgeOlXMwFFaruIaCIYtBca4OUPxf8+iDmsy 3Cn69moMWkO4RTKQk4vkGfOJ/ncI8wKle1lWsT9eaRxcnYQTWkD3biPfp4R32OTu+Gou 4YOJb0Ktmy4GiVFtuW52+xBOZOFnLr+RA7fLpCQ6hLgEJtdm4OfmrnBTNYLpaYGCW1vL yieQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685623674; x=1688215674; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=7draYKi8O8bY9wpEzwPd85VAVlOaAQazTlzk61kz37k=; b=AAOEQlrv7RaDrGG+Y0O6aX05BDQDMgdaUNtIX2px2P7YnkG9HTy7Wn9yPCWMEMcFO7 iePB6GxscsuWIZG4lJfs0bep8ldT6wQhv4ZtGwv8eG4qrOsZqd8vlVOM7pjPv+P3jpRy QQIJyVka9qLzlNq5KOgFxme7uRwfSRkunfOuVTPKisDLMe18PeaSTH2Vt9pIDZhP+h5m HkuITN/pLA3lG0ni5RnR7kF/O1QHCguD2Y7JRTlGu0BS7+rjcF0MB/JFCfLbWbA4b+Is 6kZ6snOPrsqPEpNn6CsD1MEdZ6W+a2IkGNM7k0tofSUm+jSS5sIrWnx0qzzmUbccONhZ 2v6A== X-Gm-Message-State: AC+VfDy+szO9VBYeSZQx0JYN/XDdvhrHNhXM17BHAevLSDS2sxMYbzpm tBMflE1UK5Gwws78VGlNAwg= X-Received: by 2002:a17:902:930b:b0:1af:d213:668c with SMTP id bc11-20020a170902930b00b001afd213668cmr5240056plb.12.1685623673691; Thu, 01 Jun 2023 05:47:53 -0700 (PDT) Received: from localhost.localdomain ([43.224.245.242]) by smtp.gmail.com with ESMTPSA id u9-20020a170902e80900b001ab0669d84csm3418213plg.26.2023.06.01.05.47.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 05:47:53 -0700 (PDT) From: Zhang Hui X-Google-Original-From: Zhang Hui To: Alim Akhtar , Avri Altman , Bart Van Assche , "James E . J . Bottomley" , "Martin K . Petersen" Cc: Can Guo , Manivannan Sadhasivam , Asutosh Das , Arthur Simchaev , Krzysztof Kozlowski , zhanghui , Bean Huo , peng.zhou@mediatek.com, yudongbin@xiaomi.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] scsi: ufs: core: Fix ufshcd_inc_sq_tail function bug Date: Thu, 1 Jun 2023 20:46:14 +0800 Message-Id: <20230601124613.1446-1-zhanghui31@xiaomi.com> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: zhanghui When qdepth is not power of 2, not every bit of the mask is 1, so sq_tail_slot some bits will be cleared unexpected. Signed-off-by: zhanghui --- drivers/ufs/core/ufshcd-priv.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/ufs/core/ufshcd-priv.h b/drivers/ufs/core/ufshcd-priv.h index d53b93c21a0c..319fba31c1f5 100644 --- a/drivers/ufs/core/ufshcd-priv.h +++ b/drivers/ufs/core/ufshcd-priv.h @@ -366,10 +366,11 @@ static inline bool ufs_is_valid_unit_desc_lun(struct ufs_dev_info *dev_info, u8 static inline void ufshcd_inc_sq_tail(struct ufs_hw_queue *q) __must_hold(&q->sq_lock) { - u32 mask = q->max_entries - 1; u32 val; - q->sq_tail_slot = (q->sq_tail_slot + 1) & mask; + q->sq_tail_slot++; + if (q->sq_tail_slot == q->max_entries) + q->sq_tail_slot = 0; val = q->sq_tail_slot * sizeof(struct utp_transfer_req_desc); writel(val, q->mcq_sq_tail); } -- 2.39.0