Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp774196ybl; Wed, 4 Dec 2019 10:37:46 -0800 (PST) X-Google-Smtp-Source: APXvYqyXO1Xr+gOz9hhi7kHktaYO2dxEplyvuHYdiDhtz+KSyrO9xdhAECXkFMbXcS26ZvgP1EWO X-Received: by 2002:aca:50cd:: with SMTP id e196mr3915594oib.178.1575484666831; Wed, 04 Dec 2019 10:37:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575484666; cv=none; d=google.com; s=arc-20160816; b=etrxRvImkvZitp/dF31axgtEKLyTf9QBwmHPDgzZysn7WGTJImVl0iw8fUv8JdsG4V 16tOTx7nNfzTEgtWFwiaFxhOY33Sm7Ta3daehrI/qJC1mPac0Kjxh7az+1t5+1wIQPgd 4jKlrz1m1KA7o2cOJictui41LBrmaM4HjNPU97b/aeb4JhDj8Un4p6S8cLjvuHM8vVwi 5QWR/y94ib1RmDi9zCt0rotkLxHBK542xP1WOCtez92BlN4xDImw7D3cfXVO4hKfFXzX 0iHz8nn6jSEzbAmurDPAqEzCtWX+6ZJa9aPxuIdX651HAlK463x8xJgseCyWsDSFphE8 P+uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=wK9NstZxWCZ4fUNQKTAEIPBZ++U8z5OdNqnEeiQMgbs=; b=zbvDx7FSQYKO4VxY3TbtV3qNn5M5BDAvCkxggBixsmlXvK8koDDMZRF42ZCRJ4/Dei tRib3m6UGaZw9jGcsJqMXcsQLDZovSn9fpHf1yRodjaQalEIni8xWOGN4uScejsHMaRx 74ipDAmLK7IY71Q4twh5do8BGLltturv6dodTPwtRKiLeGVJFqJvXcXrq40j8lpJscS/ eZIhUXjJkNVfoYmSQkwQLO0NGqIFG61JQv239xEzExs5VSaIYUClVrQP8JDNcH3DnLR1 BYYFDy1/AgYVr+uPdTNX+deTZrCrM3Hhxikr6H194OF05nctmm1Alhyn5Cf6NQDVX0dW YWYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=TBoXeX0L; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n139si3754704oig.121.2019.12.04.10.37.33; Wed, 04 Dec 2019 10:37:46 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=TBoXeX0L; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728307AbfLDSgm (ORCPT + 99 others); Wed, 4 Dec 2019 13:36:42 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:54418 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728244AbfLDSgm (ORCPT ); Wed, 4 Dec 2019 13:36:42 -0500 Received: by mail-wm1-f66.google.com with SMTP id b11so788662wmj.4 for ; Wed, 04 Dec 2019 10:36:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=wK9NstZxWCZ4fUNQKTAEIPBZ++U8z5OdNqnEeiQMgbs=; b=TBoXeX0LWp6vtluo0nZrXJ+HWtp6RtDGftL1htkZ25cbrFAgcczcvS6SGQxLQ/S9DF U6C+bJHCD9Nw5DYneQ5qat7aDKfmutIcMCWejKtLDLpb1WQGzCauCHqoCOTKbO7g7Seu LC6j8E+J3jdAHjZ2AfyyQ7Cb+CO2t6UECM2cw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=wK9NstZxWCZ4fUNQKTAEIPBZ++U8z5OdNqnEeiQMgbs=; b=l5wY/VdIqKm2EkkaLTRNht9T+5doW3SISY2NeblQ0Q5V/Mf/EARCvpeHu091Ssk4dM aEos1Hfv8xYELEz7rZ1QI+kT/VrvptjjiSQX9QaP6pvMDF5X0k88WruR4nRxeQpOOfYP EDYIJ51NCFyiVsUiHlWTDNx/bWKSRm61GRqx+wHmEvLVTpHr16GkaqY/UySh/E2BAKuf QAVoWhv8WulDmvi7XW3IstpHMfpiZKKnjLjqBennUp0TfstCF1iLrD5SVjA2ayVJmoQg dt5gk4WA6yp3Wc/v5eZWVZxbQBwJDryEm7A0EnEcsheHbb98C9A1VN5oHCTB1DahCKGK SUbA== X-Gm-Message-State: APjAAAUVNDE1SyNuhQATqfg+m9cTYZyNpccWwMnk0vFv3SoUgbKlZM/E Cefpc1pMQ9GshSw42gw+obJOa6FGXJMH7wpvCqi7NmzSYnsf84wmgSdAclPTNUFwSvLZ+frXTaf yw+Y4pzs4io9g3CiB08CTW1SDcZCR2sZkNdr98p9osa1h3hHwXhYW2Zy1HqmQcZlkqlmNuYexS/ hm X-Received: by 2002:a1c:7f4e:: with SMTP id a75mr1044364wmd.128.1575484598710; Wed, 04 Dec 2019 10:36:38 -0800 (PST) Received: from rj-aorus.ric.broadcom.com ([192.19.228.250]) by smtp.gmail.com with ESMTPSA id n1sm9145299wrw.52.2019.12.04.10.36.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 04 Dec 2019 10:36:37 -0800 (PST) Subject: Re: [PATCH v3 2/6] PCI: iproc: Add INTx support with better modeling To: Andrew Murray , Andy Shevchenko Cc: Srinath Mannam , Lorenzo Pieralisi , Bjorn Helgaas , Florian Fainelli , Ray Jui , Rob Herring , Mark Rutland , Arnd Bergmann , bcm-kernel-feedback-list , linux-pci@vger.kernel.org, devicetree , linux-arm Mailing List , Linux Kernel Mailing List References: <1575349026-8743-1-git-send-email-srinath.mannam@broadcom.com> <1575349026-8743-3-git-send-email-srinath.mannam@broadcom.com> <20191203155514.GE18399@e119886-lin.cambridge.arm.com> <40fffa66-4b06-a851-84c2-4de36d5c6777@broadcom.com> <20191204160729.GJ18399@e119886-lin.cambridge.arm.com> From: Ray Jui Message-ID: Date: Wed, 4 Dec 2019 10:36:31 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.1 MIME-Version: 1.0 In-Reply-To: <20191204160729.GJ18399@e119886-lin.cambridge.arm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/4/19 8:07 AM, Andrew Murray wrote: > On Wed, Dec 04, 2019 at 10:29:51AM +0200, Andy Shevchenko wrote: >> On Wed, Dec 4, 2019 at 12:09 AM Ray Jui wrote: >>> On 12/3/19 11:27 AM, Andy Shevchenko wrote: >>>> On Tue, Dec 3, 2019 at 5:55 PM Andrew Murray wrote: >>>>> On Tue, Dec 03, 2019 at 10:27:02AM +0530, Srinath Mannam wrote: >>>> >>>>>> + /* go through INTx A, B, C, D until all interrupts are handled */ >>>>>> + do { >>>>>> + status = iproc_pcie_read_reg(pcie, IPROC_PCIE_INTX_CSR); >>>>> >>>>> By performing this read once and outside of the do/while loop you may improve >>>>> performance. I wonder how probable it is to get another INTx whilst handling >>>>> one? >>>> >>>> May I ask how it can be improved? >>>> One read will be needed any way, and so does this code. >>>> >>> >>> I guess the current code will cause the IPROC_PCIE_INTX_CSR register to >>> be read TWICE, if it's ever set to start with. >>> >>> But then if we do it outside of the while loop, if we ever receive an >>> interrupt while servicing one, the interrupt will still need to be >>> serviced, and in this case, it will cause additional context switch >>> overhead by going out and back in the interrupt context. > > Yes it's a trade off - if you dropped the do/while loop and thus had a single > read you'd reduce the overhead on interrupt handling in every case except > where another INTx is received whilst in this function. But as you point out > each time that does happen you'll pay the penalty of a context switch. > Exactly, it's a tradeoff between: 1) saving one register read (which is likely in the 10th of nanosecond range) in all INTx handling; and 2) saving context switches (which is likely in 10th of microsecond range) in cases when we have multiple INTx when servicing it. The current implementation takes 2), which I thought it makes sense. > I don't have any knowledge of this platform so I have no idea if such a change > would be good/bad or material. However I thought I'd point it out. Looking at > the other controller drivers, some handle in a loop and some don't. > > >>> >>> My take is that it's probably more ideal to leave this portion of code >>> as it is. >> >> Can't we simple drop a do-while completely and leave only >> for_each_set_bit() loop? >> Like both Andrew and I pointed out. There's a tradeoff here. Could you please help to justify why you favor 1) than 2)? > > I'm happy either way. > > Thanks, > > Andrew Murray > >>> >>>>>> + for_each_set_bit(bit, &status, PCI_NUM_INTX) { >>>>>> + virq = irq_find_mapping(pcie->irq_domain, bit); >>>>>> + if (virq) >>>>>> + generic_handle_irq(virq); >>>>>> + else >>>>>> + dev_err(dev, "unexpected INTx%u\n", bit); >>>>>> + } >>>>>> + } while ((status & SYS_RC_INTX_MASK) != 0); >>>> >> >> >> >> -- >> With Best Regards, >> Andy Shevchenko