Hello community, here is the log from the commit of package vhba-kmp for openSUSE:Leap:15.2 checked in at 2020-03-23 17:27:01 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Leap:15.2/vhba-kmp (Old) and /work/SRC/openSUSE:Leap:15.2/.vhba-kmp.new.3160 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "vhba-kmp" Mon Mar 23 17:27:01 2020 rev:11 rq:787434 version:20200106 Changes: -------- --- /work/SRC/openSUSE:Leap:15.2/vhba-kmp/vhba-kmp.changes 2020-01-15 16:27:59.744738993 +0100 +++ /work/SRC/openSUSE:Leap:15.2/.vhba-kmp.new.3160/vhba-kmp.changes 2020-03-23 17:27:04.486180069 +0100 @@ -1,0 +2,14 @@ +Thu Mar 19 10:36:07 UTC 2020 - Aaron Stern <[email protected]> + +- Update to release 20200106 + * Added an ioctl to retrieve the global device number + +------------------------------------------------------------------- +Thu Oct 17 10:02:53 UTC 2019 - Jan Engelhardt <[email protected]> + +- Update to release 20190831 + * Don't try to unload module from running kernel. + * Add support for multiple SCSI channels. + * Add proper support for scatterlist chaining. + +------------------------------------------------------------------- Old: ---- vhba-module-20190410.tar.bz2 New: ---- vhba-module-20200106.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ vhba-kmp.spec ++++++ --- /var/tmp/diff_new_pack.WMVVrN/_old 2020-03-23 17:27:06.366181551 +0100 +++ /var/tmp/diff_new_pack.WMVVrN/_new 2020-03-23 17:27:06.366181551 +0100 @@ -1,7 +1,7 @@ # # spec file for package vhba-kmp # -# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2020 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,7 +17,7 @@ Name: vhba-kmp -Version: 20190410 +Version: 20200106 Release: 0 Summary: Virtual SCSI Host Bus Adapter License: GPL-2.0-or-later ++++++ vhba-module-20190410.tar.bz2 -> vhba-module-20200106.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vhba-module-20190410/Makefile new/vhba-module-20200106/Makefile --- old/vhba-module-20190410/Makefile 2019-04-11 13:30:43.000000000 +0200 +++ new/vhba-module-20200106/Makefile 2020-01-06 17:23:51.000000000 +0100 @@ -1,4 +1,4 @@ -VHBA_VERSION := 20190302 +VHBA_VERSION := 20200106 KERNELRELEASE ?= $(shell uname -r) KDIR ?= /lib/modules/$(KERNELRELEASE)/build diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vhba-module-20190410/README new/vhba-module-20200106/README --- old/vhba-module-20190410/README 2019-04-11 13:30:43.000000000 +0200 +++ new/vhba-module-20200106/README 2020-01-06 17:23:51.000000000 +0100 @@ -16,7 +16,7 @@ This is VHBA (Virtual SCSI Host Bus adapter), a Linux kernel module which acts as a low-level SCSI driver and which provides the SCSI layer with a virtual SCSI adapter which can have multiple virtual devices. It is part of -the userspace-cdemu suite, a free, GPL CD/DVD-ROM device emulator for linux. +the cdemu suite, a free, GPL CD/DVD-ROM device emulator for linux. It is written in C. Its typical use in the CDEmu software suite is to provide virtual devices @@ -28,7 +28,7 @@ 2. Requirements: ~~~~~~~~~~~~~~~~ - - Kernel development headers >= 2.6.20 + - Kernel development headers >= 3.0 3. Installation: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vhba-module-20190410/debian/changelog new/vhba-module-20200106/debian/changelog --- old/vhba-module-20190410/debian/changelog 2019-04-11 13:30:43.000000000 +0200 +++ new/vhba-module-20200106/debian/changelog 2020-01-06 17:23:51.000000000 +0100 @@ -1,3 +1,3 @@ -vhba-module (20190302-1) debian; urgency=low +vhba-module (20200106-1) debian; urgency=low * Initial Release. Closes: #705409 -- Henrik Stokseth <[email protected]> Sat, 05 Apr 2014 12:00:00 +0100 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vhba-module-20190410/debian/control new/vhba-module-20200106/debian/control --- old/vhba-module-20190410/debian/control 2019-04-11 13:30:43.000000000 +0200 +++ new/vhba-module-20200106/debian/control 2020-01-06 17:23:51.000000000 +0100 @@ -4,7 +4,7 @@ Homepage: http://cdemu.sourceforge.net/ Maintainer: Henrik Stokseth <[email protected]> Build-Depends: debhelper (>= 9), dkms -Standards-Version: 3.9.7 +Standards-Version: 4.3.0 Package: vhba-dkms @@ -12,5 +12,5 @@ Depends: build-essential, ${misc:Depends} Description: VHBA virtual host bus adapter module VHBA kernel module, a virtual SCSI host bus adapter used by CDEmu daemon from - userspace-cdemu suite. + the cdemu suite. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vhba-module-20190410/debian/source/options new/vhba-module-20200106/debian/source/options --- old/vhba-module-20190410/debian/source/options 2019-04-11 13:30:43.000000000 +0200 +++ new/vhba-module-20200106/debian/source/options 1970-01-01 01:00:00.000000000 +0100 @@ -1 +0,0 @@ -compression = "xz" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vhba-module-20190410/debian/vhba-dkms.postinst new/vhba-module-20200106/debian/vhba-dkms.postinst --- old/vhba-module-20190410/debian/vhba-dkms.postinst 2019-04-11 13:30:43.000000000 +0200 +++ new/vhba-module-20200106/debian/vhba-dkms.postinst 2020-01-06 17:23:51.000000000 +0100 @@ -19,10 +19,11 @@ configure) # try to load the module if test -d "/sys/module/vhba"; then - modprobe -r "vhba" || mywarning "Failed to unload running module." - fi + mywarning "Reboot required to load new vhba module." - modprobe "vhba" || mywarning "Unable to load module." + else + modprobe "vhba" || mywarning "Unable to load module." + fi # and make sure it's there after next reboot if test -f "/etc/modules-load.d/vhba.conf"; then diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vhba-module-20190410/debian/vhba-dkms.prerm new/vhba-module-20200106/debian/vhba-dkms.prerm --- old/vhba-module-20190410/debian/vhba-dkms.prerm 2019-04-11 13:30:43.000000000 +0200 +++ new/vhba-module-20200106/debian/vhba-dkms.prerm 1970-01-01 01:00:00.000000000 +0100 @@ -1,35 +0,0 @@ -#!/bin/sh -# prerm script for vhba-dkms -# - -#DEBHELPER# - -myerror () -{ - echo "ERROR: $1" >&2 - exit 1 -} - -mywarning () -{ - echo "WARNING: $1" >&2 -} - -case "$1" in - remove|upgrade|deconfigure) - # try to unload the module - if test -d "/sys/module/vhba"; then - modprobe -r "vhba" || mywarning "Failed to unload running module." - fi - ;; - - failed-upgrade) - ;; - - *) - myerror "prerm called with unknown argument '$1'." - ;; -esac - -exit 0 - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vhba-module-20190410/debian/watch new/vhba-module-20200106/debian/watch --- old/vhba-module-20190410/debian/watch 2019-04-11 13:30:43.000000000 +0200 +++ new/vhba-module-20200106/debian/watch 2020-01-06 17:23:51.000000000 +0100 @@ -1,4 +1,4 @@ version=3 -http://sf.net/cdemu/ vhba-module-(.+)\.tar\.bz2 +http://sf.net/cdemu/ @PACKAGE@@ANY_VERSION@@ARCHIVE_EXT@ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vhba-module-20190410/vhba.c new/vhba-module-20200106/vhba.c --- old/vhba-module-20190410/vhba.c 2019-04-11 13:30:43.000000000 +0200 +++ new/vhba-module-20200106/vhba.c 2020-01-06 17:23:51.000000000 +0100 @@ -33,6 +33,7 @@ #include <linux/miscdevice.h> #include <linux/poll.h> #include <linux/slab.h> +#include <linux/scatterlist.h> #ifdef CONFIG_COMPAT #include <linux/compat.h> #endif @@ -42,11 +43,6 @@ #include <scsi/scsi_cmnd.h> #include <scsi/scsi_device.h> -/* scatterlist.page_link and sg_page() were introduced in 2.6.24 */ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24) -#define USE_SG_PAGE -#include <linux/scatterlist.h> -#endif MODULE_AUTHOR("Chia-I Wu"); MODULE_VERSION(VHBA_VERSION); @@ -65,40 +61,19 @@ dev_dbg(&(scmd)->device->sdev_gendev, fmt, ##a) #endif -#ifndef scmd_warn -#define scmd_warn(scmd, fmt, a...) \ - dev_warn(&(scmd)->device->sdev_gendev, fmt, ##a) -#endif - #define VHBA_MAX_SECTORS_PER_IO 256 -#define VHBA_MAX_ID 32 +#define VHBA_MAX_BUS 16 +#define VHBA_MAX_ID 16 /* Usually 8 or 16 */ +#define VHBA_MAX_DEVICES (VHBA_MAX_BUS * (VHBA_MAX_ID-1)) #define VHBA_CAN_QUEUE 32 -#define VHBA_INVALID_ID VHBA_MAX_ID +#define VHBA_INVALID_BUS -1 +#define VHBA_INVALID_ID -1 #define VHBA_KBUF_SIZE PAGE_SIZE #define DATA_TO_DEVICE(dir) ((dir) == DMA_TO_DEVICE || (dir) == DMA_BIDIRECTIONAL) #define DATA_FROM_DEVICE(dir) ((dir) == DMA_FROM_DEVICE || (dir) == DMA_BIDIRECTIONAL) -/* SCSI macros were introduced in 2.6.23 */ -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 23) -#define scsi_sg_count(cmd) ((cmd)->use_sg) -#define scsi_sglist(cmd) ((cmd)->request_buffer) -#define scsi_bufflen(cmd) ((cmd)->request_bufflen) -#define scsi_set_resid(cmd, to_read) {(cmd)->resid = (to_read);} -#endif - -/* 1-argument form of k[un]map_atomic was introduced in 2.6.37-rc1; - 2-argument form was deprecated in 3.4-rc1 */ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37) -#define vhba_kmap_atomic kmap_atomic -#define vhba_kunmap_atomic kunmap_atomic -#else -#define vhba_kmap_atomic(page) kmap_atomic(page, KM_USER0) -#define vhba_kunmap_atomic(page) kunmap_atomic(page, KM_USER0) -#endif - - enum vhba_req_state { VHBA_REQ_FREE, VHBA_REQ_PENDING, @@ -115,7 +90,9 @@ }; struct vhba_device { - uint id; + int bus; /* aka. channel */ + int id; + int num; spinlock_t cmd_lock; struct list_head cmd_list; wait_queue_head_t cmd_wq; @@ -133,10 +110,10 @@ int cmd_next; struct vhba_command commands[VHBA_CAN_QUEUE]; spinlock_t dev_lock; - struct vhba_device *devices[VHBA_MAX_ID]; + struct vhba_device *devices[VHBA_MAX_DEVICES]; int num_devices; - DECLARE_BITMAP(chgmap, VHBA_MAX_ID); - int chgtype[VHBA_MAX_ID]; + DECLARE_BITMAP(chgmap, VHBA_MAX_DEVICES); + int chgtype[VHBA_MAX_DEVICES]; struct work_struct scan_devices; }; @@ -170,6 +147,7 @@ return NULL; } + vdev->bus = VHBA_INVALID_BUS; vdev->id = VHBA_INVALID_ID; spin_lock_init(&vdev->cmd_lock); INIT_LIST_HEAD(&vdev->cmd_list); @@ -184,6 +162,20 @@ return vdev; } +static void devnum_to_bus_and_id(int devnum, int *bus, int *id) +{ + int a = devnum / (VHBA_MAX_ID-1); + int b = devnum % (VHBA_MAX_ID-1); + + *bus = a; + *id = b + 1; +} + +static int bus_and_id_to_devnum(int bus, int id) +{ + return (bus * (VHBA_MAX_ID-1)) + id - 1; +} + static void vhba_device_put (struct vhba_device *vdev) { if (atomic_dec_and_test(&vdev->refcnt)) { @@ -256,29 +248,29 @@ return retval; } -static inline void vhba_scan_devices_add (struct vhba_host *vhost, int id) +static inline void vhba_scan_devices_add (struct vhba_host *vhost, int bus, int id) { struct scsi_device *sdev; - sdev = scsi_device_lookup(vhost->shost, 0, id, 0); + sdev = scsi_device_lookup(vhost->shost, bus, id, 0); if (!sdev) { - scsi_add_device(vhost->shost, 0, id, 0); + scsi_add_device(vhost->shost, bus, id, 0); } else { - dev_warn(&vhost->shost->shost_gendev, "tried to add an already-existing device 0:%d:0!\n", id); + dev_warn(&vhost->shost->shost_gendev, "tried to add an already-existing device %d:%d:0!\n", bus, id); scsi_device_put(sdev); } } -static inline void vhba_scan_devices_remove (struct vhba_host *vhost, int id) +static inline void vhba_scan_devices_remove (struct vhba_host *vhost, int bus, int id) { struct scsi_device *sdev; - sdev = scsi_device_lookup(vhost->shost, 0, id, 0); + sdev = scsi_device_lookup(vhost->shost, bus, id, 0); if (sdev) { scsi_remove_device(sdev); scsi_device_put(sdev); } else { - dev_warn(&vhost->shost->shost_gendev, "tried to remove non-existing device 0:%d:0!\n", id); + dev_warn(&vhost->shost->shost_gendev, "tried to remove non-existing device %d:%d:0!\n", bus, id); } } @@ -286,41 +278,44 @@ { struct vhba_host *vhost = container_of(work, struct vhba_host, scan_devices); unsigned long flags; - int id, change, exists; + int devnum, change, exists; + int bus, id; while (1) { spin_lock_irqsave(&vhost->dev_lock, flags); - id = find_first_bit(vhost->chgmap, vhost->shost->max_id); - if (id >= vhost->shost->max_id) { + devnum = find_first_bit(vhost->chgmap, VHBA_MAX_DEVICES); + if (devnum >= VHBA_MAX_DEVICES) { spin_unlock_irqrestore(&vhost->dev_lock, flags); break; } - change = vhost->chgtype[id]; - exists = vhost->devices[id] != NULL; + change = vhost->chgtype[devnum]; + exists = vhost->devices[devnum] != NULL; - vhost->chgtype[id] = 0; - clear_bit(id, vhost->chgmap); + vhost->chgtype[devnum] = 0; + clear_bit(devnum, vhost->chgmap); spin_unlock_irqrestore(&vhost->dev_lock, flags); + devnum_to_bus_and_id(devnum, &bus, &id); + if (change < 0) { - dev_dbg(&vhost->shost->shost_gendev, "trying to remove target 0:%d:0\n", id); - vhba_scan_devices_remove(vhost, id); + dev_dbg(&vhost->shost->shost_gendev, "trying to remove target %d:%d:0\n", bus, id); + vhba_scan_devices_remove(vhost, bus, id); } else if (change > 0) { - dev_dbg(&vhost->shost->shost_gendev, "trying to add target 0:%d:0\n", id); - vhba_scan_devices_add(vhost, id); + dev_dbg(&vhost->shost->shost_gendev, "trying to add target %d:%d:0\n", bus, id); + vhba_scan_devices_add(vhost, bus, id); } else { /* quick sequence of add/remove or remove/add; we determine which one it was by checking if device structure exists */ if (exists) { /* remove followed by add: remove and (re)add */ - dev_dbg(&vhost->shost->shost_gendev, "trying to (re)add target 0:%d:0\n", id); - vhba_scan_devices_remove(vhost, id); - vhba_scan_devices_add(vhost, id); + dev_dbg(&vhost->shost->shost_gendev, "trying to (re)add target %d:%d:0\n", bus, id); + vhba_scan_devices_remove(vhost, bus, id); + vhba_scan_devices_add(vhost, bus, id); } else { /* add followed by remove: no-op */ - dev_dbg(&vhost->shost->shost_gendev, "no-op for target 0:%d:0\n", id); + dev_dbg(&vhost->shost->shost_gendev, "no-op for target %d:%d:0\n", bus, id); } } } @@ -331,25 +326,30 @@ struct vhba_host *vhost; int i; unsigned long flags; + int bus, id; vhost = platform_get_drvdata(&vhba_platform_device); vhba_device_get(vdev); spin_lock_irqsave(&vhost->dev_lock, flags); - if (vhost->num_devices >= vhost->shost->max_id) { + if (vhost->num_devices >= VHBA_MAX_DEVICES) { spin_unlock_irqrestore(&vhost->dev_lock, flags); vhba_device_put(vdev); return -EBUSY; } - for (i = 0; i < vhost->shost->max_id; i++) { + for (i = 0; i < VHBA_MAX_DEVICES; i++) { + devnum_to_bus_and_id(i, &bus, &id); + if (vhost->devices[i] == NULL) { - vdev->id = i; + vdev->bus = bus; + vdev->id = id; + vdev->num = i; vhost->devices[i] = vdev; vhost->num_devices++; - set_bit(vdev->id, vhost->chgmap); - vhost->chgtype[vdev->id]++; + set_bit(i, vhost->chgmap); + vhost->chgtype[i]++; break; } } @@ -368,10 +368,11 @@ vhost = platform_get_drvdata(&vhba_platform_device); spin_lock_irqsave(&vhost->dev_lock, flags); - set_bit(vdev->id, vhost->chgmap); - vhost->chgtype[vdev->id]--; - vhost->devices[vdev->id] = NULL; + set_bit(vdev->num, vhost->chgmap); + vhost->chgtype[vdev->num]--; + vhost->devices[vdev->num] = NULL; vhost->num_devices--; + vdev->bus = VHBA_INVALID_BUS; vdev->id = VHBA_INVALID_ID; spin_unlock_irqrestore(&vhost->dev_lock, flags); @@ -382,7 +383,7 @@ return 0; } -static struct vhba_device *vhba_lookup_device (int id) +static struct vhba_device *vhba_lookup_device (int devnum) { struct vhba_host *vhost; struct vhba_device *vdev = NULL; @@ -390,9 +391,9 @@ vhost = platform_get_drvdata(&vhba_platform_device); - if (likely(id < vhost->shost->max_id)) { + if (likely(devnum < VHBA_MAX_DEVICES)) { spin_lock_irqsave(&vhost->dev_lock, flags); - vdev = vhost->devices[id]; + vdev = vhost->devices[devnum]; if (vdev) { vdev = vhba_device_get(vdev); } @@ -460,7 +461,7 @@ scmd_dbg(cmd, "queue %p\n", cmd); - vdev = vhba_lookup_device(cmd->device->id); + vdev = vhba_lookup_device(bus_and_id_to_devnum(cmd->device->channel, cmd->device->id)); if (!vdev) { scmd_dbg(cmd, "no such device\n"); @@ -489,9 +490,9 @@ struct vhba_device *vdev; int retval = SUCCESS; - scmd_warn(cmd, "abort %p\n", cmd); + scmd_dbg(cmd, "abort %p\n", cmd); - vdev = vhba_lookup_device(cmd->device->id); + vdev = vhba_lookup_device(bus_and_id_to_devnum(cmd->device->channel, cmd->device->id)); if (vdev) { retval = vhba_device_dequeue(vdev, cmd); vhba_device_put(vdev); @@ -523,7 +524,7 @@ struct vhba_request vreq; ssize_t ret; - scmd_dbg(cmd, "request %lu (%p), cdb 0x%x, bufflen %d, use_sg %d\n", + scmd_dbg(cmd, "request %lu (%p), cdb 0x%x, bufflen %d, sg count %d\n", cmd_serial_number, cmd, cmd->cmnd[0], scsi_bufflen(cmd), scsi_sg_count(cmd)); ret = sizeof(vreq); @@ -532,7 +533,7 @@ } if (ret > buf_len) { - scmd_warn(cmd, "buffer too small (%zd < %zd) for a request\n", buf_len, ret); + scmd_dbg(cmd, "buffer too small (%zd < %zd) for a request\n", buf_len, ret); return -EIO; } @@ -551,26 +552,23 @@ if (scsi_sg_count(cmd)) { unsigned char *kaddr, *uaddr; - struct scatterlist *sg = scsi_sglist(cmd); + struct scatterlist *sglist = scsi_sglist(cmd); + struct scatterlist *sg; int i; uaddr = (unsigned char *) buf; - for (i = 0; i < scsi_sg_count(cmd); i++) { - size_t len = sg[i].length; + for_each_sg(sglist, sg, scsi_sg_count(cmd), i) { + size_t len = sg->length; if (len > vdev->kbuf_size) { - scmd_warn(cmd, "segment size (%zu) exceeds kbuf size (%zu)!", len, vdev->kbuf_size); + scmd_dbg(cmd, "segment size (%zu) exceeds kbuf size (%zu)!", len, vdev->kbuf_size); len = vdev->kbuf_size; } -#ifdef USE_SG_PAGE - kaddr = vhba_kmap_atomic(sg_page(&sg[i])); -#else - kaddr = vhba_kmap_atomic(sg[i].page); -#endif - memcpy(vdev->kbuf, kaddr + sg[i].offset, len); - vhba_kunmap_atomic(kaddr); + kaddr = kmap_atomic(sg_page(sg)); + memcpy(vdev->kbuf, kaddr + sg->offset, len); + kunmap_atomic(kaddr); if (copy_to_user(uaddr, vdev->kbuf, len)) { return -EFAULT; @@ -591,14 +589,14 @@ { ssize_t ret = 0; - scmd_dbg(cmd, "response %lu (%p), status %x, data len %d, use_sg %d\n", + scmd_dbg(cmd, "response %lu (%p), status %x, data len %d, sg count %d\n", cmd_serial_number, cmd, res->status, res->data_len, scsi_sg_count(cmd)); if (res->status) { unsigned char sense_stack[SCSI_SENSE_BUFFERSIZE]; if (res->data_len > SCSI_SENSE_BUFFERSIZE) { - scmd_warn(cmd, "truncate sense (%d < %d)", SCSI_SENSE_BUFFERSIZE, res->data_len); + scmd_dbg(cmd, "truncate sense (%d < %d)", SCSI_SENSE_BUFFERSIZE, res->data_len); res->data_len = SCSI_SENSE_BUFFERSIZE; } @@ -616,7 +614,7 @@ size_t to_read; if (res->data_len > scsi_bufflen(cmd)) { - scmd_warn(cmd, "truncate data (%d < %d)\n", scsi_bufflen(cmd), res->data_len); + scmd_dbg(cmd, "truncate data (%d < %d)\n", scsi_bufflen(cmd), res->data_len); res->data_len = scsi_bufflen(cmd); } @@ -624,16 +622,17 @@ if (scsi_sg_count(cmd)) { unsigned char *kaddr, *uaddr; - struct scatterlist *sg = scsi_sglist(cmd); + struct scatterlist *sglist = scsi_sglist(cmd); + struct scatterlist *sg; int i; uaddr = (unsigned char *)buf; - for (i = 0; i < scsi_sg_count(cmd); i++) { - size_t len = (sg[i].length < to_read) ? sg[i].length : to_read; + for_each_sg(sglist, sg, scsi_sg_count(cmd), i) { + size_t len = (sg->length < to_read) ? sg->length : to_read; if (len > vdev->kbuf_size) { - scmd_warn(cmd, "segment size (%zu) exceeds kbuf size (%zu)!", len, vdev->kbuf_size); + scmd_dbg(cmd, "segment size (%zu) exceeds kbuf size (%zu)!", len, vdev->kbuf_size); len = vdev->kbuf_size; } @@ -642,13 +641,9 @@ } uaddr += len; -#ifdef USE_SG_PAGE - kaddr = vhba_kmap_atomic(sg_page(&sg[i])); -#else - kaddr = vhba_kmap_atomic(sg[i].page); -#endif - memcpy(kaddr + sg[i].offset, vdev->kbuf, len); - vhba_kunmap_atomic(kaddr); + kaddr = kmap_atomic(sg_page(sg)); + memcpy(kaddr + sg->offset, vdev->kbuf, len); + kunmap_atomic(kaddr); to_read -= len; if (to_read == 0) { @@ -835,7 +830,7 @@ switch (cmd) { case 0xBEEF001: { vhost = platform_get_drvdata(&vhba_platform_device); - sdev = scsi_device_lookup(vhost->shost, 0, vdev->id, 0); + sdev = scsi_device_lookup(vhost->shost, vdev->bus, vdev->id, 0); if (sdev) { int id[4] = { @@ -856,6 +851,13 @@ return -ENODEV; } } + case 0xBEEF002: { + int device_number = vdev->num; + if (copy_to_user((void *)arg, &device_number, sizeof(device_number))) { + return -EFAULT; + } + return 0; + } } return -ENOTTY; @@ -935,7 +937,7 @@ list_for_each_entry(vcmd, &vdev->cmd_list, entry) { WARN_ON(vcmd->status == VHBA_REQ_READING || vcmd->status == VHBA_REQ_WRITING); - scmd_warn(vcmd->cmd, "device released with command %lu (%p)\n", vcmd->serial_number, vcmd->cmd); + scmd_dbg(vcmd->cmd, "device released with command %lu (%p)\n", vcmd->serial_number, vcmd->cmd); vcmd->cmd->result = DID_NO_CONNECT << 16; vcmd->cmd->scsi_done(vcmd->cmd); @@ -982,6 +984,7 @@ return -ENOMEM; } + shost->max_channel = VHBA_MAX_BUS-1; shost->max_id = VHBA_MAX_ID; /* we don't support lun > 0 */ shost->max_lun = 1;
