From owner-svn-src-all@freebsd.org Wed Aug 2 14:27:29 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2FD1ADD1E3E; Wed, 2 Aug 2017 14:27:29 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0BBCE66C13; Wed, 2 Aug 2017 14:27:28 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v72ERSeT063146; Wed, 2 Aug 2017 14:27:28 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v72ERR18063142; Wed, 2 Aug 2017 14:27:27 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201708021427.v72ERR18063142@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Wed, 2 Aug 2017 14:27:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r321926 - in head/sys/compat/linuxkpi/common: include/linux src X-SVN-Group: head X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: in head/sys/compat/linuxkpi/common: include/linux src X-SVN-Commit-Revision: 321926 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Aug 2017 14:27:29 -0000 Author: hselasky Date: Wed Aug 2 14:27:27 2017 New Revision: 321926 URL: https://svnweb.freebsd.org/changeset/base/321926 Log: Fix LinuxKPI regression after r321920. The mda_unit and si_drv0 fields are not wide enough to hold the full 64-bit dev_t. Instead use the "dev" field in the "linux_cdev" structure to store and lookup this value. While at it remove superfluous use of parenthesis inside the MAJOR(), MINOR() and MKDEV() macros in the LinuxKPI. MFC after: 1 week Sponsored by: Mellanox Technologies Modified: head/sys/compat/linuxkpi/common/include/linux/cdev.h head/sys/compat/linuxkpi/common/include/linux/fs.h head/sys/compat/linuxkpi/common/include/linux/kdev_t.h head/sys/compat/linuxkpi/common/src/linux_compat.c Modified: head/sys/compat/linuxkpi/common/include/linux/cdev.h ============================================================================== --- head/sys/compat/linuxkpi/common/include/linux/cdev.h Wed Aug 2 14:12:47 2017 (r321925) +++ head/sys/compat/linuxkpi/common/include/linux/cdev.h Wed Aug 2 14:27:27 2017 (r321926) @@ -95,7 +95,6 @@ cdev_add(struct linux_cdev *cdev, dev_t dev, unsigned args.mda_gid = 0; args.mda_mode = 0700; args.mda_si_drv1 = cdev; - args.mda_unit = dev; error = make_dev_s(&args, &cdev->cdev, "%s", kobject_name(&cdev->kobj)); @@ -121,7 +120,6 @@ cdev_add_ext(struct linux_cdev *cdev, dev_t dev, uid_t args.mda_gid = gid; args.mda_mode = mode; args.mda_si_drv1 = cdev; - args.mda_unit = dev; error = make_dev_s(&args, &cdev->cdev, "%s/%d", kobject_name(&cdev->kobj), MINOR(dev)); Modified: head/sys/compat/linuxkpi/common/include/linux/fs.h ============================================================================== --- head/sys/compat/linuxkpi/common/include/linux/fs.h Wed Aug 2 14:12:47 2017 (r321925) +++ head/sys/compat/linuxkpi/common/include/linux/fs.h Wed Aug 2 14:27:27 2017 (r321926) @@ -229,12 +229,8 @@ nonseekable_open(struct inode *inode, struct file *fil return 0; } -static inline dev_t -iminor(struct inode *inode) -{ - - return (minor(dev2unit(inode->v_rdev))); -} +extern unsigned int linux_iminor(struct inode *); +#define iminor(...) linux_iminor(__VA_ARGS__) static inline struct linux_file * get_file(struct linux_file *f) Modified: head/sys/compat/linuxkpi/common/include/linux/kdev_t.h ============================================================================== --- head/sys/compat/linuxkpi/common/include/linux/kdev_t.h Wed Aug 2 14:12:47 2017 (r321925) +++ head/sys/compat/linuxkpi/common/include/linux/kdev_t.h Wed Aug 2 14:27:27 2017 (r321926) @@ -33,9 +33,9 @@ #include -#define MAJOR(dev) major((dev)) -#define MINOR(dev) minor((dev)) -#define MKDEV(ma, mi) makedev((ma), (mi)) +#define MAJOR(dev) major(dev) +#define MINOR(dev) minor(dev) +#define MKDEV(ma, mi) makedev(ma, mi) static inline uint16_t old_encode_dev(dev_t dev) Modified: head/sys/compat/linuxkpi/common/src/linux_compat.c ============================================================================== --- head/sys/compat/linuxkpi/common/src/linux_compat.c Wed Aug 2 14:12:47 2017 (r321925) +++ head/sys/compat/linuxkpi/common/src/linux_compat.c Wed Aug 2 14:27:27 2017 (r321926) @@ -1417,6 +1417,21 @@ linux_file_fill_kinfo(struct file *fp, struct kinfo_fi return (0); } +unsigned int +linux_iminor(struct inode *inode) +{ + struct linux_cdev *ldev; + + if (inode == NULL || inode->v_rdev == NULL || + inode->v_rdev->si_devsw != &linuxcdevsw) + return (-1U); + ldev = inode->v_rdev->si_drv1; + if (ldev == NULL) + return (-1U); + + return (minor(ldev->dev)); +} + struct fileops linuxfileops = { .fo_read = linux_file_read, .fo_write = invfo_rdwr, @@ -1975,13 +1990,13 @@ linux_in_atomic(void) struct linux_cdev * linux_find_cdev(const char *name, unsigned major, unsigned minor) { - int unit = MKDEV(major, minor); + dev_t dev = MKDEV(major, minor); struct cdev *cdev; dev_lock(); LIST_FOREACH(cdev, &linuxcdevsw.d_devs, si_list) { struct linux_cdev *ldev = cdev->si_drv1; - if (dev2unit(cdev) == unit && + if (ldev->dev == dev && strcmp(kobject_name(&ldev->kobj), name) == 0) { break; }