Received: by 10.192.165.156 with SMTP id m28csp621012imm; Tue, 17 Apr 2018 16:39:22 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+mIN8+zR0W7sBBbyVH5b1ZQEyYSTYCKCur+W6V3ocThOaE6eLcScWy/NBOUBhzGGVYl28s X-Received: by 10.167.129.202 with SMTP id c10mr828504pfn.245.1524008362094; Tue, 17 Apr 2018 16:39:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524008362; cv=none; d=google.com; s=arc-20160816; b=e7zu79jcTdYOETpUKmyS0MZ6BZXjNUYgf2jS8cTqZ0OJ/VRAzYwgPDLuAIL5+aXZCb TpZNu+erw3XVMTirURfWG3ishT/LLuiXS95De9h8fA+9jE6F1k9V/8ofSsPSpZMH4vI2 ZC5X0PUONrwqCpd/KE1u9zj1dSbAScC/v8uK1btZ+hgtflYQ6veSTBz7PIS70Ge630DK /D0Bgh9GFpMC6Srb5akERyRf/uhGACYa+WCmCu/Vh3O4i8XL33JvkQ5Xz4YjWaP44VCj QQdKb2TEY5CN8bg9F97J8Da4vZRNG+qfw7cKJ/t6BukA/xiogEk04hpUkeoCLaLVsxma j3xA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=T0gSAkRPtmUBPKlANFQ8bECkmHcOEAcnR5XExwttc5c=; b=HQFW+FrLlnV8XfSGurhidAzDjkdqtJkqzLqMZ2q9chsemP5CDW0csmO7TgzJpNe9ns 9O63qwKlQohhd+3nRIdgL3Dp+JGk/sZPlcgX5DvRHrUaO9eGJ6jiuYurm+cn8V64QNq6 Wmp0u3SblrHaiIqm2Hyf8ShxvUrWsQUk3uAYkrKZ2KY49Zw2CSGSW3BJWCDvi9CLKfzc tOn4RTf94lFHSbftow8dJDAn6huDRW5h5Cato5MtRWm5zYD0T3ZGjos9sss5Cg7AB52c qq9TmozfHryvDYxhkTWgdv9lpIG+X6B17DissNn2OjQ8Oy+kQDDe4SiL+Aba/TN0yoO+ xKVw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u7si5201162pgc.141.2018.04.17.16.39.08; Tue, 17 Apr 2018 16:39:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753307AbeDQXgj (ORCPT + 99 others); Tue, 17 Apr 2018 19:36:39 -0400 Received: from victor.provo.novell.com ([137.65.250.26]:33822 "EHLO prv3-mh.provo.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751882AbeDQXgg (ORCPT ); Tue, 17 Apr 2018 19:36:36 -0400 Received: from apollon.suse.de.de (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by prv3-mh.provo.novell.com with ESMTP (TLS encrypted); Tue, 17 Apr 2018 17:36:18 -0600 From: Martin Wilck To: "Martin K. Petersen" Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Hannes Reinecke , James Bottomley , Xose Vazquez Perez , Bart Van Assche , Johannes Thumshirn , Bart Van Assche , Hannes Reinecke , Linus Torvalds , Christoph Hellwig , Janusz Dziemidowicz Subject: [PATCH v3 4/6] scsi: devinfo: warn on undefined blist flags Date: Wed, 18 Apr 2018 01:35:09 +0200 Message-Id: <20180417233511.6573-5-mwilck@suse.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180417233511.6573-1-mwilck@suse.com> References: <20180417233511.6573-1-mwilck@suse.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Warn if a device (or the user) sets blist flags which are unknown or have been removed. This should enable us to reuse freed blist bits in later releases. Signed-off-by: Martin Wilck --- drivers/scsi/Makefile | 2 +- drivers/scsi/scsi_devinfo.c | 6 ++++++ include/scsi/scsi_devinfo.h | 21 +++++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile index d5135ef..fd901a5 100644 --- a/drivers/scsi/Makefile +++ b/drivers/scsi/Makefile @@ -190,7 +190,7 @@ $(obj)/53c700.o $(MODVERDIR)/$(obj)/53c700.ver: $(obj)/53c700_d.h $(obj)/scsi_sysfs.o: $(obj)/scsi_devinfo_tbl.c quiet_cmd_bflags = GEN $@ - cmd_bflags = sed -n 's/.*BLIST_\([A-Z0-9_]*\) *.*/BLIST_FLAG_NAME(\1),/p' $< > $@ + cmd_bflags = sed -n 's/.*define *BLIST_\([A-Z0-9_]*\) *.*/BLIST_FLAG_NAME(\1),/p' $< > $@ $(obj)/scsi_devinfo_tbl.c: include/scsi/scsi_devinfo.h $(call if_changed,bflags) diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c index fc6b755..c05843a 100644 --- a/drivers/scsi/scsi_devinfo.c +++ b/drivers/scsi/scsi_devinfo.c @@ -371,6 +371,12 @@ int scsi_dev_info_list_add_keyed(int compatible, char *vendor, char *model, } flags = (__force blist_flags_t)val; } + if (flags & __BLIST_UNUSED_MASK) { + pr_err("scsi_devinfo (%s:%s): unsupported flags 0x%llx", + vendor, model, flags & __BLIST_UNUSED_MASK); + kfree(devinfo); + return -EINVAL; + } devinfo->flags = flags; devinfo->compatible = compatible; diff --git a/include/scsi/scsi_devinfo.h b/include/scsi/scsi_devinfo.h index e206d29..3434e14 100644 --- a/include/scsi/scsi_devinfo.h +++ b/include/scsi/scsi_devinfo.h @@ -28,8 +28,13 @@ #define BLIST_LARGELUN ((__force blist_flags_t)(1ULL << 9)) /* override additional length field */ #define BLIST_INQUIRY_36 ((__force blist_flags_t)(1ULL << 10)) +#define __BLIST_UNUSED_11 ((__force blist_flags_t)(1ULL << 11)) /* do not do automatic start on add */ #define BLIST_NOSTARTONADD ((__force blist_flags_t)(1ULL << 12)) +#define __BLIST_UNUSED_13 ((__force blist_flags_t)(1ULL << 13)) +#define __BLIST_UNUSED_14 ((__force blist_flags_t)(1ULL << 14)) +#define __BLIST_UNUSED_15 ((__force blist_flags_t)(1ULL << 15)) +#define __BLIST_UNUSED_16 ((__force blist_flags_t)(1ULL << 16)) /* try REPORT_LUNS even for SCSI-2 devs (if HBA supports more than 8 LUNs) */ #define BLIST_REPORTLUN2 ((__force blist_flags_t)(1ULL << 17)) /* don't try REPORT_LUNS scan (SCSI-3 devs) */ @@ -44,10 +49,12 @@ #define BLIST_RETRY_HWERROR ((__force blist_flags_t)(1ULL << 22)) /* maximum 512 sector cdb length */ #define BLIST_MAX_512 ((__force blist_flags_t)(1ULL << 23)) +#define __BLIST_UNUSED_24 ((__force blist_flags_t)(1ULL << 24)) /* Disable T10 PI (DIF) */ #define BLIST_NO_DIF ((__force blist_flags_t)(1ULL << 25)) /* Ignore SBC-3 VPD pages */ #define BLIST_SKIP_VPD_PAGES ((__force blist_flags_t)(1ULL << 26)) +#define __BLIST_UNUSED_27 ((__force blist_flags_t)(1ULL << 27)) /* Attempt to read VPD pages */ #define BLIST_TRY_VPD_PAGES ((__force blist_flags_t)(1ULL << 28)) /* don't try to issue RSOC */ @@ -57,4 +64,18 @@ /* Use UNMAP limit for WRITE SAME */ #define BLIST_UNMAP_LIMIT_WS ((__force blist_flags_t)(1ULL << 31)) +#define __BLIST_LAST_USED BLIST_UNMAP_LIMIT_WS + +#define __BLIST_HIGH_UNUSED (~(__BLIST_LAST_USED | \ + (__force blist_flags_t) \ + ((__force __u64)__BLIST_LAST_USED - 1ULL))) +#define __BLIST_UNUSED_MASK (__BLIST_UNUSED_11 | \ + __BLIST_UNUSED_13 | \ + __BLIST_UNUSED_14 | \ + __BLIST_UNUSED_15 | \ + __BLIST_UNUSED_16 | \ + __BLIST_UNUSED_24 | \ + __BLIST_UNUSED_27 | \ + __BLIST_HIGH_UNUSED) + #endif -- 2.16.1