From patchwork Tue Sep 4 11:54:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil Kovvuri X-Patchwork-Id: 10587225 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 D8F38920 for ; Tue, 4 Sep 2018 12:02:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BF57C29345 for ; Tue, 4 Sep 2018 12:02:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B38A129348; Tue, 4 Sep 2018 12:02:00 +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 0D5CB29345 for ; Tue, 4 Sep 2018 12:02:00 +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=mM7tYAmPtFSgx4/MTPpDvJj9U9 nq7FG3526d4GNVvUuMo1vSGjAi24cKGKhasWCHmDfjlE6DAxadpqTS6RhjL3CC5TZpuGn597DmAI7 lOuwhWvBn5+P4wcR3gu4W5DksbkeSEi+TWEGC6v/P0OZvNead61XDcHOMlfugR6L9tHef9y81/phd Old9B+Ime6GbkywFxvPbnCiMAUKYlSkC8majBYpQj9c9CDTdtHlDYzuCVGrVrWRg9y24xgJZmxypV w8BXttT1m3tlFBI3D7ORJbXYtYt3sv2O5Ps305i6Fi6cF7CPfTv+rUXek4wUlqxDIftNXjBzXvf1e BnbgKUtg==; 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 1fxA1n-0000x7-GV; Tue, 04 Sep 2018 12:01:51 +0000 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fx9w4-0005o0-5b for linux-arm-kernel@lists.infradead.org; Tue, 04 Sep 2018 11:55:58 +0000 Received: by mail-pf1-x444.google.com with SMTP id d4-v6so1595909pfn.0 for ; Tue, 04 Sep 2018 04:55:52 -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=YFIsZIfR0yS01JLSovkltn7BAth89jIBEujwaOCkiSSFMG7iX9zPqGTOiEW9F3mke7 67uhHzOYeyUV8SCj3gCVtiD5LaTzmSLAtHvz0din7SPcYknx9Rm0Q+nTQ0sUNUaPrpr/ 0znBtfObYPHRwAMMZSqPUfYkvDqfjuVLfbqRXxUFQm/VEhuTex7lY3NI3RWGUp34/gYw zbBvP9rGLewv0MOLEF++aq/7/N85M3ssab/4kZC+a0tUOWe/KEicTznb5Pdbr2z8JB2p 9oDNryd21bBh/X9OXa84W95rfC0QSsutSO0pvuANop9dkxnwNhpblcuWDLAia48/pUa8 OulA== 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=INxnC8YYu5jw+ktfMwzpbELgQYhHuVwMjmFQTt7B4Br304PKien2PeUiqxJUpTxTZw GMdVjx+zpwsytDzVlaXpHLCZqWjrLmYyUXyvoNvuY4aEjSliUhxY+t7a6TyITs5+SyZ9 1amY7sfksIAXamxx8A72mrB5DkegIzRgXV25n92wLKVqzWofha7gLrzkQ3fPgmrglN0d zPpk2zxjPVPDreav6pW6B/IcHit2UkIr9GEJdojSQ8yv4eWJHYqp/FmROjzXL+KhlyTl +8nfvkF+DoLNWiPT8gjU7UVsRk/qsJ8tRjfI5uR6lpKeDB8ofAFsfEuDr5GzK/OIfOKf dlBQ== X-Gm-Message-State: APzg51D2CokF9jurcIbdmsnD1UDO/rdpea5bwGL9AAIss80Wa8OWhNrC 9Akz5ypt6okYpPZrGrS//rs= X-Google-Smtp-Source: ANB0VdY4SQFQNw4DjZVOaPsmnfupYuq3tsc6cbIEjA3AjhIENXdX2plbBdlEaj8k22IaqSXnqy9Jhg== X-Received: by 2002:a63:26c6:: with SMTP id m189-v6mr25291699pgm.70.1536062152078; Tue, 04 Sep 2018 04:55:52 -0700 (PDT) Received: from machine421.caveonetworks.com ([115.113.156.2]) by smtp.googlemail.com with ESMTPSA id u184-v6sm29740190pgd.46.2018.09.04.04.55.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 04 Sep 2018 04:55:51 -0700 (PDT) From: sunil.kovvuri@gmail.com To: linux-kernel@vger.kernel.org, arnd@arndb.de, olof@lixom.net Subject: [PATCH v2 10/15] soc: octeontx2: Reconfig MSIX base with IOVA Date: Tue, 4 Sep 2018 17:24:45 +0530 Message-Id: <1536062090-30446-11-git-send-email-sunil.kovvuri@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536062090-30446-1-git-send-email-sunil.kovvuri@gmail.com> References: <1536062090-30446-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_045556_250668_CE9F5DBE 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, Geetha sowjanya , linux-arm-kernel@lists.infradead.org, linux-soc@vger.kernel.org, davem@davemloft.net, Sunil Goutham 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)