Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1047413imm; Wed, 26 Sep 2018 10:43:36 -0700 (PDT) X-Google-Smtp-Source: ACcGV60ihg06SzzsG/psilYlQCXPPTjImhXkgWdxBeUkWNA0H2h1vkCfephS+83pnwqd7NM1TQU9 X-Received: by 2002:a63:5d55:: with SMTP id o21-v6mr6476670pgm.349.1537983816593; Wed, 26 Sep 2018 10:43:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537983816; cv=none; d=google.com; s=arc-20160816; b=WpBJsGg1sYkdjM0X2nFTHcgwuoQqxo8lcBa0qQFLYzbmV16Kgchdfw02kKo2ct18L3 NyFIXog2/bJnbknk/ShiItaMSZbi0/CuZ+TiKOyEnwDl8cHCAuEhmFP5pFCnNwBzLIF3 7BMi2WtezQxl2bbV8R8UzCfNIHbNkxUXgGW66MdcLtB0ml8kzXgqSZSQ/0hvFNIpU4gX OuTTY29X38uJpAcuUC5rh3Fmy40p8lirM8atHi8JWJtBt5LpNEcMz4zKoCXWPgsvn7pp UpJpiUmSQL0FiQzSgSGgf45fYfjXzZbKaaewrSDziYKTBL0W9pq9DP8a1EHKCq6vFZMl gp0Q== 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 :in-reply-to:references:mime-version:dkim-signature; bh=/0qYwNUSw2h9iWL31BwwVDHKRvAvKSe0aqFQWbUZbA8=; b=Evc8tVCPWCt1Ki5ga66kCcfg+gRdOvAu6M0t9rGZ8X27bd5DBMdh1iJwnIfHb7N+e9 1DoJEgTWiV7OAB1it4gMdyUocZWDRE+LTk4TDxGe+p9MIhJ1XpSKAuKIkaO5fgWf9S2W HXxaVMnn9NUmv/OtcK47FcuCH0jCfiBLCSj8ysz0QpniMWQmlIwcTczPZ0hxBOuPSsIF GLZs/wfZ+1gAKVxOsn46nr3K66tLM0abz0msLUV4CRbid8TSLXQWsMO21yHkj9fTsO2/ L54ccwXyetanrQtZWF92P/wKkCIJdiEWsKZwv7yHZiD4adC/AbYs44/WMaDmhNkbXcW4 tWjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sPtYDhxX; 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=QUARANTINE 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 98-v6si5470218pld.46.2018.09.26.10.43.20; Wed, 26 Sep 2018 10:43:36 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sPtYDhxX; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728481AbeIZX5I (ORCPT + 99 others); Wed, 26 Sep 2018 19:57:08 -0400 Received: from mail-qk1-f193.google.com ([209.85.222.193]:43592 "EHLO mail-qk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727604AbeIZX5H (ORCPT ); Wed, 26 Sep 2018 19:57:07 -0400 Received: by mail-qk1-f193.google.com with SMTP id v18-v6so6652892qka.10; Wed, 26 Sep 2018 10:43:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/0qYwNUSw2h9iWL31BwwVDHKRvAvKSe0aqFQWbUZbA8=; b=sPtYDhxXMQTWtUTYegsuwOQbo6AhplMuB/Mk1WHN/WKtcWHRj4U/v3aLXVep0HUToc xBz/AGugL9Yovuiw0f9R2cEfiW2mkozj/uhzUIH3jPHTRBKp3c+7dS9/00igZ/rBEcQO H06NydRwJ8hkvi53LVDU83P5L8lphVAZUYDbvl00s47UOGeJiqSqXt7DtyNmGt/RuBAO KbOhADuZtyyhx4FUpbPvHeMuDCkrvp3e1SiusivY0eQs/5fPaU2sHg3tyoKkSQM9OS5T I63WzD28pHNygsxpaGUZS3fEAA/IZBpX5YNstyGhs6tne5vYVsw0Rtn8kVgLKIhi0Dgt 9Fkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=/0qYwNUSw2h9iWL31BwwVDHKRvAvKSe0aqFQWbUZbA8=; b=ZjZuooIP/3uvWYEk2X59f9/SNgg6+0QnDDOX5LDNdyewryJ5nvBh15ChtnOIqpiI6Y FkfaaL7EsxRZArFs1n1nXWv5/eMlhJmOm4JARwhJzwf6N0URLD8kD2UyQs6h+mh4/S7F k1Fc65ZTKI0Mqx+MhmuP5gzW5N2fanulKRj8sdbPsQ+2HkAHermKLKRdOb6zJ0GGTZ7x RgEEGwSQr/9DpBxQOpi6WSrYxwzTmbENnBcD6T5GjH0ep69ieomACEXnXCKEIv733UYN DubbKFIRngB9x9xfXW1vIJScWaKDvxfKNgJpyyNxr0U99K+/SeoAR3609D5OJmQqFSo+ meDA== X-Gm-Message-State: ABuFfogxaBzB4T3nsYmpZY88SlsW/CQRP5Qnpvo5qvc/hEdO2FOjHY9i CPbBX+wfgpsFcBg4SEqxlldXQlPPF1XEPng2NZ0= X-Received: by 2002:ae9:d885:: with SMTP id u127-v6mr4938527qkf.219.1537983784919; Wed, 26 Sep 2018 10:43:04 -0700 (PDT) MIME-Version: 1.0 References: <20180903180415.31575-1-rajneesh.bhardwaj@linux.intel.com> <20180903180415.31575-3-rajneesh.bhardwaj@linux.intel.com> In-Reply-To: From: Andy Shevchenko Date: Wed, 26 Sep 2018 20:42:53 +0300 Message-ID: Subject: Re: [PATCH 3/4] platform/x86: intel_pmc_core: Decode Snoop / Non Snoop LTR To: rajneesh.bhardwaj@linux.intel.com Cc: Platform Driver , Darren Hart , Andy Shevchenko , Linux Kernel Mailing List , Rajneesh Bhardwaj , Souvik Kumar Chakravarty 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 Wed, Sep 26, 2018 at 5:19 PM Bhardwaj, Rajneesh wrote: > On 26-Sep-18 7:23 PM, Andy Shevchenko wrote: > > On Mon, Sep 3, 2018 at 9:05 PM Rajneesh Bhardwaj > > wrote: > >> +static void get_ltr_scale(u32 *val) > > What's wrong to return converted value? Actually the name should > > reflect what it does, ie *convert* value. > > I can change it as per your suggestion. Please do. > >> +union ltr_payload { > >> + u32 raw_data; > >> + struct { > >> + u32 snoop_val : 10; > >> + u32 snoop_scale : 3; > >> + u32 snoop_res : 2; > >> + u32 snoop_req : 1; > >> + u32 non_snoop_val : 10; > >> + u32 non_snoop_scale : 3; > >> + u32 non_snoop_res : 2; > >> + u32 non_snoop_req : 1; > >> + } bits; > >> +}; > > Just use normal masks and shifts. > > I chose union over masks and shifts to reduce code size and ensured > correct endian-ness. How do you ensure endianess in union if you do nothing to it here? It just would reflect CPU endianess. > Just for my understanding, can you please let me > know why you feel masks/shift are better suited here? First of all, in the very same driver shifts and masks / standalone bits are already in use. Like you mentioned an endianess, it would make it more clear here, though it's still require to get a value in a proper one in the first place. On top of that, a compiler which might generate an awful code out of bits defined as above. Btw, there are helpers for that like those in bitfield.h. -- With Best Regards, Andy Shevchenko