Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754122AbbGPAkD (ORCPT ); Wed, 15 Jul 2015 20:40:03 -0400 Received: from seldrel01.sonyericsson.com ([37.139.156.2]:8827 "EHLO seldrel01.sonyericsson.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753836AbbGPAkA (ORCPT ); Wed, 15 Jul 2015 20:40:00 -0400 Date: Wed, 15 Jul 2015 17:39:56 -0700 From: Bjorn Andersson To: Andy Gross CC: Stephen Boyd , , , Subject: Re: [PATCH v2] firmware: qcom: scm: Peripheral Authentication Service Message-ID: <20150716003955.GI32767@usrtlx11787.corpusers.net> References: <1435693579-16109-1-git-send-email-bjorn.andersson@sonymobile.com> <1436986686-18304-1-git-send-email-bjorn.andersson@sonymobile.com> <20150715213323.GA12399@qualcomm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20150715213323.GA12399@qualcomm.com> User-Agent: Mutt/1.5.22 (2013-10-16) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2224 Lines: 67 On Wed 15 Jul 14:33 PDT 2015, Andy Gross wrote: > On Wed, Jul 15, 2015 at 11:58:06AM -0700, Bjorn Andersson wrote: > > > > > +int __qcom_scm_pas_init_image(u32 peripheral, const void *metadata, size_t size) > > +{ > > + dma_addr_t mdata_phys; > > + void *mdata_buf; > > + __le32 scm_ret; > > + int ret; > > + struct pas_init_image_req { > > + __le32 proc; > > + __le32 image_addr; > > + } request; > > + > > + /* > > + * During the scm call memory protection will be enabled for the meta > > + * data blob, so make sure it's physically contiguous, 4K aligned and > > + * non-cachable to avoid XPU violations. > > + */ > > + mdata_buf = dma_alloc_coherent(NULL, size, &mdata_phys, GFP_KERNEL); > > It'd be nice to send in the dev so we can attribute the allocation correctly. > For 64 bit, we actually have to do this because NULL is not allowed right now. > As per Stephen's answer I need to respin this anyways, but I think I need to read up a little bit more on the implications of passing e.g. the PIL dev* down here. > > + if (!mdata_buf) { > > + pr_err("Allocation of metadata buffer failed.\n"); > > + return -ENOMEM; > > + } > > + memcpy(mdata_buf, metadata, size); > > + > > + request.proc = cpu_to_le32(peripheral); > > + request.image_addr = cpu_to_le32(mdata_phys); > > + > > + ret = qcom_scm_call(QCOM_SCM_SVC_PIL, QCOM_SCM_PAS_INIT_IMAGE_CMD, > > + &request, sizeof(request), > > + &scm_ret, sizeof(scm_ret)); > > + > > + dma_free_coherent(NULL, size, mdata_buf, mdata_phys); > > + > > + return ret ? : le32_to_cpu(scm_ret); > > +} > > + > > Otherwise, looks good. Let me know if you plan to modify for the device above. > If you want me to do it later, thats fine. But it means API change. > I'll respin this in a bit, need to read up a little bit more on the dma allocation. But most likely I'll just move the allocation to the common code, pass the physical address here and expect a dev* in the public api. Regards, Bjorn -- 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/