From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752072AbcGUSKy (ORCPT ); Thu, 21 Jul 2016 14:10:54 -0400 Received: from mail-pa0-f44.google.com ([209.85.220.44]:36786 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751510AbcGUSKv (ORCPT ); Thu, 21 Jul 2016 14:10:51 -0400 Date: Thu, 21 Jul 2016 11:10:47 -0700 From: Andrey Pronin To: Jason Gunthorpe Cc: Jarkko Sakkinen , Peter Huewe , Marcel Selhorst , tpmdd-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, groeck@chromium.org, smbarber@chromium.org, dianders@chromium.org, Christophe Ricard Subject: Re: [PATCH 2/2] tpm: add driver for cr50 on SPI Message-ID: <20160721181047.GA115653@apronin> References: <1468549218-19215-1-git-send-email-apronin@chromium.org> <1468549218-19215-3-git-send-email-apronin@chromium.org> <20160715033236.GH9347@obsidianresearch.com> <20160715034444.GA28128@apronin> <20160719125527.GB5047@intel.com> <20160720002411.GA147098@apronin> <20160720170336.GC21460@obsidianresearch.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160720170336.GC21460@obsidianresearch.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 20, 2016 at 11:03:36AM -0600, Jason Gunthorpe wrote: > On Tue, Jul 19, 2016 at 05:24:11PM -0700, Andrey Pronin wrote: > > > The only two things that bother me with such approach are > > (1) whatever names I pick for the new set of functions, they > > will be similar to and thus might be confused with the > > original tpm_tis_read/writeXX; > > tpm_tis_helper_read16 ? > > > (2) these functions are phy-specific, so possibly it's better > > to create tpm_tis_spi.h and put them there with proper > > name prefixes. And then use in tpm_tis_spi and cr50_spi. > > No, they are generic to any tis phy that implements read only through > read_bytes. > > (Honestly, I'm not sure we made the best choice here having phy > functions for all the versions, we are not that performance > sensitive, just getting rid of everything but read_bytes from the > phy_ops would probably also be a reasonable thing to do.) > One thing we can do is re-implement functions tpm_tis_read/writeXX to use phy-specific implementations of read16, read32, write32 if they are provided. But if those function pointers are left NULL in phy_ops, fallback to using read/write_bytes and byte-swapping. I.e., instead of: static inline int tpm_tis_read16(struct tpm_tis_data *data, u32 addr, u16 *result) { return data->phy_ops->read16(data, addr, result); } do the following: static inline int tpm_tis_read16(struct tpm_tis_data *data, u32 addr, u16 *result) { int rc; if (data->phy_ops->read16) return data->phy_ops->read16(data, addr, result); rc = data->phy_ops->read_bytes(data, addr, sizeof(u16), (u8 *)result); if (!rc) *result = le16_to_cpu(*result); return rc; } If you like the idea, I'll submit it as a separate patch. Andrey From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrey Pronin Subject: Re: [PATCH 2/2] tpm: add driver for cr50 on SPI Date: Thu, 21 Jul 2016 11:10:47 -0700 Message-ID: <20160721181047.GA115653@apronin> References: <1468549218-19215-1-git-send-email-apronin@chromium.org> <1468549218-19215-3-git-send-email-apronin@chromium.org> <20160715033236.GH9347@obsidianresearch.com> <20160715034444.GA28128@apronin> <20160719125527.GB5047@intel.com> <20160720002411.GA147098@apronin> <20160720170336.GC21460@obsidianresearch.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <20160720170336.GC21460-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: tpmdd-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org To: Jason Gunthorpe Cc: Christophe Ricard , dianders-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, smbarber-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org, tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org, groeck-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org List-Id: tpmdd-devel@lists.sourceforge.net On Wed, Jul 20, 2016 at 11:03:36AM -0600, Jason Gunthorpe wrote: > On Tue, Jul 19, 2016 at 05:24:11PM -0700, Andrey Pronin wrote: > > > The only two things that bother me with such approach are > > (1) whatever names I pick for the new set of functions, they > > will be similar to and thus might be confused with the > > original tpm_tis_read/writeXX; > > tpm_tis_helper_read16 ? > > > (2) these functions are phy-specific, so possibly it's better > > to create tpm_tis_spi.h and put them there with proper > > name prefixes. And then use in tpm_tis_spi and cr50_spi. > > No, they are generic to any tis phy that implements read only through > read_bytes. > > (Honestly, I'm not sure we made the best choice here having phy > functions for all the versions, we are not that performance > sensitive, just getting rid of everything but read_bytes from the > phy_ops would probably also be a reasonable thing to do.) > One thing we can do is re-implement functions tpm_tis_read/writeXX to use phy-specific implementations of read16, read32, write32 if they are provided. But if those function pointers are left NULL in phy_ops, fallback to using read/write_bytes and byte-swapping. I.e., instead of: static inline int tpm_tis_read16(struct tpm_tis_data *data, u32 addr, u16 *result) { return data->phy_ops->read16(data, addr, result); } do the following: static inline int tpm_tis_read16(struct tpm_tis_data *data, u32 addr, u16 *result) { int rc; if (data->phy_ops->read16) return data->phy_ops->read16(data, addr, result); rc = data->phy_ops->read_bytes(data, addr, sizeof(u16), (u8 *)result); if (!rc) *result = le16_to_cpu(*result); return rc; } If you like the idea, I'll submit it as a separate patch. Andrey ------------------------------------------------------------------------------ What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic patterns at an interface-level. Reveals which users, apps, and protocols are consuming the most bandwidth. Provides multi-vendor support for NetFlow, J-Flow, sFlow and other flows. Make informed decisions using capacity planning reports.http://sdm.link/zohodev2dev