Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp519173rwi; Wed, 26 Oct 2022 04:05:52 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4Hq7/PMgJHfucSPBJ52Epifs+0GdQuUK5RBPHAgnZfeM7V0SgeDTazC3H3YsX1aM2Ub+dw X-Received: by 2002:aa7:c6c1:0:b0:460:f684:901a with SMTP id b1-20020aa7c6c1000000b00460f684901amr29495603eds.6.1666782352349; Wed, 26 Oct 2022 04:05:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666782352; cv=none; d=google.com; s=arc-20160816; b=eHseXalq8Ku62SOjiGW05okzQSYU4/Zqd1WoWBEyM/fKAE9jEwGcoUnbiZq7ws/c6x MhfD+Ea6KOvnNQ/QgHl67UcmWqAcYCeWPxxFhzBTA5nSPerYvf5g0JxDk/rBEB7Xct1t cHYKEmg5DTGf4v1y07Wj2mR/04HQpYdUXNbfE9Vd8uthiKUQArUqkXaiIjgbCCs6iSsq MIy+rstL9m/mmp1r76ub6sVIZIzE7SPu6k9XWXMTOYzMab3u6qmbEOThiEvw5qjXObc+ NeFYdsME+VWLvi1xkBdDk+v2hbScMrwh4WNIeamt4Mb0jbG75T+bMXd75WbeHoSwbcm/ q6hw== 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=y4sQJzVrHni1WLAuaAcAXcY4IxBG/K5oBIjFNgyTIGU=; b=PwthWV+4ouRYkEfg6EYNUXBXuVqpiLltrdDBp6pYxlsqUYlrHc9jN//qA6cPRjIBxN MmnxCWsbe4TUgyWkhbii3SSzjzGfllUjMM3uSqxaJ4MuHdTt5/NiTmN4fPZKE+63X/x/ XnLc+C4qzDXH2XQomT0l9Lb30r0Vj11+xnbMoqE7bfnuNkg9LerNMNpznsU0FO33AqPz 49U9Ffg9fSsMeN26qx0kh6euu2mka/nFyUWrL5pYnPdr7Th6+CTc7LGmPL0hiySVrKib MIEkQewXgoXxny5Q/G8GXTOcZw12AO3DXWmqx8Scma0qMCbpp/Vng+gX+w4Gt1BjKFPG i4cQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TAx4tjE+; 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=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u15-20020a17090617cf00b0072a477a55e0si4614693eje.369.2022.10.26.04.05.27; Wed, 26 Oct 2022 04:05:52 -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=@linaro.org header.s=google header.b=TAx4tjE+; 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=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233166AbiJZLCe (ORCPT + 99 others); Wed, 26 Oct 2022 07:02:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233397AbiJZLC1 (ORCPT ); Wed, 26 Oct 2022 07:02:27 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EDC8FB56DB for ; Wed, 26 Oct 2022 04:02:25 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id 5so2149019wmo.1 for ; Wed, 26 Oct 2022 04:02:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=y4sQJzVrHni1WLAuaAcAXcY4IxBG/K5oBIjFNgyTIGU=; b=TAx4tjE+S9rXc/zlFGGPRl0uwIS/mtGtuJhj7IGSzfeIMVzaco9BF+sU98thou5Lgj C0JW8r0zxjpHDi8rzTS5doOZ8Gz3TnF3Ko47ZbObPbEtOiV/XczTTpCtT5Ba2yMs4k+B pVNYj0RW8tOCU53hk3rl0NmNgNTk52yI7qQ9ts6Ifjz2dS5epGUYe8Act0oylQB5oh8y wayfnhvtZhP+CWjdF+iHl2nGWhus+jPR+QftOAj4Kjkr93LT4qw8p5NssmqKSpWWYc9f 2xK+G3bYSycJwqnyByA0N5cIel8sF93aBKc2HqMaOr+na6uDjdvC/uMMj9ms4PKkYBBI zDPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=y4sQJzVrHni1WLAuaAcAXcY4IxBG/K5oBIjFNgyTIGU=; b=lx0dLSQSHwIJgbTJJAO+/S+XWoxMq+zKrv7JwpmxHwf5cLukhTbP7ya7zH40pQ3CNh 0WCZVmkJ+HTRPkttG74aABOgy1/d5mrrUAkVaRg9cSdK5Xn5Q/d3nRisD7vrf9FOM4j1 8Kiyn2Q3emn8x6mpGzADi6Nks6isz9mx8IXB6tBTzHtug9/T23YCMGaJGxtrrRhVSngq sHhZv0R6qVKxutEjRvLkReKYoWxUyukXwAeOv/auslJY2B/a6hTZp8fcf/+Cd70Rrkwb SbxOK9IuaoUagA6tWzPLIqrsi7J/38/sqwj0gMnpaIodsq0t6+l/g6ZAsIHHEzgULxaQ A8dg== X-Gm-Message-State: ACrzQf0IblewDXZollMbeYpTAPv3p8kA5jLCFTQhb6tVkslGzZOhpDdx 2pQI5IATt0c/cBZ2irJUlfc2og== X-Received: by 2002:a05:600c:244:b0:3c6:bc2f:421b with SMTP id 4-20020a05600c024400b003c6bc2f421bmr2040804wmj.32.1666782144503; Wed, 26 Oct 2022 04:02:24 -0700 (PDT) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id z7-20020a5d44c7000000b0023672104c24sm5237415wrr.74.2022.10.26.04.02.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Oct 2022 04:02:23 -0700 (PDT) From: Srinivas Kandagatla To: vkoul@kernel.org, yung-chuan.liao@linux.intel.com Cc: andersson@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, pierre-louis.bossart@linux.intel.com, sanyog.r.kale@intel.com, srinivas.kandagatla@linaro.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org Subject: [PATCH 2/6] soundwire: qcom: check for outanding writes before doing a read Date: Wed, 26 Oct 2022 12:02:06 +0100 Message-Id: <20221026110210.6575-3-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20221026110210.6575-1-srinivas.kandagatla@linaro.org> References: <20221026110210.6575-1-srinivas.kandagatla@linaro.org> 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,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 Reading will increase the fifo count, so check for outstanding cmd wrt. write fifo depth to avoid overflow as read will also increase write fifo cnt. Fixes: a661308c34de ("soundwire: qcom: wait for fifo space to be available before read/write") Signed-off-by: Srinivas Kandagatla --- drivers/soundwire/qcom.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c index 8f1a1eb017a2..cee2b2223141 100644 --- a/drivers/soundwire/qcom.c +++ b/drivers/soundwire/qcom.c @@ -380,6 +380,12 @@ static int qcom_swrm_cmd_fifo_rd_cmd(struct qcom_swrm_ctrl *swrm, val = swrm_get_packed_reg_val(&swrm->rcmd_id, len, dev_addr, reg_addr); + /* + * Check for outstanding cmd wrt. write fifo depth to avoid + * overflow as read will also increase write fifo cnt. + */ + swrm_wait_for_wr_fifo_avail(swrm); + /* wait for FIFO RD to complete to avoid overflow */ usleep_range(100, 105); swrm->reg_write(swrm, SWRM_CMD_FIFO_RD_CMD, val); -- 2.21.0