Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp603695imw; Fri, 8 Jul 2022 08:26:38 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tLLj9OZ6b3miDyxzZzatG8fj6zLIuleVhVZR0RuLQ4XWg8kaqzxLfjhGW9pl8I3SEiJUql X-Received: by 2002:a17:907:72ce:b0:722:e1a5:164c with SMTP id du14-20020a17090772ce00b00722e1a5164cmr4166024ejc.111.1657293998502; Fri, 08 Jul 2022 08:26:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657293998; cv=none; d=google.com; s=arc-20160816; b=lLo40Y5l4UnxyPEFf0DKVUYDQxeSRDO3QabQAZxyIxlUOYN7hOr/pFAWJ31DoYStkI 4wpZAW8Oz4iLW37JiiOoRN57hGDm/HEBhqQTpUHinasg3dCZ0Xrf77WE2edHT0ZUDzF5 8lLnMejQOjTOR+g0hfVjxCvqDVck36V2NnzL1r3xvkuMwcibyqovj+xMyrulvdJ1hTeF fjKvklWNAFZ1RN9oVm77AdTurJEUv3M4jC/8gkwe6KRnpktpGMrbVrVe1rK+uY8DN21o oLxERxld0yitvJJW+kDWSj1q+ODch9TnYH0TQHAr3rcreqwTJ4t7U6hE6MuN7aRz53tK 5cdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=3jpvp1J2V3RiYjdNlHd4/ahZAB1KUqyXlwmwoUipWJ0=; b=Vr2CE7M/v9Tok0eWudrO9N7aFMbS6wfcw6NUWRelpGSvNYE6lsJuNhqkQlsj4qf7LF 3kgUQRlJMiwgG93AtQwYkTfutQBRMsJEaNHTNOD/dfazMN8EGT9GuxM5OEHEWSSUMq2J vJtup75h01SIv73zr7AtWnsUdwlqnjX4EOwIQMYg+80f0BNVcye+SAy0/CyX8tHO8u0f vZs3M0pZn7fbanM4S/YBn27jOf7kR14lErF86CFaAsvrxw156KJwrskELK5FnXmPtjvx twzgtjvFXYTiXl/nDc7RVKy3148gTFJfpndrT6fIp9RcgqBsR8Qig+O1RkTn9w/oZDyW sMZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=e+7GDgz7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hq42-20020a1709073f2a00b00707dfcfc53asi16808181ejc.411.2022.07.08.08.26.12; Fri, 08 Jul 2022 08:26:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=e+7GDgz7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238727AbiGHPEX (ORCPT + 99 others); Fri, 8 Jul 2022 11:04:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238189AbiGHPEV (ORCPT ); Fri, 8 Jul 2022 11:04:21 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E7F52F67E; Fri, 8 Jul 2022 08:04:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=3jpvp1J2V3RiYjdNlHd4/ahZAB1KUqyXlwmwoUipWJ0=; b=e+7GDgz79BPotjw0lqXGRpcd/B OJkyo7ZfBI5HADrhmC15E51UM2IZDoZ+5zsP6A8p7dfQMyPpXNoN/k6FIKqZg8nTJsDigOEg25ZU/ hUHIeSNm96S6FVnqqKSG0ALs3dNA0lBWk4l0haqvkZMmTS9l6YDquQQZDw92MsZWd2+xit4RC4n+7 VKvG3pFYh8rMWwcqt4ebIIVNRhA/a59eOhYVcsQQzF3hWuxvdOlOrI8gZtwrXMhLmMFsEIERyTgHm KY4eQuyAyk79Tph0/kfYFPo9pRr8dCFiv4mn6o9AKah48N71tdHo+tvD+4fk6GdfLljZA0ApPMHj0 vMU6//og==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1o9pWX-003aRS-WF; Fri, 08 Jul 2022 15:04:06 +0000 Date: Fri, 8 Jul 2022 16:04:05 +0100 From: Matthew Wilcox To: Ira Weiny Cc: Bjorn Helgaas , Dan Williams , Greg Kroah-Hartman , "Rafael J. Wysocki" , Alison Schofield , Vishal Verma , linux-kernel@vger.kernel.org, linux-cxl@vger.kernel.org, linux-pci@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [RFC PATCH 2/3] pci/doe: Use devm_xa_init() Message-ID: References: <20220705232159.2218958-3-ira.weiny@intel.com> <20220707160646.GA306751@bhelgaas> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 08, 2022 at 07:57:10AM -0700, Ira Weiny wrote: > > > I'll update this to be more clear in a V1 if it goes that far. But to clarify > > > here; the protocol information is a u16 vendor id and u8 protocol number. So > > > we are able to store that in the unsigned long value that would normally be a > > > pointer to something in the XArray. > > > > Er. Signed long. > > Sorry I misspoke, xa_mk_value() takes an unsigned long. It does, *but* ... static inline void *xa_mk_value(unsigned long v) { WARN_ON((long)v < 0); return (void *)((v << 1) | 1); } ... you can't pass an integer that has the top bit set to it. > Can't I use xa_mk_value() to store data directly in the entry "pointer"? Yes, that's the purpose of xa_mk_value(). From what you said, it sounded like you were just storing the integer directly, which won't work. > +static void *pci_doe_xa_prot_entry(u16 vid, u8 prot) > +{ > + return xa_mk_value(((unsigned long)vid << 16) | prot); > +} > > Both Dan and I thought this was acceptable in XArray? You haven't tested that on 32-bit, have you? Shift vid by 8 instead of 16, and it'll be fine. (Oh, and you don't need to cast vid; the standard C integer promotions will promote vid to int before shifting, and you won't lose any bits)