Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp3879397rdb; Mon, 11 Dec 2023 02:46:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IHhCdLOXft7c6siE3Xkk52iWR058hWVLRUy9zzyN9zscIOIsB3LfewavH7IsGOnZNPUUJjo X-Received: by 2002:a17:902:ec92:b0:1d0:b013:229 with SMTP id x18-20020a170902ec9200b001d0b0130229mr1993191plg.23.1702291573048; Mon, 11 Dec 2023 02:46:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702291573; cv=none; d=google.com; s=arc-20160816; b=ag6gMv+CTCVilORyw6mC2Yo24NLYvllAz/Dfn4ooKkQADT19G7LRxRarff2NASn9xO L+5vtyYfYwt1Z8489R0Sr3iChRDvgsZYpyip2+xoi+T5CUOd/ZxpRVwi3PXaGOWrCz9R Wpfg1IRkxwWMU5W8DpFm4oM1Fqpkgw9cPSgPDAJDSH6keUQvIHqScp7aS3u7eOBdmqA8 i+6SZwd8qv/Tus+nOkcPOx6nZ4gjQBxzhZO/UZBkc/z5KWonWXxpCG21aDUKppTq9zZd K56LBBA334yETpmebGzyRaY0ejDqnRf35ghiy3u5EALKTqBVZPGTz9cvq05TK6OeeTyg NJoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=A5mpNl6sZR6GopyVrPugJi2So2WeLZiYBwqLvhXeiWQ=; fh=aBvetHouOHscQaSNeirPq1axjNptTVM8PjePGPzY7NE=; b=WBC/WXfJUvNbtw0k4THNjq0nwksf9zhmRAUY8/SUvZPc/7DNiK9GV/UZxjm1X0fOQ/ idShxmM0/s5kCk57mWi+7VgCnZn7RHcxc32cBdtQePHzjZ9CVlV91Vk82++9EgxGPUxd O2SUOkJDeKHo2qgqeVpF2UTvP9L9ecCz1nBxjX1Ir+yxIHScUwsgIU7VhmHwOPTu0Ejv d6opcTvfGw4/a0fAQSQsS3Qwb+zmWHMZBXHSTg+b0hE5TJg5Hsgohr/n251+2uqtXiVc 6eYrDxpYpbHXELgHTUVY/5MYKf0F2hKvY6Ef3vcIPX/qbqCuQeWP1CAtecBFRgMBlFQV fG+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JHATXVEI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id j12-20020a170903024c00b001d0c1281f07si6048599plh.205.2023.12.11.02.46.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 02:46:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JHATXVEI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 5ECBA807CB4E; Mon, 11 Dec 2023 02:45:55 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234283AbjLKKpi (ORCPT + 99 others); Mon, 11 Dec 2023 05:45:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234234AbjLKKph (ORCPT ); Mon, 11 Dec 2023 05:45:37 -0500 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBB59A9; Mon, 11 Dec 2023 02:45:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1702291543; x=1733827543; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=LC4Pclve0K/VznFdQCYhiNQPtxHVC5jnqQW33yq7eXE=; b=JHATXVEIdn6C1pnMDq0Kd3b4RtnQVtHKElqlQfHbqaxZl6BqH0WMiLLi EqGh3TPVR7Ywq5c3L0rZ8f0oQtqA5p06kqZGGm24T4Ys81YmNYFT2xJBL Mu6m5amYTARzgLP0w1Y33t3y2ya/XboEmscQ9R9HnzZxDkaTjy9qwuWij x22JBCfxksl8zwaxKhyqrMTYq+WMeTEgxvbT1CqZJgnEmV8rUreIfg8s2 jmGVGg2TwRCgwSwtd8vi8I1vYhfULf48sskhuvKIG9OLdbHpamDrolChI dOu2uMMhVCWNTiJif3bsYW3dx8Eh7KmuezfGtjVjtL5mmmnBvMAvfaPhA Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10920"; a="398481778" X-IronPort-AV: E=Sophos;i="6.04,267,1695711600"; d="scan'208";a="398481778" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Dec 2023 02:45:43 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10920"; a="838979618" X-IronPort-AV: E=Sophos;i="6.04,267,1695711600"; d="scan'208";a="838979618" Received: from ahunter6-mobl1.ger.corp.intel.com (HELO [10.0.2.15]) ([10.252.46.23]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Dec 2023 02:45:38 -0800 Message-ID: <0faa472c-d21d-46df-922b-264d7915f983@intel.com> Date: Mon, 11 Dec 2023 12:45:35 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v7][2/4] mmc: Add Synopsys DesignWare mmc cmdq host driver Content-Language: en-US To: =?UTF-8?B?SnlhbiBDaG91IFvlkajoirflrold?= , "ulf.hansson@linaro.org" , "jh80.chung@samsung.com" , "riteshh@codeaurora.org" , "robh+dt@kernel.org" , "krzysztof.kozlowski+dt@linaro.org" Cc: "conor+dt@kernel.org" , "asutoshd@codeaurora.org" , "p.zabel@pengutronix.de" , "linux-mmc@vger.kernel.org" , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "arnd@arndb.de" , "briannorris@chromium.org" , "doug@schmorgal.com" , "tonyhuang.sunplus@gmail.com" , "abel.vesa@linaro.org" , "william.qiu@starfivetech.com" References: <20231121091101.5540-1-jyanchou@realtek.com> <20231121091101.5540-3-jyanchou@realtek.com> <655c5964-0917-4021-b254-7917b368b05f@intel.com> <7b4b7219c2b6430b9c320c8d9ac1cc8b@realtek.com> <8e7b6ac2-9d92-4f37-97c4-ae295f7cdbd4@intel.com> <49d0b19c5ec741638e41ee6f970d057b@realtek.com> From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki In-Reply-To: <49d0b19c5ec741638e41ee6f970d057b@realtek.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Mon, 11 Dec 2023 02:45:55 -0800 (PST) On 11/12/23 12:37, Jyan Chou [周芷安] wrote: > Hi Adrian, > >>>>> + >>>>> +static irqreturn_t dw_mci_cqe_interrupt(int irq, void *dev_id) { >>>>> + struct dw_mci *host = dev_id; >>>>> + struct mmc_host *mmc = host->slot->mmc; >>>>> + struct cqhci_host *cq_host = NULL; >>>>> + int cmd_error = 0, data_error = 0; >>>>> + >>>>> + if (host->pdata && (host->pdata->caps2 & MMC_CAP2_CQE)) >>>>> + cq_host = mmc->cqe_private; >>>>> + >>>>> + dw_mci_get_int(host); >>>>> + >>>>> + if (host->pdata && (host->pdata->caps2 & MMC_CAP2_CQE)) { >>>>> + if (!mmc->cqe_on && !cq_host->activated) >>>> >>>> Shouldn't really look at internals like mmc->cqe_on or cq_host->activated. >>>> There are the cqhci_host_ops ->enable() and ->disable() callbacks to >>>> keep track of whether cqhci is expecting interrupts. >>> >>> Does this means we need to use cqhci_host_ops ->enable() and >>> ->disable() callbacks instead of mmc->cqe_on && !cq_host->activated? >> Thanks. >> >> Yes. ->enable() is always called before cqhci operation and ->disable() before >> non-cqhci operation, so they can be used to determine if an interrupt is for >> cqhci. > > Thanks for your advice, and I got your point for calling cqhci_host_ops ->enable() > > and ->disable() callbacks, but the reason we used " if (!mmc->cqe_on && !cq_host->activated) " > > is that when sending command like cmd0, 1, 7, 8... in mmc_init_card before mmc_cmdq_enable, > > we need to use interrupt in legacy mode, it is much better to write in this way? > > + events = mci_readw(host, NORMAL_INT_STAT_R); > - if (host->pdata && (host->pdata->caps2 & MMC_CAP2_CQE)) { > - if (!mmc->cqe_on && !cq_host->activated) > + if (mmc->caps2 & MMC_CAP2_CQE) { > + if (!(events & CQE_EVENT)) > dw_mci_clr_signal_int(host); > > Using CQE_EVENT to determine whether Command Queue enable or not. Unless you expect CQ interrupts before cqhci_host_ops ->enable() is called, then you know it is legacy mode.