Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2141828ybb; Thu, 26 Mar 2020 23:07:47 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuxioj2WYYZm2vY9+muasjUsi8iiBSPe9hVe36WDLDxsY0Lt+D3+q/DwwbcdFnZf/oUItuN X-Received: by 2002:a05:6808:8db:: with SMTP id k27mr2952052oij.175.1585289267548; Thu, 26 Mar 2020 23:07:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585289267; cv=none; d=google.com; s=arc-20160816; b=q9SbMmL4xNeK77pynFTnJEDIda5lxaWy8q1d/7HgEpTtYoB3wRewnEzJTotGnrTftf M/LVHG1e3yHtEP7wiD3N6d+gtd6N+M6w5dafIpZSOu4XmTjXS+MD/ezoB43rdVkdVJub dRxR/0ljLPlPGr2yd6CqL4KipDkndj5IUdiaVGB0n231sWO5iRCT0c9KMqBIKbCEdDYJ dLoVtBjzBW28VLMQD6EKDJrwAEUMp8u9juiaW6yMTWzW2X3ct2nNV0Pbt+YN6U6rRtFl eDjJZ8NGBvV5/vPoktlXMIoP52pHtLnOMM/r7xIla2zTLOE7H40iWwXtuUZfa5Xhhffu 9hXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:ironport-sdr:ironport-sdr; bh=szbNTU47YaLN4KXP3rHZCG9GoyK+RLp2tW0LizzbgEc=; b=nLFz/WXls68ZHFVWxM/rdgGzXcRXs4S9PSdFbXmbitHXX74i6AcndNOzlPVnbzeAoD VWiSckKw49IC2rhucc8+jmPKory/BXmGNjUqmYt4LHEQfgreHSkw2ck9x62xfV/SS+/Y znR9EQxRBRsAXsNjisHP32kmB4zNh11UgIyXePH4YC8MrpU/zlKJFS+7UxnsaGhIru5n q/Dz9tXXgqVhJ9I3cGy0tkIg5EKOOTQPAglxKjwNrMixSXz4jOr6ZnFINvteTPopYrKZ YaCEAJJKJjAGz13JRAyDBLns16/bmbpciC8rjeURWZzZ89Eut9WLXO5L2gyxwG/G4aH5 d6nQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w188si2010387oig.183.2020.03.26.23.07.35; Thu, 26 Mar 2020 23:07:47 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726656AbgC0GG3 (ORCPT + 99 others); Fri, 27 Mar 2020 02:06:29 -0400 Received: from mga06.intel.com ([134.134.136.31]:50360 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726002AbgC0GG3 (ORCPT ); Fri, 27 Mar 2020 02:06:29 -0400 IronPort-SDR: C0ZSgax653oe9kIuBcNBmjjb5sOBGrLvpXa6HdQay0mrVkeTpBQHn3s1cTKPiXhZEXTXLqYYWU nAfNOe9PJKbQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Mar 2020 23:06:28 -0700 IronPort-SDR: i81oI8iFE4asEVqdiQqz6xgD0glVRrwUJ1v2RDiFw0ucB0TmMWeEDrp4K9EbwvXVGvMnbRPRfk o6J7Ce52yaZA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,311,1580803200"; d="scan'208";a="239012996" Received: from lkp-server01.sh.intel.com (HELO lkp-server01) ([10.239.97.150]) by fmsmga007.fm.intel.com with ESMTP; 26 Mar 2020 23:06:24 -0700 Received: from kbuild by lkp-server01 with local (Exim 4.89) (envelope-from ) id 1jHi8N-0004vo-Lh; Fri, 27 Mar 2020 14:06:23 +0800 Date: Fri, 27 Mar 2020 14:05:33 +0800 From: kbuild test robot To: Alexander Graf Cc: kbuild-all@lists.01.org, "iommu@lists.linux-foundation.org, Konrad Rzeszutek Wilk" , x86@kernel.org, Christoph Hellwig , Marek Szyprowski , Robin Murphy , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Mark Rutland , dwmw@amazon.com, benh@amazon.com, Jan Kiszka , alcioa@amazon.com, aggh@amazon.com, aagch@amazon.com, dhr@amazon.com Subject: Re: [PATCH] swiotlb: Allow swiotlb to live at pre-defined address Message-ID: <202003271409.zBJrGfB4%lkp@intel.com> References: <20200326162922.27085-1-graf@amazon.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200326162922.27085-1-graf@amazon.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Alexander, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on linus/master] [also build test WARNING on swiotlb/linux-next tip/x86/core v5.6-rc7 next-20200326] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982] url: https://github.com/0day-ci/linux/commits/Alexander-Graf/swiotlb-Allow-swiotlb-to-live-at-pre-defined-address/20200327-062125 base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 9420e8ade4353a6710908ffafa23ecaf1caa0123 reproduce: # apt-get install sparse # sparse version: v0.6.1-187-gbff9b106-dirty make ARCH=x86_64 allmodconfig make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' If you fix the issue, kindly add following tag Reported-by: kbuild test robot sparse warnings: (new ones prefixed by >>) kernel/dma/swiotlb.c:97:14: sparse: sparse: symbol 'max_segment' was not declared. Should it be static? >> kernel/dma/swiotlb.c:143:53: sparse: sparse: incorrect type in argument 3 (different base types) @@ expected unsigned long *res @@ got long *res @@ >> kernel/dma/swiotlb.c:143:53: sparse: expected unsigned long *res >> kernel/dma/swiotlb.c:143:53: sparse: got char ** >> kernel/dma/swiotlb.c:268:16: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected unsigned char [noderef] *vstart @@ got n:2> *vstart @@ >> kernel/dma/swiotlb.c:268:16: sparse: expected unsigned char [noderef] *vstart >> kernel/dma/swiotlb.c:268:16: sparse: got void * >> kernel/dma/swiotlb.c:272:35: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected char *tlb @@ got unsigned char [noderef] > kernel/dma/swiotlb.c:272:35: sparse: expected char *tlb >> kernel/dma/swiotlb.c:272:35: sparse: got unsigned char [noderef] *vstart >> kernel/dma/swiotlb.c:273:26: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void *addr @@ got unsigned char [noderef] > kernel/dma/swiotlb.c:273:26: sparse: expected void *addr kernel/dma/swiotlb.c:273:26: sparse: got unsigned char [noderef] *vstart vim +143 kernel/dma/swiotlb.c 118 119 static int __init 120 setup_io_tlb_npages(char *str) 121 { 122 if (isdigit(*str)) { 123 io_tlb_nslabs = simple_strtoul(str, &str, 0); 124 /* avoid tail segment of size < IO_TLB_SEGSIZE */ 125 io_tlb_nslabs = ALIGN(io_tlb_nslabs, IO_TLB_SEGSIZE); 126 } 127 if (*str == ',') 128 ++str; 129 if (!strncmp(str, "force", 5)) { 130 swiotlb_force = SWIOTLB_FORCE; 131 str += 5; 132 } else if (!strncmp(str, "noforce", 7)) { 133 swiotlb_force = SWIOTLB_NO_FORCE; 134 io_tlb_nslabs = 1; 135 str += 7; 136 } 137 138 if (*str == ',') 139 ++str; 140 if (!strncmp(str, "addr=", 5)) { 141 char *addrstr = str + 5; 142 > 143 io_tlb_addr = kstrtoul(addrstr, 0, &str); 144 if (addrstr == str) 145 io_tlb_addr = INVALID_PHYS_ADDR; 146 } 147 148 return 0; 149 } 150 early_param("swiotlb", setup_io_tlb_npages); 151 152 static bool no_iotlb_memory; 153 154 unsigned long swiotlb_nr_tbl(void) 155 { 156 return unlikely(no_iotlb_memory) ? 0 : io_tlb_nslabs; 157 } 158 EXPORT_SYMBOL_GPL(swiotlb_nr_tbl); 159 160 unsigned int swiotlb_max_segment(void) 161 { 162 return unlikely(no_iotlb_memory) ? 0 : max_segment; 163 } 164 EXPORT_SYMBOL_GPL(swiotlb_max_segment); 165 166 void swiotlb_set_max_segment(unsigned int val) 167 { 168 if (swiotlb_force == SWIOTLB_FORCE) 169 max_segment = 1; 170 else 171 max_segment = rounddown(val, PAGE_SIZE); 172 } 173 174 /* default to 64MB */ 175 #define IO_TLB_DEFAULT_SIZE (64UL<<20) 176 unsigned long swiotlb_size_or_default(void) 177 { 178 unsigned long size; 179 180 size = io_tlb_nslabs << IO_TLB_SHIFT; 181 182 return size ? size : (IO_TLB_DEFAULT_SIZE); 183 } 184 185 void swiotlb_print_info(void) 186 { 187 unsigned long bytes = io_tlb_nslabs << IO_TLB_SHIFT; 188 189 if (no_iotlb_memory) { 190 pr_warn("No low mem\n"); 191 return; 192 } 193 194 pr_info("mapped [mem %#010llx-%#010llx] (%luMB)\n", 195 (unsigned long long)io_tlb_start, 196 (unsigned long long)io_tlb_end, 197 bytes >> 20); 198 } 199 200 /* 201 * Early SWIOTLB allocation may be too early to allow an architecture to 202 * perform the desired operations. This function allows the architecture to 203 * call SWIOTLB when the operations are possible. It needs to be called 204 * before the SWIOTLB memory is used. 205 */ 206 void __init swiotlb_update_mem_attributes(void) 207 { 208 void *vaddr; 209 unsigned long bytes; 210 211 if (no_iotlb_memory || late_alloc) 212 return; 213 214 vaddr = phys_to_virt(io_tlb_start); 215 bytes = PAGE_ALIGN(io_tlb_nslabs << IO_TLB_SHIFT); 216 set_memory_decrypted((unsigned long)vaddr, bytes >> PAGE_SHIFT); 217 memset(vaddr, 0, bytes); 218 } 219 220 int __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose) 221 { 222 unsigned long i, bytes; 223 size_t alloc_size; 224 225 bytes = nslabs << IO_TLB_SHIFT; 226 227 io_tlb_nslabs = nslabs; 228 io_tlb_start = __pa(tlb); 229 io_tlb_end = io_tlb_start + bytes; 230 231 /* 232 * Allocate and initialize the free list array. This array is used 233 * to find contiguous free memory regions of size up to IO_TLB_SEGSIZE 234 * between io_tlb_start and io_tlb_end. 235 */ 236 alloc_size = PAGE_ALIGN(io_tlb_nslabs * sizeof(int)); 237 io_tlb_list = memblock_alloc(alloc_size, PAGE_SIZE); 238 if (!io_tlb_list) 239 panic("%s: Failed to allocate %zu bytes align=0x%lx\n", 240 __func__, alloc_size, PAGE_SIZE); 241 242 alloc_size = PAGE_ALIGN(io_tlb_nslabs * sizeof(phys_addr_t)); 243 io_tlb_orig_addr = memblock_alloc(alloc_size, PAGE_SIZE); 244 if (!io_tlb_orig_addr) 245 panic("%s: Failed to allocate %zu bytes align=0x%lx\n", 246 __func__, alloc_size, PAGE_SIZE); 247 248 for (i = 0; i < io_tlb_nslabs; i++) { 249 io_tlb_list[i] = IO_TLB_SEGSIZE - OFFSET(i, IO_TLB_SEGSIZE); 250 io_tlb_orig_addr[i] = INVALID_PHYS_ADDR; 251 } 252 io_tlb_index = 0; 253 254 if (verbose) 255 swiotlb_print_info(); 256 257 swiotlb_set_max_segment(io_tlb_nslabs << IO_TLB_SHIFT); 258 return 0; 259 } 260 261 static int __init swiotlb_init_io(int verbose, unsigned long bytes) 262 { 263 unsigned __iomem char *vstart; 264 265 if (io_tlb_addr == INVALID_PHYS_ADDR) 266 return -EINVAL; 267 > 268 vstart = memremap(io_tlb_addr, bytes, MEMREMAP_WB); 269 if (!vstart) 270 return -EINVAL; 271 > 272 if (swiotlb_init_with_tbl(vstart, io_tlb_nslabs, verbose)) { > 273 memunmap(vstart); 274 return -EINVAL; 275 } 276 277 return 0; 278 } 279 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org