Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4351799rwd; Tue, 30 May 2023 04:22:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5aSs/aiD2C+w9Wdi94IpQSmXDHn8pzcd5mkSER8zHJWW0VG/xOczXdU750DfTRWXFP/5jn X-Received: by 2002:a05:6a20:3ca5:b0:10c:f674:3bab with SMTP id b37-20020a056a203ca500b0010cf6743babmr2254977pzj.61.1685445774606; Tue, 30 May 2023 04:22:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685445774; cv=none; d=google.com; s=arc-20160816; b=yRORLAP95tVzDUI6PSJNhsDRgScImvVtbtG7MSvE5ooHcSVOp5y9XoIaO4CjkR+a+Q f1TbC8xjn/lSWd8VacvWk7QpnrTlTAgJvyw3TyrwcXG4TFlcN5Zo3hmpFAP1JQlz/Akc YLLT2ObY+8zv+77vFeH7qCSqnFw+9+gek2YmKcKJwuQu6RmSJYIrPAPRF7uKuA3CawuA R3nWPJTMOZI+wV2UQM28jYy+KX4PTrXL2M2kFxJGP7kwldwW2QT6qKPxTiXLQQ8MkYUX l7BQhhcT0/ghTOfwqMdFVY9zsTcdIM2uSn4C3Pj3EyjLBUxfkL/pHUj3zF+6fHK2chR7 Pgpw== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=nH0XS4f8yJnfHM7AjACowiC+cI2naFgJ4I/q8u+Bb4Q=; b=i/2RXr30sQaO+LN6Ih/CPmMFpnC6JyOe4gWkhDHBdmBCLTsa4d6C3hfXGjiS/kE0DV 2yGG3XBUOGuXe8CUXKt3ZouRPwZcltMy88NKYrPfwbmfFrimYjSzzwDL3UnS6kxp3wR2 i/TTKCpHeUzGF1stTWJ887pL/oJYHFNlJ19sq5Gy2Ppd1WPkkoTko4X4Y0c46dcZZ3+X e3/UokXJhIxt53WcO8qftpbn2BAV5gfWz+uZgIOekawjIGXh7QXwGY74p/uZ8l/pGJn7 QBsvYjEHM3g3ja5NYuHJzUJESVqVrhOsfgMlQ0NCohqqhCY4MYl1zEG/ZN2s/QOd2VwV KQkg== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z24-20020a63b918000000b0052c9458bc07si7797557pge.468.2023.05.30.04.22.40; Tue, 30 May 2023 04:22:54 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231149AbjE3LTM (ORCPT + 99 others); Tue, 30 May 2023 07:19:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229660AbjE3LTL (ORCPT ); Tue, 30 May 2023 07:19:11 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A41EB0; Tue, 30 May 2023 04:19:10 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E9C6162A36; Tue, 30 May 2023 11:19:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A42D0C433EF; Tue, 30 May 2023 11:19:05 +0000 (UTC) Date: Tue, 30 May 2023 16:48:53 +0530 From: Manivannan Sadhasivam To: Damien Le Moal Cc: Manivannan Sadhasivam , Lorenzo Pieralisi , kw@linux.com, kishon@kernel.org, bhelgaas@google.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: Re: [PATCH v4 7/7] PCI: endpoint: Add PCI Endpoint function driver for MHI bus Message-ID: <20230530111853.GH6379@thinkpad> References: <20230519144215.25167-1-manivannan.sadhasivam@linaro.org> <20230519144215.25167-8-manivannan.sadhasivam@linaro.org> <20230529173815.GG5633@thinkpad> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS, 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 Tue, May 30, 2023 at 08:37:07AM +0900, Damien Le Moal wrote: > On 5/30/23 02:38, Manivannan Sadhasivam wrote: > [...] > >>> +static void pci_epf_mhi_unmap_free(struct mhi_ep_cntrl *mhi_cntrl, u64 pci_addr, > >>> + phys_addr_t phys_addr, void __iomem *virt_addr, size_t size) > >>> +{ > >>> + struct pci_epf_mhi *epf_mhi = container_of(mhi_cntrl, struct pci_epf_mhi, mhi_cntrl); > >>> + struct pci_epf *epf = epf_mhi->epf; > >>> + struct pci_epc *epc = epf->epc; > >>> + size_t offset = pci_addr & (epc->mem->window.page_size - 1); > >>> + > >>> + pci_epc_unmap_addr(epc, epf->func_no, epf->vfunc_no, phys_addr - offset); > >>> + pci_epc_mem_free_addr(epc, phys_addr - offset, virt_addr - offset, size + offset); > >>> +} > >>> + > >>> +static void pci_epf_mhi_raise_irq(struct mhi_ep_cntrl *mhi_cntrl, u32 vector) > >>> +{ > >>> + struct pci_epf_mhi *epf_mhi = container_of(mhi_cntrl, struct pci_epf_mhi, mhi_cntrl); > >>> + struct pci_epf *epf = epf_mhi->epf; > >>> + struct pci_epc *epc = epf->epc; > >>> + > >>> + /* > >>> + * Vector is incremented by 1 here as the DWC core will decrement it before > >>> + * writing to iATU. > >> > >> This isn't OK. It is an API, you can't write code explicitly relying on > >> the underlying implementation. I assume the API is not well specified, > >> that's why we need these tricks ? > >> > > > > Well, this is not an API issue but rather an implementation detail of the DWC EP > > core driver. The DWC driver expects the interrupt vectors to be 1 based, so it > > decrements it before writing to the MSI address: > > [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/pci/controller/dwc/pcie-designware-ep.c#n537 > > Then the driver should be fixed so that this peculiarity is not visible at the > user API level, resulting in a uniform usage of the API for all functions > regardless of the controller being used. > Just checked with Kishon offline and confirmed that this is an API behavior. I also checked other drivers and they all doing the same. But unfortunately, this behavior is not documented in the API. Will add a patch for that. - Mani > -- > Damien Le Moal > Western Digital Research > -- மணிவண்ணன் சதாசிவம்