From patchwork Tue Aug 28 10:57:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil Kovvuri X-Patchwork-Id: 10578227 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 016745A4 for ; Tue, 28 Aug 2018 11:05:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E39D228D1E for ; Tue, 28 Aug 2018 11:05:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D76FA28DCC; Tue, 28 Aug 2018 11:05:49 +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 60CF528D1E for ; Tue, 28 Aug 2018 11:05:49 +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=WZ8uYxCIDLZ4Sj8L1GzaI4RIXe nHirPXMq24KU7aln8jvKC9ZqoRBj073AzNAWQN2NQzOh/47jhKnQ6/B50mp1tytqv5jJqo9Jqe34K idflLr0C7K9nA82WT7cuMXRUoudDMo6dof1Q8XDO8g87akpcoZGOqiKjYxqL+LqCFZgjlkl/pFX4W jACDXpQClCphpDHPqKIiuxzSfchdCBEiSMnEhL2EoKHHTQx8PxEmuyoYhqp0ZTuUHgeL63ai/63vG Lk2jr28Y3akA4z2VHY/SCrETAFK8kH1Yp267txWpkVPHGir+FdtImyNlUTRT17TsMNr2RY8ILd4lQ 6YO2Uz/A==; 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 1fubod-0006zp-E3; Tue, 28 Aug 2018 11:05:43 +0000 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fubhW-0001ZH-3f for linux-arm-kernel@lists.infradead.org; Tue, 28 Aug 2018 10:58:23 +0000 Received: by mail-pf1-x443.google.com with SMTP id i26-v6so526461pfo.12 for ; Tue, 28 Aug 2018 03:58:11 -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=AzVPb+GvYrITOgWhPr3GMeSUDIHQ0oS0z8Mlb+FS2keNEI8KQ8Q2I2+qT6uHAUWNve kO1eOe9mj24wbWUyRMaQot3EYRnFpK2U5Gjk5BYZrUqqCIPG7apguPPd8KRRqJ+Twrk/ AcPc5WDeXq6mC8dMkfAU7TGOk/NZuePwOjTnMKgIT9DHHEMq8eeMF1hx6G5qqhnillX/ D0NeQrMct7OsBQqfod8AJRYyGce4SBkjlm2WXdpx1IuHZRbl97TMhuJxCBY6Kj5rXVwa GzlklquWRz+YP4kIseo9dDPHUtfqRCxR/FVxjigerbeV+swAWmUtTrOUEDkeDlrn2Qjy crAw== 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=HV2QeqE529QRndVz4/BvRYn1n5cjvYghNWbpNCJyBPh/C4Sc5rOkjWQiaFs9fTeWGO tBRGR7fYT2xyNxC0/XKYZlE7Y2SF+LbaOlj6aUL3tNbM6eIQA4NhnK2pQfPJZubdt+Kh vWtc/3rSJCYVBDiwEFTkcdgchKhdtyaimKKzd9fqAHoV0wMtDUMOYUr7UF8+hZP5qd/V jIQ84ZirC6W5fAu8AVeQMYwmVqtax/BPDGFEyWbnJqFOTvFQtrcd1+qa8qZbx8O9acOI RUcS2IA1SVBpii9f/fi1ifTXRs1Pc7U2Cuyj3/tmpBeL/mohsbcw6sP0JXgVzEOqEpxw Qgwg== X-Gm-Message-State: APzg51B8iOaBpOkxHxKP1MpoNQ1JZhq2HWQ/WCu22Tut5UtvX2KsvIxN KRSMsIJBKn4fm9kGdh0gLNc= X-Google-Smtp-Source: ANB0VdYe4r9tGq4w9Y0MBdvDYvrBSBr+pYf5wwSWubBePElqxHXUNyvD/9P4T6BeVOyNJ7yIP2oZtA== X-Received: by 2002:a65:420c:: with SMTP id c12-v6mr996031pgq.405.1535453890964; Tue, 28 Aug 2018 03:58:10 -0700 (PDT) Received: from machine421.caveonetworks.com ([115.113.156.2]) by smtp.googlemail.com with ESMTPSA id n22-v6sm2946798pfj.68.2018.08.28.03.58.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Aug 2018 03:58:10 -0700 (PDT) From: sunil.kovvuri@gmail.com To: linux-kernel@vger.kernel.org, arnd@arndb.de, olof@lixom.net Subject: [PATCH 10/15] soc: octeontx2: Reconfig MSIX base with IOVA Date: Tue, 28 Aug 2018 16:27:13 +0530 Message-Id: <1535453838-12154-11-git-send-email-sunil.kovvuri@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535453838-12154-1-git-send-email-sunil.kovvuri@gmail.com> References: <1535453838-12154-1-git-send-email-sunil.kovvuri@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180828_035822_270563_41EDE5B5 X-CRM114-Status: GOOD ( 16.82 ) 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: linux-soc@vger.kernel.org, Geetha sowjanya , linux-arm-kernel@lists.infradead.org, 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)