Received: by 10.223.176.5 with SMTP id f5csp1047998wra; Tue, 6 Feb 2018 11:40:06 -0800 (PST) X-Google-Smtp-Source: AH8x225cMkMhmY9dSqomhtC15Kon1AyujRO4aZ+d1XWyU0XoreqYyF0yBogj307GDXaP6ZCFrB96 X-Received: by 2002:a17:902:678b:: with SMTP id g11-v6mr3482110plk.13.1517946006436; Tue, 06 Feb 2018 11:40:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517946006; cv=none; d=google.com; s=arc-20160816; b=vNNS4j1cgUHSp+tgHsYUo6mmKJcbHru7FaE3dXgJUs0EGy5d0lxx563LiT6/Z5IKP4 yDk1/11cwFrRMzDJ7gQWM7cVoW7Z2r28ftwG6s389I7Y6FIRTraFUXisxbDovNXJuf02 mZji2dCO50bPrFzpxtyp2dGft8DyHmxKHNtNmFlaZ7UT7n8mH06IMJHtkMooYOtEW51I 6Ar4o8RCouSw/6l2NBpT5TkDMKb5DtVgZ0FTXPzjj/1FNLeP5lLihOTz6HTFVNcM+2Oy M21aNFIBzHikk4W9CycQwvAFb2z3f5+IeTIcf+QVzDE7AO5zHGA/wYwngsW+bA/PmUWq UCSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=Sr4UrWpLKSrdxLXAh9qtmB3BQMFv+f/rg+E+ZuPEDAw=; b=dQ08jnp2lYmLWoY0HlzzKMHUxWwMsoPhbqZCxFFwzea0A3ZOFI1hi3Qf/h4P2XfTdq 11S324d4HHxyNZOGvG+0qkoujlbTdocaxdSN42b1LUACs02V+AtT+ayecyV0luNh2gOT VcW+QoxRFNxkUxDKlptTmkxMEgw2kxYQIkH8hOLdcJTUCoW/g9lkNOAJP8Y6Neu5IjtZ 5mofuGPgNwXp6kHr8RJ3gjqqh8I1gqCsTNABOPC9Xn++Qb+UAso2NYUX7D16EjEk0AUE h+jrE1SjerlNh0q0O6USg3zk25NehtK7l6re6y5cIBakXDez7hOHfhIgDYC2k70SdAaT mG8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=l7bmoIhP; 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=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c1si1628727pgf.354.2018.02.06.11.39.52; Tue, 06 Feb 2018 11:40:06 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=l7bmoIhP; 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=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753998AbeBFTiS (ORCPT + 99 others); Tue, 6 Feb 2018 14:38:18 -0500 Received: from mail-qk0-f194.google.com ([209.85.220.194]:35194 "EHLO mail-qk0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932070AbeBFTiK (ORCPT ); Tue, 6 Feb 2018 14:38:10 -0500 Received: by mail-qk0-f194.google.com with SMTP id 69so3835382qkz.2; Tue, 06 Feb 2018 11:38:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=Sr4UrWpLKSrdxLXAh9qtmB3BQMFv+f/rg+E+ZuPEDAw=; b=l7bmoIhPkBqBJbvv6pEUyGB5ho0DJPZf9wnhbFTEO/Q5hOS29vL6SyEciWkgRjVHE7 LhIx3LUohnr4aRKvTp+wRkFwtC+ZhaeTd+7RUoBeTIdzBAkAEFYAhstK0NGhPekVocF2 y/NixeGIyVvinVVaC+hl80McYGT/4pJgFaFyRF0vD5e3d6ENAtL5r52oMYaUsstGU6an sqBSyLKh8+lL6FqL60sDwPAHEZ0vBL2N5MTJ16s+hbjUUEYmMxtOgA2wd0VeLqFyGVRz HijJ0cnTjA5NY/AzhIXMknJ/tKi06obTYxvJTN4xgM0n+FWBZoxX+au5hietPc4b4aRp qDaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=Sr4UrWpLKSrdxLXAh9qtmB3BQMFv+f/rg+E+ZuPEDAw=; b=WuxQj6bNle/OEWUxKWqbbvAxaqjiW/QyYfvtLn5h2aj2fAq47LryfVOS3vPVElImH4 NHbc+OhplcU9D2p8fQol9e4U3qxmig8AcHh8bMddZJ9w0lB5T4COhPO+fOkO1kVY95e9 3taPpYPuEXEymXJyVIqV0u1xkY8rSSeqGDbaGKXMCWEQH+V3cAZS40QgFn3k5AjhxIOS tEYzIUMQhfyuyseoVCJzBJxB8AALlXYpHZfKEQx1cTr4YLFREiO+n0qzDhDOTnVcpl0k bhkLh4Dg2rvW2k7mom5MVJp76rp/AqZVdDuSJ557+UMUOKT4JYFAG+cGSEjVQ2pdJ7LD iygg== X-Gm-Message-State: APf1xPB/6btmBY/KFyUpBl0nRIHdok2IijXF/xNMe/cbZtRfuleDXUKr LgV5dj1YRV7kwmE83h04NB+b8xo+7n8xUxKFOEg= X-Received: by 10.55.120.66 with SMTP id t63mr4791649qkc.345.1517945890088; Tue, 06 Feb 2018 11:38:10 -0800 (PST) MIME-Version: 1.0 Received: by 10.12.175.35 with HTTP; Tue, 6 Feb 2018 11:38:09 -0800 (PST) In-Reply-To: <20180205162519.GA3044@axis.com> References: <20180201161119.3852-1-niklas.cassel@axis.com> <20180201161119.3852-4-niklas.cassel@axis.com> <000601d39b8e$f58a76f0$e09f64d0$@gmail.com> <20180205162519.GA3044@axis.com> From: Andy Shevchenko Date: Tue, 6 Feb 2018 21:38:09 +0200 Message-ID: Subject: Re: [PATCH 3/3] PCI: designware-ep: Return an error when requesting a too large BAR size To: Niklas Cassel Cc: Jingoo Han , Kishon Vijay Abraham I , Joao Pinto , Lorenzo Pieralisi , Bjorn Helgaas , linux-pci@vger.kernel.org, Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 5, 2018 at 6:25 PM, Niklas Cassel wrote: > On Thu, Feb 01, 2018 at 02:00:40PM -0500, Jingoo Han wrote: >> On Thursday, February 1, 2018 1:58 PM, Andy Shevchenko wrote: >> > >> > On Thu, Feb 1, 2018 at 6:11 PM, Niklas Cassel >> > wrote: >> > >> > include/linux/sizes.h: >> > >> > +SZ_4G 0x100000000ULL >> > >> > > + if (size > 0x100000000ULL) { >> > >> > #include >> > >> > if (size > SZ_4G) { >> >> I like this one for the readability. >> Thank you. >> > > I liked it too, however both variants > > if (size > 0x100000000ULL) { > > if (size > SZ_4G) { > > result in: > > drivers/pci/dwc/pcie-designware-ep.c:131:11: warning: > comparison is always false due to limited range of data type [-Wtype-limits] > > when compiling with W=1 on a platform with 32-bit size_t. > > > The annoying thing here is that a BAR can be 64-bit, > yet the parameter size is defined as a size_t, > so the error will only show on 32-bit and not on 64-bit. Oh, indeed. And it looks moving to u64 or alike is not a solution (because if would not describe real hardware in that case). > What do you think about: > if (upper_32_bits(size)) { > dev_err(pci->dev, "can't handle BAR larger than 4GB\n"); > return -EINVAL; > } > > That should compile without warnings for both > 32-bit size_t and 64-bit size_t. Can you derive some helper based on the code in __pci_read_base() code? -- With Best Regards, Andy Shevchenko