From patchwork Fri Mar 24 19:22:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaying Liang X-Patchwork-Id: 9643911 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 813F960328 for ; Fri, 24 Mar 2017 19:31:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6E43927D45 for ; Fri, 24 Mar 2017 19:31:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5F9DE27F93; Fri, 24 Mar 2017 19:31:24 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED2F927D45 for ; Fri, 24 Mar 2017 19:31:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967128AbdCXTbW (ORCPT ); Fri, 24 Mar 2017 15:31:22 -0400 Received: from mail-sn1nam02on0046.outbound.protection.outlook.com ([104.47.36.46]:44064 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S967068AbdCXTaH (ORCPT ); Fri, 24 Mar 2017 15:30:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector1-xilinx-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=KC/BOqfNyvRgc1+loe73VJpk5Bdi9yFtPp0up4Y7dug=; b=3V/ddtd/T8699RIg/ILoRsNwukRKaBtD5xWdYToQPyfbePV2jnw0oIWtw2taoZa/4ZDyfJOEov8urGP7BIo5nsNw7oUesM1hm0xziKQ1CqDdOllycoGjTkUZwtrRMRYzZ/jHrqoPjmFKdumh8ypA+Of1uN0w3mpV2hxMWkoKEmY= Received: from MWHPR02CA0029.namprd02.prod.outlook.com (10.164.133.18) by CY1PR02MB1382.namprd02.prod.outlook.com (10.161.171.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.977.11; Fri, 24 Mar 2017 19:30:00 +0000 Received: from BL2NAM02FT058.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e46::207) by MWHPR02CA0029.outlook.office365.com (2603:10b6:301:60::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.991.14 via Frontend Transport; Fri, 24 Mar 2017 19:29:59 +0000 Authentication-Results: spf=pass (sender IP is 149.199.60.83) smtp.mailfrom=xilinx.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=bestguesspass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.60.83 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.60.83; helo=xsj-pvapsmtpgw01; Received: from xsj-pvapsmtpgw01 (149.199.60.83) by BL2NAM02FT058.mail.protection.outlook.com (10.152.76.176) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.977.7 via Frontend Transport; Fri, 24 Mar 2017 19:29:58 +0000 Received: from unknown-38-66.xilinx.com ([149.199.38.66] helo=xsj-pvapsmtp01) by xsj-pvapsmtpgw01 with esmtp (Exim 4.63) (envelope-from ) id 1crUuM-0006JS-B1; Fri, 24 Mar 2017 12:29:58 -0700 Received: from [127.0.0.1] (helo=localhost) by xsj-pvapsmtp01 with smtp (Exim 4.63) (envelope-from ) id 1crUuM-0002mW-7X; Fri, 24 Mar 2017 12:29:58 -0700 Received: from xsj-pvapsmtp01 (mailhost.xilinx.com [149.199.38.66]) by xsj-smtp-dlp1.xlnx.xilinx.com (8.13.8/8.13.1) with ESMTP id v2OJTqIY010489; Fri, 24 Mar 2017 12:29:53 -0700 Received: from [172.19.2.167] (helo=xsjjliang50.xilinx.com) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1crUuG-0002jg-PI; Fri, 24 Mar 2017 12:29:52 -0700 From: Wendy Liang To: CC: , , "Wendy Liang" , Wendy Liang , Michal Simek Subject: [RFC LINUX PATCH 19/19] remoteproc: virtio: idr_alloc for rvdev Date: Fri, 24 Mar 2017 12:22:35 -0700 Message-ID: <1490383355-23176-20-git-send-email-jliang@xilinx.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1490383355-23176-1-git-send-email-jliang@xilinx.com> References: <1490383355-23176-1-git-send-email-jliang@xilinx.com> X-RCIS-Action: ALLOW X-TM-AS-Product-Ver: IMSS-7.1.0.1224-8.1.0.1062-22962.005 X-TM-AS-User-Approved-Sender: Yes;Yes X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:149.199.60.83; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(39840400002)(39860400002)(39850400002)(39410400002)(39450400003)(2980300002)(438002)(199003)(189002)(9170700003)(81166006)(5003940100001)(6916009)(8936002)(36386004)(305945005)(50226002)(2950100002)(2906002)(48376002)(5660300001)(50466002)(189998001)(8676002)(4326008)(50986999)(36756003)(6666003)(77096006)(9786002)(38730400002)(110136004)(107886003)(47776003)(106466001)(33646002)(356003)(54906002)(2351001)(76176999)(107986001)(217873001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR02MB1382; H:xsj-pvapsmtpgw01; FPR:; SPF:Pass; MLV:sfv; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2NAM02FT058; 1:sPDyzBVvheCIT0pB21VoI7NgLE5FYphVyPYTlkLfdDysnp06vqlw3q42WZyQZe+uyUELPjg0+DTZR/e6iNc4hSjl4PRXnyG2l51OyPri3u/YZmvOUwf2sDPWE8uZ6SUIEk3NVrLyQT5x8T4yYMO62GkpKI8eOkV+ml+cGfwEbIR56KE1nJnWEE6UlGrP+W7/Jskeu8GRvz1heysmyhTNQBgbPutKBl2G1nZxQx7cJf5mN4zKaZt3PX/AIoXKR1zCihpY+Ejev1LfKgNB5HILoOmKbC7vIIpOEq9QV6UatJy6zBKOvDuH0WFhwIPkuXDsy0CAysxe/7RR/EMDtJqNdK/b94VAgSLdSnZTGk6ZsmRiQNuff6Q310JORHIQ5WIdFTIQKs68qn7cZPMfpsWi6+2nbpdbPc1aYM2rQNOHXuoPOydMhptdfVqePcWtpjjoUfa5FVUebkgIZV+CjGAK5HYC3dkfU6wnZjfF5oyNRQWPAKeGooAtwNwfNMEpXUOXRG/MQUB8F2Et3al19Qfy6wMx/uNIr84QynGFwB87WeKg6CJAh6umTGC4auxl2gj2dcdJcAgpWESFeh8r2DFKuQ== MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 5cd25313-5707-4a2d-b8e3-08d472ec28f1 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(8251501002)(2017030254075); SRVR:CY1PR02MB1382; X-Microsoft-Exchange-Diagnostics: 1; CY1PR02MB1382; 3:mXkEI9h+c5zGk4gdQz0gxhzKvvAWdA8tRSaMObtPwPE2p/79+4u4yUweYWPjMmgzHF/3KlLQeeSRHiWmz1CHcfwRWhiWMaOC6a1e+2TMpvHyALo2Ia1N2c12t7AwnXPs9h4thkqJ2JaK8yT+Mi9NvWWkxO5JeQycAwGondyeqzwqL4IUR0QL+3LbWyjhbp3kgOAQAXVBAYnpX131+XBtTUQaA2kz/HsddRVi6/WqxDKf5jzxj/8D5Qqc5SSBT6Qapbd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PgivZc0sUgmYwb1pvD1isqvYHI4yTa8V2A/bCdZE/Sp/+mmXlv4RqiihPkhDrVDT+HFerMad0tZTt2cCeApksk+bJu+h5Z7xh2R3Sk/0V5w2f3zpLofLNtPDUEOWOWRxtYt0ErpwsfMGP1UF9iL9KtCok81ELNOFS6gi5BjGKziVsCinL+O06+YldktfIjTyUM/e+gU++CqgADAt+8yOSXIH0cHWJuoprmcwsBgEgQO+0Ih9C2q+PydhGyrmnpWtekpOL0g8+6GxYjdCf5/ZAWMOwvnqEIgFvnkPApEPstuUe0JRrdDgVCJcN2ce2EyFgf4Vt5XZ1wZL3PGgEsWhLWOE2/EyoEO8evAeTC35ouFV0hTwwmIbojnRHlvUWXrCH4Wfa64VRNGOQkU35Rm/tHnbL45RKPS7Eqguofc5XZV7hJc2lN X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(192813158149592); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(13024025)(13023025)(13017025)(13018025)(13015025)(5005006)(8121501046)(10201501046)(3002001)(6055026)(6041248)(20161123564025)(20161123555025)(20161123560025)(20161123558025)(20161123562025)(6072148); SRVR:CY1PR02MB1382; BCL:0; PCL:0; RULEID:; SRVR:CY1PR02MB1382; X-Microsoft-Exchange-Diagnostics: 1; CY1PR02MB1382; 4:gUn8W4srsnhYygDCrlfSSqVXx59QBnGkJbTmTUPeC73cPX+t8FeB9GO53Gb2V5irxxwol/y2Q00qVnbVFiKoptl5tPc+kjesDaIseO27DHZiNEI+A6ibZOg3bBbt9tYgTYscu36j1FISKNLeraVtdu3xyDxmUCnoXRg9TjAPmLxMgM0Y6YSdzc29+aZ8byGEKTBcvoCPl8BqWz0eST3bmVl2LXOblnyjknCFgr3QZ/lOVfiEJLrUeMDD/apopMu8Mtg5f4svz2oRoZiPNtDUDWR8wMbBytwGc+viEUv50FDTW3b1OzRK9qu97zHVu2+1+QecERD6OKtPKZRXfaCGp/ykRUcBZ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0ZhqhWRIe2hPl6gE52ejs3jjiTtQRxJhz8OW7kWQo4sZFKlMwguDYlfmPvDt46rH/6J66IMW0Eu35laF0vnURrus5V7TSgoDibXfdpdTG3nw02hVmid00Ibe406dv429P/A3QokfNR7w/P0pRJUTOMBB+ZzHCZJw7q45sK1Naq+d/ewY=; 5:kQJ7t4GhrWeY5wkgI/WHuEFwwe1qqFrYmRdtkHx36tUnb4kZyd2aQGqWXU0fPpS8S6tpCngk0JRuTsZB1GHQU+lu/dB2lmDGvM47Ak7w3/Y3YT0YB5Sks8AIHHgC3YRPgwj0JgRgR7nx8uthgbmk6w==; 24:eb6HfTAtGv6dewH0Dx5PW4xT8pcZEAF6m6CfiPORfoMvCuy2AyjwQHOICEHFWKhLBAkYeLKe4Ey7DQx9RMIbZGMTF7JODmkq9VU3JAof+KM= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY1PR02MB1382; 7:913cvAFEGplpwu1NtUu0ZP3z4c3mBsPafPr9NMF2lk0lsLrDnmqGarqUgPcNdzVv0R5AT3VaCsInJeHIfKXfuSegTEZ2oAhFHTss6TEZ2mWvIgpg6LskrP9qMcxHsDwvKfrH1UdHAVhqT3wSerNcyDhLRcJaKd8hq3tzO+o/0ppiWbMOlverWTWIq1LYkCKW7GCS/uFoEURHG5VOH4WbeiVshCQb/IQAo30WRYdNIDW4MUkL9/HbwtHBi9zn1MGnuwtmfDzXh6anZW3V+BgeTABbUc4I+grXurAz33d+sznSdqaSPL8rk6vu6iN9BpOPzJr24estsmVrFNK5XU1EXg== X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Mar 2017 19:29:58.8204 (UTC) X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.60.83]; Helo=[xsj-pvapsmtpgw01] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR02MB1382 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Wendy Liang use idr_alloc to allocate notifyid for rvdev and set it to the resource table. Signed-off-by: Wendy Liang Signed-off-by: Michal Simek --- drivers/remoteproc/remoteproc_core.c | 4 +--- drivers/remoteproc/remoteproc_virtio.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 62c0356..35cebd8 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -271,12 +271,10 @@ int rproc_alloc_vring(struct rproc_vdev *rvdev, int i) /* * Assign an rproc-wide unique index for this vring - * TODO: assign a notifyid for rvdev updates as well - * TODO: support predefined notifyids (via resource table) */ ret = rproc_idr_alloc(rproc, rvring, RPROC_IDR_VRING, 0, 0); if (ret < 0) { - dev_err(dev, "idr_alloc failed: %d\n", ret); + dev_err(dev, "rvfing idr_alloc failed: %d\n", ret); dma_free_coherent(dev->parent, size, va, dma); return ret; } diff --git a/drivers/remoteproc/remoteproc_virtio.c b/drivers/remoteproc/remoteproc_virtio.c index bf3be6f1..117e7e3 100644 --- a/drivers/remoteproc/remoteproc_virtio.c +++ b/drivers/remoteproc/remoteproc_virtio.c @@ -361,6 +361,8 @@ int rproc_add_virtio_dev(struct rproc_vdev *rvdev, int id) struct device *dev = &rproc->dev; struct virtio_device *vdev = &rvdev->vdev; int ret; + int idr_start, idr_end; + struct fw_rsc_vdev *rsc; vdev->id.device = id, vdev->config = &rproc_virtio_config_ops, @@ -381,6 +383,27 @@ int rproc_add_virtio_dev(struct rproc_vdev *rvdev, int id) /* Reference the vdev and vring allocations */ kref_get(&rvdev->refcount); + /* + * Assign an rproc-wide unique index for this rvdev + */ + rsc = (void *)rproc->table_ptr + rvdev->rsc_offset; + idr_start = 0; + idr_end = 0; + if (rsc->notifyid != FW_RSC_ADDR_ANY) { + if (!idr_find(&rproc->notifyids, rsc->notifyid)) { + idr_start = rsc->notifyid; + idr_end = idr_start + 1; + } + } + + ret = rproc_idr_alloc(rproc, rvdev, RPROC_IDR_VDEV, + idr_start, idr_end); + if (ret < 0) { + dev_err(dev, "rvdev idr_alloc failed: %d\n", ret); + return ret; + } + rsc->notifyid = ret; + ret = register_virtio_device(vdev); if (ret) { put_device(&rproc->dev); @@ -402,5 +425,11 @@ int rproc_add_virtio_dev(struct rproc_vdev *rvdev, int id) */ void rproc_remove_virtio_dev(struct rproc_vdev *rvdev) { + struct rproc *rproc = rvdev->rproc; + struct fw_rsc_vdev *rsc; + + rsc = (void *)rproc->table_ptr + rvdev->rsc_offset; + rproc_idr_remove(rproc, rsc->notifyid); + unregister_virtio_device(&rvdev->vdev); }