Re: [PATCH v6 40/53] PCI: Unify skip_ioresource_align()
On Wed, 30 Sep 2015, Yinghai Lu wrote: > There are powerpc generic version and x86 local version for > skip_ioresource_align(). > > Move the powerpc version to setup-bus.c, and kill x86 local version. > > Also kill dummy version in microblaze. > > Cc: Michal Simek> Cc: Paul Mackerras > Cc: Michael Ellerman > Cc: Arnd Bergmann > Cc: linuxppc-dev@lists.ozlabs.org > Cc: linux-a...@vger.kernel.org > Signed-off-by: Yinghai Lu Reviewed-by: Thomas Gleixner ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 3/3] gianfar: Add WAKE_UCAST and "wake-on-filer" support
This enables eTSEC's filer (Rx parser) and the FGPI Rx interrupt (Filer General Purpose Interrupt) as a wakeup source event. Upon entering suspend state, the eTSEC filer is given a rule to match incoming L2 unicast packets. A packet matching the rule will be enqueued in the Rx ring and a FGPI Rx interrupt will be asserted by the filer to wakeup the system. Other packet types will be dropped. On resume the filer table is restored to the content before entering suspend state. The set of rules from gfar_filer_config_wol() could be extended to implement other WoL capabilities as well. The "fsl,wake-on-filer" DT binding enables this capability on certain platforms that feature the necessary power management infrastructure, targeting mainly printing and imaging applications. (refer to Power Management section of the SoC Ref Man) Cc: Li YangCc: Zhao Chenhui Signed-off-by: Claudiu Manoil --- drivers/net/ethernet/freescale/gianfar.c | 155 +-- drivers/net/ethernet/freescale/gianfar.h | 12 +- drivers/net/ethernet/freescale/gianfar_ethtool.c | 43 +-- 3 files changed, 186 insertions(+), 24 deletions(-) diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c index 710715f..7f5389c 100644 --- a/drivers/net/ethernet/freescale/gianfar.c +++ b/drivers/net/ethernet/freescale/gianfar.c @@ -907,6 +907,9 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev) if (of_find_property(np, "fsl,magic-packet", NULL)) priv->device_flags |= FSL_GIANFAR_DEV_HAS_MAGIC_PACKET; + if (of_get_property(np, "fsl,wake-on-filer", NULL)) + priv->device_flags |= FSL_GIANFAR_DEV_HAS_WAKE_ON_FILER; + priv->phy_node = of_parse_phandle(np, "phy-handle", 0); /* In the case of a fixed PHY, the DT node associated @@ -1415,8 +1418,14 @@ static int gfar_probe(struct platform_device *ofdev) goto register_fail; } - device_set_wakeup_capable(>dev, priv->device_flags & - FSL_GIANFAR_DEV_HAS_MAGIC_PACKET); + if (priv->device_flags & FSL_GIANFAR_DEV_HAS_MAGIC_PACKET) + priv->wol_supported |= GFAR_WOL_MAGIC; + + if ((priv->device_flags & FSL_GIANFAR_DEV_HAS_WAKE_ON_FILER) && + priv->rx_filer_enable) + priv->wol_supported |= GFAR_WOL_FILER_UCAST; + + device_set_wakeup_capable(>dev, priv->wol_supported); /* fill out IRQ number and name fields */ for (i = 0; i < priv->num_grps; i++) { @@ -1479,15 +1488,122 @@ static int gfar_remove(struct platform_device *ofdev) #ifdef CONFIG_PM +static void __gfar_filer_disable(struct gfar_private *priv) +{ + struct gfar __iomem *regs = priv->gfargrp[0].regs; + u32 temp; + + temp = gfar_read(>rctrl); + temp &= ~(RCTRL_FILREN | RCTRL_PRSDEP_INIT); + gfar_write(>rctrl, temp); +} + +static void __gfar_filer_enable(struct gfar_private *priv) +{ + struct gfar __iomem *regs = priv->gfargrp[0].regs; + u32 temp; + + temp = gfar_read(>rctrl); + temp |= RCTRL_FILREN | RCTRL_PRSDEP_INIT; + gfar_write(>rctrl, temp); +} + +/* Filer rules implementing wol capabilities */ +static void gfar_filer_config_wol(struct gfar_private *priv) +{ + unsigned int i; + u32 rqfcr; + + __gfar_filer_disable(priv); + + /* clear the filer table, reject any packet by default */ + rqfcr = RQFCR_RJE | RQFCR_CMP_MATCH; + for (i = 0; i <= MAX_FILER_IDX; i++) + gfar_write_filer(priv, i, rqfcr, 0); + + i = 0; + if (priv->wol_opts & GFAR_WOL_FILER_UCAST) { + /* unicast packet, accept it */ + struct net_device *ndev = priv->ndev; + /* get the default rx queue index */ + u8 qindex = (u8)priv->gfargrp[0].rx_queue->qindex; + u32 dest_mac_addr = (ndev->dev_addr[0] << 16) | + (ndev->dev_addr[1] << 8) | +ndev->dev_addr[2]; + + rqfcr = (qindex << 10) | RQFCR_AND | + RQFCR_CMP_EXACT | RQFCR_PID_DAH; + + gfar_write_filer(priv, i++, rqfcr, dest_mac_addr); + + dest_mac_addr = (ndev->dev_addr[3] << 16) | + (ndev->dev_addr[4] << 8) | +ndev->dev_addr[5]; + rqfcr = (qindex << 10) | RQFCR_GPI | + RQFCR_CMP_EXACT | RQFCR_PID_DAL; + gfar_write_filer(priv, i++, rqfcr, dest_mac_addr); + } + + __gfar_filer_enable(priv); +} + +static void gfar_filer_restore_table(struct gfar_private *priv) +{ + u32 rqfcr, rqfpr; + unsigned int i; + + __gfar_filer_disable(priv); + + for (i = 0; i <= MAX_FILER_IDX; i++) { + rqfcr
Re: [RFC v2 4/7] powerpc: atomic: Implement xchg_* and atomic{,64}_xchg_* variants
On Wed, Sep 16, 2015 at 11:49:32PM +0800, Boqun Feng wrote: > Implement xchg_relaxed and define atomic{,64}_xchg_* as xchg_relaxed, > based on these _relaxed variants, release/acquire variants can be built. > > Note that xchg_relaxed and atomic_{,64}_xchg_relaxed are not compiler > barriers. Hmm, and I note your previous patch creating the regular _relaxed thingies also removes the memory clobber. And looking at the ARM _relaxed patch from Will, I see their _relaxed ops are also not a compiler barrier. I must say I'm somewhat surprised by this level of relaxation, I had expected to only loose SMP barriers, not the program order ones. Is there a good argument for this? ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [RFC v2 6/7] powerpc: atomic: Make atomic{,64}_xchg and xchg a full barrier
On Wed, Sep 16, 2015 at 11:49:34PM +0800, Boqun Feng wrote: > According to memory-barriers.txt, xchg and its atomic{,64}_ versions > need to imply a full barrier, however they are now just RELEASE+ACQUIRE, > which is not a full barrier. > > So remove the definition of xchg(), and let __atomic_op_fence() build > the full-barrier versions of these operations. Do you want to do a patch for -stable fixing the current implementation? ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [RFC v2 5/7] powerpc: atomic: Implement cmpxchg{,64}_* and atomic{,64}_cmpxchg_* variants
On Thu, Oct 01, 2015 at 02:27:15PM +0200, Peter Zijlstra wrote: > On Wed, Sep 16, 2015 at 11:49:33PM +0800, Boqun Feng wrote: > > Unlike other atomic operation variants, cmpxchg{,64}_acquire and > > atomic{,64}_cmpxchg_acquire don't have acquire semantics if the cmp part > > fails, so we need to implement these using assembly. > > I think that is actually expected and documented. That is, a cmpxchg > only implies barriers on success. See: > > ed2de9f74ecb ("locking/Documentation: Clarify failed cmpxchg() memory > ordering semantics") Also: 654672d4ba1a6 (Will Deacon 2015-08-06 17:54:37 +0100 28) * store portion of the operation. Note that a failed cmpxchg_acquire 654672d4ba1a6 (Will Deacon 2015-08-06 17:54:37 +0100 29) * does -not- imply any memory ordering constraints. ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 2/3] powerpc: dts: p1022si: Add fsl,wake-on-filer for eTSEC
Enable the "wake-on-filer" (aka. wake on user defined packet) wake on lan capability for the eTSEC ethernet nodes. Cc: Li YangCc: Zhao Chenhui Signed-off-by: Claudiu Manoil --- arch/powerpc/boot/dts/fsl/p1022si-post.dtsi | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/powerpc/boot/dts/fsl/p1022si-post.dtsi b/arch/powerpc/boot/dts/fsl/p1022si-post.dtsi index 426bf41..5f51b7b 100644 --- a/arch/powerpc/boot/dts/fsl/p1022si-post.dtsi +++ b/arch/powerpc/boot/dts/fsl/p1022si-post.dtsi @@ -224,10 +224,12 @@ /include/ "pq3-etsec2-0.dtsi" enet0: enet0_grp2: ethernet@b { + fsl,wake-on-filer; }; /include/ "pq3-etsec2-1.dtsi" enet1: enet1_grp2: ethernet@b1000 { + fsl,wake-on-filer; }; global-utilities@e { -- 1.7.11.7 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 1/3] doc: dt: net: Add fsl,wake-on-filer for eTSEC
Add the "fsl,wake-on-filer" property for eTSEC nodes to indicate that the system has the power management infrastructure needed to be able to wake up the system via FGPI (filer, aka. h/w rx parser) interrupt. Cc: Li YangCc: Zhao Chenhui Signed-off-by: Claudiu Manoil --- Documentation/devicetree/bindings/net/fsl-tsec-phy.txt | 4 1 file changed, 4 insertions(+) diff --git a/Documentation/devicetree/bindings/net/fsl-tsec-phy.txt b/Documentation/devicetree/bindings/net/fsl-tsec-phy.txt index 1e97532..db74f0d 100644 --- a/Documentation/devicetree/bindings/net/fsl-tsec-phy.txt +++ b/Documentation/devicetree/bindings/net/fsl-tsec-phy.txt @@ -57,6 +57,10 @@ Properties: "rgmii-id", as all other connection types are detected by hardware. - fsl,magic-packet : If present, indicates that the hardware supports waking up via magic packet. + - fsl,wake-on-filer : If present, indicates that the hardware supports +waking up by Filer General Purpose Interrupt (FGPI) asserted on the +Rx int line. This is an advanced power management capability allowing +certain packet types (user) defined by filer rules to wake up the system. - bd-stash : If present, indicates that the hardware supports stashing buffer descriptors in the L2. - rx-stash-len : Denotes the number of bytes of a received buffer to stash -- 1.7.11.7 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [RFC v2 5/7] powerpc: atomic: Implement cmpxchg{,64}_* and atomic{,64}_cmpxchg_* variants
On Wed, Sep 16, 2015 at 11:49:33PM +0800, Boqun Feng wrote: > Unlike other atomic operation variants, cmpxchg{,64}_acquire and > atomic{,64}_cmpxchg_acquire don't have acquire semantics if the cmp part > fails, so we need to implement these using assembly. I think that is actually expected and documented. That is, a cmpxchg only implies barriers on success. See: ed2de9f74ecb ("locking/Documentation: Clarify failed cmpxchg() memory ordering semantics") ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [RFC v2 5/7] powerpc: atomic: Implement cmpxchg{,64}_* and atomic{,64}_cmpxchg_* variants
On Thu, Oct 01, 2015 at 02:36:26PM +0200, Peter Zijlstra wrote: > On Thu, Oct 01, 2015 at 02:27:15PM +0200, Peter Zijlstra wrote: > > On Wed, Sep 16, 2015 at 11:49:33PM +0800, Boqun Feng wrote: > > > Unlike other atomic operation variants, cmpxchg{,64}_acquire and > > > atomic{,64}_cmpxchg_acquire don't have acquire semantics if the cmp part > > > fails, so we need to implement these using assembly. > > > > I think that is actually expected and documented. That is, a cmpxchg > > only implies barriers on success. See: > > > > ed2de9f74ecb ("locking/Documentation: Clarify failed cmpxchg() memory > > ordering semantics") > > Also: > > 654672d4ba1a6 (Will Deacon 2015-08-06 17:54:37 +0100 28) * store > portion of the operation. Note that a failed cmpxchg_acquire > 654672d4ba1a6 (Will Deacon 2015-08-06 17:54:37 +0100 29) * does -not- > imply any memory ordering constraints. What C11 does is to allow the developer to specify different orderings on success and failure. But it is no harder to supply a barrier (if needed) on the failure path, right? Thanx, Paul ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH V2 19/31] powerpc/mm: Convert 4k hash insert to C
On 10/01/2015 01:48 AM, Benjamin Herrenschmidt wrote: > On Wed, 2015-09-30 at 17:37 +0530, Anshuman Khandual wrote: >>> + if (unlikely(old_pte & _PAGE_BUSY)) >>> + return 0; >>> + /* If PTE permissions don't match, take page fault */ >> >> We are already in page fault interrupt path, will it be better >> if we call it "take Linux page fault" instead as we will go back >> walking the page table. > > A better wording would be "escalate the page fault" Right. There is one more thing. hash_page_mm function can have these following return values after completion. /* Result code is: * 0 - handled * 1 - normal page fault---> Escalate into linux page fault * -1 - critical hash insertion error * -2 - access not permitted by subpage protection mechanism */ -2 is returned after looking into the sub page protection bits. 0 is returned when hash page insert succeeds - ppc_md.hpte_insert returns actual slot number - Multiple retries after ppc_md.hpte_insert returns -1 indicating that HPTEG is full and try secondary hash 1 is returned when PTE in the page table does not contain PFN -1 is returned when hash page did not succeed - ppc_md.hpte_insert returns -2 when it cannot insert HPTE The point is, there are multiple combinations of (0, 1, -1, -2) out there in various paths without much documentation which can be cleaned up. Not in this series but may be later. ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH v4 17/32] cxlflash: Remove dual port online dependency
> On Sep 30, 2015, at 6:50 PM, Daniel Axtenswrote: > (resending to the list this time, apologies!) > >>> I'm not sure I fully understand the flow of this function, but it looks >>> like you set rc=0 regardless of how things actually go: is this ever >>> going to print a return value other than zero? >> >> Correct, this function behaves more like a void for the time being. The >> overall goal of this is to allow a card to configure even when the link is >> down. At some later point when the link is transitioned to 'up', a link state >> change interrupt will trigger the port configuration. I left this with a >> return >> code for right now in case we need to alter the behavior again (based >> upon testing) and actually return a value other than 0. > > OK. That makes more sense - it wasn't clear to me how it could be > correct to proceed if the links were down but now I understand how that > works. I think that explanation should go in the commit message. > if (!wait_port_online(fc_regs, FC_PORT_STATUS_RETRY_INTERVAL_US, FC_PORT_STATUS_RETRY_CNT)) { pr_debug("%s: wait on port %d to go online timed out\n", __func__, port); > > As an aside, should this be a bit noisier? It seems like something > a user would probably want to know - especially in the case where > something has actually gone wrong so there's no link state change > interrupt forthcoming regardless of how long you wait. You bring up a good point. There is another place where we are noisier with respect to the link being down, so we'll do the same here. I'll include this in v5 along with an updated commit message as requested. ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [RFC v2 4/7] powerpc: atomic: Implement xchg_* and atomic{,64}_xchg_* variants
On Thu, Oct 01, 2015 at 02:24:40PM +0200, Peter Zijlstra wrote: > On Wed, Sep 16, 2015 at 11:49:32PM +0800, Boqun Feng wrote: > > Implement xchg_relaxed and define atomic{,64}_xchg_* as xchg_relaxed, > > based on these _relaxed variants, release/acquire variants can be built. > > > > Note that xchg_relaxed and atomic_{,64}_xchg_relaxed are not compiler > > barriers. > > Hmm, and I note your previous patch creating the regular _relaxed > thingies also removes the memory clobber. > > And looking at the ARM _relaxed patch from Will, I see their _relaxed > ops are also not a compiler barrier. > > I must say I'm somewhat surprised by this level of relaxation, I had > expected to only loose SMP barriers, not the program order ones. > > Is there a good argument for this? Yes, when we say "relaxed", we really mean relaxed. ;-) Both the CPU and the compiler are allowed to reorder around relaxed operations. Thanx, Paul ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [RFC v2 5/7] powerpc: atomic: Implement cmpxchg{,64}_* and atomic{,64}_cmpxchg_* variants
On Thu, Oct 01, 2015 at 02:36:26PM +0200, Peter Zijlstra wrote: > On Thu, Oct 01, 2015 at 02:27:15PM +0200, Peter Zijlstra wrote: > > On Wed, Sep 16, 2015 at 11:49:33PM +0800, Boqun Feng wrote: > > > Unlike other atomic operation variants, cmpxchg{,64}_acquire and > > > atomic{,64}_cmpxchg_acquire don't have acquire semantics if the cmp part > > > fails, so we need to implement these using assembly. > > > > I think that is actually expected and documented. That is, a cmpxchg > > only implies barriers on success. See: > > > > ed2de9f74ecb ("locking/Documentation: Clarify failed cmpxchg() memory > > ordering semantics") > > Also: > > 654672d4ba1a6 (Will Deacon 2015-08-06 17:54:37 +0100 28) * store > portion of the operation. Note that a failed cmpxchg_acquire > 654672d4ba1a6 (Will Deacon 2015-08-06 17:54:37 +0100 29) * does -not- > imply any memory ordering constraints. Agreed, no need for ordering on failed cmpxchg. Thanx, Paul ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v5 32/34] cxlflash: Fix to avoid potential deadlock on EEH
Ioctl threads that use scsi_execute() can run for an excessive amount of time due to the fact that they have lengthy timeouts and retry logic built in. Under normal operation this is not an issue. However, once EEH enters the picture, a long execution time coupled with the possibility that a timeout can trigger entry to the driver via registered reset callbacks becomes a liability. In particular, a deadlock can occur when an EEH event is encountered while in running in scsi_execute(). As part of the recovery, the EEH handler drains all currently running ioctls, waiting until they have completed before proceeding with a reset. As the scsi_execute()'s are situated on the ioctl path, the EEH handler will wait until they (and the remainder of the ioctl handler they're associated with) have completed. Normally this would not be much of an issue aside from the longer recovery period. Unfortunately, the scsi_execute() triggers a reset when it times out. The reset handler will see that the device is already being reset and wait until that reset completed. This creates a condition where the EEH handler becomes stuck, infinitely waiting for the ioctl thread to complete. To avoid this behavior, temporarily unmark the scsi_execute() threads as an ioctl thread by releasing the ioctl read semaphore. This allows the EEH handler to proceed with a recovery while the thread is still running. Once the scsi_execute() returns, the ioctl read semaphore is reacquired and the adapter state is rechecked in case it changed while inside of scsi_execute(). The state check will wait if the adapter is still being recovered or returns a failure if the recovery failed. In the event that the adapter reset failed, the failure is simply returned as the ioctl would be unable to continue. Reported-by: Brian KingSigned-off-by: Matthew R. Ochs Signed-off-by: Manoj N. Kumar Reviewed-by: Brian King Reviewed-by: Daniel Axtens --- drivers/scsi/cxlflash/superpipe.c | 30 +- drivers/scsi/cxlflash/superpipe.h | 2 ++ drivers/scsi/cxlflash/vlun.c | 29 + 3 files changed, 60 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/cxlflash/superpipe.c b/drivers/scsi/cxlflash/superpipe.c index f625e07..8af7cdc 100644 --- a/drivers/scsi/cxlflash/superpipe.c +++ b/drivers/scsi/cxlflash/superpipe.c @@ -283,6 +283,24 @@ out: * @sdev: SCSI device associated with LUN. * @lli: LUN destined for capacity request. * + * The READ_CAP16 can take quite a while to complete. Should an EEH occur while + * in scsi_execute(), the EEH handler will attempt to recover. As part of the + * recovery, the handler drains all currently running ioctls, waiting until they + * have completed before proceeding with a reset. As this routine is used on the + * ioctl path, this can create a condition where the EEH handler becomes stuck, + * infinitely waiting for this ioctl thread. To avoid this behavior, temporarily + * unmark this thread as an ioctl thread by releasing the ioctl read semaphore. + * This will allow the EEH handler to proceed with a recovery while this thread + * is still running. Once the scsi_execute() returns, reacquire the ioctl read + * semaphore and check the adapter state in case it changed while inside of + * scsi_execute(). The state check will wait if the adapter is still being + * recovered or return a failure if the recovery failed. In the event that the + * adapter reset failed, simply return the failure as the ioctl would be unable + * to continue. + * + * Note that the above puts a requirement on this routine to only be called on + * an ioctl thread. + * * Return: 0 on success, -errno on failure */ static int read_cap16(struct scsi_device *sdev, struct llun_info *lli) @@ -314,8 +332,18 @@ retry: dev_dbg(dev, "%s: %ssending cmd(0x%x)\n", __func__, retry_cnt ? "re" : "", scsi_cmd[0]); + /* Drop the ioctl read semahpore across lengthy call */ + up_read(>ioctl_rwsem); result = scsi_execute(sdev, scsi_cmd, DMA_FROM_DEVICE, cmd_buf, CMD_BUFSIZE, sense_buf, to, CMD_RETRIES, 0, NULL); + down_read(>ioctl_rwsem); + rc = check_state(cfg); + if (rc) { + dev_err(dev, "%s: Failed state! result=0x08%X\n", + __func__, result); + rc = -ENODEV; + goto out; + } if (driver_byte(result) == DRIVER_SENSE) { result &= ~(0xFF<<24); /* DRIVER_SENSE is not an error */ @@ -1221,7 +1249,7 @@ static const struct file_operations null_fops = { * * Return: 0 on success, -errno on failure */ -static int check_state(struct cxlflash_cfg *cfg) +int check_state(struct cxlflash_cfg *cfg) { struct device *dev = >dev->dev; int rc = 0; diff --git
[PATCH v5 34/34] cxlflash: Fix to escalate to LINK_RESET on login timeout
From: Manoj KumarA 'login timed out' asynchronous error interrupt is generated if no response is seen to a FLOGI within 2 seconds. If the time out error is not escalated to a LINK_RESET the port will not be available for use. This fix provides the required escalation. Signed-off-by: Manoj N. Kumar --- drivers/scsi/cxlflash/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c index c152703..afaf533 100644 --- a/drivers/scsi/cxlflash/main.c +++ b/drivers/scsi/cxlflash/main.c @@ -1100,7 +1100,7 @@ static const struct asyc_intr_info ainfo[] = { {SISL_ASTATUS_FC0_OTHER, "other error", 0, CLR_FC_ERROR | LINK_RESET}, {SISL_ASTATUS_FC0_LOGO, "target initiated LOGO", 0, 0}, {SISL_ASTATUS_FC0_CRC_T, "CRC threshold exceeded", 0, LINK_RESET}, - {SISL_ASTATUS_FC0_LOGI_R, "login timed out, retrying", 0, 0}, + {SISL_ASTATUS_FC0_LOGI_R, "login timed out, retrying", 0, LINK_RESET}, {SISL_ASTATUS_FC0_LOGI_F, "login failed", 0, CLR_FC_ERROR}, {SISL_ASTATUS_FC0_LOGI_S, "login succeeded", 0, SCAN_HOST}, {SISL_ASTATUS_FC0_LINK_DN, "link down", 0, 0}, -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v5 07/34] cxlflash: Fix context encode mask width
The context encode mask covers more than 32-bits, making it a long integer. This should be noted by appending the ULL width suffix to the mask. Signed-off-by: Matthew R. OchsSigned-off-by: Manoj N. Kumar Reviewed-by: Brian King Reviewed-by: Daniel Axtens --- drivers/scsi/cxlflash/superpipe.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/cxlflash/superpipe.h b/drivers/scsi/cxlflash/superpipe.h index 72d53cf..7947091 100644 --- a/drivers/scsi/cxlflash/superpipe.h +++ b/drivers/scsi/cxlflash/superpipe.h @@ -87,7 +87,7 @@ enum ctx_ctrl { CTX_CTRL_FILE = (1 << 5) }; -#define ENCODE_CTXID(_ctx, _id)(u64)_ctx) & 0x0) << 28) | _id) +#define ENCODE_CTXID(_ctx, _id)(u64)_ctx) & 0x0ULL) << 28) | _id) #define DECODE_CTXID(_val) (_val & 0x) struct ctx_info { -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v5 14/34] cxlflash: Fix location of setting resid
The resid is incorrectly set which can lead to unnecessary retry attempts by the stack. This is due to resid _always_ being set using a value returned from the adapter. Instead, the value should only be interpreted and set when in an underrun scenario. Signed-off-by: Matthew R. OchsSigned-off-by: Manoj N. Kumar Reviewed-by: Brian King --- drivers/scsi/cxlflash/main.c | 20 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c index 110037d..5503a40 100644 --- a/drivers/scsi/cxlflash/main.c +++ b/drivers/scsi/cxlflash/main.c @@ -107,6 +107,7 @@ static void process_cmd_err(struct afu_cmd *cmd, struct scsi_cmnd *scp) { struct sisl_ioarcb *ioarcb; struct sisl_ioasa *ioasa; + u32 resid; if (unlikely(!cmd)) return; @@ -115,9 +116,10 @@ static void process_cmd_err(struct afu_cmd *cmd, struct scsi_cmnd *scp) ioasa = &(cmd->sa); if (ioasa->rc.flags & SISL_RC_FLAGS_UNDERRUN) { - pr_debug("%s: cmd underrun cmd = %p scp = %p\n", -__func__, cmd, scp); - scp->result = (DID_ERROR << 16); + resid = ioasa->resid; + scsi_set_resid(scp, resid); + pr_debug("%s: cmd underrun cmd = %p scp = %p, resid = %d\n", +__func__, cmd, scp, resid); } if (ioasa->rc.flags & SISL_RC_FLAGS_OVERRUN) { @@ -158,8 +160,7 @@ static void process_cmd_err(struct afu_cmd *cmd, struct scsi_cmnd *scp) /* If the SISL_RC_FLAGS_OVERRUN flag was set, * then we will handle this error else where. * If not then we must handle it here. -* This is probably an AFU bug. We will -* attempt a retry to see if that resolves it. +* This is probably an AFU bug. */ scp->result = (DID_ERROR << 16); } @@ -183,7 +184,7 @@ static void process_cmd_err(struct afu_cmd *cmd, struct scsi_cmnd *scp) /* We have an AFU error */ switch (ioasa->rc.afu_rc) { case SISL_AFU_RC_NO_CHANNELS: - scp->result = (DID_MEDIUM_ERROR << 16); + scp->result = (DID_NO_CONNECT << 16); break; case SISL_AFU_RC_DATA_DMA_ERR: switch (ioasa->afu_extra) { @@ -217,7 +218,6 @@ static void process_cmd_err(struct afu_cmd *cmd, struct scsi_cmnd *scp) static void cmd_complete(struct afu_cmd *cmd) { struct scsi_cmnd *scp; - u32 resid; ulong lock_flags; struct afu *afu = cmd->parent; struct cxlflash_cfg *cfg = afu->parent; @@ -229,14 +229,11 @@ static void cmd_complete(struct afu_cmd *cmd) if (cmd->rcb.scp) { scp = cmd->rcb.scp; - if (unlikely(cmd->sa.rc.afu_rc || -cmd->sa.rc.scsi_rc || -cmd->sa.rc.fc_rc)) + if (unlikely(cmd->sa.ioasc)) process_cmd_err(cmd, scp); else scp->result = (DID_OK << 16); - resid = cmd->sa.resid; cmd_is_tmf = cmd->cmd_tmf; cmd_checkin(cmd); /* Don't use cmd after here */ @@ -244,7 +241,6 @@ static void cmd_complete(struct afu_cmd *cmd) "ioasc=%d\n", __func__, scp, scp->result, cmd->sa.ioasc); - scsi_set_resid(scp, resid); scsi_dma_unmap(scp); scp->scsi_done(scp); -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v5 13/34] cxlflash: Fix to avoid stall while waiting on TMF
Borrowing the TMF waitq's spinlock causes a stall condition when waiting for the TMF to complete. To remedy, introduce our own spin lock to serialize TMF and use the appropriate wait services. Also add a timeout while waiting for a TMF completion. When a TMF times out, report back a failure such that a bigger hammer reset can occur. Signed-off-by: Matthew R. OchsSigned-off-by: Manoj N. Kumar Reviewed-by: Brian King --- drivers/scsi/cxlflash/common.h | 1 + drivers/scsi/cxlflash/main.c | 55 +- 2 files changed, 34 insertions(+), 22 deletions(-) diff --git a/drivers/scsi/cxlflash/common.h b/drivers/scsi/cxlflash/common.h index b038ac7..7a0cb5c 100644 --- a/drivers/scsi/cxlflash/common.h +++ b/drivers/scsi/cxlflash/common.h @@ -124,6 +124,7 @@ struct cxlflash_cfg { struct list_head lluns; /* list of llun_info structs */ wait_queue_head_t tmf_waitq; + spinlock_t tmf_slock; bool tmf_active; wait_queue_head_t reset_waitq; enum cxlflash_state state; diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c index 527ff85..110037d 100644 --- a/drivers/scsi/cxlflash/main.c +++ b/drivers/scsi/cxlflash/main.c @@ -249,11 +249,10 @@ static void cmd_complete(struct afu_cmd *cmd) scp->scsi_done(scp); if (cmd_is_tmf) { - spin_lock_irqsave(>tmf_waitq.lock, lock_flags); + spin_lock_irqsave(>tmf_slock, lock_flags); cfg->tmf_active = false; wake_up_all_locked(>tmf_waitq); - spin_unlock_irqrestore(>tmf_waitq.lock, - lock_flags); + spin_unlock_irqrestore(>tmf_slock, lock_flags); } } else complete(>cevent); @@ -420,6 +419,7 @@ static int send_tmf(struct afu *afu, struct scsi_cmnd *scp, u64 tmfcmd) struct device *dev = >dev->dev; ulong lock_flags; int rc = 0; + ulong to; cmd = cmd_checkout(afu); if (unlikely(!cmd)) { @@ -428,15 +428,15 @@ static int send_tmf(struct afu *afu, struct scsi_cmnd *scp, u64 tmfcmd) goto out; } - /* If a Task Management Function is active, do not send one more. -*/ - spin_lock_irqsave(>tmf_waitq.lock, lock_flags); + /* When Task Management Function is active do not send another */ + spin_lock_irqsave(>tmf_slock, lock_flags); if (cfg->tmf_active) - wait_event_interruptible_locked_irq(cfg->tmf_waitq, - !cfg->tmf_active); + wait_event_interruptible_lock_irq(cfg->tmf_waitq, + !cfg->tmf_active, + cfg->tmf_slock); cfg->tmf_active = true; cmd->cmd_tmf = true; - spin_unlock_irqrestore(>tmf_waitq.lock, lock_flags); + spin_unlock_irqrestore(>tmf_slock, lock_flags); cmd->rcb.ctx_id = afu->ctx_hndl; cmd->rcb.port_sel = port_sel; @@ -457,15 +457,24 @@ static int send_tmf(struct afu *afu, struct scsi_cmnd *scp, u64 tmfcmd) rc = send_cmd(afu, cmd); if (unlikely(rc)) { cmd_checkin(cmd); - spin_lock_irqsave(>tmf_waitq.lock, lock_flags); + spin_lock_irqsave(>tmf_slock, lock_flags); cfg->tmf_active = false; - spin_unlock_irqrestore(>tmf_waitq.lock, lock_flags); + spin_unlock_irqrestore(>tmf_slock, lock_flags); goto out; } - spin_lock_irqsave(>tmf_waitq.lock, lock_flags); - wait_event_interruptible_locked_irq(cfg->tmf_waitq, !cfg->tmf_active); - spin_unlock_irqrestore(>tmf_waitq.lock, lock_flags); + spin_lock_irqsave(>tmf_slock, lock_flags); + to = msecs_to_jiffies(5000); + to = wait_event_interruptible_lock_irq_timeout(cfg->tmf_waitq, + !cfg->tmf_active, + cfg->tmf_slock, + to); + if (!to) { + cfg->tmf_active = false; + dev_err(dev, "%s: TMF timed out!\n", __func__); + rc = -1; + } + spin_unlock_irqrestore(>tmf_slock, lock_flags); out: return rc; } @@ -512,16 +521,17 @@ static int cxlflash_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scp) get_unaligned_be32(&((u32 *)scp->cmnd)[2]), get_unaligned_be32(&((u32 *)scp->cmnd)[3])); - /* If a Task Management Function is active, wait for it to complete + /* +* If a Task Management Function is active, wait for it to complete *
[PATCH v5 19/34] cxlflash: Correct usage of scsi_host_put()
Currently, scsi_host_put() is being called prematurely in the remove path and is missing entirely in an error cleanup path. The former can lead to memory being freed too early with subsequent access potentially corrupting data whilst the former would result in a memory leak. Move the usage on remove to be the last cleanup action taken and introduce a call to scsi_host_put() in the one initialization error path that does not use remove to cleanup. Signed-off-by: Matthew R. OchsSigned-off-by: Manoj N. Kumar Reviewed-by: Brian King --- drivers/scsi/cxlflash/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c index c1d5c88..6b8b159 100644 --- a/drivers/scsi/cxlflash/main.c +++ b/drivers/scsi/cxlflash/main.c @@ -733,7 +733,6 @@ static void cxlflash_remove(struct pci_dev *pdev) case INIT_STATE_SCSI: cxlflash_term_local_luns(cfg); scsi_remove_host(cfg->host); - scsi_host_put(cfg->host); /* Fall through */ case INIT_STATE_AFU: term_afu(cfg); @@ -743,6 +742,7 @@ static void cxlflash_remove(struct pci_dev *pdev) case INIT_STATE_NONE: flush_work(>work_q); free_mem(cfg); + scsi_host_put(cfg->host); break; } @@ -2404,6 +2404,7 @@ static int cxlflash_probe(struct pci_dev *pdev, dev_err(>dev, "%s: call to scsi_host_alloc failed!\n", __func__); rc = -ENOMEM; + scsi_host_put(cfg->host); goto out; } -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v5 31/34] cxlflash: Correct trace string
The trace following the failure of alloc_mem() incorrectly identifies which function failed. This can lead to misdiagnosing a failure. Fix the string to correctly indicate that alloc_mem() failed. Reported-by: Brian KingSigned-off-by: Matthew R. Ochs Signed-off-by: Manoj N. Kumar Reviewed-by: Brian King Reviewed-by: Andrew Donnellan --- drivers/scsi/cxlflash/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c index 3f43879..998373e 100644 --- a/drivers/scsi/cxlflash/main.c +++ b/drivers/scsi/cxlflash/main.c @@ -2377,7 +2377,7 @@ static int cxlflash_probe(struct pci_dev *pdev, cfg->host = host; rc = alloc_mem(cfg); if (rc) { - dev_err(>dev, "%s: call to scsi_host_alloc failed!\n", + dev_err(>dev, "%s: call to alloc_mem failed!\n", __func__); rc = -ENOMEM; scsi_host_put(cfg->host); -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH v3 1/2] fsl: Add binding for RCPM
On Thu, 2015-10-01 at 12:05 -0500, Yoder Stuart-B08248 wrote: > > +++ b/Documentation/devicetree/bindings/soc/fsl/rcpm.txt > > @@ -0,0 +1,63 @@ > > +* Run Control and Power Management > > +--- > > +The RCPM performs all device-level tasks associated with device run > > control > > +and power management. > > + > > +Required properites: > > + - reg : Offset and length of the register set of RCPM block. > > s/RCPM block/the RCPM block/ > > > + - fsl,#rcpm-wakeup-cells : The number of cells in rcpm-wakeup property. > > s/rcpm-wakeup-property/the rcpm-wakeup-property/ > > > + - compatible : Sould contain a chip-specific RCPM block compatible > > string > > s/Sould/Should > > "Should" means it is recommended, but does not mean "must". Is it really > optional? > > > + and (if applicable) may contain a chassis-version RCPM compatible > > + string. Chip-specific strings are of the form "fsl,-rcpm", > > + such as: > > + * "fsl,p2041-rcpm" > > + * "fsl,p3041-rcpm" > > + * "fsl,p4080-rcpm" > > + * "fsl,p5020-rcpm" > > + * "fsl,p5040-rcpm" > > + * "fsl,t4240-rcpm" > > + * "fsl,b4420-rcpm" > > + * "fsl,b4860-rcpm" > > 2 or 3 examples is enough. > > > + Chassis-version strings are of the form "fsl,qoriq-rcpm- > > ", > > + such as: > > + * "fsl,qoriq-rcpm-1.0": for chassis 1.0 rcpm > > + * "fsl,qoriq-rcpm-2.0": for chassis 2.0 rcpm > > + * "fsl,qoriq-rcpm-2.1": for chassis 2.1 rcpm > > + > > +All references to "1.0" and "2.0" refer to the QorIQ chassis version to > > +which the chip complies. > > +Chassis VersionExample Chips > > +------ > > +1.0p4080, p5020, p5040, p2041, p3041 > > +2.0t4240, b4860, b4420 > > +2.1t1040, ls1021 > > Not sure this binding is the place to maintain a table of chassis > versions to SoCs. This is something I've been encouraging, given that the block versions are not publicly documented. It lets people find a manual that describes the advertised programming interface. -Scott ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH v3 1/3] powerpc/512x: add LocalPlus Bus FIFO device driver
On 09/30/2015 04:24 PM, Alexander Popov wrote: Can you test for "!cs" here instead? +e = -EFAULT; +goto err_param; +} Unfortunately no: 0 is a valid value for Chip Select. Is it OK to leave it like that? Yes. +lpbfifo.ram_bus_addr = sg_dma_address(); /* For freeing later */ +sg_dma_len() = lpbfifo.req->size; I don't think sg_dma_len() is meant to be used as an lvalue. I've double-checked and found many cases of such usage of this macro. It seems that I can't avoid it too. Ok. Driver code that has to parse #address-cells or #size-cells is usually wrong. I would not call it "parsing", I just check whether the dts-file is good. Anyway, could you give me a clue how to do better? You should use of_n_size_cells() and of_n_addr_cells(). -- ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [RFC v2 4/7] powerpc: atomic: Implement xchg_* and atomic{,64}_xchg_* variants
On Thu, Oct 01, 2015 at 08:09:09AM -0700, Paul E. McKenney wrote: > On Thu, Oct 01, 2015 at 02:24:40PM +0200, Peter Zijlstra wrote: > > I must say I'm somewhat surprised by this level of relaxation, I had > > expected to only loose SMP barriers, not the program order ones. > > > > Is there a good argument for this? > > Yes, when we say "relaxed", we really mean relaxed. ;-) > > Both the CPU and the compiler are allowed to reorder around relaxed > operations. Is this documented somewhere, because I completely missed this part. ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v5 05/34] cxlflash: Fix data corruption when vLUN used over multiple cards
If the same virtual LUN is accessed over multiple cards, only accesses made over the first card will be valid. Accesses made over the second card will go to the wrong LUN causing data corruption. This is because the global LUN's mode word was being used to determine whether the LUN table for that card needs to be programmed. The mode word would be setup by the first card, causing the LUN table for the second card to not be programmed. By unconditionally initializing the LUN table (not depending on the mode word), the problem is avoided. Signed-off-by: Matthew R. OchsSigned-off-by: Manoj N. Kumar Reviewed-by: Brian King --- drivers/scsi/cxlflash/vlun.c | 16 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/scsi/cxlflash/vlun.c b/drivers/scsi/cxlflash/vlun.c index 68994c4..96b074f 100644 --- a/drivers/scsi/cxlflash/vlun.c +++ b/drivers/scsi/cxlflash/vlun.c @@ -915,16 +915,9 @@ int cxlflash_disk_virtual_open(struct scsi_device *sdev, void *arg) pr_debug("%s: ctxid=%llu ls=0x%llx\n", __func__, ctxid, lun_size); + /* Setup the LUNs block allocator on first call */ mutex_lock(>mutex); if (gli->mode == MODE_NONE) { - /* Setup the LUN table and block allocator on first call */ - rc = init_luntable(cfg, lli); - if (rc) { - dev_err(dev, "%s: call to init_luntable failed " - "rc=%d!\n", __func__, rc); - goto err0; - } - rc = init_vlun(lli); if (rc) { dev_err(dev, "%s: call to init_vlun failed rc=%d!\n", @@ -942,6 +935,13 @@ int cxlflash_disk_virtual_open(struct scsi_device *sdev, void *arg) } mutex_unlock(>mutex); + rc = init_luntable(cfg, lli); + if (rc) { + dev_err(dev, "%s: call to init_luntable failed rc=%d!\n", + __func__, rc); + goto err1; + } + ctxi = get_context(cfg, rctxid, lli, 0); if (unlikely(!ctxi)) { dev_err(dev, "%s: Bad context! (%llu)\n", __func__, ctxid); -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v5 21/34] cxlflash: Correct behavior in device reset handler following EEH
When the device reset handler is entered while a reset operation is taking place, the handler exits without actually sending a reset (TMF) to the targeted device. This behavior is incorrect as the device is not reset. Further complicating matters is the fact that a success is returned even when the TMF was not sent. To fix, the state is rechecked after coming out of the reset state. When the state is normal, a TMF will be sent out. Signed-off-by: Matthew R. OchsSigned-off-by: Manoj N. Kumar Reviewed-by: Brian King --- drivers/scsi/cxlflash/main.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c index d0b9972..89bd4c3 100644 --- a/drivers/scsi/cxlflash/main.c +++ b/drivers/scsi/cxlflash/main.c @@ -1920,6 +1920,7 @@ static int cxlflash_eh_device_reset_handler(struct scsi_cmnd *scp) get_unaligned_be32(&((u32 *)scp->cmnd)[2]), get_unaligned_be32(&((u32 *)scp->cmnd)[3])); +retry: switch (cfg->state) { case STATE_NORMAL: rcr = send_tmf(afu, scp, TMF_LUN_RESET); @@ -1928,9 +1929,7 @@ static int cxlflash_eh_device_reset_handler(struct scsi_cmnd *scp) break; case STATE_RESET: wait_event(cfg->reset_waitq, cfg->state != STATE_RESET); - if (cfg->state == STATE_NORMAL) - break; - /* fall through */ + goto retry; default: rc = FAILED; break; -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v5 24/34] cxlflash: Fix MMIO and endianness errors
Sparse uncovered several errors with MMIO operations (accessing directly) and handling endianness. These can cause issues when running in different environments. Introduce __iomem and proper endianness tags/swaps where appropriate to make driver sparse clean. Signed-off-by: Matthew R. OchsSigned-off-by: Manoj N. Kumar Reviewed-by: Brian King Reviewed-by: Andrew Donnellan --- drivers/scsi/cxlflash/common.h| 10 +- drivers/scsi/cxlflash/main.c | 25 + drivers/scsi/cxlflash/superpipe.c | 6 +++--- drivers/scsi/cxlflash/superpipe.h | 2 +- drivers/scsi/cxlflash/vlun.c | 4 ++-- 5 files changed, 24 insertions(+), 23 deletions(-) diff --git a/drivers/scsi/cxlflash/common.h b/drivers/scsi/cxlflash/common.h index 3be5754..a810585 100644 --- a/drivers/scsi/cxlflash/common.h +++ b/drivers/scsi/cxlflash/common.h @@ -164,9 +164,9 @@ struct afu { /* AFU HW */ struct cxl_ioctl_start_work work; - struct cxlflash_afu_map *afu_map; /* entire MMIO map */ - struct sisl_host_map *host_map; /* MC host map */ - struct sisl_ctrl_map *ctrl_map; /* MC control map */ + struct cxlflash_afu_map __iomem *afu_map; /* entire MMIO map */ + struct sisl_host_map __iomem *host_map; /* MC host map */ + struct sisl_ctrl_map __iomem *ctrl_map; /* MC control map */ ctx_hndl_t ctx_hndl;/* master's context handle */ u64 *hrrq_start; @@ -188,10 +188,10 @@ struct afu { static inline u64 lun_to_lunid(u64 lun) { - u64 lun_id; + __be64 lun_id; int_to_scsilun(lun, (struct scsi_lun *)_id); - return swab64(lun_id); + return be64_to_cpu(lun_id); } int cxlflash_afu_sync(struct afu *, ctx_hndl_t, res_hndl_t, u8); diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c index f37e968..14fb9b4 100644 --- a/drivers/scsi/cxlflash/main.c +++ b/drivers/scsi/cxlflash/main.c @@ -644,7 +644,7 @@ static void stop_afu(struct cxlflash_cfg *cfg) complete(>cmd[i].cevent); if (likely(afu->afu_map)) { - cxl_psa_unmap((void *)afu->afu_map); + cxl_psa_unmap((void __iomem *)afu->afu_map); afu->afu_map = NULL; } } @@ -914,7 +914,7 @@ out: * that the FC link layer has synced, completed the handshaking process, and * is ready for login to start. */ -static void set_port_online(u64 *fc_regs) +static void set_port_online(__be64 __iomem *fc_regs) { u64 cmdcfg; @@ -930,7 +930,7 @@ static void set_port_online(u64 *fc_regs) * * The provided MMIO region must be mapped prior to call. */ -static void set_port_offline(u64 *fc_regs) +static void set_port_offline(__be64 __iomem *fc_regs) { u64 cmdcfg; @@ -954,7 +954,7 @@ static void set_port_offline(u64 *fc_regs) * FALSE (0) when the specified port fails to come online after timeout * -EINVAL when @delay_us is less than 1000 */ -static int wait_port_online(u64 *fc_regs, u32 delay_us, u32 nretry) +static int wait_port_online(__be64 __iomem *fc_regs, u32 delay_us, u32 nretry) { u64 status; @@ -985,7 +985,7 @@ static int wait_port_online(u64 *fc_regs, u32 delay_us, u32 nretry) * FALSE (0) when the specified port fails to go offline after timeout * -EINVAL when @delay_us is less than 1000 */ -static int wait_port_offline(u64 *fc_regs, u32 delay_us, u32 nretry) +static int wait_port_offline(__be64 __iomem *fc_regs, u32 delay_us, u32 nretry) { u64 status; @@ -1020,7 +1020,8 @@ static int wait_port_offline(u64 *fc_regs, u32 delay_us, u32 nretry) * 0 when the WWPN is successfully written and the port comes back online * -1 when the port fails to go offline or come back up online */ -static int afu_set_wwpn(struct afu *afu, int port, u64 *fc_regs, u64 wwpn) +static int afu_set_wwpn(struct afu *afu, int port, __be64 __iomem *fc_regs, + u64 wwpn) { int rc = 0; @@ -1065,7 +1066,7 @@ static int afu_set_wwpn(struct afu *afu, int port, u64 *fc_regs, u64 wwpn) * the alternate port exclusively while the reset takes place. * failure to come online is overridden. */ -static void afu_link_reset(struct afu *afu, int port, u64 *fc_regs) +static void afu_link_reset(struct afu *afu, int port, __be64 __iomem *fc_regs) { u64 port_sel; @@ -1280,7 +1281,7 @@ static irqreturn_t cxlflash_async_err_irq(int irq, void *data) struct device *dev = >dev->dev; u64 reg_unmasked; const struct asyc_intr_info *info; - struct sisl_global_map *global = >afu_map->global; + struct sisl_global_map __iomem *global = >afu_map->global; u64 reg; u8 port; int i; @@ -1466,7 +1467,7 @@ out: static void
Re: [RFC v2 5/7] powerpc: atomic: Implement cmpxchg{,64}_* and atomic{,64}_cmpxchg_* variants
On Thu, Oct 01, 2015 at 08:12:19AM -0700, Paul E. McKenney wrote: > What C11 does is to allow the developer to specify different orderings > on success and failure. But it is no harder to supply a barrier (if > needed) on the failure path, right? Quite right. ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v5 04/34] cxlflash: Fix potential oops following LUN removal
When a LUN is removed, the sdev that is associated with the LUN remains intact until its reference count drops to 0. In order to prevent an sdev from being removed while a context is still associated with it, obtain an additional reference per-context for each LUN attached to the context. This resolves a potential Oops in the release handler when a dealing with a LUN that has already been removed. Signed-off-by: Matthew R. OchsSigned-off-by: Manoj N. Kumar Reviewed-by: Brian King --- drivers/scsi/cxlflash/superpipe.c | 35 +++ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/drivers/scsi/cxlflash/superpipe.c b/drivers/scsi/cxlflash/superpipe.c index 4e44a48..ffa68cc 100644 --- a/drivers/scsi/cxlflash/superpipe.c +++ b/drivers/scsi/cxlflash/superpipe.c @@ -880,6 +880,9 @@ static int _cxlflash_disk_detach(struct scsi_device *sdev, sys_close(lfd); } + /* Release the sdev reference that bound this LUN to the context */ + scsi_device_put(sdev); + out: if (put_ctx) put_context(ctxi); @@ -1287,11 +1290,17 @@ static int cxlflash_disk_attach(struct scsi_device *sdev, } } + rc = scsi_device_get(sdev); + if (unlikely(rc)) { + dev_err(dev, "%s: Unable to get sdev reference!\n", __func__); + goto out; + } + lun_access = kzalloc(sizeof(*lun_access), GFP_KERNEL); if (unlikely(!lun_access)) { dev_err(dev, "%s: Unable to allocate lun_access!\n", __func__); rc = -ENOMEM; - goto out; + goto err0; } lun_access->lli = lli; @@ -1311,21 +1320,21 @@ static int cxlflash_disk_attach(struct scsi_device *sdev, dev_err(dev, "%s: Could not initialize context %p\n", __func__, ctx); rc = -ENODEV; - goto err0; + goto err1; } ctxid = cxl_process_element(ctx); if (unlikely((ctxid >= MAX_CONTEXT) || (ctxid < 0))) { dev_err(dev, "%s: ctxid (%d) invalid!\n", __func__, ctxid); rc = -EPERM; - goto err1; + goto err2; } file = cxl_get_fd(ctx, >cxl_fops, ); if (unlikely(fd < 0)) { rc = -ENODEV; dev_err(dev, "%s: Could not get file descriptor\n", __func__); - goto err1; + goto err2; } /* Translate read/write O_* flags from fcntl.h to AFU permission bits */ @@ -1335,7 +1344,7 @@ static int cxlflash_disk_attach(struct scsi_device *sdev, if (unlikely(!ctxi)) { dev_err(dev, "%s: Failed to create context! (%d)\n", __func__, ctxid); - goto err2; + goto err3; } work = >work; @@ -1346,13 +1355,13 @@ static int cxlflash_disk_attach(struct scsi_device *sdev, if (unlikely(rc)) { dev_dbg(dev, "%s: Could not start context rc=%d\n", __func__, rc); - goto err3; + goto err4; } rc = afu_attach(cfg, ctxi); if (unlikely(rc)) { dev_err(dev, "%s: Could not attach AFU rc %d\n", __func__, rc); - goto err4; + goto err5; } /* @@ -1388,13 +1397,13 @@ out: __func__, ctxid, fd, attach->block_size, rc, attach->last_lba); return rc; -err4: +err5: cxl_stop_context(ctx); -err3: +err4: put_context(ctxi); destroy_context(cfg, ctxi); ctxi = NULL; -err2: +err3: /* * Here, we're overriding the fops with a dummy all-NULL fops because * fput() calls the release fop, which will cause us to mistakenly @@ -1406,10 +1415,12 @@ err2: fput(file); put_unused_fd(fd); fd = -1; -err1: +err2: cxl_release_context(ctx); -err0: +err1: kfree(lun_access); +err0: + scsi_device_put(sdev); goto out; } -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v5 10/34] cxlflash: Make functions static
Found during code inspection, that the following functions are not being used outside of the file where they are defined. Make them static. int cxlflash_send_cmd(struct afu *, struct afu_cmd *); void cxlflash_wait_resp(struct afu *, struct afu_cmd *); int cxlflash_afu_reset(struct cxlflash_cfg *); struct afu_cmd *cxlflash_cmd_checkout(struct afu *); void cxlflash_cmd_checkin(struct afu_cmd *); void init_pcr(struct cxlflash_cfg *); int init_global(struct cxlflash_cfg *); Signed-off-by: Matthew R. OchsSigned-off-by: Manoj N. Kumar Reviewed-by: Brian King --- drivers/scsi/cxlflash/common.h |5 - drivers/scsi/cxlflash/main.c | 1018 2 files changed, 509 insertions(+), 514 deletions(-) diff --git a/drivers/scsi/cxlflash/common.h b/drivers/scsi/cxlflash/common.h index 11318de..b038ac7 100644 --- a/drivers/scsi/cxlflash/common.h +++ b/drivers/scsi/cxlflash/common.h @@ -192,11 +192,6 @@ static inline u64 lun_to_lunid(u64 lun) return swab64(lun_id); } -int cxlflash_send_cmd(struct afu *, struct afu_cmd *); -void cxlflash_wait_resp(struct afu *, struct afu_cmd *); -int cxlflash_afu_reset(struct cxlflash_cfg *); -struct afu_cmd *cxlflash_cmd_checkout(struct afu *); -void cxlflash_cmd_checkin(struct afu_cmd *); int cxlflash_afu_sync(struct afu *, ctx_hndl_t, res_hndl_t, u8); void cxlflash_list_init(void); void cxlflash_term_global_luns(void); diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c index 8940336..226cefe 100644 --- a/drivers/scsi/cxlflash/main.c +++ b/drivers/scsi/cxlflash/main.c @@ -36,7 +36,7 @@ MODULE_LICENSE("GPL"); /** - * cxlflash_cmd_checkout() - checks out an AFU command + * cmd_checkout() - checks out an AFU command * @afu: AFU to checkout from. * * Commands are checked out in a round-robin fashion. Note that since @@ -47,7 +47,7 @@ MODULE_LICENSE("GPL"); * * Return: The checked out command or NULL when command pool is empty. */ -struct afu_cmd *cxlflash_cmd_checkout(struct afu *afu) +static struct afu_cmd *cmd_checkout(struct afu *afu) { int k, dec = CXLFLASH_NUM_CMDS; struct afu_cmd *cmd; @@ -70,7 +70,7 @@ struct afu_cmd *cxlflash_cmd_checkout(struct afu *afu) } /** - * cxlflash_cmd_checkin() - checks in an AFU command + * cmd_checkin() - checks in an AFU command * @cmd: AFU command to checkin. * * Safe to pass commands that have already been checked in. Several @@ -79,7 +79,7 @@ struct afu_cmd *cxlflash_cmd_checkout(struct afu *afu) * to avoid clobbering values in the event that the command is checked * out right away. */ -void cxlflash_cmd_checkin(struct afu_cmd *cmd) +static void cmd_checkin(struct afu_cmd *cmd) { cmd->rcb.scp = NULL; cmd->rcb.timeout = 0; @@ -238,7 +238,7 @@ static void cmd_complete(struct afu_cmd *cmd) resid = cmd->sa.resid; cmd_is_tmf = cmd->cmd_tmf; - cxlflash_cmd_checkin(cmd); /* Don't use cmd after here */ + cmd_checkin(cmd); /* Don't use cmd after here */ pr_debug("%s: calling scsi_set_resid, scp=%p " "result=%X resid=%d\n", __func__, @@ -260,6 +260,146 @@ static void cmd_complete(struct afu_cmd *cmd) } /** + * context_reset() - timeout handler for AFU commands + * @cmd: AFU command that timed out. + * + * Sends a reset to the AFU. + */ +static void context_reset(struct afu_cmd *cmd) +{ + int nretry = 0; + u64 rrin = 0x1; + u64 room = 0; + struct afu *afu = cmd->parent; + ulong lock_flags; + + pr_debug("%s: cmd=%p\n", __func__, cmd); + + spin_lock_irqsave(>slock, lock_flags); + + /* Already completed? */ + if (cmd->sa.host_use_b[0] & B_DONE) { + spin_unlock_irqrestore(>slock, lock_flags); + return; + } + + cmd->sa.host_use_b[0] |= (B_DONE | B_ERROR | B_TIMEOUT); + spin_unlock_irqrestore(>slock, lock_flags); + + /* +* We really want to send this reset at all costs, so spread +* out wait time on successive retries for available room. +*/ + do { + room = readq_be(>host_map->cmd_room); + atomic64_set(>room, room); + if (room) + goto write_rrin; + udelay(nretry); + } while (nretry++ < MC_ROOM_RETRY_CNT); + + pr_err("%s: no cmd_room to send reset\n", __func__); + return; + +write_rrin: + nretry = 0; + writeq_be(rrin, >host_map->ioarrin); + do { + rrin = readq_be(>host_map->ioarrin); + if (rrin != 0x1) + break; + /* Double delay each time */ + udelay(2 ^ nretry); + } while (nretry++ < MC_ROOM_RETRY_CNT); +} + +/** + * send_cmd() - sends an AFU command + * @afu: AFU associated with the
[PATCH v5 11/34] cxlflash: Refine host/device attributes
Implement the following suggestions and add two new attributes to allow for debugging the port LUN table. - use scnprintf() instead of snprintf() - use DEVICE_ATTR_RO and DEVICE_ATTR_RW Suggested-by: Shane SeymourSigned-off-by: Matthew R. Ochs Signed-off-by: Manoj N. Kumar Reviewed-by: Brian King --- drivers/scsi/cxlflash/main.c | 180 +-- 1 file changed, 138 insertions(+), 42 deletions(-) diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c index 226cefe..b44212b 100644 --- a/drivers/scsi/cxlflash/main.c +++ b/drivers/scsi/cxlflash/main.c @@ -1995,33 +1995,24 @@ static int cxlflash_change_queue_depth(struct scsi_device *sdev, int qdepth) /** * cxlflash_show_port_status() - queries and presents the current port status - * @dev: Generic device associated with the host owning the port. - * @attr: Device attribute representing the port. + * @port: Desired port for status reporting. + * @afu: AFU owning the specified port. * @buf: Buffer of length PAGE_SIZE to report back port status in ASCII. * * Return: The size of the ASCII string returned in @buf. */ -static ssize_t cxlflash_show_port_status(struct device *dev, -struct device_attribute *attr, -char *buf) +static ssize_t cxlflash_show_port_status(u32 port, struct afu *afu, char *buf) { - struct Scsi_Host *shost = class_to_shost(dev); - struct cxlflash_cfg *cfg = (struct cxlflash_cfg *)shost->hostdata; - struct afu *afu = cfg->afu; - char *disp_status; - int rc; - u32 port; u64 status; - u64 *fc_regs; + __be64 __iomem *fc_regs; - rc = kstrtouint((attr->attr.name + 4), 10, ); - if (rc || (port >= NUM_FC_PORTS)) + if (port >= NUM_FC_PORTS) return 0; fc_regs = >afu_map->global.fc_regs[port][0]; - status = - (readq_be(_regs[FC_MTIP_STATUS / 8]) & FC_MTIP_STATUS_MASK); + status = readq_be(_regs[FC_MTIP_STATUS / 8]); + status &= FC_MTIP_STATUS_MASK; if (status == FC_MTIP_STATUS_ONLINE) disp_status = "online"; @@ -2030,31 +2021,69 @@ static ssize_t cxlflash_show_port_status(struct device *dev, else disp_status = "unknown"; - return snprintf(buf, PAGE_SIZE, "%s\n", disp_status); + return scnprintf(buf, PAGE_SIZE, "%s\n", disp_status); +} + +/** + * port0_show() - queries and presents the current status of port 0 + * @dev: Generic device associated with the host owning the port. + * @attr: Device attribute representing the port. + * @buf: Buffer of length PAGE_SIZE to report back port status in ASCII. + * + * Return: The size of the ASCII string returned in @buf. + */ +static ssize_t port0_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct Scsi_Host *shost = class_to_shost(dev); + struct cxlflash_cfg *cfg = (struct cxlflash_cfg *)shost->hostdata; + struct afu *afu = cfg->afu; + + return cxlflash_show_port_status(0, afu, buf); } /** - * cxlflash_show_lun_mode() - presents the current LUN mode of the host + * port1_show() - queries and presents the current status of port 1 + * @dev: Generic device associated with the host owning the port. + * @attr: Device attribute representing the port. + * @buf: Buffer of length PAGE_SIZE to report back port status in ASCII. + * + * Return: The size of the ASCII string returned in @buf. + */ +static ssize_t port1_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct Scsi_Host *shost = class_to_shost(dev); + struct cxlflash_cfg *cfg = (struct cxlflash_cfg *)shost->hostdata; + struct afu *afu = cfg->afu; + + return cxlflash_show_port_status(1, afu, buf); +} + +/** + * lun_mode_show() - presents the current LUN mode of the host * @dev: Generic device associated with the host. - * @attr: Device attribute representing the lun mode. + * @attr: Device attribute representing the LUN mode. * @buf: Buffer of length PAGE_SIZE to report back the LUN mode in ASCII. * * Return: The size of the ASCII string returned in @buf. */ -static ssize_t cxlflash_show_lun_mode(struct device *dev, - struct device_attribute *attr, char *buf) +static ssize_t lun_mode_show(struct device *dev, +struct device_attribute *attr, char *buf) { struct Scsi_Host *shost = class_to_shost(dev); struct cxlflash_cfg *cfg = (struct cxlflash_cfg *)shost->hostdata; struct afu *afu = cfg->afu; - return snprintf(buf, PAGE_SIZE,
[PATCH v5 16/34] cxlflash: Fix async interrupt bypass logic
A bug was introduced earlier in the development cycle when cleaning up logic statements. Instead of skipping bits that are not set, set bits are skipped, causing async interrupts to not be handled correctly. To fix, simply add back in the proper evaluation for an unset bit. Signed-off-by: Matthew R. OchsSigned-off-by: Manoj N. Kumar Reviewed-by: Brian King --- drivers/scsi/cxlflash/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c index 98fdac1..ed9fd8c 100644 --- a/drivers/scsi/cxlflash/main.c +++ b/drivers/scsi/cxlflash/main.c @@ -1315,7 +1315,7 @@ static irqreturn_t cxlflash_async_err_irq(int irq, void *data) /* check each bit that is on */ for (i = 0; reg_unmasked; i++, reg_unmasked = (reg_unmasked >> 1)) { info = find_ainfo(1ULL << i); - if ((reg_unmasked & 0x1) || !info) + if (((reg_unmasked & 0x1) == 0) || !info) continue; port = info->port; -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v5 22/34] cxlflash: Remove unnecessary scsi_block_requests
The host reset handler is called with I/O already blocked, thus there is no need to explicitly block and unblock I/O in the handler. Signed-off-by: Matthew R. OchsSigned-off-by: Manoj N. Kumar Reviewed-by: Brian King --- drivers/scsi/cxlflash/main.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c index 89bd4c3..441e897 100644 --- a/drivers/scsi/cxlflash/main.c +++ b/drivers/scsi/cxlflash/main.c @@ -1966,7 +1966,6 @@ static int cxlflash_eh_host_reset_handler(struct scsi_cmnd *scp) switch (cfg->state) { case STATE_NORMAL: cfg->state = STATE_RESET; - scsi_block_requests(cfg->host); cxlflash_mark_contexts_error(cfg); rcr = afu_reset(cfg); if (rcr) { @@ -1975,7 +1974,6 @@ static int cxlflash_eh_host_reset_handler(struct scsi_cmnd *scp) } else cfg->state = STATE_NORMAL; wake_up_all(>reset_waitq); - scsi_unblock_requests(cfg->host); break; case STATE_RESET: wait_event(cfg->reset_waitq, cfg->state != STATE_RESET); -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v5 26/34] cxlflash: Correct spelling, grammar, and alignment mistakes
There are several spelling and grammar mistakes throughout the driver. Additionally there are a handful of places where there are extra lines and unnecessary variables/statements. These are a nuisance and pollute the driver. Fix spelling and grammar issues. Update some comments for clarity and consistency. Remove extra lines and a few unneeded variables/statements. Signed-off-by: Matthew R. OchsSigned-off-by: Manoj N. Kumar Reviewed-by: Brian King Reviewed-by: Andrew Donnellan --- drivers/scsi/cxlflash/common.h| 2 -- drivers/scsi/cxlflash/main.c | 62 +-- drivers/scsi/cxlflash/sislite.h | 6 ++-- drivers/scsi/cxlflash/superpipe.c | 2 +- drivers/scsi/cxlflash/vlun.c | 14 - 5 files changed, 38 insertions(+), 48 deletions(-) diff --git a/drivers/scsi/cxlflash/common.h b/drivers/scsi/cxlflash/common.h index a810585..bbfe711 100644 --- a/drivers/scsi/cxlflash/common.h +++ b/drivers/scsi/cxlflash/common.h @@ -105,8 +105,6 @@ struct cxlflash_cfg { atomic_t scan_host_needed; struct cxl_afu *cxl_afu; - - struct pci_pool *cxlflash_cmd_pool; struct pci_dev *parent_dev; atomic_t recovery_threads; diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c index 14fb9b4..eeb1c47 100644 --- a/drivers/scsi/cxlflash/main.c +++ b/drivers/scsi/cxlflash/main.c @@ -34,7 +34,6 @@ MODULE_AUTHOR("Manoj N. Kumar "); MODULE_AUTHOR("Matthew R. Ochs "); MODULE_LICENSE("GPL"); - /** * cmd_checkout() - checks out an AFU command * @afu: AFU to checkout from. @@ -730,7 +729,7 @@ static void cxlflash_remove(struct pci_dev *pdev) case INIT_STATE_SCSI: cxlflash_term_local_luns(cfg); scsi_remove_host(cfg->host); - /* Fall through */ + /* fall through */ case INIT_STATE_AFU: term_afu(cfg); cancel_work_sync(>work_q); @@ -763,9 +762,7 @@ static int alloc_mem(struct cxlflash_cfg *cfg) char *buf = NULL; struct device *dev = >dev->dev; - /* This allocation is about 12K, i.e. only 1 64k page -* and upto 4 4k pages -*/ + /* AFU is ~12k, i.e. only one 64k page or up to four 4k pages */ cfg->afu = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, get_order(sizeof(struct afu))); if (unlikely(!cfg->afu)) { @@ -1295,10 +1292,10 @@ static irqreturn_t cxlflash_async_err_irq(int irq, void *data) goto out; } - /* it is OK to clear AFU status before FC_ERROR */ + /* FYI, it is 'okay' to clear AFU status before FC_ERROR */ writeq_be(reg_unmasked, >regs.aintr_clear); - /* check each bit that is on */ + /* Check each bit that is on */ for (i = 0; reg_unmasked; i++, reg_unmasked = (reg_unmasked >> 1)) { info = find_ainfo(1ULL << i); if (((reg_unmasked & 0x1) == 0) || !info) @@ -1311,7 +1308,7 @@ static irqreturn_t cxlflash_async_err_irq(int irq, void *data) readq_be(>fc_regs[port][FC_STATUS / 8])); /* -* do link reset first, some OTHER errors will set FC_ERROR +* Do link reset first, some OTHER errors will set FC_ERROR * again if cleared before or w/o a reset */ if (info->action & LINK_RESET) { @@ -1326,7 +1323,7 @@ static irqreturn_t cxlflash_async_err_irq(int irq, void *data) reg = readq_be(>fc_regs[port][FC_ERROR / 8]); /* -* since all errors are unmasked, FC_ERROR and FC_ERRCAP +* Since all errors are unmasked, FC_ERROR and FC_ERRCAP * should be the same and tracing one is sufficient. */ @@ -1472,23 +1469,22 @@ static void init_pcr(struct cxlflash_cfg *cfg) for (i = 0; i < MAX_CONTEXT; i++) { ctrl_map = >afu_map->ctrls[i].ctrl; - /* disrupt any clients that could be running */ - /* e. g. clients that survived a master restart */ + /* Disrupt any clients that could be running */ + /* e.g. clients that survived a master restart */ writeq_be(0, _map->rht_start); writeq_be(0, _map->rht_cnt_id); writeq_be(0, _map->ctx_cap); } - /* copy frequently used fields into afu */ + /* Copy frequently used fields into afu */ afu->ctx_hndl = (u16) cxl_process_element(cfg->mcctx); - /* ctx_hndl is 16 bits in CAIA */ afu->host_map = >afu_map->hosts[afu->ctx_hndl].host; afu->ctrl_map =
[PATCH v5 33/34] cxlflash: Fix to avoid leaving dangling interrupt resources
When running with an unsupported AFU, the cxlflash driver fails the probe. When the driver is removed, the following Oops is encountered on a show_interrupts() thread: Call Trace: [c01fba5a7a10] [0003] 0x3 (unreliable) [c01fba5a7a60] [c053dcf4] vsnprintf+0x204/0x4c0 [c01fba5a7ae0] [c030045c] seq_vprintf+0x5c/0xd0 [c01fba5a7b20] [c030051c] seq_printf+0x4c/0x60 [c01fba5a7b50] [c013e140] show_interrupts+0x370/0x4f0 [c01fba5a7c10] [c02ff898] seq_read+0xe8/0x530 [c01fba5a7ca0] [c035d5c0] proc_reg_read+0xb0/0x110 [c01fba5a7cf0] [c02ca74c] __vfs_read+0x6c/0x180 [c01fba5a7d90] [c02cb464] vfs_read+0xa4/0x1c0 [c01fba5a7de0] [c02cc51c] SyS_read+0x6c/0x110 [c01fba5a7e30] [c0009204] system_call+0x38/0xb4 The Oops is due to not cleaning up correctly on the unsupported AFU error path, leaving various allocated and registered resources. In this case, interrupts are in a semi-allocated/registered state, which the show_interrupts() thread attempts to use. To fix, the cleanup logic in init_afu() is consolidated to error gates at the bottom of the function and the appropriate goto is added to each error path. As a mini side fix while refactoring in this routine, the else statement following the AFU version evaluation is eliminated as it is not needed. Signed-off-by: Matthew R. Ochs--- drivers/scsi/cxlflash/main.c | 28 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c index 998373e..c152703 100644 --- a/drivers/scsi/cxlflash/main.c +++ b/drivers/scsi/cxlflash/main.c @@ -1721,15 +1721,14 @@ static int init_afu(struct cxlflash_cfg *cfg) if (rc) { dev_err(dev, "%s: call to init_mc failed, rc=%d!\n", __func__, rc); - goto err1; + goto out; } /* Map the entire MMIO space of the AFU */ afu->afu_map = cxl_psa_map(cfg->mcctx); if (!afu->afu_map) { - rc = -ENOMEM; - term_mc(cfg, UNDO_START); dev_err(dev, "%s: call to cxl_psa_map failed!\n", __func__); + rc = -ENOMEM; goto err1; } @@ -1743,19 +1742,17 @@ static int init_afu(struct cxlflash_cfg *cfg) "interface version 0x%llx\n", afu->version, afu->interface_version); rc = -EINVAL; - goto err1; - } else - pr_debug("%s: afu version %s, interface version 0x%llX\n", -__func__, afu->version, afu->interface_version); + goto err2; + } + + pr_debug("%s: afu version %s, interface version 0x%llX\n", __func__, +afu->version, afu->interface_version); rc = start_afu(cfg); if (rc) { dev_err(dev, "%s: call to start_afu failed, rc=%d!\n", __func__, rc); - term_mc(cfg, UNDO_START); - cxl_psa_unmap((void __iomem *)afu->afu_map); - afu->afu_map = NULL; - goto err1; + goto err2; } afu_err_intr_init(cfg->afu); @@ -1763,9 +1760,16 @@ static int init_afu(struct cxlflash_cfg *cfg) /* Restore the LUN mappings */ cxlflash_restore_luntable(cfg); -err1: +out: pr_debug("%s: returning rc=%d\n", __func__, rc); return rc; + +err2: + cxl_psa_unmap((void __iomem *)afu->afu_map); + afu->afu_map = NULL; +err1: + term_mc(cfg, UNDO_START); + goto out; } /** -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v5 01/34] cxlflash: Fix to avoid invalid port_sel value
From: Manoj KumarIf two concurrent MANAGE_LUN ioctls are issued with the same WWID parameter, it would result in an incorrect value of port_sel. This is because port_sel is modified without any locks being held. If the first caller stalls after the return from find_and_create_lun(), the value of port_sel will be set incorrectly to indicate a single port, though in this case it should have been set to both ports. To fix, use the global mutex to serialize the lookup of the WWID and the subsequent modification of port_sel. Signed-off-by: Matthew R. Ochs Signed-off-by: Manoj N. Kumar Reviewed-by: Brian King --- drivers/scsi/cxlflash/lunmgt.c | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/cxlflash/lunmgt.c b/drivers/scsi/cxlflash/lunmgt.c index d98ad0f..8c372fc 100644 --- a/drivers/scsi/cxlflash/lunmgt.c +++ b/drivers/scsi/cxlflash/lunmgt.c @@ -120,7 +120,8 @@ static struct glun_info *lookup_global(u8 *wwid) * * The LUN is kept both in a local list (per adapter) and in a global list * (across all adapters). Certain attributes of the LUN are local to the - * adapter (such as index, port selection mask etc.). + * adapter (such as index, port selection mask, etc.). + * * The block allocation map is shared across all adapters (i.e. associated * wih the global list). Since different attributes are associated with * the per adapter and global entries, allocate two separate structures for each @@ -128,6 +129,8 @@ static struct glun_info *lookup_global(u8 *wwid) * * Keep a pointer back from the local to the global entry. * + * This routine assumes the caller holds the global mutex. + * * Return: Found/Allocated local lun_info structure on success, NULL on failure */ static struct llun_info *find_and_create_lun(struct scsi_device *sdev, u8 *wwid) @@ -137,7 +140,6 @@ static struct llun_info *find_and_create_lun(struct scsi_device *sdev, u8 *wwid) struct Scsi_Host *shost = sdev->host; struct cxlflash_cfg *cfg = shost_priv(shost); - mutex_lock(); if (unlikely(!wwid)) goto out; @@ -169,7 +171,6 @@ static struct llun_info *find_and_create_lun(struct scsi_device *sdev, u8 *wwid) list_add(>list, ); out: - mutex_unlock(); pr_debug("%s: returning %p\n", __func__, lli); return lli; } @@ -235,6 +236,7 @@ int cxlflash_manage_lun(struct scsi_device *sdev, u64 flags = manage->hdr.flags; u32 chan = sdev->channel; + mutex_lock(); lli = find_and_create_lun(sdev, manage->wwid); pr_debug("%s: ENTER: WWID = %016llX%016llX, flags = %016llX li = %p\n", __func__, get_unaligned_le64(>wwid[0]), @@ -261,6 +263,7 @@ int cxlflash_manage_lun(struct scsi_device *sdev, } out: + mutex_unlock(); pr_debug("%s: returning rc=%d\n", __func__, rc); return rc; } -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v5 15/34] cxlflash: Fix host link up event handling
Following a link up event, the LUNs available to the host may have changed. Without rescanning the host, the LUN topology is unknown to the user. In such a state, the user would be unable to locate provisioned resources. To remedy, the host should be rescanned after a link up event. Signed-off-by: Matthew R. OchsSigned-off-by: Manoj N. Kumar Reviewed-by: Brian King Conflicts: drivers/scsi/cxlflash/common.h --- drivers/scsi/cxlflash/common.h | 1 + drivers/scsi/cxlflash/main.c | 17 + drivers/scsi/cxlflash/main.h | 1 + 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/cxlflash/common.h b/drivers/scsi/cxlflash/common.h index 7a0cb5c..faf7f56 100644 --- a/drivers/scsi/cxlflash/common.h +++ b/drivers/scsi/cxlflash/common.h @@ -102,6 +102,7 @@ struct cxlflash_cfg { enum cxlflash_init_state init_state; enum cxlflash_lr_state lr_state; int lr_port; + atomic_t scan_host_needed; struct cxl_afu *cxl_afu; diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c index 5503a40..98fdac1 100644 --- a/drivers/scsi/cxlflash/main.c +++ b/drivers/scsi/cxlflash/main.c @@ -1119,17 +1119,17 @@ static const struct asyc_intr_info ainfo[] = { {SISL_ASTATUS_FC0_CRC_T, "CRC threshold exceeded", 0, LINK_RESET}, {SISL_ASTATUS_FC0_LOGI_R, "login timed out, retrying", 0, 0}, {SISL_ASTATUS_FC0_LOGI_F, "login failed", 0, CLR_FC_ERROR}, - {SISL_ASTATUS_FC0_LOGI_S, "login succeeded", 0, 0}, + {SISL_ASTATUS_FC0_LOGI_S, "login succeeded", 0, SCAN_HOST}, {SISL_ASTATUS_FC0_LINK_DN, "link down", 0, 0}, - {SISL_ASTATUS_FC0_LINK_UP, "link up", 0, 0}, + {SISL_ASTATUS_FC0_LINK_UP, "link up", 0, SCAN_HOST}, {SISL_ASTATUS_FC1_OTHER, "other error", 1, CLR_FC_ERROR | LINK_RESET}, {SISL_ASTATUS_FC1_LOGO, "target initiated LOGO", 1, 0}, {SISL_ASTATUS_FC1_CRC_T, "CRC threshold exceeded", 1, LINK_RESET}, {SISL_ASTATUS_FC1_LOGI_R, "login timed out, retrying", 1, 0}, {SISL_ASTATUS_FC1_LOGI_F, "login failed", 1, CLR_FC_ERROR}, - {SISL_ASTATUS_FC1_LOGI_S, "login succeeded", 1, 0}, + {SISL_ASTATUS_FC1_LOGI_S, "login succeeded", 1, SCAN_HOST}, {SISL_ASTATUS_FC1_LINK_DN, "link down", 1, 0}, - {SISL_ASTATUS_FC1_LINK_UP, "link up", 1, 0}, + {SISL_ASTATUS_FC1_LINK_UP, "link up", 1, SCAN_HOST}, {0x0, "", 0, 0} /* terminator */ }; @@ -1350,6 +1350,11 @@ static irqreturn_t cxlflash_async_err_irq(int irq, void *data) writeq_be(reg, >fc_regs[port][FC_ERROR / 8]); writeq_be(0, >fc_regs[port][FC_ERRCAP / 8]); } + + if (info->action & SCAN_HOST) { + atomic_inc(>scan_host_needed); + schedule_work(>work_q); + } } out: @@ -2309,6 +2314,7 @@ MODULE_DEVICE_TABLE(pci, cxlflash_pci_table); * - Link reset which cannot be performed on interrupt context due to * blocking up to a few seconds * - Read AFU command room + * - Rescan the host */ static void cxlflash_worker_thread(struct work_struct *work) { @@ -2351,6 +2357,9 @@ static void cxlflash_worker_thread(struct work_struct *work) } spin_unlock_irqrestore(cfg->host->host_lock, lock_flags); + + if (atomic_dec_if_positive(>scan_host_needed) >= 0) + scsi_scan_host(cfg->host); } /** diff --git a/drivers/scsi/cxlflash/main.h b/drivers/scsi/cxlflash/main.h index cf0e809..6032456 100644 --- a/drivers/scsi/cxlflash/main.h +++ b/drivers/scsi/cxlflash/main.h @@ -99,6 +99,7 @@ struct asyc_intr_info { u8 action; #define CLR_FC_ERROR 0x01 #define LINK_RESET 0x02 +#define SCAN_HOST 0x04 }; #ifndef CONFIG_CXL_EEH -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v5 20/34] cxlflash: Fix to prevent workq from accessing freed memory
The workq can process work in parallel with a remove event, leading to a condition where the workq handler can access freed memory. To remedy, the workq should be terminated prior to freeing memory. Move the termination call earlier in remove and use cancel_work_sync() instead of flush_work() as there is not a need to process any scheduled work when shutting down. Signed-off-by: Matthew R. OchsSigned-off-by: Manoj N. Kumar Reviewed-by: Brian King --- drivers/scsi/cxlflash/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c index 6b8b159..d0b9972 100644 --- a/drivers/scsi/cxlflash/main.c +++ b/drivers/scsi/cxlflash/main.c @@ -736,11 +736,11 @@ static void cxlflash_remove(struct pci_dev *pdev) /* Fall through */ case INIT_STATE_AFU: term_afu(cfg); + cancel_work_sync(>work_q); case INIT_STATE_PCI: pci_release_regions(cfg->dev); pci_disable_device(pdev); case INIT_STATE_NONE: - flush_work(>work_q); free_mem(cfg); scsi_host_put(cfg->host); break; -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v5 25/34] cxlflash: Fix to prevent EEH recovery failure
The process_sense() routine can perform a read capacity which can take some time to complete. If an EEH occurs while waiting on the read capacity, the EEH handler will wait to obtain the context's mutex in order to put the context in an error state. The EEH handler will sit and wait until the context is free, but this wait can potentially last forever (deadlock) if the scsi_execute() that performs the read capacity experiences a timeout and calls into the reset callback. When that occurs, the reset callback sees that the device is already being reset and waits for the reset to complete. This leaves two threads waiting on the other. To address this issue, make the context unavailable to new, non-system owned threads and release the context while calling into process_sense(). After returning from process_sense() the context mutex is reacquired and the context is made available again. The context can be safely moved to the error state if needed during the unavailable window as no other threads will hold its reference. Signed-off-by: Matthew R. OchsSigned-off-by: Manoj N. Kumar Reviewed-by: Brian King Reviewed-by: Daniel Axtens --- drivers/scsi/cxlflash/superpipe.c | 9 + 1 file changed, 9 insertions(+) diff --git a/drivers/scsi/cxlflash/superpipe.c b/drivers/scsi/cxlflash/superpipe.c index a6316f5..7283e83 100644 --- a/drivers/scsi/cxlflash/superpipe.c +++ b/drivers/scsi/cxlflash/superpipe.c @@ -1787,12 +1787,21 @@ static int cxlflash_disk_verify(struct scsi_device *sdev, * inquiry (i.e. the Unit attention is due to the WWN changing). */ if (verify->hint & DK_CXLFLASH_VERIFY_HINT_SENSE) { + /* Can't hold mutex across process_sense/read_cap16, +* since we could have an intervening EEH event. +*/ + ctxi->unavail = true; + mutex_unlock(>mutex); rc = process_sense(sdev, verify); if (unlikely(rc)) { dev_err(dev, "%s: Failed to validate sense data (%d)\n", __func__, rc); + mutex_lock(>mutex); + ctxi->unavail = false; goto out; } + mutex_lock(>mutex); + ctxi->unavail = false; } switch (gli->mode) { -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v5 00/34] cxlflash: Miscellaneous bug fixes and corrections
This patch set contains various fixes and corrections for issues that were found during test and code review. The series is based upon the code upstreamed in 4.3 and is intended for the rc phase. The entire set is bisectable. Please reference the changelog below for details on what has been altered from previous versions of this patch set. v5 Changes: - Incorporate comments from Daniel Axtens - Incorporate comments from Andrew Donnellan - Added additional clarifications to several commit messages - Specified some return codes as failures in "Fix function prolog..." - Made port online failure noisier in "Remove dual port online..." - Added patch to properly cleanup when encountering an unsupported AFU - Added patch to escalate a link reset on login timeout v4 Changes: - Incorporate comments from Brian King - Removed unnecessary check_state() parameter from "Fix to avoid CXL..." - Added patch to fix potential deadlock on EEH - Removed patch to avoid state change collision - Changed fops initialization location in "Fix to avoid corrupting..." v3 Changes: - Rebased the series on top of patch by Dan Carpenter ("a couple off...") - Incorporate comments from David Laight - Incorporate comments from Tomas Henzl - Incorporate comments from Brian King - Removed patch to stop interrupt processing on remove - Removed double scsi_device_put() from "Fix potential oops" - Fixed usage of scnprintf() in "Refine host/device attributes" - Removed unnecessary parenthesis from "Fix read capacity timeout" - Added patch to use correct operator for doubling delay - Changed location of cancel_work_sync() in "Fix to prevent workq..." - Removed local mutex from cxlflash_afu_sync() in "Fix to avoid state..." - Added patch to correctly identify a failed function in a trace - Added patch to fix a fops corruption bug v2 Changes: - Incorporate comments from Ian Munsie - Rework commit messages to be more descriptive - Add state change serialization patch Manoj Kumar (5): cxlflash: Fix to avoid invalid port_sel value cxlflash: Replace magic numbers with literals cxlflash: Fix read capacity timeout cxlflash: Fix to double the delay each time cxlflash: Fix to escalate to LINK_RESET on login timeout Matthew R. Ochs (29): cxlflash: Fix potential oops following LUN removal cxlflash: Fix data corruption when vLUN used over multiple cards cxlflash: Fix to avoid sizeof(bool) cxlflash: Fix context encode mask width cxlflash: Fix to avoid CXL services during EEH cxlflash: Correct naming of limbo state and waitq cxlflash: Make functions static cxlflash: Refine host/device attributes cxlflash: Fix to avoid spamming the kernel log cxlflash: Fix to avoid stall while waiting on TMF cxlflash: Fix location of setting resid cxlflash: Fix host link up event handling cxlflash: Fix async interrupt bypass logic cxlflash: Remove dual port online dependency cxlflash: Fix AFU version access/storage and add check cxlflash: Correct usage of scsi_host_put() cxlflash: Fix to prevent workq from accessing freed memory cxlflash: Correct behavior in device reset handler following EEH cxlflash: Remove unnecessary scsi_block_requests cxlflash: Fix function prolog parameters and return codes cxlflash: Fix MMIO and endianness errors cxlflash: Fix to prevent EEH recovery failure cxlflash: Correct spelling, grammar, and alignment mistakes cxlflash: Fix to prevent stale AFU RRQ MAINTAINERS: Add cxlflash driver cxlflash: Fix to avoid corrupting adapter fops cxlflash: Correct trace string cxlflash: Fix to avoid potential deadlock on EEH cxlflash: Fix to avoid leaving dangling interrupt resources MAINTAINERS |9 + drivers/scsi/cxlflash/common.h| 30 +- drivers/scsi/cxlflash/lunmgt.c|9 +- drivers/scsi/cxlflash/main.c | 1549 - drivers/scsi/cxlflash/main.h |1 + drivers/scsi/cxlflash/sislite.h |8 +- drivers/scsi/cxlflash/superpipe.c | 204 +++-- drivers/scsi/cxlflash/superpipe.h | 13 +- drivers/scsi/cxlflash/vlun.c | 68 +- 9 files changed, 1055 insertions(+), 836 deletions(-) -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v5 02/34] cxlflash: Replace magic numbers with literals
From: Manoj KumarMagic numbers are not meaningful and can create confusion. As a remedy, replace them with descriptive literals. Replace 512 with literal MAX_SECTOR_UNIT. Replace 5 with literal CMD_RETRIES. Signed-off-by: Matthew R. Ochs Signed-off-by: Manoj N. Kumar Reviewed-by: Brian King Reviewed-by: Andrew Donnellan --- drivers/scsi/cxlflash/superpipe.c | 6 -- drivers/scsi/cxlflash/superpipe.h | 3 +++ drivers/scsi/cxlflash/vlun.c | 3 ++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/cxlflash/superpipe.c b/drivers/scsi/cxlflash/superpipe.c index 05e0ecf..4db15a4 100644 --- a/drivers/scsi/cxlflash/superpipe.c +++ b/drivers/scsi/cxlflash/superpipe.c @@ -315,7 +315,8 @@ retry: retry_cnt ? "re" : "", scsi_cmd[0]); result = scsi_execute(sdev, scsi_cmd, DMA_FROM_DEVICE, cmd_buf, - CMD_BUFSIZE, sense_buf, tout, 5, 0, NULL); + CMD_BUFSIZE, sense_buf, tout, CMD_RETRIES, + 0, NULL); if (driver_byte(result) == DRIVER_SENSE) { result &= ~(0xFF<<24); /* DRIVER_SENSE is not an error */ @@ -1375,7 +1376,8 @@ out_attach: attach->block_size = gli->blk_len; attach->mmio_size = sizeof(afu->afu_map->hosts[0].harea); attach->last_lba = gli->max_lba; - attach->max_xfer = (sdev->host->max_sectors * 512) / gli->blk_len; + attach->max_xfer = (sdev->host->max_sectors * MAX_SECTOR_UNIT) / + gli->blk_len; out: attach->adap_fd = fd; diff --git a/drivers/scsi/cxlflash/superpipe.h b/drivers/scsi/cxlflash/superpipe.h index d7dc88b..3f7856b 100644 --- a/drivers/scsi/cxlflash/superpipe.h +++ b/drivers/scsi/cxlflash/superpipe.h @@ -29,6 +29,9 @@ extern struct cxlflash_global global; #define MC_CHUNK_SIZE (1 << MC_RHT_NMASK) /* in LBAs */ #define MC_DISCOVERY_TIMEOUT 5 /* 5 secs */ +#define CMD_RETRIES 5 /* 5 retries for scsi_execute */ + +#define MAX_SECTOR_UNIT 512 /* max_sector is in 512 byte multiples */ #define CHAN2PORT(_x) ((_x) + 1) #define PORT2CHAN(_x) ((_x) - 1) diff --git a/drivers/scsi/cxlflash/vlun.c b/drivers/scsi/cxlflash/vlun.c index 6155cb1..6d6608b 100644 --- a/drivers/scsi/cxlflash/vlun.c +++ b/drivers/scsi/cxlflash/vlun.c @@ -434,7 +434,8 @@ static int write_same16(struct scsi_device *sdev, _cmd[10]); result = scsi_execute(sdev, scsi_cmd, DMA_TO_DEVICE, cmd_buf, - CMD_BUFSIZE, sense_buf, tout, 5, 0, NULL); + CMD_BUFSIZE, sense_buf, tout, CMD_RETRIES, + 0, NULL); if (result) { dev_err_ratelimited(dev, "%s: command failed for " "offset %lld result=0x%x\n", -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v5 18/34] cxlflash: Fix AFU version access/storage and add check
The AFU version is stored as a non-terminated string of bytes within a 64-bit little-endian register. Presently the value is read directly (no MMIO accessor) and is stored in a buffer that is not big enough to contain a NULL terminator. Additionally the version obtained is not evaluated against a known value to prevent usage with unsupported AFUs. All of these deficiencies can lead to a variety of problems. To remedy, use the correct MMIO accessor to read the version value into a null-terminated buffer and add a check to prevent an incompatible AFU from being used with this driver. Signed-off-by: Matthew R. OchsSigned-off-by: Manoj N. Kumar Reviewed-by: Brian King --- drivers/scsi/cxlflash/common.h | 2 +- drivers/scsi/cxlflash/main.c| 18 -- drivers/scsi/cxlflash/sislite.h | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/drivers/scsi/cxlflash/common.h b/drivers/scsi/cxlflash/common.h index faf7f56..3be5754 100644 --- a/drivers/scsi/cxlflash/common.h +++ b/drivers/scsi/cxlflash/common.h @@ -179,7 +179,7 @@ struct afu { u32 cmd_couts; /* Number of command checkouts */ u32 internal_lun; /* User-desired LUN mode for this AFU */ - char version[8]; + char version[16]; u64 interface_version; struct cxlflash_cfg *parent; /* Pointer back to parent cxlflash_cfg */ diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c index c25efc3..c1d5c88 100644 --- a/drivers/scsi/cxlflash/main.c +++ b/drivers/scsi/cxlflash/main.c @@ -1751,14 +1751,20 @@ static int init_afu(struct cxlflash_cfg *cfg) goto err1; } - /* don't byte reverse on reading afu_version, else the string form */ - /* will be backwards */ - reg = afu->afu_map->global.regs.afu_version; - memcpy(afu->version, , 8); + /* No byte reverse on reading afu_version or string will be backwards */ + reg = readq(>afu_map->global.regs.afu_version); + memcpy(afu->version, , sizeof(reg)); afu->interface_version = readq_be(>afu_map->global.regs.interface_version); - pr_debug("%s: afu version %s, interface version 0x%llX\n", -__func__, afu->version, afu->interface_version); + if ((afu->interface_version + 1) == 0) { + pr_err("Back level AFU, please upgrade. AFU version %s " + "interface version 0x%llx\n", afu->version, + afu->interface_version); + rc = -EINVAL; + goto err1; + } else + pr_debug("%s: afu version %s, interface version 0x%llX\n", +__func__, afu->version, afu->interface_version); rc = start_afu(cfg); if (rc) { diff --git a/drivers/scsi/cxlflash/sislite.h b/drivers/scsi/cxlflash/sislite.h index 63bf394..8425d1a 100644 --- a/drivers/scsi/cxlflash/sislite.h +++ b/drivers/scsi/cxlflash/sislite.h @@ -340,7 +340,7 @@ struct sisl_global_regs { #define SISL_AFUCONF_MBOX_CLR_READ 0x0010ULL __be64 afu_config; __be64 rsvd[0xf8]; - __be64 afu_version; + __le64 afu_version; __be64 interface_version; }; -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v5 23/34] cxlflash: Fix function prolog parameters and return codes
Several function prologs have incorrect parameter names and return code descriptions. This can lead to confusion when reviewing the source and creates inaccurate documentation. To remedy, update the function prologs to properly reflect parameter names and return codes. Signed-off-by: Matthew R. OchsSigned-off-by: Manoj N. Kumar Reviewed-by: Brian King Reviewed-by: Andrew Donnellan --- drivers/scsi/cxlflash/main.c | 70 1 file changed, 26 insertions(+), 44 deletions(-) diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c index 441e897..f37e968 100644 --- a/drivers/scsi/cxlflash/main.c +++ b/drivers/scsi/cxlflash/main.c @@ -314,7 +314,7 @@ write_rrin: * @cmd: AFU command to send. * * Return: - * 0 on success or SCSI_MLQUEUE_HOST_BUSY + * 0 on success, SCSI_MLQUEUE_HOST_BUSY on failure */ static int send_cmd(struct afu *afu, struct afu_cmd *cmd) { @@ -401,8 +401,7 @@ static void wait_resp(struct afu *afu, struct afu_cmd *cmd) * @tmfcmd:TMF command to send. * * Return: - * 0 on success - * SCSI_MLQUEUE_HOST_BUSY when host is busy + * 0 on success, SCSI_MLQUEUE_HOST_BUSY on failure */ static int send_tmf(struct afu *afu, struct scsi_cmnd *scp, u64 tmfcmd) { @@ -491,9 +490,7 @@ static const char *cxlflash_driver_info(struct Scsi_Host *host) * @host: SCSI host associated with device. * @scp: SCSI command to send. * - * Return: - * 0 on success - * SCSI_MLQUEUE_HOST_BUSY when host is busy + * Return: 0 on success, SCSI_MLQUEUE_HOST_BUSY on failure */ static int cxlflash_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scp) { @@ -597,7 +594,7 @@ out: /** * cxlflash_wait_for_pci_err_recovery() - wait for error recovery during probe - * @cxlflash: Internal structure associated with the host. + * @cfg: Internal structure associated with the host. */ static void cxlflash_wait_for_pci_err_recovery(struct cxlflash_cfg *cfg) { @@ -611,7 +608,7 @@ static void cxlflash_wait_for_pci_err_recovery(struct cxlflash_cfg *cfg) /** * free_mem() - free memory associated with the AFU - * @cxlflash: Internal structure associated with the host. + * @cfg: Internal structure associated with the host. */ static void free_mem(struct cxlflash_cfg *cfg) { @@ -633,7 +630,7 @@ static void free_mem(struct cxlflash_cfg *cfg) /** * stop_afu() - stops the AFU command timers and unmaps the MMIO space - * @cxlflash: Internal structure associated with the host. + * @cfg: Internal structure associated with the host. * * Safe to call with AFU in a partially allocated/initialized state. */ @@ -655,7 +652,7 @@ static void stop_afu(struct cxlflash_cfg *cfg) /** * term_mc() - terminates the master context - * @cxlflash: Internal structure associated with the host. + * @cfg: Internal structure associated with the host. * @level: Depth of allocation, where to begin waterfall tear down. * * Safe to call with AFU/MC in partially allocated/initialized state. @@ -691,7 +688,7 @@ static void term_mc(struct cxlflash_cfg *cfg, enum undo_level level) /** * term_afu() - terminates the AFU - * @cxlflash: Internal structure associated with the host. + * @cfg: Internal structure associated with the host. * * Safe to call with AFU/MC in partially allocated/initialized state. */ @@ -751,7 +748,7 @@ static void cxlflash_remove(struct pci_dev *pdev) /** * alloc_mem() - allocates the AFU and its command pool - * @cxlflash: Internal structure associated with the host. + * @cfg: Internal structure associated with the host. * * A partially allocated state remains on failure. * @@ -804,12 +801,9 @@ out: /** * init_pci() - initializes the host as a PCI device - * @cxlflash: Internal structure associated with the host. + * @cfg: Internal structure associated with the host. * - * Return: - * 0 on success - * -EIO on unable to communicate with device - * A return code from the PCI sub-routines + * Return: 0 on success, -errno on failure */ static int init_pci(struct cxlflash_cfg *cfg) { @@ -889,11 +883,9 @@ out_release_regions: /** * init_scsi() - adds the host to the SCSI stack and kicks off host scan - * @cxlflash: Internal structure associated with the host. + * @cfg: Internal structure associated with the host. * - * Return: - * 0 on success - * A return code from adding the host + * Return: 0 on success, -errno on failure */ static int init_scsi(struct cxlflash_cfg *cfg) { @@ -1357,7 +1349,7 @@ out: /** * start_context() - starts the master context - * @cxlflash: Internal structure associated with the host. + * @cfg: Internal structure associated with the host. * * Return: A success or failure value from CXL services. */ @@
[PATCH v5 28/34] MAINTAINERS: Add cxlflash driver
Add stanza for cxlflash SCSI driver. Signed-off-by: Matthew R. OchsSigned-off-by: Manoj N. Kumar Reviewed-by: Brian King Reviewed-by: Andrew Donnellan --- MAINTAINERS | 9 + 1 file changed, 9 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 274f854..f2f3046 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3153,6 +3153,15 @@ F: Documentation/powerpc/cxl.txt F: Documentation/powerpc/cxl.txt F: Documentation/ABI/testing/sysfs-class-cxl +CXLFLASH (IBM Coherent Accelerator Processor Interface CAPI Flash) SCSI DRIVER +M: Manoj N. Kumar +M: Matthew R. Ochs +L: linux-s...@vger.kernel.org +S: Supported +F: drivers/scsi/cxlflash/ +F: include/uapi/scsi/cxlflash_ioctls.h +F: Documentation/powerpc/cxlflash.txt + STMMAC ETHERNET DRIVER M: Giuseppe Cavallaro L: net...@vger.kernel.org -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v5 29/34] cxlflash: Fix to double the delay each time
From: Manoj KumarThe operator used to double the master context response delay is incorrect and does not result in delay doubling. To fix, use a left shift instead of the XOR operator. Reported-by: Tomas Henzl Signed-off-by: Matthew R. Ochs Signed-off-by: Manoj N. Kumar Reviewed-by: Brian King Reviewed-by: Andrew Donnellan --- drivers/scsi/cxlflash/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c index c77cb92..51883be 100644 --- a/drivers/scsi/cxlflash/main.c +++ b/drivers/scsi/cxlflash/main.c @@ -303,7 +303,7 @@ write_rrin: if (rrin != 0x1) break; /* Double delay each time */ - udelay(2 ^ nretry); + udelay(2 << nretry); } while (nretry++ < MC_ROOM_RETRY_CNT); } -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v5 03/34] cxlflash: Fix read capacity timeout
From: Manoj KumarThe timeout value for read capacity is too small. Certain devices may take longer to respond and thus the command may prematurely timeout. Additionally the literal used for the timeout is stale. Update the timeout to 30 seconds (matches the value used in sd.c) and rework the timeout literal to a more appropriate description. Signed-off-by: Matthew R. Ochs Signed-off-by: Manoj N. Kumar Reviewed-by: Brian King --- drivers/scsi/cxlflash/superpipe.c | 9 - drivers/scsi/cxlflash/superpipe.h | 2 +- drivers/scsi/cxlflash/vlun.c | 4 ++-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/scsi/cxlflash/superpipe.c b/drivers/scsi/cxlflash/superpipe.c index 4db15a4..4e44a48 100644 --- a/drivers/scsi/cxlflash/superpipe.c +++ b/drivers/scsi/cxlflash/superpipe.c @@ -296,7 +296,7 @@ static int read_cap16(struct scsi_device *sdev, struct llun_info *lli) int rc = 0; int result = 0; int retry_cnt = 0; - u32 tout = (MC_DISCOVERY_TIMEOUT * HZ); + u32 to = CMD_TIMEOUT * HZ; retry: cmd_buf = kzalloc(CMD_BUFSIZE, GFP_KERNEL); @@ -315,8 +315,7 @@ retry: retry_cnt ? "re" : "", scsi_cmd[0]); result = scsi_execute(sdev, scsi_cmd, DMA_FROM_DEVICE, cmd_buf, - CMD_BUFSIZE, sense_buf, tout, CMD_RETRIES, - 0, NULL); + CMD_BUFSIZE, sense_buf, to, CMD_RETRIES, 0, NULL); if (driver_byte(result) == DRIVER_SENSE) { result &= ~(0xFF<<24); /* DRIVER_SENSE is not an error */ @@ -1376,8 +1375,8 @@ out_attach: attach->block_size = gli->blk_len; attach->mmio_size = sizeof(afu->afu_map->hosts[0].harea); attach->last_lba = gli->max_lba; - attach->max_xfer = (sdev->host->max_sectors * MAX_SECTOR_UNIT) / - gli->blk_len; + attach->max_xfer = sdev->host->max_sectors * MAX_SECTOR_UNIT; + attach->max_xfer /= gli->blk_len; out: attach->adap_fd = fd; diff --git a/drivers/scsi/cxlflash/superpipe.h b/drivers/scsi/cxlflash/superpipe.h index 3f7856b..fffb179 100644 --- a/drivers/scsi/cxlflash/superpipe.h +++ b/drivers/scsi/cxlflash/superpipe.h @@ -28,7 +28,7 @@ extern struct cxlflash_global global; */ #define MC_CHUNK_SIZE (1 << MC_RHT_NMASK) /* in LBAs */ -#define MC_DISCOVERY_TIMEOUT 5 /* 5 secs */ +#define CMD_TIMEOUT 30 /* 30 secs */ #define CMD_RETRIES 5 /* 5 retries for scsi_execute */ #define MAX_SECTOR_UNIT 512 /* max_sector is in 512 byte multiples */ diff --git a/drivers/scsi/cxlflash/vlun.c b/drivers/scsi/cxlflash/vlun.c index 6d6608b..68994c4 100644 --- a/drivers/scsi/cxlflash/vlun.c +++ b/drivers/scsi/cxlflash/vlun.c @@ -414,7 +414,7 @@ static int write_same16(struct scsi_device *sdev, int ws_limit = SISLITE_MAX_WS_BLOCKS; u64 offset = lba; int left = nblks; - u32 tout = sdev->request_queue->rq_timeout; + u32 to = sdev->request_queue->rq_timeout; struct cxlflash_cfg *cfg = (struct cxlflash_cfg *)sdev->host->hostdata; struct device *dev = >dev->dev; @@ -434,7 +434,7 @@ static int write_same16(struct scsi_device *sdev, _cmd[10]); result = scsi_execute(sdev, scsi_cmd, DMA_TO_DEVICE, cmd_buf, - CMD_BUFSIZE, sense_buf, tout, CMD_RETRIES, + CMD_BUFSIZE, sense_buf, to, CMD_RETRIES, 0, NULL); if (result) { dev_err_ratelimited(dev, "%s: command failed for " -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v5 06/34] cxlflash: Fix to avoid sizeof(bool)
Using sizeof(bool) is considered poor form for various reasons and sparse warns us of that. Correct by changing type from bool to u8. Signed-off-by: Matthew R. OchsSigned-off-by: Manoj N. Kumar Reviewed-by: Brian King Reviewed-by: Daniel Axtens --- drivers/scsi/cxlflash/superpipe.c | 2 +- drivers/scsi/cxlflash/superpipe.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/cxlflash/superpipe.c b/drivers/scsi/cxlflash/superpipe.c index ffa68cc..28aa9d9 100644 --- a/drivers/scsi/cxlflash/superpipe.c +++ b/drivers/scsi/cxlflash/superpipe.c @@ -737,7 +737,7 @@ static struct ctx_info *create_context(struct cxlflash_cfg *cfg, struct afu *afu = cfg->afu; struct ctx_info *ctxi = NULL; struct llun_info **lli = NULL; - bool *ws = NULL; + u8 *ws = NULL; struct sisl_rht_entry *rhte; ctxi = kzalloc(sizeof(*ctxi), GFP_KERNEL); diff --git a/drivers/scsi/cxlflash/superpipe.h b/drivers/scsi/cxlflash/superpipe.h index fffb179..72d53cf 100644 --- a/drivers/scsi/cxlflash/superpipe.h +++ b/drivers/scsi/cxlflash/superpipe.h @@ -97,7 +97,7 @@ struct ctx_info { u32 rht_out;/* Number of checked out RHT entries */ u32 rht_perms; /* User-defined permissions for RHT entries */ struct llun_info **rht_lun; /* Mapping of RHT entries to LUNs */ - bool *rht_needs_ws; /* User-desired write-same function per RHTE */ + u8 *rht_needs_ws; /* User-desired write-same function per RHTE */ struct cxl_ioctl_start_work work; u64 ctxid; -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v5 09/34] cxlflash: Correct naming of limbo state and waitq
Limbo is not an accurate representation of this state and is also not consistent with the terminology that other drivers use to represent this concept. Rename the state and and its associated waitq to 'reset'. Signed-off-by: Matthew R. OchsSigned-off-by: Manoj N. Kumar Reviewed-by: Brian King Reviewed-by: Daniel Axtens --- drivers/scsi/cxlflash/common.h| 4 ++-- drivers/scsi/cxlflash/main.c | 26 +- drivers/scsi/cxlflash/superpipe.c | 14 +++--- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/drivers/scsi/cxlflash/common.h b/drivers/scsi/cxlflash/common.h index 1abe4e0..11318de 100644 --- a/drivers/scsi/cxlflash/common.h +++ b/drivers/scsi/cxlflash/common.h @@ -79,7 +79,7 @@ enum cxlflash_init_state { enum cxlflash_state { STATE_NORMAL, /* Normal running state, everything good */ - STATE_LIMBO,/* Limbo running state, trying to reset/recover */ + STATE_RESET,/* Reset state, trying to reset/recover */ STATE_FAILTERM /* Failed/terminating state, error out users/threads */ }; @@ -125,7 +125,7 @@ struct cxlflash_cfg { wait_queue_head_t tmf_waitq; bool tmf_active; - wait_queue_head_t limbo_waitq; + wait_queue_head_t reset_waitq; enum cxlflash_state state; }; diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c index 6e85c77..8940336 100644 --- a/drivers/scsi/cxlflash/main.c +++ b/drivers/scsi/cxlflash/main.c @@ -382,8 +382,8 @@ static int cxlflash_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scp) spin_unlock_irqrestore(>tmf_waitq.lock, lock_flags); switch (cfg->state) { - case STATE_LIMBO: - dev_dbg_ratelimited(>dev->dev, "%s: device in limbo!\n", + case STATE_RESET: + dev_dbg_ratelimited(>dev->dev, "%s: device is in reset!\n", __func__); rc = SCSI_MLQUEUE_HOST_BUSY; goto out; @@ -479,8 +479,8 @@ static int cxlflash_eh_device_reset_handler(struct scsi_cmnd *scp) if (unlikely(rcr)) rc = FAILED; break; - case STATE_LIMBO: - wait_event(cfg->limbo_waitq, cfg->state != STATE_LIMBO); + case STATE_RESET: + wait_event(cfg->reset_waitq, cfg->state != STATE_RESET); if (cfg->state == STATE_NORMAL) break; /* fall through */ @@ -519,7 +519,7 @@ static int cxlflash_eh_host_reset_handler(struct scsi_cmnd *scp) switch (cfg->state) { case STATE_NORMAL: - cfg->state = STATE_LIMBO; + cfg->state = STATE_RESET; scsi_block_requests(cfg->host); cxlflash_mark_contexts_error(cfg); rcr = cxlflash_afu_reset(cfg); @@ -528,11 +528,11 @@ static int cxlflash_eh_host_reset_handler(struct scsi_cmnd *scp) cfg->state = STATE_FAILTERM; } else cfg->state = STATE_NORMAL; - wake_up_all(>limbo_waitq); + wake_up_all(>reset_waitq); scsi_unblock_requests(cfg->host); break; - case STATE_LIMBO: - wait_event(cfg->limbo_waitq, cfg->state != STATE_LIMBO); + case STATE_RESET: + wait_event(cfg->reset_waitq, cfg->state != STATE_RESET); if (cfg->state == STATE_NORMAL) break; /* fall through */ @@ -705,7 +705,7 @@ static void cxlflash_wait_for_pci_err_recovery(struct cxlflash_cfg *cfg) struct pci_dev *pdev = cfg->dev; if (pci_channel_offline(pdev)) - wait_event_timeout(cfg->limbo_waitq, + wait_event_timeout(cfg->reset_waitq, !pci_channel_offline(pdev), CXLFLASH_PCI_ERROR_RECOVERY_TIMEOUT); } @@ -2304,7 +2304,7 @@ static int cxlflash_probe(struct pci_dev *pdev, cfg->mcctx = NULL; init_waitqueue_head(>tmf_waitq); - init_waitqueue_head(>limbo_waitq); + init_waitqueue_head(>reset_waitq); INIT_WORK(>work_q, cxlflash_worker_thread); cfg->lr_state = LINK_RESET_INVALID; @@ -2396,7 +2396,7 @@ static pci_ers_result_t cxlflash_pci_error_detected(struct pci_dev *pdev, switch (state) { case pci_channel_io_frozen: - cfg->state = STATE_LIMBO; + cfg->state = STATE_RESET; scsi_block_requests(cfg->host); drain_ioctls(cfg); rc = cxlflash_mark_contexts_error(cfg); @@ -2408,7 +2408,7 @@ static pci_ers_result_t cxlflash_pci_error_detected(struct pci_dev *pdev, return PCI_ERS_RESULT_NEED_RESET; case pci_channel_io_perm_failure:
[PATCH v5 08/34] cxlflash: Fix to avoid CXL services during EEH
During an EEH freeze event, certain CXL services should not be called until after the hardware reset has taken place. Doing so can result in unnecessary failures and possibly cause other ill effects by triggering hardware accesses. This translates to a requirement to quiesce all threads that may potentially use CXL runtime service during this window. In particular, multiple ioctls make use of the CXL services when acting on contexts on behalf of the user. Thus, it is essential to 'drain' running ioctls _before_ proceeding with handling the EEH freeze event. Create the ability to drain ioctls by wrapping the ioctl handler call in a read semaphore and then implementing a small routine that obtains the write semaphore, effectively creating a wait point for all currently executing ioctls. Signed-off-by: Matthew R. OchsSigned-off-by: Manoj N. Kumar Reviewed-by: Brian King Reviewed-by: Daniel Axtens --- drivers/scsi/cxlflash/common.h| 2 + drivers/scsi/cxlflash/main.c | 18 +-- drivers/scsi/cxlflash/superpipe.c | 98 --- 3 files changed, 77 insertions(+), 41 deletions(-) diff --git a/drivers/scsi/cxlflash/common.h b/drivers/scsi/cxlflash/common.h index 1c56037..1abe4e0 100644 --- a/drivers/scsi/cxlflash/common.h +++ b/drivers/scsi/cxlflash/common.h @@ -16,6 +16,7 @@ #define _CXLFLASH_COMMON_H #include +#include #include #include #include @@ -110,6 +111,7 @@ struct cxlflash_cfg { atomic_t recovery_threads; struct mutex ctx_recovery_mutex; struct mutex ctx_tbl_list_mutex; + struct rw_semaphore ioctl_rwsem; struct ctx_info *ctx_tbl[MAX_CONTEXT]; struct list_head ctx_err_recovery; /* contexts w/ recovery pending */ struct file_operations cxl_fops; diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c index 3e3ccf1..6e85c77 100644 --- a/drivers/scsi/cxlflash/main.c +++ b/drivers/scsi/cxlflash/main.c @@ -2311,6 +2311,7 @@ static int cxlflash_probe(struct pci_dev *pdev, cfg->lr_port = -1; mutex_init(>ctx_tbl_list_mutex); mutex_init(>ctx_recovery_mutex); + init_rwsem(>ioctl_rwsem); INIT_LIST_HEAD(>ctx_err_recovery); INIT_LIST_HEAD(>lluns); @@ -2365,6 +2366,19 @@ out_remove: } /** + * drain_ioctls() - wait until all currently executing ioctls have completed + * @cfg: Internal structure associated with the host. + * + * Obtain write access to read/write semaphore that wraps ioctl + * handling to 'drain' ioctls currently executing. + */ +static void drain_ioctls(struct cxlflash_cfg *cfg) +{ + down_write(>ioctl_rwsem); + up_write(>ioctl_rwsem); +} + +/** * cxlflash_pci_error_detected() - called when a PCI error is detected * @pdev: PCI device struct. * @state: PCI channel state. @@ -2383,16 +2397,14 @@ static pci_ers_result_t cxlflash_pci_error_detected(struct pci_dev *pdev, switch (state) { case pci_channel_io_frozen: cfg->state = STATE_LIMBO; - - /* Turn off legacy I/O */ scsi_block_requests(cfg->host); + drain_ioctls(cfg); rc = cxlflash_mark_contexts_error(cfg); if (unlikely(rc)) dev_err(dev, "%s: Failed to mark user contexts!(%d)\n", __func__, rc); term_mc(cfg, UNDO_START); stop_afu(cfg); - return PCI_ERS_RESULT_NEED_RESET; case pci_channel_io_perm_failure: cfg->state = STATE_FAILTERM; diff --git a/drivers/scsi/cxlflash/superpipe.c b/drivers/scsi/cxlflash/superpipe.c index 28aa9d9..655cbf1 100644 --- a/drivers/scsi/cxlflash/superpipe.c +++ b/drivers/scsi/cxlflash/superpipe.c @@ -1214,6 +1214,46 @@ static const struct file_operations null_fops = { }; /** + * check_state() - checks and responds to the current adapter state + * @cfg: Internal structure associated with the host. + * + * This routine can block and should only be used on process context. + * It assumes that the caller is an ioctl thread and holding the ioctl + * read semaphore. This is temporarily let up across the wait to allow + * for draining actively running ioctls. Also note that when waking up + * from waiting in reset, the state is unknown and must be checked again + * before proceeding. + * + * Return: 0 on success, -errno on failure + */ +static int check_state(struct cxlflash_cfg *cfg) +{ + struct device *dev = >dev->dev; + int rc = 0; + +retry: + switch (cfg->state) { + case STATE_LIMBO: + dev_dbg(dev, "%s: Limbo state, going to wait...\n", __func__); + up_read(>ioctl_rwsem); + rc = wait_event_interruptible(cfg->limbo_waitq, + cfg->state != STATE_LIMBO); +
[PATCH v5 12/34] cxlflash: Fix to avoid spamming the kernel log
During run-time the driver can be very chatty and spam the system kernel log. Various print statements can be limited and/or moved to development-only mode. Additionally, numerous prints can be converted to trace the corresponding device. Lastly, one spelling correction was made: 'entra' to 'extra'. The following changes were made: - pr_debug to pr_devel - pr_debug to pr_debug_ratelimited - pr_err to dev_err - pr_debug to dev_dbg Signed-off-by: Matthew R. OchsSigned-off-by: Manoj N. Kumar Reviewed-by: Brian King Reviewed-by: Andrew Donnellan Conflicts: drivers/scsi/cxlflash/main.c --- drivers/scsi/cxlflash/main.c | 109 +++ 1 file changed, 59 insertions(+), 50 deletions(-) diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c index b44212b..527ff85 100644 --- a/drivers/scsi/cxlflash/main.c +++ b/drivers/scsi/cxlflash/main.c @@ -58,8 +58,8 @@ static struct afu_cmd *cmd_checkout(struct afu *afu) cmd = >cmd[k]; if (!atomic_dec_if_positive(>free)) { - pr_debug("%s: returning found index=%d\n", -__func__, cmd->slot); + pr_devel("%s: returning found index=%d cmd=%p\n", +__func__, cmd->slot, cmd); memset(cmd->buf, 0, CMD_BUFSIZE); memset(cmd->rcb.cdb, 0, sizeof(cmd->rcb.cdb)); return cmd; @@ -93,7 +93,7 @@ static void cmd_checkin(struct afu_cmd *cmd) return; } - pr_debug("%s: released cmd %p index=%d\n", __func__, cmd, cmd->slot); + pr_devel("%s: released cmd %p index=%d\n", __func__, cmd, cmd->slot); } /** @@ -127,7 +127,7 @@ static void process_cmd_err(struct afu_cmd *cmd, struct scsi_cmnd *scp) } pr_debug("%s: cmd failed afu_rc=%d scsi_rc=%d fc_rc=%d " -"afu_extra=0x%X, scsi_entra=0x%X, fc_extra=0x%X\n", +"afu_extra=0x%X, scsi_extra=0x%X, fc_extra=0x%X\n", __func__, ioasa->rc.afu_rc, ioasa->rc.scsi_rc, ioasa->rc.fc_rc, ioasa->afu_extra, ioasa->scsi_extra, ioasa->fc_extra); @@ -240,9 +240,9 @@ static void cmd_complete(struct afu_cmd *cmd) cmd_is_tmf = cmd->cmd_tmf; cmd_checkin(cmd); /* Don't use cmd after here */ - pr_debug("%s: calling scsi_set_resid, scp=%p " -"result=%X resid=%d\n", __func__, -scp, scp->result, resid); + pr_debug_ratelimited("%s: calling scsi_done scp=%p result=%X " +"ioasc=%d\n", __func__, scp, scp->result, +cmd->sa.ioasc); scsi_set_resid(scp, resid); scsi_dma_unmap(scp); @@ -417,12 +417,13 @@ static int send_tmf(struct afu *afu, struct scsi_cmnd *scp, u64 tmfcmd) short lflag = 0; struct Scsi_Host *host = scp->device->host; struct cxlflash_cfg *cfg = (struct cxlflash_cfg *)host->hostdata; + struct device *dev = >dev->dev; ulong lock_flags; int rc = 0; cmd = cmd_checkout(afu); if (unlikely(!cmd)) { - pr_err("%s: could not get a free command\n", __func__); + dev_err(dev, "%s: could not get a free command\n", __func__); rc = SCSI_MLQUEUE_HOST_BUSY; goto out; } @@ -493,7 +494,7 @@ static int cxlflash_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scp) { struct cxlflash_cfg *cfg = (struct cxlflash_cfg *)host->hostdata; struct afu *afu = cfg->afu; - struct pci_dev *pdev = cfg->dev; + struct device *dev = >dev->dev; struct afu_cmd *cmd; u32 port_sel = scp->device->channel + 1; int nseg, i, ncount; @@ -502,13 +503,14 @@ static int cxlflash_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scp) short lflag = 0; int rc = 0; - pr_debug("%s: (scp=%p) %d/%d/%d/%llu cdb=(%08X-%08X-%08X-%08X)\n", -__func__, scp, host->host_no, scp->device->channel, -scp->device->id, scp->device->lun, -get_unaligned_be32(&((u32 *)scp->cmnd)[0]), -get_unaligned_be32(&((u32 *)scp->cmnd)[1]), -get_unaligned_be32(&((u32 *)scp->cmnd)[2]), -get_unaligned_be32(&((u32 *)scp->cmnd)[3])); + dev_dbg_ratelimited(dev, "%s: (scp=%p) %d/%d/%d/%llu " + "cdb=(%08X-%08X-%08X-%08X)\n", + __func__, scp, host->host_no, scp->device->channel, + scp->device->id, scp->device->lun, + get_unaligned_be32(&((u32 *)scp->cmnd)[0]), +
[PATCH v5 17/34] cxlflash: Remove dual port online dependency
At present, both ports must be online for the device to configure properly. Remove this dependency and the unnecessary internal LUN override logic as well. Additionally, as a refactoring measure, change the return code variable name to match that used throughout the driver. With this change, the card will be able to configure even when the link is down. At some later point when the link is transitioned to 'up', a link state change interrupt will trigger the port configuration. Note that despite its void-like behavior, the function was left with a return code for right now in case its behavior needs to be altered again in the near future based on testing. Signed-off-by: Matthew R. OchsSigned-off-by: Manoj N. Kumar Reviewed-by: Brian King --- drivers/scsi/cxlflash/main.c | 27 ++- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c index ed9fd8c..c25efc3 100644 --- a/drivers/scsi/cxlflash/main.c +++ b/drivers/scsi/cxlflash/main.c @@ -1030,7 +1030,7 @@ static int wait_port_offline(u64 *fc_regs, u32 delay_us, u32 nretry) */ static int afu_set_wwpn(struct afu *afu, int port, u64 *fc_regs, u64 wwpn) { - int ret = 0; + int rc = 0; set_port_offline(fc_regs); @@ -1038,33 +1038,26 @@ static int afu_set_wwpn(struct afu *afu, int port, u64 *fc_regs, u64 wwpn) FC_PORT_STATUS_RETRY_CNT)) { pr_debug("%s: wait on port %d to go offline timed out\n", __func__, port); - ret = -1; /* but continue on to leave the port back online */ + rc = -1; /* but continue on to leave the port back online */ } - if (ret == 0) + if (rc == 0) writeq_be(wwpn, _regs[FC_PNAME / 8]); + /* Always return success after programming WWPN */ + rc = 0; + set_port_online(fc_regs); if (!wait_port_online(fc_regs, FC_PORT_STATUS_RETRY_INTERVAL_US, FC_PORT_STATUS_RETRY_CNT)) { - pr_debug("%s: wait on port %d to go online timed out\n", -__func__, port); - ret = -1; - - /* -* Override for internal lun!!! -*/ - if (afu->internal_lun) { - pr_debug("%s: Overriding port %d online timeout!!!\n", -__func__, port); - ret = 0; - } + pr_err("%s: wait on port %d to go online timed out\n", + __func__, port); } - pr_debug("%s: returning rc=%d\n", __func__, ret); + pr_debug("%s: returning rc=%d\n", __func__, rc); - return ret; + return rc; } /** -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v5 30/34] cxlflash: Fix to avoid corrupting adapter fops
The fops owned by the adapter can be corrupted in certain scenarios, opening a window where certain fops are temporarily NULLed before being reset to their proper value. This can potentially lead software to make incorrect decisions, leaving the user with the inability to function as intended. An example of this behavior can be observed when there are a number of users with a high rate of turn around (attach to LUN, perform an I/O, detach from LUN, repeat). Every so often a user is given a valid context and adapter file descriptor, but the file associated with the descriptor lacks the correct read permission bit (FMODE_CAN_READ) and thus the read system call bails before calling the valid read fop. Background: The fops is stored in the adapter structure to provide the ability to lookup the adapter structure from within the fop handler. CXL services use the file's private_data and at present, the CXL context does not have a private section. In an effort to limit areas of the cxlflash driver with code specific the superpipe function, a design choice was made to keep the details of the fops situated away from the legacy portions of the driver. This drove the behavior that the adapter fops is set at the beginning of the disk attach ioctl handler when there are no users present. The corruption that this fix remedies is due to the fact that the fops is initially defaulted to values found within a static structure. When the fops is handed down to the CXL services later in the attach path, certain services are patched. The fops structure remains correct until the user count drops to 0 and the fops is reset, triggering the process to repeat again. The user counts are tightly coupled with the creation and deletion of the user context. If multiple users perform a disk attach at the same time, when the user count is currently 0, some users can be in the middle of obtaining a file descriptor and have not yet reached the context creation code that [in addition to creating the context] increments the user count. Subsequent users coming in to perform the attach see that the user count is still 0, and reinitialize the fops, temporarily removing the patched fops. The users that are in the middle obtaining their file descriptor may then receive an invalid descriptor. The fix simply removes the user count altogether and moves the fops initialization to probe time such that it is only performed one time for the life of the adapter. In the future, if the CXL services adopt a private member for their context, that could be used to store the adapter structure reference and cxlflash could revert to a model that does not require an embedded fops. Signed-off-by: Matthew R. OchsSigned-off-by: Manoj N. Kumar Reviewed-by: Brian King Reviewed-by: Andrew Donnellan Reviewed-by: Daniel Axtens --- drivers/scsi/cxlflash/common.h| 3 +-- drivers/scsi/cxlflash/main.c | 1 + drivers/scsi/cxlflash/superpipe.c | 11 +-- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/drivers/scsi/cxlflash/common.h b/drivers/scsi/cxlflash/common.h index bbfe711..c11cd19 100644 --- a/drivers/scsi/cxlflash/common.h +++ b/drivers/scsi/cxlflash/common.h @@ -21,6 +21,7 @@ #include #include +extern const struct file_operations cxlflash_cxl_fops; #define MAX_CONTEXT CXLFLASH_MAX_CONTEXT /* num contexts per afu */ @@ -115,8 +116,6 @@ struct cxlflash_cfg { struct list_head ctx_err_recovery; /* contexts w/ recovery pending */ struct file_operations cxl_fops; - atomic_t num_user_contexts; - /* Parameters that are LUN table related */ int last_lun_index[CXLFLASH_NUM_FC_PORTS]; int promote_lun_index; diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c index 51883be..3f43879 100644 --- a/drivers/scsi/cxlflash/main.c +++ b/drivers/scsi/cxlflash/main.c @@ -2386,6 +2386,7 @@ static int cxlflash_probe(struct pci_dev *pdev, cfg->init_state = INIT_STATE_NONE; cfg->dev = pdev; + cfg->cxl_fops = cxlflash_cxl_fops; /* * The promoted LUNs move to the top of the LUN table. The rest stay diff --git a/drivers/scsi/cxlflash/superpipe.c b/drivers/scsi/cxlflash/superpipe.c index 3cc8609..f625e07 100644 --- a/drivers/scsi/cxlflash/superpipe.c +++ b/drivers/scsi/cxlflash/superpipe.c @@ -712,7 +712,6 @@ static void destroy_context(struct cxlflash_cfg *cfg, kfree(ctxi->rht_needs_ws); kfree(ctxi->rht_lun); kfree(ctxi); - atomic_dec_if_positive(>num_user_contexts); } /** @@ -769,7 +768,6 @@ static struct ctx_info *create_context(struct cxlflash_cfg *cfg, INIT_LIST_HEAD(>luns); INIT_LIST_HEAD(>list); /* initialize for list_empty() */ - atomic_inc(>num_user_contexts); mutex_lock(>mutex); out: return ctxi; @@ -1164,10 +1162,7
Re: [RFC v2 4/7] powerpc: atomic: Implement xchg_* and atomic{,64}_xchg_* variants
On Thu, Oct 01, 2015 at 07:13:04PM +0200, Peter Zijlstra wrote: > On Thu, Oct 01, 2015 at 08:09:09AM -0700, Paul E. McKenney wrote: > > On Thu, Oct 01, 2015 at 02:24:40PM +0200, Peter Zijlstra wrote: > > > > I must say I'm somewhat surprised by this level of relaxation, I had > > > expected to only loose SMP barriers, not the program order ones. > > > > > > Is there a good argument for this? > > > > Yes, when we say "relaxed", we really mean relaxed. ;-) > > > > Both the CPU and the compiler are allowed to reorder around relaxed > > operations. > > Is this documented somewhere, because I completely missed this part. Well, yes, these need to be added to the documentation. I am assuming that Will is looking to have the same effect as C11 memory_order_relaxed, which is relaxed in this sense. If he has something else in mind, he needs to tell us what it is and why. ;-) Thanx, Paul ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
RE: [PATCH v3 1/2] fsl: Add binding for RCPM
> +++ b/Documentation/devicetree/bindings/soc/fsl/rcpm.txt > @@ -0,0 +1,63 @@ > +* Run Control and Power Management > +--- > +The RCPM performs all device-level tasks associated with device run control > +and power management. > + > +Required properites: > + - reg : Offset and length of the register set of RCPM block. s/RCPM block/the RCPM block/ > + - fsl,#rcpm-wakeup-cells : The number of cells in rcpm-wakeup property. s/rcpm-wakeup-property/the rcpm-wakeup-property/ > + - compatible : Sould contain a chip-specific RCPM block compatible string s/Sould/Should "Should" means it is recommended, but does not mean "must". Is it really optional? > + and (if applicable) may contain a chassis-version RCPM compatible > + string. Chip-specific strings are of the form "fsl,-rcpm", > + such as: > + * "fsl,p2041-rcpm" > + * "fsl,p3041-rcpm" > + * "fsl,p4080-rcpm" > + * "fsl,p5020-rcpm" > + * "fsl,p5040-rcpm" > + * "fsl,t4240-rcpm" > + * "fsl,b4420-rcpm" > + * "fsl,b4860-rcpm" 2 or 3 examples is enough. > + Chassis-version strings are of the form "fsl,qoriq-rcpm-", > + such as: > + * "fsl,qoriq-rcpm-1.0": for chassis 1.0 rcpm > + * "fsl,qoriq-rcpm-2.0": for chassis 2.0 rcpm > + * "fsl,qoriq-rcpm-2.1": for chassis 2.1 rcpm > + > +All references to "1.0" and "2.0" refer to the QorIQ chassis version to > +which the chip complies. > +Chassis VersionExample Chips > +------ > +1.0p4080, p5020, p5040, p2041, p3041 > +2.0t4240, b4860, b4420 > +2.1t1040, ls1021 Not sure this binding is the place to maintain a table of chassis versions to SoCs. Thanks, Stuart ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [RFC v2 4/7] powerpc: atomic: Implement xchg_* and atomic{,64}_xchg_* variants
On Thu, Oct 01, 2015 at 11:03:01AM -0700, Paul E. McKenney wrote: > On Thu, Oct 01, 2015 at 07:13:04PM +0200, Peter Zijlstra wrote: > > On Thu, Oct 01, 2015 at 08:09:09AM -0700, Paul E. McKenney wrote: > > > On Thu, Oct 01, 2015 at 02:24:40PM +0200, Peter Zijlstra wrote: > > > > > > I must say I'm somewhat surprised by this level of relaxation, I had > > > > expected to only loose SMP barriers, not the program order ones. > > > > > > > > Is there a good argument for this? > > > > > > Yes, when we say "relaxed", we really mean relaxed. ;-) > > > > > > Both the CPU and the compiler are allowed to reorder around relaxed > > > operations. > > > > Is this documented somewhere, because I completely missed this part. > > Well, yes, these need to be added to the documentation. I am assuming > that Will is looking to have the same effect as C11 memory_order_relaxed, > which is relaxed in this sense. If he has something else in mind, > he needs to tell us what it is and why. ;-) I suspect he is; but I'm not _that_ up to date on the whole C11 stuff. ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [RFC v2 4/7] powerpc: atomic: Implement xchg_* and atomic{,64}_xchg_* variants
On Thu, Oct 01, 2015 at 08:23:09PM +0200, Peter Zijlstra wrote: > On Thu, Oct 01, 2015 at 11:03:01AM -0700, Paul E. McKenney wrote: > > On Thu, Oct 01, 2015 at 07:13:04PM +0200, Peter Zijlstra wrote: > > > On Thu, Oct 01, 2015 at 08:09:09AM -0700, Paul E. McKenney wrote: > > > > On Thu, Oct 01, 2015 at 02:24:40PM +0200, Peter Zijlstra wrote: > > > > > > > > I must say I'm somewhat surprised by this level of relaxation, I had > > > > > expected to only loose SMP barriers, not the program order ones. > > > > > > > > > > Is there a good argument for this? > > > > > > > > Yes, when we say "relaxed", we really mean relaxed. ;-) > > > > > > > > Both the CPU and the compiler are allowed to reorder around relaxed > > > > operations. > > > > > > Is this documented somewhere, because I completely missed this part. > > > > Well, yes, these need to be added to the documentation. I am assuming > > that Will is looking to have the same effect as C11 memory_order_relaxed, > > which is relaxed in this sense. If he has something else in mind, > > he needs to tell us what it is and why. ;-) > > I suspect he is; but I'm not _that_ up to date on the whole C11 stuff. Lucky you! ;-) Thanx, Paul ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH] drivers/macintosh: adb: fix misleading Kconfig help text
CONFIG_INPUT_KEYBDEV does not exist and no additional keyboard-specific options are needed to get the keyboard working. Signed-off-by: Aaro Koskinen--- drivers/macintosh/Kconfig | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/macintosh/Kconfig b/drivers/macintosh/Kconfig index 5844b80..3e8b29e 100644 --- a/drivers/macintosh/Kconfig +++ b/drivers/macintosh/Kconfig @@ -166,9 +166,8 @@ config INPUT_ADBHID Say Y here if you want to have ADB (Apple Desktop Bus) HID devices such as keyboards, mice, joysticks, trackpads or graphic tablets handled by the input layer. If you say Y here, make sure to say Y to - the corresponding drivers "Keyboard support" (CONFIG_INPUT_KEYBDEV), - "Mouse Support" (CONFIG_INPUT_MOUSEDEV) and "Event interface - support" (CONFIG_INPUT_EVDEV) as well. + the corresponding drivers "Mouse Support" (CONFIG_INPUT_MOUSEDEV) and + "Event interface support" (CONFIG_INPUT_EVDEV) as well. If unsure, say Y. -- 2.4.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH v3 0/5] powerpc/pseries: bug fix and clean up
On 10/1/15, Andy Shevchenkowrote: > Changelog v2: > - fix compiler error > - rebase on top of recent linux-next > - compile tested > > Andy Shevchenko (5): > powerpc/pseries: extract of_helpers module > powerpc/pseries: fix a potential memory leak > powerpc/pseries: replace kmalloc + strlcpy > powerpc/pseries: handle nodes without '/' > powerpc/pseries: re-use code from of_helpers module Ok, looks like it's working for me. Tested-by: Denis Kirjanov > > arch/powerpc/platforms/pseries/Makefile | 1 + > arch/powerpc/platforms/pseries/dlpar.c | 31 + > arch/powerpc/platforms/pseries/of_helpers.c | 35 > + > arch/powerpc/platforms/pseries/of_helpers.h | 8 +++ > arch/powerpc/platforms/pseries/reconfig.c | 34 > ++-- > 5 files changed, 51 insertions(+), 58 deletions(-) > create mode 100644 arch/powerpc/platforms/pseries/of_helpers.c > create mode 100644 arch/powerpc/platforms/pseries/of_helpers.h > > -- > 2.5.1 > > ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH v5 33/34] cxlflash: Fix to avoid leaving dangling interrupt resources
Acked-by: Manoj Kumar___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [RFC v2 6/7] powerpc: atomic: Make atomic{,64}_xchg and xchg a full barrier
Hi Peter, Please forgive me for the format of my reply. I'm travelling, and replying from my phone. 2015年10月1日 下午7:28,"Peter Zijlstra"写道: > > On Wed, Sep 16, 2015 at 11:49:34PM +0800, Boqun Feng wrote: > > According to memory-barriers.txt, xchg and its atomic{,64}_ versions > > need to imply a full barrier, however they are now just RELEASE+ACQUIRE, > > which is not a full barrier. > > > > So remove the definition of xchg(), and let __atomic_op_fence() build > > the full-barrier versions of these operations. > > Do you want to do a patch for -stable fixing the current implementation? Good idea! I didn't think of this before, and I'd love to do the patch, but thing is that I'm not able to use my laptop until Oct 10th. I will send the patch once I'm back. Does that work for you? Regards, Boqun ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH] powerpc/iommu: use iommu_num_pages() to calculate the number of iommu page
On Thu, Oct 01, 2015 at 02:15:45PM +1000, Michael Ellerman wrote: >On Thu, 2015-10-01 at 07:50 +0800, Wei Yang wrote: >> Hmm... some comments on this one? like it or not? > >It sounds like it's fixing a bug, but you don't really say. Have you seen this >fail in the wild? Hmm... as described in the commit log, this would be a bug when PAGE_SIZE is much smaller than IOMMU Page Size. This configuration doesn't happen on current platform. So I didn't see this failure yet. > >Which commit introduced the breakage? Hmm... maybe we could say it is 'commit d084775738b7 '. From this commit, powerpc iommu supports dynamic iommu page size. Before this commit, the size is aligned with PAGE_SIZE, so the value after shift would be non-zero. After this commit, when PAGE_SIZE is smaller than the IOMMU Page Size, shift right will make the size 0. > >cheers > -- Richard Yang Help you, Help me ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v6 52/53] PCI: Introduce resource_disabled()
Current is using !flags, and we are going to use IORESOURCE_DISABLED instead of clearing resource flags. Let's convert all !flags to helper function resource_disabled(). resource_disabled will check !flags and IORESOURCE_DISABLED both. Cc: linux-al...@vger.kernel.org Cc: linux-i...@vger.kernel.org Cc: linux-am33-l...@redhat.com Cc: linuxppc-dev@lists.ozlabs.org Cc: linux-s...@vger.kernel.org Cc: sparcli...@vger.kernel.org Cc: linux-...@vger.kernel.org Cc: linux-xte...@linux-xtensa.org Cc: io...@lists.linux-foundation.org Cc: linux...@vger.kernel.org Signed-off-by: Yinghai Lu--- arch/alpha/kernel/pci.c | 2 +- arch/ia64/pci/pci.c | 4 ++-- arch/microblaze/pci/pci-common.c | 15 --- arch/mn10300/unit-asb2305/pci-asb2305.c | 4 ++-- arch/mn10300/unit-asb2305/pci.c | 4 ++-- arch/powerpc/kernel/pci-common.c | 16 +--- arch/powerpc/platforms/powernv/pci-ioda.c | 12 ++-- arch/s390/pci/pci.c | 2 +- arch/sparc/kernel/pci.c | 2 +- arch/x86/pci/i386.c | 4 ++-- arch/xtensa/kernel/pci.c | 4 ++-- drivers/iommu/intel-iommu.c | 3 ++- drivers/pci/host/pcie-rcar.c | 2 +- drivers/pci/iov.c | 2 +- drivers/pci/probe.c | 2 +- drivers/pci/quirks.c | 4 ++-- drivers/pci/rom.c | 2 +- drivers/pci/setup-bus.c | 8 drivers/pci/setup-res.c | 2 +- include/linux/ioport.h| 4 20 files changed, 53 insertions(+), 45 deletions(-) diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c index 5f387ee..c89c8ef 100644 --- a/arch/alpha/kernel/pci.c +++ b/arch/alpha/kernel/pci.c @@ -282,7 +282,7 @@ pcibios_claim_one_bus(struct pci_bus *b) for (i = 0; i < PCI_NUM_RESOURCES; i++) { struct resource *r = >resource[i]; - if (r->parent || !r->start || !r->flags) + if (r->parent || !r->start || resource_disabled(r)) continue; if (pci_has_flag(PCI_PROBE_ONLY) || (r->flags & IORESOURCE_PCI_FIXED)) { diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c index 7cc3be9..cc293ea 100644 --- a/arch/ia64/pci/pci.c +++ b/arch/ia64/pci/pci.c @@ -501,7 +501,7 @@ void pcibios_fixup_device_resources(struct pci_dev *dev) for (idx = 0; idx < PCI_BRIDGE_RESOURCES; idx++) { struct resource *r = >resource[idx]; - if (!r->flags || r->parent || !r->start) + if (resource_disabled(r) || r->parent || !r->start) continue; pci_claim_resource(dev, idx); @@ -519,7 +519,7 @@ static void pcibios_fixup_bridge_resources(struct pci_dev *dev) for (idx = PCI_BRIDGE_RESOURCES; idx < PCI_NUM_RESOURCES; idx++) { struct resource *r = >resource[idx]; - if (!r->flags || r->parent || !r->start) + if (resource_disabled(r) || r->parent || !r->start) continue; pci_claim_bridge_resource(dev, idx); diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c index 09b1af6..c123d3c 100644 --- a/arch/microblaze/pci/pci-common.c +++ b/arch/microblaze/pci/pci-common.c @@ -705,7 +705,7 @@ static void pcibios_fixup_resources(struct pci_dev *dev) } for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { struct resource *res = dev->resource + i; - if (!res->flags) + if (resource_disabled(res)) continue; if (res->start == 0) { pr_debug("PCI:%s Resource %d %016llx-%016llx [%x]", @@ -806,7 +806,7 @@ static void pcibios_fixup_bridge(struct pci_bus *bus) pci_bus_for_each_resource(bus, res, i) { if (!res) continue; - if (!res->flags) + if (resource_disabled(res)) continue; if (i >= 3 && bus->self->transparent) continue; @@ -985,7 +985,7 @@ static void pcibios_allocate_bus_resources(struct pci_bus *bus) pci_domain_nr(bus), bus->number); pci_bus_for_each_resource(bus, res, i) { - if (!res || !res->flags + if (!res || resource_disabled(res) || res->start > res->end || res->parent) continue; if (bus->parent == NULL) @@ -1087,7 +1087,8 @@ static void __init pcibios_allocate_resources(int pass) r = >resource[idx]; if (r->parent) /* Already allocated */ continue; -
Re: [RFC PATCH 1/2] scripts/kconfig/Makefile: Allow KBUILD_DEFCONFIG to be a target
On Fri, 2015-09-25 at 22:46 +0200, Michal Marek wrote: > Dne 24.9.2015 v 00:16 Michael Ellerman napsal(a): > > > > > > On 23 September 2015 19:50:52 GMT+10:00, Michal Marek > >wrote: > >> On 2015-09-23 07:40, Michael Ellerman wrote: > >>> +else ifneq ($(wildcard > >> arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)),) > >>> @$(kecho) "*** Default configuration is based on > >> '$(KBUILD_DEFCONFIG)'" > >>> $(Q)$< $(silent) > >> --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig) > >>> +else + @$(kecho) "*** Default configuration is based on target > >> '$(KBUILD_DEFCONFIG)'" > >>> + $(Q)$(MAKE) -f $(srctree)/Makefile $(KBUILD_DEFCONFIG) endif > >> > >> What is the anticipated usage of this? The patch is not needed to > >> make > >> > >> make ppc64le_defconfig > >> > >> work with the second patch. If it was, this would create a loop > >> anyway. > > > > The idea is to make 'make defconfig' work when KBUILD_DEFCONFIG is > > ppc64le_defconfig (which happens for us when uname returns ppc64le) > > and additionally when ppc64le_defconfig is not a real file. > > Ah, that makes sense. You can add > > Acked-by: Michal Marek > > if you want. Thanks. I'll assume by that you mean you're happy if I take both patches through the powerpc tree. cheers ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 1/4] powerpc/pseries: Make PCI non-optional
The pseries build with PCI=n looks to have been broken for at least 5 years, and no one's noticed or cared. Following the obvious breakages backward, the first commit I can find that builds is the parent of 2eb4afb69ff3 ("powerpc/pci: Move pseries code into pseries platform specific area") from April 2009. A distro would never ship a PCI=n kernel, so it is only useful for folks building custom kernels. Also on KVM the virtio devices appear on PCI, so it would only be useful if you were building kernels specifically to run on PowerVM and with no PCI devices. The added code complexity, and testing load (which we've clearly not been doing), is not justified by the small reduction in kernel size for such a niche use case. So just make PCI non-optional on pseries. Signed-off-by: Michael Ellerman--- arch/powerpc/platforms/pseries/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/platforms/pseries/Kconfig b/arch/powerpc/platforms/pseries/Kconfig index 54c87d5d349d..d9068a3d6af4 100644 --- a/arch/powerpc/platforms/pseries/Kconfig +++ b/arch/powerpc/platforms/pseries/Kconfig @@ -4,6 +4,7 @@ config PPC_PSERIES select HAVE_PCSPKR_PLATFORM select MPIC select OF_DYNAMIC + select PCI select PCI_MSI select PPC_XICS select PPC_ICP_NATIVE @@ -15,7 +16,6 @@ config PPC_PSERIES select RTAS_ERROR_LOGGING select PPC_UDBG_16550 select PPC_NATIVE - select PPC_PCI_CHOICE if EXPERT select PPC_DOORBELL select HAVE_CONTEXT_TRACKING select HOTPLUG_CPU if SMP -- 2.1.4 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 2/4] powerpc/pseries: Remove use of CONFIG_PCI
Now that we always have CONFIG_PCI=y for pseries, we can stop guarding code with CONFIG_PCI ifdefs. Signed-off-by: Michael Ellerman--- arch/powerpc/platforms/pseries/iommu.c | 10 -- arch/powerpc/platforms/pseries/setup.c | 4 2 files changed, 14 deletions(-) diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c index 0946b98d75d4..bd98ce2be17b 100644 --- a/arch/powerpc/platforms/pseries/iommu.c +++ b/arch/powerpc/platforms/pseries/iommu.c @@ -532,7 +532,6 @@ static int tce_setrange_multi_pSeriesLP_walk(unsigned long start_pfn, return tce_setrange_multi_pSeriesLP(start_pfn, num_pfn, arg); } -#ifdef CONFIG_PCI static void iommu_table_setparms(struct pci_controller *phb, struct device_node *dn, struct iommu_table *tbl) @@ -1292,15 +1291,6 @@ static u64 dma_get_required_mask_pSeriesLP(struct device *dev) return dma_iommu_ops.get_required_mask(dev); } -#else /* CONFIG_PCI */ -#define pci_dma_bus_setup_pSeries NULL -#define pci_dma_dev_setup_pSeries NULL -#define pci_dma_bus_setup_pSeriesLPNULL -#define pci_dma_dev_setup_pSeriesLPNULL -#define dma_set_mask_pSeriesLP NULL -#define dma_get_required_mask_pSeriesLPNULL -#endif /* !CONFIG_PCI */ - static int iommu_mem_notifier(struct notifier_block *nb, unsigned long action, void *data) { diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c index 9a83eb71b030..9e524c26db14 100644 --- a/arch/powerpc/platforms/pseries/setup.c +++ b/arch/powerpc/platforms/pseries/setup.c @@ -837,10 +837,6 @@ static int pSeries_pci_probe_mode(struct pci_bus *bus) return PCI_PROBE_NORMAL; } -#ifndef CONFIG_PCI -void pSeries_final_fixup(void) { } -#endif - struct pci_controller_ops pseries_pci_controller_ops = { .probe_mode = pSeries_pci_probe_mode, }; -- 2.1.4 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [RFC PATCH 1/2] scripts/kconfig/Makefile: Allow KBUILD_DEFCONFIG to be a target
On 2015-10-01 08:14, Michael Ellerman wrote: > On Fri, 2015-09-25 at 22:46 +0200, Michal Marek wrote: >> Dne 24.9.2015 v 00:16 Michael Ellerman napsal(a): >>> >>> >>> On 23 September 2015 19:50:52 GMT+10:00, Michal Marek >>>wrote: On 2015-09-23 07:40, Michael Ellerman wrote: > +else ifneq ($(wildcard arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)),) > @$(kecho) "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'" > $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig) > +else + @$(kecho) "*** Default configuration is based on target '$(KBUILD_DEFCONFIG)'" > + $(Q)$(MAKE) -f $(srctree)/Makefile $(KBUILD_DEFCONFIG) endif What is the anticipated usage of this? The patch is not needed to make make ppc64le_defconfig work with the second patch. If it was, this would create a loop anyway. >>> >>> The idea is to make 'make defconfig' work when KBUILD_DEFCONFIG is >>> ppc64le_defconfig (which happens for us when uname returns ppc64le) >>> and additionally when ppc64le_defconfig is not a real file. >> >> Ah, that makes sense. You can add >> >> Acked-by: Michal Marek >> >> if you want. > > Thanks. I'll assume by that you mean you're happy if I take both patches > through the powerpc tree. Yes, I assumed that this was your plan. Michal ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [GIT PULL 00/16] perf/core improvements and fixes
* Arnaldo Carvalho de Melowrote: > Hi Ingo, > > Please consider pulling, > > - Arnaldo > > The following changes since commit 9c17dbc6eb73bdd8a6aaea1baefd37ff78d86148: > > Merge tag 'perf-core-for-mingo' of > git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core > (2015-09-29 09:43:46 +0200) > > are available in the git repository at: > > git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git > tags/perf-core-for-mingo > > for you to fetch changes up to 7f8d1ade1b19f684ed3a7c4fb1dc5d347127b438: > > perf tools: By default use the most precise "cycles" hw counter available > (2015-09-30 18:34:39 -0300) > > > perf/core improvements and fixes: > > User visible: > > - By default use the most precise "cycles" hw counter available, i.e. > when the user doesn't specify any event, it will try using cycles:ppp, > cycles:pp, etc (Arnaldo Carvalho de Melo) That looks really useful! > - Remove blank lines, headers when piping output in 'perf list', so that it > can > be sanely used with 'wc -l', etc (Arnaldo Carvalho de Melo) > > - Amend documentation about max_stack and synthesized callchains (Adrian > Hunter) > > - Fix 'perf probe -l' for probes added to kernel module functions (Masami > Hiramatsu) > > Build fixes: > > - Fix shadowed declarations that break the build on older distros (Jiri Olsa) > > - Fix build break on powerpc due to sample_reg_masks (Sukadev Bhattiprolu) > > Signed-off-by: Arnaldo Carvalho de Melo > > > Adrian Hunter (1): > perf report: Amend documentation about max_stack and synthesized > callchains > > Arnaldo Carvalho de Melo (7): > perf maps: Introduce maps__find_symbol_by_name() > perf machine: Use machine__kernel_map() thoroughly > perf machine: Add method for common kernel_map(FUNCTION) operation > tools lib symbol: Rename kallsyms2elf_type to kallsyms2elf_binding > tools lib symbol: Introduce kallsyms2elf_type > perf list: Remove blank lines, headers when piping output > perf tools: By default use the most precise "cycles" hw counter > available > > Jiri Olsa (2): > tools: Fix shadowed declaration in err.h > perf tools: Fix shadowed declaration in parse-events.c > > Masami Hiramatsu (5): > perf probe: Fix to remove dot suffix from second or latter events > perf probe: Begin and end libdwfl report session correctly > perf probe: Show correct source lines of probes on kmodules > perf probe: Fix a segfault bug in debuginfo_cache > perf probe: Improve error message when %return is on inlined function > > Sukadev Bhattiprolu (1): > perf tools: Fix build break on powerpc due to sample_reg_masks > > tools/include/linux/err.h| 4 +- > tools/lib/symbol/kallsyms.c | 6 ++ > tools/lib/symbol/kallsyms.h | 4 +- > tools/perf/Documentation/perf-report.txt | 2 + > tools/perf/builtin-kmem.c| 2 +- > tools/perf/builtin-list.c| 2 +- > tools/perf/builtin-report.c | 2 +- > tools/perf/tests/code-reading.c | 2 +- > tools/perf/tests/vmlinux-kallsyms.c | 4 +- > tools/perf/util/Build| 2 +- > tools/perf/util/event.c | 7 +-- > tools/perf/util/evlist.c | 22 +++- > tools/perf/util/intel-pt.c | 2 +- > tools/perf/util/machine.c| 26 - > tools/perf/util/machine.h| 8 ++- > tools/perf/util/map.c| 21 --- > tools/perf/util/map.h| 2 + > tools/perf/util/parse-events.c | 53 +- > tools/perf/util/perf_regs.c | 2 + > tools/perf/util/perf_regs.h | 1 + > tools/perf/util/pmu.c| 2 +- > tools/perf/util/probe-event.c| 96 > > tools/perf/util/probe-finder.c | 58 +-- > tools/perf/util/symbol.c | 2 +- > 24 files changed, 224 insertions(+), 108 deletions(-) Pulled, thanks a lot Arnaldo! Ingo ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 3/4] powerpc/pseries: Move PCI objects to obj-y
Make it entirely clear in the Makefile that we always build the pci related files by moving them to obj-y. Note that CONFIG_EEH is now always enabled on pseries, because it depends on PSERIES && PCI. Signed-off-by: Michael Ellerman--- arch/powerpc/platforms/pseries/Makefile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/platforms/pseries/Makefile b/arch/powerpc/platforms/pseries/Makefile index 03480796af9a..952f4ba0546e 100644 --- a/arch/powerpc/platforms/pseries/Makefile +++ b/arch/powerpc/platforms/pseries/Makefile @@ -3,12 +3,11 @@ ccflags-$(CONFIG_PPC_PSERIES_DEBUG) += -DDEBUG obj-y := lpar.o hvCall.o nvram.o reconfig.o \ setup.o iommu.o event_sources.o ras.o \ - firmware.o power.o dlpar.o mobility.o rng.o + firmware.o power.o dlpar.o mobility.o rng.o \ + pci.o pci_dlpar.o eeh_pseries.o obj-$(CONFIG_SMP) += smp.o obj-$(CONFIG_SCANLOG) += scanlog.o -obj-$(CONFIG_EEH) += eeh_pseries.o obj-$(CONFIG_KEXEC)+= kexec.o -obj-$(CONFIG_PCI) += pci.o pci_dlpar.o obj-$(CONFIG_PSERIES_MSI) += msi.o obj-$(CONFIG_PSERIES_ENERGY) += pseries_energy.o -- 2.1.4 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 4/4] powerpc/pseries: Drop always true CONFIG_PSERIES_MSI
Now that pseries selects PCI_MSI && PCI, EEH will always be true, and therefore CONFIG_PSERIES_MSI will always be true. So drop it, and move msi.o to obj-y. Signed-off-by: Michael Ellerman--- arch/powerpc/platforms/pseries/Kconfig | 5 - arch/powerpc/platforms/pseries/Makefile | 3 +-- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/arch/powerpc/platforms/pseries/Kconfig b/arch/powerpc/platforms/pseries/Kconfig index d9068a3d6af4..bec90fb30425 100644 --- a/arch/powerpc/platforms/pseries/Kconfig +++ b/arch/powerpc/platforms/pseries/Kconfig @@ -43,11 +43,6 @@ config DTL Say N if you are unsure. -config PSERIES_MSI - bool - depends on PCI_MSI && PPC_PSERIES && EEH - default y - config PSERIES_ENERGY tristate "pSeries energy management capabilities driver" depends on PPC_PSERIES diff --git a/arch/powerpc/platforms/pseries/Makefile b/arch/powerpc/platforms/pseries/Makefile index 952f4ba0546e..cf53be157624 100644 --- a/arch/powerpc/platforms/pseries/Makefile +++ b/arch/powerpc/platforms/pseries/Makefile @@ -4,11 +4,10 @@ ccflags-$(CONFIG_PPC_PSERIES_DEBUG) += -DDEBUG obj-y := lpar.o hvCall.o nvram.o reconfig.o \ setup.o iommu.o event_sources.o ras.o \ firmware.o power.o dlpar.o mobility.o rng.o \ - pci.o pci_dlpar.o eeh_pseries.o + pci.o pci_dlpar.o eeh_pseries.o msi.o obj-$(CONFIG_SMP) += smp.o obj-$(CONFIG_SCANLOG) += scanlog.o obj-$(CONFIG_KEXEC)+= kexec.o -obj-$(CONFIG_PSERIES_MSI) += msi.o obj-$(CONFIG_PSERIES_ENERGY) += pseries_energy.o obj-$(CONFIG_HOTPLUG_CPU) += hotplug-cpu.o -- 2.1.4 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [1/3] cxl: fix leak of IRQ names in cxl_free_afu_irqs()
On Wed, 2015-30-09 at 01:58:05 UTC, Andrew Donnellan wrote: > cxl_free_afu_irqs() doesn't free IRQ names when it releases an AFU's IRQ > ranges. The userspace API equivalent in afu_release_irqs() calls > afu_irq_name_free() to release the IRQ names. > > Call afu_irq_name_free() in cxl_free_afu_irqs() to release the IRQ names. > Make afu_irq_name_free() non-static to allow this. > > Reported-by: Matthew R. Ochs> Fixes: 6f7f0b3df6d4 ("cxl: Add AFU virtual PHB and kernel API") > Signed-off-by: Andrew Donnellan > Signed-off-by: Ian Munsie > Reviewed-by: Matthew R. Ochs Applied to powerpc fixes, thanks. https://git.kernel.org/powerpc/c/8dde152ea34860403c839598 cheers ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [2/3] cxl: fix leak of ctx->irq_bitmap when releasing context via kernel API
On Wed, 2015-30-09 at 01:58:06 UTC, Andrew Donnellan wrote: > At present, ctx->irq_bitmap is freed in afu_release_irqs(), which is called > from afu_release() via cxl_context_detach(). > > Move the freeing of ctx->irq_bitmap from afu_release_irqs() to > reclaim_ctx() (called through cxl_context_free()) so it's freed when > releasing a context via the kernel API (cxl_release_context()) or the > userspace API (afu_release()). > > Reported-by: Matthew R. Ochs> Fixes: 6f7f0b3df6d4 ("cxl: Add AFU virtual PHB and kernel API") > Signed-off-by: Andrew Donnellan > Acked-by: Ian Munsie > Reviewed-by: Matthew R. Ochs Applied to powerpc fixes, thanks. https://git.kernel.org/powerpc/c/52adee580d3c71a0dfabc316 cheers ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [v2,5/5] powerpc/pseries: re-use code from of_helpers module
On 10/1/15, Michael Ellermanwrote: > On Wed, 2015-09-30 at 19:19 +0300, Andy Shevchenko wrote: >> On Fri, 2015-08-14 at 21:51 +1000, Michael Ellerman wrote: >> > On Tue, 2015-11-08 at 11:23:09 UTC, Andy Shevchenko wrote: >> > > int dlpar_attach_node(struct device_node *dn) >> > > { >> > > int rc; >> > > >> > > -dn->parent = derive_parent(dn->full_name); >> > > -if (!dn->parent) >> > > -return -ENOMEM; >> > > +dn->parent = pseries_of_derive_parent(dn->full_name); >> > > +if (IS_ERR(dn->parent)) >> > > +return PTR_ERR(dn_parent); >> > ^ >> > ? >> > >> > There are cross compilers on kernel.org, or on Ubuntu you can just: >> > >> > $ apt-get install gcc-powerpc-linux-gnu >> > $ make ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu-gcc >> >> Thanks! I tried today and the above the only problem with the series. >> Would you like me to resend whole series? > > I'd like someone to test it. I gather that you haven't because it didn't > compile. Oh yeah, totally untested: CC arch/powerpc/platforms/pseries/dlpar.o arch/powerpc/platforms/pseries/dlpar.c: In function 'dlpar_attach_node': arch/powerpc/platforms/pseries/dlpar.c:255:18: error: 'dn_parent' undeclared (first use in this function) return PTR_ERR(dn_parent); ^ arch/powerpc/platforms/pseries/dlpar.c:255:18: note: each undeclared identifier is reported only once for each function it appears in scripts/Makefile.build:258: recipe for target 'arch/powerpc/platforms/pseries/dlpar.o' failed make[2]: *** [arch/powerpc/platforms/pseries/dlpar.o] Error 1 scripts/Makefile.build:403: recipe for target 'arch/powerpc/platforms/pseries' failed make[1]: *** [arch/powerpc/platforms/pseries] Error 2 Makefile:941: recipe for target 'arch/powerpc/platforms' failed make: *** [arch/powerpc/platforms] Error 2 > > I assume you don't have access to hardware to test it on? > > cheers > > > > ___ > Linuxppc-dev mailing list > Linuxppc-dev@lists.ozlabs.org > https://lists.ozlabs.org/listinfo/linuxppc-dev ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [RFC PATCH 1/2] scripts/kconfig/Makefile: Allow KBUILD_DEFCONFIG to be a target
On Thu, 2015-10-01 at 08:50 +0200, Michal Marek wrote: > On 2015-10-01 08:14, Michael Ellerman wrote: > > On Fri, 2015-09-25 at 22:46 +0200, Michal Marek wrote: > >> Dne 24.9.2015 v 00:16 Michael Ellerman napsal(a): > >>> On 23 September 2015 19:50:52 GMT+10:00, Michal Marek > >>>wrote: > On 2015-09-23 07:40, Michael Ellerman wrote: > > +else ifneq ($(wildcard > arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)),) > > @$(kecho) "*** Default configuration is based on > '$(KBUILD_DEFCONFIG)'" > > $(Q)$< $(silent) > --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig) > > +else + @$(kecho) "*** Default configuration is based on target > '$(KBUILD_DEFCONFIG)'" > > + $(Q)$(MAKE) -f $(srctree)/Makefile $(KBUILD_DEFCONFIG) endif > > What is the anticipated usage of this? The patch is not needed to > make > > make ppc64le_defconfig > > work with the second patch. If it was, this would create a loop > anyway. > >>> > >>> The idea is to make 'make defconfig' work when KBUILD_DEFCONFIG is > >>> ppc64le_defconfig (which happens for us when uname returns ppc64le) > >>> and additionally when ppc64le_defconfig is not a real file. > >> > >> Ah, that makes sense. You can add > >> > >> Acked-by: Michal Marek > >> > >> if you want. > > > > Thanks. I'll assume by that you mean you're happy if I take both patches > > through the powerpc tree. > > Yes, I assumed that this was your plan. I didn't really have a plan :) It's certainly easiest if I take it in my tree along with the new ppc64le_defconfig, so I'll do that. Thanks. cheers ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v6 40/53] PCI: Unify skip_ioresource_align()
There are powerpc generic version and x86 local version for skip_ioresource_align(). Move the powerpc version to setup-bus.c, and kill x86 local version. Also kill dummy version in microblaze. Cc: Michal SimekCc: Paul Mackerras Cc: Michael Ellerman Cc: Arnd Bergmann Cc: linuxppc-dev@lists.ozlabs.org Cc: linux-a...@vger.kernel.org Signed-off-by: Yinghai Lu --- arch/microblaze/pci/pci-common.c | 8 arch/powerpc/kernel/pci-common.c | 11 +-- arch/x86/include/asm/pci_x86.h | 1 - arch/x86/pci/common.c| 4 ++-- arch/x86/pci/i386.c | 12 ++-- drivers/pci/setup-bus.c | 9 + include/asm-generic/pci-bridge.h | 2 ++ 7 files changed, 16 insertions(+), 31 deletions(-) diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c index ae838ed..09b1af6 100644 --- a/arch/microblaze/pci/pci-common.c +++ b/arch/microblaze/pci/pci-common.c @@ -878,11 +878,6 @@ void pcibios_fixup_bus(struct pci_bus *bus) } EXPORT_SYMBOL(pcibios_fixup_bus); -static int skip_isa_ioresource_align(struct pci_dev *dev) -{ - return 0; -} - /* * We need to avoid collisions with `mirrored' VGA ports * and other strange ISA hardware, so we always want the @@ -899,12 +894,9 @@ static int skip_isa_ioresource_align(struct pci_dev *dev) resource_size_t pcibios_align_resource(void *data, const struct resource *res, resource_size_t size, resource_size_t align) { - struct pci_dev *dev = data; resource_size_t start = res->start; if (res->flags & IORESOURCE_IO) { - if (skip_isa_ioresource_align(dev)) - return start; if (start & 0x300) start = (start + 0x3ff) & ~0x3ff; } diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c index 7587b2a..8853667 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c @@ -1052,15 +1052,6 @@ void pci_fixup_cardbus(struct pci_bus *bus) pcibios_setup_bus_devices(bus); } - -static int skip_isa_ioresource_align(struct pci_dev *dev) -{ - if (pci_has_flag(PCI_CAN_SKIP_ISA_ALIGN) && - !(dev->bus->bridge_ctl & PCI_BRIDGE_CTL_ISA)) - return 1; - return 0; -} - /* * We need to avoid collisions with `mirrored' VGA ports * and other strange ISA hardware, so we always want the @@ -1081,7 +1072,7 @@ resource_size_t pcibios_align_resource(void *data, const struct resource *res, resource_size_t start = res->start; if (res->flags & IORESOURCE_IO) { - if (skip_isa_ioresource_align(dev)) + if (skip_isa_ioresource_align(dev->bus)) return start; if (start & 0x300) start = (start + 0x3ff) & ~0x3ff; diff --git a/arch/x86/include/asm/pci_x86.h b/arch/x86/include/asm/pci_x86.h index fa1195d..81a7abf 100644 --- a/arch/x86/include/asm/pci_x86.h +++ b/arch/x86/include/asm/pci_x86.h @@ -28,7 +28,6 @@ do { \ #define PCI_ASSIGN_ROMS0x1000 #define PCI_BIOS_IRQ_SCAN 0x2000 #define PCI_ASSIGN_ALL_BUSSES 0x4000 -#define PCI_CAN_SKIP_ISA_ALIGN 0x8000 #define PCI_USE__CRS 0x1 #define PCI_CHECK_ENABLE_AMD_MMCONF0x2 #define PCI_HAS_IO_ECS 0x4 diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c index dc78a4a..7c018df 100644 --- a/arch/x86/pci/common.c +++ b/arch/x86/pci/common.c @@ -83,7 +83,7 @@ DEFINE_RAW_SPINLOCK(pci_config_lock); static int __init can_skip_ioresource_align(const struct dmi_system_id *d) { - pci_probe |= PCI_CAN_SKIP_ISA_ALIGN; + pci_add_flags(PCI_CAN_SKIP_ISA_ALIGN); printk(KERN_INFO "PCI: %s detected, can skip ISA alignment\n", d->ident); return 0; } @@ -619,7 +619,7 @@ char *__init pcibios_setup(char *str) pci_routeirq = 1; return NULL; } else if (!strcmp(str, "skip_isa_align")) { - pci_probe |= PCI_CAN_SKIP_ISA_ALIGN; + pci_add_flags(PCI_CAN_SKIP_ISA_ALIGN); return NULL; } else if (!strcmp(str, "noioapicquirk")) { noioapicquirk = 1; diff --git a/arch/x86/pci/i386.c b/arch/x86/pci/i386.c index 0a9f2ca..3f17726 100644 --- a/arch/x86/pci/i386.c +++ b/arch/x86/pci/i386.c @@ -33,6 +33,7 @@ #include #include +#include #include #include #include @@ -128,15 +129,6 @@ static void __init pcibios_fw_addr_list_del(void) pcibios_fw_addr_done = true; } -static int -skip_isa_ioresource_align(struct pci_dev *dev) { - - if ((pci_probe & PCI_CAN_SKIP_ISA_ALIGN) && - !(dev->bus->bridge_ctl & PCI_BRIDGE_CTL_ISA)) - return 1; - return 0; -} - /* * We need to avoid collisions with `mirrored'
Re: [1/3] cxl: fix leak of IRQ names in cxl_free_afu_irqs()
On Wed, 2015-30-09 at 01:58:05 UTC, Andrew Donnellan wrote: > cxl_free_afu_irqs() doesn't free IRQ names when it releases an AFU's IRQ > ranges. The userspace API equivalent in afu_release_irqs() calls > afu_irq_name_free() to release the IRQ names. > > Call afu_irq_name_free() in cxl_free_afu_irqs() to release the IRQ names. > Make afu_irq_name_free() non-static to allow this. > > Reported-by: Matthew R. Ochs> Fixes: 6f7f0b3df6d4 ("cxl: Add AFU virtual PHB and kernel API") > Signed-off-by: Andrew Donnellan > Signed-off-by: Ian Munsie > Reviewed-by: Matthew R. Ochs Applied to powerpc fixes, thanks. https://git.kernel.org/powerpc/c/8dde152ea34860403c839598 cheers ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [3/3] cxl: fix leak of ctx->mapping when releasing kernel API contexts
On Wed, 2015-30-09 at 01:58:07 UTC, Andrew Donnellan wrote: > When a context is created via the kernel API, ctx->mapping is allocated > within the kernel and thus needs to be freed when the context is freed. > reclaim_ctx() attempts to do this for contexts with the ctx->kernelapi flag > set, but afu_release() (which can be called from the kernel API through > cxl_fd_release()) sets ctx->mapping to NULL before calling > cxl_context_free() to free the context. > > Add a check to afu_release() so that the mappings in contexts created via > the kernel API are left alone so reclaim_ctx() can free them. > > Reported-by: Matthew R. Ochs> Fixes: 6f7f0b3df6d4 ("cxl: Add AFU virtual PHB and kernel API") > Signed-off-by: Andrew Donnellan > Acked-by: Ian Munsie > Reviewed-by: Matthew R. Ochs Applied to powerpc fixes, thanks. https://git.kernel.org/powerpc/c/5f81b95fe2a2de4ec51d46ff cheers ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH v5 17/34] cxlflash: Remove dual port online dependency
"Matthew R. Ochs"writes: > At present, both ports must be online for the device to > configure properly. Remove this dependency and the unnecessary > internal LUN override logic as well. Additionally, as a refactoring > measure, change the return code variable name to match that used > throughout the driver. > > With this change, the card will be able to configure even when the > link is down. At some later point when the link is transitioned to > 'up', a link state change interrupt will trigger the port configuration. > Note that despite its void-like behavior, the function was left with a > return code for right now in case its behavior needs to be altered again > in the near future based on testing. > Thanks for updating that. Reviewed-by: Daniel Axtens Regards, Daniel > Signed-off-by: Matthew R. Ochs > Signed-off-by: Manoj N. Kumar > Reviewed-by: Brian King > --- > drivers/scsi/cxlflash/main.c | 27 ++- > 1 file changed, 10 insertions(+), 17 deletions(-) > > diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c > index ed9fd8c..c25efc3 100644 > --- a/drivers/scsi/cxlflash/main.c > +++ b/drivers/scsi/cxlflash/main.c > @@ -1030,7 +1030,7 @@ static int wait_port_offline(u64 *fc_regs, u32 > delay_us, u32 nretry) > */ > static int afu_set_wwpn(struct afu *afu, int port, u64 *fc_regs, u64 wwpn) > { > - int ret = 0; > + int rc = 0; > > set_port_offline(fc_regs); > > @@ -1038,33 +1038,26 @@ static int afu_set_wwpn(struct afu *afu, int port, > u64 *fc_regs, u64 wwpn) > FC_PORT_STATUS_RETRY_CNT)) { > pr_debug("%s: wait on port %d to go offline timed out\n", >__func__, port); > - ret = -1; /* but continue on to leave the port back online */ > + rc = -1; /* but continue on to leave the port back online */ > } > > - if (ret == 0) > + if (rc == 0) > writeq_be(wwpn, _regs[FC_PNAME / 8]); > > + /* Always return success after programming WWPN */ > + rc = 0; > + > set_port_online(fc_regs); > > if (!wait_port_online(fc_regs, FC_PORT_STATUS_RETRY_INTERVAL_US, > FC_PORT_STATUS_RETRY_CNT)) { > - pr_debug("%s: wait on port %d to go online timed out\n", > - __func__, port); > - ret = -1; > - > - /* > - * Override for internal lun!!! > - */ > - if (afu->internal_lun) { > - pr_debug("%s: Overriding port %d online timeout!!!\n", > - __func__, port); > - ret = 0; > - } > + pr_err("%s: wait on port %d to go online timed out\n", > +__func__, port); > } > > - pr_debug("%s: returning rc=%d\n", __func__, ret); > + pr_debug("%s: returning rc=%d\n", __func__, rc); > > - return ret; > + return rc; > } > > /** > -- > 2.1.0 > > ___ > Linuxppc-dev mailing list > Linuxppc-dev@lists.ozlabs.org > https://lists.ozlabs.org/listinfo/linuxppc-dev signature.asc Description: PGP signature ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH v5 18/34] cxlflash: Fix AFU version access/storage and add check
> On Oct 1, 2015, at 7:56 PM, Daniel Axtenswrote: > > "Matthew R. Ochs" writes: > >> The AFU version is stored as a non-terminated string of bytes within >> a 64-bit little-endian register. Presently the value is read directly >> (no MMIO accessor) and is stored in a buffer that is not big enough >> to contain a NULL terminator. Additionally the version obtained is not >> evaluated against a known value to prevent usage with unsupported AFUs. >> All of these deficiencies can lead to a variety of problems. >> >> +if ((afu->interface_version + 1) == 0) { >> +pr_err("Back level AFU, please upgrade. AFU version %s " >> + "interface version 0x%llx\n", afu->version, >> + afu->interface_version); >> +rc = -EINVAL; >> +goto err1; > > I'm confused by this if statement. If afu->interface_version + 1 == 0, > and interface_version is a 64bit unsigned int, that would mean that > afu->interface_version was 0x . > > Are you trying to check against all Fs? Is that value significant in the > hardware? Correct, downlevel (unsupported) AFUs don't implement the interface_version register and thus will return -1 at that offset. ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [RFC PATCH 0/8] clk: qoriq: Move chip-specific knowledge into driver
[Resending to updated e-mail address] On Tue, 2015-08-11 at 11:25 -0700, Michael Turquette wrote: > Hi Scott, > > Quoting Scott Wood (2015-06-18 19:49:10) > > The existing device tree bindings are error-prone and inflexible. > > Correct the mistake by moving the knowledge into the driver, which > > has more flexibility in describing the quirks of each chip. This leaves > > the device tree to its proper role of identifying a programming interface > > rather than describing its individual registers. > > Sorry for not responding to this one sooner. Fell through the cracks. > > All of the changes to drives/clk/clk-qoriq.c look great to me. I assume > you need to keep all of these patches together and want to the take > through the freescale tree? If so feel free to add, > > Acked-by: Michael TurquetteIs the ack still valid for the v3 patchset? -Scott ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH v5 18/34] cxlflash: Fix AFU version access/storage and add check
"Matthew R. Ochs"writes: > The AFU version is stored as a non-terminated string of bytes within > a 64-bit little-endian register. Presently the value is read directly > (no MMIO accessor) and is stored in a buffer that is not big enough > to contain a NULL terminator. Additionally the version obtained is not > evaluated against a known value to prevent usage with unsupported AFUs. > All of these deficiencies can lead to a variety of problems. > > + if ((afu->interface_version + 1) == 0) { > + pr_err("Back level AFU, please upgrade. AFU version %s " > +"interface version 0x%llx\n", afu->version, > +afu->interface_version); > + rc = -EINVAL; > + goto err1; I'm confused by this if statement. If afu->interface_version + 1 == 0, and interface_version is a 64bit unsigned int, that would mean that afu->interface_version was 0x . Are you trying to check against all Fs? Is that value significant in the hardware? Regards, Daniel > + } else > + pr_debug("%s: afu version %s, interface version 0x%llX\n", > + __func__, afu->version, afu->interface_version); > > rc = start_afu(cfg); > if (rc) { > diff --git a/drivers/scsi/cxlflash/sislite.h b/drivers/scsi/cxlflash/sislite.h > index 63bf394..8425d1a 100644 > --- a/drivers/scsi/cxlflash/sislite.h > +++ b/drivers/scsi/cxlflash/sislite.h > @@ -340,7 +340,7 @@ struct sisl_global_regs { > #define SISL_AFUCONF_MBOX_CLR_READ 0x0010ULL > __be64 afu_config; > __be64 rsvd[0xf8]; > - __be64 afu_version; > + __le64 afu_version; > __be64 interface_version; > }; > > -- > 2.1.0 > > ___ > Linuxppc-dev mailing list > Linuxppc-dev@lists.ozlabs.org > https://lists.ozlabs.org/listinfo/linuxppc-dev ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [RFC PATCH 0/8] clk: qoriq: Move chip-specific knowledge into driver
On Tue, 2015-08-11 at 11:25 -0700, Michael Turquette wrote: > Hi Scott, > > Quoting Scott Wood (2015-06-18 19:49:10) > > The existing device tree bindings are error-prone and inflexible. > > Correct the mistake by moving the knowledge into the driver, which > > has more flexibility in describing the quirks of each chip. This leaves > > the device tree to its proper role of identifying a programming interface > > rather than describing its individual registers. > > Sorry for not responding to this one sooner. Fell through the cracks. > > All of the changes to drives/clk/clk-qoriq.c look great to me. I assume > you need to keep all of these patches together and want to the take > through the freescale tree? If so feel free to add, > > Acked-by: Michael TurquetteIs the ack still valid for the v3 patchset? -Scott ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [v3 1/8] devres: add devm_alloc_percpu()
On Thu, Sep 24, 2015 at 06:00:12PM +0300, Madalin Bucur wrote: > Introduce managed counterparts for alloc_percpu() and free_percpu(). > Add devm_alloc_percpu() and devm_free_percpu() into the managed > interfaces list. > > Signed-off-by: Madalin Bucur> Tested-by: Madalin-Cristian Bucur > --- > Documentation/driver-model/devres.txt | 4 +++ > drivers/base/devres.c | 64 > +++ > include/linux/device.h| 19 +++ > 3 files changed, 87 insertions(+) Greg KH needs to be CCed on any drivers/base changes. -Scott ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 0/5] powerpc/pseries: bug fix and clean up
Changelog v2: - fix compiler error - rebase on top of recent linux-next - compile tested Andy Shevchenko (5): powerpc/pseries: extract of_helpers module powerpc/pseries: fix a potential memory leak powerpc/pseries: replace kmalloc + strlcpy powerpc/pseries: handle nodes without '/' powerpc/pseries: re-use code from of_helpers module arch/powerpc/platforms/pseries/Makefile | 1 + arch/powerpc/platforms/pseries/dlpar.c | 31 + arch/powerpc/platforms/pseries/of_helpers.c | 35 + arch/powerpc/platforms/pseries/of_helpers.h | 8 +++ arch/powerpc/platforms/pseries/reconfig.c | 34 ++-- 5 files changed, 51 insertions(+), 58 deletions(-) create mode 100644 arch/powerpc/platforms/pseries/of_helpers.c create mode 100644 arch/powerpc/platforms/pseries/of_helpers.h -- 2.5.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 3/5] powerpc/pseries: replace kmalloc + strlcpy
The helper kstrndup() will do the same in one line. Signed-off-by: Andy Shevchenko--- arch/powerpc/platforms/pseries/of_helpers.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/powerpc/platforms/pseries/of_helpers.c b/arch/powerpc/platforms/pseries/of_helpers.c index 2f363e3..8c6b05a 100644 --- a/arch/powerpc/platforms/pseries/of_helpers.c +++ b/arch/powerpc/platforms/pseries/of_helpers.c @@ -24,10 +24,9 @@ struct device_node *pseries_of_derive_parent(const char *path) return ERR_PTR(-EINVAL); if (strrchr(path, '/') != path) { - parent_path = kmalloc(parent_path_len, GFP_KERNEL); + parent_path = kstrndup(path, parent_path_len, GFP_KERNEL); if (!parent_path) return ERR_PTR(-ENOMEM); - strlcpy(parent_path, path, parent_path_len); } parent = of_find_node_by_path(parent_path); if (strcmp(parent_path, "/")) -- 2.5.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 5/5] powerpc/pseries: re-use code from of_helpers module
The derive_parent() has similar semantics to what we have in newly introduced of_helpers module. The replacement reduces code base and propagates the actual error code to the caller. Signed-off-by: Andy Shevchenko--- arch/powerpc/platforms/pseries/dlpar.c | 31 +-- 1 file changed, 5 insertions(+), 26 deletions(-) diff --git a/arch/powerpc/platforms/pseries/dlpar.c b/arch/powerpc/platforms/pseries/dlpar.c index db17827..f244dcb 100644 --- a/arch/powerpc/platforms/pseries/dlpar.c +++ b/arch/powerpc/platforms/pseries/dlpar.c @@ -18,6 +18,8 @@ #include #include #include + +#include "of_helpers.h" #include "offline_states.h" #include "pseries.h" @@ -244,36 +246,13 @@ cc_error: return first_dn; } -static struct device_node *derive_parent(const char *path) -{ - struct device_node *parent; - char *last_slash; - - last_slash = strrchr(path, '/'); - if (last_slash == path) { - parent = of_find_node_by_path("/"); - } else { - char *parent_path; - int parent_path_len = last_slash - path + 1; - parent_path = kmalloc(parent_path_len, GFP_KERNEL); - if (!parent_path) - return NULL; - - strlcpy(parent_path, path, parent_path_len); - parent = of_find_node_by_path(parent_path); - kfree(parent_path); - } - - return parent; -} - int dlpar_attach_node(struct device_node *dn) { int rc; - dn->parent = derive_parent(dn->full_name); - if (!dn->parent) - return -ENOMEM; + dn->parent = pseries_of_derive_parent(dn->full_name); + if (IS_ERR(dn->parent)) + return PTR_ERR(dn->parent); rc = of_attach_node(dn); if (rc) { -- 2.5.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 1/5] powerpc/pseries: extract of_helpers module
Extract a new module to share the code between other modules. There is no functional change. Signed-off-by: Andy Shevchenko--- arch/powerpc/platforms/pseries/Makefile | 1 + arch/powerpc/platforms/pseries/of_helpers.c | 38 + arch/powerpc/platforms/pseries/of_helpers.h | 8 ++ arch/powerpc/platforms/pseries/reconfig.c | 34 ++ 4 files changed, 49 insertions(+), 32 deletions(-) create mode 100644 arch/powerpc/platforms/pseries/of_helpers.c create mode 100644 arch/powerpc/platforms/pseries/of_helpers.h diff --git a/arch/powerpc/platforms/pseries/Makefile b/arch/powerpc/platforms/pseries/Makefile index 0348079..2e857c2 100644 --- a/arch/powerpc/platforms/pseries/Makefile +++ b/arch/powerpc/platforms/pseries/Makefile @@ -2,6 +2,7 @@ ccflags-$(CONFIG_PPC64) := $(NO_MINIMAL_TOC) ccflags-$(CONFIG_PPC_PSERIES_DEBUG)+= -DDEBUG obj-y := lpar.o hvCall.o nvram.o reconfig.o \ + of_helpers.o \ setup.o iommu.o event_sources.o ras.o \ firmware.o power.o dlpar.o mobility.o rng.o obj-$(CONFIG_SMP) += smp.o diff --git a/arch/powerpc/platforms/pseries/of_helpers.c b/arch/powerpc/platforms/pseries/of_helpers.c new file mode 100644 index 000..1cbd896 --- /dev/null +++ b/arch/powerpc/platforms/pseries/of_helpers.c @@ -0,0 +1,38 @@ +#include +#include +#include +#include + +#include "of_helpers.h" + +/** + * pseries_of_derive_parent - basically like dirname(1) + * @path: the full_name of a node to be added to the tree + * + * Returns the node which should be the parent of the node + * described by path. E.g., for path = "/foo/bar", returns + * the node with full_name = "/foo". + */ +struct device_node *pseries_of_derive_parent(const char *path) +{ + struct device_node *parent = NULL; + char *parent_path = "/"; + size_t parent_path_len = strrchr(path, '/') - path + 1; + + /* reject if path is "/" */ + if (!strcmp(path, "/")) + return ERR_PTR(-EINVAL); + + if (strrchr(path, '/') != path) { + parent_path = kmalloc(parent_path_len, GFP_KERNEL); + if (!parent_path) + return ERR_PTR(-ENOMEM); + strlcpy(parent_path, path, parent_path_len); + } + parent = of_find_node_by_path(parent_path); + if (!parent) + return ERR_PTR(-EINVAL); + if (strcmp(parent_path, "/")) + kfree(parent_path); + return parent; +} diff --git a/arch/powerpc/platforms/pseries/of_helpers.h b/arch/powerpc/platforms/pseries/of_helpers.h new file mode 100644 index 000..bb83d39 --- /dev/null +++ b/arch/powerpc/platforms/pseries/of_helpers.h @@ -0,0 +1,8 @@ +#ifndef _PSERIES_OF_HELPERS_H +#define _PSERIES_OF_HELPERS_H + +#include + +struct device_node *pseries_of_derive_parent(const char *path); + +#endif /* _PSERIES_OF_HELPERS_H */ diff --git a/arch/powerpc/platforms/pseries/reconfig.c b/arch/powerpc/platforms/pseries/reconfig.c index 0f31952..7c7fcc0 100644 --- a/arch/powerpc/platforms/pseries/reconfig.c +++ b/arch/powerpc/platforms/pseries/reconfig.c @@ -22,37 +22,7 @@ #include #include -/** - * derive_parent - basically like dirname(1) - * @path: the full_name of a node to be added to the tree - * - * Returns the node which should be the parent of the node - * described by path. E.g., for path = "/foo/bar", returns - * the node with full_name = "/foo". - */ -static struct device_node *derive_parent(const char *path) -{ - struct device_node *parent = NULL; - char *parent_path = "/"; - size_t parent_path_len = strrchr(path, '/') - path + 1; - - /* reject if path is "/" */ - if (!strcmp(path, "/")) - return ERR_PTR(-EINVAL); - - if (strrchr(path, '/') != path) { - parent_path = kmalloc(parent_path_len, GFP_KERNEL); - if (!parent_path) - return ERR_PTR(-ENOMEM); - strlcpy(parent_path, path, parent_path_len); - } - parent = of_find_node_by_path(parent_path); - if (!parent) - return ERR_PTR(-EINVAL); - if (strcmp(parent_path, "/")) - kfree(parent_path); - return parent; -} +#include "of_helpers.h" static int pSeries_reconfig_add_node(const char *path, struct property *proplist) { @@ -71,7 +41,7 @@ static int pSeries_reconfig_add_node(const char *path, struct property *proplist of_node_set_flag(np, OF_DYNAMIC); of_node_init(np); - np->parent = derive_parent(path); + np->parent = pseries_of_derive_parent(path); if (IS_ERR(np->parent)) { err = PTR_ERR(np->parent); goto out_err; -- 2.5.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org
[PATCH v3 2/5] powerpc/pseries: fix a potential memory leak
In case we have a full node name like /foo/bar and /foo is not found the parent_path left unfreed. So, free a memory before return to a caller. Signed-off-by: Andy Shevchenko--- arch/powerpc/platforms/pseries/of_helpers.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/arch/powerpc/platforms/pseries/of_helpers.c b/arch/powerpc/platforms/pseries/of_helpers.c index 1cbd896..2f363e3 100644 --- a/arch/powerpc/platforms/pseries/of_helpers.c +++ b/arch/powerpc/platforms/pseries/of_helpers.c @@ -15,7 +15,7 @@ */ struct device_node *pseries_of_derive_parent(const char *path) { - struct device_node *parent = NULL; + struct device_node *parent; char *parent_path = "/"; size_t parent_path_len = strrchr(path, '/') - path + 1; @@ -30,9 +30,7 @@ struct device_node *pseries_of_derive_parent(const char *path) strlcpy(parent_path, path, parent_path_len); } parent = of_find_node_by_path(parent_path); - if (!parent) - return ERR_PTR(-EINVAL); if (strcmp(parent_path, "/")) kfree(parent_path); - return parent; + return parent ? parent : ERR_PTR(-EINVAL); } -- 2.5.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 4/5] powerpc/pseries: handle nodes without '/'
In case we have node without '/' strrchr() returns NULL which might lead to crash. Replace strrchr() by kbasename() and modify condition to avoid such behaviour. Suggested-by: Segher BoessenkoolSigned-off-by: Andy Shevchenko --- arch/powerpc/platforms/pseries/of_helpers.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/platforms/pseries/of_helpers.c b/arch/powerpc/platforms/pseries/of_helpers.c index 8c6b05a..4417afe 100644 --- a/arch/powerpc/platforms/pseries/of_helpers.c +++ b/arch/powerpc/platforms/pseries/of_helpers.c @@ -17,14 +17,14 @@ struct device_node *pseries_of_derive_parent(const char *path) { struct device_node *parent; char *parent_path = "/"; - size_t parent_path_len = strrchr(path, '/') - path + 1; + const char *tail = kbasename(path); /* reject if path is "/" */ if (!strcmp(path, "/")) return ERR_PTR(-EINVAL); - if (strrchr(path, '/') != path) { - parent_path = kstrndup(path, parent_path_len, GFP_KERNEL); + if (tail > path + 1) { + parent_path = kstrndup(path, tail - path, GFP_KERNEL); if (!parent_path) return ERR_PTR(-ENOMEM); } -- 2.5.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [v5, 2/6] fsl/fman: Add FMan support
On Thu, Sep 24, 2015 at 12:10:34PM +0300, igal.liber...@freescale.com wrote: > +int fman_get_rx_extra_headroom(void) > +{ > + static bool fm_check_rx_extra_headroom; > + > + if (!fm_check_rx_extra_headroom) { > + if (fsl_fm_rx_extra_headroom > FSL_FM_RX_EXTRA_HEADROOM_MAX || > + fsl_fm_rx_extra_headroom < FSL_FM_RX_EXTRA_HEADROOM_MIN) { > + pr_warn("Invalid fsl_fm_rx_extra_headroom value (%d) in > bootargs, valid range is %d-%d. Falling back to the default (%d)\n", > + fsl_fm_rx_extra_headroom, > + FSL_FM_RX_EXTRA_HEADROOM_MIN, > + FSL_FM_RX_EXTRA_HEADROOM_MAX, > + FSL_FM_RX_EXTRA_HEADROOM); > + fsl_fm_rx_extra_headroom = FSL_FM_RX_EXTRA_HEADROOM; > + } > + > + fsl_fm_rx_extra_headroom = true; I think you mean "fm_check_rx_extra_headroom = true". > + fsl_fm_rx_extra_headroom = ALIGN(fsl_fm_rx_extra_headroom, 16); > + } > + > + return fsl_fm_rx_extra_headroom; > +} > +EXPORT_SYMBOL(fman_get_rx_extra_headroom); Please just check things like this once during module init. Init-on-first-use is unnecessarily complicated, and race-prone. -Scott ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH] cxl: Workaround malformed pcie packets on some cards
Acked-by: Ian Munsie___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [RFC v2 6/7] powerpc: atomic: Make atomic{,64}_xchg and xchg a full barrier
On Fri, Oct 02, 2015 at 07:19:04AM +0800, Boqun Feng wrote: > Hi Peter, > > Please forgive me for the format of my reply. I'm travelling, > and replying from my phone. > > 2015年10月1日 下午7:28,"Peter Zijlstra"写道: > > > > On Wed, Sep 16, 2015 at 11:49:34PM +0800, Boqun Feng wrote: > > > According to memory-barriers.txt, xchg and its atomic{,64}_ versions > > > need to imply a full barrier, however they are now just RELEASE+ACQUIRE, > > > which is not a full barrier. > > > > > > So remove the definition of xchg(), and let __atomic_op_fence() build > > > the full-barrier versions of these operations. > > > > Do you want to do a patch for -stable fixing the current implementation? > > Good idea! I didn't think of this before, and I'd love to do the patch, > but thing is that I'm not able to use my laptop until Oct 10th. > I will send the patch once I'm back. > Does that work for you? Sure, no hurry. ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH v5 18/34] cxlflash: Fix AFU version access/storage and add check
"Matthew R. Ochs"writes: > Correct, downlevel (unsupported) AFUs don't implement the interface_version > register and thus will return -1 at that offset. Cool. It would be good to document that somewhere, either the comment or the commit message, but it's not worth holding up the series for it. I also tend to use the form (var == ~0ULL) for tests like this but that's an aesthetic thing. Reviewed-by: Daniel Axtens Regards, Daniel signature.asc Description: PGP signature ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH] cxl: Workaround malformed pcie packets on some cards
From: Philippe BergheaudThis works around a pcie host bridge defect on some cards, that can cause malformed Transaction Layer Packet (TLP) errors to be erroneously reported. The upper nibble of the vendor section PSL revision is used to distinguish between different cards. The affected ones have it set to 0. Signed-off-by: Philippe Bergheaud Acked-by: Ian Munsie --- Resending this on Philippe's behalf - it seems like the original never made it to linuxppc-dev for some reason. drivers/misc/cxl/pci.c | 28 1 file changed, 28 insertions(+) diff --git a/drivers/misc/cxl/pci.c b/drivers/misc/cxl/pci.c index a5e9771..85761d7 100644 --- a/drivers/misc/cxl/pci.c +++ b/drivers/misc/cxl/pci.c @@ -1035,6 +1035,32 @@ static int cxl_read_vsec(struct cxl *adapter, struct pci_dev *dev) return 0; } +/* + * Workaround a PCIe Host Bridge defect on some cards, that can cause + * malformed Transaction Layer Packet (TLP) errors to be erroneously + * reported. Mask this error in the Uncorrectable Error Mask Register. + * + * The upper nibble of the PSL revision is used to distinguish between + * different cards. The affected ones have it set to 0. + */ +static void cxl_fixup_malformed_tlp(struct cxl *adapter, struct pci_dev *dev) +{ + int aer; + u32 data; + + if (adapter->psl_rev & 0xf000) + return; + if (!(aer = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR))) + return; + pci_read_config_dword(dev, aer + PCI_ERR_UNCOR_MASK, ); + if (data & PCI_ERR_UNC_MALF_TLP) + if (data & PCI_ERR_UNC_INTN) + return; + data |= PCI_ERR_UNC_MALF_TLP; + data |= PCI_ERR_UNC_INTN; + pci_write_config_dword(dev, aer + PCI_ERR_UNCOR_MASK, data); +} + static int cxl_vsec_looks_ok(struct cxl *adapter, struct pci_dev *dev) { if (adapter->vsec_status & CXL_STATUS_SECOND_PORT) @@ -1134,6 +1160,8 @@ static int cxl_configure_adapter(struct cxl *adapter, struct pci_dev *dev) if ((rc = cxl_vsec_looks_ok(adapter, dev))) return rc; + cxl_fixup_malformed_tlp(adapter, dev); + if ((rc = setup_cxl_bars(dev))) return rc; -- 2.1.4 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [v2,5/5] powerpc/pseries: re-use code from of_helpers module
On 10/1/15, Andy Shevchenkowrote: > On Thu, 2015-10-01 at 10:02 +0300, Denis Kirjanov wrote: >> On 10/1/15, Michael Ellerman wrote: >> > On Wed, 2015-09-30 at 19:19 +0300, Andy Shevchenko wrote: >> > > On Fri, 2015-08-14 at 21:51 +1000, Michael Ellerman wrote: >> > > > On Tue, 2015-11-08 at 11:23:09 UTC, Andy Shevchenko wrote: >> > > > > int dlpar_attach_node(struct device_node *dn) >> > > > > { >> > > > > int rc; >> > > > > >> > > > > -dn->parent = derive_parent(dn->full_name); >> > > > > -if (!dn->parent) >> > > > > -return -ENOMEM; >> > > > > +dn->parent = pseries_of_derive_parent(dn >> > > > > ->full_name); >> > > > > +if (IS_ERR(dn->parent)) >> > > > > +return PTR_ERR(dn_parent); >> > > > ^ >> > > > ? >> > > > >> > > > There are cross compilers on kernel.org, or on Ubuntu you can >> > > > just: >> > > > >> > > > $ apt-get install gcc-powerpc-linux-gnu >> > > > $ make ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu-gcc >> > > >> > > Thanks! I tried today and the above the only problem with the >> > > series. >> > > Would you like me to resend whole series? >> > >> > I'd like someone to test it. I gather that you haven't because it >> > didn't >> > compile. >> >> Oh yeah, totally untested: >> >> CC arch/powerpc/platforms/pseries/dlpar.o >> arch/powerpc/platforms/pseries/dlpar.c: In function >> 'dlpar_attach_node': >> arch/powerpc/platforms/pseries/dlpar.c:255:18: error: 'dn_parent' >> undeclared (first use in this function) >>return PTR_ERR(dn_parent); >> ^ >> arch/powerpc/platforms/pseries/dlpar.c:255:18: note: each undeclared >> identifier is reported only once for each function it appears in >> scripts/Makefile.build:258: recipe for target >> 'arch/powerpc/platforms/pseries/dlpar.o' failed >> make[2]: *** [arch/powerpc/platforms/pseries/dlpar.o] Error 1 >> scripts/Makefile.build:403: recipe for target >> 'arch/powerpc/platforms/pseries' failed >> make[1]: *** [arch/powerpc/platforms/pseries] Error 2 >> Makefile:941: recipe for target 'arch/powerpc/platforms' failed >> make: *** [arch/powerpc/platforms] Error 2 > > Like I mentioned earlier this is the only one issue to compile the > series. Can you fix it and try on real HW? Please resend the updates series and then I'll test it. Thanks! > >> >> > >> > I assume you don't have access to hardware to test it on? >> > >> > cheers >> > >> > >> > >> > ___ >> > Linuxppc-dev mailing list >> > Linuxppc-dev@lists.ozlabs.org >> > https://lists.ozlabs.org/listinfo/linuxppc-dev > > -- > Andy Shevchenko > Intel Finland Oy > ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [v2,5/5] powerpc/pseries: re-use code from of_helpers module
On Thu, 2015-10-01 at 10:02 +0300, Denis Kirjanov wrote: > On 10/1/15, Michael Ellermanwrote: > > On Wed, 2015-09-30 at 19:19 +0300, Andy Shevchenko wrote: > > > On Fri, 2015-08-14 at 21:51 +1000, Michael Ellerman wrote: > > > > On Tue, 2015-11-08 at 11:23:09 UTC, Andy Shevchenko wrote: > > > > > int dlpar_attach_node(struct device_node *dn) > > > > > { > > > > > int rc; > > > > > > > > > > - dn->parent = derive_parent(dn->full_name); > > > > > - if (!dn->parent) > > > > > - return -ENOMEM; > > > > > + dn->parent = pseries_of_derive_parent(dn > > > > > ->full_name); > > > > > + if (IS_ERR(dn->parent)) > > > > > + return PTR_ERR(dn_parent); > > > > ^ > > > > ? > > > > > > > > There are cross compilers on kernel.org, or on Ubuntu you can > > > > just: > > > > > > > > $ apt-get install gcc-powerpc-linux-gnu > > > > $ make ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu-gcc > > > > > > Thanks! I tried today and the above the only problem with the > > > series. > > > Would you like me to resend whole series? > > > > I'd like someone to test it. I gather that you haven't because it > > didn't > > compile. > > Oh yeah, totally untested: > > CC arch/powerpc/platforms/pseries/dlpar.o > arch/powerpc/platforms/pseries/dlpar.c: In function > 'dlpar_attach_node': > arch/powerpc/platforms/pseries/dlpar.c:255:18: error: 'dn_parent' > undeclared (first use in this function) >return PTR_ERR(dn_parent); > ^ > arch/powerpc/platforms/pseries/dlpar.c:255:18: note: each undeclared > identifier is reported only once for each function it appears in > scripts/Makefile.build:258: recipe for target > 'arch/powerpc/platforms/pseries/dlpar.o' failed > make[2]: *** [arch/powerpc/platforms/pseries/dlpar.o] Error 1 > scripts/Makefile.build:403: recipe for target > 'arch/powerpc/platforms/pseries' failed > make[1]: *** [arch/powerpc/platforms/pseries] Error 2 > Makefile:941: recipe for target 'arch/powerpc/platforms' failed > make: *** [arch/powerpc/platforms] Error 2 Like I mentioned earlier this is the only one issue to compile the series. Can you fix it and try on real HW? > > > > > I assume you don't have access to hardware to test it on? > > > > cheers > > > > > > > > ___ > > Linuxppc-dev mailing list > > Linuxppc-dev@lists.ozlabs.org > > https://lists.ozlabs.org/listinfo/linuxppc-dev -- Andy Shevchenko Intel Finland Oy ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev