From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752111AbdGGH5W (ORCPT ); Fri, 7 Jul 2017 03:57:22 -0400 Received: from mx2.suse.de ([195.135.220.15]:58442 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750883AbdGGH5V (ORCPT ); Fri, 7 Jul 2017 03:57:21 -0400 Date: Fri, 7 Jul 2017 09:57:15 +0200 From: Johannes Thumshirn To: Douglas Gilbert Cc: "Martin K . Petersen" , Linux SCSI Mailinglist , Linux Kernel Mailinglist , Chris Clayton Subject: Re: [PATCH] scsi: sg: fix SG_DXFER_FROM_DEV transfers Message-ID: <20170707075715.GD3854@linux-x5ow.site> References: <20170705134934.1703-1-jthumshirn@suse.de> <54abb58b-3fe6-8e64-91aa-182fbef93467@interlog.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <54abb58b-3fe6-8e64-91aa-182fbef93467@interlog.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 06, 2017 at 02:47:22PM -0400, Douglas Gilbert wrote: > Can you check your patch with one of the utilities from sg3_utils > such as sg_inq which will use SG_DXFER_FROM_DEV with the newer > interface? Correct, this patch broke sg_inq. I'll send a corrected v2. > BTW I'm not sure why dxferp is set to NULL for SG_DXFER_FROM_DEV > transfers; perhaps some magic done by the block layer. Maybe a > comment in the code (e.g. on line 654) would help. This is due to: commit fad7f01e61bf737fe8a3740d803f000db57ecac6 Author: FUJITA Tomonori Date: Tue Sep 2 16:20:20 2008 +0900 sg: set dxferp to NULL for READ with the older SG interface With the older SG interface, we don't know a user-space address to trasfer data when executing a SCSI command. So we can't pass a user-space address to blk_rq_map_user. This patch fixes sg to pass a NULL user-space address to blk_rq_map_user so that it just sets up a request and bios with page frames propely without data transfer. Signed-off-by: FUJITA Tomonori Signed-off-by: Jens Axboe > > Also sg_is_valid_dxfer() is only called once and is more complex > than it looks; so perhaps it could be inlined back in > sg_common_write(). The compiler will inline it anyways (at least the one I checked with) and inlining it into sg_common_write() won't make the code more readable IMHO. But ultimately it's your driver so if you insist I'll do. -- Johannes Thumshirn Storage jthumshirn@suse.de +49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: Felix Imendörffer, Jane Smithard, Graham Norton HRB 21284 (AG Nürnberg) Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850