From patchwork Tue Feb 12 05:59:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengguang Xu X-Patchwork-Id: 10807377 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 7C4F413B4 for ; Tue, 12 Feb 2019 06:00:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6ACEA2AF10 for ; Tue, 12 Feb 2019 06:00:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5BAEC2AF01; Tue, 12 Feb 2019 06:00:40 +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=-7.9 required=2.0 tests=BAYES_00,FREEMAIL_FROM, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 E61F92AF01 for ; Tue, 12 Feb 2019 06:00:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726219AbfBLGAb (ORCPT ); Tue, 12 Feb 2019 01:00:31 -0500 Received: from mout.gmx.net ([212.227.15.19]:43703 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725916AbfBLGAb (ORCPT ); Tue, 12 Feb 2019 01:00:31 -0500 Received: from localhost.localdomain ([218.18.229.179]) by mail.gmx.com (mrgmx002 [212.227.17.184]) with ESMTPSA (Nemesis) id 0LwqwS-1h8tWW3chE-016QK4; Tue, 12 Feb 2019 07:00:21 +0100 From: Chengguang Xu To: alex.williamson@redhat.com, kwankhede@nvidia.com Cc: kvm@vger.kernel.org, Chengguang Xu Subject: [PATCH 1/4] vfio: expand minor range when registering chrdev region Date: Tue, 12 Feb 2019 13:59:29 +0800 Message-Id: <20190212055932.8825-1-cgxu519@gmx.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Provags-ID: V03:K1:9YJXx5ELA7pO2NOivTVp3ZGViAgFiD5TExI5vx1w2d7XfCFq0ff YL+jb4KJcSYs5DufeCZezmnI+OZ6pLxsPxmVboIsRt6/vnJ5VHQthcAwaD5bgkZZb2jsrvE 1wKPINa2jjEIPtz/0er7JOOb87cEbNcTbDoivrAIZa2/H1Ng6aZcKF3Md0xnBHbaskLo8pi MivQInIH++yLtjtZxpQgA== X-UI-Out-Filterresults: notjunk:1;V03:K0:iWYqjvhCJUE=:FKPTt0y0VCAPchprQjJDtB LUP6JZ9D2Ex2JTZWKSoHzfGMT5YvsrjD8DJffC6MTLYWRWyn7zeLpmatOWokqSB8r0QyedJlL /mrpLyyDw0l7lVSkTvIk4bcXcta2xFH1vv2YoAQIuWKujfMciP74UI79km5MobnK8IMBhb8CI lWYFrj/mDJpr+qoltI//6VGw2SiRUGRIZxbE2GJO0AoL/h8mofDNpR66683scuH/yW4arANhj X8oClnLHM35Gbqe51hQVr49wLjby7zJLPKY/ot3AJEQYGQlELJaZJ2Sa6G0fs3W9auLJZ+BoE pzrhWGJKqZ6WQk8DXrYixps8cRUpkpyMPidgzmjQqIxENPpwUUegJWDdbw44J/9Uqo7bLSjKQ DOjGv0aNRXCWjq/wMBN/VQFYTHqTk6nrmt84Ch3eGWhlgFYh+YvkYfMj185lQyA5/0AzfDXwm QQZ3FLWY2AYKzoq4c97pk+808oFXiaPm14267yEboFXejMh8IEDuD4WwX6IpIW5brfsixJsm+ N5NbEJqKh7rwQsIPSe8w075RSN0YC7YnjSNlTb9QDPFWBqOU9zVw9IGuMeSb/S8NnX7+RHGlJ nn2YzRrKZqvbKXMBrEQ/5WTQ64uZwswSYip/wqy8o6VexZFBdwuBP9qa11lLu9bS4EnRrcRR8 /CzDqgZsHRzZsUZ3wPEydEkjtKeU9ORPPgoi4mCidR4ahvzJbWXj4YPgJHoDRwlQpBZTVcLSL hkcetAukIeltMjQk5blnJOpXJ4GGYKkcMxS2JWQwl+vanY5e+YcIExpN8GmvGnvk/wVxN7CmE poHX9CWHNFLd1yk/sFVxg7Rb+aFIU0Mno92HwJ7GwowRURkcLK+50tRQcKX9INbBMkXzyVwC+ LvOy+X+BDeVHR7/11+R3EnJqUkWH6zpOhP6Nlm7neZs/aRJLIuwGb/DM3H/oKS Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Actually, total amount of available minor number for a single major is MINORMARK + 1. So expand minor range when registering chrdev region. Signed-off-by: Chengguang Xu --- drivers/vfio/vfio.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c index 64833879f75d..a3030cdf3c18 100644 --- a/drivers/vfio/vfio.c +++ b/drivers/vfio/vfio.c @@ -2219,12 +2219,12 @@ static int __init vfio_init(void) vfio.class->devnode = vfio_devnode; - ret = alloc_chrdev_region(&vfio.group_devt, 0, MINORMASK, "vfio"); + ret = alloc_chrdev_region(&vfio.group_devt, 0, MINORMASK + 1, "vfio"); if (ret) goto err_alloc_chrdev; cdev_init(&vfio.group_cdev, &vfio_group_fops); - ret = cdev_add(&vfio.group_cdev, vfio.group_devt, MINORMASK); + ret = cdev_add(&vfio.group_cdev, vfio.group_devt, MINORMASK + 1); if (ret) goto err_cdev_add; @@ -2236,7 +2236,7 @@ static int __init vfio_init(void) return 0; err_cdev_add: - unregister_chrdev_region(vfio.group_devt, MINORMASK); + unregister_chrdev_region(vfio.group_devt, MINORMASK + 1); err_alloc_chrdev: class_destroy(vfio.class); vfio.class = NULL; @@ -2254,7 +2254,7 @@ static void __exit vfio_cleanup(void) #endif idr_destroy(&vfio.group_idr); cdev_del(&vfio.group_cdev); - unregister_chrdev_region(vfio.group_devt, MINORMASK); + unregister_chrdev_region(vfio.group_devt, MINORMASK + 1); class_destroy(vfio.class); vfio.class = NULL; misc_deregister(&vfio_dev); From patchwork Tue Feb 12 05:59:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengguang Xu X-Patchwork-Id: 10807379 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 AF16617E0 for ; Tue, 12 Feb 2019 06:00:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9E7B12AF01 for ; Tue, 12 Feb 2019 06:00:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9276F2AF10; Tue, 12 Feb 2019 06:00: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=-7.9 required=2.0 tests=BAYES_00,FREEMAIL_FROM, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 28A882AF01 for ; Tue, 12 Feb 2019 06:00:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726269AbfBLGAr (ORCPT ); Tue, 12 Feb 2019 01:00:47 -0500 Received: from mout.gmx.net ([212.227.15.15]:46809 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725550AbfBLGAr (ORCPT ); Tue, 12 Feb 2019 01:00:47 -0500 Received: from localhost.localdomain ([218.18.229.179]) by mail.gmx.com (mrgmx002 [212.227.17.184]) with ESMTPSA (Nemesis) id 0Ma1pn-1geo9K3HCx-00LpQZ; Tue, 12 Feb 2019 07:00:38 +0100 From: Chengguang Xu To: alex.williamson@redhat.com, kwankhede@nvidia.com Cc: kvm@vger.kernel.org, Chengguang Xu Subject: [PATCH 2/4] samples/vfio-mdev/mbochs: expand minor range when registering chrdev region Date: Tue, 12 Feb 2019 13:59:30 +0800 Message-Id: <20190212055932.8825-2-cgxu519@gmx.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190212055932.8825-1-cgxu519@gmx.com> References: <20190212055932.8825-1-cgxu519@gmx.com> MIME-Version: 1.0 X-Provags-ID: V03:K1:dwsh+CqzbspXqQsAwpObR/AKs+zmjVSt31cY2UNZBKGEdxDniqt 92MVwnXa9ykxXQqKCS3HZc4q6VnLFJ/gYJSRCikhdITOKNzxzv6dljpwcTJ4uYCbzIw6CnK y8k0kVukoDELaSELXdrfo/C0z7qv5mb26neQjr09L9FO1PPcglzLNbJwhuLc2PQDwFzEiIC nb2Qi5v04v7jAlPF4/h5g== X-UI-Out-Filterresults: notjunk:1;V03:K0:5MyLZwufjd8=:M35PP/ZfrDWS9qYksYarmd fOoo8s5eswRch/9eCv9pu4JZo0EXKmltQYpEm9ichq/GI6uVUwTAsUBqzIRxjrkZMSh4W407V jAy/WgKf5axobyIJUSNp4sVZnT3/3x81jL5YZMJpz36ocswGV1PtIJhAdYM7ZPMm8eTHjHmqz wUIllFXBKZ7umwrJKM+7YUvkyCQ0Bu/SxXWAJLg+ibcZJDmj+oGFKOjKAMaNUAIwVKmVkfu5S UuwoLay3wnSEKUGCuy1Xg0H9N16VC1LLn0ISJ7WTHaifTbUnAVZaKmFMeTVaok08rWVs03cYv wH0uHg8o+T4fZPy1UUtPAvkr1DkF4yUUhHUciPw7/A4S0WxLT24jpM3cFHpKcfLvN9AvvSK4+ W25ELpi0w6xDY7REf7BbJy05jVRreQGMH5swTPTh0Ur+kiSPGkFtcJLA420e1V/WRCyrwG2K+ wiLmAm9IyiVbpHpt6nl1XY+CSnTkV87ieZJfeDmJpw1Z30tScbDbFVhcg2fHWvUn0PJD1vZIs svCvQoTxE1DDNego3l0BXmGWaU1nfKQNkjglKF2u+y/RhE//lXz4kKFmDi3OfbP8/GIMocYTu IkkMUGaogE1mxSY0CIG8qlJkc4gQ76IAw50q8wavExDAqChyNZGuapcde8WokoWKKCAWMZxSx oj2rSSN4BGhWLuAzY6ZyfCuHvSiji235e9UD2MlK4hFRZewfoxJWYOx0vYxa4RuToFE4ady2h 7V8Ml3+DjZyD9Zv5MpgqZBey7UqX2t929ruly2KDIpUC3URsppvHWd/9Ug4XhHlmwZ8RcVDxq eHZ+3Z7UrH5rE7/tCtHX8VoZOOfH4cYeLYDLn+mqSdRmzb5j4M3JloPumGcHtz3HXOkcokwZ+ O9vLyhsHJHvlXMUCcLdmWQC6rFrvON12SKfVQ5+2ibCU/AZdtWrKvFhLqUuBya Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Actually, total amount of available minor number for a single major is MINORMARK + 1. So expand minor range when registering chrdev region. Signed-off-by: Chengguang Xu --- samples/vfio-mdev/mbochs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/samples/vfio-mdev/mbochs.c b/samples/vfio-mdev/mbochs.c index ca7960adf5a3..b038aa9f5a70 100644 --- a/samples/vfio-mdev/mbochs.c +++ b/samples/vfio-mdev/mbochs.c @@ -1448,13 +1448,13 @@ static int __init mbochs_dev_init(void) { int ret = 0; - ret = alloc_chrdev_region(&mbochs_devt, 0, MINORMASK, MBOCHS_NAME); + ret = alloc_chrdev_region(&mbochs_devt, 0, MINORMASK + 1, MBOCHS_NAME); if (ret < 0) { pr_err("Error: failed to register mbochs_dev, err: %d\n", ret); return ret; } cdev_init(&mbochs_cdev, &vd_fops); - cdev_add(&mbochs_cdev, mbochs_devt, MINORMASK); + cdev_add(&mbochs_cdev, mbochs_devt, MINORMASK + 1); pr_info("%s: major %d\n", __func__, MAJOR(mbochs_devt)); mbochs_class = class_create(THIS_MODULE, MBOCHS_CLASS_NAME); @@ -1483,7 +1483,7 @@ static int __init mbochs_dev_init(void) class_destroy(mbochs_class); failed1: cdev_del(&mbochs_cdev); - unregister_chrdev_region(mbochs_devt, MINORMASK); + unregister_chrdev_region(mbochs_devt, MINORMASK + 1); return ret; } @@ -1494,7 +1494,7 @@ static void __exit mbochs_dev_exit(void) device_unregister(&mbochs_dev); cdev_del(&mbochs_cdev); - unregister_chrdev_region(mbochs_devt, MINORMASK); + unregister_chrdev_region(mbochs_devt, MINORMASK + 1); class_destroy(mbochs_class); mbochs_class = NULL; } From patchwork Tue Feb 12 05:59:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengguang Xu X-Patchwork-Id: 10807381 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 8A30913B4 for ; Tue, 12 Feb 2019 06:00:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7A1A72AF01 for ; Tue, 12 Feb 2019 06:00:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6DED72AF10; Tue, 12 Feb 2019 06:00:56 +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=-7.9 required=2.0 tests=BAYES_00,FREEMAIL_FROM, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 1E19F2AF01 for ; Tue, 12 Feb 2019 06:00:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727018AbfBLGAy (ORCPT ); Tue, 12 Feb 2019 01:00:54 -0500 Received: from mout.gmx.net ([212.227.15.15]:45641 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726985AbfBLGAy (ORCPT ); Tue, 12 Feb 2019 01:00:54 -0500 Received: from localhost.localdomain ([218.18.229.179]) by mail.gmx.com (mrgmx002 [212.227.17.184]) with ESMTPSA (Nemesis) id 0MEFIm-1grECz254y-00FQCC; Tue, 12 Feb 2019 07:00:46 +0100 From: Chengguang Xu To: alex.williamson@redhat.com, kwankhede@nvidia.com Cc: kvm@vger.kernel.org, Chengguang Xu Subject: [PATCH 3/4] samples/vfio-mdev/mdpy: expand minor range when registering chrdev region Date: Tue, 12 Feb 2019 13:59:31 +0800 Message-Id: <20190212055932.8825-3-cgxu519@gmx.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190212055932.8825-1-cgxu519@gmx.com> References: <20190212055932.8825-1-cgxu519@gmx.com> MIME-Version: 1.0 X-Provags-ID: V03:K1:bNJV7R7f12bEhmUf20yA9jI9aDx4yzfHLg5oarNLN7D480YO4y7 4Bha1w3pgwf9nAADz+J2Fh3qtTZQopYn/jzxdPf8rZk040yfdfvFt2R+03NCZYvdTc8Ai4Y NfnElkLYH1y9FzXXzYOIl9dFdSNUx/kVGp6Xf10Del5B8Xl4OEasvWe1haM7Al19mLQBnds 1ebIwm1G3Xc7Z5HYqm71Q== X-UI-Out-Filterresults: notjunk:1;V03:K0:6fcl5Zn9CXE=:Wbq7N9ZfHbCLqoycrbwt0s Wjc0XxVV3hp/edK6SE5owSe8N7/VRdDi3dTzbYe6xkOn2aQc+y1WaBzmtECOTGYGnolNVBFeC XrGETGm2S4oftIyqAeWHOGzj/Sbf2GsdbZtlalSPaoq2tqCogmJryAWZB1YodJLapD6EfXLaV mhqWQlPVygNbUZcJ77wa+gdgurIxcadc+uB/RUK3GseAoSXu1LFTDFrOogDKjELlHjZ5dM8yq 3wH7KrBvT0ppjPaT7PqU+ii1L7Pmvq4dCGU8ybtHD5tHNxLsvrWLr+ewjLpgodF6yLFScdl21 mZ8krW7nbB2ZZeya7IT8uovrmW0AlynUWit6ZIFUvZv1pRqM2fTa0XYgflKtsm2HvuUl1eGqR KKQxkPJsjzDRXbnsRvOlizmhd25z73Q34sgSdVepfNC4cW2LTJ01Crf5jT/+ZlaaYmKSmUd1g ia+ITZ3+Bs5Ctqm3aLb/aMyDpb2DSPimTSPft90SCzEINLlIvc5hVKSk8iMhwrG8UQUgSP5iM MII1THftT2wzbr4hRq1tleJuq8UEv++p5ZzxJGkHevsbSNhgjKLJVfnGuFLH+IO9BmuHIgOFf E/aMtPS3USc+BVHAKYO2RHx4KjsQfe4U9XqRSYlYwrjfEMD9iMYsgn9JCqQdHW1rx1JvH1Syh mMnDVfnxoG1rUujRVn5ikt1lwsjkRrpu45x2IvilGHwuwkq1/QyGOdflTIfgr93bqFj3xJfyq RZi7kDEoVKbxiV4J6oWMBYjFUmmMSiL8zp8LFt4B7lc4veNpxupdkuvCwjwF9+iRMexc9mKIu /CXjvNWQ9KrFlUkZOapGL/GA+IEtA0Pw11sRgZXCl5K31V0KGWL9p3i//t5KVkUFRoAp/VNzE jcSYVsbq5dX2yUSGACFu09up8WXHhQjtLUstpIf3UkEbYmQ71Okxphimc0A6Wx Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Actually, total amount of available minor number for a single major is MINORMARK + 1. So expand minor range when registering chrdev region. Signed-off-by: Chengguang Xu --- samples/vfio-mdev/mdpy.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/samples/vfio-mdev/mdpy.c b/samples/vfio-mdev/mdpy.c index 96e7969c473a..cc86bf6566e4 100644 --- a/samples/vfio-mdev/mdpy.c +++ b/samples/vfio-mdev/mdpy.c @@ -752,13 +752,13 @@ static int __init mdpy_dev_init(void) { int ret = 0; - ret = alloc_chrdev_region(&mdpy_devt, 0, MINORMASK, MDPY_NAME); + ret = alloc_chrdev_region(&mdpy_devt, 0, MINORMASK + 1, MDPY_NAME); if (ret < 0) { pr_err("Error: failed to register mdpy_dev, err: %d\n", ret); return ret; } cdev_init(&mdpy_cdev, &vd_fops); - cdev_add(&mdpy_cdev, mdpy_devt, MINORMASK); + cdev_add(&mdpy_cdev, mdpy_devt, MINORMASK + 1); pr_info("%s: major %d\n", __func__, MAJOR(mdpy_devt)); mdpy_class = class_create(THIS_MODULE, MDPY_CLASS_NAME); @@ -787,7 +787,7 @@ static int __init mdpy_dev_init(void) class_destroy(mdpy_class); failed1: cdev_del(&mdpy_cdev); - unregister_chrdev_region(mdpy_devt, MINORMASK); + unregister_chrdev_region(mdpy_devt, MINORMASK + 1); return ret; } @@ -798,7 +798,7 @@ static void __exit mdpy_dev_exit(void) device_unregister(&mdpy_dev); cdev_del(&mdpy_cdev); - unregister_chrdev_region(mdpy_devt, MINORMASK); + unregister_chrdev_region(mdpy_devt, MINORMASK + 1); class_destroy(mdpy_class); mdpy_class = NULL; } From patchwork Tue Feb 12 05:59:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengguang Xu X-Patchwork-Id: 10807383 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 85B1E13B4 for ; Tue, 12 Feb 2019 06:00:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 74B782AF01 for ; Tue, 12 Feb 2019 06:00:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 692E82AF10; Tue, 12 Feb 2019 06:00:58 +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=-7.9 required=2.0 tests=BAYES_00,FREEMAIL_FROM, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 1791D2AF01 for ; Tue, 12 Feb 2019 06:00:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727150AbfBLGA4 (ORCPT ); Tue, 12 Feb 2019 01:00:56 -0500 Received: from mout.gmx.net ([212.227.15.19]:54773 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727045AbfBLGA4 (ORCPT ); Tue, 12 Feb 2019 01:00:56 -0500 Received: from localhost.localdomain ([218.18.229.179]) by mail.gmx.com (mrgmx002 [212.227.17.184]) with ESMTPSA (Nemesis) id 0LuxG5-1h2XrN313x-0105bZ; Tue, 12 Feb 2019 07:00:49 +0100 From: Chengguang Xu To: alex.williamson@redhat.com, kwankhede@nvidia.com Cc: kvm@vger.kernel.org, Chengguang Xu Subject: [PATCH 4/4] samples/vfio-mdev/mtty: expand minor range when registering chrdev region Date: Tue, 12 Feb 2019 13:59:32 +0800 Message-Id: <20190212055932.8825-4-cgxu519@gmx.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190212055932.8825-1-cgxu519@gmx.com> References: <20190212055932.8825-1-cgxu519@gmx.com> MIME-Version: 1.0 X-Provags-ID: V03:K1:VBfOd3Lm60yGOT0PoFcjHdhuH82y7qxxdNxzl3hYlugkwCUkDmk eZQ0haajQGnhqRJvJNxxRSfjqCXN/zoZ1g4zvVe9BqSqE3fPKosB766rr4BpF43CvRC9QOW zdSYg/lai9GS0NeNHm0yVXh1U5ElVNuBjk45N/x3hy4LfinneCNZUCSwS+se9Eh7tCEnMB1 NmetQaM4vnkimcsVK5uYg== X-UI-Out-Filterresults: notjunk:1;V03:K0:/LZPKw/zugo=:AnJhRJ4WVgkljEvHwxoi3C LCYWEcThJX5TKJobul2dR6GZb2ffyMxdIXL9lgSjeUhjo1uW/FN2zlXCPyDOQCNb4Eu7Xrj5E 7h/Zs7r4oWLz8x8ULj9slCCRMfwFG0gDydLfoG8BmkX6o7NsE51e7bQHeIpZMAbUZZmNQgaXO ngyrDiyT0Wb3vjVhICGavt7wNlxkpikBbC5443LGVaV27r3mUKtGb2HVNpusVqlpGIs6woZtV GdRDX4GSJ1prmPrg29WZoQWUTQbKBmeA9Qgp0l6cg+bTYzUwia081ffzkFzIup4RJxHbI5E4e HjF5M6ZYU3JP5UFRcgcX4FKMD0snNakPCNcIcXThXLzX5R7D9rp2P0odPG3TC6AyUaslbkfMe de3gUJwqwyNhWGJKsQ/do2A38OB1Wcy5LOCVA3RPV/rv6yDiXYIFsbFWvBMNRpQfICnxIWmch 5gk/i8G9fGsaTUktiqotdwZokJNv8Z6tuseNTeGCEkuYlHMkFnFq54reC6wMQZKUl/MRLKPpR zz0CJpPuvfxeBBx3eo7ZnPdz/0mS85PPmAKTcZ2evcgl4Qbq7FhIhIW8mnepMRSfepaekeiMl IY/0bkTX2BaeckSpj4VOP4u0Lkw46U2+24ZIT5aDtmTNWkp6X5bItQ4VjdwjqAq73WvP3H570 EkNR6lF70S0Kchsb3oGbXHEgmdxcarS7BaUEWdGUl6Vt5nTn0Px8yUvxeANG2qqE7t3jMJ92Z iswPEtRqU4I780X8hTRGeLYotRzPdr/AB7RLEceQpxA9ejZsGixN+vvCoOSnrJmpJ5Bwy0pCC 6gZb4G5UnSYJTfhiRZh38VXAOAufzGs5WorwL0Mor2X/mxPlnV34V+CJJsuVJKKYFxPSJ6ldB QcFt+bAcv4xRqr/GiABCpF3AEsFew5i4T6Cj3JJd6NoaNr4PhNQQPTUbRCr2KI Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Actually, total amount of available minor number for a single major is MINORMARK + 1. So expand minor range when registering chrdev region. Signed-off-by: Chengguang Xu --- samples/vfio-mdev/mtty.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/samples/vfio-mdev/mtty.c b/samples/vfio-mdev/mtty.c index f6732aa16bb1..b9203a4fae12 100644 --- a/samples/vfio-mdev/mtty.c +++ b/samples/vfio-mdev/mtty.c @@ -1442,7 +1442,8 @@ static int __init mtty_dev_init(void) idr_init(&mtty_dev.vd_idr); - ret = alloc_chrdev_region(&mtty_dev.vd_devt, 0, MINORMASK, MTTY_NAME); + ret = alloc_chrdev_region(&mtty_dev.vd_devt, 0, MINORMASK + 1, + MTTY_NAME); if (ret < 0) { pr_err("Error: failed to register mtty_dev, err:%d\n", ret); @@ -1450,7 +1451,7 @@ static int __init mtty_dev_init(void) } cdev_init(&mtty_dev.vd_cdev, &vd_fops); - cdev_add(&mtty_dev.vd_cdev, mtty_dev.vd_devt, MINORMASK); + cdev_add(&mtty_dev.vd_cdev, mtty_dev.vd_devt, MINORMASK + 1); pr_info("major_number:%d\n", MAJOR(mtty_dev.vd_devt)); @@ -1487,7 +1488,7 @@ static int __init mtty_dev_init(void) failed1: cdev_del(&mtty_dev.vd_cdev); - unregister_chrdev_region(mtty_dev.vd_devt, MINORMASK); + unregister_chrdev_region(mtty_dev.vd_devt, MINORMASK + 1); all_done: return ret; @@ -1501,7 +1502,7 @@ static void __exit mtty_dev_exit(void) device_unregister(&mtty_dev.dev); idr_destroy(&mtty_dev.vd_idr); cdev_del(&mtty_dev.vd_cdev); - unregister_chrdev_region(mtty_dev.vd_devt, MINORMASK); + unregister_chrdev_region(mtty_dev.vd_devt, MINORMASK + 1); class_destroy(mtty_dev.vd_class); mtty_dev.vd_class = NULL; pr_info("mtty_dev: Unloaded!\n");