From patchwork Thu Sep 3 17:28:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 274651 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9327CC433E9 for ; Thu, 3 Sep 2020 17:29:07 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5FA8020716 for ; Thu, 3 Sep 2020 17:29:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UclCLAR7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5FA8020716 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:57620 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kDt2o-0002gG-GZ for qemu-devel@archiver.kernel.org; Thu, 03 Sep 2020 13:29:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55512) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kDt1z-0000s8-Oa; Thu, 03 Sep 2020 13:28:15 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:34248) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kDt1y-0002Vb-29; Thu, 03 Sep 2020 13:28:15 -0400 Received: by mail-wr1-x442.google.com with SMTP id t10so4135320wrv.1; Thu, 03 Sep 2020 10:28:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oW6XvxZuE1zKD54bo18SFHuDRJFc1R7THevACoTqgkM=; b=UclCLAR7ukADVGhNA2HNAojA6SmIcNm9cl64vWhssP/TJgxEjb/Dre40PT6j1zRVJz b1jmNs+ajxvVpK/B3+M3YnDLeo2oN4W3O0NX5uLJSPXLrkd4Dn3JFAassBF2smNIs2N7 M+7Ne82EAHw7vtlwNfPC0kpMng65TwEpbMO4OtrcqOr0WBmBcsD9A/KsOW0sJ1t977bF KtWvXBN+hMHkBZBqVx2yCLzV6OFSgAGg5M07rJqBybgVM6ftJ/y2RfR0qML2XJUsapRj y6BUD74UFJJUHcuCeQhaPwMrhU2lOjf8VpWo6bkRwCO+ESTLbBA93f18yIT3Vz19tgW9 7eWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=oW6XvxZuE1zKD54bo18SFHuDRJFc1R7THevACoTqgkM=; b=j0ggyhR8PqknYO3k2jZzjO5wkA21n7cW+xLqyTdrwyWbqRaki2grzsL/SYkoz5jiIi Vf4wTKs91zUnYh6Pox8im8hbhtKDs/H7D3LtDcj7nuGiD8epxOLWmxhtSF52G56uhEsL MvlwIJtwb/t9CVrF4JOt2xhwli2qb+kGYGc3n+HoPsQwC1VZJpb1hGYrz9xY5IPftYq1 D1IKKmKSioDDS6lLanGI+SNFT1HpvG1vZbx6D+iqA4vcKcTT57zybkcm+nJVHi/mfFWF qEocUnmvQE+DS9bxlZhJ3fEBu7LWoqLeUOjKOAwrbDASImaMoZMMg486sGjClxOGe6vh +b/g== X-Gm-Message-State: AOAM532KlCVapeUG+cw6ucRwOBmbnBmFnoTF/J2Bg8GXWF88In24haSs 5SxYNQncVovxBFPMI9xs72RJE5bTFes= X-Google-Smtp-Source: ABdhPJxD/eT6l2vFol7VZU2Jyo5/WQJgbylf3v9Kt/NGmTML055BK2l8qA9Um3yZQ8pwfkfEf9Uzlw== X-Received: by 2002:adf:8445:: with SMTP id 63mr3451049wrf.375.1599154091708; Thu, 03 Sep 2020 10:28:11 -0700 (PDT) Received: from localhost.localdomain (50.red-83-52-54.dynamicip.rima-tde.net. [83.52.54.50]) by smtp.gmail.com with ESMTPSA id b2sm5325802wmh.47.2020.09.03.10.28.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2020 10:28:10 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 2/4] hw/sd/sdhci: Resume pending DMA transfers on MMIO accesses Date: Thu, 3 Sep 2020 19:28:04 +0200 Message-Id: <20200903172806.489710-3-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200903172806.489710-1-f4bug@amsat.org> References: <20200903172806.489710-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::442; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x442.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Prasad J Pandit , qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Alexander Bulekov , qemu-arm@nongnu.org, Ruhr-University Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" If we have pending DMA requests scheduled, process them first. So far we don't need to implement a bottom half to process them. Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sdhci.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c index 703357e94a7..2b197631870 100644 --- a/hw/sd/sdhci.c +++ b/hw/sd/sdhci.c @@ -945,11 +945,21 @@ sdhci_buff_access_is_sequential(SDHCIState *s, unsigned byte_num) return true; } +static void sdhci_resume_pending_transfer(SDHCIState *s) +{ + timer_del(s->transfer_timer); + sdhci_data_transfer(s); +} + static uint64_t sdhci_read(void *opaque, hwaddr offset, unsigned size) { SDHCIState *s = (SDHCIState *)opaque; uint32_t ret = 0; + if (timer_pending(s->transfer_timer)) { + sdhci_resume_pending_transfer(s); + } + switch (offset & ~0x3) { case SDHC_SYSAD: ret = s->sdmasysad; @@ -1093,6 +1103,10 @@ sdhci_write(void *opaque, hwaddr offset, uint64_t val, unsigned size) uint32_t value = val; value <<= shift; + if (timer_pending(s->transfer_timer)) { + sdhci_resume_pending_transfer(s); + } + switch (offset & ~0x3) { case SDHC_SYSAD: s->sdmasysad = (s->sdmasysad & mask) | value; From patchwork Thu Sep 3 17:28:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 274650 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 74659C433E2 for ; Thu, 3 Sep 2020 17:31:28 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3A65F206C0 for ; Thu, 3 Sep 2020 17:31:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dlseXbUP" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3A65F206C0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:36170 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kDt55-0005YW-44 for qemu-devel@archiver.kernel.org; Thu, 03 Sep 2020 13:31:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55558) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kDt22-0000yk-9W; Thu, 03 Sep 2020 13:28:18 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:53982) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kDt20-0002WP-Nk; Thu, 03 Sep 2020 13:28:17 -0400 Received: by mail-wm1-x343.google.com with SMTP id u18so3672371wmc.3; Thu, 03 Sep 2020 10:28:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=h5iaQi3vWrr7M+kdi5/Gojkf+HOxBwaJDmXr+jv44dA=; b=dlseXbUPPWe78yt35GsXIDaRQ7iWXdV+Kjuns6hAGs8G9CuivxFz4Ohu+9joPCTdtJ dWRuPopDm5Su8N2femkKXQV0ghgfzUg4V5KlAB+1XFJNolm/N/jPhTLV0Ay1LpEOypW8 UClq4JZ+3sGbt0CuBJmrFIbSMTug0UUDw7pQL4r7flk1i6qu3b9ZTTX+fllC35+FwHLF DaGD5dMzrHMNm0UPnngtMENYnIlpajxhX7Bh/c8t5mNgJRz4WCfpmUeKYVri9sj2/KRm ZwP45wszHKmeLBAEiqzcCsHwMmAX9ikzy/irKvSiJAQoq3NSqRLqSIrvJpRjp+a88l9T 5JSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=h5iaQi3vWrr7M+kdi5/Gojkf+HOxBwaJDmXr+jv44dA=; b=Ld9Mwn2b2JHrXam0O9PT2ip6y53h6R+1kpewNjKeSfft2ezy+o6qVMxgyBvAb3recL GIGblEn3M66uYHt7tiUC+Jz+EEZUkpkkFSmB66vUsmcr28iXlCGDYEvNYNgggZxI878j T4vP26ctUgDmHuWnp85196SVXRpCR7WBskBFY/OX0w46hcHb8kJ9bWMXkgtt8+swfEch WXNUGwa7SCT0wtLcldR5uecuM8WoJaIFvlDvnmUqIzb6jgPq/Cv3s99oVdK+2m9IeD6v g8AMpeR3aB5jw20im5z04+0LquYWuITEjyrOalhJ5sjSpiJXKGFp/vFZ4/ytrgW3f4Ti sfSg== X-Gm-Message-State: AOAM530F3dSnylxn+f8eBeXf/YjqZDPNxQrfWIVWu/nVWlpChTnaDJ58 QswKjXMcrbx5RaJxFmMqhldYS4yVuvY= X-Google-Smtp-Source: ABdhPJyhemRyOsLI9pWpEZQSs6hRzeM4cZOzNRA/oSJWtDsoJLui1dskwVNPAsICJPfo9SeDKsKgWg== X-Received: by 2002:a7b:c387:: with SMTP id s7mr3520582wmj.171.1599154094081; Thu, 03 Sep 2020 10:28:14 -0700 (PDT) Received: from localhost.localdomain (50.red-83-52-54.dynamicip.rima-tde.net. [83.52.54.50]) by smtp.gmail.com with ESMTPSA id b2sm5325802wmh.47.2020.09.03.10.28.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2020 10:28:13 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 4/4] hw/sd/sdhci: Yield if interrupt delivered during multiple transfer Date: Thu, 3 Sep 2020 19:28:06 +0200 Message-Id: <20200903172806.489710-5-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200903172806.489710-1-f4bug@amsat.org> References: <20200903172806.489710-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::343; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-x343.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Prasad J Pandit , qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Alexander Bulekov , qemu-arm@nongnu.org, Ruhr-University Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The Descriptor Table has a bit to allow the DMA to generates Interrupt when the operation of the descriptor line is completed (see "1.13.4. Descriptor Table" of 'SD Host Controller Simplified Specification Version 2.00'). If we have pending interrupt and the descriptor requires it to be generated as soon as it is completed, reschedule pending transfers and yield to the CPU. Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sdhci.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c index 06cb098036c..74b0bf77103 100644 --- a/hw/sd/sdhci.c +++ b/hw/sd/sdhci.c @@ -834,7 +834,10 @@ static void sdhci_do_adma(SDHCIState *s) s->norintsts |= SDHC_NIS_DMA; } - sdhci_update_irq(s); + if (sdhci_update_irq(s) && !(dscr.attr & SDHC_ADMA_ATTR_END)) { + /* IRQ delivered, reschedule current transfer */ + break; + } } /* ADMA transfer terminates if blkcnt == 0 or by END attribute */