@@ -284,6 +284,7 @@ int css_enumerate(void);
#define IO_SCH_ISC 3
int css_enable(int schid, int isc);
bool css_enabled(int schid);
+int css_disable(int schid);
/* Library functions */
int start_ccw1_chain(unsigned int sid, struct ccw1 *ccw);
@@ -186,6 +186,69 @@ bool css_enabled(int schid)
}
return true;
}
+
+/*
+ * css_disable: disable the subchannel
+ * @schid: Subchannel Identifier
+ * Return value:
+ * On success: 0
+ * On error the CC of the faulty instruction
+ * or -1 if the retry count is exceeded.
+ */
+int css_disable(int schid)
+{
+ struct pmcw *pmcw = &schib.pmcw;
+ int retries = 0;
+ int cc;
+
+ /* Read the SCHIB for this subchannel */
+ cc = stsch(schid, &schib);
+ if (cc) {
+ report_info("stsch: sch %08x failed with cc=%d", schid, cc);
+ return cc;
+ }
+
+ if (!(pmcw->flags & PMCW_ENABLE)) {
+ report_info("stsch: sch %08x already disabled", schid);
+ return 0;
+ }
+
+ for (retries = 0; retries < MAX_ENABLE_RETRIES; retries++) {
+ /* Update the SCHIB to disable the subchannel */
+ pmcw->flags &= ~PMCW_ENABLE;
+
+ /* Tell the CSS we want to modify the subchannel */
+ cc = msch(schid, &schib);
+ /*
+ * If the subchannel is status pending or if a function is in progress,
+ * we consider both cases as errors.
+ */
+ if (cc) {
+ report_info("msch: sch %08x failed with cc=%d", schid, cc);
+ return cc;
+ }
+
+ /* Read the SCHIB again to verify the disablement */
+ cc = stsch(schid, &schib);
+ if (cc) {
+ report_info("stsch: updating sch %08x failed with cc=%d", schid, cc);
+ return cc;
+ }
+
+ if (!(pmcw->flags & PMCW_ENABLE)) {
+ if (retries)
+ report_info("stsch: sch %08x successfully disabled after %d retries", schid, retries);
+ return 0;
+ }
+
+ /* the hardware was not ready, give it some time */
+ mdelay(10);
+ }
+
+ report_info("msch: modifying sch %08x failed after %d retries. pmcw flags: %04x",
+ schid, retries, pmcw->flags);
+ return -1;
+}
/*
* css_enable: enable the subchannel with the specified ISC
* @schid: Subchannel Identifier