From patchwork Tue Sep 4 16:28:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil Kovvuri X-Patchwork-Id: 10587663 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 99834112B for ; Tue, 4 Sep 2018 16:37:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7967B29C59 for ; Tue, 4 Sep 2018 16:37:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6893929DCB; Tue, 4 Sep 2018 16:37:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0075629C01 for ; Tue, 4 Sep 2018 16:37:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=z0Xwpfmi1tKy1CIPoH/KF48g2xl4NUB6rOkMUg4drVc=; b=knjCClpaX6+m3q+zn+EuFb3zje mRJ09CbVHcrnNdCcVhxTtNtGqWGg9f+QziYTu67gGY4mrkS4gpvObuUhA5EQ6CDkKnfBAyC0OkdN2 zM3ZZfw8ya0+i+x+TrpVGN5gs1N3S8oIYz1WNUn3uMpbZf4jefoZeCQFubIT6K6fDzlvsFsdL3hQA NCTxQVzecbyBRBM2PTZF06EohTvfL9QBhtf3wEILqSToX+SSAzGNBqYoeEz9EM/pdnY0Xg6E3Cdj/ GLcUmYIQVBPMIoJI/eQeru0PjEduhOAaXnr5qm4wpidKMnBZafwnNWNfosek8ldntiVbApm56wUsx Qjm8HjqA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fxEKQ-0002EE-3V; Tue, 04 Sep 2018 16:37:22 +0000 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fxED1-0004j4-V8 for linux-arm-kernel@lists.infradead.org; Tue, 04 Sep 2018 16:29:48 +0000 Received: by mail-pg1-x541.google.com with SMTP id t84-v6so76731pgb.5 for ; Tue, 04 Sep 2018 09:29:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=BShs/B7WbmjGF339oaZcnn6uTeYWtvRJSOdxcgoD9c4=; b=e4gKMDwmkaESgOEOlqil9MwG44rpi+ReeeVZMvRQVUTaalant3g37UPg/9ZFbDkiPV jr3Lr0PHB0p0Xt7fQLIzCNjau59nCZE+Hk1+XG1NaIsO1KwKe6bG0ClT36DZR/GflPTx E1GUGe6cUSt8/T1+c1S02FoV/nzmvtivzMrNBs5BzvGrdp/OQ1gAdGd7/s/O/Wl3GEQ1 Iecei+U9M0sYTE871s9KzwJOrS8h+ijsSyf+AvkZMFTOus3DPA6Qad3n6WcESIncWLjZ 1jd1eW2TzSCmsQKlDzU+qbhxQXUNflxyjNrZw1ALX0p2daaJPURiasWIsGPosCuBBnUG yZ0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=BShs/B7WbmjGF339oaZcnn6uTeYWtvRJSOdxcgoD9c4=; b=ioZ8tdPgUp6AFeIJAx6igbPsnrn7ZuTImIZxvm1CHYsTdfoZhvoWN7+JP5O8bV8Qw+ Pgs5MjmRTViXFneqBbPf7X1j6KzlFYfu9fNiKExpCb6L4IHDgGF5mw1JDIQ7I/OXBIPo 2YrREizKvWqtYU+xbHcc9i8cRq735VN6kPe7nI1BQMRVTOyadXI2V+0kllUVfakiTZ58 uNO/ga1PILM2RWiL3ynj/l01eXi4ft9dfgmPi3s0rmojsBT6QtgSnuIZcQZsz0zgMQI/ VhdDdh78HnTSD5a+1XkhlWkmtq9h1A/pn30EyNhjPwvfw22qOhkcDFAUE3BQtHOGoMH0 11nQ== X-Gm-Message-State: APzg51DXXJHtUpOQkcA1jItpAgsIngibCENjFZ/NSdKCAx0K7ZfuMetD elGEirIxaFPzmL+p9LHju9E= X-Google-Smtp-Source: ANB0VdamhIOU/vVDidtHA2IGycSKLhEggiicYOGY1ussbUXaHV38/g//IsbZA0M4aYv9LKmIFwGilA== X-Received: by 2002:a63:6183:: with SMTP id v125-v6mr32566152pgb.242.1536078572892; Tue, 04 Sep 2018 09:29:32 -0700 (PDT) Received: from machine421.caveonetworks.com ([115.113.156.2]) by smtp.googlemail.com with ESMTPSA id j191-v6sm32243827pfc.136.2018.09.04.09.29.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 04 Sep 2018 09:29:32 -0700 (PDT) From: sunil.kovvuri@gmail.com To: linux-kernel@vger.kernel.org, arnd@arndb.de, olof@lixom.net Subject: [PATCH v3 10/15] soc: octeontx2: Reconfig MSIX base with IOVA Date: Tue, 4 Sep 2018 21:58:40 +0530 Message-Id: <1536078525-31534-11-git-send-email-sunil.kovvuri@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536078525-31534-1-git-send-email-sunil.kovvuri@gmail.com> References: <1536078525-31534-1-git-send-email-sunil.kovvuri@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180904_092944_022796_5D4B2207 X-CRM114-Status: GOOD ( 17.06 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: andrew@lunn.ch, netdev@vger.kernel.org, davem@davemloft.net, Sunil Goutham , linux-soc@vger.kernel.org, Geetha sowjanya , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Geetha sowjanya HW interprets RVU_AF_MSIXTR_BASE address as an IOVA, hence create a IOMMU mapping for the physcial address configured by firmware and reconfig RVU_AF_MSIXTR_BASE with IOVA. Signed-off-by: Geetha sowjanya Signed-off-by: Sunil Goutham --- drivers/soc/marvell/octeontx2/rvu.c | 33 ++++++++++++++++++++++++++++++--- drivers/soc/marvell/octeontx2/rvu.h | 1 + 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/drivers/soc/marvell/octeontx2/rvu.c b/drivers/soc/marvell/octeontx2/rvu.c index 8ac3524..40684c9 100644 --- a/drivers/soc/marvell/octeontx2/rvu.c +++ b/drivers/soc/marvell/octeontx2/rvu.c @@ -442,9 +442,10 @@ static int rvu_setup_msix_resources(struct rvu *rvu) { struct rvu_hwinfo *hw = rvu->hw; int pf, vf, numvfs, hwvf, err; + int nvecs, offset, max_msix; struct rvu_pfvf *pfvf; - int nvecs, offset; - u64 cfg; + u64 cfg, phy_addr; + dma_addr_t iova; for (pf = 0; pf < hw->total_pfs; pf++) { cfg = rvu_read64(rvu, BLKADDR_RVUM, RVU_PRIV_PFX_CFG(pf)); @@ -523,6 +524,22 @@ static int rvu_setup_msix_resources(struct rvu *rvu) } } + /* HW interprets RVU_AF_MSIXTR_BASE address as an IOVA, hence + * create a IOMMU mapping for the physcial address configured by + * firmware and reconfig RVU_AF_MSIXTR_BASE with IOVA. + */ + cfg = rvu_read64(rvu, BLKADDR_RVUM, RVU_PRIV_CONST); + max_msix = cfg & 0xFFFFF; + phy_addr = rvu_read64(rvu, BLKADDR_RVUM, RVU_AF_MSIXTR_BASE); + iova = dma_map_single(rvu->dev, (void *)phy_addr, + max_msix * PCI_MSIX_ENTRY_SIZE, + DMA_BIDIRECTIONAL); + if (dma_mapping_error(rvu->dev, iova)) + return -ENOMEM; + + rvu_write64(rvu, BLKADDR_RVUM, RVU_AF_MSIXTR_BASE, (u64)iova); + rvu->msix_base_iova = iova; + return 0; } @@ -531,7 +548,8 @@ static void rvu_free_hw_resources(struct rvu *rvu) struct rvu_hwinfo *hw = rvu->hw; struct rvu_block *block; struct rvu_pfvf *pfvf; - int id; + int id, max_msix; + u64 cfg; /* Free block LF bitmaps */ for (id = 0; id < BLK_COUNT; id++) { @@ -549,6 +567,15 @@ static void rvu_free_hw_resources(struct rvu *rvu) pfvf = &rvu->hwvf[id]; kfree(pfvf->msix.bmap); } + + /* Unmap MSIX vector base IOVA mapping */ + if (!rvu->msix_base_iova) + return; + cfg = rvu_read64(rvu, BLKADDR_RVUM, RVU_PRIV_CONST); + max_msix = cfg & 0xFFFFF; + dma_unmap_single(rvu->dev, rvu->msix_base_iova, + max_msix * PCI_MSIX_ENTRY_SIZE, + DMA_BIDIRECTIONAL); } static int rvu_setup_hw_resources(struct rvu *rvu) diff --git a/drivers/soc/marvell/octeontx2/rvu.h b/drivers/soc/marvell/octeontx2/rvu.h index 7435e83..92c2022 100644 --- a/drivers/soc/marvell/octeontx2/rvu.h +++ b/drivers/soc/marvell/octeontx2/rvu.h @@ -99,6 +99,7 @@ struct rvu { u16 num_vec; char *irq_name; bool *irq_allocated; + dma_addr_t msix_base_iova; }; static inline void rvu_write64(struct rvu *rvu, u64 block, u64 offset, u64 val)