Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753938AbbDHJcp (ORCPT ); Wed, 8 Apr 2015 05:32:45 -0400 Received: from mga11.intel.com ([192.55.52.93]:5499 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751380AbbDHJcm (ORCPT ); Wed, 8 Apr 2015 05:32:42 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,543,1422950400"; d="scan'208";a="552746531" Date: Wed, 8 Apr 2015 12:32:35 +0300 From: Jarkko Sakkinen To: Jason Gunthorpe Cc: christophe.ricard@gmail.com, Ashley Lai , linux-kernel@vger.kernel.org, tpmdd-devel@lists.sourceforge.net, jason.gunthorpe@obsidianresearch.com Subject: Re: [tpmdd-devel] [PATCH] tpm: unified PPI interface for TPM 1.x/2.0 devices Message-ID: <20150408093235.GA10329@intel.com> References: <1427891332-16709-1-git-send-email-jarkko.sakkinen@linux.intel.com> <20150401181925.GA20550@obsidianresearch.com> <20150408072607.GA7994@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150408072607.GA7994@intel.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3428 Lines: 95 Gave this some rethought :) On Wed, Apr 08, 2015 at 10:26:07AM +0300, Jarkko Sakkinen wrote: > On Wed, Apr 01, 2015 at 12:19:25PM -0600, Jason Gunthorpe wrote: > > On Wed, Apr 01, 2015 at 03:28:52PM +0300, Jarkko Sakkinen wrote: > > > Added PPI interface to the character device. PPI interface is also kept > > > in the pdev for backwards compatibility. > > > > Could you look at just completely moving the PPI interface to the char > > dev and then adding a symlink from the pdev? That would be really > > ideal. > > > > symlinks have the advantage that they actually fully fix the lifetime > > issues. > > > > This seems doable, if we replace the ppi_attrs group with a bunch of > > calls to sysfs_create_link it should work ? > > If we follow the pattern in [1] by the book, how would you use > sysfs_create_link()? To be more specific, how would you get the driver > core to create the symlinks for you? > > If we decide not to follow [1] by the book, then this might be doable > (thinking off my head, that's the reason why I use *might be* instead > of *is*). Wouldn't we get non-racy behavior if sysfs_create_link()'s > are executed after device_initialize() and before device_add()? Here I tend to lean towards for creating a separate set of attributes instead. I would keep the legacy stuff completely separated of the sysfs attributes for the character devices and not do any clever things in the sysfs. > > > +static struct tpm_chip *ppi_dev_to_chip(struct device *dev) > > > +{ > > > + struct tpm_chip *chip = dev_get_drvdata(dev); > > > + > > > + if (chip == NULL) > > > + chip = to_tpm_chip(chip); > > > + > > > + return chip; > > > +} > > > > If symlinks don't work out, we should probably just set the drvdata on > > the tpm_chip itself to avoid this. > > I'll experiment with this. Thanks for the comment. > > > > + if (!(chip->flags & TPM_CHIP_FLAG_PPI)) > > > + return -EINVAL; > > > > Hum, I don't think the PPI files should be created if there is no PPI > > support.. > > Again, following [1] by the book. And again, I think we could just as > well do our sysfs stuff in-between device_initialize() and device_add() > and get the non-racy behavior. I do not think it would be a bad idea to always create them when the kernel is compiled with CONFIG_ACPI. Maybe it would be abetter idea to return -ENOSYS? Device Model in the Linux kernel seems to recommend through the defaults APIs a flat set of attributes for each device node. > > > +void __init tpm_ppi_init(struct class *tpm_class) > > > +{ > > > + tpm_class->dev_groups = tpm_groups; > > > } > > > > So this shouldn't be unconditional. > > > > Also, ultimately PPI can't just claim the dev_groups, other parts of > > the driver will need to add groups too. > > > > I think it makes more sense to do > > > > struct attribute_group *tpm_ppi_get_sysfs(struct tpm_chip *chip) > > { > > } > > > > And take care of building the list in the caller. > > > > And tpm_ppi_get_sysfs should be called after the driver is readied but > > before adding the device. > > I don't think this would matter. Things could be refactored when more > sysfs attributes are needed. > > > Jason /Jarkko -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/