Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2757388imm; Tue, 4 Sep 2018 09:31:20 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaUr20iOj+3zFbCjNkq9mdEJXrg7OjOtUoSyfEghYIwBr5CxcD4hsHYKl+3V/CCQT2x3LiD X-Received: by 2002:a17:902:3081:: with SMTP id v1-v6mr34941102plb.58.1536078680445; Tue, 04 Sep 2018 09:31:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536078680; cv=none; d=google.com; s=arc-20160816; b=Oi4iy/UKm+vTUgkm3sFbyR0CNJiRXBs6a4t0zjbUsOz7p4zAJnPBme7VOhr0ehpP9D 4oXWAqofTAuzC5+xhv4vk8Yor2KUb1nVzBeqQuKfTrP8O2i3haoPn6MEiGwz6tMIVWAz 4t1umlyvCscCJpJAqAgSlBIG6lSWg3vzMt195WhGKEDOQjf9FrsOh246+FfvwViwh9uQ A7c2w/c+uitbqztXgrS+f+88IfBApRQXVBcsgMh9jDAObbstej6kGgsIdn8iuGRlRNCN ASXb1sq/a0FnxKeGMEWiqP3z5P0uP89cp/aWPpU47oX7RH3mRo6F3D65SnFEt1hC4JZI wyUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=BShs/B7WbmjGF339oaZcnn6uTeYWtvRJSOdxcgoD9c4=; b=FKRhsFW7+sSfs+CGMlffBaYfPC+XslEsHS0pouI0HeZGWjndHO3A0Y2Z6QKa81H8Ik 7OA+jGuPAkwA3Z1QSqcYQwMMU/1o09ox/RBx0FEHrYYH8AaErChMWGOoaW0r5czOuRjj gG1TNjeXnajtW2f9Xn1UuUmijKmTKDixqmxFlJAbiBuAGi7Y6vrvnceqWrOgHJ9H/Ilh fPf2jBiBN/ONztxKRYkm4JdswceQ8MQOID9KpdAzXGKRfw4osAlffjaDAUglyMkT3Y6T IQB8Sd1s05ssz948bPQdzfjraf9D+qeE4o5jE6GT5zouKSmA8XXz1N9sXWXm+O96hYrk KXvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=e4gKMDwm; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q17-v6si14563022pgc.464.2018.09.04.09.31.02; Tue, 04 Sep 2018 09:31:20 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b=e4gKMDwm; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728077AbeIDUzZ (ORCPT + 99 others); Tue, 4 Sep 2018 16:55:25 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:38901 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726052AbeIDUzZ (ORCPT ); Tue, 4 Sep 2018 16:55:25 -0400 Received: by mail-pf1-f195.google.com with SMTP id x17-v6so1955070pfh.5; 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=kfmwtCgkrp1wYw+oZUqsURqBMndGuXUGhwq9S9cCDcasDzsoQ0m3gfH0bfC2QXuxUt kdCQKapCIzyVgKGO5Sm49+YnL9GYIrvPH74cJa9TvuLtQPtnWawRdqCGgs7oaVp2o0BN MSHEnowV4w/5DJ89niUAEzvT5ajZBQBFjToq8szSdwZVNncG4Fte0XMe5e2sI9q9b7pD mE8ia7L2tMg2lLpzNhEOugClwSh9qR2TkPjqYwvcLvbpgoIJmY5l+Kgm3QlQ3OHlohgQ g186vC2RXl24EEkmwmYobC/Ue2jedHrv+I+6ldIoGbuThUym98Fhc0pQ3WJIUGHiQiRQ V4Sw== X-Gm-Message-State: APzg51BletLmXjb5koB0Zj3tZ9FuiDtixYt9NYh8b904j3MAgPR+da+7 U2nL4VyjYrhoUU6vSdO1Zh+5N0IR 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 Cc: linux-arm-kernel@lists.infradead.org, linux-soc@vger.kernel.org, andrew@lunn.ch, davem@davemloft.net, netdev@vger.kernel.org, Geetha sowjanya , Sunil Goutham 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) -- 2.7.4